Reputation: 9550
I am trying to get some feelings on HighCharts performance. Compare these two codes:
Renderer
object ~50msRenderer
and Chart
objects ~500msThe timing difference is ~10x, which is quite wired.
I need the chart.tooltip
to show tooltips. So I cannot simply use the code A. But why the performance is so different? How to write a better solution?
Upvotes: 3
Views: 389
Reputation: 2197
I've done some digging in Highcharts and it turns out to be the handling of Z indices in the SVGElement.add method that slows it down. The solution is to add your own group, and add all the rectangles to that group. Then the performance is the same whether you add it inside or outside a chart.
var ren = chart.renderer;
var g = ren.g().add();
for (var i = 0; i < 1000; i++) {
ren.rect(i, i, 100, 100, 0).attr({ fill: '#FF0000' }).add(g);
}
http://jsfiddle.net/highcharts/jxpSk/7/
Upvotes: 4