fl_chart icon indicating copy to clipboard operation
fl_chart copied to clipboard

BarChart: Is there a possibility to "shrinkWrap" the chart?

Open ManuelRauber opened this issue 5 months ago • 1 comments

Hi,

at the moment, the BarChart seems to use any available horizontal space.

Is there a possibility to turn this around, so it draws the horizontal size it requires, but not more?

I'm trying to implement this chart (screenshot from Figma):

Image

My current achievement looks like this:

Image

As you can see the horizontal lines span the full available width. The axis is also separated from the chart due to that.

I want to use the groupSpace so I can define the space between each group. Any other placement is not what I need.

So, the issue is, that the chart uses more space than it actually needs.

Is there a way to render it only in the size it really needs, or do I need to calculate that beforehand and put the chart into a SizedBox?

ManuelRauber avatar Jul 21 '25 08:07 ManuelRauber

Hello 👋

There doesn't seem to be anything on the BarChart or BarChartData classes to manipulate the space/width.

My guess is that at the moment you just have to wrap it in something with a fixed size, like a SizedBox.

It would be pretty useful if there was a shrinkWrap option on the chart data classes to only take up the necessary space though! 😊

alettsy avatar Jul 23 '25 00:07 alettsy