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

D3 v4.0 namespaced imports are actually encouraged #5

Closed
caesarsol opened this issue Jul 25, 2016 · 1 comment
Closed

D3 v4.0 namespaced imports are actually encouraged #5

caesarsol opened this issue Jul 25, 2016 · 1 comment

Comments

@caesarsol
Copy link

Hello,
there is a small inaccuracy in your documentation.
In the README you say:

A small thing — it's possible to use only parts of d3. For example: import {voronoi as d3Voronoi} from 'd3-voronoi'; instead of d3.voronoi, and import {lab} from 'd3-color'; instead of d3.color.lab), but nobody uses it that way, so examples of the import style are hard to find (and it's often not obvious which name will be exported (d3-geo exports geoArea and geoBounds rather than area and bounds).

Actually, the namespacing is a powerful feature and using it is encouraged in d3v4:

If you don’t care about modularity, you can mostly ignore this change and keep using the default bundle. However, there is one unavoidable consequence of adopting ES6 modules: every symbol in D3 4.0 now shares a flat namespace rather than the nested one of D3 3.x. For example, d3.scale.linear is now d3.scaleLinear, and d3.layout.treemap is now d3.treemap.

See the official migration guide (and specifically this namespace migration table for the d3-geo library)

@joelburget
Copy link
Owner

I agree, modularity is the bomb. I wouldn't ever discourage it! But I maintain there are very few examples of its use today.

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

2 participants