Control color of data points in RadHtmlChart programatically

259 views Asked by At

Can someone help me figure out how to do this? I need to change the color/shape of a datapoint based on a value in the datasource. If a certain value for each datarow is empty, display one shape. Otherwise, default to another shape.

I've tried using code blocks in the aspx file, but that isn't allowed.

I'm also trying to control it from the code behind, but I'm not sure how to access the datapoint once it has been plotted on the graph

Thanks!

1

There are 1 answers

0
rdmptn On

You can't access data points once rendered. They render on the client, so coloring must happen in the data source. See this demo for example: http://demos.telerik.com/aspnet-ajax/htmlchart/examples/functionality/custombarcolor/defaultcs.aspx.

It uses the ColorField property of the series to tell it where to take the item color from, and it is up to the data source to provide that color.

On changing the shape - probably you could via a Visual Template that comes with Q2 2015: http://docs.telerik.com/devtools/aspnet-ajax/controls/htmlchart/functionality/visual-template. I have not fiddled with this, so I cannot say whether the data item or at least the value are available in the visual function.