/** * Colour scales and class breaks. * * Classification is the invisible decision that changes a choropleth's * conclusion, so the breaks are always computed explicitly, exposed on the scale * object, and rendered in the legend. Quantile is the default because it * guarantees every class is populated, which is what a reader assumes when they * see five classes. * * @module scales/Scale */ import type { PaletteKind } from './Palettes'; import type { LegendItem, ScaleOptions, ScaleType } from '../types'; /** * No-data on a dark map. Light grey reads as the brightest class there, which is * the one thing a no-data fill must never do, so callers that know the theme pass * this as `nullColor`. */ export declare const DARK_NULL_COLOR = "#374151"; /** * Quantile breaks: interior boundaries at even population intervals. * * @returns `classes - 1` interior breaks. */ export declare function quantileBreaks(sorted: number[], classes: number): number[]; /** * Equal-interval breaks. * */ export declare function equalIntervalBreaks([min, max]: [number, number], classes: number): number[]; /** * Fisher-Jenks natural breaks. * * O(n^2 k), so the input is sampled above `maxSample` values. Sampling changes * the breaks slightly; that is preferable to freezing the main thread, and the * caller is told via the returned scale's `warnings`. * */ export declare function jenksBreaks(sorted: number[], classes: number, maxSample?: number): { breaks: number[]; sampled: boolean; }; /** * Round a domain outward to human-friendly bounds. * */ export declare function niceDomain([min, max]: [number, number]): [number, number]; export declare function formatNumber(v: number): string; /** * Create a colour scale. * * @param values Raw values; nulls and non-numerics are tolerated. */ export declare function createScale(values: readonly unknown[], options?: ScaleOptions): Scale; export declare class Scale { readonly warnings: string[]; readonly type: ScaleType; readonly nullColor: string; readonly nullLabel: string; readonly isOrdinal: boolean; /** Class boundaries. Empty for continuous and ordinal scales. */ breaks: number[]; /** One colour per class, or ramp samples for a continuous scale. */ colors: string[]; /** Feature count per class, for the legend. */ counts: number[]; domain: [number, number]; continuous: boolean; classes: number; stops: string[]; paletteName: string; paletteKind: PaletteKind | 'explicit'; /** Distinct categories, for ordinal scales. */ categories: string[]; constructor(values: readonly unknown[], options?: ScaleOptions); /** * The slice of the palette to sample. Only sequential ramps get a light-end * inset: a diverging ramp needs both of its extremes and its true midpoint, and * an explicit colour list is the caller's own decision. */ private _rampWindow; private _initOrdinal; private _countClasses; /** Class index for a value. */ classIndex(value: number): number; /** * Fill colour for a value. Null, undefined, NaN and non-numerics all resolve * to `nullColor`, so an unmatched join renders as explicit no-data rather than * as the bottom class (which would silently understate it). * */ color(value: unknown): string; /** A label colour guaranteed to be readable on the fill for `value`. */ labelColorFor(value: unknown): string; /** * Legend entries, including the no-data swatch when relevant. * */ legendItems({ includeNull, format, }?: { includeNull?: boolean; format?: (v: number) => string; }): LegendItem[]; /** * A gradient stop list for a continuous legend bar. * */ gradientStops(steps?: number): { offset: number; color: string; }[]; /** * Stop list for a *classed* legend bar: each class repeated at both edges of * its band, so the bar reads as the hard steps the map actually uses instead * of implying a continuum the classification does not have. */ classStops(): { offset: number; color: string; }[]; /** * Where a value sits along the legend bar, as a fraction from 0 to 1, or null * when it has no place on it (no data, or a category this scale never saw). * * On a continuous bar this is the same transform the colour uses, so the * marker lands on the exact shade the feature was painted. On a classed bar * the classes are drawn as equal-width bands regardless of how wide their * value ranges are, so the position is the band index plus the value's * progress through that band: the marker stays inside the band whose colour * the reader is being asked to match. */ position(value: unknown): number | null; } //# sourceMappingURL=Scale.d.ts.map