Back to Devexpress

ChartHitInfo Class

corelibraries-devexpress-dot-xtracharts-9c85e1f9.md

latest3.6 KB
Original Source

ChartHitInfo Class

Contains information about a specific point within a chart.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
[RuntimeObject]
public class ChartHitInfo :
    ChartHitInfoBase
vb
<RuntimeObject>
Public Class ChartHitInfo
    Inherits ChartHitInfoBase

The following members return ChartHitInfo objects:

LibraryRelated API Members
Cross-Platform Class LibraryHotTrackEventArgs.HitInfo
WinForms ControlsChartControl.CalcHitInfo(Int32, Int32)
ChartControl.CalcHitInfo(Point, Boolean)

Remarks

ChartHitInfo objects can be created by calling the chart’s ChartControl.CalcHitInfo method. This method requires the test point as a parameter, or its coordinates.

The ChartHitInfo class properties can be grouped into three logical categories:

  • The properties indicating whether the test point resides over a particular view element. For instance, the ChartHitInfo.InChartTitle property indicates whether the test point is over the chart title or not;
  • The ChartHitInfo.HitTest property identifying the type of the topmost element located under the test point;
  • The ChartHitInfoBase.HitObject and ChartHitInfoBase.HitObjects properties identifying the topmost element or the collection of all visual elements which contains the test point.

Example

The following examples demonstrates how to handle the ChartControl.MouseMove event and calculate the hit information for the point which the mouse pointer is currently hovering over. Then, the name of the chart element located under the mouse pointer is shown within the form caption.

csharp
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...

private void chartControl1_MouseMove(object sender, MouseEventArgs e) {
    ChartHitInfo hi = chartControl1.CalcHitInfo(new System.Drawing.Point(e.X, e.Y));
    this.Text = hi.HitTest.ToString();
}
vb
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...

Private Sub ChartControl1_MouseMove(ByVal sender As System.Object, ByVal e As MouseEventArgs) _
Handles ChartControl1.MouseMove
    Dim hi As ChartHitInfo = ChartControl1.CalcHitInfo(New System.Drawing.Point(e.X, e.Y))
    Me.Text = hi.HitTest.ToString()
End Sub

Inheritance

Object ChartHitInfoBase ChartHitInfo

See Also

ChartHitInfo Members

DevExpress.XtraCharts Namespace