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 }}
/>
);
}import { ComposedChart } from "@senvenli/react/charts";Examples
Guidelines
When to use it
- A count and a rate over the same periods, e.g. orders and conversion.
Use something else when
- Only one kind of mark is needed. Bar chart
- All series are trends over time. Line chart
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 | Description |
|---|---|---|---|
title | string | – | What the chart shows ("Revenue"), over it; leave it out when a card or a heading already says so. |
aria-label | string | – | Names the chart when it has no visible |
period | string | – | The period it covers ("June–September 2026"). |
total | React.ReactNode | – | The headline figure, in |
dataRequired | readonly T[] | – | |
indexRequired | keyof T & string | – | The x key: the period or category of each row. |
labels | Readonly<Partial<Record<string, string>>> | – | Series names by key ("web" → "Website"); the key by default. |
indexFormatter | (value: unknown) => string | – | The index label in the tooltip and the table ("August 2026"). |
indexLabel | string | – | The index column's header in the data table; "Period" for time charts, "Category" for BarChart. |
height | number | – | The plot's height in px; 240 by default. |
isLoading | boolean | – | |
emptyState | React.ReactNode | – | Shown instead of the plot when there is no data: an |
barsRequired | readonly ComposedSeries<T>[] | – | Volume: |
linesRequired | readonly ComposedSeries<T>[] | – | Rate: |
valueFormattersRequired | { left: ChartValueFormatter; right: ChartValueFormatter; } | – | One formatter per axis ("124 orders", "€ 54"); put the units in |
titlestringWhat the chart shows ("Revenue"), over it; leave it out when a card or a heading already says so.
aria-labelstringNames the chart when it has no visible
title(a card's heading already says what it shows).periodstringThe period it covers ("June–September 2026").
totalReact.ReactNodeThe headline figure, in
metric-medium("€ 184,2k").dataRequiredreadonly T[]indexRequiredkeyof T & stringThe x key: the period or category of each row.
labelsReadonly<Partial<Record<string, string>>>Series names by key ("web" → "Website"); the key by default.
indexFormatter(value: unknown) => stringThe index label in the tooltip and the table ("August 2026").
indexLabelstringThe index column's header in the data table; "Period" for time charts, "Category" for BarChart.
heightnumberThe plot's height in px; 240 by default.
isLoadingbooleanemptyStateReact.ReactNodeShown instead of the plot when there is no data: an
EmptyState size="small"or text; "No data" by default.barsRequiredreadonly ComposedSeries<T>[]Volume:
ds-chart-2bars.linesRequiredreadonly ComposedSeries<T>[]Rate:
ds-chart-1lines with ringed points.valueFormattersRequired{ left: ChartValueFormatter; right: ChartValueFormatter; }One formatter per axis ("124 orders", "€ 54"); put the units in
periodor the title.