0

I'm using a c# .Net Chart object with series type = Spline.

How can I convert the x/y co-ords from MouseMove event into a DataPoint so I can get at the point's Tag value? Something like:

private void chart1_MouseMove(object sender, MouseEventArgs e)
{
    Point pt = e.Location;
    HitTestResult[] results = chart1.HitTest(pt.X, pt.Y, false, ChartElementType.PlottingArea);

    foreach (HitTestResult result in results)
    {
        ... get DataPoint index from x/y co-ords
    }
}
DaveR
  • 11
  • 1
  • Each Axis lets you convert between the 3 (!) coordinate systems in a mschart: the pixels, the data values and positions in percent. There are various functions to do that. However, there will not always be a DataPoint at each exact mouse position. So you may have to search for the closest one.. – TaW Jan 30 '21 at 14:41
  • See [here](https://stackoverflow.com/questions/46092227/get-chart-value-in-point/46093416#46093416) and [here](https://stackoverflow.com/questions/33899354/get-y-value-of-series-from-the-x-cursor-position-where-a-chartarea-is-clicked-on/33905483#33905483) and [here](https://stackoverflow.com/questions/40056264/selecting-specific-values-on-a-chart/40057669#40057669) for examples.. – TaW Jan 30 '21 at 14:42
  • Thanks. The second example fitted in fine and works for me. – DaveR Jan 31 '21 at 10:49

0 Answers0