I have a small problem of accuracy of the cursors. Here is the situation : I have a spectrum and when I use a cursor to get me the nearst point (using a mouse click) the X Axis value is correct but not the Y Axis one. The cursor is not attached to the PEAK value of my linseSerie, The first image shows the unexpected behavior. But when I zoom in (picture 2) the problem is gone. it does this to me each time I have a big number of samples displayed in the graph.
![Image](https://s20.postimg.org/rrp0uvbn1/spec1.jpg)
![Image](https://s20.postimg.org/mubg9r9nx/spec2.jpg)
Here is the code I use to put the cursor on the right value. It never shows the correct spot when I don't zoom in.
Code: Select all
void m_chart_MouseClick(object sender, MouseEventArgs e)
{
//Find nearest point and show its values
try
{
double dXValue, dYValue;
int iNearestIndex;
if (m_chart.ViewXY.SampleDataSeries[0].SolveNearestSampleByCoord(e.X, e.Y, out dXValue, out dYValue, out iNearestIndex))
{
m_chart.BeginUpdate();
LineSeriesCursor cl = m_chart.ViewXY.LineSeriesCursors[0];
cl.ValueAtXAxis = dXValue;
m_chart.EndUpdate();
}
}
catch (Exception ex)
{ MessageBox.Show(ex.Message);}
}
Code: Select all
//Create main cursor
LineSeriesCursor cl = new LineSeriesCursor(m_chart.ViewXY, m_chart.ViewXY.XAxes[0]);
cl.Behind = true;
cl.Visible = true;
cl.LineStyle.Pattern = LinePattern.Dot;
cl.LineStyle.Color = Color.Blue;
cl.LineStyle.Width = 1;
cl.MoveByMouse = true;
cl.Tag = "main";
cl.SnapToPoints = true;
cl.PositionChanged += new LineSeriesCursor.PositionChangedHandler(cl_PositionChanged);
m_chart.ViewXY.LineSeriesCursors.Add(cl);
I hope that I can find a solution to get more accurate cursors.
Thank you very much.