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

SeriesProvider and Generic Data Point Bindings

4 Answers 111 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Colter
Top achievements
Rank 1
Colter asked on 26 Jun 2013, 06:32 PM
Hello,

I think I want to use the Series Provider in xaml where I am defining my charts as I'm not entirely sure how many series there will be.

I do however want to use Generic DataPoint Bindings for the Value and Categories, and I don't see there being a way of doing that in xaml using the SeriesDescriptors.  I feel like this isn't possible to do entirely of xaml since the Generic Data Point Bindings use lambda statements.. but maybe with a converter.. I just don't see it being a possibility with the SeriesDescriptor class.

Any thoughts?

Regards,

Colter

4 Answers, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 01 Jul 2013, 12:46 PM
Hello Colter,

Straight to your questions:

  1. The number of the generated series depends on the number of collections in the itemssource. You can read more about the series provided here.
  2. Yes, you are correct. Because of the lambda expressions, you cannot define GenericDataPointBindings in XAML. You can read more about RadChartView support for GenericDataPointBindings in our online documentation:
    1. http://www.telerik.com/help/silverlight/radchartview-populating-with-data-binding-to-data-table.html
    2. http://www.telerik.com/help/silverlight/radchartview-series-databinding.html
Regards,
Tsvetie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Louis
Top achievements
Rank 1
answered on 17 Sep 2013, 04:31 PM
Hi,

I'm trying to do the same thing of using GenericDataPointBindings against a SeriesProvider. While I understand how to do each of these individually, I have not been able to find the right way to combine the two, since CategoricalSeriesDescriptor does not support the ValueBinding property like a Series does (it only has ValuePath). How does one attach the GenericDataPointBinding to the variable number of axes generated by the SeriesProvider?

Thanks,
Louis
0
Petar Kirov
Telerik team
answered on 19 Sep 2013, 09:21 AM
Hi Louis,

In order to set GenericDataPointBindings through XAML, you will need to define them as StaticResources. To do that you will need to make classes for each of the different bindings you want to have, that inherit from GenericDataPointBinding in order to make it non-generic and to set the ValueSelector in the constructor. Here's an example:
public class ChartPoint
{
    public string XCat { get; set; }
    public double Value { get; set; }
}
 
public class CategoryBinding : GenericDataPointBinding<ChartPoint, string>
{
    public CategoryBinding()
    {
        this.ValueSelector = (cp) => cp.XCat;
    }
}
 
public class ValueBinding : GenericDataPointBinding<ChartPoint, double>
{
    public ValueBinding()
    {
        this.ValueSelector = (cp) => cp.Value;
    }
}
<UserControl.Resources>
    <local:CategoryBinding x:Key="categoryBinding"/>
    <local:ValueBinding x:Key="valueBinding"/>
</UserControl.Resources>
 
<telerik:RadCartesianChart>
  <telerik:RadCartesianChart.SeriesProvider>
    <telerik:ChartSeriesProvider Source="{Binding Series}">
       <telerik:ChartSeriesProvider.SeriesDescriptors>
         <telerik:CategoricalSeriesDescriptor ItemsSourcePath="ChartPoints">
           <telerik:CategoricalSeriesDescriptor.Style>
             <Style TargetType="telerik:BarSeries">
               <Setter Property="CategoryBinding"
                    Value="{StaticResource categoryBinding}"/>
               <Setter Property="ValueBinding"
                    Value="{StaticResource valueBinding}"/>            
             </Style>

I hope this helps.
 
Regards,
Petar Kirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Louis
Top achievements
Rank 1
answered on 19 Sep 2013, 04:18 PM
This approach worked great, thank you very much!
Louis
Tags
Chart
Asked by
Colter
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Louis
Top achievements
Rank 1
Petar Kirov
Telerik team
Share this question
or