1👍
✅
Remove the slice of the labels, that should do the trick
Which means your addRandomValue() should look like this:
addRandomValue(): void {
this.chartData.push(Math.random() * 10 + 10);
this.chartLabels.push(this.chartData.length + '');
// weird workaround for refreshing data, works fine
// for all other chart types I tried it on
this.chartData = this.chartData.slice();
}
0👍
That’s a somewhat known issue. If you look at the examples for ng2-chart you’ll notice a comment written beneath the declaration of the bar-chart (https://github.com/valor-software/ng2-charts/blob/master/demo/src/app/components/charts/bar-chart-demo.ts).
To put it in a nutshell, you have to clone the data, get your CRUD done on the clone, and reassign the data to the original variable so the change is recognized.
Source:stackexchange.com