Chartjs-How can I assign dynamic data from service via subscribe to doughnut chart in angular?

0👍

Depends on what backend you use. For example, if u obtain data through php from mysql you would use the below:

array1=[];
array2=[];

//api call on backend

this.http.get('http://localhost/angular9/chartData.php').subscribe(data => {
//create array and push the data
this.array1.push(data);
  //assign this array to another arraya and map it     
  this.array2 = this.array1[0].map(function(item, keys) {
   var mixarrayy = Object.keys(item).concat(Object.values(item));
  return mixarrayy;

    });

Leave a comment