[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
   [Expand]Product Information
    Product Structure
    Getting Started
   [Expand]Spreadsheet Document
    Supported Formats
   [Expand]Cell Basics
    Defined Names
    Data Binding
    Data Validation
   [Expand]Data Presentation
    Data Grouping
   [Expand]Pivot Tables
   [Expand]Charts and Graphics
   [Expand]Mail Merge
    Operation Restrictions
    Find and Replace
   [Expand]Visual Elements
   [Expand]Keyboard Shortcuts
    [Expand]Rows and Columns
    [Expand]Import and Export Data
    [Expand]Data Binding
    [Expand]Mail Merge
    [Expand]Formatting Cells
    [Expand]Conditional Formatting
    [Expand]Group Data
    [Expand]Filter Data
    [Expand]Pivot Tables
      How to: Create and Modify a Chart
      How to: Create a Stock Chart
      How to: Format Chart Elements
      How to: Change the Color of Series Points
      How to: Display the Chart Title
      How to: Display and Format Data Labels
      How to: Show or Hide the Chart Legend
      How to: Change the Display of Chart Axes
      How to: Protect a Chart
      How to: Create a Chart Sheet
      How to: Move a Chart to a Chart Sheet
      How to: Specify Chart Sheet Print Options
      How to: Remove a Chart Sheet
      How to: Protect a Chart Sheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Change the Display of Chart Axes

When you create a chart, its primary axes are generated automatically depending on the chart type. Most charts have two primary axes: the category axis (X-axis), usually running horizontally at the bottom of the plot area, and the value axis (Y-axis), usually running vertically on the left side of the plot area. 3-D charts also have the depth (or series) axis along which the series names are displayed. But some charts, like a pie or doughnut chart, have no axes at all.

If the chart type you selected supports axes, you can modify them by displaying axis tick marks and gridlines, changing the axis position, applying formatting options, specifying the axis scaling, adding secondary axes, etc.

Select the action you wish to perform.

Expanded Display or Hide Primary Axes

All primary axes are stored in the primary axis collection (AxisCollection), accessible using the ChartObject.PrimaryAxes property. An individual axis defined by the Axis object can be accessed using the indexer notation (0 for the category axis, 1 for the value axis and 2 for the depth axis if it is present). To display or hide a primary axis, utilize the Axis.Visible property. To position an axis on the chart, use the Axis.Position property.

The example below demonstrates how to create a chart and specify its y-axis position using the Axis.Position property.

Expanded Add Axis Titles

For both primary and secondary axes in the chart, it's possible to add and customize their text titles, which can be used to clarify data displayed along the axes.

The axis titles are not shown by default. However, you can add a title to any horizontal, vertical, or depth axes by utilizing the Axis.Title property, which accesses the ChartTitleOptions object containing display settings for axis titles. This object inherits the ChartText interface which provides methods used to specify the title text. Thus, to add the axis title, set the ChartTitleOptions.Visible property to true, and then do one of the following.

The following example demonstrates how to create a clustered bar chart and add the title to the value axis using the Axis.Title property, which returns the ChartTitleOptions object containing basic title options. Set the ChartTitleOptions.Visible property to true to display the axis title. To explicitly specify the text for the title, utilize the ChartText.SetValue method.

Expanded Specify Scaling Options

By default, the minimum and maximum scale values for the numerical axis are evaluated automatically based on the data used by the chart. However, you can control the axis scaling by using the Axis.Scaling property, which gets the AxisScaling object. The object's properties allow you to control the minimum (AxisScaling.Min) and maximum (AxisScaling.Max) values of the axis, change the numerical axis to logarithmic (AxisScaling.LogScale and AxisScaling.LogBase) and specify the axis orientation (AxisScaling.Orientation).

The example below demonstrates how to create a clustered column chart and specify the value axis scale. Set the AxisScaling.AutoMax and AxisScaling.AutoMin properties to false to indicate that maximum and minimum values of the axis will be set manually by using the AxisScaling.Max and AxisScaling.Min properties

Expanded Format Numbers on the Axis

You can specify how to display numeric values on the axis by applying number formats. Numbers in the axis labels can appear as percentage, decimal, currency, scientific, fraction, text, accounting, date, time, or custom values. To apply a number format to tick-mark labels, utilize the Axis.NumberFormat property. This property provides access to the NumberFormatOptions object that contains format options for displaying numbers in chart elements. Assign the corresponding number format code to the NumberFormatOptions.FormatCode property, and set the NumberFormatOptions.IsSourceLinked property to false to indicate that the applied format differs from the number format of the worksheet cell.

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.

Expanded Display Secondary Axes

When data on a chart vary widely and the scale difference is huge, or when you combine different types of data on a combination chart, you can plot one or more data series along secondary axes.

To display secondary axes for a specific series, assign the AxisGroup.Secondary value to the Series.AxisGroup property. Note that you cannot make all the series on the chart secondary. An exception occurs when you try to change the axis group for the only primary series on a chart or for a series whose chart type does not allow secondary axes.

If the secondary axes were created successfully, they are added to the secondary axis collection (accessible using the ChartObject.SecondaryAxes property) and treated separately from the primary axes. You can get an individual secondary axis defined by the Axis object by its index in the collection (0 for the secondary category axis and 1 for the secondary value axis). For the secondary axes, you can specify the same set of axis options that the primary axes have: for example, you can set the secondary axis position, adjust scaling options, add the axis title, etc.

The example below demonstrates how to display a secondary axis on a chart. The secondary axis group is used to plot data of a specific series, for which the Series.AxisGroup property is set to AxisGroup.Secondary value.

Expanded Display or Hide Axis Tick Marks and Gridlines

When you create a chart, it adds major tick marks to each axis by default. Tick marks are tiny lines used to indicate the demarcation of the axis. You can hide major tick marks or adjust their placement by using the Axis.MajorTickMarks property. To display and position minor tick marks, use the Axis.MinorTickMarks property. You can also specify how many tick marks should appear on the axis by changing the distance between the major and minor tick marks via the Axis.MajorUnit and Axis.MinorUnit properties.

Each major tick mark on the axis is accompanied by a tick-mark label - a textual identifier that explains the meaning of the axis units. Tick-mark labels are generated automatically based on the data displayed along the axis. However, you can remove axis labels from the chart by setting the Axis.TickLabelPosition property to AxisTickLabelPosition.None. You can also apply number format to the numerical values displayed in the labels.

The example below demonstrates how to create the clustered column chart and hide the axis major tick marks by setting the Axis.MajorTickMarks property to the AxisTickMarks.None value.

To improve the readability of a chart, you can display gridlines - a series of horizontal and vertical lines running across the plot area. By default, the chart displays major gridlines for the primary value axis to help you to determine the value of each data point. However, you can hide major gridlines for the value axis or add gridlines to the category axis by using the Axis.MajorGridlines property. You can also display minor gridlines by utilizing the Axis.MinorGridlines property.

The example below demonstrates how to create a simple line chart and display major gridlines for the category axis and the minor gridlines for the value axis by setting the ChartLineOptions.Visible property to true.

Expanded See Also

Is this topic helpful?​​​​​​​