TdxChartHitTest Class
In This Article
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:
- The OnHotTrackElement or OnMouseMove event occurs. The inspected point matches the current mouse pointer position.
- You call the CalculateHitTest procedure. The procedure’s
X
andY
parameters define inspected point coordinates within the Chart control client area.
#Main API Members
The list below outlines key class members that allow you to identify visual elements.
#Inspected Point-Related API Members
- 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.
#Common Visual Element-Related API Members
- 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.
See Also