Chartjs-Datalabels plugin throws error when using scriptable option

1👍

Since the pie chart defines an array of backgroundColor for each dataset in it and the function is called for each datalabel on the chart, you will need a way to tell which color in the array the function should use, probably using the index will do the trick.

Try something like this:

return context.dataset.backgroundColor[context.dataIndex];

Leave a comment