Chart Series Builder - Donut Colour

1 Answer 32 Views
Chart
Lee
Top achievements
Rank 1
Veteran
Lee asked on 28 Apr 2021, 04:09 AM

Hi,

I'm using a Donut Chart and would like to specify the Color via expression like the expressionValue and categoryExpression like so:

series
    .Donut(model => model.Count, model => model.Status, model => model.Color)

I've looked via source code and can see that the ChartSeries class does have a Color filed but with no way of specifying it.

Can you please recommend a fix/solution?

PS I am using remote data source.

1 Answer, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 30 Apr 2021, 12:30 PM

Hello Lee,

The Chart series color can be set via the ColorField property that points to the data item field which contains the series color. For example:

@(Html.Kendo().Chart<WebApplication1.Models.ChartModel>()
        .Name("chart")
        .Series(series => {
            series.Donut("Value", "Category")
                .ColorField("Color")
        })
    )

FOr your reference, I am attaching a small Mvc Core project demonstrating this.

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Chart
Asked by
Lee
Top achievements
Rank 1
Veteran
Answers by
Nikolay
Telerik team
Share this question
or