[BUG] Strange issue with chartjs-color
See original GitHub issueExpected Behavior
Ideally, it would be great to fallback to a value, and catch this as an exception rather throw Error.
Current Behavior
Better handling of Error, when this error occurs, the chart disappears. Main issue with this bug is a string value to “center” is causing an error to be thrown.
Possible Solution
Add validation to if statement to match only valid Rgba values. chartjs-color/index.js (line 25-35)
if (typeof obj === 'string') {
vals = string.getRgba(obj);
if (vals) {
this.setValues('rgb', vals);
} else if (vals = string.getHsla(obj)) {
this.setValues('hsl', vals);
} else if (vals = string.getHwb(obj)) {
this.setValues('hwb', vals);
} else {
throw new Error('Unable to parse color from string "' + obj + '"');
}
Steps to Reproduce (for bugs)
This bug is rather difficult to produce, occurs occasionally.
Context
Environment
- Chart.js version: 2.5.0
- Browser name and version: Version 56.0.2924.87 (64-bit)
- Link to your project: https://jsfiddle.net/oy05bwuk/1/
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Automatic colors assignment in chart.js 2.x doesn't work ...
All colors used in chart examples in the docs are defined explicitly. And this two-month-old issue features a categorical response from a Chart....
Read more >Chart.js issue : r/Angular2 - Reddit
The chart is rendering correctly, however I am having an issue when trying to display the [colors] property of the chart.
Read more >How to Change onHover Color of X-axis Labels in Chart JS
This will make the color of the x-axis change. Let's explore this right now! ▭ Chartjs Viewers Question Series ▭▭▭▭▭▭▭▭▭▭ This is ...
Read more >Change Border Color and Add Annotation Line on Hover in ...
In Chart JS changing the border color on hover for a line chart is not possible by default. Luckily with some small adjustments...
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 Free
Top 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
sorry, this is not 2.5.0 but master. I’ll give that a try and see if this issue still occurs.
sorry I didn’t follow up. The issue are there not there anymore after
npm update
. You can close this ticket.