[Chartjs]-Ionic using multiple chart.js canvas in the same page

1👍

I have found the solution….finally!!!

In html:

<canvas #barCanvas id="barCanvaslist{{i}}"></canvas>

Then in ts:
@ViewChildren(‘barCanvas’) Canvaslist: QueryList;
charts: any;

and afterwards:

this.Canvaslist.changes.subscribe(c => 
{ c.toArray().forEach(item => 
  { 
    this.Canvaslist = new Chart(item.nativeElement, pieData[j]);
    j = j+1;
  }) 
});

this does the trick

Leave a comment