import { Selection, BaseType } from 'd3-selection'; import { Rect } from '../types/misc'; export interface ResolveRectsOverlapOptions { /** Padding for the intersection test, forwarded to `rectIntersect`. * A negative value expands the rects (hides more eagerly / enforces a minimum gap), * a positive value shrinks them (rects must overlap more before being considered colliding). Default: `0` */ tolerance?: number; /** Optional per-rect priority, aligned to `rects`. When two rects collide, the one with the higher priority * stays visible. Ties (or when omitted) are resolved in favour of the rect that comes first in sweep order * (the left-most / top-most one). Default: `undefined` */ priorities?: number[]; } /** * Resolves overlaps among a set of axis-aligned rectangles using a sort-and-sweep * ("sweep and prune") algorithm. Works for text distributed along one axis (axis tick * labels, heatmap row / column labels) as well as text distributed across a 2D grid. * * The sweep axis is chosen automatically as the axis along which the rects are more * spread out, keeping the active set small in every layout. Overlapping cascades are * resolved in a single pass: it runs in `O(n log n)` for spatially separated rects and * only degrades towards `O(n²)` when many rects genuinely share the sweep-axis interval. * * @returns A boolean array aligned to `rects`: `true` = keep visible, `false` = hide. */ export declare function resolveRectsOverlap(rects: Rect[], options?: ResolveRectsOverlapOptions): boolean[]; /** * Hides overlapping label elements in a d3 selection by measuring their on-screen * bounding boxes and resolving collisions with {@link resolveRectsOverlap}. Visible * labels get `opacity: 1`, hidden ones `opacity: 0`. Call inside a `requestAnimationFrame` * to avoid forcing a synchronous reflow. */ export declare function hideOverlappingLabels(selection: Selection, options?: ResolveRectsOverlapOptions): void;