Back to Devexpress

ChartHitInfoBase.HitPoint Property

corelibraries-devexpress-dot-xtracharts-dot-charthitinfobase-47448d43.md

latest3.9 KB
Original Source

ChartHitInfoBase.HitPoint Property

Gets the test point.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public Point HitPoint { get; }
vb
Public ReadOnly Property HitPoint As Point

Property Value

TypeDescription
Point

A Point structure specifying test point coordinates relative to the chart’s top-left corner.

|

Remarks

Hit information for a point is calculated via the ChartControl.CalcHitInfo method. This method takes the test point as the parameter. The test point is assigned to the HitPoint property of the returned ChartHitInfo object.

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the HitPoint property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-chart-make-points-in-a-chartcontrol-adjustable-interactively/CS/Form1.cs#L20

csharp
DiagramCoordinates point =
    ((XYDiagram)(sender as ChartControl).Diagram).PointToDiagram(e.HitInfo.HitPoint);

winforms-chart-make-points-in-a-chartcontrol-adjustable-interactively/VB/Form1.vb#L22

vb
If selectedPoint IsNot Nothing AndAlso isPressed Then
    Dim point As DiagramCoordinates = CType(TryCast(sender, ChartControl).Diagram, XYDiagram).PointToDiagram(e.HitInfo.HitPoint)
    If lastY <> -1 Then

See Also

CalcHitInfo

ChartHitInfoBase Class

ChartHitInfoBase Members

DevExpress.XtraCharts Namespace