Waterfall
A waterfall shows how a start value becomes an end value: a month's result from revenue through costs, or a budget through its changes. Each change is a bar floating from the running total before it to the one after, and totals stand on zero.
From revenue to result
Give WaterfallSeries the changes as YValue and mark the totals with IsTotal. A total shows the
running total so far, so its own value is ignored (it can be null); a subtotal in between keeps the total running. Rises are
green and falls red (--rio-positive and --rio-negative), totals take the series color, and thin lines
carry each bar's end over to the next. The tooltip shows the change and the running total after it.
Code
<RioChart TItem="Step" Items="steps">
<WaterfallSeries Name="Result" XValue="s => s.Name" YValue="s => s.Amount"
IsTotal="s => s.IsTotal" DataLabels="true" />
</RioChart>
@code {
record Step(string Name, double? Amount, bool IsTotal = false);
Step[] steps =
[
new("Revenue", 420), new("Cost of sales", -180), new("Gross profit", null, true),
new("Salaries", -120), new("Marketing", -45), new("Other income", 15), new("Result", null, true),
];
}A start value and own colors
The first bar is a change from zero, so an opening balance rises like any other. ColorValue gives it a color of its
own; here the series color, like the closing total. Bars with their own color keep it in the tooltip.
Code
<RioChart TItem="Step" Items="steps">
<WaterfallSeries Name="Cash" XValue="s => s.Name" YValue="s => s.Amount" IsTotal="s => s.IsTotal"
ColorValue="@(s => s.Name == "Opening" ? "--rio-series-1" : null)" />
</RioChart>Down the page
With Horizontal="true" on the chart, the steps run down the side, first on top, and each bar floats left or right
from the running total. It reads like a statement, and long step names have room.
Code
<RioChart TItem="Step" Items="steps" Horizontal="true">
<WaterfallSeries Name="Result" XValue="s => s.Name" YValue="s => s.Amount"
IsTotal="s => s.IsTotal" DataLabels="true" />
</RioChart>In JSON definitions
"type": "waterfall" (also "bridge") with a category x, the changes as y, and
"total": the field that marks total rows (true, yes or 1). "horizontal": true
runs the steps down the rows.