Chart for .NET / User's Guide / Interactivity / Data Cursor

In This Topic
Data Cursor
In This Topic

The data cursor feature of the control allows you to synchronize the values of axis cursors (represented by the NAxisCursor object) with the mouse coordinates transformed to axis coordinates.

You enable the data cursor feature by adding an object of type NDataCursorTool to the Tools collection of the control:

C#
Copy Code
// add horizontal axis cursor
NAxisCursor horzAxisCursor = new NAxisCursor();
horzAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryY;
horzAxisCursor.SynchronizeOnMouseAction = MouseAction.Down;
chart.Axis(StandardAxis.PrimaryX).Cursors.Add(horzAxisCursor);

// add vertical axis cursor
NAxisCursor vertAxisCursor = new NAxisCursor();
vertAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryX;
vertAxisCursor.SynchronizeOnMouseAction = MouseAction.Down;
chart.Axis(StandardAxis.PrimaryY).Cursors.Add(vertAxisCursor);

// add selector and data cursor tool
chartControl.Controller.Tools.Add(new NSelectorTool());
chartControl.Controller.Tools.Add(new NDataCursorTool());
Visual Basic
Copy Code
' add horizontal axis cursor
Dim horzAxisCursor As New NAxisCursor
horzAxisCursor.BeginEndAxis = CType(StandardAxis.PrimaryY, Integer)
horzAxisCursor.SynchronizeOnMouseAction = MouseAction.Down
chart.Axis(StandardAxis.PrimaryX).Cursors.Add(horzAxisCursor)

' add vertical axis cursor
Dim vertAxisCursor As New NAxisCursor
vertAxisCursor.BeginEndAxis = CType(StandardAxis.PrimaryX, Integer)
vertAxisCursor.SynchronizeOnMouseAction = MouseAction.Down
chart.Axis(StandardAxis.PrimaryY).Cursors.Add(vertAxisCursor)

' add selector and data cursor tool
chartControl.Controller.Tools.Add(New NSelectorTool)
chartControl.Controller.Tools.Add(New NDataCursorTool)

Now when the user presses the left mouse button over the chart the axis cursors will be positioned at the this location.

See Also