Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxChartHitTest.GetAxisCoordinate(TdxChartCustomAxis) Method

Returns the coordinate of the inspected point‘s position on the specified primary or secondary axis.

#Declaration

Delphi
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.

Main X or Y Axis
  • If the target axis is the main axis of arguments in a diagram, the function returns the Argument property value.
  • If the target axis is the main axis of values in a diagram, the function returns the Value property value.
Non-XY Diagram Area
The function returns varNull if the inspected point is not within the plot area of an XY diagram (for example, when the inspected point is within a simple 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: Get Mouse Pointer Coordinates

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 and Point.Y property values change to the corresponding mouse pointer coordinates.
  • You call the CalculateHitTest procedure. Point.X and Point.Y property values change to the procedure’s X and Y 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.

See Also