alexa
Syncfusion
menu Syncfusion

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class CartesianDataLabelSettings

    The CartesianDataLabelSettings class is used to customize the appearance of cartesian series data labels.

    Inheritance
    object
    ChartDataLabelSettings
    CartesianDataLabelSettings
    Inherited Members
    ChartDataLabelSettings.LabelPlacement
    ChartDataLabelSettings.LabelPlacementProperty
    ChartDataLabelSettings.LabelStyle
    ChartDataLabelSettings.LabelStyleProperty
    ChartDataLabelSettings.OnBindingContextChanged()
    ChartDataLabelSettings.UseSeriesPalette
    ChartDataLabelSettings.UseSeriesPaletteProperty
    Namespace: Syncfusion.Maui.Charts
    Assembly: Syncfusion.Maui.Charts.dll
    Syntax
    public class CartesianDataLabelSettings : ChartDataLabelSettings
    Remarks

    To customize data labels, create an instance of CartesianDataLabelSettings class, and set it to the DataLabelSettings property of a cartesian series.

    ShowDataLabels

    Data labels can be added to a chart series by enabling the ShowDataLabels option.

    • Xaml
    • C#
    <chart:SfCartesianChart>
    
       <!-- ... Eliminated for simplicity-->
       <chart:LineSeries ItemsSource ="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue"
                         ShowDataLabels="True"/>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    ViewModel viewModel = new ViewModel();
    
    // Eliminated for simplicity
    LineSeries series = new PieSeries()
    {
       ItemsSource = viewModel.Data,
       XBindingPath = "XValue",
       YBindingPath = "YValue",
       ShowDataLabels = true
    };
    
    chart.Series.Add(series);

    Customization

    To change the appearance of data labels, it offers LabelStyle options.

    Null values are invalid for LabelStyle.

    • Xaml
    • C#
    <chart:SfCartesianChart>
    
     <!-- ... Eliminated for simplicity-->
       <chart:LineSeries ItemsSource ="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue"
                        ShowDataLabels="True">
          <chart:LineSeries.CartesianDataLabelSettings>
               <chart:CartesianDataLabelSettings>
                    <chart:CartesianDataLabelSettings.LabelStyle>
                        <chart:ChartDataLabelStyle Background = "Red" FontSize="14" TextColor="Black" />
                    </chart:CartesianDataLabelSettings.LabelStyle>
                </chart:CartesianDataLabelSettings>
          </chart:LineSeries.CartesianDataLabelSettings>
       <chart:LineSeries />
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    ViewModel viewModel = new ViewModel();
    
    // Eliminated for simplicity
    LineSeries series = new LineSeries()
    {
       ItemsSource = viewModel.Data,
       XBindingPath = "XValue",
       YBindingPath = "YValue",
       ShowDataLabels = true,
    };
    
    var labelStyle = new ChartDataLabelStyle()
    { 
        Background = new SolidColorBrush(Colors.Red),
        TextColor = Colors.Black,
        FontSize = 14,
    };
    series.DataLabelSettings = new CartesianDataLabelSettings()
    {
        LabelStyle = labelStyle,
    };
    
    chart.Series.Add(series);

    Constructors

    CartesianDataLabelSettings()

    Initializes a new instance of the CartesianDataLabelSettings.

    Declaration
    public CartesianDataLabelSettings()

    Fields

    BarAlignmentProperty

    Identifies the BarAlignment bindable property.

    Declaration
    public static readonly BindableProperty BarAlignmentProperty
    Field Value
    Type
    BindableProperty

    Properties

    BarAlignment

    Gets or sets the value for a bar chart data label's alignment.

    Declaration
    public DataLabelAlignment BarAlignment { get; set; }
    Property Value
    Type Description
    DataLabelAlignment

    It accepts DataLabelAlignment values and has a default value of Top.

    Examples
    • Xaml
    • C#
    <chart:SfCartesianChart>
    
    <!-- ... Eliminated for simplicity-->
    
         <chart:ColumnSeries ItemsSource="{Binding Data}"
                           XBindingPath="XValue"
                           YBindingPath="YValue"
                           ShowDataLabels="True">
               <chart:ColumnSeries.DataLabelSettings>
                   <chart:CartesianDataLabelSettings BarAlignment="Middle" />
               </chart:ColumnSeries.DataLabelSettings>
             </chart:ColumnSeries>
    
    </chart:SfCartesianChart>
    SfCartesianChart chart = new SfCartesianChart();
    ViewModel viewModel = new ViewModel();
    
    // Eliminated for simplicity
    var dataLabelSettings = new CartesianDataLabelSettings()
    {
        BarAlignment = DataLabelAlignment.Middle
    };
    ColumnSeries series = new ColumnSeries()
    {
          ItemsSource = viewModel.Data,
          XBindingPath = "XValue",
          YBindingPath = "YValue",
          ShowDataLabels = true,
          DataLabelSettings = dataLabelSettings,
    };
    
    chart.Series.Add(series);
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved