menu

MAUI Toolkit

  • User Guide
  • Demos
  • Support
Class ChartAxisLabelStyle - MAUI-ToolKit API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ChartAxisLabelStyle

    Represents the chart axis's label style class.

    Inheritance
    System.Object
    ChartLabelStyle
    ChartAxisLabelStyle
    Inherited Members
    ChartLabelStyle.Background
    ChartLabelStyle.BackgroundProperty
    ChartLabelStyle.CornerRadius
    ChartLabelStyle.CornerRadiusProperty
    ChartLabelStyle.FontAttributes
    ChartLabelStyle.FontAttributesProperty
    ChartLabelStyle.FontFamily
    ChartLabelStyle.FontFamilyProperty
    ChartLabelStyle.FontSize
    ChartLabelStyle.FontSizeProperty
    ChartLabelStyle.LabelFormat
    ChartLabelStyle.LabelFormatProperty
    ChartLabelStyle.Margin
    ChartLabelStyle.MarginProperty
    ChartLabelStyle.Stroke
    ChartLabelStyle.StrokeProperty
    ChartLabelStyle.StrokeWidth
    ChartLabelStyle.StrokeWidthProperty
    ChartLabelStyle.TextColor
    ChartLabelStyle.TextColorProperty
    Namespace: Syncfusion.Maui.Toolkit.Charts
    Assembly: Syncfusion.Maui.Toolkit.dll
    Syntax
    public class ChartAxisLabelStyle : ChartLabelStyle, ITextElement, IThemeElement
    Remarks

    To customize the axis labels appearance, create an instance of the ChartAxisLabelStyle class and set to the LabelStyle property.

    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
    
        <chart:SfCartesianChart.XAxes>
            <chart:CategoryAxis>
               <chart:CategoryAxis.LabelStyle>
                   <chart:ChartAxisLabelStyle TextColor = "Red" FontSize="14"/>
               </chart:CategoryAxis.LabelStyle>
           </chart:CategoryAxis>
        </chart:SfCartesianChart.XAxes>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    
    CategoryAxis xaxis = new CategoryAxis();
    xaxis.LabelStyle = new ChartAxisLabelStyle()
    {
        TextColor = Colors.Red,
        FontSize = 14,
    };
    chart.XAxes.Add(xaxis);

    It provides more options to customize the chart axis label.

    LabelAlignment - To position the axis label, refer to this LabelAlignment property.

    LabelFormat - To customize the numeric or date-time format of the axis label, refer to this LabelFormat property.

    TextColor - To customize the text color, refer to this TextColor property.

    Background - To customize the background color, refer to this Background property.

    Stroke - To customize the stroke color, refer to this Stroke property.

    StrokeWidth - To modify the stroke width, refer to this StrokeWidth property.

    Constructors

    ChartAxisLabelStyle()

    Initializes a new instance of the ChartAxisLabelStyle.

    Declaration
    public ChartAxisLabelStyle()

    Fields

    LabelAlignmentProperty

    Identifies the LabelAlignment bindable property.

    Declaration
    public static readonly BindableProperty LabelAlignmentProperty
    Field Value
    Type
    Microsoft.Maui.Controls.BindableProperty
    Remarks

    The identifier for the LabelAlignment bindable property indicates the position of the axis label.

    MaxWidthProperty

    Identifies the MaxWidth bindable property.

    Declaration
    public static readonly BindableProperty MaxWidthProperty
    Field Value
    Type
    Microsoft.Maui.Controls.BindableProperty
    Remarks

    The identifier for the MaxWidth bindable property represents the maximum width value for wrapped axis labels.

    WrappedLabelAlignmentProperty

    Identifies the WrappedLabelAlignment bindable property.

    Declaration
    public static readonly BindableProperty WrappedLabelAlignmentProperty
    Field Value
    Type
    Microsoft.Maui.Controls.BindableProperty
    Remarks

    The identifier for the WrappedLabelAlignment bindable property is used to align wrapped axis labels based on the label's rectangle.

    Properties

    LabelAlignment

    Gets or sets a value that indicates the position of the axis label.

    Declaration
    public ChartAxisLabelAlignment LabelAlignment { get; set; }
    Property Value
    Type Description
    ChartAxisLabelAlignment

    It accepts ChartAxisLabelAlignment values and the default value is Center.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
     <chart:SfCartesianChart.XAxes>
      <chart:CategoryAxis>
        <chart:CategoryAxis.LabelStyle>
         <chart:ChartAxisLabelStyle LabelAlignment="Center"/>
           </chart:CategoryAxis.LabelStyle>
      </chart:CategoryAxis>
     </chart:SfCartesianChart.XAxes>
    
     <chart:SfCartesianChart.YAxes>
      <chart:NumericalAxis>
       <chart:NumericalAxis.LabelStyle>
              <chart:ChartAxisLabelStyleLabelAlignment="Center"/>
          </chart:NumericalAxi.LabelStyle>
     </chart:NumericalAxis>
    </chart:SfCartesianChart.YAxes>
    </chart:SfCartesianChart>
      SfCartesianChart chart = new SfCartesianChart();
      CategoryAxis primaryAxis = new CategoryAxis();
      ChartAxisLabelStyle chartAxisLabelStyle = new ChartAxisLabelStyle()
      {
           LabelAlignment = ChartAxisLabelAlignment.Center,
      };
      primaryAxis.LabelStyle = chartAxisLabelStyle;
      chart.XAxes.Add(primaryAxis);
      NumericalAxis secondaryAxis = new NumericalAxis();
      ChartAxisLabelStyle secondaryAxisStyle = new ChartAxisLabelStyle()
      {
          LabelAlignment = ChartAxisLabelAlignment.Center,
      };
      secondaryAxis.LabelStyle = secondaryAxisStyle;
      chart.YAxes.Add(secondaryAxis);

    MaxWidth

    Gets or sets the maximum width value for wrapped axis labels.

    Declaration
    public double MaxWidth { get; set; }
    Property Value
    Type Description
    System.Double

    It accepts double values and its default value is double.NaN.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
     <chart:SfCartesianChart.XAxes>
      <chart:CategoryAxis LabelsIntersectAction="Wrap">
        <chart:CategoryAxis.LabelStyle>
         <chart:ChartAxisLabelStyle MaxWidth="30"/>
           </chart:CategoryAxis.LabelStyle>
      </chart:CategoryAxis>
     </chart:SfCartesianChart.XAxes>
    
     <chart:SfCartesianChart.YAxes>
      <chart:NumericalAxis LabelsIntersectAction="Wrap">
       <chart:NumericalAxis.LabelStyle>
              <chart:ChartAxisLabelStyle MaxWidth="30"/>
          </chart:NumericalAxi.LabelStyle>
     </chart:NumericalAxis>
    </chart:SfCartesianChart.YAxes>
    </chart:SfCartesianChart>
      SfCartesianChart chart = new SfCartesianChart();
      CategoryAxis primaryAxis = new CategoryAxis()
      {
           LabelsIntersectAction = AxisLabelsIntersectAction.Wrap,
      };
      ChartAxisLabelStyle chartAxisLabelStyle = new ChartAxisLabelStyle()
      {
           MaxWidth = 30,
      };
      primaryAxis.LabelStyle = chartAxisLabelStyle;
      chart.XAxes.Add(primaryAxis);
      NumericalAxis secondaryAxis = new NumericalAxis()
      {
          LabelsIntersectAction = AxisLabelsIntersectAction.Wrap,
      };
      ChartAxisLabelStyle secondaryAxisStyle = new ChartAxisLabelStyle()
      {
           MaxWidth = 30,
      };
      secondaryAxis.LabelStyle = secondaryAxisStyle;
      chart.YAxes.Add(secondaryAxis);

    WrappedLabelAlignment

    Gets or sets the value to align wrapped axis labels based upon the labels rect.

    Declaration
    public ChartAxisLabelAlignment WrappedLabelAlignment { get; set; }
    Property Value
    Type Description
    ChartAxisLabelAlignment

    It accepts ChartAxisLabelAlignment values and the default value is Start.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart>
     <chart:SfCartesianChart.XAxes>
      <chart:CategoryAxis LabelsIntersectAction="Wrap">
        <chart:CategoryAxis.LabelStyle>
         <chart:ChartAxisLabelStyle WrappedLabelAlignment="Center" MaxWidth="30"/>
           </chart:CategoryAxis.LabelStyle>
      </chart:CategoryAxis>
     </chart:SfCartesianChart.XAxes>
    
     <chart:SfCartesianChart.YAxes>
      <chart:NumericalAxis LabelsIntersectAction="Wrap">
       <chart:NumericalAxis.LabelStyle>
              <chart:ChartAxisLabelStyle WrappedLabelAlignment="Center" MaxWidth="30"/>
          </chart:NumericalAxi.LabelStyle>
     </chart:NumericalAxis>
    </chart:SfCartesianChart.YAxes>
    </chart:SfCartesianChart>
      SfCartesianChart chart = new SfCartesianChart();
      CategoryAxis primaryAxis = new CategoryAxis()
      {
           LabelsIntersectAction = AxisLabelsIntersectAction.Wrap,
      };
      ChartAxisLabelStyle chartAxisLabelStyle = new ChartAxisLabelStyle()
      {
           MaxWidth = 30,
           WrappedLabelAlignment = ChartAxisLabelAlignment.Center,
       };
    
       primaryAxis.LabelStyle = chartAxisLabelStyle;
       chart.XAxes.Add(primaryAxis);
       NumericalAxis secondaryAxis = new NumericalAxis()
       {
           LabelsIntersectAction = AxisLabelsIntersectAction.Wrap,
       };
       ChartAxisLabelStyle secondaryAxisStyle = new ChartAxisLabelStyle()
       {
            MaxWidth = 30,
            WrappedLabelAlignment = ChartAxisLabelAlignment.Center,
       };
       secondaryAxis.LabelStyle = secondaryAxisStyle;
       chart.YAxes.Add(secondaryAxis);
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved