Changing chart types runtime

Thread is closed for posting
2 posts, 0 answers
  1. Debashis Pyne
    Debashis Pyne avatar
    66 posts
    Member since:
    Apr 2010

    Posted 28 Aug 2010 Link to this post

    Hi,

    I have a drop down control which lists 4 of the chart types (Area, Pie, Line and Bar).

    My default chart type is Pie.
    I would like to change the chart type dynamically during run time based on the selection in the drop down.

    The folllowing the code I have used:

    protected void DdlChartType_SelectedIndexChanged(object sender, EventArgs e)
    {
    radChart.Clear();
    chartSeries.Clear();

    TextBox1.Text = DdlChartType.SelectedValue.ToString();
    if (DdlChartType.SelectedValue == "ChartSeriesType.Area")
    {
    chartSeries.Type = ChartSeriesType.Area;
    Chart1();
    }
    else if (DdlChartType.SelectedValue == "ChartSeriesType.Pie")
    {
    chartSeries.Type = ChartSeriesType.Pie;
    Chart1();
    }
    }
    }


    protected void Chart1()
    {
    radChart.ChartTitle.TextBlock.Text = "My RadChart";
    chartSeries.Name = "Sales";
    chartSeries.AddItem(120, "Internet");
    chartSeries.AddItem(140, "Retail");
    chartSeries.AddItem(35, "Wholesale");
    radChart.Series.Add(chartSeries);
    this.Page.Controls.Add(radChart);
    }


    The problem is I am always getting the same chart type and it does not change.
    is it beacuse if cache?
    Any ideas?

    Thanks!!
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 01 Sep 2010 Link to this post

    Hello Debashis,

    Attached to this message, is a small application, which handles a functionality close to the one which you mentioned. I hope it gets you started properly.

    Regards,
    Yavor
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top