D3js: How do I clear the zoom scale set by the d3.zoom event?
The zoom scale is stored in your zoom object. I'm guessing you have a line of code that looks like:
var zoom = d3.behavior.zoom()
Getting the scale from that object is simple:
zoom.scale()
To zoom out x2:
zoom.scale( zoom.scale()/2 )
Translation works the same way, with zoom.translate()
and zoom.translate( [x, y] )
to get and set.
To keep the display transform in sync with the zoom, just make sure that when you update one, the other is also updated.