Mudblazor pie/doughnut slice colors
Asked Answered
G

0

1

I am exploring Mudblazor. I created a doughnut chart and it works fine. But I need to define the colors of the slices of the pie/doughnut. I see you can have a class for the entire chart, but how do set custom colors for each slice of the pie?

The default for a 3 slice pie is like blue, teal and gold. I need to change those colors and will need to be changed in code also.

The theming palette options don't seem to have options for this.

Thanks,

Michael

Edit: I figured it out. In case anyone else needs to do this. Example:

ChartOptions options = new ChartOptions();

protected override void OnInitialized()
{
    string[] colors = { "#ff0000", "#00FF00","#0000ff" };
    options.ChartPalette = colors;
}

Chart-add ChartOptions="@options":

Grandiloquence answered 11/6, 2022 at 17:18 Comment(5)
OK, I figured it out. In case anyone else needs to do this:Grandiloquence
Well done! Please add the solution as answer and accept it. SO explicitly encourages to do that. An answer hidden in the question is hard to find for others.Tickler
@Grandiloquence note that you can do that in one go: ChartOptions options = new() { ChartPalette = new[] { "#ff0000", "#00FF00", "#0000ff" } };Moose
This was my first post on StackOverflow. I apologize, but I don't know what you mean by "Please add the solution as answer and accept it." How do you do that?Grandiloquence
@Grandiloquence Scroll down and put the answer in the text box labeled "Your Answer", then click the "Post Your Answer" button.Downs

© 2022 - 2024 — McMap. All rights reserved.