Back to Devexpress

ChartControl.CalcHitInfo(Point, Boolean) Method

windowsforms-devexpress-dot-xtracharts-dot-chartcontrol-dot-calchitinfo-x28-system-dot-drawing-dot-point-system-dot-boolean-x29.md

latest5.0 KB
Original Source

ChartControl.CalcHitInfo(Point, Boolean) Method

Returns information on the chart elements located at the specified point.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.UI.dll

NuGet Package : DevExpress.Win.Charts

Declaration

csharp
public ChartHitInfo CalcHitInfo(
    Point point,
    bool forceUpdate = true
)
vb
Public Function CalcHitInfo(
    point As Point,
    forceUpdate As Boolean = True
) As ChartHitInfo

Parameters

NameTypeDescription
pointPoint

The hit point, relative to the chart’s top-left edge integer screen coordinates.

|

Optional Parameters

NameTypeDefaultDescription
forceUpdateBooleanTrue

The value that specifies that all update commands that the Chart currently collects should be executed immediately instead of before the control ‘s next rendering.

|

Returns

TypeDescription
ChartHitInfo

The information about the item in the test point.

|

Remarks

Use the CalcHitInfo method to determine which element is located at the point with the specified coordinates. For example, you can use this method in the chart’s Click event handler to determine clicked element. In this case, pass the current mouse pointer’s coordinates as the method’s parameter.

Important

Make sure that the ChartControl.RuntimeHitTesting property is set to true to enable hit testing at runtime.

The Chart Control supports only 2D Chart Types hit testing and does not support hit testing for 3D Chart Types.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CalcHitInfo(Point, Boolean) method.

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-dashboard-custom-items/CS/TutorialsCustomItems/CustomItems/FunnelItemControlProvider.cs#L116

csharp
{
    ChartHitInfo hitInfo = chart.CalcHitInfo(e.Location);
    if (hitInfo.InSeriesPoint)

winforms-dashboard-custom-items-extension/CS/CustomItemExtension/CustomItems/Funnel/FunnelItemControlProvider.cs#L115

csharp
void MouseDoubleClick(object sender, MouseEventArgs e) {
    ChartHitInfo hitInfo = chart.CalcHitInfo(e.Location);
    if(hitInfo.InSeriesPoint) {

winforms-dashboard-custom-items/VB/TutorialsCustomItems/CustomItems/FunnelItemControlProvider.vb#L112

vb
Private Sub MouseDoubleClick(ByVal sender As Object, ByVal e As MouseEventArgs)
Dim hitInfo As ChartHitInfo = chart.CalcHitInfo(e.Location)
If hitInfo.InSeriesPoint Then

winforms-dashboard-custom-items-extension/VB/CustomItemExtension/CustomItems/Funnel/FunnelItemControlProvider.vb#L124

vb
Private Sub MouseDoubleClick(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim hitInfo As ChartHitInfo = chart.CalcHitInfo(e.Location)
    If hitInfo.InSeriesPoint Then

See Also

ChartControl Class

ChartControl Members

DevExpress.XtraCharts Namespace