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!
problem with calcXpos (also calcYpos)
Re: problem with calcXpos (also calcYpos)
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).
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: problem with calcXpos (also calcYpos)
That works! Thank you very much.