amcharts / amcharts5

The newest, fastest, and most advanced amCharts charting library for JavaScript and TypeScript apps.
Other
353 stars 95 forks source link

Unable to get the true rendered width of a label to detect overflow on a bar chart #1757

Open cheryllaird opened 1 month ago

cheryllaird commented 1 month ago

Bug description Similar to this issue https://github.com/amcharts/amcharts5/issues/1632. I want to be able to measure the rendered with of a label.

On my bar chart I want the labels to wrap (using oversizedBehavior: "wrap-no-break",) but if any text overflows the column I want to be able to hide the label.

In the codepen below you can see that I am trying to get the _contentWidth of the label in the Add bullet(s) section. However this is not always hiding the labels if it overflows the series on the bar when a single word overflows.

image

Codepen: https://codepen.io/cheryllaird/pen/rNXWqeO

martynasma commented 1 month ago

I don't think that relying on height adapter will work.

Why not watch label's boundschanged event instead?

cheryllaird commented 1 month ago

Yeah good shout. I have updated to the boundschanged event but I still can't seem to be able to get the rendered width of the label. The label width matches the width of the column so I am unable to detect when the text has overflowed.

martynasma commented 1 month ago

I can't seem to be able to make this work. We will consider adding a functionality to auto-hide a wrapped label if it does not fit into maxWidth.