menu

MAUI Toolkit

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

    Show / Hide Table of Contents

    Class ChartAnnotation

    Serves as a base class for all types of annotations such as text, shape, and view. The annotations can be added to the chart.

    Inheritance
    System.Object
    ChartAnnotation
    ShapeAnnotation
    TextAnnotation
    ViewAnnotation
    Namespace: Syncfusion.Maui.Toolkit.Charts
    Assembly: Syncfusion.Maui.Toolkit.dll
    Syntax
    public abstract class ChartAnnotation : Element

    Constructors

    ChartAnnotation()

    Initializes a new instance of the ChartAnnotation.

    Declaration
    public ChartAnnotation()

    Fields

    CoordinateUnitProperty

    Identifies the CoordinateUnit bindable property.

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

    The CoordinateUnit property defines whether the annotation coordinates are based on axis units or pixel units.

    IsVisibleProperty

    Identifies the IsVisible bindable property.

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

    The IsVisible property determines annotation visibility in the SfCartesianChart.

    X1Property

    Identifies the X1 bindable property.

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

    The X1 property sets the X-coordinate for the annotation.

    XAxisNameProperty

    Identifies the XAxisName bindable property.

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

    The XAxisName property specifies the X-axis to which the annotation is tied.

    Y1Property

    Identifies the Y1 bindable property.

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

    The Y1 property sets the Y-coordinate for the annotation.

    YAxisNameProperty

    Identifies the YAxisName bindable property.

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

    The YAxisName property specifies the Y-axis to which the annotation is tied.

    Properties

    CoordinateUnit

    Gets or sets the property that identifies whether the annotation is positioned based on pixel or axis coordinates.

    Declaration
    public ChartCoordinateUnit CoordinateUnit { get; set; }
    Property Value
    Type Description
    ChartCoordinateUnit

    This property takes the ChartCoordinateUnit as its value. Its default value is Axis.

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

    IsVisible

    Gets or sets a value that indicates whether the annotation is visible or not.

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

    This property takes the bool as its value. Its default value is true.

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

    X1

    Gets or sets the DateTime or double that represents the x1 position of the chart annotation.

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

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

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

    XAxisName

    Get or set the value of a string that represents the name of the x-axis in the annotation.

    Declaration
    public string XAxisName { 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:LineAnnotation X1="0" Y1="10" X2="4" Y2="50" LineCap="Arrow" XAxisName="xAxis"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var lineAnnotation = new LineAnnotation()
        {
            X1 = 0,
            Y1 = 10,
            X2 = 4,
            Y2 = 50,
            LineCap = ChartLineCap.Arrow,
            XAxisName= "xAxis",
        };
    
        chart.Annotations.Add(lineAnnotation);

    Y1

    Gets or sets the double that represents the y1 position of the chart annotation.

    Declaration
    public double Y1 { 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:HorizontalLineAnnotation Y1="10"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var horizontalAnnotation = new HorizontalLineAnnotation()
        {    
            Y1 = 10,        
        };
    
        chart.Annotations.Add(horizontalAnnotation);

    YAxisName

    Get or set the value of a string that represents the name of the y-axis in the annotation.

    Declaration
    public string YAxisName { 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:LineAnnotation X1="0" Y1="10" X2="4" Y2="50" LineCap="Arrow" YAxisName="yAxis"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var line = new LineAnnotation()
        {
            X1 = 0,
            Y1 = 10,
            X2 = 4,
            Y2 = 50,
            LineCap = ChartLineCap.Arrow,
            YAxisName= "yAxis",
        };
    
        chart.Annotations.Add(line);

    Methods

    Draw(ICanvas, RectF)

    Draws the annotation of the chart.

    Declaration
    protected virtual void Draw(ICanvas canvas, RectF dirtyRect)
    Parameters
    Type Name Description
    Microsoft.Maui.Graphics.ICanvas canvas
    Microsoft.Maui.Graphics.RectF dirtyRect
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved