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

Chart "Revenue per quarter, €" with 2 series. 2025: 4 values, lowest 182,000 at Q1, highest 271,000 at Q4. 2026: 4 values, lowest 214,000 at Q1, highest 305,000 at Q4. Revenue per quarter, €0100k200k300k400kQ1Q2Q3Q420252026Use Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<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.

Chart "Revenue per product group" with 3 series. Shoes: 6 values, lowest 29 k€ at Mar, highest 42 k€ at Jan. Clothing: 6 values, lowest 17 k€ at Feb, highest 26 k€ at May. Gear: 6 values, lowest 6 k€ at Jan, highest 35 k€ at Jun. Revenue per product group050100JanFebMarAprMayJunk€ShoesClothingGear42 k€38 k€29 k€33 k€36 k€31 k€18 k€17 k€21 k€24 k€26 k€22 k€11 k€19 k€28 k€35 k€Use Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<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".

Chart "Share of revenue per product group" with 3 series. Shoes: 6 values, lowest 29 k€ at Mar, highest 42 k€ at Jan. Clothing: 6 values, lowest 17 k€ at Feb, highest 26 k€ at May. Gear: 6 values, lowest 6 k€ at Jan, highest 35 k€ at Jun. Share of revenue per product group0%50%100%JanFebMarAprMayJunShoesClothingGearUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<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).

Chart "Support tickets per topic" with 2 series. Tickets: 4 values, lowest 1 at Account, highest 4 at Shipping. Handling time (h): 4 values, lowest 0.3 h at Account, highest 4.2 h at Payment. Support tickets per topic0246ShippingPaymentReturnsAccountTicketsHandling time (h)Use Left and Right to move between points, Up and Down to change series. Press Enter to select a point, Escape to leave.

Clicked: nothing yet

Code
Razor
<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".

Chart "Revenue, €" with 1 series. Revenue: 48 values, lowest 172 € at 11/17/2026 8:00 AM, highest 6,804 € at 11/16/2026 6:00 PM, trend stable. Revenue, €02k4k6k8kNov 166:00 AM12:00 PM6:00 PMNov 176:00 AM12:00 PM6:00 PMUse Left and Right to move between points. Press Escape to leave.

Code
Razor
@* 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.

Chart with 2 series. Orders: 35 values, lowest 159 at 11/2/2026 12:00 AM, highest 290 at 10/18/2026 12:00 AM, trend falling. 7-day average: 35 values, lowest 162.7 at 11/5/2026 12:00 AM, highest 275 at 10/20/2026 12:00 AM, trend falling. 0100200300Oct 19Oct 26Nov 2Nov 9Nov 16Orders per dayOrders7-day averageUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<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.

Chart "Revenue per category, this year" with 1 series. Revenue: 7 values, lowest 6 k€ at Socks, highest 412 k€ at Shoes. Revenue per category, this year0100200300400500k€ShoesClothingCampingAccessoriesBagsGift cardsSocksTarget412 k€236 k€148 k€97 k€31 k€9 k€6 k€Use Left and Right to move between points. Press Escape to leave.
Code
Razor
<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.

Chart with 1 series. Orders: 7 values, lowest 88 at Fri, highest 156 at Sat. 050100150200MonTueWedThuFriSatSunOrders per dayTarget: 100TargetUse Left and Right to move between points. Press Escape to leave.
Code
Razor
<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.

Chart with 1 series. Result: 12 values, lowest -18 k€ at Jan, highest 52 k€ at Dec. -40-20020406080JanFebMarAprMayJunJulAugSepOctNovDeck€-18 k€-7 k€12 k€21 k€26 k€19 k€4 k€-11 k€15 k€24 k€37 k€52 k€Use Left and Right to move between points. Press Escape to leave.
Code
Razor
<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.

Chart with 1 series. 2026: 1 value, lowest 214,000 at Q1, highest 214,000 at Q1. 0100k200k300kQ1Use Left and Right to move between points. Press Escape to leave.

Quarters:

Code
Razor
@* 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.

Chart with 2 series. 2025: 4 values, lowest 182,000 at Q1, highest 271,000 at Q4. 2026: 4 values, lowest 214,000 at Q1, highest 305,000 at Q4. 0100k200k300k400kQ1Q2Q3Q420252026182k236k198k271k214k251k243k305kUse Left and Right to move between points, Up and Down to change series. Press Escape to leave.
Code
Razor
<RioChart TItem="Sales" Tooltip="new TooltipOptions { Shared = false }">
    <BarSeries ... DataLabels="true" />
</RioChart>
An unhandled error has occurred. Reload 🗙