score:1

Accepted answer

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.

score: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();


Related Query

More Query from same tag