This is a migrated thread and some comments may be shown as answers.

Series color issue when Binding Chart series to dynamic Data

2 Answers 320 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 21 May 2015, 02:18 PM

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 Answers, 1 is accepted

Sort by
0
Accepted
Iliana Dyankova
Telerik team
answered on 25 May 2015, 08:37 AM

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
0
Steven
Top achievements
Rank 1
answered on 26 May 2015, 11:21 AM

It's working now!!

Thanks,

Steve

Tags
Chart
Asked by
Steven
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Steven
Top achievements
Rank 1
Share this question
or