Help wanted overcoming delay in repainting contour graph

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Geocentrix
Newbie
Newbie
Posts: 4
Joined: Thu Sep 30, 2021 12:00 am

Help wanted overcoming delay in repainting contour graph

Post by Geocentrix » Thu Apr 17, 2025 1:27 pm

I am trying to create a contour graph that uses ISO axes (i.e. the same X and Y scales) AND has a number of circles drawn on top of it. Screenshot #2 (correct) below shows the graph I am trying to produce.
Screenshot 2 (correct).jpg
Screenshot 2 (correct).jpg (111.84 KiB) Viewed 2273 times
The problem is that, when the graph first appears, the axes are not scaled properly, as shown here:
Screenshot 1 (wrong).jpg
Screenshot 1 (wrong).jpg (127.84 KiB) Viewed 2273 times
I have put the code that adjusts the scales AND draws the circles is the chart's AfterDraw event handler:

Code: Select all

void __fastcall TGxGraphPaper::TeeChartAfterDraw(TObject *Sender)
{
	if(auto plot = dynamic_pointer_cast<BoundaryElementContourPlot, TeeGraph>(contour_graph)) {
		// adjust the axes
		plot->MakeIsoAxis();    // THIS CALL ADJUSTS THE AXES

		// draw the piles
		if(auto analysis = dynamic_pointer_cast<const Repute::BoundaryElementAnalysis>(data))
			plot->DrawPileGroup(*analysis.get());    // THIS CALL DRAWS THE CIRCLES
	}
}
The strange thing is the WRONG drawing displays the circles, so has clearly gone through the AfterDraw event.

It is only when I move the mouse over the drawing that the graphs flashes and then displays the CORRECT drawing, without going through AfterDraw a second time.

Can anyone please explain what is happening here? What am I missing?

Thanks in advance.

Andrew Bond

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

Re: Help wanted overcoming delay in repainting contour graph

Post by Yeray » Wed Apr 23, 2025 7:16 am

Hello Andrew,

This probably happens because the MakeIsoAxis function changes the axes scales but doesn’t redraw the chart, so the changes only take effect the next time the chart is drawn.
To fix this, you likely just need to force a chart redraw by calling Draw() at the end of your FormCreate event or a similar initialization routine.
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

Geocentrix
Newbie
Newbie
Posts: 4
Joined: Thu Sep 30, 2021 12:00 am

Re: Help wanted overcoming delay in repainting contour graph

Post by Geocentrix » Thu Apr 24, 2025 11:29 am

Thanks, Yeray, that worked

Post Reply