Note that there are some explanatory texts on larger screens.

plurals
  1. POFocus/Context Brushing + Pan/Zoom graph - How to limit panning
    primarykey
    data
    text
    <p>I've managed to make a d3.js line+area graph sync with focus/context brushing and pan/zoom, with a small example here:</p> <p><a href="http://jsfiddle.net/MtXvx/8/" rel="nofollow noreferrer">http://jsfiddle.net/MtXvx/8/</a></p> <p>I'm having trouble limiting the panning to stop at the original domain boundaries, while also working nicely with the brush. This is to prevent users from losing the graph in their view. </p> <p>While I have tried manually detecting when panning has exceeded boundaries and then setting zoom.translate([0,0]), such as in these examples: <a href="https://stackoverflow.com/questions/15069959/d3-js-scatter-plot-zoom-drag-boundaries-zoom-buttons-reset-zoom-calculate-m">d3.js scatter plot - zoom/drag boundaries, zoom buttons, reset zoom, calculate median</a> <a href="https://stackoverflow.com/questions/10422738/limiting-domain-when-zooming-or-panning-in-d3-js">Limiting domain when zooming or panning in D3.js</a> <a href="https://stackoverflow.com/questions/15069959/d3-js-scatter-plot-zoom-drag-boundaries-zoom-buttons-reset-zoom-calculate-m?lq=1">d3.js scatter plot - zoom/drag boundaries, zoom buttons, reset zoom, calculate median</a></p> <p>...as I do here at line 183:</p> <pre><code> //If exceed original domain, limit panning by resetting translate if (x.domain()[0] &lt; x0.domain()[0]) { zoom.translate([0, 0]); } </code></pre> <p>The problem occurs when: 1) Create a brush region in the small context graph 2) Pan the big focus graph all the way towards the earliest date 3) Graph jumps when panning is almost at the boundary</p> <p>Would appreciate any help to prevent the jumping from happening, or if there is any other way to limit the panning (and eventually the zooming out too) to the original domain boundaries.</p> <p>Regarding limiting the zoom-out, setting:</p> <pre><code>var zoom = d3.behavior.zoom().x(x).scaleExtent([1,10]).on("zoom", zoomed); </code></pre> <p>...does not work nicely because the zoom-out would be limited to the brush region instead of the full extent of the graph data.</p> <p>Much thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload