[Solved] TAChart: how to reset a plot? lazarus / 55-TAChart ---------------------------------------------------------------------- madepabloh · 2011-08-24 19:07 I am plotting data into a chart. I would like to reset the plot and delete the data in order to start again but without to close the program and run it again. I tried different options: Code: [Select]Chart1. Series. Free; Chart1.Series.CleanupInstance; Chart1.CleanupInstance; Chart1.ClearSeries; So i am a little bit lost. Any idea about how could i do that? Thanks! ---------------------------------------------------------------------- wp · 2011-08-24 21:06 Depends on what you want to do exactly. I assume that your chart contains one or more series that you created at design-time and you just want to plot new data in these series. Just call the method "Clear" of each series. This erases the data from the series. Now you can add new data to the series. Unless you fixed the axis extent the axes will be updated automatically. ---------------------------------------------------------------------- madepabloh · 2011-08-24 21:30 Exactly!! This is what i was looking for! I tried with Chart1.Series.Clear; but it produces error. Now, doing Clear with each serie works perfectly like this: Code: [Select]LineSerie1.Clear; Thanks WP!! ---------------------------------------------------------------------- wp · 2011-08-24 22:51 The reason why Chart1.Series.Clear does not work is because the TChart property Series is an array containing all the series. So you should call Chart1.Series[0].Clear to erase the first series, or Code: [Select]for i:=0 to Chart1.SeriesCount-1 do   Chart1.Series[i].Clear; to clear all. In addition, each series has the name given in the Object Inspector. Therefore, you can also reference the series by this name (such as "LineSerie2"). ---------------------------------------------------------------------- madepabloh · 2011-08-25 10:46 Thanks for the explanation... i see now what i was doing wrong... And your code is much more simple than call one by one all the series. Thanks wp! ---------------------------------------------------------------------- jw · 2012-01-28 02:44 is my lazarus to old for wp's code to work? for i:=0 to Chart.SeriesCount-1 do          chart.Series.Clear;      fails to compile  identifier ident no member clear 0.9.30 2.4.2 ---------------------------------------------------------------------- Ask · 2012-01-28 05:56 Hm, actually both your and his code is incorrect. You can either use chart.Series.Clear to remove all series (this, naturally, does not need to be in a loop) or TChartSeries.Clear to remove all data from the specific series' source. wp: Are you sure that the code you posted ever worked for you? Both in trunk and 0.9.30 the Clear method is in the TChartSeries, not in TBasicChartSeries, so a cast is required. ---------------------------------------------------------------------- wp · 2012-01-28 08:26 Oh, you are right in both cases -- I was not aware of the Clear method of the TChartSeriesList ---------------------------------------------------------------------- jw · 2012-01-29 17:45 tchartseries.clear works to clear a single series one by one, but chart.series.clear does nothing. ---------------------------------------------------------------------- Ask · 2012-01-29 18:13 Quote from: jw on January 29, 2012, 06:45:00 pmchart.series.clear does nothing. It does remove all series, but does not refresh the chart -- which I have fixed in r34981. You can either back-port the fix to your local copy or refresh the chart manually. ---------------------------------------------------------------------- jw · 2012-01-29 23:41 I can't find the package in the svn https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus- ccr/components/ is it easiest to just download the latest a daily snapshot? ---------------------------------------------------------------------- Ask · 2012-01-30 03:23 Yes. TAChart package is part of the Lazarus repository.