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

ColorField in mvc helper

3 Answers 203 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Alan
Top achievements
Rank 1
Alan asked on 22 Oct 2012, 04:03 PM
I can see an option for setting the color on a series e.g .Color("red)", however I don't see a colorField.

Is it possible to use a field from the model to set the color of the series, when using the mvc helpers?

Thanks
Alan

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 25 Oct 2012, 12:38 PM
Hello Alan,

The color property name can be set through the series configuration for the Chart types that support it. For example:

series.Bar("ValueFieldName", "ColorFieldName")

 Kind regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alan
Top achievements
Rank 1
answered on 25 Oct 2012, 01:02 PM
Thanks for your reply Daniel.

But this doesn't seem to work for the Column chart type.
It does however work when doing it through JSON/ajax.

So for example this works for bar chart.....

series.Bar(model => model.Value, model => model.SeriesColor);

but this doesn't.....

series.Column(model => model.Value, model => model.SeriesColor);

Kind Regards
Alan

0
Daniel
Telerik team
answered on 30 Oct 2012, 10:30 AM
Hello again Alan,

It seems that there was a problem with the column Chart colorField serialization in the official release. The good news is that this has already been addressed and the changes will be available in the next official release which is expected next month. A workaround for now is to set the colorField to the chart series options after the Chart is created on the client and redraw it e.g.

$(function () {
    var chart = $("#chart").data("kendoChart");
    chart.options.series[0].colorField = "SeriesColor";
    chart.redraw();
})
Kind regards,
Daniel
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Chart
Asked by
Alan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Alan
Top achievements
Rank 1
Share this question
or