{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "scatter-chart",
  "type": "registry:component",
  "title": "Relationship chart",
  "description": "Explore how two measures move together, with optional bubble size for a third.",
  "categories": [
    "charts"
  ],
  "dependencies": [
    "recharts-analytics@npm:recharts@3.10.1"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/registry/overtrue/scatter-chart.tsx",
      "type": "registry:component",
      "target": "components/overtrue/scatter-chart.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\n\"use client\";\n\nimport * as React from \"react\";\nimport {\n  CartesianGrid,\n  Scatter,\n  ScatterChart as RechartsScatterChart,\n  XAxis,\n  YAxis,\n  ZAxis,\n} from \"recharts-analytics\";\n\nimport { cn } from \"@/lib/utils\";\nimport { formatNumber } from \"./metric-format\";\nimport {\n  ChartContainer,\n  ChartLegend,\n  ChartTooltip,\n  type ChartConfig,\n} from \"./analytics-chart\";\n\nexport interface ScatterSeries {\n  /** Stable identifier. Defaults to a slug of the label. */\n  key?: string;\n  label: string;\n  /** Rows for this series. Each needs the x and y keys, plus the size and name keys when set. */\n  data: Record<string, unknown>[];\n  /** Any CSS color. Defaults to chart-1 through chart-5 in order. */\n  color?: string;\n}\n\nexport interface ScatterChartProps extends Omit<\n  React.ComponentProps<typeof ChartContainer>,\n  \"config\" | \"children\"\n> {\n  series: ScatterSeries[];\n  /** Key of the x value in each row. */\n  xKey: string;\n  /** Key of the y value in each row. */\n  yKey: string;\n  /** Key of a value that scales each point into a bubble. */\n  sizeKey?: string;\n  /** Key of a per-point label shown as the tooltip title. */\n  nameKey?: string;\n  /** Names for the tooltip rows. Default to the keys. */\n  xLabel?: string;\n  yLabel?: string;\n  sizeLabel?: string;\n  /** Print `xLabel` at the end of the x-axis and `yLabel` above the y-axis. */\n  showAxisLabels?: boolean;\n  showGrid?: boolean;\n  showXAxis?: boolean;\n  showYAxis?: boolean;\n  showLegend?: boolean;\n  showTooltip?: boolean;\n  xFormatter?: (value: number) => string;\n  yFormatter?: (value: number) => string;\n  sizeFormatter?: (value: number) => string;\n  /** Radius of each point in px when sizeKey is not set. */\n  dotRadius?: number;\n  /**\n   * Bubble area range in px² when sizeKey is set, smallest to largest. Areas grow\n   * in proportion to the value, measured from zero.\n   */\n  sizeRange?: [number, number];\n  /** Recharts domain for the x-axis, e.g. [\"auto\", \"auto\"]. Defaults to [0, \"auto\"]. */\n  xDomain?: React.ComponentProps<typeof XAxis>[\"domain\"];\n  /** Recharts domain for the y-axis, e.g. [\"auto\", \"auto\"]. Defaults to [0, \"auto\"]. */\n  yDomain?: React.ComponentProps<typeof YAxis>[\"domain\"];\n  /** Animate points after hydration and when data changes. Respects reduced motion. */\n  animate?: boolean;\n  animationDuration?: number;\n}\n\nconst EASE = \"cubic-bezier(0.22,1,0.36,1)\";\nconst GRID = \"color-mix(in oklab, var(--color-foreground) 7%, transparent)\";\nconst AXIS = \"color-mix(in oklab, var(--color-foreground) 14%, transparent)\";\nconst TICK = {\n  fill: \"var(--color-muted-foreground)\",\n  fontSize: 11,\n  className: \"tabular-nums\",\n};\n\nconst reducedMotionQuery = \"(prefers-reduced-motion: reduce)\";\n\nfunction subscribeToReducedMotion(onChange: () => void) {\n  const query = window.matchMedia(reducedMotionQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n}\n\nfunction getReducedMotionSnapshot() {\n  return window.matchMedia(reducedMotionQuery).matches;\n}\n\nfunction getReducedMotionServerSnapshot() {\n  return true;\n}\n\n/** Hidden key stamped onto each row so the tooltip can find the point's series. */\nconst SERIES_KEY = \"__scatterSeries\";\n\nfunction slug(label: string) {\n  return label.toLowerCase().replace(/[^a-z0-9]+/g, \"-\");\n}\n\ninterface ScatterTooltipContentProps {\n  active?: boolean;\n  payload?: ReadonlyArray<{ payload?: unknown }>;\n  config: ChartConfig;\n  rows: { key: string; label: string; format: (value: number) => string }[];\n  nameKey?: string;\n}\n\nfunction ScatterTooltipContent({\n  active,\n  payload,\n  config,\n  rows,\n  nameKey,\n}: ScatterTooltipContentProps) {\n  const point = payload?.[0]?.payload as Record<string, unknown> | undefined;\n  if (!active || !point) return null;\n  const seriesKey = String(point[SERIES_KEY] ?? \"\");\n  const seriesLabel = config[seriesKey]?.label ?? seriesKey;\n  const name = nameKey ? point[nameKey] : undefined;\n  const title = name != null ? String(name) : seriesLabel;\n\n  return (\n    <div className=\"grid min-w-44 gap-2 rounded-xl border border-border/70 bg-popover/90 px-3 py-2.5 text-xs text-popover-foreground shadow-xl backdrop-blur-md\">\n      <div className=\"flex items-center gap-2\">\n        <span\n          aria-hidden=\"true\"\n          className=\"size-2.5 shrink-0 rounded-full shadow-[0_0_0_3px_color-mix(in_oklab,var(--scatter-swatch)_20%,transparent)]\"\n          style={\n            {\n              backgroundColor: `var(--color-${seriesKey})`,\n              \"--scatter-swatch\": `var(--color-${seriesKey})`,\n            } as React.CSSProperties\n          }\n        />\n        <span className=\"font-medium text-foreground\">{title}</span>\n        {name != null ? (\n          <span className=\"ml-auto pl-3 text-muted-foreground\">\n            {seriesLabel}\n          </span>\n        ) : null}\n      </div>\n      <div className=\"grid gap-1\">\n        {rows.map((row) => (\n          <div\n            key={row.key}\n            className=\"flex items-center justify-between gap-6\"\n          >\n            <span className=\"text-muted-foreground\">{row.label}</span>\n            <span className=\"font-medium text-foreground tabular-nums\">\n              {row.format(Number(point[row.key]))}\n            </span>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n\ninterface PointShapeProps {\n  cx?: number;\n  cy?: number;\n  size?: number;\n  index?: number;\n}\n\n/** A scatter chart on shadcn's chart primitives: correlation dots per series, or bubbles when a size key is set. */\nfunction ScatterChart({\n  series,\n  xKey,\n  yKey,\n  sizeKey,\n  nameKey,\n  xLabel,\n  yLabel,\n  sizeLabel,\n  showAxisLabels = false,\n  showGrid = true,\n  showXAxis = true,\n  showYAxis = true,\n  showLegend = false,\n  showTooltip = true,\n  xFormatter = (value) => formatNumber(value, { format: \"compact\" }),\n  yFormatter = (value) => formatNumber(value, { format: \"compact\" }),\n  sizeFormatter = (value) => formatNumber(value, { format: \"compact\" }),\n  dotRadius = 4,\n  sizeRange = [60, 1100],\n  xDomain,\n  yDomain,\n  animate = true,\n  animationDuration = 700,\n  className,\n  ...props\n}: ScatterChartProps) {\n  const reducedMotion = React.useSyncExternalStore(\n    subscribeToReducedMotion,\n    getReducedMotionSnapshot,\n    getReducedMotionServerSnapshot,\n  );\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const [focusKey, setFocusKey] = React.useState<string | null>(null);\n  // Recharts marks every series' point at the hovered index as active, so track the real one here.\n  const [hovered, setHovered] = React.useState<{\n    series: string;\n    index: number;\n  } | null>(null);\n  const resolved = React.useMemo(\n    () =>\n      series.map((s, index) => {\n        const key = s.key ?? slug(s.label);\n        const rows = s.data.map((row) => ({ ...row, [SERIES_KEY]: key }));\n        // Draw the largest bubbles first so smaller ones stay on top and reachable.\n        if (sizeKey)\n          rows.sort(\n            (a, b) =>\n              Number((b as Record<string, unknown>)[sizeKey]) -\n              Number((a as Record<string, unknown>)[sizeKey]),\n          );\n        return {\n          key,\n          label: s.label,\n          color: s.color ?? `var(--color-chart-${(index % 5) + 1})`,\n          data: rows,\n        };\n      }),\n    [series, sizeKey],\n  );\n  const config = Object.fromEntries(\n    resolved.map((s) => [s.key, { label: s.label, color: s.color }]),\n  ) satisfies ChartConfig;\n  const rows = [\n    { key: xKey, label: xLabel ?? xKey, format: xFormatter },\n    { key: yKey, label: yLabel ?? yKey, format: yFormatter },\n    ...(sizeKey\n      ? [{ key: sizeKey, label: sizeLabel ?? sizeKey, format: sizeFormatter }]\n      : []),\n  ];\n  // Recharts sizes symbols by area, so a fixed radius becomes a fixed area.\n  const dotArea = Math.round(Math.PI * dotRadius * dotRadius);\n  const withXTitle = showAxisLabels && showXAxis && !!xLabel;\n  const withYTitle = showAxisLabels && showYAxis && !!yLabel;\n\n  const renderPoint = (seriesKey: string) => (shape: PointShapeProps) => {\n    const { cx, cy } = shape;\n    const isActive =\n      hovered?.series === seriesKey && hovered.index === shape.index;\n    if (\n      cx == null ||\n      cy == null ||\n      !Number.isFinite(cx) ||\n      !Number.isFinite(cy)\n    )\n      return <g />;\n    const r = Math.max(0, Math.sqrt(Math.max(shape.size ?? 0, 0) / Math.PI));\n    const color = `var(--color-${seriesKey})`;\n    const dimmed = focusKey !== null && focusKey !== seriesKey;\n    if (sizeKey) {\n      return (\n        <g\n          data-slot=\"scatter-chart-point\"\n          data-series={seriesKey}\n          data-active-point={isActive || undefined}\n          className=\"transition-opacity duration-150 motion-reduce:transition-none\"\n          style={{ opacity: dimmed ? 0.2 : undefined }}\n        >\n          {isActive ? (\n            <circle cx={cx} cy={cy} r={r + 6} fill={color} fillOpacity={0.14} />\n          ) : null}\n          <circle\n            cx={cx}\n            cy={cy}\n            r={r}\n            fill={`url(#${uid}-bubble-${seriesKey})`}\n            stroke={color}\n            strokeOpacity={isActive ? 1 : 0.85}\n            strokeWidth={isActive ? 2 : 1.25}\n          />\n        </g>\n      );\n    }\n    return (\n      <g\n        data-slot=\"scatter-chart-point\"\n        data-series={seriesKey}\n        data-active-point={isActive || undefined}\n        className=\"transition-opacity duration-150 motion-reduce:transition-none\"\n        style={{ opacity: dimmed ? 0.2 : undefined }}\n      >\n        <circle\n          cx={cx}\n          cy={cy}\n          r={r + (isActive ? 6 : 3)}\n          fill={color}\n          fillOpacity={isActive ? 0.2 : 0.16}\n        />\n        <circle\n          cx={cx}\n          cy={cy}\n          r={r + (isActive ? 1 : 0)}\n          fill={color}\n          stroke=\"var(--color-card)\"\n          strokeWidth={isActive ? 2 : 1}\n          className=\"dark:[filter:drop-shadow(0_0_5px_color-mix(in_oklab,var(--scatter-glow)_55%,transparent))]\"\n          style={{ [\"--scatter-glow\" as string]: color }}\n        />\n      </g>\n    );\n  };\n\n  return (\n    <ChartContainer\n      data-slot=\"scatter-chart\"\n      data-variant={sizeKey ? \"bubble\" : \"point\"}\n      config={config}\n      className={cn(\n        \"aspect-auto h-64 w-full\",\n        // While one point is hovered, the rest step back.\n        \"[&:has([data-active-point])_[data-slot=scatter-chart-point]:not([data-active-point])]:opacity-35\",\n        className,\n      )}\n      {...props}\n    >\n      <RechartsScatterChart\n        margin={{\n          top: withYTitle && !showLegend ? 24 : 12,\n          right: 12,\n          bottom: 0,\n          left: showYAxis ? 0 : 8,\n        }}\n      >\n        <defs>\n          {resolved.map((s) => (\n            <radialGradient\n              key={s.key}\n              id={`${uid}-bubble-${s.key}`}\n              cx=\"38%\"\n              cy=\"32%\"\n              r=\"75%\"\n            >\n              <stop\n                offset=\"0%\"\n                stopColor={`var(--color-${s.key})`}\n                stopOpacity={0.62}\n              />\n              <stop\n                offset=\"100%\"\n                stopColor={`var(--color-${s.key})`}\n                stopOpacity={0.3}\n              />\n            </radialGradient>\n          ))}\n        </defs>\n        {showGrid ? <CartesianGrid vertical={false} stroke={GRID} /> : null}\n        <XAxis\n          type=\"number\"\n          dataKey={xKey}\n          hide={!showXAxis}\n          domain={xDomain}\n          tickLine={false}\n          axisLine={{ stroke: AXIS }}\n          tickMargin={8}\n          tick={TICK}\n          height={withXTitle ? 44 : 30}\n          tickFormatter={xFormatter}\n          label={\n            withXTitle\n              ? {\n                  content: ({ viewBox }) => {\n                    const box = viewBox as\n                      { x?: number; y?: number; width?: number } | undefined;\n                    if (box?.x == null || box.y == null || box.width == null)\n                      return null;\n                    return (\n                      <text\n                        x={box.x + box.width}\n                        y={box.y + 38}\n                        textAnchor=\"end\"\n                        className=\"fill-muted-foreground text-[11px]\"\n                      >\n                        {xLabel} →\n                      </text>\n                    );\n                  },\n                }\n              : undefined\n          }\n        />\n        <YAxis\n          type=\"number\"\n          dataKey={yKey}\n          hide={!showYAxis}\n          domain={yDomain}\n          tickLine={false}\n          axisLine={false}\n          tickMargin={8}\n          tick={TICK}\n          width=\"auto\"\n          tickFormatter={yFormatter}\n          label={\n            // With a legend, the y title sits at the start of the legend row instead.\n            withYTitle && !showLegend\n              ? {\n                  content: ({ viewBox }) => {\n                    const box = viewBox as\n                      { x?: number; y?: number } | undefined;\n                    if (box?.x == null || box.y == null) return null;\n                    return (\n                      <text\n                        x={box.x}\n                        y={box.y - 11}\n                        textAnchor=\"start\"\n                        className=\"fill-muted-foreground text-[11px]\"\n                      >\n                        ↑ {yLabel}\n                      </text>\n                    );\n                  },\n                }\n              : undefined\n          }\n        />\n        {sizeKey ? (\n          <ZAxis\n            type=\"number\"\n            dataKey={sizeKey}\n            range={sizeRange}\n            domain={[0, \"dataMax\"]}\n          />\n        ) : (\n          <ZAxis type=\"number\" range={[dotArea, dotArea]} />\n        )}\n        {showTooltip ? (\n          <ChartTooltip\n            cursor={{\n              stroke:\n                \"color-mix(in oklab, var(--color-foreground) 25%, transparent)\",\n              strokeWidth: 1,\n              strokeDasharray: \"3 3\",\n            }}\n            isAnimationActive={false}\n            content={(tooltipProps) => (\n              <ScatterTooltipContent\n                active={tooltipProps.active}\n                payload={\n                  tooltipProps.payload as ReadonlyArray<{ payload?: unknown }>\n                }\n                config={config}\n                rows={rows}\n                nameKey={nameKey}\n              />\n            )}\n          />\n        ) : null}\n        {showLegend ? (\n          <ChartLegend\n            verticalAlign=\"top\"\n            align=\"right\"\n            content={() => (\n              <div\n                data-slot=\"scatter-chart-legend\"\n                className=\"flex items-start justify-between gap-4 pb-3\"\n                onPointerLeave={() => setFocusKey(null)}\n              >\n                {withYTitle ? (\n                  <span className=\"shrink-0 text-[11px] leading-4 text-muted-foreground\">\n                    ↑ {yLabel}\n                  </span>\n                ) : null}\n                <span className=\"ml-auto flex flex-wrap items-center justify-end gap-x-4 gap-y-1\">\n                  {resolved.map((s) => (\n                    <span\n                      key={s.key}\n                      onPointerEnter={() => setFocusKey(s.key)}\n                      className={cn(\n                        \"flex cursor-default items-center gap-1.5 text-xs text-muted-foreground transition-[color,opacity] duration-150 motion-reduce:transition-none\",\n                        focusKey === s.key && \"text-foreground\",\n                        focusKey !== null && focusKey !== s.key && \"opacity-50\",\n                      )}\n                    >\n                      <span\n                        aria-hidden=\"true\"\n                        className=\"size-2 rounded-full\"\n                        style={{\n                          backgroundColor: s.color,\n                          boxShadow: `0 0 0 3px color-mix(in oklab, ${s.color} 18%, transparent)`,\n                        }}\n                      />\n                      {s.label}\n                    </span>\n                  ))}\n                </span>\n              </div>\n            )}\n          />\n        ) : null}\n        {resolved.map((s) => (\n          <Scatter\n            key={s.key}\n            name={s.key}\n            data={s.data}\n            fill={`var(--color-${s.key})`}\n            shape={renderPoint(s.key)}\n            onMouseEnter={(_: unknown, index: number) =>\n              setHovered({ series: s.key, index })\n            }\n            onMouseLeave={() => setHovered(null)}\n            isAnimationActive={animate && !reducedMotion}\n            animationDuration={animationDuration}\n            animationEasing={EASE}\n          />\n        ))}\n      </RechartsScatterChart>\n    </ChartContainer>\n  );\n}\n\nexport { ScatterChart };\n"
    },
    {
      "path": "src/registry/overtrue/metric-format.tsx",
      "type": "registry:component",
      "target": "components/overtrue/metric-format.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\nexport type NumberFormat = \"number\" | \"compact\" | \"currency\" | \"percent\";\n\nexport interface FormatNumberOptions {\n  format?: NumberFormat;\n  /** ISO 4217 code, used when format is \"currency\". Defaults to USD. */\n  currency?: string;\n  locale?: string;\n  maximumFractionDigits?: number;\n  /** Abbreviate large values, e.g. \"$158K\" instead of \"$158,143\". */\n  compact?: boolean;\n}\n\nconst formatterCache = new Map<string, Intl.NumberFormat>();\n\nfunction getFormatter(locale: string, options: Intl.NumberFormatOptions) {\n  const key = locale + JSON.stringify(options);\n  let formatter = formatterCache.get(key);\n  if (!formatter) {\n    formatter = new Intl.NumberFormat(locale, options);\n    formatterCache.set(key, formatter);\n  }\n  return formatter;\n}\n\n/**\n * Format a metric value for display.\n *\n * formatNumber(1234567)                          -> \"1,234,567\"\n * formatNumber(1234567, { format: \"compact\" })   -> \"1.2M\"\n * formatNumber(48.2, { format: \"currency\" })     -> \"$48.20\"\n * formatNumber(158143, { format: \"currency\", compact: true }) -> \"$158K\"\n * formatNumber(0.124, { format: \"percent\" })     -> \"12.4%\"\n */\nexport function formatNumber(\n  value: number,\n  {\n    format = \"number\",\n    currency = \"USD\",\n    locale = \"en-US\",\n    maximumFractionDigits,\n    compact = false,\n  }: FormatNumberOptions = {},\n): string {\n  if (!Number.isFinite(value)) return \"—\";\n\n  // Compact values keep three significant digits: $158K, $1.23M, 41.2K.\n  const compactOptions: Intl.NumberFormatOptions = compact\n    ? maximumFractionDigits === undefined\n      ? { notation: \"compact\", maximumSignificantDigits: 3 }\n      : { notation: \"compact\", maximumFractionDigits }\n    : {};\n  switch (format) {\n    case \"compact\":\n      return getFormatter(locale, {\n        notation: \"compact\",\n        maximumFractionDigits: maximumFractionDigits ?? 1,\n      }).format(value);\n    case \"currency\":\n      return getFormatter(locale, {\n        style: \"currency\",\n        currency,\n        maximumFractionDigits: maximumFractionDigits ?? 2,\n        ...compactOptions,\n      }).format(value);\n    case \"percent\":\n      return getFormatter(locale, {\n        style: \"percent\",\n        maximumFractionDigits: maximumFractionDigits ?? 1,\n      }).format(value);\n    default:\n      return getFormatter(locale, {\n        maximumFractionDigits: maximumFractionDigits ?? 0,\n        ...compactOptions,\n      }).format(value);\n  }\n}\n\n/**\n * Format a fractional change as a signed percentage.\n *\n * formatDelta(0.124)  -> \"+12.4%\"\n * formatDelta(-0.03)  -> \"-3.0%\"\n * formatDelta(0)      -> \"0.0%\"\n */\nexport function formatDelta(delta: number, locale = \"en-US\"): string {\n  if (!Number.isFinite(delta)) return \"—\";\n  return getFormatter(locale, {\n    style: \"percent\",\n    signDisplay: \"exceptZero\",\n    maximumFractionDigits: 1,\n    minimumFractionDigits: 1,\n  }).format(delta);\n}\n\n/**\n * Fractional change between two values. Returns 0 when there is no baseline.\n */\nexport function computeDelta(current: number, previous: number): number {\n  if (!previous) return 0;\n  return (current - previous) / Math.abs(previous);\n}\n"
    },
    {
      "path": "src/registry/overtrue/analytics-chart.tsx",
      "type": "registry:component",
      "target": "components/overtrue/analytics-chart.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\n\"use client\";\n\nimport * as React from \"react\";\nimport * as RechartsPrimitive from \"recharts-analytics\";\nimport type { TooltipValueType } from \"recharts-analytics\";\n\nimport { cn } from \"@/lib/utils\";\n\n// Format: { THEME_NAME: CSS_SELECTOR }\nconst THEMES = { light: \"\", dark: \".dark\" } as const;\n\nconst INITIAL_DIMENSION = { width: 320, height: 200 } as const;\ntype TooltipNameType = number | string;\n\nexport type ChartConfig = Record<\n  string,\n  {\n    label?: React.ReactNode;\n    icon?: React.ComponentType;\n  } & (\n    | { color?: string; theme?: never }\n    | { color?: never; theme: Record<keyof typeof THEMES, string> }\n  )\n>;\n\ntype ChartContextProps = {\n  config: ChartConfig;\n};\n\nconst ChartContext = React.createContext<ChartContextProps | null>(null);\n\nfunction useChart() {\n  const context = React.useContext(ChartContext);\n\n  if (!context) {\n    throw new Error(\"useChart must be used within a <ChartContainer />\");\n  }\n\n  return context;\n}\n\nfunction ChartContainer({\n  id,\n  className,\n  children,\n  config,\n  initialDimension = INITIAL_DIMENSION,\n  ...props\n}: React.ComponentProps<\"div\"> & {\n  config: ChartConfig;\n  children: React.ComponentProps<\n    typeof RechartsPrimitive.ResponsiveContainer\n  >[\"children\"];\n  initialDimension?: {\n    width: number;\n    height: number;\n  };\n}) {\n  const uniqueId = React.useId();\n  const chartId = `chart-${id ?? uniqueId.replace(/:/g, \"\")}`;\n\n  return (\n    <ChartContext.Provider value={{ config }}>\n      <div\n        data-slot=\"chart\"\n        data-chart={chartId}\n        className={cn(\n          \"flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden\",\n          className,\n        )}\n        {...props}\n      >\n        <ChartStyle id={chartId} config={config} />\n        <RechartsPrimitive.ResponsiveContainer\n          initialDimension={initialDimension}\n        >\n          {children}\n        </RechartsPrimitive.ResponsiveContainer>\n      </div>\n    </ChartContext.Provider>\n  );\n}\n\nconst ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {\n  const colorConfig = Object.entries(config).filter(\n    ([, config]) => config.theme ?? config.color,\n  );\n\n  if (!colorConfig.length) {\n    return null;\n  }\n\n  return (\n    <style\n      dangerouslySetInnerHTML={{\n        __html: Object.entries(THEMES)\n          .map(\n            ([theme, prefix]) => `\n${prefix} [data-chart=${id}] {\n${colorConfig\n  .map(([key, itemConfig]) => {\n    const color =\n      itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ??\n      itemConfig.color;\n    return color ? `  --color-${key}: ${color};` : null;\n  })\n  .join(\"\\n\")}\n}\n`,\n          )\n          .join(\"\\n\"),\n      }}\n    />\n  );\n};\n\nconst ChartTooltip = RechartsPrimitive.Tooltip;\n\nfunction ChartTooltipContent({\n  active,\n  payload,\n  className,\n  indicator = \"dot\",\n  hideLabel = false,\n  hideIndicator = false,\n  label,\n  labelFormatter,\n  labelClassName,\n  formatter,\n  color,\n  nameKey,\n  labelKey,\n}: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &\n  React.ComponentProps<\"div\"> & {\n    hideLabel?: boolean;\n    hideIndicator?: boolean;\n    indicator?: \"line\" | \"dot\" | \"dashed\";\n    nameKey?: string;\n    labelKey?: string;\n  } & Omit<\n    RechartsPrimitive.DefaultTooltipContentProps<\n      TooltipValueType,\n      TooltipNameType\n    >,\n    \"accessibilityLayer\"\n  >) {\n  const { config } = useChart();\n\n  const tooltipLabel = React.useMemo(() => {\n    if (hideLabel || !payload?.length) {\n      return null;\n    }\n\n    const [item] = payload;\n    const key = `${labelKey ?? item?.dataKey ?? item?.name ?? \"value\"}`;\n    const itemConfig = getPayloadConfigFromPayload(config, item, key);\n    const value =\n      !labelKey && typeof label === \"string\"\n        ? (config[label]?.label ?? label)\n        : itemConfig?.label;\n\n    if (labelFormatter) {\n      return (\n        <div className={cn(\"font-medium\", labelClassName)}>\n          {labelFormatter(value, payload)}\n        </div>\n      );\n    }\n\n    if (!value) {\n      return null;\n    }\n\n    return <div className={cn(\"font-medium\", labelClassName)}>{value}</div>;\n  }, [\n    label,\n    labelFormatter,\n    payload,\n    hideLabel,\n    labelClassName,\n    config,\n    labelKey,\n  ]);\n\n  if (!active || !payload?.length) {\n    return null;\n  }\n\n  const nestLabel = payload.length === 1 && indicator !== \"dot\";\n\n  return (\n    <div\n      className={cn(\n        \"grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl\",\n        className,\n      )}\n    >\n      {!nestLabel ? tooltipLabel : null}\n      <div className=\"grid gap-1.5\">\n        {payload\n          .filter((item) => item.type !== \"none\")\n          .map((item, index) => {\n            const key = `${nameKey ?? item.name ?? item.dataKey ?? \"value\"}`;\n            const itemConfig = getPayloadConfigFromPayload(config, item, key);\n            const indicatorColor = color ?? item.payload?.fill ?? item.color;\n\n            return (\n              <div\n                key={index}\n                className={cn(\n                  \"flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground\",\n                  indicator === \"dot\" && \"items-center\",\n                )}\n              >\n                {formatter && item?.value !== undefined && item.name ? (\n                  formatter(item.value, item.name, item, index, item.payload)\n                ) : (\n                  <>\n                    {itemConfig?.icon ? (\n                      <itemConfig.icon />\n                    ) : (\n                      !hideIndicator && (\n                        <div\n                          className={cn(\n                            \"shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)\",\n                            {\n                              \"h-2.5 w-2.5\": indicator === \"dot\",\n                              \"w-1\": indicator === \"line\",\n                              \"w-0 border-[1.5px] border-dashed bg-transparent\":\n                                indicator === \"dashed\",\n                              \"my-0.5\": nestLabel && indicator === \"dashed\",\n                            },\n                          )}\n                          style={\n                            {\n                              \"--color-bg\": indicatorColor,\n                              \"--color-border\": indicatorColor,\n                            } as React.CSSProperties\n                          }\n                        />\n                      )\n                    )}\n                    <div\n                      className={cn(\n                        \"flex flex-1 justify-between leading-none\",\n                        nestLabel ? \"items-end\" : \"items-center\",\n                      )}\n                    >\n                      <div className=\"grid gap-1.5\">\n                        {nestLabel ? tooltipLabel : null}\n                        <span className=\"text-muted-foreground\">\n                          {itemConfig?.label ?? item.name}\n                        </span>\n                      </div>\n                      {item.value != null && (\n                        <span className=\"font-mono font-medium text-foreground tabular-nums\">\n                          {typeof item.value === \"number\"\n                            ? item.value.toLocaleString()\n                            : String(item.value)}\n                        </span>\n                      )}\n                    </div>\n                  </>\n                )}\n              </div>\n            );\n          })}\n      </div>\n    </div>\n  );\n}\n\nconst ChartLegend = RechartsPrimitive.Legend;\n\nfunction ChartLegendContent({\n  className,\n  hideIcon = false,\n  payload,\n  verticalAlign = \"bottom\",\n  nameKey,\n}: React.ComponentProps<\"div\"> & {\n  hideIcon?: boolean;\n  nameKey?: string;\n} & RechartsPrimitive.DefaultLegendContentProps) {\n  const { config } = useChart();\n\n  if (!payload?.length) {\n    return null;\n  }\n\n  return (\n    <div\n      className={cn(\n        \"flex items-center justify-center gap-4\",\n        verticalAlign === \"top\" ? \"pb-3\" : \"pt-3\",\n        className,\n      )}\n    >\n      {payload\n        .filter((item) => item.type !== \"none\")\n        .map((item, index) => {\n          const key = `${nameKey ?? item.dataKey ?? \"value\"}`;\n          const itemConfig = getPayloadConfigFromPayload(config, item, key);\n\n          return (\n            <div\n              key={index}\n              className={cn(\n                \"flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground\",\n              )}\n            >\n              {itemConfig?.icon && !hideIcon ? (\n                <itemConfig.icon />\n              ) : (\n                <div\n                  className=\"h-2 w-2 shrink-0 rounded-[2px]\"\n                  style={{\n                    backgroundColor: item.color,\n                  }}\n                />\n              )}\n              {itemConfig?.label}\n            </div>\n          );\n        })}\n    </div>\n  );\n}\n\n// Helper to extract item config from a payload.\nfunction getPayloadConfigFromPayload(\n  config: ChartConfig,\n  payload: unknown,\n  key: string,\n) {\n  if (typeof payload !== \"object\" || payload === null) {\n    return undefined;\n  }\n\n  const payloadPayload =\n    \"payload\" in payload &&\n    typeof payload.payload === \"object\" &&\n    payload.payload !== null\n      ? payload.payload\n      : undefined;\n\n  let configLabelKey: string = key;\n\n  if (\n    key in payload &&\n    typeof payload[key as keyof typeof payload] === \"string\"\n  ) {\n    configLabelKey = payload[key as keyof typeof payload] as string;\n  } else if (\n    payloadPayload &&\n    key in payloadPayload &&\n    typeof payloadPayload[key as keyof typeof payloadPayload] === \"string\"\n  ) {\n    configLabelKey = payloadPayload[\n      key as keyof typeof payloadPayload\n    ] as string;\n  }\n\n  return configLabelKey in config ? config[configLabelKey] : config[key];\n}\n\nexport {\n  ChartContainer,\n  ChartTooltip,\n  ChartTooltipContent,\n  ChartLegend,\n  ChartLegendContent,\n  ChartStyle,\n};\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/scatter-chart. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
