From da204225b95bbea459ebed20f591535a5e70256e Mon Sep 17 00:00:00 2001 From: "Bulat.V" Date: Mon, 24 Sep 2018 15:42:24 +0500 Subject: [PATCH 1/2] Update highcharts-chart.component.ts --- .../src/lib/highcharts-chart.component.ts | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/highcharts-angular/src/lib/highcharts-chart.component.ts b/highcharts-angular/src/lib/highcharts-chart.component.ts index 7dd3786..7fceb36 100644 --- a/highcharts-angular/src/lib/highcharts-chart.component.ts +++ b/highcharts-angular/src/lib/highcharts-chart.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, EventEmitter, Input, OnDestroy, Output } from '@angular/core'; +import { Component, ElementRef, EventEmitter, Input, OnDestroy, Output, NgZone } from '@angular/core'; @Component({ selector: 'highcharts-chart', @@ -25,21 +25,25 @@ export class HighchartsChartComponent implements OnDestroy { private chart: any; private optionsValue: any; - constructor( - private el: ElementRef - ) {} + constructor(private el: ElementRef, + private _zone: NgZone) { + } updateOrCreateChart() { - if (this.chart && this.chart.update) { - this.chart.update(this.optionsValue, true, this.oneToOne || false); - } else { - this.chart = this.Highcharts[this.constructorType || 'chart']( - this.el.nativeElement, - this.optionsValue, - this.callbackFunction || null - ); - this.optionsValue.series = this.chart.userOptions.series; - } + window.setTimeout(() => { + this._zone.runOutsideAngular(() => { + if (this.chart && this.chart.update) { + this.chart.update(this.optionsValue, true, this.oneToOne || false); + } else { + this.chart = this.Highcharts[this.constructorType || 'chart']( + this.el.nativeElement, + this.optionsValue, + this.callbackFunction || null + ); + this.optionsValue.series = this.chart.userOptions.series; + } + }); + }, 0); } ngOnDestroy() { // #44 From 478b42fc053fdabec483ce1f0102db58c1e91ea8 Mon Sep 17 00:00:00 2001 From: "Bulat.V" Date: Wed, 26 Sep 2018 11:32:41 +0500 Subject: [PATCH 2/2] Update highcharts-chart.component.ts --- .../src/lib/highcharts-chart.component.ts | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/highcharts-angular/src/lib/highcharts-chart.component.ts b/highcharts-angular/src/lib/highcharts-chart.component.ts index 7fceb36..1d749f1 100644 --- a/highcharts-angular/src/lib/highcharts-chart.component.ts +++ b/highcharts-angular/src/lib/highcharts-chart.component.ts @@ -30,20 +30,18 @@ export class HighchartsChartComponent implements OnDestroy { } updateOrCreateChart() { - window.setTimeout(() => { - this._zone.runOutsideAngular(() => { - if (this.chart && this.chart.update) { - this.chart.update(this.optionsValue, true, this.oneToOne || false); - } else { - this.chart = this.Highcharts[this.constructorType || 'chart']( - this.el.nativeElement, - this.optionsValue, - this.callbackFunction || null - ); - this.optionsValue.series = this.chart.userOptions.series; - } - }); - }, 0); + this._zone.runOutsideAngular(() => { + if (this.chart && this.chart.update) { + this.chart.update(this.optionsValue, true, this.oneToOne || false); + } else { + this.chart = this.Highcharts[this.constructorType || 'chart']( + this.el.nativeElement, + this.optionsValue, + this.callbackFunction || null + ); + this.optionsValue.series = this.chart.userOptions.series; + } + }); } ngOnDestroy() { // #44