Chart for .NET / User's Guide / Axes / Custom Axes

Custom Axes

Cartesian charts support unlimited number of custom X and Y axes.

 Creating a custom axis

Custom axes are created with the help of the AddCustomAxis method of the NAxisCollection class. The method receives two arguments - the orientation of the new axis and its predefined position. Currently only horizontal and vertical custom axes are supported. The following code creates a vertical custom axis with FrontLeft predefined position.

C#
Copy Code
NCartesianChart chart = (NCartesianChart)chartControl.Charts[0];
NAxis axis = chart.Axes.AddCustomAxis(AxisOrientation.Vertical, AxisPredefinedPositon.FrontLeft);
Visual Basic
Copy Code
Dim chart As NCartesianChart = chartControl.Charts(0)
Dim axis As NAxis = chart.Axes.AddCustomAxis(AxisOrientation.Vertical,  AxisPredefinedPositon.FrontLeft)
 Accessing the custom axis

The component assigns an unique ID for each custom axis. This id can later be used to obtain a reference to the custom axis. In the context of the previous code example, you can save the id with the following code:

C#
Copy Code
int axisId = axis.AxisId;
Visual Basic
Copy Code
Dim axisId As Integer = axis.AxisId

Later you can obtain a reference to the custom axis object with the help of the GetAxis method:

C#
Copy Code
NAxis axis = chart.Axes.GetAxis(axisId);
Visual Basic
Copy Code
Dim axis As NAxis = chart.Axes.GetAxis(axisId)
 Scaling series on a custom axis

You can scale a series on an arbitrary custom axis with the help of the DisplayOnAxis method of the NSeriesBase type. You can query whether the series is scaled on a particular axis with the help of the IsDisplayedOnAxis method. The following code scales a bar series on the custom axis.

C#
Copy Code
NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
bar.DisplayOnAxis(axisId, true);
Visual Basic
Copy Code
Dim bar As NBarSeries = chart.Series.Add(SeriesType.Bar)
bar.DisplayOnAxis(axisId, True)

See the Basic Series Functionality topic for more information regarding the scaling of the series on the chart axes.

 Related Examples
Windows Forms: Axes \ General \ Docking
See Also