{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "composed-chart",
  "type": "registry:component",
  "title": "Combined chart",
  "description": "Put actuals, targets, and supporting measures on the same reporting surface.",
  "categories": [
    "charts"
  ],
  "dependencies": [
    "recharts-analytics@npm:recharts@3.10.1"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/registry/overtrue/composed-chart.tsx",
      "type": "registry:component",
      "target": "components/overtrue/composed-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  Area,\n  AreaRevealShape,\n  Bar,\n  CartesianGrid,\n  ComposedChart as RechartsComposedChart,\n  Line,\n  Rectangle,\n  ReferenceDot,\n  ReferenceLine,\n  XAxis,\n  YAxis,\n  useActiveTooltipDataPoints,\n  type ActiveDotProps,\n  type AreaRevealShapeProps,\n  type BarProps,\n  type BarShapeProps,\n} from \"recharts-analytics\";\n\nimport { cn } from \"@/lib/utils\";\nimport {\n  ChartContainer,\n  ChartLegend,\n  ChartTooltip,\n  type ChartConfig,\n} from \"./analytics-chart\";\n\nexport interface ComposedSeries {\n  /** Key in each data row. */\n  key: string;\n  label: string;\n  type?: \"area\" | \"line\" | \"bar\";\n  /** Any CSS color. Defaults to chart-1 through chart-5 in order. */\n  color?: string;\n  /** Plot against the right axis. */\n  axis?: \"left\" | \"right\";\n  /** Series with the same stackId stack on top of each other. */\n  stackId?: string;\n  /** Bars only: fill with a diagonal hatch instead of a solid color. */\n  pattern?: \"solid\" | \"hatched\";\n  /** Lines and areas only. */\n  dashed?: boolean;\n  curve?: \"monotone\" | \"linear\" | \"step\";\n  /** Lines only: draw a dot on every point. */\n  dots?: boolean;\n  /** Mark the highest point of this series with a dot. */\n  highlightMax?: boolean;\n}\n\nexport interface ReferenceLineSpec {\n  /** Horizontal line at this y value. */\n  y?: number;\n  /** Vertical line at this x value. */\n  x?: string | number;\n  label?: string;\n  /** Any CSS color. Defaults to the muted foreground. */\n  color?: string;\n  dashed?: boolean;\n  axis?: \"left\" | \"right\";\n}\n\nexport interface ComposedChartProps extends Omit<\n  React.ComponentProps<typeof ChartContainer>,\n  \"config\" | \"children\"\n> {\n  data: Record<string, unknown>[];\n  /** Key of the x-axis value in each row. */\n  xKey: string;\n  series: ComposedSeries[];\n  referenceLines?: ReferenceLineSpec[];\n  showGrid?: boolean;\n  showYAxis?: boolean;\n  showLegend?: boolean;\n  showTooltip?: boolean;\n  xFormatter?: (value: unknown) => string;\n  yFormatter?: (value: number) => string;\n  rightYFormatter?: (value: number) => string;\n  barRadius?: number;\n  /** Animate series after hydration and when their data changes. Respects reduced motion. */\n  animate?: boolean;\n  animationDuration?: number;\n  /** \"zero\" starts the y-axis at 0; \"auto\" fits it to the data. */\n  yDomain?: \"zero\" | \"auto\" | [number, number];\n}\n\n/** Keyboard focus on the plot gets the shared primary ring. */\nconst FOCUS =\n  \"[&_.recharts-surface:focus-visible]:rounded-lg [&_.recharts-surface:focus-visible]:shadow-[0_0_0_2px_color-mix(in_oklab,var(--color-primary)_30%,transparent)]\";\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\n/** The server snapshot disables motion so hydration starts from identical markup. */\nfunction getReducedMotionServerSnapshot() {\n  return true;\n}\n\nfunction defaultXFormatter(value: unknown) {\n  if (typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}/.test(value)) {\n    const [y, m, d] = value.split(\"-\").map(Number);\n    return new Date(y!, m! - 1, d).toLocaleDateString(\"en-US\", {\n      month: \"short\",\n      day: \"numeric\",\n    });\n  }\n  return String(value);\n}\n\n/* ------------------------------------------------------------ visual tokens */\n\nconst EASE = \"cubic-bezier(0.22,1,0.36,1)\" as const;\n/** cubic-bezier(0.22, 1, 0.36, 1) is the ease-out-quint curve. */\nconst easeOut = (t: number) => 1 - Math.pow(1 - t, 5);\nconst clamp01 = (t: number) => Math.min(1, Math.max(0, t));\nconst mix = (from: number, to: number, t: number) => from + (to - from) * t;\n\nconst GRID = \"color-mix(in oklab, var(--color-foreground) 7%, transparent)\";\nconst CROSSHAIR =\n  \"color-mix(in oklab, var(--color-foreground) 25%, transparent)\";\nconst REFERENCE =\n  \"color-mix(in oklab, var(--color-muted-foreground) 70%, transparent)\";\n/** Lines glow in their own color in dark mode; `color` on each series feeds currentColor. */\nconst GLOW =\n  \"dark:[&_.recharts-area-curve]:[filter:drop-shadow(0_0_6px_color-mix(in_oklab,currentColor_50%,transparent))] dark:[&_.recharts-line-curve]:[filter:drop-shadow(0_0_6px_color-mix(in_oklab,currentColor_50%,transparent))]\";\nconst TICK = { fontSize: 11, fill: \"var(--color-muted-foreground)\" };\n/** Gap between stacked segments, in px. */\nconst STACK_GAP = 1.5;\n\n/** Areas rise from the baseline on entrance; later updates tween in place. */\nfunction RisingAreaShape(props: AreaRevealShapeProps) {\n  const { isEntrance, animationElapsedTime = 1, baseLine } = props;\n  const content = (\n    <AreaRevealShape\n      {...props}\n      isEntrance={false}\n      vectorEffect=\"non-scaling-stroke\"\n    />\n  );\n  if (!isEntrance || animationElapsedTime >= 1) return content;\n  const base =\n    typeof baseLine === \"number\"\n      ? baseLine\n      : Math.max(0, ...(baseLine ?? []).map((point) => point.y ?? 0));\n  const t = Math.max(animationElapsedTime, 0.001);\n  return (\n    <g\n      transform={`translate(0 ${base * (1 - t)}) scale(1 ${t})`}\n      opacity={Math.min(1, t * 4)}\n    >\n      {content}\n    </g>\n  );\n}\n\n/** A solid point with a soft halo. */\nfunction HaloDot({\n  cx,\n  cy,\n  color,\n  r = 3.5,\n}: {\n  cx?: number;\n  cy?: number;\n  color: string;\n  r?: number;\n}) {\n  if (cx == null || cy == null) return null;\n  return (\n    <g data-slot=\"composed-chart-point\" pointerEvents=\"none\">\n      <circle cx={cx} cy={cy} r={r * 2.3} fill={color} fillOpacity={0.18} />\n      <circle\n        cx={cx}\n        cy={cy}\n        r={r}\n        fill={color}\n        stroke=\"var(--color-card)\"\n        strokeWidth={1.5}\n      />\n    </g>\n  );\n}\n\ntype BarInterpolate = NonNullable<BarProps[\"animationInterpolateFn\"]>;\n\n/**\n * Bars rise from their base one after another on entrance and glide on updates.\n * Recharts runs the clock linearly; each bar applies its own delay and easing.\n */\nfunction barTween(count: number, duration: number, delay: number) {\n  const step = count > 1 ? Math.min(32, 320 / (count - 1)) : 0;\n  const total = duration + delay + step * Math.max(count - 1, 0);\n  const interpolate: BarInterpolate = (items, elapsed) => {\n    if (items == null) return [];\n    const entering = items.every((item) => item.status === \"added\");\n    return items.flatMap((item, index) => {\n      const t =\n        elapsed >= 1\n          ? 1\n          : easeOut(\n              clamp01(\n                (elapsed * total - delay - (entering ? index * step : 0)) /\n                  duration,\n              ),\n            );\n      if (item.status === \"removed\") {\n        if (t >= 1) return [];\n        const prev = item.prev;\n        return [\n          {\n            ...prev,\n            height: mix(prev.height, 0, t),\n            y: mix(prev.y, prev.y + prev.height, t),\n          },\n        ];\n      }\n      if (item.status === \"matched\") {\n        const { prev, next } = item;\n        return [\n          {\n            ...next,\n            x: mix(prev.x, next.x, t),\n            y: mix(prev.y, next.y, t),\n            width: mix(prev.width, next.width, t),\n            height: mix(prev.height, next.height, t),\n          },\n        ];\n      }\n      const next = item.next;\n      return [\n        {\n          ...next,\n          height: mix(0, next.height, t),\n          y: mix(next.stackedBarStart, next.y, t),\n        },\n      ];\n    });\n  };\n  return { interpolate, total };\n}\n\n/** A bar that dims while another category is hovered or focused. */\nfunction ComposedBarShape({\n  fill,\n  inset,\n  ...props\n}: BarShapeProps & { fill: string; inset: boolean }) {\n  const active = useActiveTooltipDataPoints();\n  const dimmed =\n    active != null && active.length > 0 && !active.includes(props.payload);\n  const height =\n    inset && Math.abs(props.height) > STACK_GAP * 2\n      ? props.height - STACK_GAP\n      : props.height;\n  return (\n    <Rectangle\n      {...props}\n      height={height}\n      fill={fill}\n      className=\"transition-opacity duration-150 ease-out motion-reduce:transition-none\"\n      style={{ opacity: dimmed ? 0.4 : 1 }}\n    />\n  );\n}\n\ntype Swatch = \"dot\" | \"bar\" | \"dashed\";\n\nfunction SwatchMark({ color, kind }: { color: string; kind: Swatch }) {\n  if (kind === \"dashed\")\n    return (\n      <span\n        aria-hidden=\"true\"\n        className=\"w-3 shrink-0 border-t-2 border-dashed\"\n        style={{ borderColor: color }}\n      />\n    );\n  return (\n    <span\n      aria-hidden=\"true\"\n      className={cn(\n        \"size-2 shrink-0\",\n        kind === \"bar\" ? \"rounded-[2px]\" : \"rounded-full\",\n      )}\n      style={{ backgroundColor: color }}\n    />\n  );\n}\n\nfunction ComposedChart({\n  data,\n  xKey,\n  series,\n  referenceLines = [],\n  showGrid = true,\n  showYAxis = false,\n  showLegend = false,\n  showTooltip = true,\n  xFormatter = defaultXFormatter,\n  yFormatter,\n  rightYFormatter,\n  barRadius = 4,\n  animate = true,\n  animationDuration = 500,\n  yDomain = \"zero\",\n  className,\n  ...props\n}: ComposedChartProps) {\n  const id = React.useId().replace(/:/g, \"\");\n  const reducedMotion = React.useSyncExternalStore(\n    subscribeToReducedMotion,\n    getReducedMotionSnapshot,\n    getReducedMotionServerSnapshot,\n  );\n  const motion = animate && !reducedMotion;\n  const colors = series.map(\n    (s, index) => s.color ?? `var(--color-chart-${(index % 5) + 1})`,\n  );\n  const config = Object.fromEntries(\n    series.map((s, index) => [s.key, { label: s.label, color: colors[index] }]),\n  ) satisfies ChartConfig;\n  const hasRightAxis = series.some((s) => s.axis === \"right\");\n  const hasBars = series.some((s) => s.type === \"bar\");\n  const areaCount = series.filter(\n    (s) => (s.type ?? \"area\") === \"area\" && !s.stackId,\n  ).length;\n  const domain =\n    yDomain === \"auto\"\n      ? ([\"auto\", \"auto\"] as const)\n      : yDomain === \"zero\"\n        ? undefined\n        : yDomain;\n  const swatchFor = (s: ComposedSeries): Swatch =>\n    s.type === \"bar\" ? \"bar\" : s.dashed ? \"dashed\" : \"dot\";\n  const formatterFor = (s: ComposedSeries | undefined) =>\n    s?.axis === \"right\" ? (rightYFormatter ?? yFormatter) : yFormatter;\n\n  // The first and last series of each stack own its rounded outer corners.\n  const stackEnds = new Map<string, { first: string; last: string }>();\n  for (const s of series) {\n    if (s.type !== \"bar\" || !s.stackId) continue;\n    const ends = stackEnds.get(s.stackId);\n    stackEnds.set(s.stackId, { first: ends?.first ?? s.key, last: s.key });\n  }\n  let barIndex = 0;\n\n  const maxPoints = series\n    .filter((s) => s.highlightMax)\n    .map((s) => {\n      let best: { x: unknown; y: number } | null = null;\n      for (const row of data) {\n        const y = Number(row[s.key]);\n        if (Number.isFinite(y) && (!best || y > best.y))\n          best = { x: row[xKey], y };\n      }\n      return best\n        ? {\n            ...best,\n            key: s.key,\n            axis: s.axis ?? \"left\",\n            color: colors[series.indexOf(s)]!,\n          }\n        : null;\n    })\n    .filter((p): p is NonNullable<typeof p> => p !== null);\n\n  return (\n    <ChartContainer\n      data-slot=\"composed-chart\"\n      config={config}\n      className={cn(\"aspect-auto h-64 w-full tabular-nums\", GLOW, FOCUS, className)}\n      {...props}\n    >\n      <RechartsComposedChart\n        data={data}\n        margin={{\n          top: 12,\n          right: hasRightAxis ? 0 : 10,\n          bottom: 0,\n          left: showYAxis ? 0 : 10,\n        }}\n        barCategoryGap=\"24%\"\n        barGap={3}\n      >\n        <defs>\n          {series.map((s, index) => (\n            <React.Fragment key={s.key}>\n              <linearGradient\n                id={`${id}-fill-${index}`}\n                x1=\"0\"\n                y1=\"0\"\n                x2=\"0\"\n                y2=\"1\"\n              >\n                <stop\n                  offset=\"0%\"\n                  stopColor={colors[index]}\n                  stopOpacity={areaCount > 1 ? 0.24 : 0.32}\n                />\n                <stop\n                  offset=\"55%\"\n                  stopColor={colors[index]}\n                  stopOpacity={areaCount > 1 ? 0.08 : 0.11}\n                />\n                <stop offset=\"100%\" stopColor={colors[index]} stopOpacity={0} />\n              </linearGradient>\n              <linearGradient\n                id={`${id}-bar-${index}`}\n                x1=\"0\"\n                y1=\"0\"\n                x2=\"0\"\n                y2=\"1\"\n              >\n                <stop offset=\"0%\" stopColor={colors[index]} stopOpacity={1} />\n                <stop\n                  offset=\"100%\"\n                  stopColor={colors[index]}\n                  stopOpacity={0.72}\n                />\n              </linearGradient>\n              <pattern\n                id={`${id}-hatch-${index}`}\n                patternUnits=\"userSpaceOnUse\"\n                width={6}\n                height={6}\n                patternTransform=\"rotate(45)\"\n              >\n                <rect\n                  width={6}\n                  height={6}\n                  fill={colors[index]}\n                  fillOpacity={0.14}\n                />\n                <rect\n                  width={1.5}\n                  height={6}\n                  fill={colors[index]}\n                  fillOpacity={0.85}\n                />\n              </pattern>\n            </React.Fragment>\n          ))}\n        </defs>\n        {showGrid ? <CartesianGrid vertical={false} stroke={GRID} /> : null}\n        <XAxis\n          dataKey={xKey}\n          tickLine={false}\n          axisLine={false}\n          tickMargin={10}\n          tick={TICK}\n          minTickGap={32}\n          tickFormatter={xFormatter}\n        />\n        <YAxis\n          yAxisId=\"left\"\n          domain={domain}\n          hide={!showYAxis}\n          tickLine={false}\n          axisLine={false}\n          tickMargin={8}\n          tick={TICK}\n          width={44}\n          tickFormatter={yFormatter}\n        />\n        {hasRightAxis ? (\n          <YAxis\n            yAxisId=\"right\"\n            orientation=\"right\"\n            domain={domain}\n            hide={!showYAxis}\n            tickLine={false}\n            axisLine={false}\n            tickMargin={8}\n            tick={TICK}\n            width={44}\n            tickFormatter={rightYFormatter ?? yFormatter}\n          />\n        ) : null}\n        <ChartTooltip\n          isAnimationActive={false}\n          cursor={\n            hasBars || !showTooltip\n              ? false\n              : {\n                  stroke: CROSSHAIR,\n                  strokeWidth: 1,\n                  style: { stroke: CROSSHAIR },\n                }\n          }\n          content={({ active, payload, label }) => {\n            if (!showTooltip || !active || !payload?.length) return null;\n            const rows = payload.filter(\n              (item) => item.type !== \"none\" && item.value != null,\n            );\n            if (!rows.length) return null;\n            return (\n              <div\n                data-slot=\"composed-chart-tooltip\"\n                className=\"min-w-40 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              >\n                <p className=\"mb-1.5 font-medium text-foreground\">\n                  {xFormatter(label)}\n                </p>\n                <div className=\"grid gap-1\">\n                  {rows.map((item) => {\n                    const index = series.findIndex(\n                      (s) => s.key === String(item.dataKey),\n                    );\n                    const s = series[index];\n                    const fmt = formatterFor(s);\n                    const value = Number(item.value);\n                    return (\n                      <div\n                        key={String(item.dataKey)}\n                        className=\"flex items-center gap-2\"\n                      >\n                        <SwatchMark\n                          color={colors[index] ?? String(item.color)}\n                          kind={s ? swatchFor(s) : \"dot\"}\n                        />\n                        <span className=\"text-muted-foreground\">\n                          {s?.label ?? String(item.dataKey)}\n                        </span>\n                        <span className=\"ml-auto pl-4 font-medium text-foreground tabular-nums\">\n                          {fmt ? fmt(value) : String(item.value)}\n                        </span>\n                      </div>\n                    );\n                  })}\n                </div>\n              </div>\n            );\n          }}\n        />\n        {showLegend ? (\n          <ChartLegend\n            content={() => (\n              <div\n                data-slot=\"composed-chart-legend\"\n                className=\"flex flex-wrap items-center justify-center gap-x-4 gap-y-1.5 pt-4 text-xs text-muted-foreground\"\n              >\n                {series.map((s, index) => (\n                  <span key={s.key} className=\"inline-flex items-center gap-1.5\">\n                    <SwatchMark color={colors[index]!} kind={swatchFor(s)} />\n                    {s.label}\n                  </span>\n                ))}\n              </div>\n            )}\n          />\n        ) : null}\n        {series.map((s, index) => {\n          const color = colors[index]!;\n          const common = {\n            dataKey: s.key,\n            yAxisId: s.axis ?? \"left\",\n            stackId: s.stackId,\n            isAnimationActive: motion,\n          };\n          if (s.type === \"bar\") {\n            const tween = barTween(\n              data.length,\n              animationDuration,\n              barIndex++ * 50,\n            );\n            const ends = s.stackId ? stackEnds.get(s.stackId) : undefined;\n            const r = barRadius;\n            const radius: number | [number, number, number, number] = !ends\n              ? r\n              : ends.first === ends.last\n                ? r\n                : ends.last === s.key\n                  ? [r, r, 0, 0]\n                  : ends.first === s.key\n                    ? [0, 0, r, r]\n                    : 0;\n            const hatched = s.pattern === \"hatched\";\n            return (\n              <Bar\n                key={s.key}\n                {...common}\n                animationDuration={tween.total}\n                animationEasing=\"linear\"\n                animationInterpolateFn={tween.interpolate}\n                fill={color}\n                stroke={\n                  hatched\n                    ? `color-mix(in oklab, ${color} 70%, transparent)`\n                    : undefined\n                }\n                strokeWidth={hatched ? 1 : 0}\n                radius={radius}\n                shape={(shape: BarShapeProps) => (\n                  <ComposedBarShape\n                    {...shape}\n                    fill={\n                      hatched\n                        ? `url(#${id}-hatch-${index})`\n                        : `url(#${id}-bar-${index})`\n                    }\n                    inset={Boolean(ends && ends.first !== s.key)}\n                  />\n                )}\n              />\n            );\n          }\n          if (s.type === \"line\") {\n            return (\n              <Line\n                key={s.key}\n                {...common}\n                animationDuration={animationDuration + 200}\n                animationBegin={index * 80}\n                animationEasing={EASE}\n                type={s.curve ?? \"monotone\"}\n                stroke={color}\n                color={color}\n                strokeWidth={2}\n                strokeLinecap={s.dashed ? \"butt\" : \"round\"}\n                strokeLinejoin=\"round\"\n                strokeDasharray={s.dashed ? \"5 5\" : undefined}\n                dot={\n                  s.dots\n                    ? (dot: { cx?: number; cy?: number; index?: number }) =>\n                        dot.cx == null || dot.cy == null ? null : (\n                          <circle\n                            key={`${s.key}-dot-${dot.index}`}\n                            cx={dot.cx}\n                            cy={dot.cy}\n                            r={3}\n                            fill={color}\n                            stroke=\"var(--color-card)\"\n                            strokeWidth={1.5}\n                          />\n                        )\n                    : false\n                }\n                activeDot={(dot: ActiveDotProps) => (\n                  <HaloDot\n                    key={`${s.key}-${dot.index}`}\n                    cx={dot.cx}\n                    cy={dot.cy}\n                    color={color}\n                  />\n                )}\n              />\n            );\n          }\n          return (\n            <Area\n              key={s.key}\n              {...common}\n              animationDuration={animationDuration + 200}\n              animationBegin={index * 60}\n              animationEasing={EASE}\n              type={s.curve ?? \"monotone\"}\n              stroke={color}\n              color={color}\n              strokeWidth={2}\n              strokeLinecap={s.dashed ? \"butt\" : \"round\"}\n              strokeLinejoin=\"round\"\n              strokeDasharray={s.dashed ? \"5 5\" : undefined}\n              fill={`url(#${id}-fill-${index})`}\n              fillOpacity={1}\n              dot={false}\n              activeDot={(dot: ActiveDotProps) => (\n                <HaloDot\n                  key={`${s.key}-${dot.index}`}\n                  cx={dot.cx}\n                  cy={dot.cy}\n                  color={color}\n                />\n              )}\n              shape={RisingAreaShape}\n            />\n          );\n        })}\n        {referenceLines.map((line, index) => (\n          <ReferenceLine\n            key={index}\n            y={line.y}\n            x={line.x}\n            yAxisId={line.axis ?? \"left\"}\n            stroke={line.color ?? REFERENCE}\n            strokeWidth={1}\n            strokeDasharray={line.dashed === false ? undefined : \"3 4\"}\n            label={\n              line.label\n                ? {\n                    value: line.label,\n                    // Sit above a horizontal line, beside a vertical one.\n                    position:\n                      line.y !== undefined\n                        ? \"insideBottomRight\"\n                        : \"insideTopLeft\",\n                    fill: line.color ?? \"var(--color-muted-foreground)\",\n                    fontSize: 11,\n                    fontWeight: 500,\n                    stroke: \"var(--color-card)\",\n                    strokeWidth: 4,\n                    strokeLinejoin: \"round\",\n                    paintOrder: \"stroke\",\n                  }\n                : undefined\n            }\n          />\n        ))}\n        {maxPoints.map((point) => (\n          <ReferenceDot\n            key={point.key}\n            x={point.x as string | number}\n            y={point.y}\n            yAxisId={point.axis}\n            r={4}\n            fill={point.color}\n            stroke=\"var(--color-card)\"\n            strokeWidth={2}\n            shape={(dot) => (\n              <HaloDot\n                cx={Number(dot.cx)}\n                cy={Number(dot.cy)}\n                color={point.color}\n                r={4}\n              />\n            )}\n          />\n        ))}\n      </RechartsComposedChart>\n    </ChartContainer>\n  );\n}\n\nexport { ComposedChart };\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/composed-chart. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
