menu

MAUI Toolkit

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

    Show / Hide Table of Contents

    Class HorizontalLineAnnotation

    This class is used to add a horizontal 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
    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
    LineAnnotation.LineCap
    LineAnnotation.LineCapProperty
    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 HorizontalLineAnnotation : LineAnnotation, IThemeElement
    Remarks

    HorizontalLineAnnotation is used to draw a horizontal line across the chart area.

    Examples
    • MainPage.xaml
    • MainPage.xaml.cs
    <chart:SfCartesianChart.Annotations>
      <chart:HorizontalLineAnnotation Y1="10" Text="Horizontal" ShowAxisLabel="True">
      </chart:HorizontalLineAnnotation>
    </chart:SfCartesianChart.Annotations>  
     SfCartesianChart chart = new SfCartesianChart();
     var horizontal = new HorizontalLineAnnotation()
     {
       Y1 = 10,
       Text = "Horizontal",
       ShowAxisLabel= true,
     };
    
    chart.Annotations.Add(horizontal);

    Constructors

    HorizontalLineAnnotation()

    Initializes a new instance of the HorizontalLineAnnotation.

    Declaration
    public HorizontalLineAnnotation()

    Fields

    AxisLabelStyleProperty

    Identifies the AxisLabelStyle bindable property.

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

    The AxisLabelStyle property allows customization of the axis label in the HorizontalLineAnnotation.

    ShowAxisLabelProperty

    Identifies the ShowAxisLabel bindable property.

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

    The ShowAxisLabel property determines whether the axis label is visible for the HorizontalLineAnnotation.

    Properties

    AxisLabelStyle

    Gets or sets the customized style for the annotation axis label.

    Declaration
    public ChartLabelStyle AxisLabelStyle { get; set; }
    Property Value
    Type Description
    ChartLabelStyle

    This property takes the ChartLabelStyle as its value.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:HorizontalLineAnnotation Y1="10" >
              <chart:HorizontalLineAnnotation.AxisLabelStyle>
                <chart:ChartLabelStyle Background="Yellow"/>
              </chart:HorizontalLineAnnotation.AxisLabelStyle>
             </chart:HorizontalLineAnnotation>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
        SfCartesianChart chart = new SfCartesianChart();     
    
        // Eliminated for simplicity
        var horizontal = new HorizontalLineAnnotation()
        {
            Y1 = 10,
        };
    
     horizontal.AxisLabelStyle = new ChartLabelStyle()
     {
        Background = Colors.Yellow,
     };
    
    chart.Annotations.Add(horizontal);

    ShowAxisLabel

    Gets or sets a value indicating whether to enable or disable the display of the annotation label on the axis.

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

    This property takes the bool as its value and its default value is false.

    Examples
    • Xaml
    • C#
        <chart:SfCartesianChart>
    
        <!-- ... Eliminated for simplicity-->
        <chart:SfCartesianChart.Annotations>
             <chart:HorizontalLineAnnotation Y1="10" ShowAxisLabel="True"/>
        </chart:SfCartesianChart.Annotations>  
    
        </chart:SfCartesianChart>
       SfCartesianChart chart = new SfCartesianChart();     
    
       // Eliminated for simplicity
       var horizontal = new HorizontalLineAnnotation()
       {
           Y1 = 10,
           ShowAxisLabel = true,
       };
    
       chart.Annotations.Add(horizontal);

    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
    LineAnnotation.Draw(ICanvas, RectF)
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved