Combo Chart
Plot bars and lines on one category axis, with an optional second value axis for a different unit.
Overview
Use a combo chart when two related measures share a category axis but answer different questions: an amount drawn as bars, and a rate or trend drawn as a line. Revenue with conversion rate, rainfall with temperature, and tickets opened with tickets resolved are typical pairs.
When the two measures use different units, put the line on a right-hand axis. The right axis picks ticks that land on the left axis's grid lines, so one set of dashed lines serves both scales. Reach for a second axis only when the units really differ: two axes on the same unit invite readers to compare heights that are not comparable.
Anatomy
ComboChart owns the data, the category axis, selection, the brush, and loading. Bar and Line parts add series; each one names the axis it is measured against with yAxisId. Add one YAxis per side you want labelled, and optional Grid, Legend, Tooltip, and Brush parts.
Lines always draw above bars, so a trend is never hidden behind a column. Bars and lines share one axis tooltip that lists every series at the hovered category.
Accessibility
Two axes make a chart harder to read precisely, so name each axis with label or a unit in its tickFormatter, and give the chart a clear ariaLabel. The canvas exposes only that name: pair the chart with a summary or table when readers need exact values. The tooltip, legend toggles, and brush are pointer-operated; do not make them the only way to reach information.
Installation
Usage
import { ComboChart, type ChartConfig } from "honestui/charts";<ComboChart data={data} config={chartConfig} xDataKey="month">
<ComboChart.Grid />
<ComboChart.XAxis />
<ComboChart.YAxis yAxisId="left" tickFormatter={(value) => `$${value / 1000}k`} />
<ComboChart.YAxis yAxisId="right" tickFormatter={(value) => `${value}%`} />
<ComboChart.Legend isClickable />
<ComboChart.Tooltip />
<ComboChart.Bar dataKey="revenue" isClickable />
<ComboChart.Line dataKey="conversion" yAxisId="right" isClickable>
<ComboChart.Dot variant="border" />
</ComboChart.Line>
</ComboChart>Give the tooltip a valueFormatter when the series use different units. It receives the series key, so each row can carry its own unit:
<ComboChart.Tooltip
valueFormatter={(value, key) => (key === "conversion" ? `${value}%` : `$${value}`)}
/>Examples
Stacked Bars
stackType="stacked" stacks every bar series that shares an axis, so the line can show a total, a target, or an outcome against the composition. Lines are never stacked.
Brush
Add ComboChart.Brush to zoom a long series. The preview strip shows the first bar series; dragging the selection filters bars and lines together.
Reference Lines and Comparison
ComboChart.ReferenceLine, ReferenceArea, and ReferenceDot mark targets and periods; they are measured against the left value axis. compareDataKey on a Bar draws last period's value as a tick across the column, and on a Line as a faded dashed line on the same axis as the line. The tooltip adds the earlier value and the change under each compared row. See Reference Lines and Period Comparison.
Synced Crosshair
Charts that share a syncId show their tooltip at the same category when any one of them is hovered, here a candlestick chart above a combo chart of trading activity. Add ComboChart.Zoom to zoom and pan inside the plot; it shares its window with the brush. See Synced Crosshair and Brush and Zoom.
Loading State
isLoading keeps the layout with a neutral bar and line silhouette and the same loading label as the other Honest UI charts.
API Reference
ComboChart.Zoom takes the props listed in Brush and Zoom. The reference parts take the props listed in Reference Lines; a y value is read on the left value axis.