Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Don't show text labels on stacked bar chart if there's not enough room for them


I am using plotly to create stacked bar chart (textposition: inside):

Some values doesn’t fit their blocks which result in decrease of their size (like 10 on the rightest bar or value 2 which has horizontal position on the previous bar).

Is there a way to avoid displaying values if their block doesn’t have enough space?

Different sizes make chart look a bit unprofessional.


We don’t expose an attribute that does that at the moment. But you can try replacing the text items corresponding to the labels that don’t have enough room by '' to make them disappear.

Hi @etienne, thanks for your reply.

I update charts dynamically so that probably wouldn’t work for me as I don’t know in advance which block going to be tiny.

A feature that sets min font size for charts would be useful (don’t show numbers that were auto-adjusted to smaller font sizes).



1 Like