Color for CategoricalDataPoint

2 posts, 0 answers
  1. Igor
    Igor avatar
    4 posts
    Member since:
    Dec 2014

    Posted 14 Dec 2014 Link to this post

    I have RadCartesianChart with 10 CategoricalDataPoints. How can i set color for each CategoricalDataPoint programmatically?
  2. Martin Ivanov
    Martin Ivanov avatar
    1442 posts

    Posted 15 Dec 2014 Link to this post

    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.

        <Style TargetType="Border">
            <Setter Property="Background" Value="{Binding DataItem.PointBrush}" />
    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.  


    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