shadcn Combo Chart: Bars and a Line Together, Without a Dual Axis
A combo chart puts two measures on the same time periods: usually bars for a volume (orders, signups, revenue) and a line for a rate or average (conversion, average order value, margin). It's one of the most requested additions to shadcn/ui charts: the issue asking for a bar and line combo is still open (shadcn-ui/ui#9716), and the charts gallery has no example.
This guide covers the two kinds of combo chart, which one to build, and how to add one to a shadcn project with one command.
Two kinds of combo chart
The right design depends on one question: do the two measures share a unit?
Same unit (revenue bars with a revenue target line, actual bars with a forecast line): draw both on one axis. Nothing is distorted, because the bar and the line are measured against the same scale. In a shadcn project you can do this with Recharts' ComposedChart inside ChartContainer, or use a line chart with the target as a second series.
Different units (orders and average order value, visitors and conversion rate): don't put them on one plot with two y-axes. A dual axis lets the chart maker choose where the line crosses the bars by stretching either scale, so readers see correlations that are just a choice of axis range. Draw two panels instead, stacked, sharing one x axis and one crosshair. Each measure keeps its own honest scale and bars still start at zero.
Most "combo chart" requests are the second kind: a volume and a rate. That's the case the panels design is for.
Add a combo chart to a shadcn project
ChartslibraryUI's combo chart is free (MIT) and installs through the shadcn CLI like any registry component:
npx shadcn@latest add https://chartslibraryui.com/r/combo-chart.jsonThat adds components/charts/combo-chart.tsx and the shared chart core (React is the only dependency). Import the theme once in your root layout:
import "@/components/charts/core/charts.css";Then use it:
import { ComboChart } from "@/components/charts/combo-chart";
export function OrdersAndAov({ rows }: { rows: { month: string; orders: number; aov: number }[] }) {
return (
<ComboChart
title="The November sale lifted orders without cutting order value much"
subtitle="Orders per month and average order value"
data={rows}
x="month"
top={{ key: "aov", label: "Average order value", format: { kind: "currency", decimals: 2 }, type: "line" }}
bottom={{ key: "orders", label: "Orders", format: "integer", type: "bar" }}
/>
);
}top and bottom each take a key, a label, a format and a type ("line" or "bar"). split sets the share of the height for the top panel (default 0.45).
What you get
- One crosshair across both panels. Hover or use the arrow keys and both values for that period show together.
- Colors from your theme. The chart reads CSS variables, so light and dark mode follow your shadcn theme.
- Missing months stay missing.
nulldraws a gap with a note, never a zero. - A table view and CSV export on the chart, for anyone who wants the exact numbers.
- A title that states the takeaway, with the units in the subtitle.
Choosing the measure for each panel
- Put the measure readers care about most on top.
- Use bars for counts and totals (they're read from zero) and a line for rates, averages and prices.
- If only growth matters, not the levels, index both series to 100 at the start and use an index chart on one axis.
- If you have more than two measures, use small multiples.