Articles in this section
Category / Section

Find nearest datapoint in series using touch point from chart area

1 min read

You can get the nearest data point in series from wherever you touch the chart area using the PointerMoved event in chart and using the FindNearestChartPoint method in ChartSeries.

Please refer to the following code sample to get the nearest data point in series.


private void Chart_PointerMoved(object sender, PointerRoutedEventArgs e)
            FieldInfo feild = typeof(ChartBase).GetField("AdorningCanvas", BindingFlags.NonPublic | BindingFlags.Instance);
            UIElement canvas = feild.GetValue(Chart) as UIElement;
            var pointer = e.GetCurrentPoint(canvas);
            double xvalue = pointer.Position.X;
            double yvalue = pointer.Position.Y;
            double stackvalue = double.NaN;
            Point point = new Point(xvalue, yvalue);
            Chart.Series[0].FindNearestChartPoint(point, out xvalue, out yvalue, out stackvalue);
            textblock.Text = "Nearest X Point is " + xvalue.ToString();
            textblock1.Text = "Nearest Y Point is " + yvalue.ToString();


Chart area to find the nearest point in UWP


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment