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.
Namespace: Syncfusion.Maui.Charts
Assembly: Syncfusion.Maui.Charts.dll
Syntax
public abstract class ChartAnnotation : Element
Constructors
ChartAnnotation()
Declaration
public ChartAnnotation()
Fields
CoordinateUnitProperty
Identifies the CoordinateUnit bindable property.
Declaration
public static readonly BindableProperty CoordinateUnitProperty
Field Value
| Type | Description |
|---|---|
| Microsoft.Maui.Controls.BindableProperty | The identifier for CoordinateUnit bindable property. |
IsVisibleProperty
Identifies the IsVisible bindable property.
Declaration
public static readonly BindableProperty IsVisibleProperty
Field Value
| Type | Description |
|---|---|
| Microsoft.Maui.Controls.BindableProperty | The identifier for IsVisible bindable property. |
X1Property
Identifies the X1 bindable property.
Declaration
public static readonly BindableProperty X1Property
Field Value
| Type | Description |
|---|---|
| Microsoft.Maui.Controls.BindableProperty | The identifier for X1 bindable property. |
XAxisNameProperty
Identifies the XAxisName bindable property.
Declaration
public static readonly BindableProperty XAxisNameProperty
Field Value
| Type | Description |
|---|---|
| Microsoft.Maui.Controls.BindableProperty | The identifier for XAxisName bindable property. |
Y1Property
Identifies the Y1 bindable property.
Declaration
public static readonly BindableProperty Y1Property
Field Value
| Type | Description |
|---|---|
| Microsoft.Maui.Controls.BindableProperty | The identifier for Y1 bindable property. |
YAxisNameProperty
Identifies the YAxisName bindable property.
Declaration
public static readonly BindableProperty YAxisNameProperty
Field Value
| Type | Description |
|---|---|
| Microsoft.Maui.Controls.BindableProperty | The identifier for YAxisName bindable property. |
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
<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>
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 |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Annotations>
<chart:VerticalLineAnnotation X1="1" IsVisible="True"/>
</chart:SfCartesianChart.Annotations>
</chart:SfCartesianChart>
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 |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Annotations>
<chart:VerticalLineAnnotation X1="1"/>
</chart:SfCartesianChart.Annotations>
</chart:SfCartesianChart>
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 |
Examples
<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>
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 |
Examples
<chart:SfCartesianChart>
<!-- ... Eliminated for simplicity-->
<chart:SfCartesianChart.Annotations>
<chart:HorizontalLineAnnotation Y1="10"/>
</chart:SfCartesianChart.Annotations>
</chart:SfCartesianChart>
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 |
Examples
<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>
Methods
Draw(ICanvas, RectF)
Declaration
protected virtual void Draw(ICanvas canvas, RectF dirtyRect)
Parameters
| Type | Name | Description |
|---|---|---|
| Microsoft.Maui.Graphics.ICanvas | canvas | |
| Microsoft.Maui.Graphics.RectF | dirtyRect |
OnTouchDown(Single, Single)
The method is called when a touch interaction begins on the ChartAnnotation.
Declaration
protected virtual void OnTouchDown(float pointX, float pointY)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | pointX | |
| System.Single | pointY |
Remarks
Use the provided points X and Y to determine the exact location of the touch.
OnTouchMove(Single, Single)
The method is called when touch movements occur over the ChartAnnotation.
Declaration
protected virtual void OnTouchMove(float pointX, float pointY)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | pointX | |
| System.Single | pointY |
Remarks
This method updates the annotation's position based on the current touch coordinates (X and Y).
OnTouchUp(Single, Single)
The method is called when the touch interaction with the ChartAnnotation ends.
Declaration
protected virtual void OnTouchUp(float pointX, float pointY)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single | pointX | |
| System.Single | pointY |
Remarks
This method finalizes the annotation's position using the last known touch coordinates (X and Y).