/** * Dependency-free chart math, palette, and formatting helpers shared across * the charts/ family. Pure functions only — unit-tested in chart.utils.test.ts. * * Following the repo's zero-dependency philosophy (see Sankey's embedded * layout and the custom tv() engine), charts hand-roll their scales rather * than pulling in d3. */ /** A point in plot-local SVG coordinates. */ export type ChartPoint = [x: number, y: number]; /** Inclusive `[min, max]` of a numeric array; `[0, 0]` for an empty array. */ export declare function extent(values: readonly number[]): [number, number]; /** * Linear mapping from a numeric `domain` onto a pixel `range`. A zero-width * domain collapses to the range start (avoids divide-by-zero → NaN coords). */ export declare function linearScale(domain: [number, number], range: [number, number]): (value: number) => number; /** Categorical band scale over `count` items across a pixel `range`. */ export interface BandScale { /** Left edge of band `index`. */ position(index: number): number; /** Center of band `index` (use for line/scatter x). */ center(index: number): number; /** Rendered width of a single band (step minus padding). */ bandwidth: number; /** Distance between consecutive band starts. */ step: number; } /** * Evenly spaced categorical bands with inner padding. `padding` is the * fraction (0–1) of each step left empty around bands. */ export declare function bandScale(count: number, range: [number, number], padding?: number): BandScale; /** * Round a raw `[min, max]` outward to "nice" round bounds suitable for an * axis and return evenly spaced tick values within them (Heckbert's * algorithm). With `includeZero` (default) the domain always reaches zero * for single-signed data so bars sit on a real baseline. */ export declare function niceScale(rawMin: number, rawMax: number, tickCount?: number, includeZero?: boolean): { min: number; max: number; ticks: number[]; }; /** SVG path `d` for a polyline through `points` (straight segments). */ export declare function linePath(points: readonly ChartPoint[]): string; /** SVG path `d` for a filled area between `points` and a horizontal `baselineY`. */ export declare function areaPath(points: readonly ChartPoint[], baselineY: number): string; /** * SVG path `d` for a donut/pie segment between `startAngle` and `endAngle` * (radians, clockwise from 12 o'clock). `innerRadius` of 0 yields a filled pie * slice. A full-circle sweep is split into two arcs so it renders as a ring * rather than collapsing to a point. */ export declare function arcPath(cx: number, cy: number, outerRadius: number, innerRadius: number, startAngle: number, endAngle: number): string; /** * Ordered categorical palette mapped to the `--color-chart-*` tokens * (declared in `style/semantic.css`). Cycles for series beyond its length. */ export declare const chartPalette: readonly string[]; /** Resolve a series color: explicit override wins, else cycle the palette. */ export declare function seriesColor(index: number, explicit?: string, palette?: readonly string[]): string; /** * A locale-aware number formatter. Falls back to `String(value)` if `Intl` * is unavailable (defensive — present in every modern browser + SSR runtime). */ export declare function numberFormatter(locale?: string, options?: Intl.NumberFormatOptions): (value: number) => string;