Chartjs-My Chart.js Options referencing React state are being ignored

2👍

Chart.js 3+ has a different setting on the options. Yours is the v2 settings which will be ignored.

Here is the codesandbox for your reference:

https://codesandbox.io/s/inspiring-payne-q3sw2?file=/src/App.js

  • The legend will now be under plugins
  • fontColor will be color
  • fontSize will be font: { size: xx }
options: {
    plugins: {
        legend: {
            labels: {
                color: "blue",
                font: {
                   size: 18
                }
            }
        }
    }
}

The legend config in v3:

https://www.chartjs.org/docs/master/configuration/legend.html

I think their doc has some problems which is mixing v2 and v3 syntax together sometimes. confusing people 🙁

Leave a comment