Binding the colour to BarSeries using ChartDataSource

2 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    6 posts
    Member since:
    Feb 2016

    Posted 11 Mar 2016 Link to this post


    I've followed the example here to colour each point of my BarSeries, but I can't make it work. Instead, all the points have turned invisible. The only difference I've noticied between my code and the example is that I use a ChartDataSource object as my points' source, instead of directly binding my collection to the property ItemsSource.

    This is my relevant code:

    <telerik:ChartDataSource Grid.Column="1" x:Name="VolumeChartDataSource" ItemsSource="{Binding VolumeSerie}" />

    Then, on the series definition:

        <telerik:BarSeries x:Name="VolumeS" ItemsSource="{Binding ElementName=VolumeChartDataSource}" ValueBinding="Y" CategoryBinding="X">
                <telerik:Direct2DRenderOptions />
                    <Rectangle Fill="{Binding Path=DataItem.Color}" />

    The datapoint class inside VolumeSerie has the properties X, Y and Color, all already set.

    Am I missing something?



  2. Dinko
    Dinko avatar
    440 posts

    Posted 16 Mar 2016 Link to this post

    Hello Jonathan,

    The behavior mentioned in your post is expected when using the RadChartView sampling source. Basically, ChartDataSource samples the original items which mean that it combines several data items into one and the DataItem property doesn't know which one to use. That's why it is empty. We have a feature request for adding support for this scenario. You can find it in our feedback portal where you can track its status and vote for its implementation.

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top