Skip to content

Commit cb30d00

Browse files
authored
Merge pull request #13 from JeongHun-Park/master
Chart rendering performance improvement
2 parents fa93cec + abc7a6f commit cb30d00

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

dist/src/fusioncharts.component.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ var FusionChartsComponent = (function () {
144144
_this.chartObj = fusioncharts_constructor_1.FusionChartsConstructor(_this.fusionchartsService, configObj);
145145
configObj['renderAt'] = 'container-' + _this.chartObj.id;
146146
_this.containerId = _this.chartObj.id;
147-
setTimeout(function () {
148-
_this.chartObj.render(_this.configObj['renderAt']);
149-
}, 1);
147+
this.zone.runOutsideAngular(function () {
148+
setTimeout(function () {
149+
_this.chartObj.render(_this.configObj['renderAt']);
150+
}, 1);
151+
});
150152
}
151153
};
152154
FusionChartsComponent.prototype.ngOnDestroy = function () {

src/fusioncharts.component.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Component, Input, ElementRef, OnInit,
22
OnChanges, DoCheck, AfterViewInit, OnDestroy,
3-
KeyValueDiffers, ViewChild} from '@angular/core';
3+
KeyValueDiffers, ViewChild, NgZone} from '@angular/core';
44

55
import { FusionChartsService } from './fusioncharts.service';
66
import { FusionChartsConstructor } from './fusioncharts.constructor';
@@ -141,7 +141,7 @@ export class FusionChartsComponent implements OnInit, OnChanges, DoCheck, AfterV
141141
element: ElementRef;
142142
fusionchartsService: FusionChartsService;
143143

144-
constructor(element: ElementRef, fusionchartsService: FusionChartsService, private differs: KeyValueDiffers) {
144+
constructor(element: ElementRef, fusionchartsService: FusionChartsService, private differs: KeyValueDiffers, private zone: NgZone) {
145145
this.element = element;
146146
this.fusionchartsService = fusionchartsService;
147147
}
@@ -237,10 +237,11 @@ export class FusionChartsComponent implements OnInit, OnChanges, DoCheck, AfterV
237237
configObj['renderAt'] = 'container-' + _this.chartObj.id;
238238
_this.containerId = _this.chartObj.id;
239239

240-
setTimeout(() => {
241-
_this.chartObj.render(_this.configObj['renderAt']);
242-
}, 1);
243-
240+
this.zone.runOutsideAngular(() => {
241+
setTimeout(() => {
242+
_this.chartObj.render(_this.configObj['renderAt']);
243+
}, 1);
244+
})
244245
}
245246
}
246247

0 commit comments

Comments
 (0)