Class DateTimeCategoryAxis
The DateTimeCategoryAxis is a specialized axis for plotting chronological data where the axis labels represent dates and times.
Inherited Members
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.
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeCategoryAxis Interval="1" IntervalType="Months"/>
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
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 |
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:DateTimeCategoryAxis Interval="6"/>
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
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
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:DateTimeCategoryAxis Interval="1" IntervalType="Years" />
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
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
<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>
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
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
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 |