Skip to main content

AxisLabel.TextPattern Property

Gets or sets a string that formats text for the auto-generated x- or y-axis labels.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v23.2.dll

NuGet Package: DevExpress.Charts

Declaration

[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
public string TextPattern { get; set; }

Property Value

Type Description
String

The string that formats text for axis labels.

The default value is Empty.

Remarks

The following images show how various patterns affect the axis label text:

The code below formats label text:

AxisLabel axisXLabel = ((XYDiagram)chartControl.Diagram).AxisX.Label;
AxisLabel axisYLabel = ((XYDiagram)chartControl.Diagram).AxisY.Label;

axisXLabel.TextPattern = "{A:dd-MM HH:mm}";
axisYLabel.TextPattern = "{V} °F";

Patterns can contain regular text (displayed as is) and value placeholders in braces. To format numeric and date/time values, you can apply Format Specifiers. Use a colon to separate a placeholder and its format specifier.

The following table contains the available placeholders:

Placeholder Description
Placeholders available for arguments’ axis
{A} Use it to display arguments.
Placeholders available for values’ axis
{V} Use it to display values.
{VP} Use it to display values as a percentage.

Note

To show year quarters for the date-time x-axis labels, use the “{A:q}” pattern.

You can use the Pattern Editor to specify the label text format. To invoke the editor, click the TextPattern property ellipsis button in the Properties window or in the Chart Designer.

PatternEditor

Example

This example demonstrates how to customize axis labels’ text pattern. Axis labels use this pattern to provide text representation of axis values’ on which labels are located.

Use the following properties to access the text pattern:

Property Description
Axis2D.Label Gets the settings of axis labels.
Axis3D.Label Gets the settings of axis labels in 3D series.
RadarAxisX.Label Gets the settings of axis labels.
RadarAxisY.Label Gets the settings of axis labels.
AxisLabel.TextPattern Gets or sets a string that formats text for the auto-generated x- or y-axis labels.
using System;
using DevExpress.XtraCharts;

namespace LabelTextPatternSample {
    public partial class Form1 : DevExpress.XtraEditors.XtraForm {
        protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
            if (chartControl1.Diagram is XYDiagram xyDiagram) {
                xyDiagram.AxisX.Label.TextPattern = "Region: {A}";
                xyDiagram.AxisY.Label.TextPattern = "{VP:P0}";
            }
        }
        public Form1() {
            InitializeComponent();
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the TextPattern 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