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.Charts
Assembly: Syncfusion.Maui.Charts.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 |
IntervalProperty
Identifies the Interval bindable property.
Declaration
public static readonly BindableProperty IntervalProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
LabelPlacementProperty
Identifies the LabelPlacement bindable property.
Declaration
public static readonly BindableProperty LabelPlacementProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
PlotBandsProperty
Identifies the PlotBands bindable property.
Declaration
public static readonly BindableProperty PlotBandsProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
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 | Its default is |
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)
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)
Declaration
protected override double CalculateActualInterval(DoubleRange range, Size availableSize)
Parameters
Type | Name | Description |
---|---|---|
DoubleRange | range | |
Microsoft.Maui.Graphics.Size | availableSize |
Returns
Type |
---|
System.Double |