Setting line series color from DataSource

2 posts, 0 answers
  1. Aerion
    Aerion avatar
    13 posts
    Member since:
    Aug 2011

    Posted 17 Feb 2015 Link to this post

    Is it possible to set the color of a Line chart series based on the grouped data received from the DataSource?
  2. Iliana Nikolova
    Iliana Nikolova avatar
    2622 posts

    Posted 19 Feb 2015 Link to this post

    Hi Aerion,

    If I understand correctly you have a color field in the dataSource and would like the seriesColor to get this color? This is not supported out-of-the-box, however it can easily achieved using the following approach: 
    - Set series.colorField
    - In the dataBound event set the value of colorField as series color.
      .Series(series =>
           model => model.Value,
           model => model.UserColor
      .Events(ev => ev.DataBound("onDB"))
    function onDB(e) {
       e.sender.options.series[0].color = e.sender.options.series[0].data[0].UserColor
    In case I am missing something please elaborate a bit more on the exact outcome you are trying to implement - this way I would be able to advice you further and provide concrete recommendations.

    Iliana Nikolova

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top