1
votes

I want a legend to appear in my sunburst chart (to be able to hide data on click).

Here is an official example of a sunburst chart: https://playground.anychart.com/gallery/Sunburst_Charts/Employee_Count_by_Country

I tried to add:

chart.legend().enabled(true);

But I do not see any legend nor any error messages in the console. The website says:

In AnyChart, the legend can be used with Basic Charts, Stock Charts, Maps, and every other chart type.

So i expected the legend to show up, but it doesn't.

1
The sunburst chart doesn't support a legend as it's working with tree-like data. You can create your own standalone legend like in this sample - playground.anychart.com/7WVc5zEj/1 In that sample, we created a legend based on the second level points. But as @Alex Q said there are many conditions for creating the legend. Also, how do you want to hide the data on the click? As it's tree data, if you remove a node on the middle level all related leaves should get hidden too. Or do you mean any other interactivity?AnyChart Support
@AnyChartSupport Thank you for your sample, it helped me to get started. I was able to remove a tree node on legend click, that is sufficient for my purpose.bibermann

1 Answers

1
votes

1) If you remove the custom coloring (like chart.fill() and palette), you'll see the default anychart palette.

2) Sunburst chart uses tree-data. It is not the series separation by category or value.

It means that is not clear how to provide legend data. Separation by root data? By values? By any additional conditions? That's why legend is not included in sunburst by default. In this case customer is able to use standalone legend to provide any data.