Bars and stacking
Bar and column charts for Blazor: bars start at zero, group side by side, stack by name or to 100 %, and can mix with lines. They also combine repeated x values or time buckets.
Grouped bars
Several bar series share each category. Large numbers are compact (182k).
Code
<RioChart TItem="Sales" Title="Revenue per quarter, €">
<BarSeries Items="quarters" Name="2025" XValue="s => s.Quarter" YValue="s => s.LastYear" />
<BarSeries Items="quarters" Name="2026" XValue="s => s.Quarter" YValue="s => s.ThisYear" />
</RioChart>Stacked bars with data labels
Same Stack name, same slot. Labels show inside segments that are big enough.
Code
<BarSeries Items="mix" Name="Shoes" XValue="m => m.Month" YValue="m => m.Shoes" Stack="mix" DataLabels="true" Format="0 k€" />
<BarSeries Items="mix" Name="Clothing" XValue="m => m.Month" YValue="m => m.Clothing" Stack="mix" DataLabels="true" Format="0 k€" />
<BarSeries Items="mix" Name="Gear" XValue="m => m.Month" YValue="m => m.Gear" Stack="mix" DataLabels="true" Format="0 k€" />100 % stacked bars
Stacking = StackMode.Percent on the y axis stacks its bar, line and area series to 100 %, so each
month shows the product groups' shares. Series without a Stack name are stacked together. The tooltip
shows the value and its share; hide a series in the legend and the others fill its share. In JSON definitions:
"y": { "stacking": "percent" } or the type "stackedBar100".
Code
<RioChart TItem="Monthly" YAxis="@(new AxisOptions { Stacking = StackMode.Percent })">
<BarSeries Items="mix" Name="Shoes" XValue="m => m.Month" YValue="m => m.Shoes" Format="0 k€" />
<BarSeries Items="mix" Name="Clothing" XValue="m => m.Month" YValue="m => m.Clothing" Format="0 k€" />
<BarSeries Items="mix" Name="Gear" XValue="m => m.Month" YValue="m => m.Gear" Format="0 k€" />
</RioChart>Combining repeated x values
Items with the same x are drawn on top of each other unless the series combines them.
Aggregate gives the Sum, Average, Min, Max or Last
of YValue, or the Count of items. YAggregate computes y from the group's items.
A click gives the whole group in Items. Sort="ChartSort.Descending" orders the categories by the
combined values, largest first (sorting the items cannot, since the counts only exist after grouping).
Clicked: nothing yet
Code
<RioChart TItem="Ticket" Items="tickets" OnPointClick="e => clicked = e">
<BarSeries Name="Tickets" XValue="t => t.Topic" Aggregate="Aggregate.Count" Sort="ChartSort.Descending" />
<BarSeries Name="Handling time (h)" XValue="t => t.Topic" YAggregate="g => g.Sum(t => t.Minutes) / 60" Format="0.0 h" />
</RioChart>
@* clicked.Items holds every ticket behind the bar *@Bars per time bucket
Bucket groups items with a time x per minute, hour, day, week, month, quarter or year (on their wall-clock
time, or in the chart's TimeZone when set) and draws one bar at the start of each bucket, combined with Aggregate (the average when not set).
TimeBucket.Auto picks the bucket from the data's time span, aiming for about 50 bars: hours for these two
days of revenue, weeks for a year. Lines and areas take Bucket too. In JSON definitions:
"timeBucket": "auto".
Code
@* Revenue every 15 minutes for two days *@
<RioChart Items="revenue" Title="Revenue, €">
<BarSeries Name="Revenue" XValue="r => r.Time" YValue="r => r.Value"
Bucket="TimeBucket.Auto" Aggregate="Aggregate.Sum" Format="#,0 €" />
</RioChart>Bars and a line
Default draw order is areas, then bars, then lines (override with ZIndex). Bars work on time axes too.
Code
<BarSeries Items="orders" Name="Orders" XValue="r => r.Time" YValue="r => r.Value" />
<LineSeries Items="average" Name="7-day average" XValue="r => r.Time" YValue="r => r.Value" Curve="CurveType.Monotone" />Horizontal bars
Horizontal="true" turns the bars sideways: categories down the side, first on top, so a sorted list reads as a
ranking and long names have room (very long ones are shortened, the tooltip has them in full). YAxis formats the
values; reference lines such as a target are drawn across the rows. In a JSON definition: "type": "horizontalBar" or
"horizontal": true.
Code
<RioChart Items="categories.OrderByDescending(c => c.Revenue)" Horizontal="true" YAxis="@(new AxisOptions { Title = "k€" })"
Title="Revenue per category, this year">
<BarSeries Name="Revenue" XValue="c => c.Name" YValue="c => c.Revenue" Format="0 k€" DataLabels="true" />
<ReferenceLine Value="200" Label="Target" />
</RioChart>Colors from the data
ColorValue gives an item its own color: here the days under the target in the falling color and the best day in
the rising one. Return a theme token ("--rio-negative", "--rio-series-3": they follow light and dark
themes) or any CSS color, and null to keep the series color. It works on every series: bars, scatter markers, pie
slices, radial bars and treemap items take the color, lines and areas mark the point with a dot. Aggregated points take their
first item's color. In JSON definitions, "colorField" names the field that holds the colors.
Color should not be the only signal: here the target line and the tooltip say it too.
Code
<RioChart TItem="DayOrders" Items="orders">
<BarSeries Name="Orders" XValue="d => d.Day" YValue="d => d.Orders"
ColorValue="@(d => d.Orders < 100 ? "--rio-negative" : d.Orders >= 150 ? "--rio-positive" : null)" />
<ReferenceLine Value="100" Label="Target" />
</RioChart>Negative values
Bars grow from zero, so a negative value is a bar pointing down and the y axis takes in both sides. Here the result per
month, with the loss months in the falling color through ColorValue; data labels sit at the end of each bar,
below the negative ones.
Code
<RioChart Items="monthlyResult" YAxis="@(new AxisOptions { Title = "k€" })">
<BarSeries Name="Result" XValue="m => m.Name" YValue="m => m.Value" Format="0 k€" DataLabels="true"
ColorValue="@(m => m.Value < 0 ? "--rio-negative" : null)" />
</RioChart>Bar width
Bars fill their band, but never take more than a fifth of the plot: when a filter leaves one or two categories, the bars
stay bar-shaped and centered instead of filling the chart. MaxBarWidth (pixels) narrows them further; grouped
bars stay side by side. In JSON definitions: "maxBarWidth": 40.
Quarters:
Code
@* One quarter left after filtering: the bar takes a fifth of the plot, centered. MaxBarWidth narrows it further. *@
<RioChart Items="quarters">
<BarSeries Name="2026" XValue="s => s.Quarter" YValue="s => s.ThisYear" MaxBarWidth="40" />
</RioChart>Per-bar tooltip
Tooltips are shared per x by default; Shared = false shows only the bar under the pointer.
Code
<RioChart TItem="Sales" Tooltip="new TooltipOptions { Shared = false }">
<BarSeries ... DataLabels="true" />
</RioChart>