Examples

Dual-axis revenue and margin

Preview
Quarterly revenue and marginCombination chart with 4 categories across 1 bar series and 1 line series.
  • Revenue ($k)
  • Margin (%)
Use the arrow keys to move between data points, Home and End to jump to the first and last.
Example.tsx
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

ComboChart props
PropTypeDefault
datarequired
Data rows to plot.
readonly Row[]—
xrequired
Category or date accessor.
Accessor<Row, XValue>—
barSeriesrequired
Series rendered as bars.
readonly ChartSeries<Row>[]—
lineSeriesrequired
Series rendered as lines.
readonly ChartSeries<Row>[]—
dualAxis
Render an independent right Y-axis for lineSeries.
booleanfalse

Keyboard interaction

Keyboard interactions
KeyAction
ArrowLeft / ArrowRightMove between categories and announce values
Home / EndJump 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.