Binding the colour to BarSeries using ChartDataSource

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

    Posted 11 Mar Link to this post

    Hi,

    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:RadCartesianChart.Series>
        <telerik:BarSeries x:Name="VolumeS" ItemsSource="{Binding ElementName=VolumeChartDataSource}" ValueBinding="Y" CategoryBinding="X">
            <telerik:BarSeries.RenderOptions>
                <telerik:Direct2DRenderOptions />
            </telerik:BarSeries.RenderOptions>
            <telerik:BarSeries.PointTemplate>
                <DataTemplate>
                    <Rectangle Fill="{Binding Path=DataItem.Color}" />
                </DataTemplate>
            </telerik:BarSeries.PointTemplate>
        </telerik:BarSeries>
    </telerik:RadCartesianChart.Series>

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

    Am I missing something?

    Thanks,

    Jonathan.

  2. Dinko
    Admin
    Dinko avatar
    201 posts

    Posted 16 Mar 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.

    Regards,
    Dinko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top