menu

MAUI Toolkit

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

    Show / Hide Table of Contents

    Class LineAnnotation

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

    Inheritance
    System.Object
    ChartAnnotation
    ShapeAnnotation
    LineAnnotation
    HorizontalLineAnnotation
    VerticalLineAnnotation
    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
    ShapeAnnotation.Fill
    ShapeAnnotation.FillProperty
    ShapeAnnotation.LabelStyle
    ShapeAnnotation.LabelStyleProperty
    ShapeAnnotation.Stroke
    ShapeAnnotation.StrokeDashArray
    ShapeAnnotation.StrokeDashArrayProperty
    ShapeAnnotation.StrokeProperty
    ShapeAnnotation.StrokeWidth
    ShapeAnnotation.StrokeWidthProperty
    ShapeAnnotation.Text
    ShapeAnnotation.TextProperty
    ShapeAnnotation.X2
    ShapeAnnotation.X2Property
    ShapeAnnotation.Y2
    ShapeAnnotation.Y2Property
    Namespace: Syncfusion.Maui.Toolkit.Charts
    Assembly: Syncfusion.Maui.Toolkit.dll
    Syntax
    public class LineAnnotation : ShapeAnnotation, IThemeElement
    Remarks

    LineAnnotation is used to draw a line across the chart area.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart.Annotations>
      <chart:LineAnnotation X1="1" Y1="10" X2="4" Y2="20" Text="Line" CoordinateUnit="Axis">
      </chart:LineAnnotation>
    </chart:SfCartesianChart.Annotations>  
     SfCartesianChart chart = new SfCartesianChart();
     var line = new LineAnnotation()
     {
       X1 = 1,
       Y1 = 10,
       X2 = 4,
       Y2 = 20,
       Text = "Line",
       CoordinateUnit= ChartCoordinateUnit.Axis,
     };
    
    chart.Annotations.Add(line);

    Constructors

    LineAnnotation()

    Initializes a new instance of the LineAnnotation.

    Declaration
    public LineAnnotation()

    Fields

    LineCapProperty

    Identifies the LineCap bindable property.

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

    The identifier for the LineCap bindable property determines the style of the line cap for the ChartAnnotation.

    Properties

    LineCap

    Represents the type of cap for line annotation. Gets or sets the line cap value for the line annotation.

    Declaration
    public ChartLineCap LineCap { get; set; }
    Property Value
    Type Description
    ChartLineCap

    This property takes the ChartLineCap as its value and its default value is None.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:LineAnnotation X1="0" Y1="10" X2="4" Y2="50" LineCap="Arrow"/>
        </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,
      };
    
      chart.Annotations.Add(line);

    Methods

    Draw(ICanvas, RectF)

    Draws the annotation of the chart.

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