ColorField in mvc helper

4 posts, 0 answers
  1. Alan
    Alan avatar
    12 posts
    Member since:
    Aug 2012

    Posted 22 Oct 2012 Link to this post

    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
  2. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 25 Oct 2012 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Alan
    Alan avatar
    12 posts
    Member since:
    Aug 2012

    Posted 25 Oct 2012 Link to this post

    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

  5. Daniel
    Admin
    Daniel avatar
    2117 posts

    Posted 30 Oct 2012 Link to this post

    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!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready