Refresh on Tchart doesn't work

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
den
Newbie
Newbie
Posts: 15
Joined: Wed Jan 30, 2008 12:00 am

Refresh on Tchart doesn't work

Post by den » Mon Jul 02, 2012 2:01 pm

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

den
Newbie
Newbie
Posts: 15
Joined: Wed Jan 30, 2008 12:00 am

Re: Refresh on Tchart doesn't work

Post by den » Mon Jul 02, 2012 2:59 pm

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'?

Yeray
Site Admin
Site Admin
Posts: 9587
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Refresh on Tchart doesn't work

Post by Yeray » Mon Jul 02, 2012 5:31 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

den
Newbie
Newbie
Posts: 15
Joined: Wed Jan 30, 2008 12:00 am

Re: Refresh on Tchart doesn't work

Post by den » Mon Jul 02, 2012 10:04 pm

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

Yeray
Site Admin
Site Admin
Posts: 9587
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Refresh on Tchart doesn't work

Post by Yeray » Tue Jul 03, 2012 7:43 am

Hi Dennis,

Glad to be helpful!
Don't hesitate to let us know if you find any other problem with it.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply