Search code examples
javascriptsunburst-diagramanychart

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 ?


Solution

  • 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}");