AxisCollection Interface
A collection that stores axes in the chart.
Namespace: DevExpress.Spreadsheet.Charts
Assembly: DevExpress.Spreadsheet.v24.1.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
public interface AxisCollection :
ISimpleCollection<Axis>,
IEnumerable<Axis>,
IEnumerable,
ICollection
Related API Members
The following members return AxisCollection objects:
Remarks
The AxisCollection is generated automatically when creating a chart and depends on the chart type. Most charts have two primary axes: the category axis (X-axis) and the value axis (Y-axis). 3-D charts also have the depth (or series) axis along which the series names are displayed. The bubble and scatter charts have two value axis, while the pie and doughnut charts have no axes at all.
To access a collection of primary axes, use the ChartObject.PrimaryAxes property. You can get an individual axis defined by the Axis object by its index in the collection. The category axis is the first item in the axis collection with the index 0, the value axis is the second item with the index 1, and the series axis (if it is presented) is the third item with the index 2.
A chart may also have a collection of secondary axes accessible via the ChartObject.SecondaryAxes property. This collection includes two items: the secondary category axis with the index 0 and the secondary value axis with index 1. To display secondary axes for a specific series, set the Series.AxisGroup property to the AxisGroup.Secondary value.
Example
The following example demonstrates how to create a clustered column chart and display numbers on the value axis as percentage values. To apply the number format, set the NumberFormatOptions.IsSourceLinked property to false
and assign the corresponding format code to the NumberFormatOptions.FormatCode property.
Worksheet worksheet = workbook.Worksheets["chartTask3"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet["B3:C5"]);
chart.TopLeftCell = worksheet.Cells["H2"];
chart.BottomRightCell = worksheet.Cells["N14"];
// Format the axis labels.
Axis axis = chart.PrimaryAxes[1];
axis.NumberFormat.FormatCode = "0%";
axis.NumberFormat.IsSourceLinked = false;
// Hide the legend.
chart.Legend.Visible = false;