-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "Cannot read property 'property' of undefined" #183
Comments
This implies that you are invoking the zoom behavior with an undefined selection. I’m not sure why that would be based on your code snippet. I also note that you’re combining the D3 default bundle ( 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! 🤗 |
Edit: I see now you said the error doesn’t occur until you wheel. At any rate, you should post a reproduction of your error if you want help debugging. It’s practically impossible to guess what could be wrong from a snippet, and I would be wasting both of our time speculating. Good luck! |
Sorry about that! Here's a code pen that shows the same console error with a basic setup: https://codepen.io/shofman10/pen/BXxKxJ |
The problem is that you’re invoking the zoom instance on zoom: selection.on("zoom", zoom); You probably mean to call your zoom event handler instead? selection.on("zoom", zoomed);
function zoomed() {
console.log(d3.event);
} |
That worked and I was able to get it zooming in/out after that :D sooooo happy thanks! |
Hi, when I try to add zoom functionality for regular HTML content, I can't seem to get it to work. I'm importing the right plugins with NPM:
import * as d3 from 'd3';
import * as d3Zoom from 'd3-zoom';
import * as d3Select from 'd3-selection';
and then on load of my app I'm calling:
let zoom = d3.zoom();
let selection = d3.select('.seat-selector-content');
selection.call(d3.zoom().scaleExtent([1, 8]).on("zoom", zoom));
No errors on initial load but when i try to use my mouse wheel to zoom on the html, I get the error "Cannot read property 'property' of undefined".
If I click through the console error to the code it comes to this function:
function zoom(selection) {
selection
.property("__zoom", defaultTransform)
.on("wheel.zoom", wheeled)
.on("mousedown.zoom", mousedowned)
.on("dblclick.zoom", dblclicked)
.filter(touchable)
.on("touchstart.zoom", touchstarted)
.on("touchmove.zoom", touchmoved)
.on("touchend.zoom touchcancel.zoom", touchended)
.style("touch-action", "none")
.style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
}
The text was updated successfully, but these errors were encountered: