Skip to content
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

TypeError: setting getter-only property "event" #1396

Closed
Justus-Maier opened this issue Apr 4, 2018 · 8 comments
Closed

TypeError: setting getter-only property "event" #1396

Justus-Maier opened this issue Apr 4, 2018 · 8 comments
Milestone

Comments

@Justus-Maier
Copy link

I'm using d3-ng2-service to integrate D3 into Angular, now I'm also trying to use dc.js (3.0 branch), but I get errors when trying to draw a simple barchart, because d3-ng2-service builds it's own D3 with the modularised parts, and dc.js brings another instance of D3 (copying inbetween gives read-only errors).

TypeError: setting getter-only property "event"
Stack trace:
_dc/dc.coordinateGridMixin/_chart._brushing@webpack:///./node_modules/dc/dc.js?:3956:9

@kum-deepak did you touch #1175 yet? Can't follow your reference to it..
It feels the solution for me lies within..

How can I inject my instance of D3 into DC.js?

@gordonwoodhull
Copy link
Contributor

gordonwoodhull commented Apr 4, 2018

Sorry, no, we're not moving to webpack babel etc. But that's not the problem here.

The problem here is just what it says: we're trying to set d3.event and we shouldn't do that. I'm working on a merge of #1385 which will fix this. Hopefully this is the only problem.

@gordonwoodhull gordonwoodhull added this to the 3.0 milestone Apr 4, 2018
@gordonwoodhull gordonwoodhull changed the title D3(v4) Dependency Injection with d3-ng2-service TypeError: setting getter-only property "event" Apr 4, 2018
@Justus-Maier
Copy link
Author

@gordonwoodhull what about importing only the parts of D3 that are actually used by DC.js? How would you interface with d3-ng2-service?

@gordonwoodhull
Copy link
Contributor

Sorry, I don't know anything about d3-ng2-service. I agree it's going to be a problem if you try to use dc.js with a custom build of d3 designed for some other library.

I'd consider adding a custom build of d3 to dc.js (e.g. an index.js for rollup to assemble the relevant bits). I don't know if that would help you or not. I'm focused on getting 3.0 out the door, so for now I recommend using the kitchen-sink d3.js.

@Justus-Maier
Copy link
Author

The index.js approach will be fine I guess. That will deduplicate the d3(-*) dependencies and reduce overall footprint of DC.js. Obviously treeshakable chart modules would be better, when only using one or a few charts from DC.

@gordonwoodhull
Copy link
Contributor

Yes, rollup supports tree shaking - I think we'd just need to import the specific functions needed, rather than importing *.

I hope to break up dc.js into dozens of rollup modules, but it's a huge effort so I hope to find volunteers to help with that. I guess that would be dc.js 4.0.

Contributions are welcome for other module systems - I just don't personally intend to learn/support anything but rolllup.

@kum-deepak
Copy link
Collaborator

@Justus-Maier can you please try the current 3.0 branch, it no longer tries to assign d3.event.

@Justus-Maier
Copy link
Author

@kum-deepak thank you, I'm no longer encountering this error.

@gordonwoodhull
Copy link
Contributor

Glad to hear it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants