export interface Pt { x: number; y: number; } /** * Map `[d0, d1]` linearly onto `[r0, r1]`. A degenerate domain (d0 === d1) * maps every value to the range midpoint instead of dividing by zero. */ export declare function linearScale(d0: number, d1: number, r0: number, r1: number): (v: number) => number; export interface Band { /** Left edge of band `i`. */ position: (i: number) => number; /** Center of band `i` (where a line/scatter x for a categorical axis sits). */ center: (i: number) => number; /** Width of one band. */ bandWidth: number; /** Distance from one band's left edge to the next (bandWidth + inner gap). */ step: number; } /** * Divide `[r0, r1]` into `count` equal bands with `paddingInner` (0..1 of a * step) between bands and `paddingOuter` (same unit) at both edges. */ export declare function bandScale(count: number, r0: number, r1: number, paddingInner?: number, paddingOuter?: number): Band; export interface Ticks { /** Ascending tick values, first <= domain min, last >= domain max. */ ticks: number[]; /** The niced domain the ticks span. */ niceMin: number; niceMax: number; } /** * "Nice" ticks covering `[min, max]` with roughly `count` steps of 1/2/5*10^n. * The returned domain is expanded outward to the tick grid so the top gridline * always sits at or above the data max. */ export declare function niceTicks(min: number, max: number, count?: number): Ticks; /** Straight-segment polyline path ("M x,y L x,y ..."). */ export declare function linePath(points: Pt[]): string; /** * Monotone cubic path through `points` (Fritsch-Carlson, x must ascend): the * curve is smooth but never overshoots beyond the data values, so a peak in * the curve is always a peak in the data. */ export declare function monotonePath(points: Pt[]): string; /** * A bar rectangle with only its TOP corners rounded (the kit's bar idiom: * rounded at the data end, square on the baseline). SVG's `rx` rounds all * four corners, so bars draw through this path instead. The radius clamps to * what the bar can carry. */ export declare function topRoundedRect(x: number, y: number, w: number, h: number, r: number): string; /** * Closed polygon path ("M x,y L x,y ... Z") through `points` in order. The * radar polygons and funnel trapezoids are drawn with this. */ export declare function polygonPath(points: Pt[]): string; /** * Close a line down to a horizontal baseline (a single-series area fill). * `curved` picks the monotone curve for the top edge. */ export declare function areaPath(points: Pt[], baselineY: number, curved?: boolean): string; /** * Fill between a top and bottom edge (one band of a stacked area). Both edges * run left-to-right over the same x positions; the bottom edge is traversed in * reverse to close the ring. The Fritsch-Carlson tangents are symmetric under * reversal, so curving the reversed bottom matches the bottom's own curve. */ export declare function areaBandPath(top: Pt[], bottom: Pt[], curved?: boolean): string; /** * Running-sum stacking for positive series: returns, per series, the [y0, y1] * (bottom, top) value pair at each index. Negative and non-finite values are * treated as 0 (mixed-sign stacking is out of the chart family's scope). */ export declare function stackSeries(series: number[][]): Array>; /** * Uniform histogram bins over `values` with nice edges (the 1/2/5 tick grid, * expanded to cover the data). `binCount` overrides the default Sturges' rule * (ceil(log2 n) + 1). Non-finite values are dropped; empty input yields empty * arrays. `counts[i]` covers `[edges[i], edges[i + 1])`, with the last bin * closed so the data max is counted. */ export declare function binValues(values: number[], binCount?: number): { edges: number[]; counts: number[]; }; /** * Tukey five-number summary of `values`: quartiles by linear interpolation, * whiskers at the most extreme data inside the 1.5 IQR fences, everything * beyond listed in `outliers` (ascending). Non-finite values are dropped; * empty input yields an all-zero summary. */ export declare function boxStats(values: number[]): { min: number; q1: number; median: number; q3: number; max: number; outliers: number[]; }; export interface WaterfallBar { /** The running total where this bar starts (its value edge nearer zero history). */ start: number; /** The running total where this bar ends. */ end: number; /** Rise (positive step), fall (negative step), or total (a snapshot from 0). */ kind: "rise" | "fall" | "total"; } /** * Bar spans for a running-total bridge. Each step floats from the running * total to the total plus its signed `value`. A `total` step draws an * absolute bar from 0: with a non-zero finite `value` it (re)sets the * running total to that level (an opening or re-based total); with `value` * omitted or 0 it snapshots the running total so far. Non-finite values are * treated as 0. `min`/`max` span every bar edge and 0, ready for a y extent. */ export declare function waterfallLayout(steps: Array<{ value?: number; total?: boolean; }>): { bars: WaterfallBar[]; min: number; max: number; }; export interface Slice { /** Start/end angles in radians; 0 points up (12 o'clock), increasing clockwise. */ startAngle: number; endAngle: number; /** This slice's share of the total, 0..1. */ fraction: number; } /** * Angles for a pie: slices start at 12 o'clock and run clockwise in input * order. Negative and non-finite values become zero-width slices (kept in the * output so slice index still matches input index). */ export declare function pieLayout(values: number[]): Slice[]; /** * The point at radius `r` and `angle` around `(cx, cy)`: 0 rad points up * (12 o'clock), increasing clockwise, in standard screen coordinates (y grows * downward). The polar workhorse for arcs, radial bars, and radar spokes. */ export declare function polarPoint(cx: number, cy: number, r: number, angle: number): Pt; /** * SVG path for an annular sector (donut slice; `rInner` 0 gives a pie slice). * A full-circle slice (fraction ~1) is drawn as two half arcs, since a single * SVG arc cannot span 360 degrees. */ export declare function arcPath(cx: number, cy: number, rOuter: number, rInner: number, startAngle: number, endAngle: number): string; export interface Rect { x: number; y: number; w: number; h: number; } /** * Squarified treemap (Bruls, Huizing, van Wijk): tile the `(x, y, w, h)` box * with one rectangle per value, areas proportional to the values, aspect * ratios kept near 1. `rects[i]` always belongs to `values[i]` (the layout * sorts internally but places results back by input index). Non-positive and * non-finite values get a zero-area rect at the box origin. */ export declare function squarify(values: number[], x: number, y: number, w: number, h: number): Rect[]; /** * Centered trapezoid outlines for a funnel in a `w` x `h` box: one stage per * value, top width proportional to the stage's value, tapering to the NEXT * stage's width; the last stage is rectangular. Each stage is 4 points * clockwise from the top-left, ready for `polygonPath`. `gap` is the vertical * space between stages. Non-positive values yield zero-width stages. */ export declare function funnelLayout(values: number[], w: number, h: number, gap?: number): Pt[][]; export interface DepthLevel { price: number; size: number; } export interface DepthPoint { price: number; /** Cumulative size at this price (away from the spread). */ depth: number; } /** * Cumulative order-book depth per level, sorted by ascending price. Bids * accumulate away from the best bid (suffix sums: the lowest price carries * the total), asks away from the best ask (prefix sums). Non-finite and * non-positive sizes are dropped. */ export declare function cumulativeDepth(levels: DepthLevel[], side: "bids" | "asks"): DepthPoint[]; /** * Closed step-area path through `points` (ascending x), then down to the * baseline and back. Step-after (default) holds each y until the NEXT x (an * ask book: depth rises AT each level price); `before` steps at the CURRENT * x first (a bid book: depth drops AT each level price moving right). */ export declare function stepAreaPath(points: Pt[], baselineY: number, before?: boolean): string; /** * Compact tick/label formatting: 950 -> "950", 1200 -> "1.2k", 3400000 -> * "3.4M", 2500000000 -> "2.5B". One decimal at most, trailing ".0" trimmed. */ export declare function formatCompact(v: number): string; export declare const DENSE_SERIES = 24; /** * The accessible name for one labeled series across `labels`, formatted with * `fmt`. Dense series (more than DENSE_SERIES points) are summarized by their * endpoints and range; sparse series list every "