Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Waterfall Chart Stats Block for Svelte

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.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A waterfall chart for Svelte with Ark 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.

What moves, and what happens with reduced motion?

The header and chart fade up once on load, the bars are revealed from the start to the end and the amounts fade in. With reduced motion every transition is off and the finished chart is there.

How does it fit on a phone?

The plot is shorter and the category names switch to short ones ("Prices", "Online", "Food") so six columns fit at 320 pixels; the amounts above the bars stay. The table still uses the long names. Nothing scrolls sideways.