I have a chart with nearest point tool and lineserie. I'd like to get at information about the X,Y values of the actual point in the lineseries pointed at by the tool Something like...
procedure TMainForm.ChartTool1Change(Sender: TObject);
var
x:real;
begin
x:=sender.XValue[valueindex];
statusbar.panels[1].text:=floattostrf(x,fffixed,9,1);
end;
So as user moves the mouse the statusbar updates with x/y values.
The sender.xvalue[valueindex] above are what I use in the onclick event for Tlineseries. I can figure out which series the nearesttool is pointing at, but I'm not sure how to find which xvallue and yvalue the nearesttool is pointing at. Have read tutorials and forum, but still struggling. Any advice much appreciated.
thanks
Sean
Nearestpoint tool - accessing the nearest point properties
-
- Newbie
- Posts: 48
- Joined: Fri Mar 12, 2004 5:00 am
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Sean,
If you figured out which series point the tool is pointing at then you just have to retrieve the X and Y Values from the series doing something like what's done here:
If you figured out which series point the tool is pointing at then you just have to retrieve the X and Y Values from the series doing something like what's done here:
Code: Select all
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var Index: Integer;
begin
Index:=Series1.Clicked(X,Y);
if Index<>-1 then
Chart1.Title.Text[0]:=FloatToStr(Series1.XValue[Index])+', '+
FloatToStr(Series1.YValue[Index]);
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 48
- Joined: Fri Mar 12, 2004 5:00 am
Hi Sean,
to do this you could use the following code :
to do this you could use the following code :
Code: Select all
procedure TForm1.ChartTool1Change(Sender: TObject);
begin
if ChartTool1.Point <> -1 then
Label1.Caption := 'Point index = ' + IntToStr(ChartTool1.Point) +
' X : '+ FloatToStr(Series1.XValue[Charttool1.Point]) + ' Y : '+ FloatToStr(Series1.YValue[Charttool1.Point])
else Label1.Caption := '';
end;
Pep Jorge
http://support.steema.com
http://support.steema.com