import { AxisPosition, CartesianAxisInstance, CartesianSeriesInstance, ChartWidget, SeriesColors } from './cartesian'; import { PolarSeriesInstance } from './polar'; import { StandaloneSeriesInstance } from './standalone'; import { LocaleOptions } from '../locale'; import { ColorValue, Fraction, Pixels } from '../options'; import { Scene } from '../scene'; export * from './cartesian'; export * from './polar'; export * from './standalone'; export type ChartKind = 'cartesian' | 'polar' | 'hierarchy' | 'flow'; /** * Axis chrome as modules see it. The switches and the shared metrics are always * resolved; the rest is optional and falls back at the point of use — to * `axisColor` for the strokes, `mutedColor` for the labels, `foregroundColor` * for the title. That keeps `params.axisColor` in charge unless a theme * deliberately splits the three apart. */ export interface ThemeAxisContext { line: boolean; tick: boolean; gridLine: boolean; strokeWidth: Pixels; /** Grid dash pattern; an empty array draws a solid line. */ gridDash: Pixels[]; /** The axis line, separately from the grid and the ticks. */ color?: ColorValue; /** Dash pattern of the axis line itself; solid by default. */ lineDash?: Pixels[]; gridColor?: ColorValue; tickColor?: ColorValue; /** Length of a tick mark, px. */ tickSize?: Pixels; labelColor?: ColorValue; labelSize?: Pixels; /** Gap between the axis line and its labels, px. */ labelSpacing?: Pixels; titleColor?: ColorValue; titleSize?: Pixels; } /** * The theme with every token resolved — the single definition, re-exported by * app/themes as ResolvedTheme. It lives here because shared cannot import app, * while app may import shared. */ export interface ThemeContext { backgroundColor: ColorValue; foregroundColor: ColorValue; mutedColor: ColorValue; /** Axis chrome: the axis line, ticks and grid lines. */ axisColor: ColorValue; fontFamily: string; /** Base label size; component sizes are this plus a fixed FONT_STEP offset. */ fontSize: Pixels; /** Data line width — line/area/radar strokes, never a shape outline. */ strokeWidth: Pixels; /** * Nudge tokens: undefined leaves every mark with its own default, a value * overrides them all at once. The per-mark defaults differ on purpose * (a bar is square, a range bar is rounded), so there is no single literal * these could default to. */ cornerRadius?: Pixels; fillOpacity?: Fraction; /** Outline width of filled marks — bars, sectors, boxes. Not a data line. */ markStrokeWidth?: Pixels; /** Dash pattern of data lines; solid unless a theme or a series says otherwise. */ lineDash?: Pixels[]; /** Growth and decline: candlesticks, OHLC bars, falling waterfall columns. */ positiveColor: ColorValue; negativeColor: ColorValue; palette: { fills: ColorValue[]; strokes: ColorValue[]; /** Continuous ramp for colorField series (heatmap) and gradient legends. */ sequential: ColorValue[]; }; /** The one block theme overrides cannot express: ChartOptions.axes is an array. */ axis: ThemeAxisContext; } /** * Component label sizes as offsets from ThemeContext.fontSize. Every hardcoded * size in the library sits within −1..+6 of the base, so the offsets reproduce * the built-in design exactly and scale together when the base moves. */ export declare const FONT_STEP: { /** 10 — polar ring labels, gradient legend. */ readonly small: -1; /** 11 — axis labels, series labels, callouts. */ readonly label: 0; /** 12 — axis title, legend, tooltip. */ readonly heading: 1; /** 13 — subtitle, empty-state overlay. */ readonly subtitle: 2; /** 14 — donut center label. */ readonly emphasis: 3; /** 17 — chart title. */ readonly title: 6; }; /** Resolved size of a label role. */ export declare function themeFont(theme: ThemeContext, step: number): Pixels; export interface SeriesEnv { id: string; colors: SeriesColors; theme: ThemeContext; /** * Locale of the chart the series belongs to: the words a series prints * without being handed them — the halves of a box, the four prices of a * session, the total of a waterfall — are translated here. */ locale?: LocaleOptions; } export interface AxisEnv { position: AxisPosition; theme: ThemeContext; } /** Series instance of any family; the widget narrows it by the module's chartKind. */ export type AnySeriesInstance = CartesianSeriesInstance | PolarSeriesInstance | StandaloneSeriesInstance; export interface SeriesModule { kind: 'series'; /** Options discriminator: 'line', 'bar', 'pie', ... */ type: string; chartKind: ChartKind; /** Required options keys (validated when the chart is created). */ requiredOptions?: string[]; create(options: O, env: SeriesEnv): AnySeriesInstance; } export interface AxisModule { kind: 'axis'; /** 'number', 'category', 'time', ... */ type: string; create(options: O, env: AxisEnv): CartesianAxisInstance; } /** Chart widget (cartesian/polar/standalone) as a registrable module. */ export interface ChartWidgetModule { kind: 'chart'; /** Which series chartKinds the widget serves. */ chartKinds: readonly ChartKind[]; create(scene: Scene, registry: ModuleRegistry, requestRender: () => void, container?: HTMLElement): ChartWidget & { setOptions(inputs: never, theme: ThemeContext): void; }; } /** * Optional feature (tooltip, legend, navigator, ...). Widgets obtain * the implementation via registry.getFeature(name) and silently skip * rendering if the feature is not registered; api types are imported type-only. */ export interface FeatureModule { kind: 'feature'; name: string; api: Api; } export type ChartModule = SeriesModule | AxisModule | ChartWidgetModule | FeatureModule; export declare class ModuleRegistry { private readonly series; private readonly axes; private readonly charts; private readonly features; register(...modules: ChartModule[]): void; getSeries(type: string): SeriesModule | undefined; getAxis(type: string): AxisModule | undefined; getChart(chartKind: ChartKind): ChartWidgetModule | undefined; /** Feature API by name; the caller supplies the type (type-only import from the feature). */ getFeature(name: string): Api | undefined; } /** One-time warning: the options request a feature missing from the registry. */ export declare function warnMissingFeature(name: string): void; export type EventHandler = (event: unknown) => void; export declare class EventBus { private readonly handlers; on(type: string, handler: EventHandler): () => void; emit(type: string, event: unknown): void; }