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
Inherited Members
Namespace: Syncfusion.Maui.Toolkit.Charts
Assembly: Syncfusion.Maui.Toolkit.dll
Syntax
public abstract class ShapeAnnotation : ChartAnnotation, IThemeElement
Constructors
ShapeAnnotation()
Initializes a new instance of the ShapeAnnotation class.
Declaration
public ShapeAnnotation()
Fields
FillProperty
Identifies the Fill bindable property.
Declaration
public static readonly BindableProperty FillProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The Fill property sets the fill color of the ShapeAnnotation.
LabelStyleProperty
Identifies the LabelStyle bindable property.
Declaration
public static readonly BindableProperty LabelStyleProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The LabelStyle property allows customization of the appearance of the label associated with the ShapeAnnotation.
StrokeDashArrayProperty
Identifies the StrokeDashArray bindable property.
Declaration
public static readonly BindableProperty StrokeDashArrayProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The StrokeDashArray property defines the dash pattern used for the border or outline of the ShapeAnnotation.
StrokeProperty
Identifies the Stroke bindable property.
Declaration
public static readonly BindableProperty StrokeProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The Stroke property defines the brush for the border or outline of the ShapeAnnotation.
StrokeWidthProperty
Identifies the StrokeWidth bindable property.
Declaration
public static readonly BindableProperty StrokeWidthProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The StrokeWidth property sets the thickness of the border or outline of the ShapeAnnotation.
TextProperty
Identifies the Text bindable property.
Declaration
public static readonly BindableProperty TextProperty
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The Text property defines the text content displayed within the ShapeAnnotation.
X2Property
Identifies the X2 bindable property.
Declaration
public static readonly BindableProperty X2Property
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The X2 property sets the second X-coordinate for the ShapeAnnotation in the chart.
Y2Property
Identifies the Y2 bindable property.
Declaration
public static readonly BindableProperty Y2Property
Field Value
Type |
---|
Microsoft.Maui.Controls.BindableProperty |
Remarks
The Y2 property sets the second Y-coordinate for the ShapeAnnotation in the chart.
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
<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>
LabelStyle
Gets or sets 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
<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>
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
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Annotations>
<chart:VerticalLineAnnotation X1="1" Y1="10" Stroke="Red"/>
</chart:SfCartesianChart.Annotations>
</chart:SfCartesianChart>
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
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Annotations>
<chart:VerticalLineAnnotation X1="1" Y1="10" StrokeDashArray="5,3"/>
</chart:SfCartesianChart.Annotations>
</chart:SfCartesianChart>
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 |
Remarks
The value needs to be greater than zero.
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Annotations>
<chart:VerticalLineAnnotation X1="1" Y1="10" StrokeWidth="5"/>
</chart:SfCartesianChart.Annotations>
</chart:SfCartesianChart>
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 |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Annotations>
<chart:HorizontalLineAnnotation Y1="10" Text="Text"/>
</chart:SfCartesianChart.Annotations>
</chart:SfCartesianChart>
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 |
Examples
<chart:SfCartesianChart.Annotations>
<chart:RectangleAnnotation X1="3" Y1="20" X2="4" Y2="40">
</chart:RectangleAnnotation>
</chart:SfCartesianChart.Annotations>
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 |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Annotations>
<chart:LineAnnotation X1="1" Y1="10" X2="4" Y2="20"/>
</chart:SfCartesianChart.Annotations>
</chart:SfCartesianChart>
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 |