Get the touch position in SfCartesianChart

ChartInteractiveBehavior provides the following override methods to get the x and y positions when touching the SfCartesianChart.

  • OnTouchUp - Called when a user lifts their finger or releases their touch input from the Chart area.
  • OnTouchMove - Called when a user’s finger or touch input device is in contact with the Chart area and moves across its surface.
  • OnTouchDown - Called when the user makes the initial contact of a user’s finger or touch input device with the Chart Area.
<chart:SfCartesianChart>
    .........

    <chart:SfCartesianChart.InteractiveBehavior>
        <local:ChartInteractiveExt/>
    </chart:SfCartesianChart.InteractiveBehavior>

</chart:SfCartesianChart>
SfCartesianChart chart = new SfCartesianChart();
.......
    
ChartInteractiveExt interactiveExt = new ChartInteractiveExt();
chart.Behaviors.Add(interactiveExt);

this.Content = chart;
public class ChartInteractiveExt: ChartInteractiveBehavior
{
    protected override void OnTouchDown(ChartBase chart, float pointX, float pointY)
    {
        base.OnTouchDown(chart, pointX, pointY);
    }

    protected override void OnTouchMove(ChartBase chart, float pointX, float pointY)
    {
        base.OnTouchMove(chart, pointX, pointY);
    }

    protected override void OnTouchUp(ChartBase chart, float pointX, float pointY)
    {
        base.OnTouchUp(chart, pointX, pointY);
    }
}