question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Changing default color for charts does not seem to work

See original GitHub issue

Expected 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)

  1. Go to live example: https://codepen.io/anon/pen/QvRQgW
  2. 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:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
simonbrunelcommented, Nov 22, 2017

@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 use Chart.helpers.merge (fiddle) or simply

0reactions
etimbergcommented, Nov 22, 2017

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found