Blazorise SVG Chart Annotations
Add contextual markers and regions directly to native SVG charts.
SVG chart annotations can be declared as child components or supplied through SvgChartOptions.Annotations. Use them for thresholds, release markers, operating ranges, target areas, and labeled points.
Examples
Line and label annotations
Use line annotations for thresholds and category markers, and label annotations for free-positioned notes.<SvgLineChart TItem="MonthlyService" Items="" Options=""> <SvgChartTitle Title='@("Service level")' Subtitle='@("Threshold and release annotations")' /> <SvgChartTooltip Enabled /> <SvgChartLineAnnotation YMin="80" YMax="80" Border="@( new SvgChartBorderOptions { Color = Color.Danger, Width = 2 } )" DashPattern="6 4" Label="" /> <SvgChartLineAnnotation XMin="3.5" XMax="3.5" Border="@( new SvgChartBorderOptions { Color = Color.Warning, Width = 2 } )" DashPattern="4 4" Label="" /> <SvgChartLabelAnnotation X="5" Y="91" Label="" /> <SvgChartCategoryAxis Value="@( item => item.Month )" /> <SvgChartValueAxis BeginAtZero TickCount="6" /> <SvgLineSeries Name="Uptime" Value="@( item => item.Uptime )" Color="Color.Primary" StrokeWidth="3" MarkerRadius="4" /> </SvgLineChart>
@code { private readonly SvgChartOptions options = new() { Height = 360, Legend = new() { Visible = false }, }; private readonly SvgChartAnnotationLabelOptions thresholdLabel = new() { Visible = true, Text = "Target", Position = SvgChartAnnotationLabelPosition.End, BackgroundColor = "#ffffff", Border = new() { Color = Color.Danger, Width = 1, Radius = 3 }, }; private readonly SvgChartAnnotationLabelOptions releaseLabel = new() { Visible = true, Text = "Release", Position = SvgChartAnnotationLabelPosition.Start, BackgroundColor = "#ffffff", Border = new() { Color = Color.Warning, Width = 1, Radius = 3 }, }; private readonly SvgChartAnnotationLabelOptions noteLabel = new() { Visible = true, Text = "Stabilized", Position = SvgChartAnnotationLabelPosition.Center, BackgroundColor = "#ffffff", Border = new() { Color = Color.Primary, Width = 1, Radius = 3 }, }; private readonly List<MonthlyService> services = [ new() { Month = "Jan", Uptime = 73 }, new() { Month = "Feb", Uptime = 78 }, new() { Month = "Mar", Uptime = 84 }, new() { Month = "Apr", Uptime = 82 }, new() { Month = "May", Uptime = 88 }, new() { Month = "Jun", Uptime = 91 }, new() { Month = "Jul", Uptime = 86 }, new() { Month = "Aug", Uptime = 93 }, ]; private sealed class MonthlyService { public string Month { get; set; } public double Uptime { get; set; } } }
Box, ellipse, and point annotations
Use box and ellipse annotations to mark regions, and point annotations to highlight a specific value.<SvgScatterChart TItem="StoreSample" Items="" Options=""> <SvgChartTitle Title='@("Store performance")' Subtitle='@("Region and point annotations")' /> <SvgChartTooltip Enabled /> <SvgChartEllipseAnnotation XMin="20" XMax="40" YMin="60" YMax="90" BackgroundColor="Color.Success" Border="@( new SvgChartBorderOptions { Color = Color.Success, Width = 1 } )" Opacity="0.12" Label="" /> <SvgChartPointAnnotation X="33" Y="74" Radius="6" BackgroundColor="Color.Warning" Border="@( new SvgChartBorderOptions { Color = Color.Danger, Width = 2 } )" Label="" /> <SvgChartValueAxis BeginAtZero TickCount="6" /> <SvgScatterSeries Name="Stores" XValue="@( item => item.Traffic )" YValue="@( item => item.Sales )" Color="Color.Primary" MarkerRadius="5" /> </SvgScatterChart>
@code { private readonly SvgChartOptions options = new() { Height = 360, XAxis = new() { GridLines = new() { Visible = true }, }, YAxis = new() { BeginAtZero = true, TickCount = 6, }, Annotations = [ new SvgChartBoxAnnotationOptions { XMin = 10, XMax = 20, YMin = 40, YMax = 65, BackgroundColor = Color.Info, Opacity = 0.1, Label = new() { Visible = true, Text = "Watch", Position = SvgChartAnnotationLabelPosition.Start, BackgroundColor = "#ffffff", }, }, ], }; private readonly SvgChartAnnotationLabelOptions targetLabel = new() { Visible = true, Text = "Target area", Position = SvgChartAnnotationLabelPosition.Start, BackgroundColor = "#ffffff", Border = new() { Color = Color.Success, Width = 1, Radius = 3 }, }; private readonly SvgChartAnnotationLabelOptions pointLabel = new() { Visible = true, Text = "Selected store", Position = SvgChartAnnotationLabelPosition.End, BackgroundColor = "#ffffff", Border = new() { Color = Color.Warning, Width = 1, Radius = 3 }, }; private readonly List<StoreSample> stores = [ new() { Traffic = 8, Sales = 42 }, new() { Traffic = 13, Sales = 48 }, new() { Traffic = 18, Sales = 51 }, new() { Traffic = 22, Sales = 64 }, new() { Traffic = 27, Sales = 62 }, new() { Traffic = 33, Sales = 74 }, new() { Traffic = 38, Sales = 83 }, new() { Traffic = 45, Sales = 88 }, ]; private sealed class StoreSample { public double Traffic { get; set; } public double Sales { get; set; } } }
Options annotations
Configure annotations throughSvgChartOptions.Annotations when chart options are created in C#.
<SvgLineChart TItem="DeploymentSample" Items="" Options=""> <SvgChartTitle Title='@("Deployment health")' Subtitle='@("Annotations configured from chart options")' /> <SvgChartTooltip Enabled /> <SvgChartCategoryAxis Value="@( item => item.Step )" /> <SvgChartValueAxis BeginAtZero TickCount="6" /> <SvgLineSeries Name="Health" Value="@( item => item.Score )" Color="Color.Primary" StrokeWidth="3" MarkerRadius="4" /> </SvgLineChart>
@code { private readonly SvgChartOptions options = new() { Height = 360, Legend = new() { Visible = false }, Annotations = [ new SvgChartBoxAnnotationOptions { XMin = 2.5, XMax = 4.5, YMin = 0, YMax = 100, BackgroundColor = Color.Warning, Opacity = 0.12, Label = new() { Visible = true, Text = "Deploy", Position = SvgChartAnnotationLabelPosition.Start, BackgroundColor = "#ffffff", }, }, new SvgChartLineAnnotationOptions { YMin = 80, YMax = 80, Border = new() { Color = Color.Success, Width = 2 }, DashPattern = "6 4", Label = new() { Visible = true, Text = "Target", Position = SvgChartAnnotationLabelPosition.End, BackgroundColor = "#ffffff", Border = new() { Color = Color.Success, Width = 1, Radius = 3 }, }, }, new SvgChartPointAnnotationOptions { X = 4, Y = 88, Radius = 6, BackgroundColor = Color.Primary, Border = new() { Color = Color.Light, Width = 2 }, Label = new() { Visible = true, Text = "Recovered", Position = SvgChartAnnotationLabelPosition.End, BackgroundColor = "#ffffff", }, }, ], }; private readonly List<DeploymentSample> samples = [ new() { Step = "Build", Score = 86 }, new() { Step = "Test", Score = 84 }, new() { Step = "Canary", Score = 63 }, new() { Step = "Ramp", Score = 72 }, new() { Step = "Stable", Score = 88 }, new() { Step = "Observe", Score = 91 }, ]; private sealed class DeploymentSample { public string Step { get; set; } public double Score { get; set; } } }
API
Parameters
SvgChartLineAnnotation
| Parameter | Description | Type | Default |
|---|---|---|---|
Border |
Defines the annotation line border options. |
SvgChartBorderOptions | null |
DashPattern |
Defines the annotation line dash pattern. |
string | |
Label |
Defines annotation label options. |
SvgChartAnnotationLabelOptions | null |
Name |
Defines the annotation name. |
string | |
Opacity |
Defines the annotation opacity. |
double | 1 |
Order |
Defines the annotation rendering order among line annotations. Lower values are rendered first, behind higher values. |
int? | null |
ValueAxisId |
Defines the value axis identifier used by this annotation. |
string | |
Visible |
Defines whether the annotation is visible. |
bool | true |
XMax |
Defines the annotation end X value. For category charts, this is the category index where |
double? | null |
XMin |
Defines the annotation start X value. For category charts, this is the category index where |
double? | null |
YMax |
Defines the annotation end Y value. |
double? | null |
YMin |
Defines the annotation start Y value. |
double? | null |
SvgChartBoxAnnotation
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Defines the annotation background color. |
Color | null |
Border |
Defines the annotation border options. |
SvgChartBorderOptions | null |
Label |
Defines annotation label options. |
SvgChartAnnotationLabelOptions | null |
Name |
Defines the annotation name. |
string | |
Opacity |
Defines the annotation opacity. |
double | 0.16 |
Order |
Defines the annotation rendering order among box annotations. Lower values are rendered first, behind higher values. |
int? | null |
ValueAxisId |
Defines the value axis identifier used by this annotation. |
string | |
Visible |
Defines whether the annotation is visible. |
bool | true |
XMax |
Defines the annotation end X value. For category charts, this is the category index where |
double? | null |
XMin |
Defines the annotation start X value. For category charts, this is the category index where |
double? | null |
YMax |
Defines the annotation end Y value. |
double? | null |
YMin |
Defines the annotation start Y value. |
double? | null |
SvgChartLabelAnnotation
| Parameter | Description | Type | Default |
|---|---|---|---|
Label |
Defines annotation label options. |
SvgChartAnnotationLabelOptions | null |
Name |
Defines the annotation name. |
string | |
Order |
Defines the annotation rendering order among label annotations. Lower values are rendered first, behind higher values. |
int? | null |
ValueAxisId |
Defines the value axis identifier used by this annotation. |
string | |
Visible |
Defines whether the annotation is visible. |
bool | true |
X |
Defines the annotation X value. For category charts, this is the category index. |
double? | null |
Y |
Defines the annotation Y value. |
double? | null |
SvgChartEllipseAnnotation
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Defines the annotation background color. |
Color | null |
Border |
Defines the annotation border options. |
SvgChartBorderOptions | null |
Label |
Defines annotation label options. |
SvgChartAnnotationLabelOptions | null |
Name |
Defines the annotation name. |
string | |
Opacity |
Defines the annotation opacity. |
double | 0.16 |
Order |
Defines the annotation rendering order among ellipse annotations. Lower values are rendered first, behind higher values. |
int? | null |
ValueAxisId |
Defines the value axis identifier used by this annotation. |
string | |
Visible |
Defines whether the annotation is visible. |
bool | true |
XMax |
Defines the annotation end X value. For category charts, this is the category index where |
double? | null |
XMin |
Defines the annotation start X value. For category charts, this is the category index where |
double? | null |
YMax |
Defines the annotation end Y value. |
double? | null |
YMin |
Defines the annotation start Y value. |
double? | null |
SvgChartPointAnnotation
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Defines the annotation background color. |
Color | null |
Border |
Defines the annotation border options. |
SvgChartBorderOptions | null |
Label |
Defines annotation label options. |
SvgChartAnnotationLabelOptions | null |
Name |
Defines the annotation name. |
string | |
Opacity |
Defines the annotation opacity. |
double | 1 |
Order |
Defines the annotation rendering order among point annotations. Lower values are rendered first, behind higher values. |
int? | null |
Radius |
Defines the annotation point radius. |
double | 5 |
ValueAxisId |
Defines the value axis identifier used by this annotation. |
string | |
Visible |
Defines whether the annotation is visible. |
bool | true |
X |
Defines the annotation X value. For category charts, this is the category index. |
double? | null |
Y |
Defines the annotation Y value. |
double? | null |
SvgChartAnnotationOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
Label |
Defines annotation label options. |
SvgChartAnnotationLabelOptions | null |
Name |
Defines the annotation name. |
string | |
Order |
Defines the annotation rendering order among annotations of the same type. Lower values are rendered first, behind higher values. |
int? | null |
ValueAxisId |
Defines the value axis identifier used by this annotation. |
string | |
Visible |
Defines whether the annotation is visible. |
bool | true |
SvgChartLineAnnotationOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
Border |
Defines the annotation line border options. |
SvgChartBorderOptions | new()
{
Width = 2,
} |
DashPattern |
Defines the annotation line dash pattern. |
string | |
Opacity |
Defines the annotation opacity. |
double | 1 |
XMax |
Defines the annotation end X value. For category charts, this is the category index where |
double? | null |
XMin |
Defines the annotation start X value. For category charts, this is the category index where |
double? | null |
YMax |
Defines the annotation end Y value. |
double? | null |
YMin |
Defines the annotation start Y value. |
double? | null |
SvgChartBoxAnnotationOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Defines the annotation background color. |
Color | null |
Border |
Defines the annotation border options. |
SvgChartBorderOptions | new() |
Opacity |
Defines the annotation opacity. |
double | 0.16 |
XMax |
Defines the annotation end X value. For category charts, this is the category index where |
double? | null |
XMin |
Defines the annotation start X value. For category charts, this is the category index where |
double? | null |
YMax |
Defines the annotation end Y value. |
double? | null |
YMin |
Defines the annotation start Y value. |
double? | null |
SvgChartLabelAnnotationOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
X |
Defines the annotation X value. For category charts, this is the category index. |
double? | null |
Y |
Defines the annotation Y value. |
double? | null |
SvgChartEllipseAnnotationOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Defines the annotation background color. |
Color | null |
Border |
Defines the annotation border options. |
SvgChartBorderOptions | new()
{
Width = 1,
} |
Opacity |
Defines the annotation opacity. |
double | 0.16 |
XMax |
Defines the annotation end X value. For category charts, this is the category index where |
double? | null |
XMin |
Defines the annotation start X value. For category charts, this is the category index where |
double? | null |
YMax |
Defines the annotation end Y value. |
double? | null |
YMin |
Defines the annotation start Y value. |
double? | null |
SvgChartPointAnnotationOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Defines the annotation background color. |
Color | null |
Border |
Defines the annotation border options. |
SvgChartBorderOptions | new()
{
Width = 1,
} |
Opacity |
Defines the annotation opacity. |
double | 1 |
Radius |
Defines the annotation point radius. |
double | 5 |
X |
Defines the annotation X value. For category charts, this is the category index. |
double? | null |
Y |
Defines the annotation Y value. |
double? | null |
SvgChartAnnotationLabelOptions
| Parameter | Description | Type | Default |
|---|---|---|---|
BackgroundColor |
Defines the annotation label background color. |
Color | null |
Border |
Defines the annotation label border options. |
SvgChartBorderOptions | new()
{
Radius = 3,
} |
Font |
Defines the annotation label font options. |
SvgChartFontOptions | new()
{
Size = 11,
Weight = "600",
} |
Offset |
Defines the annotation label offset from its anchor. |
double | 8 |
Padding |
Defines the annotation label padding. |
SvgChartSpacing | new()
{
Top = 3,
End = 6,
Bottom = 3,
Start = 6,
} |
Position |
Defines the annotation label position. Possible values: |
SvgChartAnnotationLabelPosition | SvgChartAnnotationLabelPosition.Center |
Text |
Defines the annotation label text. |
string | |
Visible |
Defines whether the annotation label is visible. |
bool | false |
Methods
SvgChartLineAnnotation
| Method | Description | Return | Parameters |
|---|---|---|---|
Render |
Renders the plugin SVG content into the chart. | void | SvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence |
SvgChartBoxAnnotation
| Method | Description | Return | Parameters |
|---|---|---|---|
Render |
Renders the plugin SVG content into the chart. | void | SvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence |
SvgChartLabelAnnotation
| Method | Description | Return | Parameters |
|---|---|---|---|
Render |
Renders the plugin SVG content into the chart. | void | SvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence |
SvgChartEllipseAnnotation
| Method | Description | Return | Parameters |
|---|---|---|---|
Render |
Renders the plugin SVG content into the chart. | void | SvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence |
SvgChartPointAnnotation
| Method | Description | Return | Parameters |
|---|---|---|---|
Render |
Renders the plugin SVG content into the chart. | void | SvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence |