How do I clear/reset a chart

5 posts, 0 answers
  1. Steven
    Steven avatar
    32 posts
    Member since:
    Jul 2012

    Posted 16 Jul 2012 Link to this post

    I have an html chart that I generate some series for based on whatever is selected in a combobox. How do I reset the chart when I have new data for it?

    I pretty much add the series myself.

    RadHtmlChart1.PlotArea.Series.Add(Task1Series);

    RadHtmlChart1.PlotArea.Series.Add(Task1Trend);

    RadHtmlChart1.PlotArea.Series.Add(Task2Series);

    RadHtmlChart1.PlotArea.Series.Add(Task2Trend);

    the other chart control has a clear() method, but I am not seeing it here.

    RadHtmlChart1.PlotArea.Series.Clear(); doent seem to work either.

    Thanks

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

    Posted 16 Jul 2012 Link to this post

    Hi Steven,

    Following is the code that I tried to clear the series on a Button click. Clear method is working as expected at my end.

    ASPX:

    <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server"></telerik:RadHtmlChart>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" />

    C#:
    protected void Page_Load(object sender, EventArgs e)
     {
       ColumnSeries series1 = new ColumnSeries();
       series1.Name = "IE";
       series1.Stacked = true;
       SeriesItem SeriesItem11 = new SeriesItem();
       SeriesItem11.YValue =0;
       SeriesItem SeriesItem12 = new SeriesItem();
       SeriesItem12.YValue = 0;
       SeriesItem SeriesItem13 = new SeriesItem();
       SeriesItem13.YValue = 48;
       SeriesItem SeriesItem14 = new SeriesItem();
       SeriesItem14.YValue = 41;
       SeriesItem SeriesItem15 = new SeriesItem();
       SeriesItem15.YValue = 34;
       series1.Items.Add(SeriesItem11);
       series1.Items.Add(SeriesItem12);
       series1.Items.Add(SeriesItem13);
       series1.Items.Add(SeriesItem14);
       series1.Items.Add(SeriesItem15);
       RadHtmlChart1.PlotArea.Series.Add(series1);
     }
    protected void Button1_Click(object sender, EventArgs e)
     {
       RadHtmlChart1.PlotArea.Series.Clear();
     }

    Please provide your code where I can replicate your problem locally if it doesn't helps.

    Regards,
    Princy.

  3. Steven
    Steven avatar
    32 posts
    Member since:
    Jul 2012

    Posted 17 Jul 2012 Link to this post

    I figured it out, I also had to do a

     

    RadHtmlChart1.PlotArea.XAxis.Items.Clear();

  4. Qurat
    Qurat avatar
    21 posts
    Member since:
    Jan 2013

    Posted 25 Feb 2013 Link to this post

    just simply add this line it will clear the previous data 
     PieChart1.PlotArea.Series[0].Items.Clear();
    after that databind again to new value

    regards
    @nnu shah
    Punjab lokh sujag

  5. Rob
    Rob avatar
    3 posts
    Member since:
    Dec 2012

    Posted 04 Aug 2013 Link to this post

    This is what did it for me as well! Thanks for posting.  :)

    RadHtmlChart1.PlotArea.XAxis.Items.Clear();

Back to Top