0👍
✅
You could do it like this:
const randomColor = (i) => {
const colors = ["#93B5C6", "#DDEDAA", "#F0CF65", "#D7816A", "#BD4F6C"];
return colors[i % colors.length];
}
const datasets = Object.keys(this.aux).map((key, index) => {
const color = randomColor(index);
return {
label: key,
backgroundColor: color,
borderColor: color,
fill: false,
data: this.aux[key].map((item) => item.monto_moneda_norm)
};
});
There is also a plugin: https://github.com/kurkle/chartjs-plugin-autocolors
Source:stackexchange.com