/** * Legend. * * A choropleth is won or lost here: the legend is the only place a reader learns * what the colours mean and where the class boundaries fell. So it renders the * actual computed breaks (never a decorative gradient), shows the no-data swatch * whenever any feature lacks data, and is interactive by default because muting a * class is the cheapest useful exploration available. * * Bubble series get a **nested-circle** legend instead: three reference circles * drawn concentrically at round values. It is the only bubble legend that lets a * reader decode areas rather than guess them, and almost nobody ships it. * * @module components/Legend */ import type { LegendItem, LegendOptions, SizeLegendEntry } from '../types'; export interface LegendSection { title?: string; /** Classed or gradient colour legend. */ items?: LegendItem[]; continuous?: boolean; gradient?: { offset: number; color: string; }[]; /** Nested-circle size legend, for proportional symbols. */ sizes?: SizeLegendEntry[]; /** Index of the series this section describes, for muting callbacks. */ seriesIndex?: number; } export declare class Legend { readonly container: HTMLElement; /** Re-pointed at the live config on every draw; see `_syncComponentOptions`. */ options: LegendOptions; readonly onToggle: (classIndex: number, muted: boolean, seriesIndex: number) => void; el: HTMLElement | null; /** Muted class indices, keyed by series index. */ readonly muted: Map>; /** Gradient bars by series index, rebuilt on every render. */ private bars; constructor({ container, options, onToggle, }: { container: HTMLElement; options: LegendOptions; onToggle?: (classIndex: number, muted: boolean, seriesIndex: number) => void; }); /** Render one section per series that has something to explain. */ render(sections: LegendSection[]): void; private renderSection; /** * The colour chip for a class, which is a patch of the map rather than a * decoration: a textured series puts its actual tile here, so what the reader * matches against the map is what the map drew. */ private swatch; private classList; private gradientBar; /** * Numbers under the bar. * * A continuous bar has two ends and nothing in between, so the ends are the * labels. A classed bar has boundaries, and the boundary is the number the * reader needs: printing "10 to 20" under a band says the same thing twice and * leaves the band edge unlabelled, which is where the eye actually goes. */ private gradientLabels; /** * Move the hover marker to `position` (0 to 1 along the bar). Called as the * pointer crosses features: the reader sees where the feature they are looking * at falls on the scale without translating a colour back into a number. */ highlight(seriesIndex: number, position: number | null, label?: string): void; /** Park every marker. */ clearHighlight(): void; /** Left and right legends are columns, so their bar runs vertically. */ private isVertical; private markerEnabled; private markerLabels; /** * Nested circles, sharing a bottom edge so their diameters line up and the areas * can be compared directly. */ private sizeLegend; private mutedFor; /** Screen-reader text describing a colour scale, used by the a11y description. */ static describe(items: LegendItem[]): string; reset(): void; destroy(): void; } //# sourceMappingURL=Legend.d.ts.map