Composed Chart
ProBars, lines and areas in one plot, with an optional second value axis.
Playground
Composed Charts
| month | Revenue | Profit |
|---|---|---|
| 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 |
Installation
Composed 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 {
ComposedChart,
ComposedChartProps,
ComposedChartVariant,
} from "@wunderui/react/charts"Then use it:
import { ComposedChart } from "@wunderui/react/charts"
const data = [
{ month: "Jan", revenue: 32000, profit: 18000 },
{ month: "Feb", revenue: 41000, profit: 22000 },
{ month: "Mar", revenue: 38000, profit: 27000 },
{ month: "Apr", revenue: 47000, profit: 24000 },
]
export function RevenueAndProfit() {
return (
<ComposedChart
data={data}
index="month"
series={[
{ key: "revenue", label: "Revenue" },
{ key: "profit", label: "Profit" },
]}
label="Revenue and profit"
/>
)
}Expected result: You should see revenue as bars and profit as a line over the same grid, with the months below.
When to use
Use Composed Chart for
- A volume and a rate in one plot (revenue as bars, margin as a line)
- Two measures with different units on two value axes
- A target or a previous period drawn over bars
- A backdrop series such as activity under a line
Use something else for
- Bar Chart for one measure per category
- Line Chart for trends only
- Area Chart for volumes only
- Stacked Chart for the parts of a total
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.
Composed Charts
| month | Revenue | Profit |
|---|---|---|
| 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 |
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.
Revenue
| month | Revenue | Profit |
|---|---|---|
| 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 |
Keyboard interactions
The plot is focusable, so the chart works without a pointer.
- TaborShift+Tab
- 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 category. 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 category.
- Shift+ArrowRightorShift+ArrowLeft
- 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.
- Series types
- Each series can set its own type. Without one, the first series is a bar and the others are lines, or areas in the bar and area variant.
- Second axis
- A series on the right axis is measured on its own scale over the same grid lines. Use it only for a different unit.
- Draw order
- Series are drawn in order, so lines stay on top of bars and areas. A backdrop bar series sits under everything.
- Tooltip
- Each visible series gets a row, in series order. For mixed units, format the number so it reads well for both.
- Loading, empty and error
- Loading shows a shimmering skeleton, empty and error show a centred message, and error adds a Try again button when a retry handler is set. The card never changes height.
- Legend
- A ChartCard shows the series as badges. With two or more, each badge toggles its series off (the last visible one stays on), and a static legend works for roles.
- 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 the width of its container, and a height setting controls the plot. 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.
- Draw-in
- Bars grow from zero while areas and lines wipe in from the left, and each point on a line appears as the line reaches it. It plays the first time the chart is in view, after loading and when the data changes.
- Hover
- The hovered category keeps its strength and the bars and points of the others dim. Lines and areas get a ringed point per series on their own axis.
- Reduced motion
- With reduced motion the chart appears at once. The tooltip, the crosshair and every state still work.
Anatomy
ComposedChart puts bars, lines and areas in one plot. Each series chooses its type and axis, and a second value axis on the right keeps different units readable.
Revenue
| month | Revenue | Profit |
|---|---|---|
| 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 |
- 1
Takes the data, the index key and a list of series. Each series picks bar, line or area and the left or right axis, and a bar series can sit behind the others as a backdrop.
- 2data-slot="chart-plot"
The focusable region. Arrow keys walk the categories; the hover shows a muted band with a bar series, otherwise a crosshair.
- 3data-slot="chart-grid"
One set of grid lines serves both axes. The right axis has its own scale on the same lines, and its labels start at the plot edge so the two never share a label.
- 4data-slot="chart-marks"
Bars grow from zero, areas wipe in and lines draw along their path, with lines always on top. A backdrop bar series sits under the areas and lines.
- data-slot="chart-active"Optional
One ringed point per line or area series on the hovered category, placed on that series' own axis. Bar series show the hover band instead.
- 5data-slot="chart-tooltip"Optional
One row per visible series, in series order. Keep the series in one unit family, or format the number so it reads right in both cases.
- data-slot="chart-message"Optional
The skeleton is bar-shaped when any series is a bar, and line-shaped otherwise.
A table for screen readers with a column per series, plus a live region that announces the active category.
Best practices
- Do
Put the second measure on the right axis only when its unit differs. Say in the card description which series reads against which axis.
- Do
Draw amounts as bars and rates as lines, and stay at three series. Every extra type adds another visual rule to learn.
- Do
Give the right axis its own formatter so labels carry their unit, such as a percent sign. Without one they reuse the left formatter and a rate reads as 3.1k.
- Don’t
Don't use two axes to make unrelated lines look correlated, since rescaling can make any two series follow each other. With no real link, use two charts.
- Don’t
Don't cover bars with an opaque area. Put the bar series behind the others, or use the bar and line pattern, so the bars stay readable.
API reference
One table covers ComposedChart and lists every prop. The ChartCard around it has its own props, and the chart works without one.
Takes the data, the index key and a list of series. Each series picks bar, line or area and the left or right axis, and a bar series can sit behind the others as a backdrop.
| Prop | Type | Default | Description |
|---|---|---|---|
| data required | readonly ChartDatum[] | — | One object per category / point. |
| index required | string | — | Field holding the category label (x axis; y axis for horizontal bars). |
| series required | readonly ComposedSeries[] | — | |
| variant | "bar-line" | "bar-area" | "area-line-dual-axis" | "bar-line-markers" | "bar-line" | Figma variant. Default . |
| valueFormatter | ChartValueFormatter | — | Values in tooltip, labels, table and live region. Default: 42000 → "42k". |
| rightAxisFormatter | (v) => string | — | Labels of the right axis (dual axis). |
| rightAxisDomain | readonly number[] | — | Values that bound the right axis (default: the right-axis series). |
| label | string | — | Accessible name, e.g. the card title. |
| height | number | — | Fixed height of the plot frame in px. Without it the height follows the width (, , ): 220 px on a phone, up to 434 px (the plot of the Figma large card) from about 1130 px wide. |
| state | "ready" | "loading" | "empty" | "error" | — | shows the chart-shaped skeleton, and a message in the plot. |
| hiddenSeries | readonly string[] | — | Series keys that are switched off (legend toggle): drawn faded, dimmed in the tooltip. |
| activeIndex | number | null | — | The active point (hovered or focused) as an index into , to control it yourself. 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. ). New replays it by itself. |
| aspectRatio | number | — | Width ÷ height when is not set. Default 2.6. |
| axisFormatter | ChartValueFormatter | — | Value-axis labels; defaults to . |
| categoryAxis | boolean | — | Category-axis labels (default true). |
| categoryFormatter | (label) => 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). |
| 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; draws them through. |
| includeZero | boolean | — | The value axis starts at 0 (owner rule, default). fits the data (prices, temperatures). |
| maxHeight | number | — | Highest height from . Default 434. |
| minHeight | number | — | Lowest height from . Default 220. |
| onActiveIndexChange | (index) => void | — | Called with the index when the pointer or the arrow keys move to another point, and with 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) => void | — | Called when a drag across the plot or Shift with an arrow key changes the range, and with when Escape or a click clears it. |
| rangeSelectable | boolean | — | Allow selecting a range by dragging or Shift + arrow keys. On when is set. |
| resolution | "auto" | "full" | — | (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 … draws every point and eve… |
| selectedRange | ChartRange | null | — | The selected range as inclusive indices into , to control it yourself. selects nothing. |
| tooltip | boolean | — | Tooltip on hover / keyboard focus. Default true. |
| tooltipTitle | (datum, index) => 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: left of the plot, in the plot above their grid lines (saves the label column on narrow charts). (default) puts them left of the plot at every size; is opt-in. |
| valueAxisSide | "left" | "right" | — | Side of the value axis (vertical charts). 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). |
| valueTicks | readonly number[] | — | Exact value-axis ticks (ascending), e.g. [0, 10000, … 70000]; replaces the nice-step domain. |
| width | number | — | Fixed width instead of filling and measuring the container. |
| xScale | "band" | "time" | — | (default): the categories sit side by side in equal bands. : the 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… |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("composed-chart")The full library index for assistants is at /llms.txt.
Related components
Bar chart, 12 points from Jan to Dec. Revenue from $32.0k to $58.0k, lowest $32.0k, highest $58.0k; Expenses from $18.0k to $35.0k, lowest $18.0k, highest $38.0k. Revenue and expenses, data table month Revenue Expenses Jan $32.0k $18.0k Feb $41.0k $22.0k Mar $38.0k $27.0k Apr $47.0k $24.0k May $44.0k $30.0k Jun $52.0k $28.0k Jul $49.0k $34.0k Aug $55.0k $31.0k Sep $51.0k $36.0k Oct $46.0k $33.0k Nov $53.0k $38.0k Dec $58.0k $35.0k Charts32 stylesProBar ChartBar chart for comparing values: grouped, horizontal, diverging, top-k and highlighted bars, with tooltip, keyboard navigation and a data table.Line chart, 12 points from Jan to Dec. Revenue from $32.0k to $58.0k, lowest $32.0k, highest $58.0k; Expenses from $18.0k to $35.0k, lowest $18.0k, highest $38.0k. Revenue and expenses, data table month Revenue Expenses Jan $32.0k $18.0k Feb $41.0k $22.0k Mar $38.0k $27.0k Apr $47.0k $24.0k May $44.0k $30.0k Jun $52.0k $28.0k Jul $49.0k $34.0k Aug $55.0k $31.0k Sep $51.0k $36.0k Oct $46.0k $33.0k Nov $53.0k $38.0k Dec $58.0k $35.0k Charts27 stylesProLine ChartLine chart for trends over time: smooth lines (straight on request) and stepped lines, comparisons, bands, forecasts and thresholds, with tooltip, keyboard navigation and a data table.Area chart, 12 points from Jan to Dec. Revenue from $32.0k to $58.0k, lowest $32.0k, highest $58.0k; Expenses from $18.0k to $35.0k, lowest $18.0k, highest $38.0k. Area Charts, data table month Revenue Expenses Jan $32.0k $18.0k Feb $41.0k $22.0k Mar $38.0k $27.0k Apr $47.0k $24.0k May $44.0k $30.0k Jun $52.0k $28.0k Jul $49.0k $34.0k Aug $55.0k $31.0k Sep $51.0k $36.0k Oct $46.0k $33.0k Nov $53.0k $38.0k Dec $58.0k $35.0k Charts19 stylesProArea ChartArea chart for volumes over time: gradients, steps, ranges, a horizon graph, differences and target lines.Stacked chart, 12 points from Jan to Dec. Direct from $14.0k to $27.0k, lowest $14.0k, highest $27.0k; Organic from $10.0k to $17.0k, lowest $10.0k, highest $17.0k; Referral from $5.0k to $11.0k, lowest $5.0k, highest $11.0k. Stacked Charts, data table month Direct Organic Referral Jan $14.0k $10.0k $5.0k Feb $18.0k $11.0k $7.0k Mar $16.0k $10.0k $6.0k Apr $20.0k $14.0k $8.0k May $19.0k $13.0k $7.0k Jun $23.0k $15.0k $9.0k Jul $21.0k $14.0k $8.0k Aug $25.0k $16.0k $10.0k Sep $22.0k $15.0k $9.0k Oct $20.0k $13.0k $8.0k Nov $24.0k $16.0k $10.0k Dec $27.0k $17.0k $11.0k Charts13 stylesProStacked ChartStacked chart for the parts of a total: stacked and 100 % columns, stacked areas, diverging Likert bars, Marimekko and gapped rows.