Page 1 of 1
How to get coordinates of the extreme points of a series ?
Posted: Thu Mar 16, 2006 8:30 am
by 9343260
Hello,
Is it possible to get the coordinates of the 2 points illustrated on the illustration below ? (With red circles around them).
Posted: Thu Mar 16, 2006 11:41 am
by narcis
Hi bertrod,
Yes, you can do something like:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues();
Chart1.Draw;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var
XVal,YVal: Double;
XCoord, YCoord: Integer;
begin
XVal:=Series1.XValue[0];
YVal:=Series1.YValue[0];
XCoord:=Series1.CalcXPos(0);
YCoord:=Series1.CalcYPos(0);
Chart1.Title.Text.Clear;
Chart1.Title.Text.Add(FloatToStr(XVal)+', '+FloatToStr(YVal));
Chart1.Title.Text.Add(IntToStr(XCoord)+', '+IntToStr(YCoord));
XVal:=Series1.XValue[Series1.Count-1];
YVal:=Series1.YValue[Series1.Count-1];
XCoord:=Series1.CalcXPos(Series1.Count-1);
YCoord:=Series1.CalcYPos(Series1.Count-1);
Chart1.Title.Text.Add('');
Chart1.Title.Text.Add(FloatToStr(XVal)+', '+FloatToStr(YVal));
Chart1.Title.Text.Add(IntToStr(XCoord)+', '+IntToStr(YCoord));
end;
Posted: Thu Mar 16, 2006 12:29 pm
by 9343260
Hello,
Thanks, but I had already thought about it and there is a "little problem" with your solution : when I zoom, the coordinates are not correct anymore because I need the extreme left and right points of the Series, but only with points which are shown on the screen
.
For my problem, i tried to use the Series1.FirstValueIndex and Series1.LastValueIndex. But those values are not updated when zooming !
Posted: Fri Mar 31, 2006 10:04 am
by Pep
Hi,
in that case the only way around this would be to iterate through all the points after zoom checking if these are between the axis limits. Having this info you have to be able to get the corrdinate of the first and last visible valueindex.
Posted: Mon Apr 03, 2006 6:51 am
by 9343260
Ok, that's what I've done, and it works. Thanks.