{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "area-chart",
  "title": "Area chart",
  "description": "Area chart that draws its line in on view, morphs between 1W / 1M / 1Y ranges, and rolls its headline value as a hairline and tooltip follow the pointer or the arrow keys.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json",
    "https://goodui.dev/r/number-flow.json"
  ],
  "files": [
    {
      "path": "registry/components/charts/area-chart.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { AnimatePresence, LayoutGroup, motion, useReducedMotion } from \"motion/react\"\nimport { cn } from \"@/lib/utils\"\nimport { NumberFlow } from \"@/components/goodui/number-flow\"\nimport { useLabels } from \"@/lib/goodui-locale\"\nimport { GooduiTokens, spring } from \"@/lib/goodui-motion\"\n\n/* Mono film grain, tiled through an SVG pattern over the area fill. */\nconst GRAIN = `data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%' height='100%' filter='url(#n)'/></svg>`)}`\n\nconst CSS = `\n.pc-area-chart-delta{--pc-d:var(--muted-foreground);color:color-mix(in oklab,var(--pc-d) 75%,var(--foreground));background:color-mix(in oklab,var(--pc-d) 13%,transparent);transition:color .2s ease,background-color .2s ease}\n.pc-area-chart-delta[data-trend=good]{--pc-d:oklch(0.53 0.13 155)}\n.pc-area-chart-delta[data-trend=bad]{--pc-d:oklch(0.56 0.21 27)}\n.dark .pc-area-chart-delta[data-trend=good]{--pc-d:oklch(0.72 0.16 155)}\n.dark .pc-area-chart-delta[data-trend=bad]{--pc-d:oklch(0.7 0.19 25)}\n.pc-area-chart-line{filter:drop-shadow(0 3px 6px color-mix(in oklab,var(--pc-area-c) 35%,transparent))}\n@keyframes pc-area-chart-ping{0%{transform:scale(1);opacity:.45}80%,100%{transform:scale(2.8);opacity:0}}\n.pc-area-chart-ping{transform-box:fill-box;transform-origin:center;animation:pc-area-chart-ping 2.4s var(--pc-ease-out) infinite}\n@media (prefers-reduced-motion:reduce){.pc-area-chart-ping{animation:none;opacity:0}}\n`\n\nconst CHANGE_FORMAT: Intl.NumberFormatOptions = { maximumFractionDigits: 1 }\n\nexport type AreaPoint = { label: string; value: number }\nexport type AreaRange = { key: string; label: string; data: AreaPoint[] }\n\nexport type AreaChartLabels = {\n  /** Screen reader summary of the plot; `name` is the title when it is a string. */\n  summary: (name: string, first: string, last: string, low: string, high: string) => string\n  /** Announced while scrubbing. */\n  point: (label: string, value: string) => string\n  /** Accessible name of the range picker. */\n  range: string\n  /** Column headers of the screen reader table. */\n  columnLabel: string\n  columnValue: string\n  noData: string\n}\nconst DEFAULT_LABELS: AreaChartLabels = {\n  summary: (name, first, last, low, high) => `${name ? name + \": \" : \"\"}from ${first} to ${last}, low ${low}, high ${high}`,\n  point: (label, value) => `${label}: ${value}`,\n  range: \"Time range\",\n  columnLabel: \"Period\",\n  columnValue: \"Value\",\n  noData: \"No data\",\n}\n\nexport type AreaChartProps = Omit<React.ComponentProps<\"div\">, \"title\"> & {\n  /** Points in order, oldest first. Changing them morphs the curve to the new shape. */\n  data?: AreaPoint[]\n  /** Named data sets with a built-in picker (1W / 1M / 1Y); the curve morphs between them. Takes precedence over data. */\n  ranges?: AreaRange[]\n  /** Selected range key (controlled). */\n  range?: string\n  /** Initial range key when uncontrolled; defaults to the first. */\n  defaultRange?: string\n  onRangeChange?: (key: string) => void\n  /** Metric name above the headline, e.g. \"Revenue\". */\n  title?: React.ReactNode\n  /** What the rolling headline shows while nobody is scrubbing: the sum, the latest point, the average, or nothing. */\n  headline?: \"total\" | \"last\" | \"average\" | \"none\"\n  /** Pill with the change from the first point, following the scrub position. Its arrow flips when the sign does. */\n  showChange?: boolean\n  /** A drop is good news (no-shows, wait time): swaps the pill's colors. */\n  invertChange?: boolean\n  /** Film grain over the gradient fill. */\n  grain?: boolean\n  /** Muted text beside the headline, replaced by the hovered point's label while scrubbing. */\n  description?: React.ReactNode\n  /** Any CSS color for the line and gradient. Defaults to the theme's first chart color. */\n  color?: string\n  /** Plot height in px, axes included. The width follows the container. */\n  height?: number\n  /** smooth: monotone curve that never overshoots the data. linear: straight segments. */\n  curve?: \"smooth\" | \"linear\"\n  /** Horizontal hairline gridlines. */\n  grid?: boolean\n  /** Value ticks on the start side. */\n  axis?: boolean\n  /** Space reserved for the value ticks, in px. */\n  axisWidth?: number\n  /** Intl.NumberFormat options for the headline, tooltip and ticks, e.g. { style: \"currency\", currency: \"USD\" }. */\n  format?: Intl.NumberFormatOptions\n  locale?: string\n  /** Replaces the default formatter for the tooltip, table and screen readers. */\n  formatValue?: (value: number) => string\n  /** Replaces the default tick formatter (compact above 10,000). */\n  formatTick?: (value: number) => string\n  /** Resampled points along the curve; a constant count is what lets 7 and 365 points morph into each other. */\n  samples?: number\n  /** Seconds the line takes to draw in. */\n  duration?: number\n  /** Text for built-in controls and screen readers; pass translations here. */\n  labels?: Partial<AreaChartLabels>\n}\n\n// Reduced motion is read after mount, so the first client render matches the server.\nfunction useReduce() {\n  const prefers = useReducedMotion()\n  const [mounted, setMounted] = React.useState(false)\n  React.useEffect(() => setMounted(true), [])\n  return mounted && !!prefers\n}\n\n// True once the element has been at least `threshold` visible; the entrance plays from then on.\nfunction useInView(ref: React.RefObject<Element | null>, threshold = 0.2) {\n  const [inView, setInView] = React.useState(false)\n  React.useEffect(() => {\n    const el = ref.current\n    if (!el || inView) return\n    if (typeof IntersectionObserver === \"undefined\") {\n      setInView(true)\n      return\n    }\n    const io = new IntersectionObserver(\n      ([e]) => {\n        if (e?.isIntersecting) {\n          setInView(true)\n          io.disconnect()\n        }\n      },\n      { threshold },\n    )\n    io.observe(el)\n    return () => io.disconnect()\n  }, [ref, inView, threshold])\n  return inView\n}\n\n// Measured before paint; null until then so the server and the first client render both show an empty plot.\nfunction useWidth(ref: React.RefObject<HTMLElement | null>) {\n  const [width, setWidth] = React.useState<number | null>(null)\n  React.useLayoutEffect(() => {\n    const el = ref.current\n    if (!el) return\n    // A hidden parent (display:none) measures 0: keep the last real width instead of collapsing the chart.\n    const measure = () => {\n      const w = Math.round(el.clientWidth)\n      if (w > 0) setWidth(Math.max(120, w))\n    }\n    measure()\n    const ro = new ResizeObserver(measure)\n    ro.observe(el)\n    return () => ro.disconnect()\n  }, [ref])\n  return width\n}\n\n/** Round ticks (1, 2, 2.5, 5 × 10^n) covering lo..hi. */\nfunction niceTicks(lo: number, hi: number, count = 4): number[] {\n  if (hi <= lo) hi = lo + 1\n  const raw = (hi - lo) / count\n  const mag = 10 ** Math.floor(Math.log10(raw))\n  const norm = raw / mag\n  const step = (norm <= 1 ? 1 : norm <= 2 ? 2 : norm <= 2.5 ? 2.5 : norm <= 5 ? 5 : 10) * mag\n  const start = Math.floor(lo / step) * step\n  const end = Math.ceil(hi / step) * step\n  const ticks: number[] = []\n  for (let v = start; v <= end + step / 2; v += step) ticks.push(Number(v.toFixed(10)))\n  return ticks\n}\n\n/**\n * Samples the series at `n` evenly spaced positions: monotone cubic (Fritsch–Carlson, no overshoot) or linear.\n * Every data set becomes a path with the same number of points, so motion can morph one into the next.\n */\nfunction sampleCurve(values: number[], n: number, smooth: boolean): number[] {\n  const len = values.length\n  if (len === 0) return []\n  if (len === 1) return Array.from({ length: n }, () => values[0] ?? 0)\n  // Tangents on unit spacing; every index below stays in range (len >= 2).\n  const d: number[] = []\n  for (let i = 0; i < len - 1; i++) d.push((values[i + 1] ?? 0) - (values[i] ?? 0))\n  const m: number[] = [d[0] ?? 0]\n  for (let i = 1; i < len - 1; i++) {\n    const a = d[i - 1] ?? 0\n    const b = d[i] ?? 0\n    m.push(a * b <= 0 ? 0 : (a + b) / 2)\n  }\n  m.push(d[len - 2] ?? 0)\n  for (let i = 0; i < len - 1; i++) {\n    const di = d[i] ?? 0\n    if (di === 0) {\n      m[i] = 0\n      m[i + 1] = 0\n      continue\n    }\n    const a = (m[i] ?? 0) / di\n    const b = (m[i + 1] ?? 0) / di\n    const s = a * a + b * b\n    if (s > 9) {\n      const k = 3 / Math.sqrt(s)\n      m[i] = k * a * di\n      m[i + 1] = k * b * di\n    }\n  }\n  const out: number[] = []\n  for (let i = 0; i < n; i++) {\n    const t = (i / (n - 1)) * (len - 1)\n    const k = Math.min(len - 2, Math.floor(t))\n    const u = t - k\n    const y0 = values[k] ?? 0\n    const y1 = values[k + 1] ?? 0\n    if (!smooth) {\n      out.push(y0 + (y1 - y0) * u)\n      continue\n    }\n    const u2 = u * u\n    const u3 = u2 * u\n    out.push((2 * u3 - 3 * u2 + 1) * y0 + (u3 - 2 * u2 + u) * (m[k] ?? 0) + (-2 * u3 + 3 * u2) * y1 + (u3 - u2) * (m[k + 1] ?? 0))\n  }\n  return out\n}\n\n/** Area chart that draws in on view, morphs between ranges, and rolls its headline while you scrub with the pointer or arrow keys. */\nexport function AreaChart({\n  data: dataProp,\n  ranges,\n  range: rangeProp,\n  defaultRange,\n  onRangeChange,\n  title,\n  headline = \"total\",\n  showChange = true,\n  invertChange = false,\n  grain = true,\n  description,\n  color = \"var(--chart-1)\",\n  height = 220,\n  curve = \"smooth\",\n  grid = true,\n  axis = true,\n  axisWidth = 44,\n  format,\n  locale = \"en-US\",\n  formatValue,\n  formatTick,\n  samples = 160,\n  duration = 1.1,\n  labels,\n  className,\n  \"aria-label\": ariaLabel,\n  ...props\n}: AreaChartProps) {\n  const l = useLabels(\"area-chart\", DEFAULT_LABELS, labels)\n  const reduce = useReduce()\n  const rootRef = React.useRef<HTMLDivElement>(null)\n  const plotRef = React.useRef<HTMLDivElement>(null)\n  const inView = useInView(rootRef)\n  const width = useWidth(plotRef)\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\")\n  const [innerRange, setInnerRange] = React.useState(defaultRange ?? ranges?.[0]?.key ?? \"\")\n  const rangeKey = rangeProp ?? innerRange\n  const data = React.useMemo(() => (ranges ? ((ranges.find((r) => r.key === rangeKey) ?? ranges[0])?.data ?? []) : (dataProp ?? [])), [ranges, rangeKey, dataProp])\n  const [active, setActive] = React.useState<number | null>(null)\n  const signature = data.map((d) => d.value).join(\",\")\n  // A new data set clears the scrub position; the hairline would otherwise point at a value that no longer exists.\n  const [seen, setSeen] = React.useState(signature)\n  if (seen !== signature) {\n    setSeen(signature)\n    setActive(null)\n  }\n\n  const fmt = React.useMemo(() => formatValue ?? ((v: number) => new Intl.NumberFormat(locale, format).format(v)), [formatValue, locale, format])\n  const n = data.length\n  const values = data.map((d) => d.value)\n  const min = n ? Math.min(...values) : 0\n  const max = n ? Math.max(...values) : 0\n  const ticks = niceTicks(Math.min(0, min), Math.max(0, max), 4)\n  const bottom = ticks[0] ?? 0\n  const top = ticks[ticks.length - 1] ?? 1\n  const tick = React.useMemo(() => {\n    if (formatTick) return formatTick\n    const compact = Math.max(Math.abs(top), Math.abs(bottom)) >= 10000\n    const f = new Intl.NumberFormat(locale, compact ? { ...format, notation: \"compact\", maximumFractionDigits: Math.max(1, format?.minimumFractionDigits ?? 0) } : format)\n    return (v: number) => f.format(v)\n  }, [formatTick, locale, format, top, bottom])\n\n  const W = width ?? 0\n  const padL = axis ? axisWidth : 6\n  const padR = 10\n  const padT = 12\n  const padB = 24\n  const plotW = Math.max(10, W - padL - padR)\n  const plotH = Math.max(10, height - padT - padB)\n  const yOf = (v: number) => padT + (1 - (v - bottom) / (top - bottom || 1)) * plotH\n  const xOf = (i: number) => padL + (n > 1 ? (i / (n - 1)) * plotW : plotW / 2)\n  const ys = React.useMemo(() => sampleCurve(values, samples, curve === \"smooth\"), [signature, samples, curve]) // eslint-disable-line react-hooks/exhaustive-deps\n  const linePath = ys.map((v, i) => `${i ? \"L\" : \"M\"}${(padL + (i / (samples - 1)) * plotW).toFixed(1)},${yOf(v).toFixed(1)}`).join(\"\")\n  const base = (padT + plotH).toFixed(1)\n  const areaPath = linePath ? `${linePath}L${(padL + plotW).toFixed(1)},${base}L${padL.toFixed(1)},${base}Z` : \"\"\n\n  // Which x labels fit: every k-th, always the first, and the last when there is room for it.\n  const xLabels: number[] = []\n  if (n > 0) {\n    const step = Math.max(1, Math.ceil(n / Math.max(2, Math.floor(plotW / 64))))\n    for (let i = 0; i < n; i += step) xLabels.push(i)\n    const lastShown = xLabels[xLabels.length - 1] ?? 0\n    if (n > 1 && lastShown !== n - 1) {\n      // The last label is always shown; it replaces the previous one when the two would touch.\n      if (((n - 1 - lastShown) * plotW) / (n - 1) >= 56) xLabels.push(n - 1)\n      else xLabels[xLabels.length - 1] = n - 1\n    }\n  }\n\n  const total = values.reduce((s, v) => s + v, 0)\n  const resting = headline === \"total\" ? total : headline === \"last\" ? (values[n - 1] ?? 0) : headline === \"average\" ? (n ? total / n : 0) : 0\n  const activePoint = active !== null ? data[active] : undefined\n  const shownValue = activePoint ? activePoint.value : resting\n  const name = typeof title === \"string\" ? title : \"\"\n  const summary = ariaLabel ?? (n ? l.summary(name, fmt(values[0] ?? 0), fmt(values[n - 1] ?? 0), fmt(min), fmt(max)) : l.noData)\n\n  const firstValue = values[0] ?? 0\n  const change = n > 1 && firstValue !== 0 ? (((activePoint ? activePoint.value : (values[n - 1] ?? 0)) - firstValue) / Math.abs(firstValue)) * 100 : 0\n  const changeTrend = change === 0 ? \"flat\" : change > 0 !== invertChange ? \"good\" : \"bad\"\n\n  const select = (key: string) => {\n    if (rangeProp === undefined) setInnerRange(key)\n    onRangeChange?.(key)\n  }\n\n  const indexAt = (clientX: number) => {\n    const rect = plotRef.current?.getBoundingClientRect()\n    if (!rect || n === 0) return null\n    if (n === 1) return 0\n    return Math.min(n - 1, Math.max(0, Math.round((clientX - rect.left - padL) / (plotW / (n - 1)))))\n  }\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    if (n === 0) return\n    if (e.key === \"ArrowLeft\" || e.key === \"ArrowRight\") {\n      e.preventDefault()\n      const dir = e.key === \"ArrowLeft\" ? -1 : 1\n      setActive((i) => Math.min(n - 1, Math.max(0, (i ?? n - 1) + dir)))\n    } else if (e.key === \"Home\" || e.key === \"End\") {\n      e.preventDefault()\n      setActive(e.key === \"Home\" ? 0 : n - 1)\n    } else if (e.key === \"Escape\") setActive(null)\n  }\n\n  const onRangeKey = (e: React.KeyboardEvent<HTMLDivElement>) => {\n    if (!ranges || ![\"ArrowLeft\", \"ArrowRight\", \"ArrowUp\", \"ArrowDown\"].includes(e.key)) return\n    e.preventDefault()\n    const i = ranges.findIndex((r) => r.key === rangeKey)\n    const next = ranges[(i + (e.key === \"ArrowLeft\" || e.key === \"ArrowUp\" ? -1 : 1) + ranges.length) % ranges.length]\n    if (!next) return\n    select(next.key)\n    e.currentTarget.querySelector<HTMLButtonElement>(`[data-key=\"${next.key}\"]`)?.focus()\n  }\n\n  const ready = inView || reduce\n  // Once the entrance has played, labels that appear later (a resize, a new range) show without the stagger.\n  const [entered, setEntered] = React.useState(false)\n  React.useEffect(() => {\n    if (!inView) return\n    const id = window.setTimeout(() => setEntered(true), reduce ? 0 : duration * 1000 + 300)\n    return () => window.clearTimeout(id)\n  }, [inView, reduce, duration])\n  // A container resize reshapes the chart at once; only data changes morph.\n  const widthRef = React.useRef(W)\n  const resized = widthRef.current !== W\n  widthRef.current = W\n  const ease = [0.65, 0, 0.35, 1] as const\n  const morph = reduce || resized ? { duration: 0 } : spring.morph\n  const snap = reduce ? { duration: 0 } : spring.snap\n  const ax = activePoint ? xOf(active ?? 0) : 0\n  const ay = activePoint ? yOf(activePoint.value) : 0\n  const tipRight = ax > W * 0.55\n  const tipBelow = ay < padT + 44\n  const last = n ? { x: xOf(n - 1), y: yOf(values[n - 1] ?? 0) } : null\n\n  return (\n    <div ref={rootRef} className={cn(\"pc-area-chart flex w-full min-w-0 flex-col gap-3\", className)} {...props}>\n      <GooduiTokens />\n      <style href=\"pc-area-chart\" precedence=\"default\">\n        {CSS}\n      </style>\n      {(title !== undefined || headline !== \"none\" || ranges) && (\n        <div className=\"flex flex-wrap items-start justify-between gap-x-4 gap-y-2\">\n          <div className=\"flex min-w-0 flex-col gap-0.5\">\n            {title !== undefined && <div className=\"text-sm text-muted-foreground\">{title}</div>}\n            {headline !== \"none\" && (\n              <div className=\"flex flex-wrap items-baseline gap-x-2 gap-y-0.5\">\n                <NumberFlow value={shownValue} format={format} locale={locale} speed={activePoint ? \"fast\" : \"smooth\"} className=\"text-2xl leading-none font-semibold tracking-tight\" />\n                {showChange && n > 1 && (\n                  <span data-trend={changeTrend} className=\"pc-area-chart-delta inline-flex items-center gap-0.5 self-center rounded-full px-1.5 py-0.5 text-xs font-semibold\">\n                    <motion.svg viewBox=\"0 0 12 12\" className=\"size-3\" fill=\"none\" aria-hidden=\"true\" initial={false} animate={{ rotate: change < 0 ? 180 : 0 }} transition={reduce ? { duration: 0 } : spring.play}>\n                      <path d=\"M6 9.5v-7M3 5l3-3 3 3\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                    </motion.svg>\n                    <span className=\"sr-only\">{change < 0 ? \"−\" : \"+\"}</span>\n                    <NumberFlow value={Math.abs(change)} format={CHANGE_FORMAT} suffix=\"%\" locale={locale} speed=\"fast\" />\n                  </span>\n                )}\n                <span className=\"text-xs text-muted-foreground\">{activePoint ? activePoint.label : description}</span>\n              </div>\n            )}\n          </div>\n          {ranges && ranges.length > 1 && (\n            <LayoutGroup id={uid}>\n              <div role=\"radiogroup\" aria-label={l.range} onKeyDown={onRangeKey} className=\"flex shrink-0 rounded-lg bg-muted p-0.5 text-xs\">\n                {ranges.map((r) => {\n                  const on = r.key === rangeKey\n                  return (\n                    <button\n                      key={r.key}\n                      type=\"button\"\n                      role=\"radio\"\n                      aria-checked={on}\n                      tabIndex={on ? 0 : -1}\n                      data-key={r.key}\n                      onClick={() => select(r.key)}\n                      className=\"pc-press relative rounded-md px-2.5 py-1 font-medium text-foreground/65 transition-colors outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 aria-checked:text-foreground\"\n                    >\n                      {on && <motion.span layoutId=\"thumb\" className=\"absolute inset-0 rounded-md bg-background shadow-[var(--pc-e1)]\" transition={reduce ? { duration: 0 } : spring.snap} />}\n                      <span className=\"relative\">{r.label}</span>\n                    </button>\n                  )\n                })}\n              </div>\n            </LayoutGroup>\n          )}\n        </div>\n      )}\n      <div\n        ref={plotRef}\n        role=\"group\"\n        aria-roledescription=\"area chart\"\n        aria-label={summary}\n        tabIndex={0}\n        onPointerMove={(e) => setActive(indexAt(e.clientX))}\n        onPointerLeave={() => setActive(null)}\n        onFocus={() => setActive((i) => i ?? (n ? n - 1 : null))}\n        onBlur={() => setActive(null)}\n        onKeyDown={onKeyDown}\n        className=\"relative w-full touch-pan-y rounded-md outline-none focus-visible:ring-3 focus-visible:ring-ring/50\"\n        style={{ height, \"--pc-area-c\": color } as React.CSSProperties}\n      >\n        {width !== null && n > 0 && (\n          <svg width={W} height={height} viewBox={`0 0 ${W} ${height}`} className=\"absolute inset-0 overflow-visible\" aria-hidden=\"true\">\n            <defs>\n              <linearGradient id={`pc-area-${uid}`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n                <stop offset=\"0%\" style={{ stopColor: color, stopOpacity: 0.42 }} />\n                <stop offset=\"55%\" style={{ stopColor: color, stopOpacity: 0.14 }} />\n                <stop offset=\"100%\" style={{ stopColor: color, stopOpacity: 0 }} />\n              </linearGradient>\n              <linearGradient id={`pc-area-fade-${uid}`} x1=\"0\" x2=\"0\" y1=\"0\" y2=\"1\">\n                <stop offset=\"0%\" stopColor=\"#fff\" stopOpacity=\"0.9\" />\n                <stop offset=\"100%\" stopColor=\"#fff\" stopOpacity=\"0\" />\n              </linearGradient>\n              <mask id={`pc-area-mask-${uid}`}>\n                <rect x={0} y={0} width={W} height={height} fill={`url(#pc-area-fade-${uid})`} />\n              </mask>\n              <pattern id={`pc-area-grain-${uid}`} patternUnits=\"userSpaceOnUse\" width={120} height={120}>\n                <image href={GRAIN} width={120} height={120} />\n              </pattern>\n              <clipPath id={`pc-area-past-${uid}`}>\n                <motion.rect x={0} y={-8} height={height + 16} initial={false} animate={{ width: activePoint ? ax : W }} transition={snap} />\n              </clipPath>\n            </defs>\n            <AnimatePresence initial={false}>\n              {ticks.map((t) => (\n                <motion.g key={t} initial={{ opacity: 0, y: yOf(t) }} animate={{ opacity: 1, y: yOf(t) }} exit={{ opacity: 0 }} transition={morph}>\n                  {grid && <line x1={padL} x2={padL + plotW} y1={0} y2={0} className=\"stroke-border\" strokeWidth={1} />}\n                  {axis && (\n                    <text x={padL - 8} y={0} dy=\".35em\" textAnchor=\"end\" className=\"fill-muted-foreground text-[11px] tabular-nums\">\n                      {tick(t)}\n                    </text>\n                  )}\n                </motion.g>\n              ))}\n            </AnimatePresence>\n            {!grid && <line x1={padL} x2={padL + plotW} y1={padT + plotH} y2={padT + plotH} className=\"stroke-border\" />}\n            <motion.path\n              d={areaPath}\n              fill={`url(#pc-area-${uid})`}\n              initial={false}\n              animate={{ d: areaPath, opacity: ready ? 1 : 0 }}\n              transition={{ d: morph, opacity: reduce ? { duration: 0 } : { duration: 0.7, delay: duration * 0.4, ease: \"easeOut\" } }}\n              clipPath={`url(#pc-area-past-${uid})`}\n            />\n            {grain && (\n              <motion.path\n                d={areaPath}\n                fill={`url(#pc-area-grain-${uid})`}\n                mask={`url(#pc-area-mask-${uid})`}\n                clipPath={`url(#pc-area-past-${uid})`}\n                style={{ mixBlendMode: \"overlay\" }}\n                initial={false}\n                animate={{ d: areaPath, opacity: ready ? 0.5 : 0 }}\n                transition={{ d: morph, opacity: reduce ? { duration: 0 } : { duration: 0.7, delay: duration * 0.4, ease: \"easeOut\" } }}\n              />\n            )}\n            <motion.path\n              d={linePath}\n              fill=\"none\"\n              style={{ stroke: color }}\n              strokeWidth={2}\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              initial={false}\n              animate={{ d: linePath, pathLength: ready ? 1 : 0, opacity: ready ? (activePoint ? 0.28 : 1) : 0 }}\n              transition={{ d: morph, pathLength: reduce ? { duration: 0 } : { duration, ease }, opacity: { duration: activePoint ? 0.15 : 0.01 } }}\n            />\n            {activePoint && <path d={linePath} fill=\"none\" className=\"pc-area-chart-line\" style={{ stroke: color }} strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" clipPath={`url(#pc-area-past-${uid})`} />}\n            {last && (\n              <motion.g initial={false} animate={{ x: last.x, y: last.y, opacity: ready ? 1 : 0, scale: ready ? 1 : 0 }} transition={{ x: morph, y: morph, scale: reduce ? { duration: 0 } : { ...spring.play, delay: duration * 0.85 }, opacity: { duration: 0.01, delay: reduce ? 0 : duration * 0.85 } }}>\n                <circle className=\"pc-area-chart-ping\" r={4} style={{ fill: color }} />\n                <circle r={4} style={{ fill: color }} className=\"stroke-background\" strokeWidth={2} />\n              </motion.g>\n            )}\n            <g>\n              {xLabels.map((i) => (\n                <motion.text\n                  key={`${data[i]?.label ?? \"\"}-${i}`}\n                  x={xOf(i)}\n                  y={height - 6}\n                  textAnchor={i === 0 ? \"start\" : i === n - 1 ? \"end\" : \"middle\"}\n                  className=\"fill-muted-foreground text-[11px]\"\n                  initial={{ opacity: 0 }}\n                  animate={{ opacity: ready ? 1 : 0 }}\n                  transition={reduce ? { duration: 0 } : entered ? { duration: 0.2 } : { duration: 0.4, delay: 0.1 + (i / Math.max(1, n - 1)) * duration * 0.8 }}\n                >\n                  {data[i]?.label}\n                </motion.text>\n              ))}\n            </g>\n            {activePoint && (\n              <motion.line x1={padL} x2={padL + plotW} initial={false} animate={{ y1: ay, y2: ay }} transition={snap} className=\"stroke-foreground/15\" strokeWidth={1} strokeDasharray=\"3 4\" />\n            )}\n            {activePoint && (\n              <motion.g initial={false} animate={{ x: ax }} transition={snap}>\n                <line x1={0} x2={0} y1={padT} y2={padT + plotH} className=\"stroke-foreground/40\" strokeWidth={1} strokeDasharray=\"3 4\" />\n                <motion.circle r={5} style={{ fill: color }} className=\"stroke-background\" strokeWidth={2} initial={false} animate={{ cy: ay }} transition={snap} />\n              </motion.g>\n            )}\n          </svg>\n        )}\n        {width !== null && n === 0 && <div className=\"absolute inset-0 grid place-items-center text-sm text-muted-foreground\">{l.noData}</div>}\n        {activePoint && (\n          <div\n            className=\"pointer-events-none absolute z-10 flex flex-col gap-0.5 rounded-md border bg-popover px-2.5 py-1.5 text-xs whitespace-nowrap text-popover-foreground shadow-[var(--pc-e2)]\"\n            style={{ left: ax, top: ay, transform: `translate(${tipRight ? \"calc(-100% - 12px)\" : \"12px\"}, ${tipBelow ? \"10px\" : \"calc(-100% - 10px)\"})` }}\n          >\n            <span className=\"text-muted-foreground\">{activePoint.label}</span>\n            <span className=\"flex items-center gap-1.5 font-semibold tabular-nums\">\n              <span className=\"inline-block h-0.5 w-3 rounded-full\" style={{ background: color }} />\n              {fmt(activePoint.value)}\n            </span>\n          </div>\n        )}\n        <span className=\"sr-only\" aria-live=\"polite\">\n          {activePoint ? l.point(activePoint.label, fmt(activePoint.value)) : \"\"}\n        </span>\n      </div>\n      {n > 0 && (\n        <div className=\"sr-only\">\n          <table>\n          <caption>{summary}</caption>\n          <thead>\n            <tr>\n              <th scope=\"col\">{l.columnLabel}</th>\n              <th scope=\"col\">{l.columnValue}</th>\n            </tr>\n          </thead>\n          <tbody>\n            {data.map((d, i) => (\n              <tr key={i}>\n                <th scope=\"row\">{d.label}</th>\n                <td>{fmt(d.value)}</td>\n              </tr>\n            ))}\n          </tbody>\n        </table>\n        </div>\n      )}\n    </div>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/area-chart.tsx"
    }
  ],
  "categories": [
    "components",
    "charts"
  ],
  "type": "registry:component"
}
