jengacore.shadcn registry · Tailwind v4 · Radix and Base UI
Components
Charts and graphs · @jengacore/chart-bar

Bar chart

Grouped or stacked bars; stacked segments are split by a card-coloured gap so colours never touch.

Payments by channel (thousands)Wallet payments grew every month, from 240 thousand in May to 389 thousand in October; card and bank grew more slowly.
Payments by channel (thousands): data table
MonthWalletCardBank transfer
May24018296
Jun262205104
Jul30119899
Aug334221118
Sep352236121
Oct389248130
Payments by channel, stacked (thousands)Total payments rose from 518 thousand in May to 767 thousand in October; wallet is about half of every month.
Payments by channel, stacked (thousands): data table
MonthWalletCardBank transfer
May24018296
Jun262205104
Jul30119899
Aug334221118
Sep352236121
Oct389248130

Install

terminal
npx shadcn@latest add @jengacore/chart-bar

Without the namespace configured: npx shadcn@latest add https://ui.jengacore.com/r/<new-york-v4|base-nova>/chart-bar.json

Source

components/blocks/chart-bar.tsx
"use client"

import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts"

import { ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent } from "@/components/ui/chart"
import { ChartFigure, type ChartCopy, seriesConfig, type ChartSeries } from "@/components/jc/chart-figure"

type Row = Record<string, string | number>

const SAMPLE: Row[] = [
  { month: "May", card: 182, wallet: 240, bank: 96 },
  { month: "Jun", card: 205, wallet: 262, bank: 104 },
  { month: "Jul", card: 198, wallet: 301, bank: 99 },
  { month: "Aug", card: 221, wallet: 334, bank: 118 },
  { month: "Sep", card: 236, wallet: 352, bank: 121 },
  { month: "Oct", card: 248, wallet: 389, bank: 130 },
]

const SAMPLE_SERIES: ChartSeries[] = [
  { key: "wallet", label: "Wallet" },
  { key: "card", label: "Card" },
  { key: "bank", label: "Bank transfer" },
]

/**
 * Bar chart, grouped (compare series within a period) or stacked (compare totals and their make-up). Stacked
 * segments are separated by a card-coloured gap, so neighbouring colours never touch.
 */
export function ChartBar({
  data = SAMPLE,
  xKey = "month",
  xLabel = "Month",
  series = SAMPLE_SERIES,
  title = "Payments by channel (thousands)",
  summary = "Wallet payments grew every month, from 240 thousand in May to 389 thousand in October; card and bank grew more slowly.",
  stacked = false,
  showTable,
  className,
}: {
  xKey?: string
  xLabel?: string
  series?: ChartSeries[]
  stacked?: boolean
  showTable?: boolean
  className?: string
} & ChartCopy<Row[]>) {
  const config = seriesConfig(series)
  const last = series.length - 1
  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">
        <BarChart 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 content={<ChartTooltipContent />} />
          <ChartLegend itemSorter={(item) => series.findIndex((s) => s.key === item.dataKey)} content={<ChartLegendContent />} />
          {series.map((s, i) => (
            <Bar
              key={s.key}
              dataKey={s.key}
              stackId={stacked ? "a" : undefined}
              fill={`var(--color-${s.key})`}
              stroke="var(--card)"
              strokeWidth={stacked ? 1 : 0}
              radius={stacked ? (i === last ? [3, 3, 0, 0] : 0) : 2}
              isAnimationActive={false}
            />
          ))}
        </BarChart>
      </ChartContainer>
    </ChartFigure>
  )
}