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

Binding the colour to BarSeries using ChartDataSource

1 Answer 108 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 11 Mar 2016, 09:53 AM

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.

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 16 Mar 2016, 08:46 AM
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.
Tags
ChartView
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or