score:0
Accepted answer
The second parameter of zoom.scaleTo(svg, d3Zoom.zoomIdentity)
accepts a k
scaling factor (e.g., 2 for 2x zoom). The method zoom.scaleTo
is intended to be used when you want to set the zoom level, but not the translation (x and y positions).
If you want to set the whole transform to the zoom identity (which resets both the zoom level and the x and y positions), the method is zoom.transform(svg, d3Zoom.zoomIdentity)
.
If you indeed just want to reset the scale, you can use zoom.scaleTo(svg, d3Zoom.zoomIdentity.k)
, or simply zoom.scaleTo(svg, 1)
.
Source: stackoverflow.com
Related Query
- D3 zoom breaks mouse wheel zooming after using zoomIdentity
- D3.zoom jumps when using mouse wheel after programmatically zoom
- d3.js pan and zoom jumps when using mouse after programatic zoom
- Zoom out D3 Force-Directed Graph without using mouse wheel
- zoom jumps when using mouse after zoom In/out
- Restore mouse wheel zoom functionality after a ".on("wheel.zoom", null)"
- Re-render HTML after zoom using Dagre d3
- Mouse Wheel Zoom Map - DataMaps.js
- Constraints for D3 mouse wheel zoom behaviour
- Get mouse position in SVG co-ordinates after zoom
- D3.js: Zooming the x-axis and data with mouse wheel scroll
- D3 V4 zoom via mouse and programmatic are zooming independent from each other
- d3: disabled "dblclick.zoom" default behaviour returns after using custom zoom
- How to implement mouse wheel zoom in D3 like Google Map with overlay and Ctrl + Scroll event?
- Bubbles in Map not getting zoomed on Map zoom on mouse wheel in d3
- performing zoom with mouse wheel programmatically for D3 parallel coordinates plot
- d3 map - After using blur filter, zoom does not work properly
- Mouse events stop working after d3 graph, zoom loads
- d3-js mouse wheel problems when activating and deactivating zoom behavior
- d3.js v4 zoom via mouse wheel and programmatically
- Holding Shift prevents mouse wheel zoom in firefox
- First zoom glitches after page load using D3
- D3JS v5 Zoom - The transform value changes between zoom on button and mouse wheel
- D3.js: Position tooltips using element position, not mouse position?
- brush on rotated lines using d3 to create zoom effect
- Zooming and Panning a Mercator Map centered on the Pacific using d3.js
- Using d3-3d with pan & zoom while retaining rotation
- Get coordinates of mouse click on svg using d3
- D3 v4 Brush and Zoom on the same element (without mouse events conflicting)
- D3 click coordinates after pan and zoom
More Query from same tag
- D3: Can I have an svg transition based on items in a list?
- How to pass different arrays to d3.svg.line() function?
- Javascript heatmap.js plugin to show data step by step in D3.js
- D3 - Dynamically change text of node in tree when pressing a button
- D3.js In Action, code example not working
- Responsive d3 bubble chart
- D3 force layout: how to update link color?
- Changes to CSS are not reflected in the d3.js site
- d3 - enter - appends too many elements, as if data is not bound
- modal of AngularJS + d3 - open() str argument
- Data structure for a family tree with multiple partners and siblings?
- How to pass ES6 rest parameters dynamically in d3.group
- d3 area between two line graphs
- Error parsing d=""
- How do I override the .value() in a D3 function
- d3.js charts framework modelling
- Scaling in d3js
- The use of a data array in the d3.js scatter file instead of an external data file
- Ordinal scale category10 mapping everything to same color
- d3 chart is showing some decimal value in the X axis tick, instead of showing the date and time
- Why is d3 keeping some of my elements when I want it to remove all of the elements?
- NVD3: multiChart wrong format for series
- d3 data scaling issue
- semicircle bar graphs with extended edges using d3.js
- How best to work with raw (uncounted) data in d3.js?
- D3: change font size of axis labels
- 2D Array Not Translating to D3 Map Coordinates
- Can't read json in D3
- Is there a way to tell crossfilter to treat elements of array as separate records instead of treating whole array as single key?
- Conditionally build group in d3