TdxChartHitTest.GetAxisCoordinate(TdxChartCustomAxis) Method
Returns the coordinate of the inspected point‘s position on the specified primary or secondary axis.
Declaration
function GetAxisCoordinate(const AAxis: TdxChartCustomAxis): Variant;
Parameters
Name | Type | Description |
---|---|---|
AAxis | TdxChartCustomAxis | The target axis of arguments (X-axis) or values (Y-axis). |
Returns
Type | Description |
---|---|
Variant | The argument or value on the target axis (in axis measurement units) that corresponds to the inspected point position within the plot area of an XY diagram.
|
Remarks
Call the GetAxisCoordinate
function to obtain the corresponding coordinate of the inspected point for any primary or secondary axis in an XY diagram. Argument and Value properties allow you to obtain the coordinates of the inspected point in measurement units of the main X and Y axes.
Code Example
The following code example demonstrates an OnMouseMove event handler that displays mouse pointer coordinates (in axis measurement units) in the application form caption:
uses dxChartControl;
// ...
procedure TMyForm.dxChartControl1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
AHitTest: TdxChartHitTest;
ADiagram: TdxChartXYDiagram;
begin
AHitTest := dxChartControl1.HitTest;
if (AHitTest.Diagram <> nil) and (AHitTest.Diagram is TdxChartXYDiagram) then
begin
ADiagram := AHitTest.Diagram as TdxChartXYDiagram;
if AHitTest.InPlotArea then
Caption := Caption + 'X: ' + VarToStr(AHitTest.GetAxisCoordinate(ADiagram.Axes.AxisX)) +
' Y: ' + VarToStr(AHitTest.GetAxisCoordinate(ADiagram.Axes.AxisY));
end;
end;
To obtain horizontal and vertical coordinates (in pixels) of the inspected point within the Chart control client area, use the Point property.
Chart HitTest Information Updates
Chart HitTest information updates every time when:
- The OnHotTrackElement or OnMouseMove event occurs.
Point
.X andPoint
.Y property values change to the corresponding mouse pointer coordinates. - You call the CalculateHitTest procedure.
Point
.X andPoint
.Y property values change to the procedure’sX
andY
parameter values.
In addition, Argument and Value property values change to corresponding coordinates (in axis measurement units) if the inspected point is within the plot area of an XY diagram.