menu

MAUI

  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ChartDataLabelSettings - MAUI API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ChartDataLabelSettings

    Represents a base class for the CartesianDataLabelSettings, and CircularDataLabelSettings classes.

    Inheritance
    System.Object
    ChartDataLabelSettings
    CartesianDataLabelSettings
    CircularDataLabelSettings
    FunnelDataLabelSettings
    PolarDataLabelSettings
    PyramidDataLabelSettings
    Namespace: Syncfusion.Maui.Charts
    Assembly: Syncfusion.Maui.Charts.dll
    Syntax
    public abstract class ChartDataLabelSettings : BindableObject
    Remarks

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

    ChartDataLabelSettings is used to customize the appearance of the data label that appears on a series.

    Constructors

    ChartDataLabelSettings()

    Initializes a new instance of the ChartDataLabelSettings class.

    Declaration
    public ChartDataLabelSettings()

    Fields

    LabelPlacementProperty

    Identifies the LabelPlacement bindable property.

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

    LabelStyleProperty

    Identifies the LabelStyle bindable property.

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

    UseSeriesPaletteProperty

    Identifies the UseSeriesPalette bindable property.

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

    Properties

    LabelPlacement

    Gets or sets a value that determines whether to place the data label on series.

    Declaration
    public DataLabelPlacement LabelPlacement { get; set; }
    Property Value
    Type Description
    DataLabelPlacement

    It accepts DataLabelPlacement values and its default value is Auto.

    Remarks

    Applies to Cartesian, Funnel, and Pyramid charts.

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

    LabelStyle

    Gets or sets a value for customizing the data labels.

    Declaration
    public ChartDataLabelStyle LabelStyle { get; set; }
    Property Value
    Type Description
    ChartDataLabelStyle

    It accepts ChartDataLabelStyle and its default value is null.

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

    UseSeriesPalette

    Gets or sets a value indicating whether the background of the data label should be filled with the series color or not.

    Declaration
    public bool UseSeriesPalette { get; set; }
    Property Value
    Type Description
    System.Boolean

    It accepts the bool value and its default value is True.

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

    Methods

    OnBindingContextChanged()

    Declaration
    protected override void OnBindingContextChanged()
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved