# River Chart

River chart (streamgraph) for how a mix changes over time: plain, with gradient bands or offset.

- Category: Charts
- Page: https://wunderui.com/components/river-chart
- Tier: Core and Pro

## Install

River Chart ships with WunderUI Core and Pro in the @wunderui/react package.

## Import

```tsx
import { RiverChart, RiverChartProps, RiverChartVariant } from "@wunderui/react"
```

## Minimal usage

Then use it:

```tsx
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

- [Stacked Chart](https://wunderui.com/components/stacked-chart) for exact amounts on a baseline
- [Area Chart](https://wunderui.com/components/area-chart) for a few overlapping series with a value axis
- [Line Chart](https://wunderui.com/components/line-chart) for values that must be read off an axis
- [Sankey Chart](https://wunderui.com/components/sankey-chart) for flows between stages

## Keyboard

The plot is focusable: Arrow keys walk the time steps and the live region announces each series at that step.

| Key | Action |
|---|---|
| `Tab` or `Shift+Tab` | Moves focus to the plot and away from it. The plot is one tab stop; so is every legend badge. |
| `ArrowRight` or `ArrowLeft` | 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). |
| `Home` or `End` | Jumps to the first or last time step. |
| `Escape` | Clears the active point. |
| `Enter` or `Space` | On a legend badge of a ChartCard: switches its series off or on. The last visible series stays on. |

## Behavior

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.
- **Band names:** A band with room carries its name at its widest point, in a text colour that keeps its contrast on the band. A band too thin for it keeps the legend and the tooltip, and the names can be switched off.
- **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 wipes in from left to right when the chart first comes into view, after loading and when new data arrives, and the band names fade in once the river has arrived.
- **Hover:** The band under the pointer keeps its strength and the others dim, and its row stays bright in the tooltip.
- **Reduced motion:** With reduced motion on, the chart appears at once without the enter sequence. The tooltip and every state still work.

## Anatomy

- `RiverChart`: 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.
- `Plot`: The focusable region. Arrow keys walk the time steps and announce each series at that step.
- `Time 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.
- `Bands`: 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.
- `Tooltip`: The time step with the value of each visible series.
- `Loading, empty and error`: A muted area under the shimmer. A retry handler adds a Try again button to the error message.
- `Data table and live region`: The raw values per series and step for screen readers.
- `Chart Layers`
- `Chart Layer Labels`

## Best practices

### When to use

- Use RiverChart to show how a mix shifts over a long period, such as share of traffic per channel across 24 months. Use StackedChart when exact values per step must be read.

### 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.
- Use at least a dozen time steps. With only a few points the smooth bands exaggerate movement that the data does not contain.
- 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 pass negative values. Bands cannot be negative and the chart treats them as zero.

## API reference

### RiverChart

| Prop | Type | Default | Description |
|---|---|---|---|
| data* | readonly ChartDatum[] |  | One object per category / point. |
| index* | string |  | Field holding the category label (x axis; y axis for horizontal bars). |
| series* | readonly ChartSeries[] |  | The series to draw, in order. |
| activeIndex | number \| null |  | The active point (hovered or focused) as an index into `data`, to control it yourself. `null` shows none. |
| animate | boolean |  | Enter sequence (draw, wipe, grow) on scroll into view, after loading and on new data. Default true; off with reduced motion. |
| animationKey | string \| number |  | Change it to play the enter sequence again (e.g. `useChartReload().version`). New `data` replays it by itself. |
| aspectRatio | number |  | Width ÷ height when `height` is not set. Default 2.6. |
| axisFormatter | ChartValueFormatter |  | Value-axis labels; defaults to `valueFormatter`. |
| categoryAxis | boolean |  | Category-axis labels (default true). |
| categoryFormatter | (label: string) => string |  | Shortens category labels on the axis, e.g. "Mar 12" → "Mar"; tooltip and pill keep the full label. |
| categoryTicks | readonly string[] |  | Only these category labels are shown on the axis (the rest stay hoverable). |
| className | string |  | Extra classes for the root element of the chart. |
| defaultActiveIndex | number \| null |  | The point that is active at first, for an uncontrolled chart. It shows the tooltip without a pointer. |
| defaultSelectedRange | ChartRange \| null |  | The range that is selected at first, for an uncontrolled chart. |
| description | string |  | Screen-reader summary; generated from the data when omitted. |
| emptyDescription | string |  | Text under the title in the empty state. |
| emptyTitle | string |  | Title of the message in the empty state. |
| errorDescription | string |  | Text under the title in the error state. |
| errorTitle | string |  | Title of the message in the error state. |
| grid | boolean |  | Grid lines (default true). |
| gridFade | boolean |  | The grid fades out towards both ends (default true). |
| gridIntervals | number |  | Number of equal grid intervals. Default: one per 44 px of plot height, capped by the size class (xs 2, sm 3, md 3, lg 4, xl 5). |
| gridStyle | "solid" \| "dashed" |  | Grid lines are dashed 4 / 4 by default; `solid` draws them through. |
| height | number |  | Fixed height of the plot frame in px. Without it the height follows the width (`aspectRatio`, `minHeight`, `maxHeight`): 220 px on a phone, up to 434 px (the plot of the Figma large card) from about 1130 px wide. |
| hiddenSeries | readonly string[] |  | Series keys that are switched off (legend toggle): drawn faded, dimmed in the tooltip. |
| includeZero | boolean |  | The value axis starts at 0 (owner rule, default). `false` fits the data (prices, temperatures). |
| label | string |  | Accessible name, e.g. the card title. |
| maxHeight | number |  | Highest height from `aspectRatio`. Default 434. |
| minHeight | number |  | Lowest height from `aspectRatio`. Default 220. |
| onActiveIndexChange | (index: number \| null) => void |  | Called with the index when the pointer or the arrow keys move to another point, and with `null` when they leave. Use it to show the hovered value in a headline. |
| onRetry | () => void |  | Shows a Try again button in the error state and calls this when it is pressed. |
| onSelectedRangeChange | (range: ChartRange \| null) => void |  | Called when a drag across the plot or Shift with an arrow key changes the range, and with `null` when Escape or a click clears it. |
| pattern | ChartPattern \| ChartPattern[] |  | One pattern form from the shared pattern library (`diagonal-lines`, `polka-dots`, `crosshatch` …) for every band, drawn in its colour on a tint of it, for print and colour-blind reading. A list keeps its first entry; a mark under 20 px on its shorter side stays solid. |
| rangeSelectable | boolean |  | Allow selecting a range by dragging or Shift + arrow keys. On when `onSelectedRangeChange` is set. |
| resolution | "auto" \| "full" |  | `auto` (default): lines and areas draw at most 1.5 points per pixel (LTTB; hover and tooltip keep every point), and bars on a time axis that would get thinner than they may are gathered into weeks, months … `full` draws every point and eve… |
| selectedRange | ChartRange \| null |  | The selected range as inclusive indices `[from, to]` into `data`, to control it yourself. `null` selects nothing. |
| showLabels | boolean | true | Writes each series name into its band at the widest point, where the band has room. On by default; a thin band keeps the legend and the tooltip. |
| state | "ready" \| "loading" \| "empty" \| "error" |  | `loading` shows the chart-shaped skeleton, `empty` and `error` a message in the plot. |
| tooltip | boolean |  | Tooltip on hover / keyboard focus. Default true. |
| tooltipTitle | (datum: ChartDatum, index: number) => React.ReactNode |  | Title line of the tooltip; defaults to the category label. |
| valueAxis | boolean |  | Value-axis labels (default true). Off for compact cards and sparkline-like plots. |
| valueAxisPlacement | "auto" \| "outside" \| "inside" |  | Where the value labels go: `outside` left of the plot, `inside` in the plot above their grid lines (saves the label column on narrow charts). `auto` (default) puts them left of the plot at every size; `inside` is opt-in. |
| valueAxisSide | "left" \| "right" |  | Side of the value axis (vertical charts). `right` is the price axis of trading charts. |
| valueDomain | readonly [number, number] |  | Fix the value domain instead of fitting it to the data (still rounded to nice steps). |
| valueFormatter | ChartValueFormatter |  | Values in tooltip, labels, table and live region. Default: 42000 → "42k". |
| valueTicks | readonly number[] |  | Exact value-axis ticks (ascending), e.g. [0, 10000, … 70000]; replaces the nice-step domain. |
| variant | "basic-river" \| "gradient-river" \| "offset-river" | "basic-river" | Figma variant. Default `basic-river`. |
| width | number |  | Fixed width instead of filling and measuring the container. |
| xScale | "band" \| "time" |  | `band` (default): the categories sit side by side in equal bands. `time`: the `index` field holds dates (Date, ms or a string such as "2026-03-01"); points sit at their real distance, the axis picks its tick level (hours → days → weeks → m… |

## Examples

### States

### Patterns

## In context

### Ticket Topics

What customers write about, month by month.

## For AI agents

`get_component("river-chart")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
