Figma Support Forum

Change Height of Bar Dynamically

I’m trying to create an autolayout bar chart that dynamically changes the size of the bars when bars are removed. Any ideas? Something like this

This should be very easy to do with auto-layout set to fill container

1 Like

That appears to be working but I still don’t understand how you’re doing it for one main reason. The white space between the bars changes depending on how many bars there are. In my example there was less whitespace between the bars when there were more bars, and more whitespace when there’s less bars. Not sure how you’re handling that.

If you set the frame to always be the same amount of padding it won’t have the same functionality when a lot more/less bars are added. Maybe I’m overcomplicating things lol

And now that I look at it, this solution does not fix the padding issue. Which I should have been more clear about. In your solution the padding between the bars is always exactly the same. I need it to dynamically change depending on the amount of bars. Just imagine you had 12 bars instead of six. If the amount of padding between the bars was exactly the same the bars would be extremely thin.

Oh, that can be achieved like this:

⫿⫿ Bar Container (↕︎Fill Container)
  ⌗ Frame (↕︎Fill Container)
    ⌗ Actual color body of bar (Vertical constraints set to `Scale` with some room on top and bottom)

This is what I was looking for! Appreciate it

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.