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

Setting line series color from DataSource

1 Answer 162 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Aerion
Top achievements
Rank 1
Aerion asked on 17 Feb 2015, 11:21 PM
Is it possible to set the color of a Line chart series based on the grouped data received from the DataSource?

1 Answer, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 19 Feb 2015, 11:31 AM
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.
@(Html.Kendo().Chart(Model)
  //....
  .Series(series =>
   {
    series.Line(
       model => model.Value,
       model => model.UserColor
    )
  })
  .Events(ev => ev.DataBound("onDB"))
)
 
<script>
function onDB(e) {
   e.sender.options.series[0].color = e.sender.options.series[0].data[0].UserColor
}
</script>
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.

Regards,
Iliana Nikolova
Telerik
 

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.

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