Composed Chart
Mix SeriesBar, Line, and Area on one shared time axis (Recharts ComposedChart–style)
Preview
Installation
pnpm dlx shadcn@latest add @bklit/composed-chartUsage
ComposedChart is the time-series shell for mixing marks on one data array and one pair of scales. Use SeriesBar for vertical columns aligned to dates (not the categorical <Bar /> from BarChart, which uses a band scale).
aspectRatio— wide charts (e.g.4 / 1) work for full-width heroes; in narrow cards use3 / 2or2 / 1so the plot stays tall enough to read.barSize,maxBarSize,barGap— parent-level layout forSeriesBargroups (similar to RechartsComposedChartprops). UsebarGap={0}and a highermaxBarSizefor dense daily data so columns read like the 90 days of data bar example.stacked/stackGap— stackSeriesBarsegments in child order at each x (lines and areas are not stacked).SeriesBar— defaultradiusis 0 (square tops). Passradius={4}(or similar) for rounded corners.Line/Area— pass acurvefrom@visx/curve(e.g.curveCatmullRom.alpha(0.42)) to soften paths when you have many daily points (preview + hero use the same curve forrevenueandrunRate).XAxis— for many rows (e.g. daily), usenumTicks={8}(default domain ticks). UsetickMode="data"when you only have a few points (e.g. one column per month) so labels sit on the data.ChartTooltip— for bar-heavy layouts,showCrosshair={false}often looks cleaner because the hover band is already vertical columns.- Hover dimming —
SeriesBarfades non-hovered columns usingtooltipData.index, like grouped bars inBarChart. Tune withfadedOpacityon eachSeriesBar.
Basic example
import {
Area,
ComposedChart,
Grid,
Line,
SeriesBar,
XAxis,
ChartTooltip,
} from "@bklitui/ui/charts";
import { curveCatmullRom } from "@visx/curve";
import { composedDemoData } from "@/lib/composed-demo-data";
const smooth = curveCatmullRom.alpha(0.42);
export default function Example() {
return (
<ComposedChart
aspectRatio="2 / 1"
barGap={0}
data={composedDemoData}
maxBarSize={32}
xDataKey="date"
>
<Grid horizontal />
<Area
curve={smooth}
dataKey="runRate"
fill="var(--chart-4)"
fillOpacity={0.32}
/>
<SeriesBar dataKey="units" fill="var(--chart-3)" radius={4} />
<Line curve={smooth} dataKey="revenue" stroke="var(--chart-1)" />
<ChartTooltip showCrosshair={false} />
<XAxis numTicks={8} />
</ComposedChart>
);
}composedDemoData is 30 daily rows with ISO date strings, one slow wave across the month plus light ripples (kept readable next to dense bars). Outside this monorepo, copy the helpers from apps/web/lib/composed-demo-data.ts into your app.
More examples
See the charts gallery for stacked bars, pattern fills, rounded bars (SeriesBar radius), a lime / amber / red accent composition, and more.
See also
- Line Chart — lines only
- Area Chart — areas only
- Bar Chart — categorical bars with
<Bar />