Series color issue when Binding Chart series to dynamic Data

3 posts, 1 answers
  1. Steven
    Steven avatar
    2 posts
    Member since:
    Apr 2015

    Posted 21 May 2015 Link to this post

    Hi,

    I having an issue with the Chart control. All series columns in the chart are Black but the Legend shows each series with a different color.

    @(Html.Kendo().Chart<ViolationsChartModel>()
    .Name("ViolationsChart")
    .Title("Inspection Results By Year")
    .DataSource(ds => ds
    .Read(read => read.Action("ViolationsReportChart", "Violations"))
    .Group(g => g.Add(v => v.InspectionYear))
    .Sort(s => s.Add(v => v.Question))
    )
    .Legend(legend => legend
    .Position(ChartLegendPosition.Bottom)
    )
    .Series(series =>
    {
    series.Column(value => value.InspectionPercent, category => category.Question).Name("${group.value}").CategoryField("Question");
    })
    .ValueAxis(axis => axis.Numeric()
    .Labels(lables => lables.Format("{0:P0}").Visible(true))
    )
    .CategoryAxis(axis => axis
    .Visible(true)
    )
    .Tooltip(tooltip => tooltip
    .Visible(true)
    .Format("{0:P0}")
    .Template("${series.name} - ${category} - ${value}")
    )

    If I add .SeriesColors("#cd1533", "#d43851", "#dc5c71", "#e47f8f", "#eba1ad",...) the Legend shows those colors but chart still shows all series as black.

    What am I doing wrong?

    Thanks,

     

               

  2. Answer
    Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2595 posts

    Posted 25 May 2015 Link to this post

    Hi Steven,

    The second parameter in the series object should be colorExpression not category field. Please modify the chart configuration in the following way and let me know if this will help: 

    //....
    .Series(series =>
    {
    series.Column(value => value.InspectionPercent).Name("${group.value}").CategoryField("Question");
    })
    .SeriesColors("#cd1533", "#d43851", "#dc5c71", "#e47f8f", "#eba1ad")
    //....

     

    Regards,
    Iliana Nikolova
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Steven
    Steven avatar
    2 posts
    Member since:
    Apr 2015

    Posted 26 May 2015 in reply to Iliana Nikolova Link to this post

    It's working now!!

    Thanks,

    Steve

Back to Top