Skip to main content

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 Class

Stores Chart control HitTest information.

#Declaration

Delphi
TdxChartHitTest = class(
    TObject
)

#Remarks

HitTest information allows you to identify and access the inspected visual element (that is, a visual element at the current mouse pointer position or at the coordinates passed to the CalculateHitTest procedure) within the Chart control client area.

Chart HitTest information updates every time when:

#Main API Members

The list below outlines key class members that allow you to identify visual elements.

InPlotArea
Identifies if the inspected point is within the plot area of an XY diagram.
HitCode
Identifies the Chart control’s visual element to which the inspected point belongs.
Point
Returns pixel coordinates of the inspected point within the Chart control’s client area.

#XY Diagram-Specific API Members

Argument | Value
Return the coordinates of the inspected point within the plot area of an XY diagram in corresponding measurement units of the main X and Y-axes.
Axis | AxisValueLabel
Provide access to inspected axes and their value labels.
GetAxisCoordinate
Returns the X or Y-coordinate of the inspected point within the plot area for the specified axis in its measurement units.

#Simple Diagram-Specific API Members

TotalLabel
Provides access to the series total label to which the inspected point belongs.
Diagram
Provides access to the diagram to which the inspected point belongs.
Legend | LegendItem
Provide access to inspected legend panes and items.
Series | SeriesPoint | SeriesValueLabel
Provide access to inspected series and their visual elements.
Title
Provides access to the axis, chart, diagram, legend, or series title to which the inspected point belongs.

#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);
begin
  if dxChartControl1.HitTest.Diagram <> nil then
  begin
    if (dxChartControl1.HitTest.Argument <> VarNull) and (dxChartControl1.HitTest.Value <> VarNull) then
    Caption := Caption + 'X: ' + VarToStr(dxChartControl1.HitTest.Argument) +
      ' Y: ' + VarToStr(dxChartControl1.HitTest.Value);
  end;
end;

#Direct TdxChartHitTest Class References

The following public API members reference a TdxChartHitTest object:

TdxCustomChartControl.HitTest
Provides access to HitTest information on the inspected point within the Chart control client area.
TdxChartHotTrackElementEventArgs.HitTest
Provides access to HitTest information on the currently hot-tracked visual Chart element.
TdxChartHotTrackElementEventArgs.PreviousHitTest
Provides access to HitTest information on the visual Chart element that was hot-tracked before the current OnHotTrackElement event occurrence.

#Inheritance

TObject
TdxChartHitTest
See Also