problem with calcXpos (also calcYpos)

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
fjrohlf
Newbie
Newbie
Posts: 33
Joined: Mon Sep 07, 2015 12:00 am

problem with calcXpos (also calcYpos)

Post by fjrohlf » Fri Oct 09, 2015 4:36 am

I need to draw a line using coordinates from a series of x,y points. The plot is fine but my attempt to draw a line fails when I use code like the following:
x1 :=Seriesxy.CalcXPos( ii-1 );
y1 :=Seriesxy.CalcYPos( ii-1 );
x2 :=Seriesxy.CalcXPos( jj-1 );
y2 :=Seriesxy.CalcYPos( jj-1 );
chart.Canvas.Line(x1, y1, x2, y2);

The problem is that the x1,y1, x2,y2 are equal to zero for all values of ii and jj even though the data values in the series are fine. I can look at them in debug mode. I also tried using :
x :=Seriesxy.XValues[ii-1];
x1 := seriesxy.CalcXPosValue( x );
The values of x are correct but x1 is still always equal to 0.

Is there some likely kind of error that I must be making?

Thanks, this is driving me a bit crazy!

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

Re: problem with calcXpos (also calcYpos)

Post by Yeray » Fri Oct 09, 2015 7:52 am

Hello,

Note the Calc* functions need some internal variables to be initialized to wok properly (axes final position depending on the labels width, etc).
That's why we use to recommend forcing a chart repaint before using them (Chart1.Draw;).
On the other hand, for custom drawing functions you'll probably be interested on calling them at OnAfterDraw event or similar so they are called every time the chart is redrawn (note a zoom/scroll repaint the chart).
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

fjrohlf
Newbie
Newbie
Posts: 33
Joined: Mon Sep 07, 2015 12:00 am

Re: problem with calcXpos (also calcYpos)

Post by fjrohlf » Sat Oct 10, 2015 1:31 am

That works! Thank you very much.

Post Reply