# Composed Chart (Lumen Halo): prompt.md (v1.0.0)

- id: `lumen-composed-chart` · version 1.0.0 · component · pro (All-Access)
- category: Charts
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/lumen-composed-chart`
- npm dependencies: recharts@^3
- registry dependencies: utils, @beautiful-ui/lumen-chart, @beautiful-ui/lumen-stat, https://beautiful-ui.dev/r/lumen-foundation.json
- docs: https://beautiful-ui.dev/components/lumen-composed-chart
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

Bars, lines and areas on one time axis, with a second axis when a series needs its own scale and format (currency beside percent), legend toggles, Lumen's tooltip with each series in its own format, and a table for screen readers.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: `recharts@^3`.
- Files: `components/ui/lumen/charts/composed-chart.tsx`, `components/ui/lumen/charts/cartesian.tsx`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `lumen-chart`, `lumen-stat`, `lumen-foundation`.
- Builds: one set of files for both, but its dependencies come in Base UI and Radix builds. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `ComposedChart`, and every exported type.
- CSS: the install merges this item's rules (the registry `css` field) into your global stylesheet, in `@layer components`, and adds the lumen foundation (tokens, keyframes, motion levels) once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--lumen-*` custom properties (`--lumen-accent`, `--lumen-accent-text`, `--lumen-bad`, `--lumen-bad-text`, `--lumen-focus`, `--lumen-good`, `--lumen-good-text`, `--lumen-hairline`, `--lumen-ink`, `--lumen-muted-ink`, `--lumen-series-1`, `--lumen-series-2`, `--lumen-series-3`, `--lumen-series-4`, `--lumen-series-5`, `--lumen-series-6`, `--lumen-warn`, `--lumen-warn-text`); this item's CSS also reads `--lumen-font-mono`, `--lumen-font-sans`, `--lumen-radius-k`. Never add Tailwind colour classes inside the component.

```tsx
import { ComposedChart } from "@/components/ui/lumen/charts/composed-chart";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `ComposedChart` | — | The plot, legend, tooltip, references, states, summary and table. |

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `GlassSoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/glass-sound.json`, import from `@/components/beautiful-ui/glass-sound`); `GlassSoundToggle` is its mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/lumen/charts/composed-chart.tsx`, `components/ui/lumen/charts/cartesian.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- composed chart, combo chart, bar and line, dual axis, revenue and margin, Recharts, Lumen
- Two related measures with different units over the same periods

### Not when
- Two measures with the same unit: one Line or Bar chart
- More than two scales: split into small multiples

## Mistakes
- Keep config and data stable (outside the component, or memoised)
- Give series colours through config (var(--chart-N) or theme), not inline

## Usage

```tsx
import { ComposedChart } from "@/components/ui/lumen/charts/composed-chart";

<ComposedChart data={weeks} x="week" config={config} layers={[{ key: "revenue", as: "bar" }, { key: "margin", as: "line", axis: "right" }]} valueFormat={{ style: "currency" }} rightFormat={{ style: "percent" }} />
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `layers` | `{ key, as: "bar" \| "line" \| "area", axis?: "left" \| "right", dashed? }[]` |  | How each series is drawn, back to front, and on which axis. |
| `rightFormat` | `StatFormat \| (n) => string` |  | The right axis's format, used for its series everywhere. |
| `data / x` | `Row[] / keyof Row` |  | Rows as they are (your own Recharts children see every field) and the field for the x axis. |
| `config` | `ChartConfig` |  | shadcn's shape: one entry per series with label and color or theme { light, dark }. |
| `series` | `string[]` |  | Which config keys to draw, in order. Default: all. |
| `valueFormat / formats` | `StatFormat \| (n) => string` |  | valueFormat formats the value axis, tooltip, table and summary (Intl). formats sets a different one per series for the tooltip, table and summary; the axis keeps valueFormat (Composed: rightFormat for the right axis). In percent stacking the chart plots shares, so extra Recharts children see shares, not raw values. |
| `xFormat / xLabel` | `(v) => string / string` |  | How x values read, and the x axis's name in the table. |
| `height` | `number` | `280` | Plot height in px; the width follows the container. |
| `grid / axes` | `"horizontal" \| "vertical" \| "both" \| "none" / { x?, y? }` | `"horizontal"` | Grid lines and which axes show. |
| `yDomain` | `"zero" \| "fit" \| [number, number]` | `"zero"` | The value axis's range: from zero, fitted to the data (rates and slow-moving levels, where zero hides every change), or fixed. |
| `legend` | `"toggle" \| "static" \| "none"` | `"toggle" with 2+ series` | Toggle buttons hide and show series; the last visible one can't be hidden. |
| `tooltip` | `boolean` | `true` | Lumen's glass tooltip with each series' value. |
| `references` | `{ y?, x?, label, tone? }[]` |  | Labelled reference lines: targets, limits, launches. |
| `motion` | `"full" \| "subtle" \| "off"` | `"full"` | Reduced motion always wins. |
| `loading / error / emptyText` | `boolean / string / string` |  | States in words, with the plot's height held. |
| `label` | `string` |  | Names the chart for assistive tech and its table. |
| `children` | `Recharts elements` |  | Your own lines, reference areas or labels, drawn with the rest. |

Full docs: https://beautiful-ui.dev/components/lumen-composed-chart

## Customising
- Motion: `motion="full"` (default) | `"subtle"` | `"off"`. prefers-reduced-motion is always respected.
- Colours: set the `--lumen-*` tokens on `:root`, or on a container with the `lumen-scope` class to retheme one area. Add the `lumen-inherit` class to follow your shadcn palette instead (`--chart-N`, `--destructive`).
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| Tab | Focus the chart, then the legend |
| ← / → | Move between points; the tooltip follows |
| Enter / Space | Toggle a focused legend entry |

## Motion inventory

| Interaction | What moves |
|---|---|
| Draw | Bars grow and lines draw in together |

## Accessibility contract (preserve when editing)
- A labelled figure; Recharts' accessibility layer lets arrow keys walk the points with the tooltip following
- A one-sentence summary (ranges, highs and lows per series) and the full data table for screen readers
- Legend toggles are buttons with a pressed state; the last visible series can't be hidden
- Errors and empty data are said in words

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/lumen-composed-chart
```

Pro item: needs the `@beautiful-ui-pro` registry in `components.json` and `BEAUTIFUL_UI_TOKEN` in `.env.local` (https://beautiful-ui.dev/account). Setup: https://beautiful-ui.dev/docs/pro. Your components.json `style` picks the build: radix-*, new-york and default get Radix, base-* gets Base UI.

## Credits
- Recharts (https://recharts.org)
- shadcn/ui charts (https://ui.shadcn.com/charts)

The lumen foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://beautiful-ui.dev/r/lumen-foundation.json.
