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

Color for CategoricalDataPoint

1 Answer 90 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Igor
Top achievements
Rank 1
Igor asked on 15 Dec 2014, 04:12 AM
I have RadCartesianChart with 10 CategoricalDataPoints. How can i set color for each CategoricalDataPoint programmatically?

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 15 Dec 2014, 01:06 PM
Hello Igor,

Let me start with a short explanation on that how the chart's data points are visualized. Most chart series (except the line series) have a default visual elements that represents its data points. This element can be replaced through the PointTemplate of the series, which means that there is no guarantee that the point will be always visualized with the series' default visual. 

The color of the data points cannot be set through the (Categorical)DataPoint model. One of the reasons is that if there is a custom PointTemplate the model won't know what property this elements use for setting its color and if there is such property.

To customize the color of the data points you can define a DefaultVisualStyle (or PointTemplate) and bind a Brush property from your view model to the color property of the visual element.

<telerik:BarSeries.DefaultVisualStyle>
    <Style TargetType="Border">
        <Setter Property="Background" Value="{Binding DataItem.PointBrush}" />
    </Style>
</telerik:BarSeries.DefaultVisualStyle>
Where the DataItem is a property of the DataPoint object that holds a reference to the view model behind the point. You can take a look at the Customizing CatesianChart Series help article to see how to define DefaultVisualStyle or PointTemplate.

I would also ask you to keep the communication about a particular issue or requirement in a single thread. This way we will be able to organize our communication history better and assist you in the most suitable manner for your case.  

Regards,
Martin
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
ChartView
Asked by
Igor
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or