Nevron .NET Vision Documentation
Axis Cursors

Axis cursors are similar to axis constant lines and are used to dynamically mark an axis value. Axis cursors are painted in overlay mode meaning that the chart content is not refreshed when the axis cursor value changes. That why it is recommended to use cursors instead of constant lines when you have to dynamically mark axis values on a chart that does not refresh often.

Creating a New Axis Cursor

You create an axis cursor by creating an instance of the NAxisCursor class and then adding it to the Cursors collection of the Axis:

Copy Code
NAxisCursor axisCursor = new NAxisCursor();
axisCursor.BeginEndAxis = (int)StandardAxis.PrimaryY;
Example Title
Copy Code
Dim axisCursor As New NAxisCursor()
axisCursor.BeginEndAxis = CType(StandardAxis.PrimaryY, Integer)

Note: You can use the BeginEndAxis property to define on which axis the cursor will scale it's begin/end values.

Modifying the Cursor Value

After you create the cursor you can modify its Value property:

Copy Code
axisCursor.Value = 10;
Visual Basic
Copy Code
axisCursor.Value = 10;
Synchronizing the Cursor With the Mouse

In order to synchronize the cursor with the mouse you have to add a special tool to the Controller.Tools collection of the control:

Copy Code
chartControl.Controller.Tools.Add(new NDataCursorTool());
Visual Basic
Copy Code
chartControl.Controller.Tools.Add(New NDataCursorTool())

Now when the user moves the mouse over the chart the cursor will receive notifications. Afterwards you have to touch the SynchronizeOnMouseAction property of the cursor accepting values from the MouseAction enum. The following code snippet synchronizes the cursor with the mouse position when mouse down or mouse move event occur:

Copy Code
axisCursor.SynchronizeOnMouseAction = MouseAction.Down | MouseAction.Move;
Visual Basic
Copy Code
axisCursor.SynchronizeOnMouseAction = MouseAction.Down Or MouseAction.Move
You may also want to tell the axis cursor to snap to certain positions on the axis or the axis grid. In this case you need to assign an object derived from the NAxisValueSnapper class to the ValueSnapper property of the cursor. For more information on axis value snapping please take a look at the Value Snapping topic.
Master / Slave Axis Cursors

When having multiple cursors on multiple axes you may encounter situations where you want two or more axis cursors to be synchronized.

A typical example for this is a financial chart showing a stock value over time and a second chart showing the stock volume over time. You may wish to give the user the ability to move the axis cursor in the first chart and this movement should reflect the axis cursor in the second and vice versa.

The Master / Slave axis cursor feature allows you to easily achieve this by specifying that the two axis cursors have a Master/Slave relationship.

Each axis cursor can have slave axis cursors that automatically synchronizes their values to the value of the master.

You can also have recursive master/slave relationship where two axis cursors are both masters and slaves to one another. In this case the axis cursor that initiates the synchronization takes priority.

The following code synchronizes the axis cursors of the stock value and stock volume charts:

Copy Code
NAxisCursor stockValueAxisCursor = new NAxisCursor();
NAxisCursor stockVolumeAxisCursor = new NAxisCursor();

stockValueAxisCursor.ValueSnapper = new NAxisMajorTickSnapper();
stockValueAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryY;

stockVolumeAxisCursor.ValueSnapper = new NAxisMajorTickSnapper();
stockVolumeAxisCursor.BeginEndAxis = (int)StandardAxis.PrimaryY;

// each cursor is master of the other. When the users click on one of the
// charts this will result in an automatic update of the other cursor

Visual Basic
Copy Code
Dim stockValueAxisCursor As New NAxisCursor
Dim stockVolumeAxisCursor As New NAxisCursor

stockValueAxisCursor.ValueSnapper = New NAxisMajorTickSnapper
stockValueAxisCursor.BeginEndAxis = CType(StandardAxis.PrimaryY, Integer)

stockVolumeAxisCursor.ValueSnapper = New NAxisMajorTickSnapper
stockVolumeAxisCursor.BeginEndAxis = CType(StandardAxis.PrimaryY, Integer)

' each cursor is master of the other. When the users click on one of the
' charts this will result in an automatic update of the other cursor

Related Examples

Windows Forms: Interactivity \ Tools \ Data Cursor Tool

Windows Forms: Interactivity \ Tools \ Axis Scroll Tool

See Also



©2019. Nevron Software LLC.

Send Feedback