Chart for .NET / User's Guide / Axes / Master / Slave Axes

In This Topic
    Master / Slave Axes
    In This Topic

    When having multiple charts or multiple axes on a single chart you may encounter situations where you want two or more axes 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 zoom in / out the stock data and still keep the charts synchronized in their date axis.

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

    Each axis can have slave axes that automatically adjust their scale mode, min/max values and paging to their master.

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

    The following code synchronizes the PrimaryX axis of stock value and stock volume charts so when you scroll the charts they will show the same date/time period.

    C#
    Copy Code
    NAxis primaryStockVolumesXAxis = stockVolumesChart.Axis(StandardAxis.PrimaryX);
    NAxis primaryStockValuesXAxis = stockValuesChart.Axis(StandardAxis.PrimaryX);
    
    primaryStockVolumesXAxis.Slaves.Add(primaryStockValuesXAxis);
    primaryStockValuesXAxis.Slaves.Add(primaryStockVolumesXAxis);
    
    Visual Basic
    Copy Code
    Dim primaryStockVolumesXAxis As NAxis = stockVolumesChart.Axis(StandardAxis.PrimaryX)
    Dim primaryStockValuesXAxis As NAxis = stockValuesChart.Axis(StandardAxis.PrimaryX)
    
    primaryStockVolumesXAxis.Slaves.Add(primaryStockValuesXAxis)
    primaryStockValuesXAxis.Slaves.Add(primaryStockVolumesXAxis)
    
     Related Examples
    Windows Forms: Interactivity \ Tools \ Axis Scroll Tool
    See Also