"use client"; import { motion } from "framer-motion"; import { COLORS, VizFrame } from "./common"; export type RadialNode = { label: string; sub?: string }; export function Radial({ center, nodes, width = 760, height = 480, }: { center: string; nodes: RadialNode[]; width?: number; height?: number; }) { const cx = width / 2; const cy = height / 2; const r = Math.min(width, height) / 2.7; return ( {nodes.map((n, i) => { const a = (i / nodes.length) * Math.PI * 2 - Math.PI / 2; const x = cx + Math.cos(a) * r; const y = cy + Math.sin(a) * r; return ( ); })} {center} {nodes.map((n, i) => { const a = (i / nodes.length) * Math.PI * 2 - Math.PI / 2; const ux = Math.cos(a); const uy = Math.sin(a); const x = cx + ux * r; const y = cy + uy * r; // Push label outward from the dot to keep it clear of neighbours. const lx = cx + ux * (r + 24); const ly = cy + uy * (r + 24); // Anchor based on horizontal direction; vertical centre on the line. const anchor: "start" | "middle" | "end" = ux > 0.25 ? "start" : ux < -0.25 ? "end" : "middle"; // Sub line below or above depending on vertical position. const subDy = uy > 0 ? 14 : -14; const subY = uy > 0 ? ly + subDy : ly + subDy; return ( {n.label} {n.sub ? ( {n.sub} ) : null} ); })} ); }