Xceed Chart for WinForms v4.4 Documentation
Custom Axes

Welcome to Xceed Chart for WinForms v4.4 > User Guide > Axes > Custom Axes

Xceed Chart for WinForms supports an unlimited number of custom axes. Custom axes can be horizontal and vertical, and the user can instruct the series to be scaled on them.

Creating a Custom Axis

Custom axes are created with the AddCustomAxis method of the AxisCollection class. The method receives two arguments: the orientation of the new axis and its predefined position. Because only horizontal and vertical custom axes can be created, the method will raise an exception if you try to create an axis with Depth orientation. The following code creates a vertical custom axis with a FrontLeft predefined position.

VB.NET  

Dim chart AsChart = CType(chartControl1.Charts(0), Chart)
Dim axis As Axis = chart.Axes.AddCustomAxis(AxisOrientation.Vertical,AxisPredefinedPositon.FrontLeft)
C#  

Chart chart = (Chart)chartControl1.Charts[0];
Axis axis = chart.Axes.AddCustomAxis(AxisOrientation.Vertical, AxisPredefinedPositon.FrontLeft);

Accessing the Custom Axis

The component assigns a 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, the user can save the ID with the following code:

VB.NET  
Dim nAxisId As Integer = axis.AxisId

C#  
int nAxisId = axis.AxisId;

Later, if a reference to the custom axis with this ID is needed, the GetAxis method can be used:

VB.NET  
Dim axis As Axis =   Chart.Axes.GetAxis(nAxisId)

C#  
Axis axis = Chart.Axes.GetAxis(nAxisId);

Scaling the Series on the Custom Axis

The DisplayOnAxis and IsDisplayedOnAxis methods have two overloads, which accept an axis ID. Using these methods, the user can scale the series on an arbitrary custom axis and query whether the series is scaled on this axis, respectively. The following code scales a bar series on the custom axis.

VB.NET  

Dim bar As BarSeries = Chart.Series.Add(SeriesType.Bar)
bar.DisplayOnAxis(nAxisId, True)
C#  

BarSeries bar = Chart.Series.Add(SeriesType.Bar);
bar.DisplayOnAxis(nAxisId, true);

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

Using a Custom Axis as a Synchronization Axis for Another Axis

In the Axis Position topic we described the possibility of synchronizing an axis coordinate with the value of another axis using the PositionAxis method. This method has an override which accepts an AxisId.

Related Examples

Windows forms: Axes\General\Custom Axes

See Also

Axis | AxisCollection