amcharts3 icon indicating copy to clipboard operation
amcharts3 copied to clipboard

Slow UI due to multiple event generation in Angular 2

Open AlexanderLukin opened this issue 7 years ago • 5 comments

I tried to use AmCharts in my Angular 2 app and noticed sufficient problem.

When I create a new instance of any AmChart chart, it looks like this instance started to generate tons of events per second and make UI of my app extremely slow.

Here is the working plunker. Angular 2 ngDoCheck hook is called each time when some event occurred. In a browser console, you may see multiple DoCheck!!! records. As AmCharts generates events so frequently, this lifecycle hook is called in parent component and their child components also frequently and noticeably slow the UI. The similar problem takes place for other charts. I've tested it for AmPieChart and the bug is reproduced.

Here is the full code of the AmCharts component based on this Stackoverflow answer.

@Directive({
    selector: 'chart'
})
export class amChartDirective {
    constructor() {
        var chart = new AmCharts.AmStockChart();
    }
    
    public ngDoCheck() {
      console.log('DoCheck!!!')
    }
}

AlexanderLukin avatar Feb 08 '17 08:02 AlexanderLukin

Hey,

Would you be able to direct this question in our Angular2 repo?

https://github.com/amcharts/amcharts3-angular2

martynasma avatar Feb 13 '17 06:02 martynasma

It's not a problem with amcharts3-angular2 directive, but with amcharts3 library itself. As you can see in my plunker, there is no amcharts3-angular2 on it, just Angular 2 and AmCharts. I believe, this issue can be reproduced without Angular 2, but I didn't build such test case.

AlexanderLukin avatar Feb 13 '17 09:02 AlexanderLukin

Sorry, managed to miss your reply somehow.

Would you be able to reproduce the issue without Angular2?

martynasma avatar Feb 22 '17 07:02 martynasma

Sorry, but I don't have much time to do it now. Maybe later I can return to this.

AlexanderLukin avatar Feb 27 '17 14:02 AlexanderLukin

OK. Sounds good. Just post it here when you have the time.

martynasma avatar Feb 28 '17 06:02 martynasma