/** * Generic pixel-space label geometry helpers shared by the axis, * legend, and tooltip overlays. * * All rectangles are in CSS pixels, origin top-left, Y-axis pointing down. */ import type { Context2D } from "../charts/canvas-types"; export interface Rect { x: number; y: number; width: number; height: number; } export type Rotation = 0 | 45 | 90; /** * Bounding rectangle of a text label anchored at `(cx, cy)`, accounting for * rotation. Matches d3fc's approximation of rotated text bounds. */ export declare function labelRect(cx: number, cy: number, textWidth: number, textHeight: number, rotation: Rotation): Rect; export declare function rectsOverlap(a: Rect, b: Rect): boolean; /** * Rotated-label overlap heuristic from d3fc: for steeply-rotated labels * the right edge of the previous box must precede the right edge of the * next (plus a small gap). */ export declare function rotatedLabelsOverlap(a: Rect, b: Rect): boolean; export declare function rectContained(inner: Rect, outer: Rect): boolean; /** * Truncate `label` with a trailing ellipsis so the rendered width fits * within `maxWidth`. Returns "" when even one character would overflow. */ export declare function truncateLabel(ctx: Context2D, label: string, maxWidth: number): string; /** * Word-wrap `text` into at most `maxLines` lines, each fitting within * `maxWidth`. Breaks at the last whitespace before the fit boundary * when possible, falls back to a hard character break otherwise. The * final line is ellipsis-truncated via {@link truncateLabel} if it * still doesn't fit. Returns `[]` when nothing meaningful fits (only * one line of ≤ 2 chars after wrapping). */ export declare function wrapLabel(ctx: Context2D, text: string, maxWidth: number, maxLines: number): string[];