Page 1 of 1
Refresh on Tchart doesn't work
Posted: Mon Jul 02, 2012 2:01 pm
by 10048147
After deleting a data point in a series, and then trying to refresh the chart to update the axis and data points, etc., at the end of the procedure that deletes the data point, the chart will not refresh.
If, however, I issue a refresh through another procedure, say a buttonclick, the chart will refresh.
Is this a bug? How can I workaround?
I am using TeeChart v8.02.10861 Win32 in Delphi 2007 on Windows Vista.
Thanks,
Dennis
Re: Refresh on Tchart doesn't work
Posted: Mon Jul 02, 2012 2:59 pm
by 10048147
Further to my last post....
I guess what I need to know is when is the best 'time' to add data points to a series. As I have a series that is determined by the values of another (source) series, I am calculating the data points (with code) in the 'after draw' event of the source series.
Is this the best 'place'?
Re: Refresh on Tchart doesn't work
Posted: Mon Jul 02, 2012 5:31 pm
by yeray
Hi Dennis,
den wrote:After deleting a data point in a series, and then trying to refresh the chart to update the axis and data points, etc., at the end of the procedure that deletes the data point, the chart will not refresh.
If, however, I issue a refresh through another procedure, say a buttonclick, the chart will refresh.
Is this a bug? How can I workaround?
I'm trying to reproduce the situation you describe in a simple example but the following code already refreshes the chart even without calling any "refresh" method (Chart1.Draw, Chart1.Refresh, Chart1[0].Refresh,...).
I guess I'm missing something relevant to reproduce the problem, so it would be helpful if you could modify the code below so we can reproduce the problem here. Or please, arrange a simple project for the same purpose.
Code: Select all
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D := false;
Chart1.AddSeries(TPointSeries).FillSampleValues;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Chart1[0].Delete(0);
end;
den wrote:I guess what I need to know is when is the best 'time' to add data points to a series. As I have a series that is determined by the values of another (source) series, I am calculating the data points (with code) in the 'after draw' event of the source series.
Is this the best 'place'?
We'd need some more details on how the data arrives to the "source" series but I'd say the best moment to refresh the "dependant" series is in the same method that captures new data for the "source" series.
Note the AfterDraw event can be executed several times, when scrolling, zooming, etc, so the "dependant" series may be refreshed unnecessarily.
Also note you should be careful when calling a refresh function at the AfterDraw event, because you may create an endless loop.
Re: Refresh on Tchart doesn't work
Posted: Mon Jul 02, 2012 10:04 pm
by 10048147
Yeray:
Thanks for your prompt reply to my posting.
You are correct, I was causing an endless loop. I have found a correction for the problem though.
I didn't know the best place (event) to calculate the dependant series. I now calculate the dependant series from the source series data right after the dataset for the source series is activated.
All is well now! (the dependant series now refreshes on its own).
Sorry for 'wasting' your time.
Thanks,
Dennis
Re: Refresh on Tchart doesn't work
Posted: Tue Jul 03, 2012 7:43 am
by yeray
Hi Dennis,
Glad to be helpful!
Don't hesitate to let us know if you find any other problem with it.