Area Chart
Area chart for volumes over time: gradients, steps, ranges, a horizon graph, differences and target lines.
Playground
Installation
Area 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 {
AreaChart,
AreaChartProps,
AreaChartVariant,
} from "@wunderui/react/charts"Then use it:
import { AreaChart } from "@wunderui/react/charts"
const data = [
{ month: "Jan", revenue: 32000 },
{ month: "Feb", revenue: 41000 },
{ month: "Mar", revenue: 38000 },
{ month: "Apr", revenue: 47000 },
]
export function RevenueArea() {
return <AreaChart data={data} index="month" series={[{ key: "revenue", label: "Revenue" }]} label="Revenue" />
}Expected result: You should see one filled area over a grid that starts at 0, with the months below. Hovering shows a crosshair and a tooltip.
When to use
Use Area Chart for
- Volumes over time, where the filled area carries the message
- A total made of overlapping series (requests, sessions)
- A band around a value (a range of temperatures), or the gap between two series
- Several signals stacked as horizon rows
Use something else for
- Line Chart for exact values and many series that would hide each other
- Stacked Chart for the parts of a total, stacked on top of each other
- River Chart for a mix that changes over time, centred on a baseline
- Sparkline for a small trend without axes
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.
Table view
Every chart carries a table of its data for screen readers. A ChartCard can show it on screen too, with a toggle in the header.
Keyboard interactions
The plot is focusable, so the chart works without a pointer.
- 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 point. 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 point.
- ShiftArrowRightorShiftArrowLeft
- Extends a selected range from the point you started on. A range is only selected when is set.
- Escape
- Clears the active point and the selected range.
- 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.
- Variants set the fill
- The variant picks the fill, the curve (smooth or step) and the layers (band, target line, difference, threshold). A separate curve setting overrides the outline.
- Order
- Overlapping series are drawn in series order, so the first one sits at the back. Put the largest first.
- Baseline
- Areas are clipped to the plot and never draw below the baseline, even on a smooth curve.
- Horizon graph
- The horizon graph gives each series its own row and folds values into bands of deepening shade: positive in the series colour, negative in red.
- Loading, empty and error
- The chart keeps its size while it loads, is empty or fails, so the card never jumps. Loading shows a skeleton; error adds a Try again button when a retry handler is set.
- Legend
- A ChartCard shows series as badges. With two or more series each badge switches its series off, the last visible one stays on, and a legend of roles can be made static.
- Data table
- The chart also renders its data as a table for screen readers, in plot order. A ChartCard can show that table on screen through a toggle that keeps the card height.
- Size
- The chart fills its container's width; you set the plot height. Text never scales: labels keep their size at every width.
Motion
The enter sequence and the hover follow the motion tokens of the library.
- Wipe
- Areas wipe in from the left and outlines draw along their path the first time the chart is in view, and again after loading or when new data arrives.
- Hover
- The crosshair and the ringed points glide from point to point. The horizon graph has no crosshair.
- Reduced motion
- With reduced motion on, the enter sequence is off and the chart appears at once. Tooltip, crosshair and every state still work.
Anatomy
AreaChart fills the space under a line so the amount reads at a glance. Variants cover solid and gradient fills, overlaps, a positive and negative split, bands, horizon rows and a target line.
Revenue
| month | Revenue | Expenses |
|---|---|---|
| Jan | 32k | 18k |
| Feb | 41k | 22k |
| Mar | 38k | 27k |
| Apr | 47k | 24k |
| May | 44k | 30k |
| Jun | 52k | 28k |
| Jul | 49k | 34k |
| Aug | 55k | 31k |
| Sep | 51k | 36k |
| Oct | 46k | 33k |
| Nov | 53k | 38k |
| Dec | 58k | 35k |
Takes data, an index and series. You can pick smooth, straight or step outlines, change the fill opacity, and mark series that skip the fill or the outline.
- data-slot="chart-plot"
The focusable region. Arrow keys walk the points, Shift with an arrow or a drag selects a range, Escape clears it, and hover shows a crosshair and one point per series (not on the horizon graph).
- data-slot="chart-grid"
Grid lines from 0 and the same axis rules as other cartesian charts. Areas are clipped to the plot and never draw below the baseline, even on smooth curves.
- data-slot="chart-marks"
A fill per series (solid, gradient, reversed gradient or light tint) with a thin outline on top. Overlapping series draw in order, so the first sits at the back.
- data-slot="chart-horizon"
The horizon layout: each series gets its own row and values fold into bands of deepening shade, positive in the series colour and negative in red.
The range band between lower and upper values, the split fill and threshold label of the positive-negative area, and the dashed target series of the target-line area.
- data-slot="chart-tooltip"
Category title and one row per visible series, with the change against the previous point on the first series.
- data-slot="chart-message"
Loading shows a muted skeleton shaped like the data; empty and error replace the plot with a message.
The data as a screen-reader table with a live region for the active point.
Best practices
- Do
Overlap at most two series, and give the back one the lighter fill. A third filled area covers the others and makes the lower values unreadable.
- Do
For positive and negative values use the positive-negative area with a threshold, not a single colour. The split at the baseline shows which side the value is on without reading the axis.
- Do
Use the horizon graph when many series share a short row height, for example 12 services in one card. Mention the fold count in the description, since the bands are not on a shared scale.
- Don’t
Don't use a gradient fill to encode data. The fade is decoration; the outline and the tooltip carry the value.
- Don’t
Don't stack unrelated series in one plot. For parts of a whole use StackedChart, whose stacking is explicit, instead of areas that merely overlap.
API reference
One table for AreaChart. It is a plain component, so the table lists every prop; the ChartCard around it takes its own props, and the chart works without one.
Takes data, an index and series. You can pick smooth, straight or step outlines, change the fill opacity, and mark series that skip the fill or the outline.
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("area-chart")The full library index for assistants is at /llms.txt.