SeriesProvider and Generic Data Point Bindings

5 posts, 0 answers
  1. Colter
    Colter avatar
    10 posts
    Member since:
    Apr 2013

    Posted 26 Jun 2013 Link to this post

    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
  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 01 Jul 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. Louis
    Louis avatar
    83 posts
    Member since:
    Aug 2013

    Posted 17 Sep 2013 Link to this post

    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
  5. Petar Kirov
    Admin
    Petar Kirov avatar
    425 posts

    Posted 19 Sep 2013 Link to this post

    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 >>
  6. Louis
    Louis avatar
    83 posts
    Member since:
    Aug 2013

    Posted 19 Sep 2013 Link to this post

    This approach worked great, thank you very much!
    Louis
Back to Top
DevCraft banner