Reputation: 6938
I'm trying to adjust the zoom level manually in a fairly simple d3 visualization I'm developing. See: http://jsfiddle.net/TXPcM/
After zooming and panning around (use shift+click to zoom out) press the "Default Zoom" button then try to pan around again. You'll notice a jarring shift as it "resets" to the state prior to the button press.
The code is a bit of a prototype and fairly long winded - but look for the applyZoom function. The intention here was to re-apply the zoom behaviour and thus, hopefully clear out any cached values it might be using. Doesn't seem to work. Suggestions?
Upvotes: 1
Views: 3645
Reputation: 34529
The way to do this is to modify your zoom object, rather than just modifying (or in your case re-creating the zoom).
So grab your zoom
object and do the following:
zoom.translate([x,y])
.scale(scale);
Upvotes: 1
Reputation: 1
i did not look at your code but this d3 google group thread has the answer you're looking for, i think: https://groups.google.com/d/topic/d3-js/-qUd_jcyGTw/discussion
Upvotes: 0