d3.js - How to add space between bars in a grouped bar chart in a nvd3 grouped multibar chart? -
i'm trying add space/padding nvd3 multi bar chart. "groupspacing" not need, since adds space between groups. i'll need space between each bar inside group. found 1 link in github support. can post solution or tweak?
i found d3 example of grouped bar chart. in example helpful me.
thanks.
i have draw d3 group barchart:
you can adjust groupspacing change code on line 56:
var groupspacing = 6;
technically achieve change width of each rects' width:
var barsenter = bars.enter().append('rect') .attr('class', 'stm-d3-bar') .attr('x', function(d,i,j) { return (j * x1.rangeband() ); }) .attr('y', function(d) { return y(d.y); }) .attr('height', function(d) { return height - y(d.y); }) .attr('width', x0.rangeband() / bardata.length - groupspacing ) .attr('transform', function(d,i) { return 'translate(' + x0(d.x) + ',0)'; }) .style("fill", function(d, i, j) { return color(data[j].key); });
hope helps understand how can achieve in d3.
Comments
Post a Comment