shadcn.io is not affiliated with official shadcn/ui
Waterfall Chart Stats Block for React
A quarter's operating profit walked from last quarter to this one in six floating bars with hairline connectors, totals at full weight, gains at 60% and losses as outlines, with the net change in the header.
Installation
Overview
A waterfall chart for React with Base UI. A compact header says how far operating profit moved and where it landed, with the net change and its percentage at the end of the row. Under it, one framed chart (a figure with + marks on its corners) walks from last quarter's profit to this quarter's in six bars: the two totals stand on the baseline at full strength, each gain floats from the running total at 60%, each loss floats as an outline, and a hairline connector carries the total from one bar to the next. The amount is written above every bar and the category below it. Only the opening profit and the four changes are typed; the running totals, the closing bar, the connectors, the net change and the headline are derived from them. For finance, margin and revenue bridges, and any story of what added to a number and what took from it.
FAQ
How do I change the figures and the categories?
Edit START (the opening total, in thousands) and CHANGES (a long name, a short name for phones and a signed amount each). The closing bar is the sum, so it can't disagree with them. The scale rounds up to the next hundred above the highest running total, so it follows the data. For a different number of changes, change the six-column grid's grid-cols-6 and the SLOT width (100 divided by the number of bars).
How do the floating bars work?
Each bar spans from its lowest to its highest value: a total from zero up to itself, a change from the running total before it to the running total after it. The connector at the end of each bar is a hairline at the running total, so a gain's top and a loss's bottom both meet the next bar. The drawing is one stretched graphic of rectangles and lines; the amounts and labels are HTML so they stay crisp.
Is it accessible?
The drawing is hidden from assistive technology and replaced by a table with one row per step: the step, its signed amount and the running total. The figure's caption lists the opening, the closing and every change in one sentence. Losses use a true minus sign, read as "minus", and the shapes differ (solid, lighter, outline), so nothing depends on colour. A key under the axis explains them.
Why aren't gains green and losses red?
Whether a change is good depends on the number: a fall in costs is good news. The chart shows direction by position, sign and shape, in your theme's text colour, so it works in every theme and stays readable without colour.
Related
- Pro
Diverging Bar Chart Stats
Bar and columnTwelve monthly returns as bars above and below a labelled zero line: gains solid, losses outlined, every value at its tip with a sign, and no green or red.
- Pro
Burndown Chart Card Stats
Area and lineA sprint burndown in a card in a card: the ideal burn as a dashed line, the actual remaining work as a solid one, the gap shaded, a tick where scope was added and a band of three figures under the chart.
- Pro
Pareto Chart Stats
Bar and columnA defect Pareto: seven bars sorted largest first, a cumulative line on a second axis, an 80% line and a bracket over the vital few, with a list of every cause's count, share and running share.
- Pro
Stacked Area Chart Breakdown Stats
Area and lineA stacked area chart of weekly signups by channel in three foreground weights, with a legend of each channel's share beside it; pointing at a row or a layer keeps that layer and fades the others.
- Pro
Renewal Delta Callout Stats
ComparisonsA subscription renewal comparison that leads with the percent change at display size, then the month before and this month as two tiles.
- Pro
Before and After Load Time Stats
ComparisonsA page-speed comparison with the time before a tune, the time after it, and the seconds saved on a connecting line between two dots.