react-d3-components icon indicating copy to clipboard operation
react-d3-components copied to clipboard

Width of each bar in groupedBars

Open psudeepta opened this issue 9 years ago • 2 comments

@codesuki Is it possible to set the width of each bars in groupedBars? Irrespective of data, I would like to set specific width to each bar. Could you please help me with this?

psudeepta avatar Nov 28 '16 11:11 psudeepta

I'll have a look at it when I am back at work. Off the top of my head I am not sure how to do it. Have to look at the code.

codesuki avatar Nov 28 '16 11:11 codesuki

I just checked. With CSS is doesn't seem possible. You would have to change the code (maybe send a pullreq?). https://github.com/codesuki/react-d3-components/blob/master/src/BarChart.jsx#L53 If BarChart would have a property barWidths that is an array of doubles [0.1, 0.2, ...] that sum up to 1.0. Then we could change the calculation width={xScale.rangeBand() / data.length} to width={xScale.rangeBand() * barWidths[i]}. That should work. Just a first idea though.

codesuki avatar Nov 29 '16 01:11 codesuki