Class DateTimeAxis
DateTimeAxis is used to plot DateTime values. The date-time axis uses date time scale and displays date-time values as axis labels in the specified format.
Inherited Members
Namespace: Syncfusion.Maui.Toolkit.Charts
Assembly: Syncfusion.Maui.Toolkit.dll
Syntax
public class DateTimeAxis : RangeAxisBase, IThemeElement
Remarks
To render an axis, the datetime axis instance to be added in chart’s XAxes collection as per the following code snippet.
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis/>
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
Title - To render the title, refer to this Title property.
Grid Lines - To show and customize the grid lines refer these ShowMajorGridLines, and MajorGridLineStyle, ShowMinorGridLines, MinorTicksPerInterval, MinorGridLineStyle properties.
Tick Lines - To show and customize the tick lines refer these MajorTickStyle, MinorTickStyle, 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.
Axis Crossing - For axis crossing, refer these CrossesAt, CrossAxisName, and RenderNextToCrossingValue properties.
Interval - To define the axis labels interval using the Interval, and IntervalType properties.
Constructors
DateTimeAxis()
Declaration
public DateTimeAxis()
Fields
AutoScrollingDeltaTypeProperty
Identifies the AutoScrollingDeltaType bindable property.
Declaration
public static readonly BindableProperty AutoScrollingDeltaTypeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Defines the type of interval[Years, Months, Days, Hours, Minutes, Seconds and Milliseconds] for auto-scrolling on the DateTime axis.
IntervalProperty
Identifies the Interval bindable property.
Declaration
public static readonly BindableProperty IntervalProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Defines the interval value for the DateTime 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 DateTime axis.
MaximumProperty
Identifies the Maximum bindable property.
Declaration
public static readonly BindableProperty MaximumProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Defines the maximum value for the DateTime axis.
MinimumProperty
Identifies the Minimum bindable property.
Declaration
public static readonly BindableProperty MinimumProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Defines the minimum value for the DateTime 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 DateTime axis.
RangePaddingProperty
Identifies the RangePadding bindable property.
Declaration
public static readonly BindableProperty RangePaddingProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
Defines the padding around the range of the DateTime axis.
Properties
ActualMaximum
Gets the actual maximum value of the DateTimeAxis.
Declaration
public DateTime ActualMaximum { get; }
Property Value
Type |
---|
System.DateTime |
Examples
<VerticalStackLayout>
<Label Text="{Binding Source={x:Reference xAxis}, Path=ActualMaximum }" />
<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>
</VerticalStackLayout>
ActualMinimum
Gets the actual minimum value of the DateTimeAxis.
Declaration
public DateTime ActualMinimum { get; }
Property Value
Type |
---|
System.DateTime |
Examples
<VerticalStackLayout>
<Label Text="{Binding Source={x:Reference xAxis}, Path=ActualMinimum }" />
<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>
</VerticalStackLayout>
AutoScrollingDeltaType
Gets or sets the date time unit of the AutoScrollingDelta value. The value can be set to years, months, days, hours, minutes, seconds and auto.
Declaration
public DateTimeIntervalType AutoScrollingDeltaType { get; set; }
Property Value
Type | Description |
---|---|
DateTimeIntervalType | It accepts DateTimeIntervalType values, and its default value is Auto, which means that the date time unit of the delta value will be automatically calculated based on the data points. |
Remarks
Note: This is only applicable for SfCartesianChart.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis AutoScrollingDeltaType="Years"/>
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
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 |
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
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis Interval="6" IntervalType="Months" />
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
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
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis IntervalType="Months"/>
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
Maximum
Gets or sets the maximum value of the time period to be displayed on the chart axis.
Declaration
public Nullable<DateTime> Maximum { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | It accepts DateTime values and the default value is null. |
Remarks
If we didn't set the maximum value, it will be calculated from the underlying collection.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis Minimum="2021/05/10" Maximum="2021/11/01"/>
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
Minimum
Gets or sets the minimum value of the time period to be displayed on the chart axis.
Declaration
public Nullable<DateTime> Minimum { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | It accepts DateTime values and the default value is null. |
Remarks
If we didn't set the minimum value, it will be calculated from the underlying collection.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis Minimum="2021/05/10" Maximum="2021/11/01"/>
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
PlotBands
Gets or sets the collection of plot bands to be added to the chart axis.
Declaration
public DateTimePlotBandCollection PlotBands { get; set; }
Property Value
Type |
---|
DateTimePlotBandCollection |
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis>
<chart:DateTimeAxis.PlotBands>
<chart:DateTimePlotBand Start="2000-01-01" Width="2" WidthType="Month"/>
</chart:DateTimeAxis.PlotBands>
</chart:DateTimeAxis>
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
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 accepts the DateTimeRangePadding value and its default value is Auto. |
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeAxis RangePadding ="Round" />
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
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 DoubleRange ApplyRangePadding(DoubleRange range, double interval)
Parameters
Type | Name | Description |
---|---|---|
DoubleRange | range | |
System.Double | interval |
Returns
Type |
---|
DoubleRange |
Overrides
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
CalculateActualRange()
Calculates the actual range of values for an axis based on the data points and axis settings.
Declaration
protected override DoubleRange CalculateActualRange()
Returns
Type |
---|
DoubleRange |
Overrides
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
CalculateVisibleRange(DoubleRange, Size)
Computes the range of values currently visible on the axis, typically after zooming or panning operations.
Declaration
protected override DoubleRange CalculateVisibleRange(DoubleRange range, Size availableSize)
Parameters
Type | Name | Description |
---|---|---|
DoubleRange | range | |
Microsoft.Maui.Graphics.Size | availableSize |
Returns
Type |
---|
DoubleRange |