menu

MAUI Toolkit

  • User Guide
  • Demos
  • Support
Class DateTimeCategoryAxis - MAUI-ToolKit API Reference | Syncfusion

    Show / Hide Table of Contents

    Class DateTimeCategoryAxis

    The DateTimeCategoryAxis is a specialized axis for plotting chronological data where the axis labels represent dates and times.

    Inheritance
    System.Object
    ChartAxis
    DateTimeCategoryAxis
    Inherited Members
    ChartAxis.ActualRangeChanged
    ChartAxis.AutoScrollingDelta
    ChartAxis.AutoScrollingDeltaProperty
    ChartAxis.AutoScrollingMode
    ChartAxis.AutoScrollingModeProperty
    ChartAxis.AxisLineOffset
    ChartAxis.AxisLineOffsetProperty
    ChartAxis.AxisLineStyle
    ChartAxis.AxisLineStyleProperty
    ChartAxis.CalculateActualRange()
    ChartAxis.CalculateVisibleInterval(DoubleRange, Size)
    ChartAxis.CalculateVisibleRange(DoubleRange, Size)
    ChartAxis.ComputeDesiredSize(Size)
    ChartAxis.CrossAxisName
    ChartAxis.CrossAxisNameProperty
    ChartAxis.CrossesAt
    ChartAxis.CrossesAtProperty
    ChartAxis.DrawAxis(ICanvas, Rect)
    ChartAxis.DrawAxisLine(ICanvas, Single, Single, Single, Single)
    ChartAxis.DrawGridLine(ICanvas, Double, Single, Single, Single, Single)
    ChartAxis.DrawMajorTick(ICanvas, Double, PointF, PointF)
    ChartAxis.DrawMinorTick(ICanvas, Double, PointF, PointF)
    ChartAxis.EdgeLabelsDrawingMode
    ChartAxis.EdgeLabelsDrawingModeProperty
    ChartAxis.EnableAutoIntervalOnZooming
    ChartAxis.EnableAutoIntervalOnZoomingProperty
    ChartAxis.GetActualDesiredIntervalsCount(Size)
    ChartAxis.IsInversed
    ChartAxis.IsInversedProperty
    ChartAxis.IsVisible
    ChartAxis.IsVisibleProperty
    ChartAxis.LabelCreated
    ChartAxis.LabelExtent
    ChartAxis.LabelExtentProperty
    ChartAxis.LabelRotation
    ChartAxis.LabelRotationProperty
    ChartAxis.LabelsIntersectAction
    ChartAxis.LabelsIntersectActionProperty
    ChartAxis.LabelsPosition
    ChartAxis.LabelsPositionProperty
    ChartAxis.LabelStyle
    ChartAxis.LabelStyleProperty
    ChartAxis.MajorGridLineStyle
    ChartAxis.MajorGridLineStyleProperty
    ChartAxis.MajorTickStyle
    ChartAxis.MajorTickStyleProperty
    ChartAxis.MaximumLabels
    ChartAxis.MaximumLabelsProperty
    ChartAxis.Name
    ChartAxis.NameProperty
    ChartAxis.OnCreateLabels()
    ChartAxis.OnLabelCreated(ChartAxisLabel)
    ChartAxis.PlotOffsetEnd
    ChartAxis.PlotOffsetEndProperty
    ChartAxis.PlotOffsetStart
    ChartAxis.PlotOffsetStartProperty
    ChartAxis.PointToValue(Double, Double)
    ChartAxis.RenderNextToCrossingValue
    ChartAxis.RenderNextToCrossingValueProperty
    ChartAxis.ShowMajorGridLines
    ChartAxis.ShowMajorGridLinesProperty
    ChartAxis.ShowTrackballLabel
    ChartAxis.ShowTrackballLabelProperty
    ChartAxis.TickPosition
    ChartAxis.TickPositionProperty
    ChartAxis.Title
    ChartAxis.TitleProperty
    ChartAxis.TrackballLabelStyle
    ChartAxis.TrackballLabelStyleProperty
    ChartAxis.TrackballLabelTemplate
    ChartAxis.TrackballLabelTemplateProperty
    ChartAxis.ValueToPoint(Double)
    ChartAxis.VisibleLabels
    ChartAxis.VisibleMaximum
    ChartAxis.VisibleMinimum
    ChartAxis.ZoomFactor
    ChartAxis.ZoomFactorProperty
    ChartAxis.ZoomPosition
    ChartAxis.ZoomPositionProperty
    Namespace: Syncfusion.Maui.Toolkit.Charts
    Assembly: Syncfusion.Maui.Toolkit.dll
    Syntax
    public class DateTimeCategoryAxis : ChartAxis, IThemeElement
    Remarks

    The DateTimeCategoryAxis is used only for the X(horizontal) axis in charts.

    To render a DateTimeCategory axis, add its instance to the charts XAxes collection as shown in the following code sample.

    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
            <chart:SfCartesianChart.XAxes>
                <chart:DateTimeCategoryAxis Interval="1" IntervalType="Months"/>
            </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeCategoryAxis xAxis = new DateTimeCategoryAxis()
    {
       Interval = 1,
       IntervalType = DateTimeIntervalType.Months
    };
    chart.XAxes.Add(xAxis);

    The DateTimeCategoryAxis supports the following features. Refer to the corresponding APIs for more details and example codes.

    Title - To render the title on the axis, refer to the Title property.

    Grid Lines - To show and customize grid lines, refer to ShowMajorGridLines and MajorGridLineStyle properties.

    Axis Line - Customize the axis line using the AxisLineStyle property.

    Labels Customization - Customize axis labels using the LabelStyle property.

    Inversed Axis - Invert the axis using the IsInversed property.

    Axis Crossing - For axis crossing, refer to CrossesAt, CrossAxisName, and RenderNextToCrossingValue properties.

    Interval - Define the interval between axis labels using the Interval and IntervalType properties.

    Constructors

    DateTimeCategoryAxis()

    Declaration
    public DateTimeCategoryAxis()

    Fields

    IntervalProperty

    Identifies the Interval bindable property.

    Declaration
    public static readonly BindableProperty IntervalProperty
    Field Value
    Type
    Microsoft.Maui.Controls.BindableProperty
    Remarks

    The Interval property represents the interval value for the DateTimeCategory axis.

    IntervalTypeProperty

    Identifies the IntervalType bindable property.

    Declaration
    public static readonly BindableProperty IntervalTypeProperty
    Field Value
    Type
    Microsoft.Maui.Controls.BindableProperty
    Remarks

    Defines the type of interval for the DateTimeCategory axis.

    PlotBandsProperty

    Identifies the PlotBands bindable property.

    Declaration
    public static readonly BindableProperty PlotBandsProperty
    Field Value
    Type
    Microsoft.Maui.Controls.BindableProperty
    Remarks

    Defines the collection of plot bands for the DateTimeCategory axis.

    Properties

    Interval

    Gets or sets a value that can be used to change the interval between labels.

    Declaration
    public double Interval { get; set; }
    Property Value
    Type Description
    System.Double

    It accepts double values and the default value is double.NaN.

    Remarks

    If this property is not set, the interval will be calculated automatically.

    By default, the interval will be calculated based on the minimum and maximum values of the provided data.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
            <chart:SfCartesianChart.XAxes>
                <chart:DateTimeCategoryAxis Interval="6"/>
            </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeCategoryAxis xAxis = new DateTimeCategoryAxis()
    {
       Interval = 6, 
    };
    chart.XAxes.Add(xAxis);

    IntervalType

    Gets or sets the type of interval to be displayed in the axis.

    Declaration
    public DateTimeIntervalType IntervalType { get; set; }
    Property Value
    Type Description
    DateTimeIntervalType

    It accepts DateTimeIntervalType values and the default value is DateTimeIntervalType.Auto.

    Remarks

    The IntervalType property determines the unit of measurement for the axis interval.

    When set to Auto, the interval type will be calculated automatically based on the data range.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
            <chart:SfCartesianChart.XAxes>
                <chart:DateTimeCategoryAxis Interval="1" IntervalType="Years" />
            </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeCategoryAxis xAxis = new DateTimeCategoryAxis()
    {
       Interval = 1, 
       IntervalType = DateTimeIntervalType.Years
    };
    chart.XAxes.Add(xAxis);

    PlotBands

    Gets or sets the collection of plot bands.

    Declaration
    public NumericalPlotBandCollection PlotBands { get; set; }
    Property Value
    Type Description
    NumericalPlotBandCollection

    It accepts NumericalPlotBandCollection and the default value is null.

    Remarks

    Plot bands are used to shade specific regions in the chart to improve data visualization.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
            <chart:SfCartesianChart.XAxes>
                <chart:DateTimeCategoryAxis>
                    <chart:DateTimeCategoryAxis.PlotBands>
                        <chart:NumericalPlotBand Start="2" End="5" Fill="LightGray" />
                    </chart:DateTimeCategoryAxis.PlotBands>
                </chart:DateTimeCategoryAxis>
            </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeCategoryAxis xAxis = new DateTimeCategoryAxis();
    NumericalPlotBandCollection plotBands = new NumericalPlotBandCollection();
    plotBands.Add(new NumericalPlotBand { Start = 2, End = 5, Fill = new SolidColorBrush(Colors.LightGray) });
    xAxis.PlotBands = plotBands;
    chart.XAxes.Add(xAxis);

    Methods

    ApplyRangePadding(DoubleRange, Double)

    Determines whether padding is applied to the axis range, typically used to add space between the plotted data points and the axis edges.

    Declaration
    protected override sealed DoubleRange ApplyRangePadding(DoubleRange range, double interval)
    Parameters
    Type Name Description
    DoubleRange range
    System.Double interval
    Returns
    Type
    DoubleRange
    Overrides
    ChartAxis.ApplyRangePadding(DoubleRange, Double)

    CalculateActualInterval(DoubleRange, Size)

    Determines the actual interval between axis labels or gridlines based on the axis range and chart size.

    Declaration
    protected override double CalculateActualInterval(DoubleRange range, Size availableSize)
    Parameters
    Type Name Description
    DoubleRange range
    Microsoft.Maui.Graphics.Size availableSize
    Returns
    Type
    System.Double
    Overrides
    ChartAxis.CalculateActualInterval(DoubleRange, Size)

    CalculateNiceInterval(DoubleRange, Size)

    Calculates the actual interval for the axis based on the provided range of values and the available size, ensuring appropriate spacing between axis labels or ticks.

    Declaration
    protected override double CalculateNiceInterval(DoubleRange actualRange, Size availableSize)
    Parameters
    Type Name Description
    DoubleRange actualRange
    Microsoft.Maui.Graphics.Size availableSize
    Returns
    Type
    System.Double
    Overrides
    ChartAxis.CalculateNiceInterval(DoubleRange, Size)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved