Skip to main content

DisplayUnitOptions.UnitType Property

Get or sets the display units for the value axis.

Namespace: DevExpress.Spreadsheet.Charts

Assembly: DevExpress.Spreadsheet.v24.2.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

DisplayUnitType UnitType { get; set; }

Property Value

Type Description
DisplayUnitType

A DisplayUnitType enumeration value specifying the type of display unit scaling applied to the value axis.

Available values:

Show 12 items
Name Description
None

Raw values are displayed on the axis.

Billions

Axis values are divided by 1,000,000,000.

HundredMillions

Axis values are divided by 100,000,000.

Hundreds

Axis values are divided by 100.

HundredThousands

Axis values are divided by 100,000.

Millions

Axis values are divided by 1,000,000.

TenMillions

Axis values are divided by 10,000,000.

TenThousands

Axis values are divided by 10,000.

Thousands

Axis values are divided by 1,000.

Trillions

Axis values are divided by 1,000,000,000,000.

Custom

The DisplayUnitOptions.CustomUnit property defines custom display units. You cannot specify custom units for Microsoft® Excel® 2016 charts.

Percentage

This value is returned for the secondary value axis of a Pareto chart and cannot be used for other chart types.

Property Paths

You can access this nested property as listed below:

Object Type Path to UnitType
Axis
.DisplayUnits .UnitType

Remarks

Use the UnitType property to make the value axis labels easier to read when you plot large numbers on the chart. For example, if the value axis stretches from 10,000 to 100,000, set the UnitType property to DisplayUnitType.Thousands to change the scaling value and display numbers on the value axis as 10 to 100. To show the display unit label, set the DisplayUnitOptions.ShowLabel property to true.

The following images demonstrate how the UnitType property works.

UnitType = DisplayUnitType.None UnitType = DisplayUnitType.Thousands
DisplayUnitsNone DisplayUnitsThousand

Example

The example below demonstrates how to create a clustered column chart and specify the display units for the value axis by utilizing the Axis.DisplayUnits property. This property provides access to the DisplayUnitOptions object containing display unit settings. Set the DisplayUnitOptions.UnitType property to DisplayUnitType.Thousands to divide values on the axis by 1,000. To show the display unit label, set the DisplayUnitOptions.ShowLabel property to true.

View Example

Worksheet worksheet = workbook.Worksheets["chartTask7"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet["B2:C8"]);
chart.TopLeftCell = worksheet.Cells["F2"];
chart.BottomRightCell = worksheet.Cells["N17"];

// Change the scale of the value axis.
AxisCollection axisCollection = chart.PrimaryAxes;
Axis valueAxis = axisCollection[1];
valueAxis.Scaling.AutoMax = false;
valueAxis.Scaling.Max = 8000000;
valueAxis.Scaling.AutoMin = false;
valueAxis.Scaling.Min = 0;

// Specify display units for the value axis.
valueAxis.DisplayUnits.UnitType = DisplayUnitType.Thousands;
valueAxis.DisplayUnits.ShowLabel = true;

// Set the chart style.
chart.Style = ChartStyle.ColorBevel;
chart.Views[0].VaryColors = true;

// Hide the legend.
chart.Legend.Visible = false;

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the UnitType property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also