menu

WinUI

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class DateTimeAxis - WinUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class DateTimeAxis

    DateTimeAxis is used to plot DateTime values in chart axis.

    Inheritance
    System.Object
    ChartAxis
    RangeAxisBase
    DateTimeAxis
    Implements
    System.ComponentModel.INotifyPropertyChanged
    Inherited Members
    ChartAxis.ActualRangeChanged
    ChartAxis.AutoScrollingDelta
    ChartAxis.AutoScrollingDeltaProperty
    ChartAxis.AutoScrollingMode
    ChartAxis.AutoScrollingModeProperty
    ChartAxis.AxisLineOffset
    ChartAxis.AxisLineOffsetProperty
    ChartAxis.AxisLineStyle
    ChartAxis.AxisLineStyleProperty
    ChartAxis.CalculateVisibleInterval(DoubleRange, Size)
    ChartAxis.CrosshairLabelTemplate
    ChartAxis.CrosshairLabelTemplateProperty
    ChartAxis.EdgeLabelsDrawingMode
    ChartAxis.EdgeLabelsDrawingModeProperty
    ChartAxis.EnableAutoIntervalOnZooming
    ChartAxis.EnableAutoIntervalOnZoomingProperty
    ChartAxis.GetActualDesiredIntervalsCount(Size)
    ChartAxis.GetRenderedRect()
    ChartAxis.Header
    ChartAxis.HeaderProperty
    ChartAxis.HeaderStyle
    ChartAxis.HeaderStyleProperty
    ChartAxis.HeaderTemplate
    ChartAxis.HeaderTemplateProperty
    ChartAxis.IsInversed
    ChartAxis.IsInversedProperty
    ChartAxis.LabelCreated
    ChartAxis.LabelExtent
    ChartAxis.LabelExtentProperty
    ChartAxis.LabelRotation
    ChartAxis.LabelRotationProperty
    ChartAxis.LabelsIntersectAction
    ChartAxis.LabelsIntersectActionProperty
    ChartAxis.LabelStyle
    ChartAxis.LabelStyleProperty
    ChartAxis.LabelTemplate
    ChartAxis.LabelTemplateProperty
    ChartAxis.MajorGridLineStyle
    ChartAxis.MajorGridLineStyleProperty
    ChartAxis.MajorTickStyle
    ChartAxis.MajorTickStyleProperty
    ChartAxis.MeasureOverride(Size)
    ChartAxis.OnApplyTemplate()
    ChartAxis.OnCreateLabels()
    ChartAxis.OnLabelCreated(ChartAxisLabel)
    ChartAxis.OpposedPosition
    ChartAxis.OpposedPositionProperty
    ChartAxis.PlotOffsetEnd
    ChartAxis.PlotOffsetEndProperty
    ChartAxis.PlotOffsetStart
    ChartAxis.PlotOffsetStartProperty
    ChartAxis.PointToValue(Double, Double)
    ChartAxis.PropertyChanged
    ChartAxis.ShowMajorGridLines
    ChartAxis.ShowMajorGridLinesProperty
    ChartAxis.ShowTrackballLabel
    ChartAxis.ShowTrackballLabelProperty
    ChartAxis.TickLineSize
    ChartAxis.TickLineSizeProperty
    ChartAxis.TrackballLabelTemplate
    ChartAxis.TrackballLabelTemplateProperty
    ChartAxis.ValueToPoint(Double)
    ChartAxis.VisibleMaximum
    ChartAxis.VisibleMinimum
    ChartAxis.ZoomFactor
    ChartAxis.ZoomFactorProperty
    ChartAxis.ZoomPosition
    ChartAxis.ZoomPositionProperty
    RangeAxisBase.EdgeLabelsVisibilityMode
    RangeAxisBase.EdgeLabelsVisibilityModeProperty
    RangeAxisBase.MinorGridLineStyle
    RangeAxisBase.MinorGridLineStyleProperty
    RangeAxisBase.MinorTickLineSize
    RangeAxisBase.MinorTickLineSizeProperty
    RangeAxisBase.MinorTicksPerInterval
    RangeAxisBase.MinorTicksPerIntervalProperty
    RangeAxisBase.MinorTickStyle
    RangeAxisBase.MinorTickStyleProperty
    RangeAxisBase.ShowMinorGridLines
    RangeAxisBase.ShowMinorGridLinesProperty
    Namespace: Syncfusion.UI.Xaml.Charts
    Assembly: Syncfusion.Chart.WinUI.dll
    Syntax
    public class DateTimeAxis : RangeAxisBase, INotifyPropertyChanged
    Remarks

    The date-time axis uses date time scale and displays date-time values as axis labels in the specified format.

    To render an axis, create an instance of DateTimeAxis and add it to the XAxes or YAxes collection.

    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
            <chart:SfCartesianChart.XAxes>
                <chart:DateTimeAxis/>
            </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeAxis xaxis = new DateTimeAxis();
    chart.XAxes.Add(xaxis);	

    Header - To render the header, refer to this Header property.

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

    Tick Lines - To show and customize the tick lines, refer to these MajorTickStyle, MinorTickStyle, and MinorTicksPerInterval properties.

    Axis Line - To customize the axis line using the AxisLineStyle property.

    Range Customization - To customize the axis range with help of the Minimum, and Maximum properties.

    Labels Customization - To customize the axis labels, refer to this LabelStyle property.

    Inversed Axis - Inverse the axis using the IsInversed property.

    Interval - To define the axis labels interval using the Interval, and IntervalType properties.

    Constructors

    DateTimeAxis()

    Initializes a new instance of the DateTimeAxis class.

    Declaration
    public DateTimeAxis()

    Fields

    AutoScrollingDeltaTypeProperty

    The DependencyProperty for AutoScrollingDeltaType property.

    Declaration
    public static readonly DependencyProperty AutoScrollingDeltaTypeProperty
    Field Value
    Type
    Microsoft.UI.Xaml.DependencyProperty

    IntervalProperty

    The DependencyProperty for Interval property.

    Declaration
    public static readonly DependencyProperty IntervalProperty
    Field Value
    Type
    Microsoft.UI.Xaml.DependencyProperty

    IntervalTypeProperty

    The DependencyProperty for IntervalType property.

    Declaration
    public static readonly DependencyProperty IntervalTypeProperty
    Field Value
    Type
    Microsoft.UI.Xaml.DependencyProperty

    MaximumProperty

    The DependencyProperty for Maximum property.

    Declaration
    public static readonly DependencyProperty MaximumProperty
    Field Value
    Type
    Microsoft.UI.Xaml.DependencyProperty

    MinimumProperty

    The DependencyProperty for Minimum property.

    Declaration
    public static readonly DependencyProperty MinimumProperty
    Field Value
    Type
    Microsoft.UI.Xaml.DependencyProperty

    RangePaddingProperty

    The DependencyProperty for RangePadding property.

    Declaration
    public static readonly DependencyProperty RangePaddingProperty
    Field Value
    Type
    Microsoft.UI.Xaml.DependencyProperty

    Properties

    ActualMaximum

    Gets the actual maximum value of the DateTimeAxis.

    Declaration
    public DateTime ActualMaximum { get; }
    Property Value
    Type
    System.DateTime
    Examples
    • MainWindow.xaml
    • MainWindow.cs
      <StackPanel>
        <TextBlock Text="{Binding ElementName=xAxis, Path=ActualMaximum, Mode=TwoWay}" />
        <chart:SfCartesianChart>
    
              <chart:SfCartesianChart.XAxes>
                  <chart:DateTimeAxis x:Name="xAxis"/>
              </chart:SfCartesianChart.XAxes>
    
              <chart:SfCartesianChart.YAxes>
                  <chart:NumericalAxis x:Name="yAxis"/>
              </chart:SfCartesianChart.YAxes>
    
              <chart:SfCartesianChart.Series>
                  <chart:ColumnSeries ItemsSource="{Binding Data}"
                                      XBindingPath="XValue"
                                      YBindingPath="YValue" />
              </chart:SfCartesianChart.Series>
    
        </chart:SfCartesianChart>
      </StackPanel>
        SfCartesianChart chart = new SfCartesianChart();
    
        DateTimeAxis xAxis = new DateTimeAxis();
        NumericalAxis yAxis = new NumericalAxis();
    
        chart.XAxes.Add(xAxis);
        chart.YAxes.Add(yAxis);
    
        ColumnSeries series = new ColumnSeries();
        series.ItemsSource = viewmodel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);
    
        TextBlock textBlock = new TextBlock();
        Binding binding = new Binding();
        binding.Source = xAxis;
        binding.Path = new PropertyPath("ActualMaximum");
        textBlock.SetBinding(TextBlock.TextProperty, binding);

    ActualMinimum

    Gets the actual minimum value of the DateTimeAxis.

    Declaration
    public DateTime ActualMinimum { get; }
    Property Value
    Type
    System.DateTime
    Examples
    • MainWindow.xaml
    • MainWindow.cs
      <StackPanel>
        <TextBlock Text="{Binding ElementName=xAxis, Path=ActualMinimum, Mode=TwoWay}" />
        <chart:SfCartesianChart>
    
              <chart:SfCartesianChart.XAxes>
                  <chart:DateTimeAxis x:Name="xAxis"/>
              </chart:SfCartesianChart.XAxes>
    
              <chart:SfCartesianChart.YAxes>
                  <chart:NumericalAxis x:Name="yAxis"/>
              </chart:SfCartesianChart.YAxes>
    
              <chart:SfCartesianChart.Series>
                  <chart:ColumnSeries ItemsSource="{Binding Data}"
                                      XBindingPath="XValue"
                                      YBindingPath="YValue" />
              </chart:SfCartesianChart.Series>
    
        </chart:SfCartesianChart>
      </StackPanel>
        SfCartesianChart chart = new SfCartesianChart();
    
        DateTimeAxis xAxis = new DateTimeAxis();
        NumericalAxis yAxis = new NumericalAxis();
    
        chart.XAxes.Add(xAxis);
        chart.YAxes.Add(yAxis);
    
        ColumnSeries series = new ColumnSeries();
        series.ItemsSource = viewmodel.Data;
        series.XBindingPath = "XValue";
        series.YBindingPath = "YValue";
        chart.Series.Add(series);
    
        TextBlock textBlock = new TextBlock();
        Binding binding = new Binding();
        binding.Source = xAxis;
        binding.Path = new PropertyPath("ActualMinimum");
        textBlock.SetBinding(TextBlock.TextProperty, binding);

    AutoScrollingDeltaType

    Gets or sets the enum DateTimeIntervalType to determine the unit of time used for the delta value for auto-scrolling on a DateTime axis.

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

    This property takes the DateTimeIntervalType as its value.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
       <chart:SfCartesianChart.XAxes>
           <chart:DateTimeAxis AutoScrollingDelta = "3" AutoScrollingDeltaType="Years"/>
       </chart:SfCartesianChart.XAxes>
       <chart:SfCartesianChart.YAxes>
           <chart:NumericalAxis/>
       </chart:SfCartesianChart.YAxes>
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeAxis xAxis = new DateTimeAxis();
    xAxis.AutoScrollingDelta = 3;
    xAxis.AutoScrollingDeltaType = DateTimeIntervalType.Years;
    
    NumericalAxis yAxis = new NumericalAxis();
    
    chart.XAxes.Add(xAxis);	
    chart.YAxes.Add(yAxis);	

    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 0.

    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.

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

    IntervalType

    Gets or sets the date time unit of the value specified in the Interval property.

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

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

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
            <chart:SfCartesianChart.XAxes>
                <chart:DateTimeAxis IntervalType="Months"/>
            </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeAxis xaxis = new DateTimeAxis()
    {
        IntervalType = DateTimeIntervalType.Months
    };
    chart.XAxes.Add(xaxis);

    Maximum

    Gets or sets the maximum value of the time period to be displayed on the chart axis.

    Declaration
    public DateTime Maximum { get; set; }
    Property Value
    Type Description
    System.DateTime

    The default value is DateTime.MaxValue.

    Remarks

    If we didn't set the maximum value, it will be calculated from the underlying collection.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
            <chart:SfCartesianChart.XAxes>
                <chart:DateTimeAxis Minimum="2021/05/10" Maximum="2021/11/01"/>
            </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeAxis xaxis = new DateTimeAxis()
    {
        Minimum = new DateTime(2021,05,10),
        Maximum = new DateTime(2021,11,01),
    };
    chart.XAxes.Add(xaxis);	

    Minimum

    Gets or sets the minimum value of the time period to be displayed on the chart axis.

    Declaration
    public DateTime Minimum { get; set; }
    Property Value
    Type Description
    System.DateTime

    The default value is DateTime.MinValue.

    Remarks

    If we didn't set the minimum value, it will be calculated from the underlying collection.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
            <chart:SfCartesianChart.XAxes>
                <chart:DateTimeAxis Minimum="2021/05/10" Maximum="2021/11/01"/>
            </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeAxis xaxis = new DateTimeAxis()
    {
        Minimum = new DateTime(2021,05,10),
        Maximum = new DateTime(2021,11,01),
    };
    chart.XAxes.Add(xaxis);	

    RangePadding

    Gets or sets a padding type for the date time axis range.

    Declaration
    public DateTimeRangePadding RangePadding { get; set; }
    Property Value
    Type Description
    DateTimeRangePadding

    It acceps the DateTimeRangePadding value and its default value is Auto

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
            <chart:SfCartesianChart.XAxes>
                <chart:DateTimeAxis RangePadding ="Round" />
            </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    DateTimeAxis xaxis = new DateTimeAxis()
    {
        RangePadding = DateTimeRangePadding.Round,
    };
    chart.XAxes.Add(xaxis);

    Methods

    ApplyRangePadding(DoubleRange, Double)

    Declaration
    protected override 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)

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

    CalculateActualRange()

    Declaration
    protected override DoubleRange CalculateActualRange()
    Returns
    Type
    DoubleRange
    Overrides
    ChartAxis.CalculateActualRange()

    CalculateNiceInterval(DoubleRange, Size)

    Declaration
    protected override double CalculateNiceInterval(DoubleRange actualRange, Size availableSize)
    Parameters
    Type Name Description
    DoubleRange actualRange
    Windows.Foundation.Size availableSize
    Returns
    Type
    System.Double
    Overrides
    ChartAxis.CalculateNiceInterval(DoubleRange, Size)

    CalculateVisibleRange(DoubleRange, Size)

    Declaration
    protected override DoubleRange CalculateVisibleRange(DoubleRange range, Size availableSize)
    Parameters
    Type Name Description
    DoubleRange range
    Windows.Foundation.Size availableSize
    Returns
    Type
    DoubleRange
    Overrides
    ChartAxis.CalculateVisibleRange(DoubleRange, Size)

    Implements

    System.ComponentModel.INotifyPropertyChanged
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved