TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
-
bertrod
- Advanced
- Posts: 151
- Joined: Wed Sep 07, 2005 4:00 am
Post
by bertrod » Thu Mar 16, 2006 8:30 am
Hello,
Is it possible to get the coordinates of the 2 points illustrated on the illustration below ? (With red circles around them).

-
Narcís
- Site Admin

- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
Post
by Narcís » Thu Mar 16, 2006 11:41 am
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;
-
bertrod
- Advanced
- Posts: 151
- Joined: Wed Sep 07, 2005 4:00 am
Post
by bertrod » Thu Mar 16, 2006 12:29 pm
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 !

-
Pep
- Site Admin

- Posts: 3313
- Joined: Fri Nov 14, 2003 5:00 am
-
Contact:
Post
by Pep » Fri Mar 31, 2006 10:04 am
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.
-
bertrod
- Advanced
- Posts: 151
- Joined: Wed Sep 07, 2005 4:00 am
Post
by bertrod » Mon Apr 03, 2006 6:51 am
Ok, that's what I've done, and it works. Thanks.