Installation
Usage
"use client"
import { ComposedChart } from "@/components/composed-chart"
export function Growth() {
return (
<ComposedChart
title="Revenue and conversion"
data={[
{ label: "Jan", revenue: 18000, rate: 2.1 },
{ label: "Feb", revenue: 21000, rate: 2.4 },
{ label: "Mar", revenue: 26000, rate: 2.9 },
]}
series={[
{ key: "revenue", label: "Revenue", type: "bar" },
{ key: "rate", label: "Conversion", type: "line", axis: "right" },
]}
formatRight={(n) => `${n}%`}
/>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| data | { label: string; [key]: number }[] | — | One entry per category. |
| series | { key; label; type; axis?; color? }[] | — | Each is a bar, line or area, on the left or right axis. |
| title | string | — | Names the chart and its data table. |
| showTitle | boolean | true | Show the title above the chart. |
| format / formatRight | (value: number) => string | — | Formats each axis, the tooltip and the table. |
| formatOptions / locale | Intl.NumberFormatOptions / string | compact, visitor's locale | Number format without a function. |
| height | number | 260 | Plot height in pixels. |
| toggleable | boolean | true | Let people hide a series from the legend. |
Accessibility
- A labelled <figure>; the full data is also available as a visually hidden table.
- Tab enters the chart; arrow keys and Home/End move between categories, each announced with all its values.
- Legend entries are buttons that report whether their series is shown.
- Bars and lines appear without moving under prefers-reduced-motion.
Changelog
- v1.0.0Latest
First release.