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

Uncaught TypeError: Cannot read property 'call' of undefined when zoom is defined #135

Closed ecollett1 closed 5 years ago

ecollett1 commented 6 years ago

I'm getting this error when I try to double click and zoom for a map I created:

d3.v3.min.js:3 Uncaught TypeError: Cannot read property 'call' of undefined
    at o (d3.v3.min.js:3)
    at Object.u (d3.v3.min.js:3)
    at Rn (d3.v3.min.js:1)
    at Tn (d3.v3.min.js:1)

I'm using this version:

  <script src="https://d3js.org/d3.v3.min.js"></script>

This is what my code looks like to implement zoom:

var zoom = d3.behavior
            .zoom()
            .on("zoom", zoomed)
            .scaleExtent([minZoom, maxZoom]);

var svg = d3.select(canvasSvg).append("svg")
            .style("width", "inherit")
            .style("height", "inherit")
            .style("cursor", "move")
            .call(zoom)
            .append("g").attr("class", "entire-map");

All the other zoom pieces work (scroll, buttons used to zoom, and a click to zoom I made). Let me know if there's any other information you need for the problem, sorry I don't know exactly what else to give. I should be able to share any pieces of the code you might need to see, I'm using Polymer 2 with d3 just fyi.

mbostock commented 5 years ago

Please use Stack Overflow tag d3.js to ask for help. Stack Overflow provides a better collaborative forum: thousands of D3-related questions have been asked there, and some answers may be relevant to you.

When asking for help, please include a link to demonstrate the issue, preferably as an Observable notebook. It is often impossible to debug from code snippets alone. Isolate the issue and reduce your code as much as possible before asking for help. The less code you post, the easier it is for someone to debug, and the more likely you are to get a helpful response.

If you have a question about D3’s behavior and want to discuss it with other users, also consider the d3-js Google Group or joining the d3-js Slack.

Thank you! 🤗