Series Y value based on X position

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
JoJu
Newbie
Newbie
Posts: 3
Joined: Tue Nov 20, 2012 12:00 am

Series Y value based on X position

Post by JoJu » Wed Nov 21, 2012 12:55 am

Hello everyone,

I have a simple line series graph. Y are values of pressure and X are time values in seconds.

I would like to get Y values based on X (mouse) cursor position. I don't want Y mouse cursor position values but the SERIES Y value based on mouse X position.

For example:

Mouse(2,2) -- series Y value at 2 = 5
Mouse(2,6) -- series Y value at 2 = 5
Mouse(2, 13) -- series Y value at 2 = 5


Best regards,
J

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Series Y value based on X position

Post by Narcís » Wed Nov 21, 2012 10:36 am

Hi JoJu,

Yes, you can do something like this:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=False;
  Series1.FillSampleValues;
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  startY  : Integer;
  endY    : Integer;
  i       : Integer;
  index   : Integer;
  yVal    : Double;
begin
  startY:=Chart1.Axes.Left.IStartPos;
  endY:=Chart1.Axes.Left.IEndPos;

  for i:=startY to endY do
  begin
    index:=Series1.Clicked(X, i);
    if (index <> TeeNoPointClicked) then
    begin
      yVal:=Series1.YValues[index];
      Chart1.Title.Text[0]:=FloatToStr(yVal);
      break;
    end;
  end;

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
Image Image Image Image Image Image
Instructions - How to post in this forum

JoJu
Newbie
Newbie
Posts: 3
Joined: Tue Nov 20, 2012 12:00 am

Re: Series Y value based on X position

Post by JoJu » Wed Nov 21, 2012 2:14 pm

Thank you! That is exactly what I needed.

Keep on with the good work!

Post Reply