Chartjs-Background color does not work when trying to create my data before using scatter chart with chart.js

0đź‘Ť

I created a jsfiddle to reproduce what you are trying to do. I can see that the colours are rendering fine after making one small change to your code:
I had to set marksData.datasets[i] = {} instead of marksData.datasets[i] = []

for (i = 0; i < 6; i++){
     marksData.datasets[i] = {};
     marksData.datasets[i].label = domaines[i];
     marksData.datasets[i].data = [{}];
     marksData.datasets[i].backgroundColor = colors[i];
}

Edit: The issue was you were setting dataset as an array, while it should’ve been an object.

Leave a comment