Charts
ComboChart
Combination bar and line chart with optional dual Y-axes, keyboard exploration, and a data table.
import '@reactloom/charts/styles.css';
import { ComboChart } from '@reactloom/charts';Examples
Dual-axis revenue and margin
- Revenue ($k)
- Margin (%)
import { ComboChart } from '@reactloom/charts';
const data = [
{ month: 'Jan', revenue: 120, margin: 18 },
{ month: 'Feb', revenue: 150, margin: 22 },
{ month: 'Mar', revenue: 138, margin: 20 },
{ month: 'Apr', revenue: 174, margin: 25 },
];
export default function Example() {
return (
<ComboChart
title="Quarterly revenue and margin"
data={data}
x="month"
barSeries={[{ key: 'revenue', label: 'Revenue ($k)' }]}
lineSeries={[{ key: 'margin', label: 'Margin (%)' }]}
dualAxis
/>
);
}API reference
| Prop | Type | Default |
|---|---|---|
datarequiredData rows to plot. | readonly Row[] | — |
xrequiredCategory or date accessor. | Accessor<Row, XValue> | — |
barSeriesrequiredSeries rendered as bars. | readonly ChartSeries<Row>[] | — |
lineSeriesrequiredSeries rendered as lines. | readonly ChartSeries<Row>[] | — |
dualAxisRender an independent right Y-axis for lineSeries. | boolean | false |
Keyboard interaction
| Key | Action |
|---|---|
| ArrowLeft / ArrowRight | Move between categories and announce values |
| Home / End | Jump to the first or last category |
Usage guidelines
Do
- Enable dualAxis when bar and line metrics use different units such as dollars and percentages.
Don’t
- Avoid plotting more than three series on each axis.