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

Line Series on Complex Type

2 Answers 26 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Guillaume asked on 02 Feb 2011, 03:17 PM

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}"
                                                    <telerik:LineSeriesDefinition />
                                                <telerik:ItemMapping DataPointMember="XValue"
                                                                     FieldName="NbFoldersProcessedByDate.Date />
                                                <telerik:ItemMapping DataPointMember="YValue"
                                                                     FieldName="NbFoldersProcessedByDate.NbFoldersProcessed />
                                            <telerik:ChartDefaultView ChartLegendPosition="Bottom">
                                                    <telerik:ChartArea SmartLabelsEnabled="true"
                                                                       Margin="0 />
                                                    <telerik:ChartLegend Visibility="Collapsed />

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,

2 Answers, 1 is accepted

Sort by
Top achievements
Rank 1
answered on 03 Feb 2011, 12:01 PM

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,

Telerik team
answered on 07 Feb 2011, 02:59 PM
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.

the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Asked by
Top achievements
Rank 1
Answers by
Top achievements
Rank 1
Telerik team
Share this question