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

Databinding a dynamic number of series

1 Answer 112 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 13 Aug 2008, 06:58 AM
Hello,

Could you please advise me on the best way to use databinding with RadChart when I have a dynamic number of series to plot?  I have a custom object 'ChartSeriesCollection' which contains a number of 'ChartSeries' objects representing the series for the chart.  Each ChartSeries contains a collection of custom 'ChartItem' objects.  Each ChartItem has an X and Y value property.

How can I databind a structure such as this to dynamically create the series and their individual points?

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 14 Aug 2008, 10:21 AM
Hello Jonathan,

I am afraid this scenario is not directly supported by RadChart. You can create the chart series and items manually by looping through the series and items and creating the corresponding objects in RadChart.

foreach (MyChartSeries mySer in MyChartSeriesCollection) 
        { 
            ChartSeries ser = new ChartSeries(); 
            RadChart1.Series.Add(ser); 
            foreach (MyChartItem myItem in mySer.Items) 
            { 
                ChartSeriesItem item = new ChartSeriesItem(); 
                item.XValue = myItem.XValue; 
                item.YValue = myItem.YValue; 
                ser.Items.Add(item); 
            } 
        } 


Best regards,
Ves
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Chart (Obsolete)
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Ves
Telerik team
Share this question
or