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

Create multiple ChartSeries on runtime

1 Answer 61 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Viky
Top achievements
Rank 1
Viky asked on 05 Nov 2012, 06:28 AM
Hi All,
Greeting of the day!

I am using radchart and i want to create chartseries on runtime using for loop.
Suppose, i take a int i variable and assign 5 into i first time then chart series will be created 5.

Please suggest me, how we will do this.

Thanks
Viky

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Nov 2012, 07:17 AM
Hi Viky,

I suppose you want to add ChartSeries dynamically. Please take a look into the following code snippet that I tried to add ChartSeries to the RadChart onclick of a button.

ASPX:
<telerik:RadChart ID="RadChart1" runat="server"></telerik:RadChart>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" />

C#:
protected void Button1_Click(object sender, EventArgs e)
{
    ChartSeries chartSeries = new ChartSeries();
    chartSeries.Name = "Sales";
    chartSeries.Type = ChartSeriesType.Bar;
    for (int i = 0; i < 5; i++)
    {
        chartSeries.AddItem(i, "Series"+i);
    }
    RadChart1.Series.Add(chartSeries);
}

Hope this helps.

Regards,
Princy.
Tags
Chart (Obsolete)
Asked by
Viky
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or