import type { ReactNode } from "react"; import { cn } from "@/lib/utils"; const TOOLTIP_WIDTH_GUESS = 200; const OFFSET = 12; /** * The one tooltip panel every chart uses, positioned inside the chart's * `relative` wrapper. It flips to the left of the pointer near the right edge * so it never spills out of the card. */ export function ChartTooltip({ x, y, containerWidth, children, }: { x: number; y: number; containerWidth: number; children: ReactNode; }) { const flip = x + OFFSET + TOOLTIP_WIDTH_GUESS > containerWidth; return (
{color && ( )} {label} {value}
); }