# Composed chart

Bars and lines on one plot, with an optional second value axis, for a figure and its rate.

- Family: charts
- Import: `import { ComposedChart } from "@senvenli/react/charts";`
- Page: https://design.senvenli.com/docs/components/composed-chart
- JSON: https://design.senvenli.com/docs/components/composed-chart.json

## Example: Orders and conversion

A count as bars on the left axis, its rate as a line on the right.

```tsx
import { ComposedChart } from "@senvenli/react/charts";

const MONTHS = [
  { month: "Jan", orders: 1240, conversion: 0.021 },
  { month: "Feb", orders: 1310, conversion: 0.023 },
  { month: "Mar", orders: 1525, conversion: 0.027 },
  { month: "Apr", orders: 1480, conversion: 0.025 },
  { month: "May", orders: 1690, conversion: 0.029 },
  { month: "Jun", orders: 1820, conversion: 0.031 },
];
const count = new Intl.NumberFormat("en");
const percent = new Intl.NumberFormat("en", { style: "percent", maximumFractionDigits: 1 });

export default function Example() {
  return (
    <ComposedChart
      title="Orders and conversion"
      period="Jan–Jun 2026"
      data={MONTHS}
      index="month"
      bars={[{ key: "orders", axis: "left" }]}
      lines={[{ key: "conversion", axis: "right" }]}
      labels={{ orders: "Orders", conversion: "Conversion rate" }}
      valueFormatters={{ left: count.format, right: percent.format }}
    />
  );
}
```

## Examples

### One shared axis

Bars and a line in the same unit read against the same scale.

```tsx
import { ComposedChart } from "@senvenli/react/charts";

const MONTHS = [
  { month: "Jan", revenue: 38200, forecast: 36000 },
  { month: "Feb", revenue: 41500, forecast: 40000 },
  { month: "Mar", revenue: 47900, forecast: 44000 },
  { month: "Apr", revenue: 45100, forecast: 48000 },
  { month: "May", revenue: 52300, forecast: 52000 },
  { month: "Jun", revenue: 56800, forecast: 56000 },
];
const usd = new Intl.NumberFormat("en", { style: "currency", currency: "USD", notation: "compact" });

export default function Example() {
  return (
    <ComposedChart
      title="Revenue against forecast"
      period="Jan–Jun 2026"
      data={MONTHS}
      index="month"
      bars={[{ key: "revenue", axis: "left" }]}
      lines={[{ key: "forecast", axis: "left" }]}
      labels={{ revenue: "Revenue", forecast: "Forecast" }}
      // Both formatters are required; with one axis in use, the right one is never called.
      valueFormatters={{ left: usd.format, right: usd.format }}
    />
  );
}
```

## Guidelines

### When to use it

- A count and a rate over the same periods, e.g. orders and conversion.

### Use something else when

- [bar-chart](https://design.senvenli.com/docs/components/bar-chart.md): Only one kind of mark is needed.
- [line-chart](https://design.senvenli.com/docs/components/line-chart.md): All series are trends over time.

## Accessibility

Built in:

- A "Show as table" button shows the same data as a table, which screen readers get by default.

You provide:

- A title that says what the figure is.

## API reference

### ComposedChart

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| title | `string` |  | no | What the chart shows ("Revenue"), over it; leave it out when a card or a heading already says so. |
| aria-label | `string` |  | no | Names the chart when it has no visible `title` (a card's heading already says what it shows). |
| period | `string` |  | no | The period it covers ("June–September 2026"). |
| total | `React.ReactNode` |  | no | The headline figure, in `metric-medium` ("€ 184,2k"). |
| data | `readonly T[]` |  | yes |  |
| index | `keyof T & string` |  | yes | The x key: the period or category of each row. |
| labels | `Readonly<Partial<Record<string, string>>>` |  | no | Series names by key ("web" → "Website"); the key by default. |
| indexFormatter | `(value: unknown) => string` |  | no | The index label in the tooltip and the table ("August 2026"). |
| indexLabel | `string` |  | no | The index column's header in the data table; "Period" for time charts, "Category" for BarChart. |
| height | `number` |  | no | The plot's height in px; 240 by default. |
| isLoading | `boolean` |  | no |  |
| emptyState | `React.ReactNode` |  | no | Shown instead of the plot when there is no data: an `EmptyState size="small"` or text; "No data" by default. |
| bars | `readonly ComposedSeries<T>[]` |  | yes | Volume: `ds-chart-2` bars. |
| lines | `readonly ComposedSeries<T>[]` |  | yes | Rate: `ds-chart-1` lines with ringed points. |
| valueFormatters | `{ left: ChartValueFormatter; right: ChartValueFormatter; }` |  | yes | One formatter per axis ("124 orders", "€ 54"); put the units in `period` or the title. |

### Tokens it reads

`--ds-background-neutral`, `--ds-border`, `--ds-border-bold`, `--ds-border-focused`, `--ds-chart-1`, `--ds-chart-2`, `--ds-chart-3`, `--ds-chart-4`, `--ds-chart-5`, `--ds-chart-neutral`, `--ds-link`, `--ds-radius-medium`, `--ds-radius-small`, `--ds-radius-xsmall`, `--ds-shadow-overlay`, `--ds-space-050`, `--ds-space-075`, `--ds-space-100`, `--ds-space-150`, `--ds-space-200`, `--ds-space-300`, `--ds-surface-overlay`, `--ds-surface-raised`, `--ds-text`, `--ds-text-danger`, `--ds-text-subtle`, `--ds-text-subtlest`, `--ds-text-success`

## Related

- [bar-chart](https://design.senvenli.com/docs/components/bar-chart.md)
- [line-chart](https://design.senvenli.com/docs/components/line-chart.md)
