Locate the nearest point in TPoint3DSeries

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
sripe
Newbie
Newbie
Posts: 26
Joined: Thu Sep 10, 2015 12:00 am

Locate the nearest point in TPoint3DSeries

Post by sripe » Thu Jan 28, 2016 9:29 am

For TPoint3DSeries, how to locate the nearest point following mouse and use annotation callout to show its coordinates?

Yeray
Site Admin
Site Admin
Posts: 9533
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Locate the nearest point in TPoint3DSeries

Post by Yeray » Thu Jan 28, 2016 2:29 pm

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

sripe
Newbie
Newbie
Posts: 26
Joined: Thu Sep 10, 2015 12:00 am

Re: Locate the nearest point in TPoint3DSeries

Post by sripe » Fri Jan 29, 2016 7:45 am

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.
Attachments
Example2.zip
(58.76 KiB) Downloaded 488 times

Yeray
Site Admin
Site Admin
Posts: 9533
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Locate the nearest point in TPoint3DSeries

Post by Yeray » Fri Jan 29, 2016 3:53 pm

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);
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply