Skip to content
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

Gradient not working in a NodeJS env #9854

Closed
YoannMa opened this issue Nov 15, 2021 · 2 comments · Fixed by #9861
Closed

Gradient not working in a NodeJS env #9854

YoannMa opened this issue Nov 15, 2021 · 2 comments · Fixed by #9861

Comments

@YoannMa
Copy link

YoannMa commented Nov 15, 2021

Firstly, I would like to apologize, I'm pretty sure you are not supporting ChartJS on a non-browser environment, but I'm not sure if the bug is elsewhere than inside ChartJS. I will understand if you ask me to move my post to Stack Overflow instead.

Expected Behavior

Using ChartJS 3.6.0 in a NodeJS environment, I would like to pass a function to set a gradient as backgroundColor.

Current Behavior

The function is executed but the backgroundColor is not set and default to black. I can make it work with ChartJS 2.9.4 using a plugin

Possible Solution

I tried to apply the same idea as v2.9.4 using a plugin and modifying the backgroundColor attribute but without any success.

Steps to Reproduce

I made a relatively small repository showing my configuration in ChartJS v2 (2.9.4) and v3 (3.6.0) here :

https://github.com/YoannMa/chartjs-gradient-v3-node

I was able to reproduce my issue using canvas or skia-canvas under the hood. Using Puppeteer, give the expected result.

Context

Environment

@kurkle
Copy link
Member

kurkle commented Nov 15, 2021

I'd suspect this:

const isPatternOrGradient = (value) => value instanceof CanvasGradient || value instanceof CanvasPattern;

Edit: I was wrong, its the config resolution that creates a proxy for those CanvasGradient implementations.

@YoannMa
Copy link
Author

YoannMa commented Nov 16, 2021

Thank you very much !

@etimberg etimberg added this to the Version 3.6.1 milestone Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants