I'm trying to add a dynamic legend in a Highcharts sunburst (like in the pie chart). The code presented in the following fiddle is exactly what I need : https://jsfiddle.net/BlackLabel/x2hL8tqo/
My problem is when I have a lot of data (near 500 points), the browser is hanging when I clic on an item in the legend. You can see the demo here (wait one minute after the clic and answer "yes" to the chrome alerts to see the result) : https://jsfiddle.net/vegaelce/py5q7ozv/
The update function seems to be the bottleneck :
p.update({
oldValue: p.value ? p.value : p.oldValue,
value: p.value ? null : p.oldValue
});
Is there any way to optimize the code to get the function working with large amount of data ?
Thanks.
Your
legendItemClicklogic is redrawing after each point edit (this is the default). This causes the delay/hang. If you instead utilize the second parameter ofupdate(options [, redraw] [, animation])(API) to not redraw the individual updates, but instead do the redraw from the chart after all the updates that should be much faster.Example edited
legendItemClick:Note how
point.updatehasfalsefor redraw. See this JSFiddle as an example.You could set the parameter of
chart.redrawtotrueif you want an animation with the change.