officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-axis-46cf47ec.md
Provides access to number format options for numerical values displayed in axis labels.
Namespace : DevExpress.Spreadsheet.Charts
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
NumberFormatOptions NumberFormat { get; }
ReadOnly Property NumberFormat As NumberFormatOptions
| Type | Description |
|---|---|
| NumberFormatOptions |
A NumberFormatOptions object that contains formatting options for displaying numbers.
|
You can specify how to display numeric values on the axis by applying number formats. For example, a number in the axis label can appear as a percentage, decimal, currency, accounting, date or time value. To apply a number format to axis labels, assign the corresponding number format code to the NumberFormatOptions.FormatCode property. This property takes effect only when the NumberFormatOptions.IsSourceLinked property, which allows you to keep the number format linked to the worksheet cell, is set to false.
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;
Dim worksheet As Worksheet = workbook.Worksheets("chartTask3")
workbook.Worksheets.ActiveWorksheet = worksheet
' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet("B3:C5"))
chart.TopLeftCell = worksheet.Cells("H2")
chart.BottomRightCell = worksheet.Cells("N14")
' Format the axis labels.
Dim axis As Axis = chart.PrimaryAxes(1)
axis.NumberFormat.FormatCode = "0%"
axis.NumberFormat.IsSourceLinked = False
' Hide the legend.
chart.Legend.Visible = False
See Also