.NET MAUI Chart Annotations
Annotations are visual elements that are used to highlight areas on the plot. They can be displayed as comments or as markers for specific values on the plot. You can use any visual element as a template for the annotation.
The Chart supports the following types of annotations:
-
CartesianGridLineAnnotation
—This annotation is visually represented by straight lines across the chart that mark specific values on the associated Cartesian axis. -
CartesianPlotBandAnnotation
—This annotation is visually represented by a band across the chart that marks a specific range on the associated Cartesian axis.
CartesianGridLineAnnotation
The CartesianGridLineAnnotation
represents a vertical or horizontal line that crosses the entire plot area and provides the following features:
-
Axis
—TheCartesianGridLineAnnotation
has to be explicitly associated with a horizontal or a vertical cartesian axis. -
Value
—The place on the associated axis where a line crosses it.
When the associated axis is numerical, the
CartesianGridLineAnnotation
expects a numeric value. When the associated axis is a Categorical Axis, theCartesianGridLineAnnotation
expects a category.
The following example shows how the CartesianGridLineAnnotation
works:
1. Create the needed business objects:
2. Create a ViewModel
:
3. Declare the RadChart
in XAML:
The following image shows how the CartesianGridLineAnnotation
looks:
CartesianPlotBandAnnotation
The CartesianPlotBandAnnotation
represents a vertical or horizontal area that crosses the entire plot area and provides the following features:
-
Axis
—TheCartesianPlotBandAnnotation
needs to be explicitly associated with a horizontal or a vertical axis. -
From
—The starting value for the plot band. -
To
—The ending value for the plot band. -
Fill
—Gets or sets the Fill.
The following example shows how the CartesianPlotBandAnnotation
works:
1. Create the needed business objects:
2. Define the ViewModel
:
3. Declare the RadChart
control in XAML:
The following image shows how the CartesianPlotBandAnnotation
looks: