Getting error on rangeRoundBands method when using D3.js version 4 for ordinal scale. Below is the example in D3.js version 3.
https://bl.ocks.org/mbostock/7440840
However with version 4 below code throws an error.
var x = d3.scaleOrdinal()
.domain(data.map(function(d) { return d.name; }))
.rangeRoundBands([0, width], 0.1);
Instead of this:
var x = d3.scaleOrdinal()
.domain(data.map(function(d) { return d.name; }))
.rangeRoundBands([0, width], 0.1);
In d3 v4
It should have been:
var x = d3.scaleBand()
.rangeRound([0, width])
.padding(0.1);
working code here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With