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 when trying to implement zoom in application #32
Comments
I see you edited the code snippet, but if you want to look at d3.event, you need to import it, too: import { select, event } from 'd3-selection'; And you need to refer to If that doesn’t do it, I am not a Webpack expert, so unfortunately I can’t give specific advice on how to configure Webpack to import from D3’s ES6 modules. I believe that Webpack does not observe jsnext:main (webpack/webpack#1979), so you may need to configure Webpack to import from node_modules/d3-selection/index.js rather than using the provided UMD bundle. Per d3/d3-brush#9 it appears possible to change how Webpack resolves d3-selection, so you can point it to node_modules/d3-selection/index.js rather than the generated UMD bundle (d3-selection.js). Related, it seems that Babel / Babelify / Browserify observes the __esModule flag that was added in recent builds of the D3 bundles (see d3/d3#2850), and that toolchain at least appears to correctly import the event binding… See also the comment on d3.event regarding bundlers. |
I had hoped that I didn't make an error when editing the code snippet, but it seems that I did. I had tried
as well as
which is where my hybrid Thank you |
Here is how you can get the live event with webpack, with require: d3.getEvent = () => require("d3-selection").event; This way I'm sure I always get a fresh binding on d3.event ! |
To use @ocombe's solution with ES5 d3.getEvent = function(){return require("d3-selection").event}.bind(this); |
Using a modified solution of @ocombe's above, I had success with the following:
And then to use it...
|
Still doesn't work for me how to apply your fix in my code ? same problem with Angular but it was working before ....
When I click on the SVG :
When I scroll :
I have tried to to this but this doesn't work :
|
I'm experiencing the same bug as @Yohandah with |
I'm also getting the |
Please upgrade to latest version to solve the issue . it worked for me. |
I am trying to port existing working code from d3 version 3.5 to 4.0. I am getting the error
Uncaught TypeError: Cannot read property 'button' of null (zoom.js:82)
when trying to implement zooming in a webpacked React application. I have written a simple example which demonstrates the issue:Clicking or scrolling on the svg rect causes the error to be thrown. It is entirely possible that I am messing up the new syntax. Can you please help?
Stack trace:
edit: fixed code snippet
The text was updated successfully, but these errors were encountered: