1👍
✅
The Array.concat()
method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array.
Therefore, you should change your loadData()
method as follows:
loadData() {
if (this.count > 10) {
return clearInterval(this.interval);
}
const { data, labels } = this.dataService.getData();
this.chart.data.labels = this.chart.data.labels.concat(labels);
this.chart.data.datasets.forEach(ds => ds.data = ds.data.concat(data));
this.count++;
this.chart.update();
}
Source:stackexchange.com