First - apologies for what is probably a dumb question. So thanks in advance for your help on the forum.
Second - in C++/VCL how do I determine the axis-based coordinates of a mouse click in a chart? That's to say, not the cursor coordinates on the Chart object itself (which start at 0,0 top-left) but within the displayed graph (with currently visible axes ranges)?
OnClick coordinates
Re: OnClick coordinates
Hi philip,
You can translate the coordinates in pixels taken, for example, from OnMouseDown event to coordinates in the axes units with CalcPosPoint function:
You can translate the coordinates in pixels taken, for example, from OnMouseDown event to coordinates in the axes units with CalcPosPoint function:
Code: Select all
procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var XPos, YPos: Double;
begin
XPos:=Chart1.Axes.Bottom.CalcPosPoint(X);
YPos:=Chart1.Axes.Left.CalcPosPoint(Y);
Chart1.Title.Text.Text:='X: ' + FormatFloat('#0.00', XPos) + ', Y: ' + FormatFloat('#0.00', YPos);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: OnClick coordinates
Code: Select all
XPos:=Chart1.Axes.Bottom.CalcPosPoint(X);
YPos:=Chart1.Axes.Left.CalcPosPoint(Y);
Re: OnClick coordinates
You're welcome, Philip!
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |