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:
C# |
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
stockValueAxisCursor.Slaves.Add(stockVolumeAxisCursor);
stockVolumeAxisCursor.Slaves.Add(stockValueAxisCursor);
chartStockValues.Axis(StandardAxis.PrimaryX).Cursors.Add(stockValueAxisCursor);
chartStockVolumes.Axis(StandardAxis.PrimaryX).Cursors.Add(stockVolumeAxisCursor);
|
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
stockValueAxisCursor.Slaves.Add(stockVolumeAxisCursor)
stockVolumeAxisCursor.Slaves.Add(stockValueAxisCursor)
chartStockValues.Axis(StandardAxis.PrimaryX).Cursors.Add(stockValueAxisCursor)
chartStockVolumes.Axis(StandardAxis.PrimaryX).Cursors.Add(stockVolumeAxisCursor)
|
Windows Forms: Interactivity \ Tools \ Data Cursor Tool
Windows Forms: Interactivity \ Tools \ Axis Scroll Tool