menu

MAUI

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

    Show / Hide Table of Contents

    Class TextAnnotation

    This class is used to add a text annotation to the SfCartesianChart. An instance of this class needs to be added to the Annotations collection.

    Inheritance
    System.Object
    ChartAnnotation
    TextAnnotation
    Inherited Members
    ChartAnnotation.CoordinateUnit
    ChartAnnotation.CoordinateUnitProperty
    ChartAnnotation.IsVisible
    ChartAnnotation.IsVisibleProperty
    ChartAnnotation.X1
    ChartAnnotation.X1Property
    ChartAnnotation.XAxisName
    ChartAnnotation.XAxisNameProperty
    ChartAnnotation.Y1
    ChartAnnotation.Y1Property
    ChartAnnotation.YAxisName
    ChartAnnotation.YAxisNameProperty
    Namespace: Syncfusion.Maui.Charts
    Assembly: Syncfusion.Maui.Charts.dll
    Syntax
    public class TextAnnotation : ChartAnnotation, IThemeElement
    Remarks

    Text annotations are used to add simple text at specific points over the chart area.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart.Annotations>
      <chart:TextAnnotation X1="3" Y1="10" Text="TextAnnotation">
      </chart:TextAnnotation>
    </chart:SfCartesianChart.Annotations>  
     SfCartesianChart chart = new SfCartesianChart();
     var text = new TextAnnotation()
     {
       X1 = 3,
       Y1 = 10,
       Text = "TextAnnotation",
     };
    
    chart.Annotations.Add(text);

    Constructors

    TextAnnotation()

    Declaration
    public TextAnnotation()

    Fields

    LabelStyleProperty

    Identifies the LabelStyle bindable property.

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

    The identifier for LabelStyle bindable property.

    TextProperty

    Identifies the Text bindable property.

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

    The identifier for Text bindable property.

    Properties

    LabelStyle

    Get or set the value to customize the appearance of annotation text.

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

    This property takes the ChartAnnotationLabelStyle as its value.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:TextAnnotation X1="3" Y1="30" Text="TextAnnotation">
              <chart:TextAnnotation.LabelStyle>
                <chart:ChartAnnotationLabelStyle HorizontalTextAlignment="Start" VerticalTextAlignment="Start"/>
              </chart:TextAnnotation.LabelStyle>
             </chart:TextAnnotation>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var textAnnotation = new TextAnnotation()
        {
            X1 = 3,
            Y1 = 30,    
            Text = "TextAnnotation",
        };
    
     textAnnotation.LabelStyle = new ChartAnnotationLabelStyle()
     {
        HorizontalTextAlignment = ChartLabelAlignment.Start,
        VerticalTextAlignment = ChartLabelAlignment.Start,
     };
    
    chart.Annotations.Add(textAnnotation);

    Text

    Gets or sets the text to be displayed on the annotation.

    Declaration
    public string Text { get; set; }
    Property Value
    Type Description
    System.String

    This property takes the string as its value and its default value is string.Empty.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:TextAnnotation X1="3" Y1="30" Text="TextAnnotation">         
             </chart:HorizontalLineAnnotation>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var text = new TextAnnotation()
        {
            X1 = 3,
            Y1 = 30,       
            Text = "TextAnnotation",
        };
    
    chart.Annotations.Add(text);

    Methods

    Draw(ICanvas, RectF)

    Declaration
    protected override void Draw(ICanvas canvas, RectF dirtyRect)
    Parameters
    Type Name Description
    Microsoft.Maui.Graphics.ICanvas canvas
    Microsoft.Maui.Graphics.RectF dirtyRect
    Overrides
    ChartAnnotation.Draw(ICanvas, RectF)

    OnBindingContextChanged()

    Declaration
    protected override void OnBindingContextChanged()

    OnParentSet()

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