Combo Chart (Bar and Line) for React
A React combo chart that draws bars and lines on one shared y-axis, such as a daily count with its rolling average. Pass data as readonly ChartRow[]: one object per category: the index key plus one number per series key.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/combo-chart.jsonOrders per day
- Orders
- 7-day average
ComboChartComboTablecomboLegendindexSeriesdefaultComboChartLabels- +3 more
Bars and their average
Same unit, one axis. The line draws across the bars once they have grown, with a surface halo so it stays readable where it crosses them.
Orders per day
Last 14 days
- Orders
- 7-day average
import { ChartCard } from "@/components/sheenui/charts/chart-parts/chart-card";
import { comboLegend, ComboTable, ComboChart, type ComboSeries } from "@/components/sheenui/charts/combo-chart";
// Package build (after the first npm release, or a packed tarball): import { ChartCard, comboLegend, ComboTable, ComboChart, type ComboSeries } from "@sheenui/theme";
const data = [
{ day: "Oct 8", orders: 402, average: 371 },
{ day: "Oct 9", orders: 388, average: 376 },
{ day: "Oct 10", orders: 431, average: 384 },
{ day: "Oct 11", orders: 455, average: 395 },
{ day: "Oct 12", orders: 301, average: 389 },
{ day: "Oct 13", orders: 296, average: 382 },
];
const series: ComboSeries[] = [
{ key: "orders", label: "Orders", color: 1, type: "bar" },
{ key: "average", label: "7-day average", color: 2, type: "line" },
];
export function Example() {
return (
<ChartCard
title="Orders per day"
legend={comboLegend(series)}
table={<ComboTable data={data} index="day" series={series} />}
>
<ComboChart data={data} index="day" series={series} aria-label="Orders per day with the 7-day average" />
</ChartCard>
);
}Files to copy
11 folders · 25 files · 4 packages
- From
theme/src/ components/charts/{combo-chart.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-utils.ts}components/charts/chart-parts/components/drawer/parts/sheet.tsxcomponents/kbd/components/menu/components/skeleton/components/status-icons/hooks/{use-controllable.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/combo-chart.jsonRegistry item: combo-chart. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".
Indexed: different units, one axis
Revenue (dollars), users and tickets (counts) can't share a value axis, and two axes would let the chart say anything. indexed rebases every series to 100 at its first value, so the axis reads “how much has each grown?”. The tooltip keeps the actual values.
Growth since November
Indexed to November = 100 for each series
- Revenue
- Active users
- Support tickets
import { ComboChart, type ComboSeries } from "@/components/sheenui/charts/combo-chart";
// Package build (after the first npm release, or a packed tarball): import { ComboChart, type ComboSeries } from "@sheenui/theme";
const data = [
{ month: "Nov", revenue: 184000, users: 8200, tickets: 1300 },
{ month: "Dec", revenue: 195000, users: 8900, tickets: 1340 },
{ month: "Jan", revenue: 201000, users: 9700, tickets: 1390 },
{ month: "Feb", revenue: 212000, users: 10200, tickets: 1360 },
{ month: "Mar", revenue: 224000, users: 11100, tickets: 1430 },
];
const series: ComboSeries[] = [
{ key: "revenue", label: "Revenue", color: 1, type: "bar" },
{ key: "users", label: "Active users", color: 2, type: "line" },
{ key: "tickets", label: "Support tickets", color: 3, type: "line" },
];
export function Example() {
return <ComboChart indexed data={data} index="month" series={series} aria-label="Revenue, users and tickets, indexed to November = 100" />;
}Stacked bars and a target
stacked stacks the bar series; the line is a target in the same unit. The tooltip adds the stack's total.
Customers vs target
- New
- Returning
- Target
import { ComboChart, type ComboSeries } from "@/components/sheenui/charts/combo-chart";
// Package build (after the first npm release, or a packed tarball): import { ComboChart, type ComboSeries } from "@sheenui/theme";
const data = [
{ month: "May", new: 420, returning: 900, target: 1500 },
{ month: "Jun", new: 460, returning: 960, target: 1570 },
{ month: "Jul", new: 495, returning: 1010, target: 1640 },
{ month: "Aug", new: 530, returning: 1080, target: 1710 },
{ month: "Sep", new: 575, returning: 1150, target: 1780 },
];
const series: ComboSeries[] = [
{ key: "new", label: "New", color: 1, type: "bar" },
{ key: "returning", label: "Returning", color: 3, type: "bar" },
{ key: "target", label: "Target", color: 2, type: "line" },
];
export function Example() {
return <ComboChart stacked data={data} index="month" series={series} aria-label="Customers per month against target" />;
}Edge cases
One category still gets a properly sized bar and a dot for the line (a line needs two points); no data keeps the chart's footprint.
One day
- Orders
- 7-day average
No data
No orders yet
import { ComboChart, type ComboSeries } from "@/components/sheenui/charts/combo-chart";
// Package build (after the first npm release, or a packed tarball): import { ComboChart, type ComboSeries } from "@sheenui/theme";
const series: ComboSeries[] = [
{ key: "orders", label: "Orders", color: 1, type: "bar" },
{ key: "average", label: "7-day average", color: 2, type: "line" },
];
export function Example() {
return (
<>
<ComboChart data={[{ day: "Today", orders: 412, average: 388 }]} index="day" series={series} aria-label="Orders today" />
<ComboChart data={[]} index="day" series={series} emptyState="No orders yet" aria-label="Orders per day" />
</>
);
}ComboChart props
ComboChartLabels keys and English defaults (5)
ComboTable props
Keyboard
Accessibility
- The chart is a focusable figure named by its aria-label (the chart title), with a one-line reading hint as its description and, inside a ChartCard with a table view, aria-details pointing at that table; moving through it announces each value politely, once. Each move announces every series' value.
- ComboTable is the table view: pair it with ChartCard's table prop (Chart / Table tabs) so every value can be read without color or sight.
- Reduced motion: the bars and the line appear at their final values and data changes jump instead of morphing.
All exports on this page
ComboChart— Bars and lines on one chart: give each series type: "bar" or type: "line".ComboTable— The table view of a combo chart: the actual values of every series (headed by a swatch for bars, a line key for lines).comboLegend— Legend items for a combo chart: a swatch for bar series, a line key for line series.defaultComboChartLabels— The built-in English strings of ComboChart; spread it into your own labels and change what you need.indexSeries— Rebase each series so its first non-zero value equals base: base + change / |first| x base.
When to use the combo chart
- Use it as a bar and line chart when a volume and a rate belong on one chart, such as orders as bars with a conversion line, or daily signups as bars with their 7-day average as a line.
- Use stacked to stack the bar series, for example revenue split by plan with a target line over it, while the line series keeps its own mark type per series.
- Use indexed when the series have different units, like revenue and sessions: each is rebased to indexBase (default 100) so the chart answers how much each has changed.
- Skip it when every series is the same mark type, where Bar chart or Line chart is simpler, or when you are tempted to add a second y-axis, which this chart deliberately does not offer.
- Pair it with ChartCard and ComboTable, a ChartLegend built with comboLegend to name the bar and line series, and a SegmentedControl that flips indexed on and off.
Frequently asked questions
Related pages
48 charts pages in all: browse them on Charts.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .