Converting screen coordinates into axis values
Moderator: Arction_LasseP
-
- Posts: 16
- Joined: Tue Mar 26, 2013 11:01 pm
Converting screen coordinates into axis values
I'm using ViewXY cartesian chart. I'd like to get the X and Y axis values under the mouse, not the screen coordinates. How ?
- ArctionPasi
- Posts: 1366
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
Re: Converting screen coordinates into axis values
If you define MouseMove, MouseDown or MouseUp events, you can use the screen coordinates to xAxis.CoordToValue() and yAxis.CoordToValue. They will give you the click value as X and Y axis values.
For example, MouseDown:
For example, MouseDown:
Code: Select all
void m_chart_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
Point pnScreen = e.GetPosition(m_chart);
double x, y;
m_chart.ViewXY.XAxes[0].CoordToValue((int)pnScreen.X, out x, false);
m_chart.ViewXY.YAxes[0].CoordToValue((int)pnScreen.Y, out y);
//x and y have the axis values now
}
LightningChart Support Team, PT