ChartControl.HitTest(Int32, Int32) Method

Returns specific chart elements, which are located under the test point.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v20.1.UI.dll

Declaration

public object[] HitTest(
    int x,
    int y
)
Public Function HitTest(
    x As Integer,
    y As Integer
) As Object()

Parameters

Name Type Description
x Int32

An integer value that specifies the x coordinate of the test point.

y Int32

An integer value that specifies the y coordinate of the test point.

Returns

Type Description
Object[]

An array of Objects, that represent the chart elements located under the test point.

Remarks

A SeriesPoint isn't a chart element. To get the current series point under the test point, you need to use the ChartControl.CalcHitInfo method and use the ChartHitInfo.SeriesPoint property.

NOTE

The HitTest method is supported in 2D charts only. It can't be used for 3D charts.

Examples

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.

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();
}
See Also