import { U as NodeProps, f as Rect, o as Group } from "./nodes.js"; //#region src/chart.d.ts declare class ChartError extends Error { constructor(message: string); } /** One data row: a plain record. `xKey`/`yKey` name the label + numeric columns. */ type DataRow = Readonly>; /** * A continuous scale: a pure, serializable map from a numeric DOMAIN onto a pixel * (or unit) RANGE. `linearScale`/`logScale` produce these. Serializable by shape * (`{ id, domain, range }`) so an agent/tool can round-trip it, matching the * data-motion card's "scales are value-types" pitch. */ interface Scale { readonly id: 'linear' | 'log'; readonly domain: readonly [number, number]; readonly range: readonly [number, number]; /** Map a domain value onto the range (clamped-free — extrapolates linearly). */ map(v: number): number; } /** A categorical BAND scale: N equal bands across a range, each with a `bandwidth`. */ interface BandScale { readonly id: 'band'; readonly count: number; readonly range: readonly [number, number]; /** The width of one band's drawable area (after padding). */ readonly bandwidth: number; /** The CENTER of band `i` (0-based) within the range. */ map(i: number): number; } /** A colour-ramp scale: a numeric domain → an interpolated hex colour STRING. */ interface ColorScale { readonly id: 'color-ramp'; readonly stops: readonly string[]; readonly domain: readonly [number, number]; /** Map a domain value onto its interpolated colour (`#rrggbb`). */ map(v: number): string; } /** A linear scale mapping `domain` → `range` (the workhorse for a value axis). */ declare function linearScale(domain: readonly [number, number], range: readonly [number, number]): Scale; /** * A base-10 logarithmic scale. Requires a strictly-positive domain (log of a * non-positive number is undefined) — throws otherwise, fail-loud. */ declare function logScale(domain: readonly [number, number], range: readonly [number, number]): Scale; /** * A categorical band scale: `count` equal bands across `range`, separated by a * `padding` fraction (0..1) of each step. `map(i)` is band `i`'s center; * `bandwidth` is its drawable width. */ declare function bandScale(count: number, range: readonly [number, number], padding?: number): BandScale; /** * A colour ramp over `domain` (default `[0, 1]`): at least two hex stops, * interpolated in sRGB byte space. `map(v)` returns `#rrggbb`. Deterministic and * pure — the same v yields the same bytes, so a fill driven by a ramp is golden- * stable. */ declare function colorRamp(stops: readonly string[], domain?: readonly [number, number]): ColorScale; interface ChartSpec extends NodeProps { /** Stable id — REQUIRED; bars bind tracks against `${id}/bars/${i}`. */ id: string; /** The rows to plot (each a plain record). */ data: readonly DataRow[]; /** The column naming each bar's category label (used for ordering / count). */ xKey: string; /** The column naming each bar's numeric value. */ yKey: string; /** Total chart width (px) the bands divide. */ width: number; /** Total chart height (px) — a full-value bar fills it. */ height: number; /** * The value → height scale. Defaults to `linearScale([0, max(y)], [0, height])` * (turnkey: bars are proportional to their value, tallest fills the box). */ yScale?: Scale; /** Gap fraction between bars (0..1) passed to the internal band scale. Default 0.2. */ bandPadding?: number; /** * Bar fill: a solid colour string, or a `ColorScale` evaluated at each bar's * VALUE (a colour ramp over the data). A ramp still on colorRamp's DEFAULT * `[0, 1]` domain is automatically re-domained over `[0, max(y)]` when the * data ranges past 1 (so `colorRamp(['#39e0ff', '#ffcf3f'])` "just works"); * pass an explicit domain to opt out. Default `'#4f8cff'`. */ fill?: string | ColorScale; } interface ChartResult { /** The wrapping group (center-anchored on its content box, like Grid). */ readonly node: Group; /** The bar nodes in row order — `bars[i]` plots `data[i]`. */ readonly bars: readonly Rect[]; /** Ready-to-bind target ids in row order: `${id}/bars/${i}/${prop}`. */ targets(prop: string): string[]; } /** * Build a bar chart from `data` and return a `Group` of bars, each pinned to the * axis at its base and sized to its value. Center-anchored (the group origin is * the center of the content box), matching every other glissade node's convention. * * The bars are freshly constructed nodes (never cloned from the caller); their * `height`/`fill` are plain signals, so a later track bind against * `chart.targets(prop)` wins and drives the reveal. */ declare function Chart(spec: ChartSpec): ChartResult; //#endregion export { BandScale, Chart, ChartError, ChartResult, ChartSpec, ColorScale, DataRow, Scale, bandScale, colorRamp, linearScale, logScale };