spotify/reactochart

Upgrade to d3 4.x

jfsiii opened this issue · 3 comments

As of v4, d3 has been broken up into many modules (e.g. d3-scale, d3-selection, etc). There are also some API changes.

Not only is it a good idea to stay on the current major version, but the final size would drop quite a bit if reactochart only imports the d3 packages it needs.

I've ported a few examples and projects from 3.x to 4.x and it's relatively simple. Changing import d3 from "d3" to import * as d3 from 'd3' then doing a search-and-replace for the new methods names (old: d3.scale.ordinal new: d3.scaleOrdinal, etc) will get you pretty far. Converting to statements like import { scaleLinear, scaleOrdinal } from 'd3-scale' should be the ultimate goal, but I typically save that for a second pass after things are converted and working.

The changes to selections are probably the most substantial but, in my experience, don't take much effort to convert.

Thanks @jfsiii - this is definitely on the roadmap. We're not using selections at all, so it shouldn't be too difficult to upgrade.

FYI Reactochart version >0.3.0 is using d3 v4, I'll leave this open though as a reminder to myself - I still need to only import the d3 packages that are actually necessary, currently we're still importing from d3.

Closing in favor of #154