Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Value labels

Since 0.1.0-alpha.22
Each value written beside its bar or point, on any series, past a bar's end or in the middle of a stacked segment, with labels that would overlap left out.

Labels on bars

To write each value beside its bar, set Labels on the series to Auto. A label goes past the end of the bar, or inside it when there's no room above.

Static

Preview

Gross state product, Great Lakes (billions USD)
  • 2022
  • 2023
  • 2024

Code

Labels.razor
@* Gross state product for the Great Lakes states over three years, each bar labeled. *@
<Chart Items="_states" Argument="s => s.State" Title="Gross state product, Great Lakes (billions USD)">
    <ChartBarSeries Value="s => s.Y2022" Name="2022" Labels="ChartLabels.Auto" LabelFormat="N0" />
    <ChartBarSeries Value="s => s.Y2023" Name="2023" Labels="ChartLabels.Auto" LabelFormat="N0" />
    <ChartBarSeries Value="s => s.Y2024" Name="2024" Labels="ChartLabels.Auto" LabelFormat="N0" />
</Chart>

@code {
    private record StateProduct(string State, decimal Y2022, decimal Y2023, decimal Y2024);

    private readonly StateProduct[] _states =
    [
        new("Illinois", 1_040, 1_090, 1_137),
        new("Indiana", 473, 505, 527),
        new("Michigan", 627, 675, 705),
        new("Ohio", 833, 890, 930),
        new("Wisconsin", 401, 415, 430),
    ];
}

LabelFormat formats the labels apart from the axis. A label that would overlap another is left out at the widths where it would; narrow the window to see them go. To show every label anyway, set LabelOverlap to Show.

With every series labeled, the chart has no tooltips, which would repeat the labels. To keep them, set Tooltip to true.

Labels in a stack

In a stack, Auto puts each label in the middle of its segment, and leaves it out when the segment is too small to hold it. Inside puts labels inside the bar at its end, and Outside past it.

Static

Preview

Support tickets by channel
  • Email
  • Chat
  • Phone

Code

LabelsStacked.razor
@* Support tickets by channel each week, stacked, each segment labeled in its middle. *@
<Chart Items="_weeks" Argument="w => w.Week" Title="Support tickets by channel" Stacking="ChartStacking.Normal">
    <ChartBarSeries Value="w => w.Email" Labels="ChartLabels.Auto" />
    <ChartBarSeries Value="w => w.Chat" Labels="ChartLabels.Auto" />
    <ChartBarSeries Value="w => w.Phone" Labels="ChartLabels.Auto" />
</Chart>

@code {
    private record WeekTickets(string Week, int Email, int Chat, int Phone);

    private readonly WeekTickets[] _weeks =
    [
        new("Oct 5", 212, 148, 61), new("Oct 12", 198, 171, 58), new("Oct 19", 236, 189, 66),
        new("Oct 26", 221, 204, 49), new("Nov 2", 247, 226, 57),
    ];
}

Connection lost

Rejoining the server…