Skip to content

CanvasPattern object loses type information in chart-dataset-override directive. #548

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

Open
jgoakley opened this issue Nov 10, 2016 · 6 comments

Comments

@jgoakley
Copy link

jgoakley commented Nov 10, 2016

Chart.JS was recently updated to support CanvasPattern objects as the background color to allow for using patterns as well as colors for their chart data.

I tried to pass in a CanvasPattern as the backgroundColor using the chart-dataset-override directive. When angular-chart.js uses angular.merge, the CanvasPattern object loses it's type information. As a result, when Chart.JS performs an instanceof CanvasPattern it does not match object's type and results in a Unable to parse color from object {} error and the patterns are not shown.

I'm not sure if this will be an acceptable fix, but using angular.extend instead of angular.merge seemed to carry over the type information. I know that merge performs a deep copy and extend does not so I'm not sure what the implications will be.

Here is a link to a fiddle: https://jsfiddle.net/jgoakley/peqcgudy/23/

Pull Request: #549

@jdavislinkeng
Copy link

I'm seeing nothing but gray on your fiddle. Did you ever get a resolution for this?

@jgoakley
Copy link
Author

jgoakley commented Apr 4, 2017 via email

@jdavislinkeng
Copy link

Thank you! I hope that your merge gets accepted, this resolved a few hours of frustration.

  • Jon

@ChrisKatsaras
Copy link

I see that this solution works on whole data sets. Is there any way to associate a pattern with a specific piece of data (e.g a slice of a pie chart)? @jgoakley

@jgoakley
Copy link
Author

jgoakley commented Jul 14, 2017 via email

@ChrisKatsaras
Copy link

@jgoakley Thanks so much! Saved me a lot of time! Sorry for the late reply.
@jtblin Any reason the pull request has not been accepted yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants