1๐
โ
I could find the solution. Have a look at this link. I defined my variable as below (this solved all the errors I mentioned above):
private test2: any[] = [{ data: [] }];
also, I changes the location of calling the barChartData
.
First, in export class:
public barChartData;
then, inside my function that calls the backend data:
this.barChartData = [
{data: this.test2, label: 'Data 1'},
{data: this.test3, label: 'Data 2'}
];
This worked for me.
0๐
You are inserting data dynamically so you need to make an update on change. You will need ChangeDetectorRef
for this. Do the following steps:
1) Add this in your imports:
import { ChangeDetectorRef } from '@angular/core';
2) Add this in the constructor:
private cdRef: ChangeDetectorRef
3) After changing the data do this:
this.cdRef.detectChanges();
Source:stackexchange.com