0๐
โ
I found my mistake thanks to mhz. He turned my focus to the colors instead of the way I add data. The problem was that I set my color as an array instead of a string which probably meant that it wanted to pick the next color in the array which was empty so it defaulted to gray. I fixed it by removing the โ[]โ from my original code snippet.
function nieuweDataSet(naam){
var kleur = getRandomColor();
var newDataset = {
label: naam,
backgroundColor:kleur,
borderColor: kleur,
borderWidth: 1,
data: []
};
barChartData.datasets.push(newDataset);
theChart.update();
}
1๐
Its because you are calling
getRandomColor()
Try changing your nieuweDataSet
function to this:
function nieuweDataSet(naam){
var newDataset = {
label: naam,
borderWidth: 1,
data: []
};
barChartData.datasets.push(newDataset);
theChart.update();
}
Source:stackexchange.com