/** * Chart scales and geometry primitives. * * Every coordinate passes through `round()` (two decimals) before it reaches * the markup, so floating-point noise never breaks byte-determinism. Axis * bounds end on clean ticks (1, 2, 2.5 or 5 × 10ⁿ). */ import { type FormatSpec } from '../data/format-value.js'; import type { ChartSeries } from './chart-types.js'; export interface Bounds { min: number; max: number; } export interface TickBounds extends Bounds { step: number; } export interface Frame { width: number; height: number; top: number; right: number; bottom: number; left: number; } /** * Shared viewBox width. Text inside the SVG scales with the rendered width, so * this is sized for a full-width card: labels render near their nominal size * there, and the canvas scrolls rather than shrinks on narrow screens. */ export declare const WIDTH = 800; /** Number of distinct series colours the stylesheet defines. */ export declare const PALETTE_SIZE = 6; export declare const CARTESIAN: Frame; export declare const RADIAL: Frame; export declare const SPARK: Frame; /** Encoded cartesian charts reserve room for axis titles and formatted ticks. */ export declare const CARTESIAN_TITLED: Frame; export declare function round(value: number): number; /** Group digits with a thin comma, deterministically and without locale data. */ export declare function formatNumber(value: number): string; /** * A number formatter for an axis or magnitude encoding. `text` (the schema * default) reads as a plain grouped number with the unit, if any. */ export declare function numberFormatter(spec: FormatSpec): (value: number) => string; /** Drop floating-point noise (0.1 + 0.2) without rounding real precision away. */ export declare function denoise(value: number): number; export declare function seriesClass(index: number): string; /** Round a span up to 1, 2, 2.5 or 5 times a power of ten, so ticks read cleanly. */ export declare function niceStep(span: number, count: number): number; /** Axis bounds that include zero and end on a clean tick. */ export declare function niceBounds(series: ChartSeries[]): TickBounds; /** Clean-tick bounds around a raw range. */ export declare function niceRange(rawMin: number, rawMax: number): TickBounds; /** * Bounds for an encoded value axis: the data range (with zero when `zero`), * overridden by the author's `min`/`max`, with a clean step between them. */ export declare function axisBounds(values: readonly number[], axis: { min?: number; max?: number; }, zero: boolean): TickBounds; export declare function plotWidth(frame: Frame): number; export declare function plotHeight(frame: Frame): number; export declare function scaleY(value: number, bounds: Bounds, frame: Frame): number; /** A value clamped into the bounds, so an out-of-range mark stays inside the plot. */ export declare function clampTo(value: number, bounds: Bounds): number; export declare function scaleX(value: number, bounds: Bounds, frame: Frame): number; /** Point charts span the plot edge to edge. */ export declare function pointX(index: number, count: number, frame: Frame): number; /** Bar groups sit in equal bands, labelled at the band centre. */ export declare function bandCentre(index: number, count: number, frame: Frame): number; /** Fragment-safe id fragment derived from a block id. */ export declare function safeId(id: string): string; /** Ticks from `min` to `max` in `step` increments, rounded. */ export declare function tickValues(bounds: TickBounds): number[]; /** * The formatter for axis ticks: like `numberFormatter`, but whole-number * currency ticks drop their cents ($15,000 rather than $15,000.00) unless the * author fixed `decimals`. */ export declare function tickFormatter(spec: FormatSpec, bounds: TickBounds): (value: number) => string; //# sourceMappingURL=chart-scales.d.ts.map