score:1
I guess that could be done if I call the
zoom.translateBy
andzoom.scaleBy
Both of these are relative, i.e. they are added to / multiplied by the current transform, they don't set it. So if the current scale was 0.5 and you use scaleBy
with a value of 1.0, you would still get a scale of 0.5 (because 0.5 * 1.0 == 0.5).
To "sync" the absolute values between two zooms you would instead use zoom.translateTo
and zoom.scaleTo
respectively.
Instead of setting the individual components of the zoom transform, a more direct approach would be to set the whole transform. For this you would use zoomTransform
on the source node (or use the event.transform
of a zoom event) to get the current transform and then set that transform on the target with zoom.transform
.
Source: stackoverflow.com
Related Query
- Zooming and panning 2 corresponding images in d3.js by same amount?
- D3.js Zooming and panning a collapsible tree diagram
- D3.JS time-series line chart with real-time data, panning and zooming
- Zooming and Panning a Mercator Map centered on the Pacific using d3.js
- D3 Canvas graph zooming and panning slow redraw in Webview
- How do you translate HTML elements along with SVG elements when zooming and panning with D3
- zooming and panning - upgrading d3 code to d3.v4
- d3 how to tie text to top right corner of view port while zooming and panning
- D3.js: How to keep marker and text on same position when zooming in and out
- D3 v4 Zoom x-Axis Zooming and Panning Issue
- D3 + Google Maps + Paths + Labels Bug witih Panning and Zooming
- Why doesn't the same group render a correct line chart and corresponding range chart?
- d3 v2 Prevent Zooming and Panning Chart Outside Viewport
- How can I detect panning and zooming by the user with d3 zoomBehavior?
- D3: keeping position of SVG's relative while panning and zooming
- d3.js - Allow brushing and zooming on same chart
- d3: hovering over words in text at the same time highlighting the corresponding bars and make word in text clickable
- How do I fix zooming and panning in my cluster bundle graph?
- D3.js zooming and panning - lock on y axis
- Ghost line path when zooming and panning a D3 chart
- how to make scatterplot on a line chart zooming and panning correspondingly in D3.js
- Having trouble panning and zooming on my d3 map
- Panning and zooming to an SVG element
- D3 Zoom & Pan - How to enable zooming & panning anywhere on the chart and restrict showing circle within the range while panning & zooming
- Having problems panning and zooming data received by d3.json in a line chart
- D3 keep line width same when zooming
- D3: How do I set "click" event and "dbclick" event at the same time?
- How to change speed of translate and scale when zooming in and out in D3 (using zoom.on & d3.event.translate, d3.event.zoom)?
- D3: How to handle zooming and tooltips in a single chart?
- Limiting domain when zooming or panning in D3.js
More Query from same tag
- d3js get data from multidimensional array
- setting css of axis in d3.js
- D3.js pattern not working with arc or donut graph
- D3 chart error bars other than stroke type
- jsdom svg transform transitions - Cannot read property 'baseVal' of undefined
- d3 with bootstrap tooltip: titles not working with data updating
- NVD3 - x axis labels fail
- Linear/Incremental rotation animation with transition
- how to write an interactive d3 component with React in ES6?
- Why does d3 axis class name change axis format?
- Using d3.interpolateString for a MM:SS transition
- Remove black SVG fill in C3.js time-series chart
- d3js: how to bind data within a single object
- Accessing the ids from the JSON files to be used in D3
- Reading CSV with multiple tables in Javascript
- Can't trigger POST-JSON request with d3 typings
- Webpack warning when building d3-tip
- Zoom to bounding box of path on externally loaded svg using D3
- D3 line chart giving wrong values at highest number
- Graph won't reload properly into D3 force layout
- connect javascript with html (a href)
- Day/Hour Heatmap + mySQL
- d3 - updating data doesnt cause a refresh
- D3 - Update chart based on data keys
- Reading an arbitrary number of csvs with javascript/D3
- Why is the 'fill' attribute colouring the entire svg area instead of only the path?
- Enter() statement with a function from one data array to multiple arrays? (Adding multiple Gradient Paths)
- d3.js v5 - d3.json reads file locally on windows but not on linux?
- Pulling data from a database for a C3js chart
- d3js 4 get coordinate of path transition