Resolve the closest point
Posted: Tue Sep 09, 2008 8:13 am
Hello, I am using TeeChart for .Net version 3.5.3146.24805.
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:
At any given time, when an event is raised in the chart, I would like to be able to figure out the following:
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:
But the problem is that it always gives me the point to the left of the mouse, even if I am very close to the point at the right of the mouse.
How would you resolve the closest point to the mouse?
Many thanks.
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.