menu

MAUI Toolkit

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

    Show / Hide Table of Contents

    Class ChartDataLabelSettings

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

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

    Data labels can be added to a chart or 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
    Remarks

    The identifier for the LabelPlacement bindable property determines the placement of the data labels.

    LabelStyleProperty

    Identifies the LabelStyle bindable property.

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

    The identifier for the LabelStyle bindable property determines the style of the data labels.

    UseSeriesPaletteProperty

    Identifies the UseSeriesPalette bindable property.

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

    The identifier for the UseSeriesPalette bindable property determines whether the data labels use the series palette colors.

    Properties

    LabelPlacement

    Determines the placement of data labels relative to the data points in a chart, such as inside, outside, or at the center of the data point.

    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);
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved