d3 / d3-zoom

Pan and zoom SVG, HTML or Canvas using mouse or touch input.
https://d3js.org/d3-zoom
ISC License
507 stars 143 forks source link

Problem with zoom after upgrading d3 v4.3 to v4.4 #73

Closed deristnochda closed 7 years ago

deristnochda commented 7 years ago

I recently did some line charts with zoom functionality using the d3 library hosted on d3js.org. Today I noticed that the zoom is not working anymore because d3.event.transform produces NaNs (see the console log in the second link). Below is an (hopefully minimal enough) example,

with v4.3

with v4.4 hosted on d3js.org

Did I do something wrong?

mbostock commented 7 years ago

Yes. You’re calling zoom.extent with two arguments:

.extent([100, 100], [width-100, height-100])

You should be calling it with one argument:

.extent([[100, 100], [width-100, height-100]])

Alternatively you can remove the call to zoom.extent entirely and use the default behavior which is to allow zooming anywhere within the SVG.

http://bl.ocks.org/mbostock/ad30855f79f2fdfa40d10a8604caff22

margaretaNikolov commented 7 years ago

Use the amazing D3 library to animate a path on a Leaflet map with d3 v4.8.0 zoom does not work well. I have coopied the same GeoJson, and i am using map.on("zoom",reset) event, but on map zoom out my svg goes out from Manhattan

mbostock commented 7 years ago

@margaretaNikolov Please use Stack Overflow tag d3.js to ask for help. For more, please read my guide on Asking for Help.

margaretaNikolov commented 7 years ago

Ok. Thank you for your help!