View.Chart_Touched C# (CSharp) Method

Chart_Touched() private method

private Chart_Touched ( object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e ) : void
sender object
e SkiaSharp.Views.Forms.SKTouchEventArgs
return void
    private void Chart_Touched(object sender, SkiaSharp.Views.Forms.SKTouchEventArgs e)
    {
        var chart = (CartesianChart)FindByName("chart");

        var viewModel = (ViewModel)BindingContext;

        // scales the UI coordintaes to the corresponging data in the chart.
        // ScaleUIPoint retuns an array of double
        var scaledPoint = chart.ScaleUIPoint(new LvcPoint(e.Location.X, e.Location.Y));

        // where the X coordinate is in the first position
        var x = scaledPoint[0];

        // and the Y coordinate in the second position
        var y = scaledPoint[1];

        // finally add the new point to the data in our chart.
        viewModel.Data.Add(new ObservablePoint(x, y));
    }
}

Same methods

View::Chart_Touched ( object sender, SkiaSharp.Views.Maui.SKTouchEventArgs e ) : void