Skip to main content

DateTimeAxisX Class

The X-axis that the chart uses to display series of data points with date-time arguments.

Namespace: DevExpress.Maui.Charts

Assembly: DevExpress.Maui.Charts.dll

NuGet Package: DevExpress.Maui.Charts


public class DateTimeAxisX :


ChartView chooses the X-axis type based on the data in the first series. If arguments are date-time values, the chart uses a DateTimeAxisX.

The chart shows DateTime values in the UTC format. Even if you change the time to a local value, ChartView shows them as if you converted them back to UTC. To resolve the issue, create a new DateTime value with the value returned by the ToLocalTime method and the Kind property set to UTC:

DateTime baseTime = new DateTime(2022, 11, 14, 9, 0, 0, DateTimeKind.Utc);
baseTime = new DateTime(baseTime.ToLocalTime().Ticks, DateTimeKind.Utc);

Use the ChartView.AxisX property to access the automatically created axis. To create and customize axes for individual series, use the Series.AxisX property.

    <!--Specify an X-axis at the chart level-->
        <dxc:DateTimeAxisX />

            <!--Specify an X-axis at the series level-->
                <dxc:DateTimeAxisX />

The DateTimeAxisX class properties allow you to configure the following axis options: range, scale parameters, labels, title, constant lines, strip, gridlines, tickmarks and interlacing colors. You can also change the axis position.

X-Axis Elements

Value Range

The ChartView automatically calculates the axis range based on data series values. You can specify a custom range for the axis. To do this, set the DateTimeAxisX.Range property to a DateTimeRange object with the following properties specified:

  • Min and Max - specify the entire range of the axis scale. A chart does not visualize data that is out of this range. A user can scroll the chart through this range when scroll is enabled for the X-axis (AxisXNavigationMode).

  • VisualMin and VisualMax - configure the axis scale range currently visible on the screen.

  • SideMargin - sets the value of margins on both sides of the axis.

X-Axis Elements

        <dxc:DateTimeRange Min="1/1/1950" VisualMin="1/1/1970"
                           Max="1/1/2050" VisualMax="1/1/2030" 

You can also set the DateTimeAxisX.EmptyRangesVisible property to False to hide the ranges of the DateTimeAxisX that contain no data.

Axis Scale Parameters

Use the following properties to configure the axis scale:

DateTime Axis X Scale Settings

<dxc:DateTimeAxisX MeasureUnit="Month" GridOffset="6"
                   GridAlignment="Year" GridSpacing="10"/>

Axis Labels

Axis labels display values at major tickmarks. They are automatically generated based on series data.

Axis Label Sample

To configure axis labels, set the axis’s Label property to an AxisLabel object with the specified settings. For example, you can use the AxisLabel.TextFormat property to change the text pattern applied to axis labels.

        <dxc:AxisLabel TextFormat="yyyy yr"/>

Label Text Formatter

To generate text strings for axis labels based on a custom condition:

  1. Create a class that inherits the IAxisLabelTextFormatter interface and implement the Format method.
  2. Assign an instance of the newly created class to the LabelTextFormatter property (it has a higher priority than AxisLabel.TextFormat).

This example shows how to format labels of a date-time axis.

<dxc:DateTimeAxisX GridAlignment="Day" GridSpacing="7">
using DevExpress.Maui.Charts;

public class AxisLabelFormatter : IAxisLabelTextFormatter {
    public string Format(object axisValue) {
        DateTime value = (DateTime)axisValue;
        return ((value.Day >= 1) && (value.Day <= 7)) ? $"{value.ToString("MMM, d")}" : $"{value.Day}";

Label Format Auto Replace

The ChartView can detect if adjacent date-time argument values belong to different measurement units (for example, days of different months) and automatically display a transition label on a date-time axis (for example, the first-day label of the next month) with a different format.

To enable this functionality:

  1. Set the DateTimeAxisX.LabelFormatAutoReplaceOptions property to an AxisLabelFormatAutoReplaceOptions object.
  2. Add DateTimeLabelFormat objects that specify label formats (Format) for arguments of different measurement units (MeasureUnit) to the AxisLabelFormatAutoReplaceOptions.LabelFormats collection.


    LabelFormats is a content property. You can skip property tags in the markup.

    If you do not populate the LabelFormats collection explicitly, the following default formats are used depending on the axis’s MeasureUnit and GridAlignment settings:

    Measurement Unit*

    Label Format


    Millisecond - “SSS”
    Second - “HH:mm:ss SSS”
    Day - “dd MMMM HH:mm:ss SSS”
    Year - “dd/MM/yyyy HH:mm:ss SSS”


    Second - “HH:mm:ss”
    Day - “dd MMMM HH:mm:ss”
    Year - “dd/MM/yyyy HH:mm:ss”


    Day - “dd MMMM”
    Year - “dd MMMM yyyy”


    Month - “MMMM”
    Year - “MMMM yyyy”


    Year - “yyyy”

    Measurement Unit* - the larger measurement unit assigned to the MeasureUnit and GridAlignment properties.

The following example configures a date-time axis so that it automatically shows when the next month starts:

Axis Label Format Auto Replace

<dxc:DateTimeAxisX x:Name="xAxis" GridAlignment="Day" GridSpacing="5">
            <dxc:DateTimeLabelFormat MeasureUnit="Day" Format="d"/>
            <dxc:DateTimeLabelFormat MeasureUnit="Month" Format="MMM, d"/>

Avoid Axis Label Overlap

You can hide axis labels to resolve overlapping labels. To enable this option, assign an AxisLabelResolveOverlappingOptions object (its AllowHide property should be set to true) to the AxisLabel.ResolveOverlappingOptions property.

<dxc:DateTimeAxisX x:Name="myAxis" GridAlignment="Day" GridSpacing="6">
        <dxc:AxisLabel TextFormat="M/d/yy">
                <dxc:AxisLabelResolveOverlappingOptions AllowHide="True"/>

Axis Title

Use the Title property to access the X-axis’s title settings.

This example demonstrates how to create, align, and customize the appearance of the X-axis’s title.

Axis Title Sample

        <dxc:AxisTitle Text="Year" Alignment="Center"/>
                        <dxc:TextStyle Color="DarkRed" Size="24"/>

You can also use the AxisTitle‘s Visible property to change the title visibility.

Constant Lines

A Constant Line visually highlights an axis value as a line perpendicular to the X-Axis.

Constant Line Sample

This example shows how to add a constant line to the X-axis, customize its appearance and display it in the chart legend. To do this, add a DateTimeConstantLine object with the specified properties to the DateTimeAxisX.ConstantLines collection.

        <dxc:DateTimeConstantLine AxisValue="2019" ShowBehind="False" 
                                  VisibleInLegend="True" LegendText="Nowadays">
            <!-- Customize the constant line title. -->
                <dxc:ConstantLineTitle Text="Nowadays" ShowBelowLine="False" Alignment="Near">
                                <dxc:TextStyle Color="DarkBlue" Size="24"/>
            <!-- Customize the constant line appearance. -->
                <dxc:ConstantLineStyle Thickness="5"/>


A Strip highlights a specific range of axis values as a rectangular area with an axis label.

Constant Line Sample

        <dxc:DateTimeStrip MinLimit="2019" MaxLimitEnabled="False">
                <dxc:StripAxisLabel Text="Future"/>


The axis hides its labels when any strip has a label.

Axis Appearance

The axis has the Style property that stores the appearance of the following elements:



Axis Line

LineColor, LineThickness, LineVisible

Major Tickmarks

LineColor, MajorTickmarksThickness, MajorTickmarksLength, MajorTickmarksVisible

Minor Tickmarks

LineColor, MinorTickmarksThickness, MinorTickmarksLength, MinorTickmarksVisible

Major Gridlines

MajorGridlinesThickness, MajorGridlinesColor, MajorGridlinesVisible

Minor Gridlines

MinorGridlinesThickness, MinorGridlinesColor, MinorGridLinesVisible


InterlacedVisible, InterlacedColor

Axis Appearance Settings


Labels, Titles, Constant Lines and Strips have Style properties that manage the appearance of these elements.

Axis Position

Use the DisplayPosition property to specify where an X-axis should be positioned within the chart diagram.

This example anchors an X-axis to the top portion of the chart’s plot area:

Axis Position Sample

See Also