[Chartjs]-Chart.js โ€“ PieChart defined background color for specific dataset element

1๐Ÿ‘

โœ…

You can define array where colors are values and good, bad and normal are keys, see next:

let chartColors = [];
chartColors['good'] = 'green';
chartColors['bad'] = 'red';
chartColors['normal'] = 'yellow';

Then the next step would be to add new array variable where you will push on the same way as you have done for labels:

someColorVar.push(chartColors[key]); 

Then replace bgcolor with someColorVar.

Leave a comment