Dynamic SeriesMapping Creation

2 posts, 0 answers
  1. Suresh K
    Suresh K avatar
    68 posts
    Member since:
    Apr 2009

    Posted 01 Oct 2011 Link to this post

    Hi.
    I am new to telerik Silverlight tools.Can any body help me
    How to Create Dynamic SerieMapping in Telerik Radchart.
    suppose i have 3 collections list from DataBase i want to dispaly 3 series in Graph.
    if i have 4 collections list i want to display 4 series.

    can Any body help me how to create it.



    Thanks & Regards

    Suresh K
  2. Rahul
    Rahul avatar
    116 posts
    Member since:
    Feb 2011

    Posted 30 Dec 2011 Link to this post

    Hi Suresh,

    Check below code it may  help you.

    public partial class MainPage : UserControl
       {
           public MainPage()
           {
               InitializeComponent();
               radChart1.Loaded += new RoutedEventHandler(radChart1_Loaded);
                
           }
     
           void radChart1_Loaded(object sender, RoutedEventArgs e)
           {
     
               List<PersonName> lst = new List<PersonName>();
               lst.Add(new PersonName { Subject = "Maths", Percentage = 3 });
               lst.Add(new PersonName { Subject = "English", Percentage = 6 });
               lst.Add(new PersonName { Subject = "Marathi", Percentage = 9 });
               lst.Add(new PersonName { Subject = "Hindi", Percentage = 14 });
     
     
     
               
     
               for (int i = lst.Count - 1; i >= 0; i--)
               {
                   LineSeriesDefinition bar = new LineSeriesDefinition { ShowItemLabels = true };
                   bar.Appearance.Fill = new SolidColorBrush(Colors.Blue);
                   SeriesMapping smLT10 = new SeriesMapping();
                   smLT10.ItemMappings.Add(new ItemMapping() { FieldName = "Subject", DataPointMember = DataPointMember.XCategory });
                   smLT10.ItemMappings.Add(new ItemMapping() { FieldName = "Percentage", DataPointMember = DataPointMember.YValue });
                   smLT10.SeriesDefinition = bar;
                   radChart1.SeriesMappings.Add(smLT10);
               }
               radChart1.ItemsSource = lst;
               
           }
     
           
       }
       public class PersonName
       {
            
           public string Subject{get;set;}
           public int Percentage{get;set;}
            
       }

    Regards
    Rahul
  3. DevCraft banner
Back to Top