1👍
✅
Change:
backgroundColor: backgroundColor[x],
to:
backgroundColor: backgroundColor,
Result:
Why does this work?
The backgroundColor
property can be specified in a number of ways. Typically it’s set to a string, e.g. #abcdef
but it can also be set to an array. In this case Chart.js itself will pick the colour from the array based on the index of the data point it is drawing.
Source:stackexchange.com