Page 1 of 1

Screen pixel to series index

Posted: Wed Oct 05, 2005 3:25 pm
by 8572663
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...

Posted: Thu Oct 06, 2005 8:48 am
by Pep
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;