Page 1 of 1

Locate the nearest point in TPoint3DSeries

Posted: Thu Jan 28, 2016 9:29 am
by 16576306
For TPoint3DSeries, how to locate the nearest point following mouse and use annotation callout to show its coordinates?

Re: Locate the nearest point in TPoint3DSeries

Posted: Thu Jan 28, 2016 2:29 pm
by yeray
Hello,

Have you seen the TNearestTool? This seems to work fine for me here:

Code: Select all

uses TeeTools;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.Aspect.Orthogonal:=false;
  Chart1.Chart3DPercent:=100;
  Chart1.Aspect.Zoom:=80;
  Chart1.Legend.Visible:=false;

  Chart1.AddSeries(TPoint3DSeries).FillSampleValues;

  with Chart1.Tools.Add(TNearestTool) as TNearestTool do
  begin
    Series:=Chart1[0];
  end;
end;

Re: Locate the nearest point in TPoint3DSeries

Posted: Fri Jan 29, 2016 7:45 am
by 16576306
While mouse moving, I want to re-position annotation callout. But a Series only has CalcXPos and CalcYPos, no CalcZPos, how to get ZPosition? And how to set a 3D cursor following on the Series? Please find the attached files.

Re: Locate the nearest point in TPoint3DSeries

Posted: Fri Jan 29, 2016 3:53 pm
by yeray
Hello,

CalcZPos exists but not for all the TChartSeries (note some series are 2D), so you are only missing a cast. Ie:

Code: Select all

      ZPosition := (ChartListBox1.SelectedSeries as TPoint3DSeries).CalcZPos(AIndex);