Create multiple ChartSeries on runtime

Thread is closed for posting
2 posts, 0 answers
  1. Viky
    Viky avatar
    9 posts
    Member since:
    Apr 2012

    Posted 05 Nov 2012 Link to this post

    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.

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Nov 2012 Link to this post

    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.

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

    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);

    Hope this helps.

Back to Top