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

RadChart Multiple Series MVVM

1 Answer 191 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Derek
Top achievements
Rank 2
Derek asked on 14 Oct 2011, 08:49 PM
Hello,

I am trying to use the RadChart to bind to a Nested Collection.  I would like every member of the parent collection to represent a spline series that has a property named CollectionName property to bind to the Legend Label.  Then I want to have each child collection have its members mapped to the points along the spline.  This code works:

 

 

 

<Telerik:RadChart ItemsSource="{Binding Path=SeriesCollection,Mode=TwoWay}" x:Name="chartcontentseries" >

<telerik:RadChart.DefaultSeriesDefinition>

<telerik:SplineSeriesDefinition></telerik:SplineSeriesDefinition>

</telerik:RadChart.DefaultSeriesDefinition>

<telerik:RadChart.SeriesMappings>

<telerik:SeriesMapping CollectionIndex="0" LegendLabel="{Binding Path=CollectionName}">

                       (I have to have this set)       (This does not display the collection name!)

<telerik:ItemMapping FieldName="Percentage" DataPointMember="YValue"></telerik:ItemMapping>

</telerik:SeriesMapping>

</telerik:RadChart.SeriesMappings>

 

</telerik:RadChart>


However, I have to have a SeriesMapping for every collection that is added which is undesirable and the LegendLabel does not display the collection name.  Is there a way in XAML to set up a template for the series and have them automatically added and removed when the collection changes?  Or do I have to do it all manually in code behind?

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 19 Oct 2011, 09:12 AM
Hi Derek,

You would have to handle the collection changes in code behind, unfortunately having templates for the series and doing this in XAML is not supported. Currently RadChart requires a series mapping for each series that is visible on the screen.

You can bind your SeriesMapping to your view model and modify them from there. Keep in mind that the SeriesMappings are configuration objects and are not included in the visual tree, that's why they don't have DataContext and the bindings don't work as expected, which is why the CollectionName is not displayed as well.You would have to create a CollectionName property in your view model and map it to LegendLabel in order to display it correctly.

All the best,
Nikolay
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
Chart
Asked by
Derek
Top achievements
Rank 2
Answers by
Nikolay
Telerik team
Share this question
or