Skip to main content

DXChartBase.CalcHitInfo(CGPoint) Method

Returns information about chart elements that are under the specified point.

Namespace: DevExpress.Xamarin.iOS.Charts

Assembly: DevExpress.Xamarin.iOS.Charts.dll

NuGet Package: DevExpress.XamarinForms.Charts

Declaration

public virtual DXChartHitInfo CalcHitInfo(
    CGPoint point
)

Parameters

Name Type Description
point CGPoint

The point to hit test, in screen points, relative to the chart’s top-left corner.

Returns

Type Description
DXChartHitInfo

Hit test result storage.

Example

The Hit test allows you to determine chart elements located under the specified screen coordinates. For example, the method allows you to know which chart element an end user taps:

public override void TouchesEnded(Foundation.NSSet touches,UIEvent evt) {
    UITouch touch = (UITouch)touches.AnyObject;
    CGPoint location = touch.LocationInView(this.chart);
    DXChartHitInfo hitInfo = this.chart.CalcHitInfo(location);

    bool useComma = false;
    StringBuilder textBuilder = new StringBuilder("You tap");

    if (hitInfo.InSeries) {
        textBuilder.Append(" in a series");
        useComma = true;
    }
    if (hitInfo.InPoint) {
        if (useComma) {
            textBuilder.Append(",");
        }
        textBuilder.Append(" in a point");
        useComma = true;
    }
    if (hitInfo.InLegend) {
        if (useComma) {
            textBuilder.Append(",");
        }
        textBuilder.Append(" in the legend");
    }
    textBuilder.Append(".");

    UIAlertController alertController = UIAlertController.Create(
        title: "Series hit-testing",
        message: textBuilder.ToString(),
        preferredStyle: UIAlertControllerStyle.Alert
    );
    alertController.AddAction(
        UIAlertAction.Create(
            title: "OK",
            style: UIAlertActionStyle.Default,
            handler: null
        )
    );

    this.PresentViewController(
        viewControllerToPresent: alertController,
        animated: true,
        completionHandler: null
    );
}

The following methods and classes allow you to perform hit testing.

Symbols

Description

DXChartBase.CalcHitInfo(CGPoint)

Returns information about chart elements that are under the specified point.

DXChartHitInfo

Chart hit test result storage.

See Also