Charts and graphs · @jengacore/chart-area
Area chart
Volume over time: translucent areas, each outline in its own dash pattern; stacked on request.
Transfers per daySettled transfers peak on Friday at 520 and fall by half over the weekend; pending follows the same shape.
| Day | Settled | Pending |
|---|---|---|
| Mon | 412 | 96 |
| Tue | 438 | 88 |
| Wed | 455 | 121 |
| Thu | 471 | 104 |
| Fri | 520 | 132 |
| Sat | 301 | 58 |
| Sun | 266 | 41 |
Install
terminal
npx shadcn@latest add @jengacore/chart-areaWithout the namespace configured: npx shadcn@latest add https://ui.jengacore.com/r/<new-york-v4|base-nova>/chart-area.json
Registry dependencies
Source
components/blocks/chart-area.tsx
"use client"
import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts"
import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"
import { ChartFigure, type ChartCopy, seriesConfig, seriesDash, type ChartSeries } from "@/components/jc/chart-figure"
type Row = Record<string, string | number>
const SAMPLE: Row[] = [
{ day: "Mon", settled: 412, pending: 96 },
{ day: "Tue", settled: 438, pending: 88 },
{ day: "Wed", settled: 455, pending: 121 },
{ day: "Thu", settled: 471, pending: 104 },
{ day: "Fri", settled: 520, pending: 132 },
{ day: "Sat", settled: 301, pending: 58 },
{ day: "Sun", settled: 266, pending: 41 },
]
const SAMPLE_SERIES: ChartSeries[] = [
{ key: "settled", label: "Settled" },
{ key: "pending", label: "Pending" },
]
/** Area chart: volume over time, one translucent area per series, each outline in its own dash pattern. */
export function ChartArea({
data = SAMPLE,
xKey = "day",
xLabel = "Day",
series = SAMPLE_SERIES,
title = "Transfers per day",
summary = "Settled transfers peak on Friday at 520 and fall by half over the weekend; pending follows the same shape.",
stacked = false,
showTable,
className,
}: {
xKey?: string
xLabel?: string
series?: ChartSeries[]
stacked?: boolean
showTable?: boolean
className?: string
} & ChartCopy<Row[]>) {
const config = seriesConfig(series)
return (
<ChartFigure
title={title}
summary={summary}
data={data}
columns={[{ key: xKey, label: xLabel }, ...series.map((s) => ({ key: s.key, label: s.label }))]}
showTable={showTable}
className={className}
>
<ChartContainer config={config} className="aspect-auto h-64 w-full">
<AreaChart data={data} accessibilityLayer title={title} margin={{ left: 4, right: 12, top: 8 }}>
<CartesianGrid vertical={false} />
<XAxis dataKey={xKey} tickLine={false} axisLine={false} tickMargin={8} />
<YAxis tickLine={false} axisLine={false} width={40} />
<ChartTooltip cursor={false} content={<ChartTooltipContent indicator="line" />} />
<ChartLegend itemSorter={(item) => series.findIndex((s) => s.key === item.dataKey)} content={<ChartLegendContent />} />
{series.map((s, i) => (
<Area
key={s.key}
dataKey={s.key}
type="monotone"
stackId={stacked ? "a" : undefined}
fill={`var(--color-${s.key})`}
fillOpacity={0.18}
stroke={`var(--color-${s.key})`}
strokeWidth={2}
strokeDasharray={seriesDash(i)}
isAnimationActive={false}
/>
))}
</AreaChart>
</ChartContainer>
</ChartFigure>
)
}