{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "area-chart",
  "title": "Area chart",
  "description": "Values over time as filled areas, overlapping, stacked or as shares, or as a band from a low to a high value. The day under the pointer stays bright, line and fill, while the rest steps back, and a new range, a hidden series or a new layout moves each area from where it is.",
  "dependencies": [],
  "registryDependencies": [
    "https://kinoui.com/r/chart-area-marks.json",
    "https://kinoui.com/r/chart-line-marks.json",
    "https://kinoui.com/r/chart.json",
    "https://kinoui.com/r/chart-core.json",
    "https://kinoui.com/r/chart-line.json",
    "https://kinoui.com/r/chart-math.json",
    "https://kinoui.com/r/line-path.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/area-chart.tsx",
      "content": "'use client'\n\nimport { areaMarks } from '@/registry/lib/chart-area-marks'\nimport { figureProps, seriesWords, useDeclared } from '@/registry/lib/chart-base'\nimport {\n  type CartesianChartProps,\n  cartesianChartKeys,\n  cartesianSignature,\n  cartesianWords,\n  type ChartPartDeclaration,\n  type LiveChartProps,\n  useCartesianChart,\n} from '@/registry/lib/chart-cartesian'\nimport {\n  framePoints,\n  frameRest,\n  frameTop,\n  LineFamilyFrame,\n  LinePlaceholder,\n  LineSeries,\n  type LineSeriesProps,\n} from '@/registry/lib/chart-line'\nimport { lineMarks } from '@/registry/lib/chart-line-marks'\nimport { type ChartStack, plotPoint, rangeOf } from '@/registry/lib/chart-math'\nimport type { LineCurve } from '@/registry/lib/line-path'\n\n/*\n * The Area chart: the Line chart's lines with the area under each filled,\n * side by side or stacked. Its areas, their moves and the window that keeps\n * the lit category bright come from the chart line lib, which the Line chart\n * shares, and its fill from the area fill lib, which the Sparkline shares.\n * Each area's line and baseline move together, so a new range stretches\n * the area, a hidden series folds into the one below it, and the areas\n * above settle onto what is left. A series the config draws as a `line`,\n * such as last year's to compare with, is a `Line` among the areas.\n */\n\ninterface AreaChartProps extends CartesianChartProps, LiveChartProps {\n  /**\n   * How the areas of one category combine: each from zero, overlapping, the\n   * default; stacked on each other in the order of the config; or stacked\n   * to fill the axis as shares of their total.\n   */\n  stack?: Exclude<ChartStack, 'overlap'>\n  /**\n   * How the areas arrive the first time the chart comes into view: rising\n   * from zero, drawn along from the reading start, or simply there, the\n   * default, since a page that loads doesn't animate into place.\n   */\n  entrance?: 'rise' | 'draw' | 'none'\n}\n\nconst areaChartKeys = [...cartesianChartKeys, 'stack', 'entrance']\n\n/** Every series at a stop, read along x. */\nconst X_BROWSE = { kind: 'x' } as const\n\n/** The legend's keys are plain swatches. */\nfunction noMarker() {\n  return null\n}\n\n/**\n * The chart's root: it lays out the frame its parts draw in, places each\n * category along the plot from edge to edge, and fits the value axis to the\n * areas, always from zero, since an area's size is its value.\n */\nfunction AreaChart(props: AreaChartProps) {\n  const {\n    stack = 'none',\n    entrance = 'none',\n    description,\n    empty,\n    className,\n    children,\n    ref,\n  } = props\n  const made = useCartesianChart(props, {\n    kinds: [areaMarks, lineMarks],\n    orientation: 'vertical',\n    stack,\n    entrance: entrance !== 'none',\n  })\n  const { model, placeholder, phase } = made\n  // An area's fill fades, so a pattern on it would fade away; its key stays solid.\n  const chart = { ...made.chart, patternOf: () => 'solid' as const }\n  const cartesian = { ...made, chart }\n  const isLine = (key: string) => model.markOf(key) === 'line'\n  return (\n    <LineFamilyFrame\n      chart={cartesian}\n      markerOf={noMarker}\n      // The tooltip sits over the highest of the stop's areas.\n      anchor={(stop) => {\n        const along = chart.entered ? model.reach(stop.index) : null\n        return plotPoint(\n          stop.band,\n          along ?? model.baselines.value,\n          'vertical',\n          chart.direction,\n        )\n      }}\n      words={seriesWords(chart, cartesianWords(chart, null))}\n      browse={X_BROWSE}\n      family={{\n        name: 'area-chart',\n        phase,\n        entrance,\n        // A hidden area folds into the one below it; a hidden line lies flat, as the Line chart's.\n        pointsOf: (key, rising) =>\n          framePoints(\n            chart,\n            model,\n            key,\n            rising || (isLine(key) && chart.hidden.includes(key)),\n            !isLine(key),\n          ),\n        topOf: (key, stop) => frameTop(model, key, stop),\n        // A value given as a range is marked at both ends.\n        bottomOf: (key, stop) =>\n          !isLine(key) && rangeOf(chart.valueOf(key, stop))\n            ? frameTop(model, key, stop, true)\n            : null,\n        restOf: (key) => frameRest(model, key),\n      }}\n      description={description}\n      empty={empty}\n      placeholder={placeholder && <LinePlaceholder name='area-chart' fill />}\n      className={className}\n      ref={ref}\n      {...figureProps(props, areaChartKeys)}\n    >\n      {children}\n    </LineFamilyFrame>\n  )\n}\n\ntype AreaProps = Omit<LineSeriesProps, 'forecastFrom' | 'connectNulls' | 'dashed'>\n\n/**\n * One series' area, in the series' colour: a layer of the plot holding its\n * fill, the line along its top, and a dot on each point. When a category is\n * lit, the area steps back, leaving it bright around the category, a window\n * that glides with the axis's pill.\n */\nfunction Area(props: AreaProps) {\n  useDeclared('Area', Area.declare(props), cartesianSignature)\n  return <LineSeries {...props} fill />\n}\n\nArea.declare = ({ dataKey, data }: AreaProps): ChartPartDeclaration => ({\n  series: { key: dataKey, mark: 'area' },\n  ...(data === undefined ? {} : { rows: data }),\n})\n\nexport {\n  Area,\n  AreaChart,\n  type AreaChartProps,\n  type AreaProps,\n  type LineCurve as AreaCurve,\n}\n",
      "type": "registry:component",
      "target": "@components/kino/area-chart.tsx"
    }
  ],
  "type": "registry:component"
}