0👍
Ok after a while of trying different things out, this seems to work for me.
ngAfterViewInit() {
this.loadCharts();
}
loadCharts() {
_.each(this.games, (game, i) => {
this.chart = new Chart(game.id, {
type: 'doughnut',
data: {
labels: [game.homeTeam, game.awayTeam],
datasets: [
{
label: "Population (millions)",
backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
data: [2478,5267,734,784,433]
}
]
},
options: {
title: {
display: true,
text: 'Predicted world population (millions) in 2050'
}
}
});
});
}
Basically it’s waiting for the view to be initialized and then it assigns the charts to the cards that I have created.
- Chartjs-First and last value is not displaying in chart.js used with django
- Chartjs-Django chartjs multiple charts stacked
Source:stackexchange.com