Back to Devexpress

TdxChartHitTest Class

vcl-dxchartcontrol-a3c6961d.md

latest6.4 KB
Original Source

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.

Inspected Point-Related API Members

InPlotAreaIdentifies if the inspected point is within the plot area of an XY diagram.HitCodeIdentifies the Chart control’s visual element to which the inspected point belongs.PointReturns pixel coordinates of the inspected point within the Chart control’s client area.

XY Diagram-Specific API Members

Argument | ValueReturn 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 | AxisValueLabelProvide access to inspected axes and their value labels.GetAxisCoordinateReturns 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

TotalLabelProvides access to the series total label to which the inspected point belongs.

Common Visual Element-Related API Members

DiagramProvides access to the diagram to which the inspected point belongs.Legend | LegendItemProvide access to inspected legend panes and items.Series | SeriesPoint | SeriesValueLabelProvide access to inspected series and their visual elements.TitleProvides 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:

delphi
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;
cpp
#include "dxChartControl.hpp"  
// ...
void __fastcall TMyForm::dxChartControl1MouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
  if(dxChartControl1->HitTest->Diagram != nullptr)
  {
    if((dxChartControl1->HitTest->Argument != VarNull) && (dxChartControl1->HitTest->Value != VarNull))
      Caption = Caption + "X: " + VarToStr(dxChartControl1->HitTest->Argument) +
        " Y: " + VarToStr(dxChartControl1->HitTest->Value);
  }
}

Direct TdxChartHitTest Class References

The following public API members reference a TdxChartHitTest object:

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

Inheritance

TObject TdxChartHitTest

See Also

TdxChartToolTips Class

TdxChartHitTest Members

dxChartControl Unit