DataBinding RadCharts

3 posts, 0 answers
  1. Yusuf
    Yusuf avatar
    15 posts
    Member since:
    Jan 2009

    Posted 22 Jul 2009 Link to this post

    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. Yusuf
    Yusuf avatar
    15 posts
    Member since:
    Jan 2009

    Posted 27 Jul 2009 Link to this post

    Any solution to the above mentioned problem?
  3. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 28 Jul 2009 Link to this post

    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.
Back to Top