River Chart
River chart (streamgraph) for how a mix changes over time: plain, with gradient bands or offset.
Playground
Installation
River Chart comes with WunderUI Core and Pro, in the package from your plan. See the plans.
The charts live in their own entry point: import the chart, its card and its hooks from @wunderui/react/charts, not from @wunderui/react.
Then import what you need:
import {
RiverChart,
RiverChartProps,
RiverChartVariant,
} from "@wunderui/react/charts"Then use it:
import { RiverChart } from "@wunderui/react/charts"
const data = [
{ month: "Jan", billing: 128, access: 94 },
{ month: "Feb", billing: 142, access: 88 },
{ month: "Mar", billing: 151, access: 81 },
{ month: "Apr", billing: 139, access: 79 },
]
export function TicketsByTopic() {
return (
<RiverChart
data={data}
index="month"
series={[
{ key: "billing", label: "Billing" },
{ key: "access", label: "Access" },
]}
label="Support tickets by topic"
/>
)
}Expected result: You should see two smooth bands flowing around a centre line, with the months below and no value axis.
When to use
Use River Chart for
- How a mix changes over time, where the thickness of a band is the message
- Topics, categories or channels that rise and fall around a centre line
Use something else for
- Stacked Chart for exact amounts on a baseline
- Area Chart for a few overlapping series with a value axis
- Line Chart for values that must be read off an axis
- Sankey Chart for flows between stages
States
Loading, empty and error keep the chart's size, so the card never jumps. Add a retry handler and the error state offers a Try again button.
Keyboard interactions
The plot is focusable: Arrow keys walk the time steps and the live region announces each series at that step.
- TaborShiftTab
- Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge.
- ArrowRightorArrowLeft
- Moves to the next or previous time step. The tooltip follows, and a live region announces the one you are on. The first press starts at the first one (Left: the last one).
- HomeorEnd
- Jumps to the first or last time step.
- Escape
- Clears the active point.
- EnterorSpace
- On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on.
Behavior and motion
What the chart does on its own and what the page decides.
- Values
- Values must be zero or positive; a missing value counts as zero. The layers are ordered inside out, so the largest bands sit near the centre.
- No value axis
- The value axis and grid are off by default, because only the thickness of a band means something. The category axis runs below, and options bring the others back.
- Offset
- The offset variant moves each band apart by a small gap and keeps the whole river centred, and the gradient variant draws the bands with a gradient.
- Loading, empty and error
- The chart keeps its size while loading, empty or failed, so the card never changes height. Add a retry handler to show a Try again button on error.
- Legend
- In a ChartCard, each series badge is a button that switches its series off, but the last visible series stays on. A legend of roles can be made static.
- Data table
- The chart renders its data as a table for screen readers, in the same order as the plot.
- Size
- The chart fills the width of its container and you set the plot height. Text never scales, so labels keep their size at every width.
Motion
The enter sequence and the hover follow the motion tokens of the library.
- Wipe
- Each band is wiped in from left to right when the chart first comes into view, after loading and when new data arrives. The animation can be turned off.
- Reduced motion
- With reduced motion on, the chart appears at once without the enter sequence. The tooltip and every state still work.
Anatomy
RiverChart is a streamgraph: series flow around a centre line instead of stacking on a baseline, so the changing mix over time stands out. Variants add gradient bands or gaps between them.
Tickets by topic
| month | Billing | Access | Bugs | API | Other |
|---|---|---|---|---|---|
| Jan | 128 | 94 | 72 | 58 | 66 |
| Feb | 142 | 88 | 80 | 66 | 61 |
| Mar | 151 | 81 | 91 | 74 | 72 |
| Apr | 139 | 79 | 99 | 62 | 64 |
| May | 122 | 86 | 112 | 55 | 69 |
| Jun | 118 | 97 | 121 | 68 | 58 |
Pass data with the index field and the series. Values must be zero or positive, and a missing value counts as zero; the largest bands sit near the centre.
- data-slot="chart-plot"
The focusable region. Arrow keys walk the time steps and announce each series at that step.
- data-slot="chart-axis-x"
The value axis and grid are off by default, because only the thickness of a band means something. The category axis runs below, and options bring the others back.
- data-slot="chart-marks"
One smooth band per series, wiped in from left to right. The offset variant moves each band apart by a small gap and keeps the whole river centred.
- data-slot="chart-tooltip"
The time step with the value of each visible series.
- data-slot="chart-message"
A muted area under the shimmer. A retry handler adds a Try again button to the error message.
The raw values per series and step for screen readers.
Best practices
- Do
Keep to four to seven series with a clear name each, and put the legend in the ChartCard. Bands are labelled only through colour and the tooltip.
- Do
Use at least a dozen time steps. With only a few points the smooth bands exaggerate movement that the data does not contain.
- Do
Describe the reading in the description, for example Band thickness is the monthly sessions per channel, because the chart has no value axis by default.
- Don’t
Don't use it to read exact totals. Thickness is hard to compare between steps; if a number matters, use StackedChart and its labels.
- Don’t
Don't pass negative values. Bands cannot be negative and the chart treats them as zero.
API reference
One table for RiverChart, listing every prop. A ChartCard around it takes its own props, and the chart works without one.
Pass data with the index field and the series. Values must be zero or positive, and a missing value counts as zero; the largest bands sit near the centre.
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("river-chart")The full library index for assistants is at /llms.txt.