In some of the chart events, I need to find which point (X value) on the Line series my mouse is closest to.
I currently keep chart of the mouse positions with:
Code: Select all
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
m_mouseXPos = e.X;
m_mouseYPos = e.Y;
}
Let's say that my line series has X values of 1, 2, 3, 4 and 8
At the time I am trying to resolve the closest point, mouseXPos and mouseYPos could look like this (192, 263).
If my mouse is around X value of (5), I would like to find 4.
If my mouse is around X value of (7), I would like to find 8.
I can find the X value index with the following call:
Code: Select all
int XIndex = series.Clicked(m_mouseXPos, m_mouseYPos);
How would you resolve the closest point to the mouse?
Many thanks.