Screen pixel to series index

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
leaf
Newbie
Newbie
Posts: 37
Joined: Fri Nov 15, 2002 12:00 am

Screen pixel to series index

Post by leaf » Wed Oct 05, 2005 3:25 pm

I have a TColorGridSeries with an image displayed. I uses the mouse Up, Down and Move events the draw a box on the image. The Up and Down events give me the X and Y screen pixel locations of the box on the screen.

Can anyone tell me how to get the X and Z index to access the data inside the box? Is there code in any example or in the forum anywhere that does this already?

Thanks in advance...

Pep
Site Admin
Site Admin
Posts: 3295
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Thu Oct 06, 2005 8:48 am

Hi,

you can use similar code to the following :

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var x,z: Integer;
begin
  for x:=3D0 to 20 do
    for z:=3D0 to 20 do
      Series1.AddXYZ(x,x+z,z);

  Chart1.View3DOptions.Orthogonal:=false;
end;

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.CalcXPos(index))+', '+
                          FloatToStr(Series1.CalcYPos(index))+', '+
                          FloatToStr(Series1.CalcZPos(index))
  else Chart1.Title.Text[0]:='';
end;

Post Reply