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.
1 series, 8 categories.Service levelThreshold and release annotations020406080100JanFebMarAprMayJunJulAugTargetReleaseStabilized
<SvgLineChart TItem="MonthlyService"
              Items="@services"
              Options="@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="@thresholdLabel" />
    <SvgChartLineAnnotation XMin="3.5"
                            XMax="3.5"
                            Border="@( new SvgChartBorderOptions { Color = Color.Warning, Width = 2 } )"
                            DashPattern="4 4"
                            Label="@releaseLabel" />
    <SvgChartLabelAnnotation X="5"
                             Y="91"
                             Label="@noteLabel" />
    <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.
1 series, 0 categories.Store performanceRegion and point annotations01020304050020406080100WatchTarget areaSelected storeStores
<SvgScatterChart TItem="StoreSample"
                 Items="@stores"
                 Options="@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="@targetLabel" />
    <SvgChartPointAnnotation X="33"
                             Y="74"
                             Radius="6"
                             BackgroundColor="Color.Warning"
                             Border="@( new SvgChartBorderOptions { Color = Color.Danger, Width = 2 } )"
                             Label="@pointLabel" />
    <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 through SvgChartOptions.Annotations when chart options are created in C#.
1 series, 6 categories.Deployment healthAnnotations configured from chart options020406080100BuildTestCanaryRampStableObserveDeployTargetRecovered
<SvgLineChart TItem="DeploymentSample"
              Items="@samples"
              Options="@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 TypeDefault
Border

Defines the annotation line border options.

SvgChartBorderOptionsnull
DashPattern

Defines the annotation line dash pattern.

string
Label

Defines annotation label options.

SvgChartAnnotationLabelOptionsnull
Name

Defines the annotation name.

string
Opacity

Defines the annotation opacity.

double1
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.

booltrue
XMax

Defines the annotation end X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
XMin

Defines the annotation start X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
YMax

Defines the annotation end Y value.

double?null
YMin

Defines the annotation start Y value.

double?null

SvgChartBoxAnnotation

Parameter Description TypeDefault
BackgroundColor

Defines the annotation background color.

Colornull
Border

Defines the annotation border options.

SvgChartBorderOptionsnull
Label

Defines annotation label options.

SvgChartAnnotationLabelOptionsnull
Name

Defines the annotation name.

string
Opacity

Defines the annotation opacity.

double0.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.

booltrue
XMax

Defines the annotation end X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
XMin

Defines the annotation start X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
YMax

Defines the annotation end Y value.

double?null
YMin

Defines the annotation start Y value.

double?null

SvgChartLabelAnnotation

Parameter Description TypeDefault
Label

Defines annotation label options.

SvgChartAnnotationLabelOptionsnull
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.

booltrue
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 TypeDefault
BackgroundColor

Defines the annotation background color.

Colornull
Border

Defines the annotation border options.

SvgChartBorderOptionsnull
Label

Defines annotation label options.

SvgChartAnnotationLabelOptionsnull
Name

Defines the annotation name.

string
Opacity

Defines the annotation opacity.

double0.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.

booltrue
XMax

Defines the annotation end X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
XMin

Defines the annotation start X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
YMax

Defines the annotation end Y value.

double?null
YMin

Defines the annotation start Y value.

double?null

SvgChartPointAnnotation

Parameter Description TypeDefault
BackgroundColor

Defines the annotation background color.

Colornull
Border

Defines the annotation border options.

SvgChartBorderOptionsnull
Label

Defines annotation label options.

SvgChartAnnotationLabelOptionsnull
Name

Defines the annotation name.

string
Opacity

Defines the annotation opacity.

double1
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.

double5
ValueAxisId

Defines the value axis identifier used by this annotation.

string
Visible

Defines whether the annotation is visible.

booltrue
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 TypeDefault
Label

Defines annotation label options.

SvgChartAnnotationLabelOptionsnull
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.

booltrue

SvgChartLineAnnotationOptions

Parameter Description TypeDefault
Border

Defines the annotation line border options.

SvgChartBorderOptionsnew() { Width = 2, }
DashPattern

Defines the annotation line dash pattern.

string
Opacity

Defines the annotation opacity.

double1
XMax

Defines the annotation end X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
XMin

Defines the annotation start X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
YMax

Defines the annotation end Y value.

double?null
YMin

Defines the annotation start Y value.

double?null

SvgChartBoxAnnotationOptions

Parameter Description TypeDefault
BackgroundColor

Defines the annotation background color.

Colornull
Border

Defines the annotation border options.

SvgChartBorderOptionsnew()
Opacity

Defines the annotation opacity.

double0.16
XMax

Defines the annotation end X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
XMin

Defines the annotation start X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
YMax

Defines the annotation end Y value.

double?null
YMin

Defines the annotation start Y value.

double?null

SvgChartLabelAnnotationOptions

Parameter Description TypeDefault
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 TypeDefault
BackgroundColor

Defines the annotation background color.

Colornull
Border

Defines the annotation border options.

SvgChartBorderOptionsnew() { Width = 1, }
Opacity

Defines the annotation opacity.

double0.16
XMax

Defines the annotation end X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
XMin

Defines the annotation start X value. For category charts, this is the category index where -0.5 represents the left plot edge.

double?null
YMax

Defines the annotation end Y value.

double?null
YMin

Defines the annotation start Y value.

double?null

SvgChartPointAnnotationOptions

Parameter Description TypeDefault
BackgroundColor

Defines the annotation background color.

Colornull
Border

Defines the annotation border options.

SvgChartBorderOptionsnew() { Width = 1, }
Opacity

Defines the annotation opacity.

double1
Radius

Defines the annotation point radius.

double5
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 TypeDefault
BackgroundColor

Defines the annotation label background color.

Colornull
Border

Defines the annotation label border options.

SvgChartBorderOptionsnew() { Radius = 3, }
Font

Defines the annotation label font options.

SvgChartFontOptionsnew() { Size = 11, Weight = "600", }
Offset

Defines the annotation label offset from its anchor.

double8
Padding

Defines the annotation label padding.

SvgChartSpacingnew() { Top = 3, End = 6, Bottom = 3, Start = 6, }
Position

Defines the annotation label position.

Possible values:Start, Center, End

SvgChartAnnotationLabelPositionSvgChartAnnotationLabelPosition.Center
Text

Defines the annotation label text.

string
Visible

Defines whether the annotation label is visible.

boolfalse

Methods

SvgChartLineAnnotation

Method DescriptionReturnParameters
Render Renders the plugin SVG content into the chart. voidSvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence

SvgChartBoxAnnotation

Method DescriptionReturnParameters
Render Renders the plugin SVG content into the chart. voidSvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence

SvgChartLabelAnnotation

Method DescriptionReturnParameters
Render Renders the plugin SVG content into the chart. voidSvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence

SvgChartEllipseAnnotation

Method DescriptionReturnParameters
Render Renders the plugin SVG content into the chart. voidSvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence

SvgChartPointAnnotation

Method DescriptionReturnParameters
Render Renders the plugin SVG content into the chart. voidSvgChartPluginRenderContext context, RenderTreeBuilder builder, int sequence
On this page