-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Unable to parse color from object when using patterns (patternomaly.js) #4279
Comments
You linked the JS using |
Changed the snippet to use just http, http://codepen.io/anon/pen/ZKmVgo |
I fixed this in a local version of Chart.js (drawBody method): ashiguruma/patternomaly#10
This could easily be added to the core to fix the issue. |
I use this simple workaround (with pattornamaly & chart.js 2.5) const getPattern = (shape, color)=> {
let rgb = Chart.helpers.colors(color)
let bgPattern = pattern.draw(shape, color)
return Chart.helpers.extend(bgPattern, {r: rgb.red(), g: rgb.green(), b: rgb.blue(), alpha: rgb.alpha()})
}
// in my chart options
// ...code omitted.....
const backgroundColor = getPattern("dot", "red");
let chart = new Chart(ctx, {
data: {
labels: ['Item 1', 'Item 2', 'Item 3'],
datasets: [{
data: [10, 20, 30],
backgroundColor
}]
}
}) |
Expected Behavior
For the hover tooltip to show without throwing any errors when using a pattern as a background color with the help of patternomaly.js as suggested in the documentation at http://www.chartjs.org/docs/#chart-configuration-patterns
Current Behavior
Currently the tooltip fails to properly show and sort of soft-locks in place and the following error is presented in the console:
Uncaught Error: Unable to parse color from object {"shapeType":"dash"}
Possible Solution
It looks like a helper function to correct for the issue was a suggestion in #1323 but I'm unsure if it's a possible solution here.
Steps to Reproduce (for bugs)
Example: http://codepen.io/anon/pen/ZKmVgo
Context
I'm trying to make use of patterns on my charts to aid colorblind individuals.
Environment
The text was updated successfully, but these errors were encountered: