1

I have this issue where my chart cursor X is not following the mouse Point.

I have the code like this,

private void TrendChart_MouseMove(object sender, MouseEventArgs e)
 {
   Point mousePoint = new Point(e.X, e.Y);
   TrendChart.ChartAreas[0].CursorX.SetCursorPixelPosition(mousePoint, true);
   TrendChart.ChartAreas[0].CursorY.SetCursorPixelPosition(mousePoint, true);
 }

The result is like this :

My mouse is at left there but x cursor (vertical red line is at right)

Do you have any idea what could be the reason it's not following where my mouse is?

TaW
  • 53,122
  • 8
  • 69
  • 111
njz
  • 47
  • 8
  • Very strange. Does the x position change or is it always where it is? Does the y-position work correctly? If none change the MouseMove is probably not [hooked up](http://stackoverflow.com/questions/33275763/copy-datagridview-values-to-textbox/33276161?s=14|0.0000#33276161) – TaW Jun 01 '16 at 07:46
  • @TaW i manage to get the Cursor X working. It is by making Interval = 0. – njz Jun 01 '16 at 07:53
  • Have you resolved your problems? If so, do accept your own answer so the question doesn't look unresolved! – TaW Jun 18 '16 at 08:28

1 Answers1

1

Found the flaws. Have to change a Chart property: Cursor X Interval to be 0. Mine was Interval = 1.

ChartAreas properties

TaW
  • 53,122
  • 8
  • 69
  • 111
njz
  • 47
  • 8
  • 1
    See [here](https://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.cursor.interval%28v=vs.110%29.aspx): _A value of zero, which is the default value, signifies that a cursor or range selection can be drawn anywhere within a chart area. A nonzero value signifies that the cursor or beginning and/or end points of a selected range will only be drawn at the specified interval_ - I am not so sure about the claim that `0` is the default; I found it to be `1` for my chart.. – TaW Jun 01 '16 at 08:50
  • @TaW thanks. I'm not sure why should change to 0. Because other chart I found also using 1 and have no problem with the cursor. – njz Jun 07 '16 at 13:09
  • Well that will depend on the data. If they go 1,2,3,4...100 it will work fine. But if they go 0,0.1,0.2,0.3...1 it won't work at all. – TaW Jun 07 '16 at 13:13