diff --git a/index.html b/index.html index b286589..e9d6977 100644 --- a/index.html +++ b/index.html @@ -181,7 +181,7 @@ var visRect = jkjs.zui.computeVisibleRect(translate, scale, w, h); overview.updateCameraRect(canvasRect, visRect, isSmooth); pool.onViewportChange(box, visRect, scale, isSmooth); - }, [ 1e-2, 3 ]); + }, [ 1e-6, 12 ]); // be generous with zooming! FIXME: adapt zoom extent depending on minTimeDiff #34 function updateViewport() { zui.move(0, 0, false); diff --git a/js/typepool.js b/js/typepool.js index e07c9cc..556776a 100644 --- a/js/typepool.js +++ b/js/typepool.js @@ -707,7 +707,13 @@ function TypePool(busy, overview, setBox, onVC, cw, rh) { var hGrids = []; var newHGrids = []; var gridSize = 100; - function updateGrid(svgport, viewport, scale, smooth) { + function updateGrid(_ /*svgport*/, viewport, scale, smooth) { + var vrect = { + x: 0, + y: 0, + width: viewport.width * scale, + height: viewport.height * scale + }; if(smooth || inTransition) { vGrids.forEach(function(s) { s.remove(); @@ -746,8 +752,8 @@ function TypePool(busy, overview, setBox, onVC, cw, rh) { s.attr({ "x1": x, "x2": x, - "y1": svgport.y - gridSize - (viewport.y * scale - gridSize) % gridSize, - "y2": svgport.height + gridSize + "y1": vrect.y - gridSize - (viewport.y * scale - gridSize) % gridSize, + "y2": vrect.y + vrect.height + gridSize }); }); newVGrids = []; @@ -760,8 +766,8 @@ function TypePool(busy, overview, setBox, onVC, cw, rh) { while(dist > gridSize * 1.5) { dist /= 2; } - var yStart = svgport.y - dist - (viewport.y * scale - dist) % dist; - for(var yPos = yStart;yPos < svgport.y + svgport.height;yPos += dist) { + var yStart = vrect.y - dist - (viewport.y * scale - dist) % dist; + for(var yPos = yStart;yPos <= vrect.y + vrect.height;yPos += dist) { newHGrids.push(yPos); } adjust(hGrids, newHGrids, "line", { @@ -773,8 +779,8 @@ function TypePool(busy, overview, setBox, onVC, cw, rh) { hGrids.forEach(function(s, ix) { var y = newHGrids[ix]; s.attr({ - "x1": svgport.x - gridSize - (viewport.x * scale - gridSize) % gridSize, - "x2": svgport.width + gridSize, + "x1": vrect.x - gridSize - (viewport.x * scale - gridSize) % gridSize, + "x2": vrect.width + gridSize, "y1": y, "y2": y }); diff --git a/spec.md b/spec.md index 60fa256..476b3df 100644 --- a/spec.md +++ b/spec.md @@ -12,6 +12,10 @@ apply and they must be globally unique). Colors are all valid CSS colors (named, hexadecimal, rgb, …) A set of good colors is `["#80b1d3", "#4daf4a", "#fb8072", "#ff7f00", "#eb9adb"]`. Timestamps are UNIX timestamps in seconds since standard epoch. +Keep in mind that the unit for positions is determined by the smallest difference +between events. It might be better to bin timestamps into coarser steps when +the input times are too granular (the visualization might become flat or invisible). +Binning also helps to make co-occurring events behave more intuitive. ## Patient file creation format