menu

MAUI

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

    Show / Hide Table of Contents

    Class ShapeAnnotation

    ShapeAnnotation allows you to add annotations in the form of shapes such as rectangles, ellipses, lines, horizontal lines, and vertical lines at specific areas of interest within the chart area.

    Inheritance
    System.Object
    ChartAnnotation
    ShapeAnnotation
    EllipseAnnotation
    LineAnnotation
    RectangleAnnotation
    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 abstract class ShapeAnnotation : ChartAnnotation, IThemeElement

    Constructors

    ShapeAnnotation()

    Declaration
    public ShapeAnnotation()

    Fields

    FillProperty

    Identifies the Fill bindable property.

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

    The identifier for Fill bindable property.

    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.

    StrokeDashArrayProperty

    Identifies the StrokeDashArray bindable property.

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

    The identifier for StrokeDashArray bindable property.

    StrokeProperty

    Identifies the Stroke bindable property.

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

    The identifier for Stroke bindable property.

    StrokeWidthProperty

    Identifies the StrokeWidth bindable property.

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

    The identifier for StrokeWidth 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.

    X2Property

    Identifies the X2 bindable property.

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

    The identifier for X2 bindable property.

    Y2Property

    Identifies the Y2 bindable property.

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

    The identifier for Y2 bindable property.

    Properties

    Fill

    Gets or sets the fill color of the shape annotation.

    Declaration
    public Brush Fill { get; set; }
    Property Value
    Type Description
    Microsoft.Maui.Controls.Brush

    This property takes the Microsoft.Maui.Controls.Brush as its value.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:RectangleAnnotation X1="1" Y1="10" X2="4" Y2="20" Fill="Green"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var rectangle = new RectangleAnnotation()
        {
            X1 = 1,
            Y1 = 10,
            X2 = 4,
            Y2 = 20,
            Fill = Colors.Green,
        };
    
        chart.Annotations.Add(rectangle);

    LabelStyle

    Get or set the value to customize the appearance of shape 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:HorizontalLineAnnotation X1="1" Y1="10" X2="4" Y2="20">
              <chart:HorizontalLineAnnotation.LabelStyle>
                <chart:ChartAnnotationLabelStyle  HorizontalTextAlignment="Start" VerticalTextAlignment="Start"/>
              </chart:HorizontalLineAnnotation.LabelStyle>
             </chart:HorizontalLineAnnotation>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var horizontalAnnotation = new HorizontalLineAnnotation()
        {
            X1 = 1,
            Y1 = 10,
            X2 = 4,
            Y2 = 20,
        };
    
       horizontalAnnotation.LabelStyle = new ChartAnnotationLabelStyle()
       {
          HorizontalTextAlignment = ChartLabelAlignment.Start,
          VerticalTextAlignment = ChartLabelAlignment.Start,
       };
    
      chart.Annotations.Add(horizontalAnnotation);

    Stroke

    Gets or sets the stroke for the annotation.

    Declaration
    public Brush Stroke { get; set; }
    Property Value
    Type Description
    Microsoft.Maui.Controls.Brush

    This property takes the Microsoft.Maui.Controls.Brush as its value.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:VerticalLineAnnotation X1="1" Y1="10" Stroke="Red"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var vertical = new VerticalLineAnnotation()
        {
            X1 = 1,
            Y1 = 10,
            Stroke = Colors.Red,
        };
    
        chart.Annotations.Add(vertical);

    StrokeDashArray

    Gets or sets a value to customize the appearance of the annotation border.

    Declaration
    public DoubleCollection StrokeDashArray { get; set; }
    Property Value
    Type Description
    Microsoft.Maui.Controls.DoubleCollection

    This property takes the Microsoft.Maui.Controls.DoubleCollection as its value and its default value is null

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:VerticalLineAnnotation X1="1" Y1="10" StrokeDashArray="5,3"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var vertical = new VerticalLineAnnotation()
        {
            X1 = 1,
            Y1 = 10,
            StrokeDashArray = new [] {5,3},
        };
    
        chart.Annotations.Add(vertical);

    StrokeWidth

    Gets or sets a value that indicates the width of the annotations stroke.

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

    This property takes the double as its value and its default value is 1

    Remarks

    The value needs to be greater than zero.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:VerticalLineAnnotation X1="1" Y1="10" StrokeWidth="5"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var vertical = new VerticalLineAnnotation()
        {
            X1 = 1,
            Y1 = 10,
            StrokeWidth = 5,
        };
    
        chart.Annotations.Add(vertical);

    Text

    Gets or sets the string value that represents 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:HorizontalLineAnnotation Y1="10" Text="Text"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var horizontalAnnotation = new HorizontalLineAnnotation()
        {
            Y1 = 10,
            Text = "Text",
        };
    
        chart.Annotations.Add(horizontalAnnotation);

    X2

    Gets or sets the DateTime or double value that represents the x2 position of the annotation.

    Declaration
    public object X2 { get; set; }
    Property Value
    Type Description
    System.Object

    This property takes the object as its value and its default value is null.

    Examples
    • Xaml
    • C#
    <chart:SfCartesianChart.Annotations>
      <chart:RectangleAnnotation X1="3" Y1="20" X2="4" Y2="40">
      </chart:RectangleAnnotation>
    </chart:SfCartesianChart.Annotations>  
     SfCartesianChart chart = new SfCartesianChart();
     var rectangle = new RectangleAnnotation()
     {
       X1 = 3,
       Y1 = 20,
       X2 = 4,
       Y2 = 40,
     };
    
    chart.Annotations.Add(rectangle);

    Y2

    Gets or sets the double value that represents the y2 position of the annotation.

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

    This property takes the double as its value and its default value is double.NaN.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:LineAnnotation X1="1" Y1="10" X2="4" Y2="20"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var line = new LineAnnotation()
        {
            X1 = 1,
            Y1 = 10,
            X2 = 4,
            Y2 = 20,   
        };
    
        chart.Annotations.Add(line);

    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