Jerome Pouille
Jerome Pouille

Reputation: 33

Sunburst chart in Anychart : How to wrap text in labels?

I am using anychart and need to wrap the text in the labels of the sunburst chart. Below is an extract of the current code:

chart.labels().fontSize(15);
chart.labels().wordWrap("break-word");
chart.labels().wordBreak("normal");

However this does not appear to be working (neither the font size, nor the word wrapping).

Any idea on how to make it work ?

Upvotes: 3

Views: 1027

Answers (2)

AnyChart Support
AnyChart Support

Reputation: 3905

There's no need to enable useHtml() mode. You can adjust the fontSize via library API after disabling adjustFontSize. adjustFontSize is enabled as default and it tends to fit the label to the point. After disabling it you can manually apply required font-size. For details check the sample, pay attention to lines 24 - 26.

Upvotes: 1

Dima Mamchur
Dima Mamchur

Reputation: 1099

To be able to style labels on Sunburst chart in Anychart you need to enable HTML for labels and use format method for inline styles:

chart.labels().useHtml(true);
chart.labels().format("<span style='font-size: 15px; word-break: normal; word-wrap: break-word;'>{%name}</span><br>{%value}");

Upvotes: 2

Related Questions