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

Dynamic SeriesMapping Creation

1 Answer 34 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Suresh K
Top achievements
Rank 1
Suresh K asked on 01 Oct 2011, 11:03 AM
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

1 Answer, 1 is accepted

Sort by
0
Rahul
Top achievements
Rank 2
answered on 30 Dec 2011, 05:44 PM
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
Tags
Chart
Asked by
Suresh K
Top achievements
Rank 1
Answers by
Rahul
Top achievements
Rank 2
Share this question
or