You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { Component, OnInit } from '@angular/core';
import 'chartjs-plugin-streaming';
import { ActivatedRoute } from '../../../node_modules/@angular/router';
@Component({
selector: 'app-resource-monitor',
templateUrl: './resource-monitor.component.html',
styleUrls: ['./resource-monitor.component.css']
})
export class ResourceMonitorComponent implements OnInit {
datasets: any[] = [{
data: [],
label: 'line1'
}, {
data: [],
label: 'line2'
}];
options: any = {
scales: {
xAxes: [{
type: 'realtime'
}]
},
plugins: {
streaming: {
onRefresh: function (chart: any) {
chart.data.datasets.forEach(function (dataset: any) {
dataset.data.push({
x: Date.now(),
y: Math.random()
});
});
},
duration: 20000, // data in the past 20000 ms will be displayed
refresh: 1000, // onRefresh callback will be called every 1000 ms
delay: 1000, // delay of 1000 ms, so upcoming values are known before plotting a line
frameRate: 30, // chart is drawn 30 times every second
pause: false, // chart is not paused
}
},
animation: {
duration: 0 // general animation time
},
hover: {
animationDuration: 0 // duration of animations when hovering an item
},
};
constructor(private route: ActivatedRoute) { }
ngOnInit(): void {
this.route.params.subscribe(params => {
const id = params['id'];
});
}
pause() {
this.options.plugins.streaming.pause = !this.options.plugins.streaming.pause;
}
}
I want to start/pause the chart.
It seems like I need to update the chart after setting this.options.plugins.streaming.pause as true.
So I wonder if there is any way to obtain the chart object and call chart.update().
Thanks a lot!!!
The text was updated successfully, but these errors were encountered:
Here is my code:
I want to start/pause the chart.
It seems like I need to update the chart after setting this.options.plugins.streaming.pause as true.
So I wonder if there is any way to obtain the chart object and call chart.update().
Thanks a lot!!!
The text was updated successfully, but these errors were encountered: