D3.js v4 - set padding for bar chart -
i'm trying add padding bar chart in d3.js v4.
in v3, done in following way:
var x = d3.scaleordinal() .domain(["a", "b", "c"]) .rangeroundbands([0, width], 0.1);
however, in v4, rangeroundbands
eliminated. know equivalent code in v4 (without padding) is:
var x = d3.scaleband() .domain(["a", "b", "c"]) .range([0, width]);
according this, should use band.padding
set padding. tried this:
var x = d3.scaleband() .domain(["a", "b", "c"]) .range([0, width]) .padding(0.1);
but doesn't seem make impact. doing wrong?
in d3 v4.
this how define axis:
var x = d3.scaleband() .range([0, width]) .round(true) .padding(.1);//set padding //set domain x.domain(data.map(function(d) { return d.letter; })); //define x axis var xaxis = d3.axisbottom() .scale(x);
working bar chart d3 v4 sample here
Comments
Post a Comment