[BUG] Changing default color for charts does not seem to work
See original GitHub issueExpected Behavior
When using Chart.defaults.global.defaultColor
to specify a new default color for all charts, the new default color you specify should overwrite the initial one of 'rgba(0, 0, 0, 0.1)'
.
Current Behavior
Specifying a new default color has no effect. The initial one persists.
Possible Solution
Steps to Reproduce (for bugs)
- Go to live example: https://codepen.io/anon/pen/QvRQgW
- I have set a new default color of ‘#FF0000’ or red in the JavaScript code, but there is no change on the chart.
Context
I wanted to change the default color of all charts to one that was more suitable to a color scheme I’m using. By changing the global default color once using the line of code suggested in the documentation, the color should automatically affect all charts and save me the trouble of having to manually do it for every chart.
Environment
- Chart.js version: 2.4.0
- Browser name and version: Google Chrome, Version 58.0.3029.110 (64-bit), macOS
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
How can I stop Excel from changing the colors of my chart
I have a chart with past and forecasted figures for several series of data. I set the colors of each serie in order...
Read more >106534 – Color set/palette for charts missing since ... - Bugzilla
First suggestion for a solution: A Chart palette could be introduced, which could be easily changed if the chart color set will be...
Read more >What happened to data colors and default color?
I have a need to update the colors of specific bars in my chart based on conditional formatting. All content I have come...
Read more >chart.js v2.80 Default Bar Chart backgroundColor
I am assuming the colour (I'm Canadian) of the horizontal bar should be the blue I've assigned. When set inside the chart instance,...
Read more >Graph colors changing | Power BI Exchange
I have the same issue with one or two of my visuals. One color always seems to revert to the default color used...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@etimberg good catch, we should maybe remove these options from defaults and use the default color if undefined when updating the chart (as we do with many other options).
@gtalarico don’t use
Chart.defaults._set
because as @etimberg said it’s a private helper that can be removed without notice, so will break your code. Instead, you should useChart.helpers.merge
(fiddle) or simply@simonbrunel that would be a good way to fix this. We did something similar around v2.3 or v2.4 for the font options. Doing it for the colours should not be too hard