2๐
โ
I would recommend that you pull out this logic into a reusable chart component and that will take care of it for you. I created a plunkr to show you an example of doing so.
Essentially this allows you to loop over them by rendering a new version of your chart component and passing the necessary data it needs to render like so:
<chart-canvas *ngFor="let chart of charts" [data]="chart"></chart-canvas>
You can then put all of the logic you have shown above in that chart-canvas
component.
Source:stackexchange.com