nagix / chartjs-plugin-colorschemes

Predefined color schemes for Chart.js
MIT License
263 stars 58 forks source link

Changing Global Default Does Not Work #3

Open xyrph opened 5 years ago

xyrph commented 5 years ago

If I change Chart.defaults.global.plugins.colorschemes.scheme at any time, including before I define the first chart, the scheme color value is not used when I do create a chart.

For some reason, it always defaults to the value of ('brewer.Accent4'). That's odd. Where does that value come from?

The default value you have set in the plugin ('brewer.Paired12') is not used.

I can get a specific chart to draw with the scheme I want by setting ch.options.plugins.colorschemes.scheme

That works fine. But setting the global fails to fall through to a chart when I do not set the scheme on the chart directly. And again, the odd value of scheme that gets used for whatever reason is ('brewer.Accent4').

Note that I am only using scatter-type charts if that makes any difference.

It would be nice to be able to set the global and then have all charts pull from that, but right now the global setting is useless... and worse, wrong.

nagix commented 5 years ago

Thank you for reporting the issue, but I cannot reproduce this issue. I set Chart.defaults.global.plugins.colorschemes.scheme to 'brewer.RdPu4' for example at the beginning, and it is applied to all the charts.

See https://jsfiddle.net/nagix/eLfznymd/. Note that this doesn't include the fix for #2, so the line colors are still set to gray.