Radzen pie chart

Hi,

Is it possible to set the color for data items on a chart(pie, doughnut, bar). I have seen the colorscheme property but I would like specific data points to be a particular color.

Thanks

Hi @Sukanzubair,

You can specify individual colors via the Fills property. It accepts IEnumerable<string> you can pass an array of strings:

<RadzenPieSeries Fills=@(new [] { "#aabbcc", "#a0b0c0" }) />

2 Likes

Thank you, I appreciate the prompt reponse.

Thank you bro , you are the best

This does not appear to allow a specific color to apply to data. These fills are applied in the order they are designated, regardless of the data in the chart. I would like to set a specific color to a specific category property value. is there a way to do this?

IE:
Category Property Value -> Color
Low -> Green
Medium -> Yellow
High -> Red

if one of these property values doesnt exist to fill the chart, it will apply the wrong color

IE:
Category Property Value -> Color

Low -> Green
High -> Yellow

Hi Andrew

Had the same issue, so I created a class to hold Title and Value, and then run individual queries on each 'Title' you need. (Tag and Header were extra pieces of data I required)

  public class PieItem
  {
    public string Title { get; set; }
    public double Value { get; set; }
    public string Tag { get; set; }
    public string Header { get; set; }
  }        

  OrderStatuses = new List<PieItem>();

  myval = (orders.Where(o => o.Status == "New Order")).Count();
  OrderStatuses.Add(new PieItem() { Title = $"New ({myval})", Value = myval, Tag = $"notstarted", Header = "Not started" });
  myval = (orders.Where(o => o.Status == "In Progress")).Count();
  OrderStatuses.Add(new PieItem() { Title = $"In Progress ({myval})", Value = myval, Tag = $"inprogress", Header = "In progress" });
  myval = (orders.Where(o => o.Status == "Complete")).Count();
  OrderStatuses.Add(new PieItem() { Title = $"Complete ({myval})", Value = myval, Tag = $"completed", Header = "Complete" });

Then your Pie/Donut Chart declaration would be something like

<RadzenChart @ref="PieOrders" ColorScheme="ColorScheme.Pastel" SeriesClick="@OrderStatusClick" LegendClick="@OrderStatusLegendClick">
    <RadzenDonutSeries Title="Order Statuses"
        Data="@OrderStatuses"
        CategoryProperty="Title"
        ValueProperty="Value">
    </RadzenDonutSeries>
</RadzenChart>

This is a great work around! Thanks @Paul_Ruston! I think an implementation for assigning colors to a property in the IDE would be great