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

Line chart

Trends per series with a dash pattern and dots per line, so no line depends on hue alone.

Transfer latency (ms)Latency improved from week 38: the 99th percentile fell from 1,390 ms to 905 ms, the median from 190 ms to 158 ms.
Transfer latency (ms): data table
WeekMedian95th percentile99th percentile
W361806201,210
W371765981,150
W381906551,390
W391715701,080
W40165540990
W411685521,020
W42160515940
W43158498905

Install

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

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

Source

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

import { CartesianGrid, Line, LineChart, 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[] = [
  { week: "W36", p50: 180, p95: 620, p99: 1210 },
  { week: "W37", p50: 176, p95: 598, p99: 1150 },
  { week: "W38", p50: 190, p95: 655, p99: 1390 },
  { week: "W39", p50: 171, p95: 570, p99: 1080 },
  { week: "W40", p50: 165, p95: 540, p99: 990 },
  { week: "W41", p50: 168, p95: 552, p99: 1020 },
  { week: "W42", p50: 160, p95: 515, p99: 940 },
  { week: "W43", p50: 158, p95: 498, p99: 905 },
]

const SAMPLE_SERIES: ChartSeries[] = [
  { key: "p50", label: "Median" },
  { key: "p95", label: "95th percentile" },
  { key: "p99", label: "99th percentile" },
]

/** Line chart: a trend per series. Each line has its own dash pattern and dot, so it never depends on hue alone. */
export function ChartLine({
  data = SAMPLE,
  xKey = "week",
  xLabel = "Week",
  series = SAMPLE_SERIES,
  title = "Transfer latency (ms)",
  summary = "Latency improved from week 38: the 99th percentile fell from 1,390 ms to 905 ms, the median from 190 ms to 158 ms.",
  showTable,
  className,
}: {
  xKey?: string
  xLabel?: string
  series?: ChartSeries[]
  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">
        <LineChart 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={44} />
          <ChartTooltip cursor={false} content={<ChartTooltipContent indicator="line" />} />
          <ChartLegend itemSorter={(item) => series.findIndex((s) => s.key === item.dataKey)} content={<ChartLegendContent />} />
          {series.map((s, i) => (
            <Line
              key={s.key}
              dataKey={s.key}
              type="monotone"
              stroke={`var(--color-${s.key})`}
              strokeWidth={2}
              strokeDasharray={seriesDash(i)}
              dot={{ r: 2.5, fill: `var(--color-${s.key})`, strokeWidth: 0 }}
              activeDot={{ r: 4 }}
              isAnimationActive={false}
            />
          ))}
        </LineChart>
      </ChartContainer>
    </ChartFigure>
  )
}