Back to Devexpress

How to: Change the Display Format for Axis Labels

windowsforms-5877-controls-and-libraries-chart-control-examples-creating-charts-data-representation-how-to-change-the-display-format-for-axis-labels.md

latest3.2 KB
Original Source

How to: Change the Display Format for Axis Labels

  • Jul 17, 2019
  • 2 minutes to read

The following tutorial demonstrates how to customize the display format of the date-time values for the X-axis labels at design time. To learn more about using different scale types in XtraCharts, refer to the Axis Scale Types.

In this example, we use a simple unbound chart with a set of manually entered points for its series. These points’ values are shown in the following image.

Note

The approach described below can also be applied to a data-bound chart.

To change the display format of the date-time values for the X-axis labels, do the following.

  1. Select the axis of arguments (X-axis), and in the Properties window, set the DateTimeScaleOptions.MeasureUnit property to Month.

  2. To change X-axis label appearance, set the DateTimeScaleOptions.GridAlignment property to Month.

  3. To specify a pattern for axis labels, expand Label in the Properties window and locate the AxisLabel.TextPattern property. Then, click the ellipsis button.

  4. In the invoked Pattern Editor, double click Argument in the ‘Placeholders:’ column. Then, select the dd-MMM-yy format in the ‘Format:’ column to display day, month and year in the axis labels. You can see the final pattern in the ‘Pattern:’ column.

  5. To apply the pattern, click OK. This closes the Pattern Editor.

The result is shown in the following image.

You can also specify this text pattern for axis labels via the Chart Designer.

See Also

How to: Change the Display Format for Axis Labels (Runtime Sample)

How to: Exclude Weekends and Holidays from the Axis Scale

Axis Scale Types

Axis Labels

Pattern Editor