Migrating D3 v3 code to v4

I was messing around with D3 v4 and mentioned that version 4 requires some code changes. This was in the context of a simple map of California reservoirs.

Here are the specific changes I had to make:

  • d3.geo.albersUsa to d3.geoAlbersUsa
  • d3.geo.path to d3.geoPath
  • d3.geo.graticule to d3.geoGraticule
  • queue to d3.queue

Three of the four are a result of the "great namespace flattening" mentioned several times in the wonderfully detailed CHANGES.md in the main D3 repo. The fourth difference was due to queue being included as a part of D3 rather than a separate library.

For more on what's different in v4, in addition to the changelog linked above, checkout the the slidedeck Irene Ros posted covering most changes in v4.