ChartJs.Blazor
ChartJs.Blazor copied to clipboard
Support Gradient Fill Colors
Describe your question
Is a gradient fill currently possible?
Any pointers on how you might try to achieve it?
For example: https://jsfiddle.net/9gLakq26/
Which charts is this question related to?
All
JavaScript equivalent
https://jsfiddle.net/9gLakq26/
Additional context
FWIW I am using master, not the 1.x release.
Good question!
Using gradients as colors isn't supported yet. We can use this issue for tracking this feature.
Since you need to create the gradients with the 2d-context of the canvas, you can't just extend the serialized classes and thus the workaround isn't as straight-forward. I have just added a sample showcasing the workaround in 609a6e5.
Please try it and tell us if it worked :)
In order to implement this feature we'll need the following:
- A new type to abstract chart colors (which accepts string,
System.Drawing.Colorand gradients) - Some way to describe and construct any sort of gradient in C#
- Some way to translate that description once we setup the chart
- Automatic resolution/translation of these gradients, otherwise we'll have to add a case for every single color there is (this is an issue we need to fix for callbacks as well)
If you have anything to add, please do!
Huge help @Joelius300 thank you.
Any updates on support for canvas 2d gradients in Blazor wasm?