Closed G2Jose closed 5 months ago
Yep, @G2Jose, there's currently no easy way to set a fix width for the bar charts, as we dynamically calculate barWidth based on innerPadding, width of the chart, and the number of data points. This could be a nice feature improvement, if someone wants to take a stab at it. I may circle back to this myself once I have some time.
what i ended up doing was adding a prop that is expectedDataLength
so the bar width gets calculated off of that instead of reading data.length
Question
Hello, I'm looking to make multiple bar charts, but where the bars have the same fixed width. I can't seem to find an obvious way to do this.
Background Info/Attempts
Here's what I've tried:
I tried using the
transform
property inPath
to scale down bars to a specified targetWidth. Something like:This does work for making bars the same size, but unfortunately this moves all my bars to the left, so they no longer line up with the axis. I tried adding a
translateX
to thetransform
prop above, but that doesn't seem to have any effect.For context, I need to show stats on multiple graphs, each of which will have different numbers of data points. Currently without scaling the bars, they can vary wildly in size. Charts that have just one datapoint for example, will have drastically different bar widths than ones that have say 20.