{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"line-chart","type":"registry:ui","title":"Line Chart","description":"Values over time as lines, with dashed ones for a target or last year; the axis fits the values so changes show. Plain SVG.","dependencies":[],"registryDependencies":["https://dashral.com/r/utils.json","https://dashral.com/r/lib-chart.json","https://dashral.com/r/lib-locale.json"],"files":[{"path":"registry/dashral/line-chart.tsx","type":"registry:file","target":"components/dashral/line-chart.tsx","content":"\"use client\"\n\nimport * as React from \"react\"\n\nimport { type CartesianChartProps, type RightAxisProps, ChartAxes, ChartLegend, ChartReading, type Curve, linePath, seriesColor, useCartesianChart } from \"./lib/chart\"\nimport { useLocale } from \"./lib/locale\"\nimport { cn } from \"./lib/utils\"\n\ntype LineChartProps = Omit<React.ComponentProps<\"div\">, \"children\"> &\n  CartesianChartProps &\n  RightAxisProps & {\n    /** How the line bends between points: smoothly (never past a value it didn't have), straight, or in steps. */\n    curve?: Curve\n    /** A dot on every point, not only the one being read. */\n    showDots?: boolean\n    /** Starts the axis at zero. Off by default: a line shows change, so the axis fits the values. */\n    startAtZero?: boolean\n    classNames?: { legend?: string; tooltip?: string }\n  }\n\n/**\n * Values over time as lines: one or several, with dashed ones for comparisons (a target, last year). The axis fits\n * the values unless it's asked to start at zero, so small changes show. Hover, or focus it and use the arrow keys, to\n * read a point: a line marks it and a tooltip lists every series there. Plain SVG, fills its container's width; it\n * draws in from the left when it first shows and moves to new data.\n */\nfunction LineChart({\n  data,\n  index,\n  labelKey,\n  series,\n  height,\n  locale,\n  formatOptions,\n  rightFormatOptions,\n  alignZero,\n  timeFormat,\n  showLegend,\n  showGrid,\n  showYAxis,\n  curve = \"smooth\",\n  showDots = false,\n  startAtZero = false,\n  className,\n  classNames,\n  \"aria-label\": ariaLabel,\n  ...props\n}: LineChartProps) {\n  const { t } = useLocale()\n  const h = useCartesianChart({\n    data,\n    index,\n    labelKey,\n    series,\n    height,\n    locale,\n    formatOptions,\n    rightFormatOptions,\n    alignZero,\n    timeFormat,\n    showLegend,\n    showGrid,\n    showYAxis,\n    zero: startAtZero,\n    axes: true,\n    \"aria-label\": ariaLabel,\n    roledescription: t(\"lineChart\"),\n  })\n  const n = data.length\n\n  return (\n    <div data-slot=\"line-chart\" {...h.root} className={cn(\"grid gap-3 rounded-md outline-none focus-visible:ring-2 focus-visible:ring-ring/50\", className)} {...props}>\n      {h.showLegend && <ChartLegend series={series} className={classNames?.legend} />}\n\n      <div ref={h.box} dir=\"ltr\" className=\"relative w-full touch-none select-none\" style={{ height: h.height }} {...h.plot}>\n        {h.width !== null && n > 0 && (\n          <>\n            <ChartAxes chart={h} band={false} />\n\n            {/* The lines, drawn in from the left when the chart first shows; new data moves them to their new shape. */}\n            <svg\n              aria-hidden\n              width={h.width}\n              height={h.height}\n              className=\"absolute inset-0 overflow-visible transition-[clip-path] duration-(--duration-considered) ease-enter motion-reduce:transition-none\"\n              style={{ clipPath: h.drawn ? \"inset(-8px -8px -8px -8px)\" : `inset(0 ${h.width}px 0 0)` }}\n            >\n              {series.map((s, k) => {\n                const points = h.columns.map((cell, i) => ({ x: h.x(i), y: h.yFor(k, cell[k]!.value) }))\n                return (\n                  <g key={s.key}>\n                    <path\n                      d={linePath(points, curve)}\n                      fill=\"none\"\n                      stroke={seriesColor(s, k)}\n                      strokeWidth={s.dashed ? 1.5 : 2}\n                      strokeDasharray={s.dashed ? \"4 4\" : undefined}\n                      strokeOpacity={s.dashed ? 0.7 : 1}\n                      strokeLinejoin=\"round\"\n                      strokeLinecap=\"round\"\n                      className=\"transition-[d] duration-(--duration-considered) ease-standard motion-reduce:transition-none\"\n                    />\n                    {showDots &&\n                      !s.dashed &&\n                      points.map((p, i) => <circle key={i} cx={p.x} cy={p.y} r={3} fill=\"var(--background)\" stroke={seriesColor(s, k)} strokeWidth={1.5} />)}\n                  </g>\n                )\n              })}\n            </svg>\n\n            <ChartReading chart={h} series={series} band={false} className={classNames?.tooltip} />\n          </>\n        )}\n        {n === 0 && <p className=\"grid h-full place-items-center text-sm text-muted-foreground\">{t(\"noData\")}</p>}\n      </div>\n      <p aria-live=\"polite\" className=\"sr-only\">\n        {h.announce}\n      </p>\n    </div>\n  )\n}\n\nexport { LineChart, type LineChartProps }\nexport type { ChartDatum, ChartSeries } from \"./lib/chart\"\n"}],"cssVars":{"theme":{"ease-standard":"var(--ease-standard)","ease-enter":"var(--ease-enter)","ease-exit":"var(--ease-exit)","ease-spring":"var(--ease-spring)"},"light":{"duration-fast":"160ms","duration-standard":"240ms","duration-considered":"480ms","ease-standard":"cubic-bezier(0.2, 0, 0, 1)","ease-enter":"cubic-bezier(0, 0, 0, 1)","ease-exit":"cubic-bezier(0.3, 0, 1, 1)","ease-spring":"linear(0, 0.071 4%, 0.234 8%, 0.433 12%, 0.626 17%, 0.791 21%, 0.917 25%, 1.004 29%, 1.055 33%, 1.079 38%, 1.083 42%, 1.075 46%, 1.06 50%, 1.043 54%, 1.027 58%, 1.015 62%, 1.005 67%, 0.998 71%, 0.995 75%, 0.993 79%, 0.993 83%, 0.994 88%, 0.995 92%, 0.997 96%, 1)"},"dark":{}}}