ChartJs.Blazor icon indicating copy to clipboard operation
ChartJs.Blazor copied to clipboard

Support Gradient Fill Colors

Open stefangordon opened this issue 5 years ago • 3 comments

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.

stefangordon avatar Oct 22 '20 17:10 stefangordon

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.Color and 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!

Joelius300 avatar Oct 23 '20 20:10 Joelius300

Huge help @Joelius300 thank you.

stefangordon avatar Oct 23 '20 20:10 stefangordon

Any updates on support for canvas 2d gradients in Blazor wasm?

brentminder avatar Feb 12 '23 15:02 brentminder