Skip to content

Changes in dc.js version 3.0

cwolcott edited this page Sep 5, 2018 · 5 revisions

dc.js version 3.* is compatible with D3 versions 4 and 5. Thanks to Deepak Kumar for all his effort on the port. Use dc.js version 2.* if you still need compatibility with D3 version 3.

We've made every effort to keep the library backward compatible. Most of the changes you will need to make are due to the great namespace flattening of D3V4, documented in d3/CHANGES.md.

However in a few places the dc.js API or behavior has changed due to the upgrade. We also deprecated a few things, and you'll get browser console warnings unless you change your code.

We'll document those changes here. Since this is a wiki, feel free to add any changes we've missed!

Scales

D3v4 requires us to use d3.scaleBands instead of d3.scaleOrdinal for ordinal coordinate grid charts. If you use d3.scaleOrdinal it should be converted automatically with a warning.

Axes

Instead of d3.svg.axis.orient(), d3 now provides separate classes d3.axisLeft, d3.axisRight, etc. dc.js will attempt to guess which one you meant, but this means you need to call useRightAxis before fetching/manipulating .xAxis

xUnits

xUnits used to take a function with three arguments, passing the entire domain array as the third argument. This was never conformant with d3 interval range functions (where the third argument is step), and it broke with D3v4. In particular, dc.units.ordinal used to be a real function but now it's just a magic value which causes coordinate grid charts to go into ordinal mode.

Colors

dc.js 3.0 introduces dc.config.defaultColors() for setting the palette of all ordinal charts in one place. For backward compatibility, dc.js 3.0 maintains a copy of the old d3.schemeCategory20c that was removed in D3v5. You'll be warned if you don't change the default colors.

Stacks

The new d3.stack is much more powerful. dc.stackMixin converts data under the hood back and forth to the new data format and it seems to be compatible with streamgraphs and positive/negative stacks. However, if you were modifying d3.layout.stack through .stackLayout() that obviously won't work anymore since the API is completely different.

lineChart.interpolate

Use lineChart.curve instead, which takes a curve factory instead of a string. interpolate (and tension) will be supported for a while with a deprecation warning.

geoChoroplethChart.projection

We're still defaulting to d3.geoAlbers but you'll get a deprecation warning - null is the appropriate default for d3.geoPath.

Brush and Zoom behaviors

d3.brush and d3.zoom are quite different from the old d3.svg.brush and d3.behavior.zoom. We think we have reproduced the old behavior faithfully, but there are likely to be differences or bugs.