Class CategoryAxis
The CategoryAxis is an indexed based axis that plots values based on the index of the data point collection. It displays string values in axis labels.
Inherited Members
Namespace: Syncfusion.Maui.Toolkit.Charts
Assembly: Syncfusion.Maui.Toolkit.dll
Syntax
public class CategoryAxis : ChartAxis, IThemeElement
Remarks
Category axis supports only for the X(horizontal) axis.
To render an axis, add the category axis instance to the chart’s XAxes collection as shown in the following code sample.
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:CategoryAxis/>
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
The CategoryAxis supports the following features. Refer to the corresponding APIs, for more details and example codes.
Title - To render the title, refer to this Title property.
Grid Lines - To show and customize the grid lines, refer these ShowMajorGridLines, and MajorGridLineStyle properties.
Axis Line - To customize the axis line using the AxisLineStyle property.
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.
Label Placement - To place the axis labels in between or on the tick lines, refer to this LabelPlacement property.
Interval - To define the interval between the axis labels, refer to this Interval property.
Constructors
CategoryAxis()
Declaration
public CategoryAxis()
Fields
ArrangeByIndexProperty
Identifies the ArrangeByIndex bindable property.
Declaration
public static readonly BindableProperty ArrangeByIndexProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The ArrangeByIndex property specifies whether axis labels are arranged based on their index or by value.
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 axis.
LabelPlacementProperty
Identifies the LabelPlacement bindable property.
Declaration
public static readonly BindableProperty LabelPlacementProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The LabelPlacement property determines whether axis labels are placed on the ticks or between them.
PlotBandsProperty
Identifies the PlotBands bindable property.
Declaration
public static readonly BindableProperty PlotBandsProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The PlotBands property represents a collection of plot bands used to highlight ranges of values on the chart.
Properties
ArrangeByIndex
Gets or sets a value that determines whether to arrange the axis labels by index or by value.
Declaration
public bool ArrangeByIndex { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | This property takes the |
Remarks
True - Used to arrange the axis labels by index.
False - Used to arrange the axis labels by value.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:CategoryAxis ArrangeByIndex="False" />
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
Interval
Gets or sets a value that can be used to customize the interval between the axis 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.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:CategoryAxis Interval="2" />
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
LabelPlacement
Gets or sets a value that determines whether to place the axis label in between or on the tick lines.
Declaration
public LabelPlacement LabelPlacement { get; set; }
Property Value
Type | Description |
---|---|
LabelPlacement | It accepts the LabelPlacement values and the default value is |
Remarks
BetweenTicks - Used to place the axis label between the ticks.
OnTicks - Used to place the axis label with the tick as the center.
Note: This is only applicable for SfCartesianChart.
Examples
<chart:SfCartesianChart>
<chart:SfCartesianChart.XAxes>
<chart:CategoryAxis LabelPlacement="BetweenTicks" />
</chart:SfCartesianChart.XAxes>
</chart:SfCartesianChart>
PlotBands
Gets or sets the collection of plot bands to be added to the chart axis.
Declaration
public NumericalPlotBandCollection PlotBands { get; set; }
Property Value
Type |
---|
NumericalPlotBandCollection |
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 |