Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Legend

Since 0.1.0-alpha.22
A legend above, below or beside the chart whose items hide and show their series, with series that can start hidden.

A legend beside the chart

Legend places the legend: Top, Bottom, Start, End or None. Start and End put it beside the chart, and above or below it under 30rem wide. By default it's above, under the title, with two series or more.

Static

Preview

Sessions by channel, 2026
  • Organic search
  • Direct
  • Paid search
  • Other
Arrow keys move between values; Escape hides the tooltip.

Code

Legend.razor
@* Sessions by channel, the legend beside the chart, and the small "Other" channel starting hidden. *@
<Chart Items="_months" Argument="m => m.Month" Title="Sessions by channel, 2026" Legend="ChartLegend.End">
    <ChartValueAxis Format="#,##0,K" />
    <ChartLineSeries Value="m => m.Organic" Name="Organic search" />
    <ChartLineSeries Value="m => m.Direct" Name="Direct" />
    <ChartLineSeries Value="m => m.Paid" Name="Paid search" />
    <ChartLineSeries Value="m => m.Other" Name="Other" Hidden />
</Chart>

@code {
    private record ChannelMonth(string Month, int Organic, int Direct, int Paid, int Other);

    private readonly ChannelMonth[] _months =
    [
        new("Jan", 182_400, 96_300, 61_200, 8_100), new("Feb", 176_900, 94_800, 58_700, 7_900),
        new("Mar", 195_300, 101_200, 66_400, 8_600), new("Apr", 201_800, 103_900, 70_100, 8_800),
        new("May", 209_600, 106_500, 72_800, 9_200), new("Jun", 198_200, 104_100, 69_300, 9_000),
        new("Jul", 191_700, 99_800, 64_500, 8_700), new("Aug", 204_300, 105_200, 71_900, 9_100),
        new("Sep", 218_900, 110_600, 78_200, 9_600), new("Oct", 226_400, 113_800, 81_500, 9_900),
        new("Nov", 241_700, 121_300, 94_600, 10_400), new("Dec", 236_200, 124_900, 98_300, 10_800),
    ];
}

Click a legend item to hide its series, and again to show it. The chart is drawn again without it, so stacks close up and the value axis rescales. To start a series hidden, set Hidden, here the small Other channel, which would flatten the rest.

LegendAlign sets where the legend sits along its edge: Start (the default, lined up with the title), Center or End. Above or below the chart, that's left, center or right; beside it, top, middle or bottom.

Connection lost

Rejoining the server…