{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"radar-chart","title":"Radar Chart","description":"Compare one or several series across a handful of measures on spokes that share one value axis. Search terms: spider chart, web chart, polar chart, star chart.","dependencies":[],"registryDependencies":["@siteplane/base","@siteplane/motion","@siteplane/chart","@siteplane/badge"],"files":[{"path":"packages/ui/src/components/radar-chart/radar-chart.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\n\nimport {\n  useFormatLocale,\n  useSiteplaneMessages,\n} from \"../../system/locale/messages-context\";\nimport { cn } from \"../../system/utils/cn\";\nimport { Badge } from \"../badge\";\nimport {\n  CHART_LEGEND_BAND,\n  ChartActiveDot,\n  ChartEmptyState,\n  chartAxisLabelClassName,\n  useChartBox,\n  useFadeClassName,\n  useLastValue,\n} from \"../chart/chart-cartesian\";\nimport {\n  chartDimOpacity,\n  seriesSteppedBack,\n  useChartDimClassName,\n} from \"../chart/chart-dimming\";\nimport {\n  CHART_DEFAULT_LOCALE,\n  chartLabels,\n  chartNumberFormatter,\n  chartTickLabels,\n  chartXFormatter,\n} from \"../chart/chart-format\";\nimport { useChartInteraction } from \"../chart/chart-interaction\";\nimport { ChartLegend, useChartSeriesFocus } from \"../chart/chart-legend\";\nimport {\n  buildCartesianModel,\n  cartesianSummary,\n  type CartesianModel,\n} from \"../chart/chart-model\";\nimport { seriesColors } from \"../chart/chart-palette\";\nimport { valueScale, valueTicks } from \"../chart/chart-scales\";\nimport {\n  ChartPlotPlaceholder,\n  ChartTooltip,\n  ChartTooltipContent,\n  chartTooltipText,\n} from \"../chart/chart-tooltip\";\nimport type {\n  CartesianChartLabels,\n  ChartDatum,\n  ChartPalette,\n  ChartSeries,\n  ChartXValue,\n} from \"../chart/chart-types\";\nimport {\n  followed,\n  useFollowDerived,\n  useFollowValue,\n  useTweenedValues,\n} from \"../motion\";\nimport {\n  nearestTurn,\n  radarAngle,\n  radarLabelPlace,\n  radarLayout,\n  radarPoint,\n  radarPolygonPath,\n  radarSpokeAt,\n  type RadarLayout,\n} from \"./radar-geometry\";\n\nexport type RadarChartProps = {\n  /** One row per spoke, from 12 o'clock clockwise: its name and one number per series. */\n  data: readonly ChartDatum[];\n  /** Key of the name of a spoke in the data. */\n  x: string;\n  series: readonly ChartSeries[];\n  /** The accessible name of the chart. */\n  label: string;\n  /**\n   * The id of an element that describes the chart, read after the summary of\n   * its data that the chart gives assistive technology itself.\n   */\n  \"aria-describedby\"?: string;\n  /** The height of the chart in px, a legend included; the width follows the container. 240 by default. */\n  height?: number;\n  /** Formats a value in the tooltip and on the pills of the vertical spoke. */\n  formatValue?: (value: number) => string;\n  /**\n   * Rolls the values in the tooltip to the next spoke's, digit by digit\n   * (MotionNumber). Off by default: they change at once, so a pointer that\n   * moves round the chart costs the page little work.\n   */\n  rollingNumbers?: boolean;\n  /** Formats the name of a spoke around the rim and in the tooltip heading. */\n  formatX?: (value: ChartXValue) => string;\n  /** The locale of the numbers: the SiteplaneLocaleProvider's unless set, en-US without one. */\n  locale?: string;\n  /**\n   * The colours of the series that name none. `brand` (the default) shades the\n   * brand colour from strong to light, spread over the number of series (up to\n   * eight); `categorical` gives each series its own chart colour, `--chart-1`\n   * to `--chart-8` in order. Both start over from the ninth series. A series\n   * that names its `color` keeps it either way.\n   */\n  palette?: ChartPalette;\n  /** Whether to list the series below the plot. On when there is more than one series. */\n  legend?: boolean;\n  /** The rings of the value axis and the spokes. */\n  grid?: boolean;\n  /** Shown in place of the marks when there is nothing to draw. */\n  emptyLabel?: string;\n  /**\n   * Replaces words that the chart gives screen readers, merged with the\n   * English defaults: its role description, the keyboard hint and the words of\n   * the summary of its data.\n   */\n  labels?: Partial<CartesianChartLabels> | undefined;\n  className?: string;\n};\n\n// A series is drawn as a tint of its colour, as the Area Chart's solid fill,\n// with a 2 px outline, as the Line Chart's lines.\nconst fillOpacity = 0.18;\nconst outlineWidth = 2;\n\n// The focus stop that holds the plot, and the box of the plot before it is drawn.\nconst plotClassName = \"relative block w-full rounded-lg\";\n\n/**\n * One or several series on spokes that share one value axis from the centre\n * out: a spoke per row of the data, from 12 o'clock clockwise, the values of a\n * series joined into a tinted polygon. Rings mark the values of the axis, whose\n * figures stand on pills along the spoke at 12 o'clock; the names of the spokes\n * stand around the rim. The spoke under the pointer is marked by a crosshair\n * and a dot on each series, and the tooltip lists its values; the plot is one\n * focus stop whose arrow keys step round the spokes. A mouse over an entry of\n * the legend steps the other series back. The plot is drawn once the chart has\n * measured its width; new data glides in.\n */\nexport function RadarChart({\n  data,\n  x,\n  series,\n  label,\n  \"aria-describedby\": describedBy,\n  height: givenHeight,\n  formatValue,\n  formatX,\n  locale: localeProp,\n  palette = \"brand\",\n  legend = series.length > 1,\n  grid = true,\n  emptyLabel: emptyLabelProp,\n  labels,\n  className,\n  rollingNumbers = false,\n}: RadarChartProps): React.ReactElement {\n  const messages = useSiteplaneMessages(\"chart\");\n  const emptyLabel = emptyLabelProp ?? messages.noData;\n  // The chart's own locale, else the provider's, else en-US.\n  const locale = useFormatLocale(localeProp, CHART_DEFAULT_LOCALE);\n  const root = React.useRef<HTMLElement>(null);\n  // The chart core sizes the chart: its width follows the container.\n  const box = useChartBox(root, { height: givenHeight });\n  const { height, width } = box;\n  const colors = seriesColors(series, palette);\n  const showLegend = legend && series.length > 0;\n  const focus = useChartSeriesFocus(series.map((item) => item.key));\n  const words = chartLabels(labels, messages);\n  // A row per spoke and the numbers of each series, read as the other charts\n  // read theirs.\n  const model = React.useMemo(\n    () => buildCartesianModel({ data, series, stacked: false, x }),\n    [data, series, x],\n  );\n  const formatHeading = formatX ?? chartXFormatter(locale, \"long\");\n  const formatNumber = formatValue ?? chartNumberFormatter(locale);\n  const description = cartesianSummary({\n    emptyLabel,\n    formatValue: formatNumber,\n    formatX: formatHeading,\n    labels: words,\n    model,\n    series,\n  });\n  const plotHeight = Math.max(0, height - (showLegend ? CHART_LEGEND_BAND : 0));\n\n  return (\n    // The figure holds the plot and the legend. The focus stop inside is the\n    // chart for assistive technology, named by the label alone.\n    <figure\n      className={cn(\"sp-radar-chart\", \"flex w-full flex-col\", className)}\n      data-slot=\"radar-chart\"\n      ref={root}\n    >\n      {width === null ? (\n        <ChartPlotPlaceholder\n          className={plotClassName}\n          description={description}\n          describedBy={describedBy}\n          height={plotHeight}\n          label={label}\n          roleDescription={words.roleDescription}\n        />\n      ) : (\n        <RadarPlot\n          colors={colors}\n          describedBy={describedBy}\n          description={description}\n          emptyLabel={emptyLabel}\n          focusedKey={focus.focusedKey}\n          formatHeading={formatHeading}\n          formatText={formatX ?? chartXFormatter(locale, \"short\")}\n          formatNumber={formatNumber}\n          formatValue={formatValue}\n          grid={grid}\n          height={plotHeight}\n          label={label}\n          locale={locale}\n          model={model}\n          rollingNumbers={rollingNumbers}\n          root={root}\n          series={series}\n          width={width}\n          words={words}\n        />\n      )}\n      {showLegend && (\n        <ChartLegend\n          className=\"pt-3\"\n          focus={focus}\n          items={series.map((item, place) => ({\n            color: colors[place]!,\n            key: item.key,\n            label: item.label,\n          }))}\n          layout=\"row\"\n        />\n      )}\n    </figure>\n  );\n}\n\n/**\n * The hairline from the centre to the rim along the active spoke. It turns to\n * the next spoke the short way round with the follow motion, fades in and out\n * with the active spoke, and waits out of sight where it last was.\n */\nfunction RadarCrosshair({\n  angle,\n  container,\n  layout,\n}: {\n  /** The angle of the active spoke, null for none. */\n  angle: number | null;\n  container: React.RefObject<Element | null>;\n  layout: RadarLayout;\n}): React.ReactElement {\n  const fade = useFadeClassName();\n  const held = useLastValue(angle) ?? 0;\n  // The angle it heads for, unwound so that it never turns more than half\n  // round: from the last spoke to the first across 12 o'clock.\n  const [turn, setTurn] = React.useState(held);\n  const next = nearestTurn(turn, held);\n  if (next !== turn) setTurn(next);\n  const along = useFollowValue(next, { active: angle !== null, container });\n  const x2 = useFollowDerived(\n    along,\n    (value) => radarPoint(layout, value, layout.radius)[0],\n  );\n  const y2 = useFollowDerived(\n    along,\n    (value) => radarPoint(layout, value, layout.radius)[1],\n  );\n  return (\n    <followed.line\n      aria-hidden=\"true\"\n      className={cn(\"sp-chart-crosshair\", \"stroke-border-strong\", fade)}\n      data-slot=\"chart-crosshair\"\n      data-visible={angle !== null ? \"\" : undefined}\n      strokeWidth={1}\n      x1={layout.cx}\n      x2={x2}\n      y1={layout.cy}\n      y2={y2}\n    />\n  );\n}\n\n/**\n * The plot of a Radar Chart at its measured width: the rings and spokes, the\n * series, the names of the spokes, the pills of the value axis, the crosshair\n * and the tooltip.\n */\nfunction RadarPlot({\n  colors,\n  describedBy,\n  description,\n  emptyLabel,\n  focusedKey,\n  formatHeading,\n  formatNumber,\n  formatText,\n  formatValue,\n  grid,\n  height,\n  label,\n  locale,\n  model,\n  rollingNumbers,\n  root,\n  series,\n  width,\n  words,\n}: {\n  colors: readonly string[];\n  describedBy: string | undefined;\n  description: string;\n  emptyLabel: string;\n  focusedKey: string | null;\n  formatHeading: (value: ChartXValue) => string;\n  formatNumber: (value: number) => string;\n  formatText: (value: ChartXValue) => string;\n  formatValue: ((value: number) => string) | undefined;\n  grid: boolean;\n  height: number;\n  label: string;\n  locale: string;\n  model: CartesianModel;\n  rollingNumbers: boolean;\n  root: React.RefObject<HTMLElement | null>;\n  series: readonly ChartSeries[];\n  width: number;\n  words: CartesianChartLabels;\n}): React.ReactElement {\n  const svg = React.useRef<SVGSVGElement>(null);\n  const { rows } = model;\n  const count = rows.length;\n  const names = rows.map((row) => formatText(row.x));\n  const layout = radarLayout({ height, labels: names, width });\n\n  // The value axis runs from the centre out to the rim: a nice domain from 0,\n  // with its ticks as rings.\n  const axis = valueScale(model.extent, [0, layout.radius]);\n  const [, top] = axis.domain() as [number, number];\n  const ticks = valueTicks(axis, layout.radius).filter((tick) => tick >= 0);\n  const tickLabels = chartTickLabels(ticks, locale, formatValue);\n\n  // New data glides in: the end of the axis and every point move to their new\n  // values together, in the units of the data. A change in the number of\n  // spokes or series shows at once.\n  const target = [\n    top,\n    ...model.values.flatMap((own) =>\n      own.map((value) => Math.max(0, value ?? 0)),\n    ),\n  ];\n  const glide = useTweenedValues(target, { container: root });\n  const gliding = glide !== target;\n  const reach = (value: number) =>\n    glide[0]! > 0 ? (Math.max(0, value) / glide[0]!) * layout.radius : 0;\n  const points = series.map((_, place) =>\n    rows.map((_, index) =>\n      radarPoint(\n        layout,\n        radarAngle(index, count),\n        reach(glide[1 + place * count + index] ?? 0),\n      ),\n    ),\n  );\n\n  // The spoke under the pointer is the one nearest to it by its angle.\n  const spokeAt = (clientX: number, clientY: number): string | null => {\n    const bounds = svg.current?.getBoundingClientRect();\n    if (!bounds || !bounds.width || model.empty) return null;\n    const scale = width / bounds.width;\n    const index = radarSpokeAt(\n      layout,\n      count,\n      (clientX - bounds.x) * scale - layout.cx,\n      (clientY - bounds.y) * scale - layout.cy,\n    );\n    return index < 0 ? null : rows[index]!.id;\n  };\n  const interaction = useChartInteraction({\n    itemAt: spokeAt,\n    keys: model.empty ? [] : rows.map((row) => row.id),\n    wrap: true,\n  });\n  const activeIndex = rows.findIndex((row) => row.id === interaction.activeKey);\n  const active = activeIndex >= 0 ? rows[activeIndex] : undefined;\n  const lastKey = useLastValue(interaction.activeKey);\n  const shownIndex = Math.max(\n    0,\n    rows.findIndex((row) => row.id === lastKey),\n  );\n\n  // A series steps back while the mouse is on another series' legend entry.\n  const dimClassName = useChartDimClassName(\"series\");\n\n  // The card sits beside the rim at the active spoke.\n  const anchorFor = (key: string) => {\n    const index = rows.findIndex((row) => row.id === key);\n    const bounds = svg.current?.getBoundingClientRect();\n    if (index < 0 || !bounds || !bounds.width) return null;\n    const scale = bounds.width / width;\n    const [px, py] = radarPoint(\n      layout,\n      radarAngle(index, count),\n      layout.radius,\n    );\n    return { x: bounds.x + px * scale, y: bounds.y + py * scale };\n  };\n  const heading = active ? formatHeading(active.x) : undefined;\n  const tooltipRows = active\n    ? series.flatMap((item, place) => {\n        const value = model.values[place]![activeIndex];\n        return value === null || value === undefined\n          ? []\n          : [\n              {\n                color: colors[place]!,\n                key: item.key,\n                label: item.label,\n                value: formatNumber(value),\n              },\n            ];\n      })\n    : [];\n  const content = active && (\n    <ChartTooltipContent\n      heading={heading}\n      rolling={rollingNumbers}\n      rows={tooltipRows}\n    />\n  );\n  const rim = rows.map((_, index) =>\n    radarPoint(layout, radarAngle(index, count), layout.radius),\n  );\n\n  return (\n    <ChartTooltip\n      align=\"center\"\n      anchorFor={anchorFor}\n      announcement={active ? chartTooltipText(heading, tooltipRows) : undefined}\n      className={plotClassName}\n      content={content}\n      describedBy={describedBy}\n      description={description}\n      interaction={interaction}\n      keyboardHint={words.keyboardHint}\n      label={label}\n      roleDescription={words.roleDescription}\n    >\n      {/* The plot is a picture that the focus stop describes, so it is\n          hidden from assistive technology. No SVG titles: the browser would\n          show its own tooltip next to the chart's. */}\n      <svg\n        aria-hidden=\"true\"\n        className=\"block w-full overflow-visible\"\n        height={height}\n        ref={svg}\n        viewBox={`0 0 ${width} ${height}`}\n        width={width}\n      >\n        {grid && !model.empty && count > 0 && (\n          <g\n            className=\"sp-radar-chart-grid stroke-border\"\n            data-slot=\"radar-chart-grid\"\n            fill=\"none\"\n            strokeWidth={1}\n          >\n            {ticks\n              .filter((tick) => tick > 0)\n              .map((tick) => (\n                <path\n                  d={radarPolygonPath(\n                    rows.map((_, index) =>\n                      radarPoint(layout, radarAngle(index, count), reach(tick)),\n                    ),\n                  )}\n                  key={tick}\n                />\n              ))}\n            {rim.map(([px, py], index) => (\n              <line\n                key={rows[index]!.id}\n                x1={layout.cx}\n                x2={px}\n                y1={layout.cy}\n                y2={py}\n              />\n            ))}\n          </g>\n        )}\n        {!model.empty &&\n          series.map((item, place) => (\n            <path\n              className={cn(\"sp-chart-area\", dimClassName)}\n              d={radarPolygonPath(points[place]!)}\n              data-slot=\"chart-area\"\n              fill={colors[place]}\n              fillOpacity={fillOpacity}\n              key={`area-${item.key}`}\n              opacity={chartDimOpacity(\n                \"area\",\n                seriesSteppedBack(focusedKey, item.key),\n              )}\n            />\n          ))}\n        {!model.empty &&\n          series.map((item, place) => (\n            <path\n              className={cn(\"sp-chart-line\", dimClassName)}\n              d={radarPolygonPath(points[place]!)}\n              data-slot=\"chart-line\"\n              fill=\"none\"\n              key={`line-${item.key}`}\n              opacity={chartDimOpacity(\n                \"area\",\n                seriesSteppedBack(focusedKey, item.key),\n              )}\n              stroke={colors[place]}\n              strokeLinejoin=\"round\"\n              strokeWidth={outlineWidth}\n            />\n          ))}\n        {!model.empty && count > 0 && (\n          <g\n            aria-hidden=\"true\"\n            className={cn(\"sp-chart-axis\", chartAxisLabelClassName)}\n            data-slot=\"chart-axis\"\n          >\n            {rows.map((row, index) => {\n              const place = radarLabelPlace(layout, radarAngle(index, count));\n              return (\n                <text\n                  dy={place.dy}\n                  key={row.id}\n                  textAnchor={place.anchor}\n                  x={place.x}\n                  y={place.y}\n                >\n                  {names[index]}\n                </text>\n              );\n            })}\n          </g>\n        )}\n        {!model.empty && count > 0 && (\n          <>\n            <RadarCrosshair\n              angle={active ? radarAngle(activeIndex, count) : null}\n              container={root}\n              layout={layout}\n            />\n            {series.map((item, place) => {\n              const value = model.values[place]![shownIndex];\n              if (value === null || value === undefined) return null;\n              const [cx, cy] = radarPoint(\n                layout,\n                radarAngle(shownIndex, count),\n                reach(value),\n              );\n              return (\n                <ChartActiveDot\n                  color={colors[place]!}\n                  container={root}\n                  cx={cx}\n                  cy={cy}\n                  key={item.key}\n                  visible={active !== undefined && !gliding}\n                />\n              );\n            })}\n          </>\n        )}\n      </svg>\n      {/* The values of the rings, on pills along the spoke at 12 o'clock: the\n          kit's Badge, in HTML over the plot, which never takes the pointer. */}\n      {!model.empty && count > 0 && (\n        <div\n          aria-hidden=\"true\"\n          className=\"sp-radar-chart-ticks pointer-events-none absolute inset-0\"\n          data-slot=\"radar-chart-ticks\"\n        >\n          {ticks.map((tick, index) => (\n            <span\n              className=\"sp-radar-chart-tick absolute -translate-x-1/2 -translate-y-1/2\"\n              data-slot=\"radar-chart-tick\"\n              key={tick}\n              style={{\n                left: layout.cx,\n                top: layout.cy - reach(tick),\n              }}\n            >\n              <Badge shape=\"pill\" size=\"sm\">\n                {tickLabels[index]}\n              </Badge>\n            </span>\n          ))}\n        </div>\n      )}\n      {model.empty && <ChartEmptyState label={emptyLabel} />}\n    </ChartTooltip>\n  );\n}\n","type":"registry:ui","target":"~/src/siteplane/components/radar-chart/radar-chart.tsx"},{"path":"packages/ui/src/components/radar-chart/radar-geometry.ts","content":"/*\n * The geometry of the Radar Chart: one spoke per row of the data, from 12\n * o'clock clockwise, the values of each series as points along the spokes,\n * joined into a polygon. The plot, the pointer, the labels and the tooltip all\n * read the same layout.\n */\n\nimport { CHART_LABEL_HEIGHT } from \"../chart/chart-cartesian\";\nimport { estimateLabelWidth } from \"../chart/chart-scales\";\n\n/** The space between the rim and the name of a spoke, in px. */\nexport const RADAR_LABEL_GAP = 8;\n/**\n * Half the height of a value pill on the vertical spoke, in px: the name of\n * the spoke at 12 o'clock stands clear of the pill at the rim.\n */\nexport const RADAR_PILL_HALF = 11;\n// The room beyond the rim, in px, in which the pointer still finds a spoke.\nconst pointerSlack = 32;\n\n/** Where the radar sits in its plot: its centre and the radius of its rim, in px. */\nexport type RadarLayout = { cx: number; cy: number; radius: number };\n\n/**\n * The radar in a plot `width` by `height` px: centred, and as large as the\n * names of its spokes leave room for. The name at 12 o'clock stands above the\n * pill of the rim's value, so the plot keeps that pill, the gap and a line of\n * text above and below the rim; to the sides it keeps the gap and the widest\n * name.\n */\nexport function radarLayout({\n  height,\n  labels,\n  width,\n}: {\n  height: number;\n  labels: readonly string[];\n  width: number;\n}): RadarLayout {\n  const widest = Math.max(0, ...labels.map(estimateLabelWidth));\n  const above = RADAR_PILL_HALF + RADAR_LABEL_GAP + CHART_LABEL_HEIGHT;\n  const beside = RADAR_LABEL_GAP + widest;\n  return {\n    cx: width / 2,\n    cy: height / 2,\n    radius: Math.max(0, Math.min(height / 2 - above, width / 2 - beside)),\n  };\n}\n\n/** The angle of spoke `index` of `count`, in radians from 12 o'clock, clockwise. */\nexport function radarAngle(index: number, count: number): number {\n  return count > 0 ? (index / count) * 2 * Math.PI : 0;\n}\n\nconst round = (value: number) => Math.round(value * 100) / 100;\n\n/** The point `reach` px out along the spoke at `angle`, in px of the plot. */\nexport function radarPoint(\n  layout: RadarLayout,\n  angle: number,\n  reach: number,\n): [x: number, y: number] {\n  return [\n    round(layout.cx + reach * Math.sin(angle)) || 0,\n    round(layout.cy - reach * Math.cos(angle)) || 0,\n  ];\n}\n\n/** A closed polygon through the points, in order. Empty for none. */\nexport function radarPolygonPath(\n  points: readonly (readonly [number, number])[],\n): string {\n  if (points.length === 0) return \"\";\n  return `${points.map(([x, y], index) => `${index === 0 ? \"M\" : \"L\"}${x},${y}`).join(\" \")} Z`;\n}\n\n/**\n * Where the name of a spoke stands and how it is set: the gap beyond the rim\n * (and beyond the value pill at 12 o'clock), anchored away from the centre, so\n * a name on the right starts there and one on the left ends there, and moved\n * from above the point at the top to below it at the bottom.\n */\nexport function radarLabelPlace(\n  layout: RadarLayout,\n  angle: number,\n): { anchor: \"start\" | \"middle\" | \"end\"; dy: string; x: number; y: number } {\n  const sin = Math.sin(angle);\n  const cos = Math.cos(angle);\n  const top = cos > 0.999;\n  const [x, y] = radarPoint(\n    layout,\n    angle,\n    layout.radius + RADAR_LABEL_GAP + (top ? RADAR_PILL_HALF : 0),\n  );\n  return {\n    anchor: Math.abs(sin) < 0.1 ? \"middle\" : sin > 0 ? \"start\" : \"end\",\n    // From the baseline on the point at the top (0.32em less 0.4em: the text\n    // stands on it) through the middle of a line at the sides to the top of\n    // the text on the point at the bottom.\n    dy: `${round(0.32 - 0.4 * cos)}em`,\n    x,\n    y,\n  };\n}\n\n/**\n * The spoke nearest to a point by its angle, or -1 in the very centre and\n * beyond the rim and its slack. The point is an offset from the centre in px,\n * with y growing downwards.\n */\nexport function radarSpokeAt(\n  layout: RadarLayout,\n  count: number,\n  dx: number,\n  dy: number,\n): number {\n  const distance = Math.hypot(dx, dy);\n  if (count <= 0 || distance === 0 || distance > layout.radius + pointerSlack)\n    return -1;\n  const turn = (Math.atan2(dx, -dy) / (2 * Math.PI) + 1) % 1;\n  return Math.round(turn * count) % count;\n}\n\n/**\n * The angle a follower heads for to reach `angle` from `from` the short way\n * round: `angle` plus the whole turns that bring it nearest to `from`, so the\n * crosshair turns from the last spoke to the first across 12 o'clock and not\n * back round the whole radar.\n */\nexport function nearestTurn(from: number, angle: number): number {\n  const turn = 2 * Math.PI;\n  return angle + Math.round((from - angle) / turn) * turn;\n}\n","type":"registry:ui","target":"~/src/siteplane/components/radar-chart/radar-geometry.ts"},{"path":"packages/ui/src/components/radar-chart/index.ts","content":"export * from \"./radar-chart\";\n","type":"registry:ui","target":"~/src/siteplane/components/radar-chart/index.ts"}],"type":"registry:ui","docs":"https://ui.siteplane.io/docs-markdown/components/radar-chart.md","categories":["Charts"],"meta":{"avoidWhen":["Avoid when the measures have different units or their order means nothing; use a Bar Chart or a Table, where values compare along one axis.","Avoid for change over many dates; use a Line Chart or an Area Chart."],"description":"Compare one or several series across a handful of measures on spokes that share one value axis.","knownLimitations":["All series share one value axis from 0 at the center to a round value at the rim; a value below 0 or a missing one sits at the center, and a missing one leaves the tooltip for its spoke.","The radar keeps room around the rim for the names of the spokes and the top pill of the axis, so long names make it smaller. height is a number of px, 240 by default, the legend included; there is no fill height.","The plot is one focus stop; the arrow keys step round the spokes and wrap. Spokes and series have no click or selection props, and the legend does not toggle series.","New data glides in when the number of spokes and series stays the same; a change in either shows at once.","The plot is drawn once the chart has measured its width; until then, and in the server HTML, the chart renders the box of the plot at its full height, the legend and what screen readers read."],"providerNotes":["The tooltip comes from the installed Tooltip. The chart opens and closes it itself, so it needs no TooltipProvider.","The glide uses the installed Motion component and its tokens. SiteplaneMotionProvider preset=\"reduced\" and the system setting show new data at once."],"releaseStatus":"preview","searchTerms":["radar chart","radar","spider chart","web chart","polar chart","star chart"],"useWhen":["Use to compare the profile of a few series across three to about ten measures on one scale, such as survey scores by area or sessions by weekday.","Use one series to show the shape of a single measure across the spokes, with the tooltip for exact values."]}}