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

Binding to DataSeriesCollection

6 Answers 89 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Farhan
Top achievements
Rank 1
Farhan asked on 22 Oct 2010, 12:19 AM
Telerik has a DataSeriesCollection which I am using to add different line data series. Is there a way in which I could bind this series to the itemsmapping collection?
Because right now I am not using any binding and in my core behind I am using the DataSeries.AddRange method to add the data series collection.
Help would be much appreciated!
Thanks,
Farhan

6 Answers, 1 is accepted

Sort by
0
Evgeni "Zammy" Petrov
Telerik team
answered on 27 Oct 2010, 10:08 AM
Hello Farhan,

 Thank you for contacting us.

DataSeriesCollection is not intended to be used by the user for binding data. You need to create your SeriesMapping and ItemMappings and then set the data to ItemSource

Here you can read for SeriesMapping:
http://www.telerik.com/help/silverlight/radchart-populating-with-data-data-binding-with-manual-series-mapping.html
Here is a link to read about binding nested collections as it seems to me that you are trying to do something similar:
http://www.telerik.com/help/silverlight/radchart-populating-with-data-data-binding-to-nested-collections.html

Sincerely yours,
Evgeni "Zammy" Petrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Farhan
Top achievements
Rank 1
answered on 27 Oct 2010, 06:16 PM
Thanks for your response. The examples that you have pointed to involve columns to be declared in Xaml in the itemsmapping.
My scenario is such that the user can select columns dynamically and then the chart would display accordingly.Therefore in that case I'll have to declare the itemsmapping in the code-behind? Isn't there any way to execute my scenario declaratively. If I could create create a Series Mapping in my view model and bind it declaratively, is that scenario possible? In your view what would be the best possible solution.

Scenario:
X-Axis will have a period
Y-Axis can have one of the selections:
1) Interest
2) Principal
3) Losses
4) Payments
5) Yields

Thanks,
Farhan
0
Jerry
Top achievements
Rank 1
answered on 28 Oct 2010, 03:19 AM
I have meet the same question!

For example,I have such datasource:
Dictionary<string,ObservableCollection<InspClock>> dataSource;

I want to generate dataSource.Count DataSeries througth looping dataSource,How do I?
By SeriesMapping class just only can add multichart by assigning the different column in same datasource!
0
Evgeni "Zammy" Petrov
Telerik team
answered on 01 Nov 2010, 05:17 PM
@Farhan

I would suggest you to create 5 SeriesMappings and hide dynamically the ones you want.
Here is the code how you can edit SeriesMapping visibility:

RC1.DefaultView.ChartArea.DataSeries[0].Definition.Visibility = SeriesVisibility.Collapsed;

Simply hide all and show only the one the user wants to see.
You can also check our hover interactivity:
http://www.telerik.com/help/silverlight/radchart-features-interactivity-effects.html

Let us know if this helped you out.


@Jerry:

You can map data source with SeriesMapping if you have collection in collection. You can do it if you have source like: List<ObservableCollection<InspClock>> dataSource; 

I would love to help you out, but I am afraid  I cannot understand fully your use-case. Would you please elaborate further on your problem?

Best regards,
Evgeni "Zammy" Petrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Farhan
Top achievements
Rank 1
answered on 01 Nov 2010, 07:40 PM
The problem with creating 5 series mappings is that in the future the fields that the user can select through would only increase. For example within the course of development the fields are expected to be in the range of 20. So it might not be practical to create 20 series mappings.
What would be the best possible scenario.
Thanks,
Farhan
0
Evgeni "Zammy" Petrov
Telerik team
answered on 03 Nov 2010, 07:14 PM
Hello Farhan,

Anyway, in that case I guess your only solution is to add SeriesMappings dynamically. 
Just like you would define it in C# you can add them after chart was drawn :

SeriesMapping seriesMapping = new SeriesMapping();
seriesMapping.ItemMappings.Add(new ItemMapping("Salary", DataPointMember.YValue));
seriesMapping.ItemMappings.Add(new ItemMapping("Age", DataPointMember.XValue));
seriesMapping.SeriesDefinition = new LineSeriesDefinition()
RC1.SeriesMappings.Add(seriesMapping);

The previous code adds a mapping of Persons's Salary and Age property.
This code works in a event handler without a problem.

Let me know if you need any further assistance.

Regards,
Evgeni "Zammy" Petrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Farhan
Top achievements
Rank 1
Answers by
Evgeni "Zammy" Petrov
Telerik team
Farhan
Top achievements
Rank 1
Jerry
Top achievements
Rank 1
Share this question
or