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

DataBinding RadCharts

2 Answers 129 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Yusuf
Top achievements
Rank 1
Yusuf asked on 23 Jul 2009, 12:07 AM
Hi,

I have a data source which looks like following:

PerformanceSeries is a List<Series>

Series has string Name and List<Pair> as Data.

Pair is nothing but a couplet of DateTime and value.

Now as obvious from the example above the Peformance Series contains a List of Series. Each Series needs to be plotted on the Chart as line series and the name to be shown as the Legend.

In Silverlight Chart we have each Line Series having an individual Data Source. So you can Create something of the sort:

            foreach(Series s in series)
            {
                LineSeries ls = new LineSeries();
                ls.ItemsSource = s.Data;
                ls.DependentValueBinding = new Binding("Value");
                ls.IndependentValueBinding = new Binding("Date");
                ls.Name = s.Name;
                ls.Title = s.Name;
                pCounters.Series.Add(ls);
            }
However with the RadChart there is no Source Property exposed at the Series level.  I was able to write something like this but then when i specify the source it fails completely.

foreach(Series s in series)
            {
                SeriesMapping seriesMapping = new SeriesMapping();
            seriesMapping.SeriesDefinition = new LineSeriesDefinition();
            seriesMapping.SeriesDefinition.ShowItemToolTips = true;
            
            
            ItemMapping itemMappingY = new ItemMapping();
            itemMappingY.DataPointMember = DataPointMember.YValue;
            itemMappingY.FieldName = "Value";

            ItemMapping itemMappingX = new ItemMapping();
            itemMappingX.DataPointMember = DataPointMember.XValue;
            itemMappingX.FieldName = "ChartDate";

            seriesMapping.ItemMappings.Add(itemMappingX);
            seriesMapping.ItemMappings.Add(itemMappingY);
            seriesMapping.LegendLabel = s.Name;
            chart.SeriesMappings.Add(seriesMapping);
            }
           chart.ItemSource = series; <---- It fails here... Because of my Collection Object
So i wanted to know is it possible to specify item sources for each series added in a chart independently rather than at the whole chart level. That is in the loop above i could have easily written seriesMapping.ItemSource = s.Data;

Thanks & Regards,
Yusuf Nazami

2 Answers, 1 is accepted

Sort by
0
Yusuf
Top achievements
Rank 1
answered on 27 Jul 2009, 05:56 AM
Any solution to the above mentioned problem?
0
Vladimir Milev
Telerik team
answered on 28 Jul 2009, 07:38 AM
Hi Yusuf,

Yes, it is possible to bind to two collections, however, you will need to restructure your data a bit. Please, take a look at this blog post which explains how to create two line series from a collection of collections.

Greetings,
Vladimir Milev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Chart
Asked by
Yusuf
Top achievements
Rank 1
Answers by
Yusuf
Top achievements
Rank 1
Vladimir Milev
Telerik team
Share this question
or