tlineseries.clear method when changing array size lazarus / 55-TAChart ---------------------------------------------------------------------- jkorten · 2012-07-11 14:59 Hello everyone. I'm a happy new user of tachart. Have a question about clearing the line series. I use a tlineseries associated with a tchart (simple x,y plotting) and when I change the array size from say 4096 to 2048, even though I call the clear function, the leftover data from the previous plot appears on the chart. How can I reset the extent of the line series? (I assume the first time I load up the tlineseries with an array, the object now assumes there are that many elements always in the tlineseries.) Many thanks for your help in advance. Jerry ---------------------------------------------------------------------- Ask · 2012-07-11 19:18 QuoteI use a tlineseries associated with a tchart (simple x,y plotting) and when I change the array size from say 4096 to 2048, even though I call the clear function, the leftover data from the previous plot appears on the chart. How do you connect the series to the array? Do you use user-defined source? Please describe what you are doing in more detail or post a relevant part of your code. ---------------------------------------------------------------------- jkorten · 2012-07-11 21:15 I double clicked on the tchart object and added a line series. Then when I want to update the series I execute the following code... form1.psd_data_series.Clear;   form1.psd_data_series.BeginUpdate;   with form1.psd_chart do   begin     if psd_smoothing then     begin       for i := 1 to (m div 2) do         form1.psd_data_series.addxy(freq'['i']', smth'['i']')     end     else       for i := 1 to (m div 2) do         form1.psd_data_series.AddXY(freq'['i']', amp'['i']');   end;   form1.psd_data_series.EndUpdate;   form1.psd_chart.Invalidate; However, if I change (to a lower number) the number of points I am putting into the line series (m) then execute the above code, there is garbage left from the previous array. (Sorry I quoted the array brackets as it screwed up the html) ---------------------------------------------------------------------- wp · 2012-07-11 21:51 In the attached demo the number of points and the range of the data is varied with each click on the button. As you can see the chart perfectly adapts to each data set. Did you modify the chart's extent? For automatic scaling it is important to have the properties UseXMin, UseXMax, UseYMin and UseYMay of Chart.Extent at false. ---------------------------------------------------------------------- jkorten · 2012-07-11 22:54 Strange - I have to remove the line   RequireDerivedFormResource := True; in order for your demo to compile. I've tried setting the extent properties as suggested but no joy. I will have to delete the tchart object and drop a new one in and see if any property was inadvertently set. I can set all my Y values to 0, but when I change from 4096 pairs to 2048 pairs you see the line go back in the x direction and swipe zeros across the bottom. I'm assuming this array size is certainly within limits. I'll try looking at the getxmax etc first and report back on what I find. Thank you very much for your help! ---------------------------------------------------------------------- wp · 2012-07-12 07:04 It seems that you have an old version of Lazarus. Remove the BeginUpdate and EndUpdate calls from your code - if I remember correctly a missing update of the chart's extent in EndUpdate had been fixed by Ask recently. Alternatively, try one of the daily snapshots. ---------------------------------------------------------------------- jkorten · 2012-07-12 13:16 Removed beginupdate and endupdate and window refreshes well now. (I am using 0.9.30.4 so still unclear about the requirederivedfromsource statement - but I will deal with this later). Array filling was in error - hence the previous data appearing. Who would have thought I'd had a math error in there? All working well now. Thanks!