Skip to content

Session 3A: D3 v4 (modular)

Sara Quigley edited this page Nov 21, 2015 · 14 revisions

D3-v4 (modular)

Notes

Version 3.4 is a major new release, and is not backward compatible with prior releases.

Why modules?

  • currently d3 is monolithic
  • eliminate the parts you don't need for increased performance
  • decoupled for easier understanding
  • monolithic is hard to keep track of, hard to test, hard to contribute to
  • the main goal is to make it easier for people who want to learn or contribute to d3
  • to set a standard way for people to create plugins for d3

Components exist in separate repository in github. (d3 is now a github org.) Each module has its own readme with a real world example, plus the API reference for just that module.

There will still be a default build of d3.v4 (d3.v4.js) which will represent a concatenation of all of the modules that go into the d3 build.

Both the code and the release cycle are decoupled. Mike is planning on writing a tutorial about how to write a plugin under this new structure. Hello World d3 plugin would contain the starter template for creating a plugin.

A new way to make a custom build that contains only the code that you need. Besides concatenating files together, you can make a precise custom build using a tool called rollup.js (like browserfy or webpack) which also understands the syntax tree and only includes the code that you're using. A rollup build would only contain a portion of a module.

Note that if people still have d3 cached in their browser, it will still load faster than any minified d3 custom d3 build.

"ES6" is really just ES5 plus the ES6 module system, which is the import and export statements.

index.js file is at the top level of each module, containing export statements. The index.js takes care of exporting the symbols so that you don't have to memorize the exact path of the symbols that are exported.

Resources

github.com/d3: self-contained and independent modules http://rollupjs.org/

Outcomes

Clone this wiki locally