Line Series on Complex Type

3 posts, 0 answers
  1. Guillaume
    Guillaume avatar
    39 posts
    Member since:
    Nov 2010

    Posted 02 Feb 2011 Link to this post

    Hello,

    I try to use the chart with Line serie on a collection of a complex type.

    In my ViewModel, i have an ObservableCollection<NumerizationOperatorByDate> OperatorsByDate with that :
    public class NumerizationOperatorByDate
        {
            public string FullName { get; set; }
     
            public List<NumerizationFoldersByDate> NbFoldersProcessedByDate { get; set; }
       }
     
    public class NumerizationFoldersByDate : ReturnObject
        {
            public DateTime Date { get; set; }
     
            public int NbFoldersProcessed { get; set; }
        }

    Ok and in my View, i have that :
    <telerik:RadChart ItemsSource="{Binding OperatorsByDate}"
                                                          Content=""
                                                          BorderBrush="Black"
                                                          Width="400"
                                                          Height="300"
                                                          BorderThickness="0"
                                                          d:LayoutOverrides="HorizontalMargin">
                                            <telerik:RadChart.SeriesMappings>
                                                <telerik:SeriesMapping>
                                                    <telerik:SeriesMapping.SeriesDefinition>
                                                        <telerik:LineSeriesDefinition />
                                                    </telerik:SeriesMapping.SeriesDefinition>
                                                    <telerik:ItemMapping DataPointMember="XValue"
                                                                         FieldName="NbFoldersProcessedByDate.Date />
                                                    <telerik:ItemMapping DataPointMember="YValue"
                                                                         FieldName="NbFoldersProcessedByDate.NbFoldersProcessed />
                                                </telerik:SeriesMapping>
                                            </telerik:RadChart.SeriesMappings>
                                            <telerik:RadChart.DefaultView>
                                                <telerik:ChartDefaultView ChartLegendPosition="Bottom">
                                                    <telerik:ChartDefaultView.ChartArea>
                                                        <telerik:ChartArea SmartLabelsEnabled="true"
                                                                           Margin="0 />
                                                    </telerik:ChartDefaultView.ChartArea>
                                                    <telerik:ChartDefaultView.ChartLegend>
                                                        <telerik:ChartLegend Visibility="Collapsed />
                                                    </telerik:ChartDefaultView.ChartLegend>
                                                </telerik:ChartDefaultView>
                                            </telerik:RadChart.DefaultView>
                                        </telerik:RadChart>

    In fact, i want a line for each NumerizationOperator and in X axis, DateTimes and in Y axis, int.

    Where i'm wrong ?

    Best regards,
    Guillaume
  2. Guillaume
    Guillaume avatar
    39 posts
    Member since:
    Nov 2010

    Posted 03 Feb 2011 Link to this post

    Re,

    I downloaded your example and opened it. As you, i created a dep property of type SeriesMappingCollection and copied the InitializeLineChartSeriesMappings but in the code, when you pass the field name (in CreateSeriesMapping) :

    result.ItemMappings.Add(new ItemMapping("Date", DataPointMember.XCategory));

    I can't do the same thing, because my property is in the sub object of my class : according to my object model above :
    NumerizationOperatorByDate > NbFoldersProcessedByDate > Date

    So, if i do that :

    result.ItemMappings.Add(new ItemMapping("NbFoldersPrcessedByDate.Date", DataPointMember.XCategory));

    I have a NullReferenceException when the OnPropertyChanged on the dep property SeriesMappingCollection.

    Can you help me ? Because i think it's not possible to target a sub property.

    Best Regards,
    Guillaume

  3. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 07 Feb 2011 Link to this post

    Hello Guillaume,

    I understand your scenario, but first let me explain a little bit more on how RadChart creates series from the data in the ItemsSource. To support complex scenarios RadChart introduces the SeriesMapping object. This non-visual element describes how the underlying data from the ItemsSource has to be mapped to the series. As you may want your series to be mapped differently, you have to add a SeriesMapping object for every series that you want to display on the screen.

    Currently RadChart's support for nested collections requires your seriesmapping to have collection index (described in our help topic) and the data for this mapping to be available in the underlying collection on the specified index like in the image below:

    If you remove the IEnumerable implementation of your business object the data for the series will be accessible through the Data property like in the image below:


    Currently RadChart SeriesMappings do not support such type of binding, but this feature is planned for Q1 of 2011. When this feature is available you will be able to configure ItemsSource per SeriesMapping.

    You can find a sample project attached that represents the scenario you have.

    Regards,
    Evgenia
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Back to Top