|
[app.component.ts]
<button (click)='stoptimer($event)'>Stop Timer</button>
<button (click)='starttimer($event)'>Start Timer</button>
<ejs-chart (loaded)='loaded($event)' [zoomSettings]='zoom'>
</ejs-chart>
public loaded(args: ILoadedEventArgs): void {
if(!this.intervalId) {
this.liveupdate = this.liveupdate.bind(this);
this.intervalId = setInterval(this.liveupdate, 100);
}
}
//Zooming
public zoom: ZoomSettingsModel = {
enablePan: true,
enableSelectionZooming: true,
enableScrollbar: true
};
//Stop the live update
public stoptimer(e: Event) {
clearInterval(this.intervalId);
this.intervalId = 100;
}
//Start the live update
public starttimer(e: Event) {
this.intervalId = 0;
this.loaded(null);
}
public liveupdate() {
let i: number;
if (getElement('chart-container') === null) {
clearInterval(this.intervalId);
} else {
//...
this.series1.push({ x: this.i, y: this.value });
//Calculated the zoom factor and position
this.chart.primaryXAxis.zoomFactor = 100 / this.series1.length;
this.chart.primaryXAxis.zoomPosition = (this.series1.length - 100) / this.series1.length;
//...
}
}
|
|
|
|
<ejs-chart [zoomSettings]='zoom'>
</ejs-chart>
public zoom: ZoomSettingsModel = {
enablePan: true,
enableSelectionZooming: true,
enableScrollbar: true
}
|
|
public scrollChanged(args: IScrollEventArgs): void {
clearInterval(this.intervalId);
this.intervalId = 200;
} |