@graphysdk/viz-engine 0.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3415 @@
1
+ import { internal } from 'arquero';
2
+
3
+ export declare interface AesMapping {
4
+ x?: AestheticValue;
5
+ y?: AestheticValue;
6
+ label?: AestheticValue;
7
+ color?: AestheticValue;
8
+ size?: AestheticValue;
9
+ alpha?: AestheticValue;
10
+ group?: AestheticValue;
11
+ strokeWidth?: AestheticValue;
12
+ }
13
+
14
+ export declare type AestheticKey = keyof AesMapping;
15
+
16
+ /**
17
+ * Aesthetic value can be:
18
+ * - string (shorthand for { variable: string })
19
+ * - { variable: string } (explicit variable mapping)
20
+ * - { value: DataValue } (constant value applied to every observation)
21
+ */
22
+ declare type AestheticValue = string | VariableMapping | ValueMapping;
23
+
24
+ declare function aggregate(options: AggregateOptions): AggregateTransformInput;
25
+
26
+ /***************************************************************
27
+ * Aggregate Transform
28
+ ***************************************************************/
29
+ declare interface AggregateOperation {
30
+ /** The aggregation function to apply. */
31
+ op: AggregationFunction;
32
+ /** The variable to aggregate. */
33
+ variableName: VariableName;
34
+ /** The name of the output variable. */
35
+ as: VariableName;
36
+ }
37
+
38
+ declare interface AggregateOptions {
39
+ /** Variables to group by before aggregating. */
40
+ groupby: VariableName[];
41
+ /** Aggregation operations to apply per group. */
42
+ operations: AggregateOperation[];
43
+ }
44
+
45
+ declare interface AggregateTransformInput {
46
+ type: 'transform';
47
+ transformType: 'aggregate';
48
+ options: AggregateOptions;
49
+ }
50
+
51
+ /** A function that aggregates a variable's values. */
52
+ declare type AggregationFunction = 'count' | 'sum' | 'mean' | 'median' | 'mode' | 'min' | 'max';
53
+
54
+ /** A record of variable names and their aggregations. */
55
+ declare type AggregationInput = Record<VariableName, {
56
+ variableName: VariableName;
57
+ aggregation: AggregationFunction;
58
+ }>;
59
+
60
+ export declare interface AngleExtent {
61
+ startAngle: NumericDataValue;
62
+ endAngle: NumericDataValue;
63
+ }
64
+
65
+ declare interface AnnotationDataPoint {
66
+ rowIndex?: number;
67
+ columnKey?: string;
68
+ rowValue?: DataValue;
69
+ }
70
+
71
+ declare interface Appearance {
72
+ paletteId?: string;
73
+ seriesStyles?: Record<string, SeriesStyle>;
74
+ useSingleColorForBars?: boolean;
75
+ background?: string;
76
+ backgroundModifier?: 'none' | 'tint';
77
+ border?: Partial<{
78
+ style: 'none' | 'custom' | 'tinted' | 'gradient' | 'preset' | 'grey';
79
+ color: string;
80
+ width: number;
81
+ }>;
82
+ hasRoundedCorners?: boolean;
83
+ textStyle?: Partial<{
84
+ heading: GraphTextStyle;
85
+ body: GraphTextStyle;
86
+ }>;
87
+ textScale?: number;
88
+ highlightStyle?: 'grey' | 'fade-color';
89
+ isLogoHidden?: boolean;
90
+ numberFormat?: Partial<{
91
+ decimalPlaces: 'auto' | number;
92
+ abbreviation: 'none' | 'auto' | 'k' | 'm' | 'b';
93
+ }>;
94
+ showTooltips?: boolean;
95
+ animateTransitions?: boolean;
96
+ }
97
+
98
+ /**
99
+ * Appearance configuration (after defaults applied)
100
+ */
101
+ declare interface AppearanceConfig {
102
+ /**
103
+ * Background color for the chart canvas.
104
+ * null means inherit from the renderer/theme default.
105
+ * @default null
106
+ */
107
+ background: string | null;
108
+ }
109
+
110
+ declare function area(options?: GeomOptions<'area'>): LayerInputOf<'area'>;
111
+
112
+ /**
113
+ * Area-specific parameters (same rendering knobs as line, but fills under the curve)
114
+ */
115
+ export declare interface AreaGeomParams {
116
+ lineWidth: number | 'auto';
117
+ lineType: LineStyleType;
118
+ interpolate: InterpolateType;
119
+ missingValues: MissingValuesType;
120
+ }
121
+
122
+ declare interface AverageLine {
123
+ columnKey: string;
124
+ }
125
+
126
+ /** Configuration for the axes (if the graph supports them). */
127
+ declare interface Axes {
128
+ x?: AxisOptions;
129
+ y?: AxisOptions;
130
+ y2?: Pick<AxisOptions, 'label'>;
131
+ hasDualYAxis?: boolean;
132
+ showGridLines?: boolean;
133
+ }
134
+
135
+ /**
136
+ * Axes configuration (after defaults applied)
137
+ * Groups all axis-related settings per axis.
138
+ */
139
+ declare interface AxesConfig {
140
+ x: XAxisConfig;
141
+ y: YAxisConfig;
142
+ ySecondary?: YAxisConfig;
143
+ }
144
+
145
+ /**
146
+ * Configuration for a single axis's grid lines
147
+ */
148
+ declare interface AxisGridConfig {
149
+ /**
150
+ * Whether grid lines are visible.
151
+ * - true/false: explicit visibility
152
+ * - null: let the compiler decide based on geom/coord policies
153
+ * (defaults to false for x-axis, true for y-axis)
154
+ */
155
+ isVisible: boolean | null;
156
+ }
157
+
158
+ /**
159
+ * Label display mode for axis ticks
160
+ * - 'auto': Show all ticks (default behavior)
161
+ * - 'edges': Show only the first and last tick
162
+ */
163
+ declare type AxisLabelMode = 'auto' | 'edges';
164
+
165
+ /**
166
+ * Maps each positional aesthetic to its axis orientation.
167
+ * The guide compiler uses this to determine where axes are placed
168
+ * and what geometry they use (e.g., linear vs circular grid lines).
169
+ */
170
+ declare interface AxisMapping {
171
+ x: {
172
+ position: AxisPosition;
173
+ geometry: GuideGeometry;
174
+ };
175
+ y: {
176
+ position: AxisPosition;
177
+ geometry: GuideGeometry;
178
+ };
179
+ }
180
+
181
+ declare interface AxisOptions {
182
+ label?: string;
183
+ isHidden?: boolean;
184
+ isReversed?: boolean;
185
+ scaleType?: 'linear' | 'logarithmic';
186
+ min?: number;
187
+ max?: number;
188
+ tickDisplayMode?: 'auto' | 'edges';
189
+ }
190
+
191
+ declare type AxisPosition = 'left' | 'right' | 'top' | 'bottom';
192
+
193
+ /**
194
+ * A single axis tick with its raw value and normalized position. Ticks in one axis share the same
195
+ * `valueFormat` — it lives on `CompiledAxisGuide`, not per-tick.
196
+ */
197
+ export declare interface AxisTick {
198
+ /** Raw value in data space (number, Date, or string) */
199
+ value: DataValue;
200
+ /** Normalized position in [0,1] space — used for placement */
201
+ position: number;
202
+ }
203
+
204
+ /**
205
+ * A tick-set candidate for an axis. The runtime picks the densest one whose labels fit. Datetime candidates
206
+ * may carry a `valueFormat` matched to their interval's granularity, overriding the axis-level format.
207
+ */
208
+ export declare interface AxisTickCandidate {
209
+ ticks: AxisTick[];
210
+ valueFormat?: ValueFormat;
211
+ }
212
+
213
+ /**
214
+ * Configuration for a single axis's ticks
215
+ */
216
+ declare interface AxisTicksConfig {
217
+ isVisible: boolean;
218
+ mode: AxisLabelMode;
219
+ }
220
+
221
+ declare function bar(options?: GeomOptions<'bar'>): LayerInputOf<'bar'>;
222
+
223
+ /**
224
+ * Bar/Column-specific parameters
225
+ */
226
+ declare type BarGeomParams = Record<string, never>;
227
+
228
+ declare interface BarOptions {
229
+ sortBars?: boolean;
230
+ }
231
+
232
+ /**
233
+ * Base params shared by all coordinate systems
234
+ */
235
+ declare interface BaseCoordParams {
236
+ /**
237
+ * Limits for x-axis [min, max]
238
+ */
239
+ xLimits: [number, number] | null;
240
+ /**
241
+ * Limits for y-axis [min, max]
242
+ */
243
+ yLimits: [number, number] | null;
244
+ }
245
+
246
+ declare interface BaseGeomOptions<T extends GeomParams> {
247
+ aes?: AesMapping;
248
+ stat?: StatName;
249
+ position?: PositionType;
250
+ yScaleType?: YScaleType;
251
+ params?: Partial<T>;
252
+ transforms?: TransformInput[];
253
+ interactive?: boolean;
254
+ }
255
+
256
+ export declare type BoxSize = {
257
+ width: number;
258
+ height: number;
259
+ };
260
+
261
+ /**
262
+ * Pure projection of `(compiled, hover)` into the tooltip's `{ header, rows }`.
263
+ *
264
+ * Row order is layer-declaration order across layers, color-scale domain order within a layer
265
+ * (= the legend's display order). The primary hit is emphasized in place — never reordered to
266
+ * the top — so the visual position stays anchored to the legend.
267
+ */
268
+ export declare const buildTooltipContent: ({ compiled, hover, formattingLocale, }: BuildTooltipContentInput) => TooltipContent | null;
269
+
270
+ declare interface BuildTooltipContentInput {
271
+ compiled: CompiledSpec;
272
+ hover: HoverState;
273
+ formattingLocale?: Locale;
274
+ }
275
+
276
+ /**
277
+ * Caching decorator for any TextMeasurer implementation.
278
+ *
279
+ * Cache key includes all dimensions that affect `measureText()` output:
280
+ * family, size, weight, style, and the text itself.
281
+ *
282
+ * No eviction policy is needed because chart text is bounded —
283
+ * a chart has at most tens to low hundreds of unique labels.
284
+ */
285
+ export declare class CachedTextMeasurer implements TextMeasurer {
286
+ private readonly inner;
287
+ private readonly cache;
288
+ constructor(inner: TextMeasurer);
289
+ measureText(text: string, font: FontSpec): MeasuredText;
290
+ private getCacheKey;
291
+ }
292
+
293
+ declare interface CartesianCoordInput {
294
+ type: 'coord';
295
+ coordType: 'cartesian';
296
+ params?: Partial<BaseCoordParams>;
297
+ }
298
+
299
+ declare type CartesianCoordParams = BaseCoordParams;
300
+
301
+ declare interface CartesianCoordSpec {
302
+ type: 'coord';
303
+ coordType: 'cartesian';
304
+ params: BaseCoordParams;
305
+ }
306
+
307
+ /**
308
+ * Cartesian coordinate system - standard x/y plot. Also used for flipped coordinates (flip is
309
+ * an axis-assignment variant, not a different geometric paradigm).
310
+ */
311
+ export declare interface CartesianCoordSystem {
312
+ type: 'cartesian';
313
+ /**
314
+ * The data-space axis that is the main (independent) one. `'x'` for standard cartesian (bars
315
+ * rise, X ticks on the horizontal axis); `'y'` for `coord.flip()` (bars extend, Y ticks on the
316
+ * horizontal axis). Consumers that need to branch on flip read this; the runtime `coord/axes`
317
+ * helpers turn it into main/cross accessors so the branch lives in one place.
318
+ */
319
+ mainAxis: MainAxis;
320
+ /** Axis orientation metadata for the guide compiler */
321
+ axisMapping: AxisMapping;
322
+ }
323
+
324
+ declare type CategoricalDataValue = string | null;
325
+
326
+ declare interface CategoricalValueFormat {
327
+ type: 'text';
328
+ }
329
+
330
+ /**
331
+ * Chart display and interaction mode.
332
+ * - 'readonly': Normal chart display with full interactivity but no editing (default)
333
+ * - 'editable': Chart with inline editing capabilities for labels, titles, etc.
334
+ */
335
+ declare type ChartMode = 'readonly' | 'editable';
336
+
337
+ declare interface ColorScaleMethods {
338
+ /**
339
+ * Continuous (numeric) color scale. Supports `transform`, `reverse`, `nice`, `zero`, `domainMin`, `domainMax`.
340
+ * @example scale.color.continuous({ reverse: true })
341
+ */
342
+ continuous: (options?: ContinuousScaleOptions) => ContinuousScaleInput;
343
+ /**
344
+ * Discrete (categorical) color scale. Supports explicit `range` values.
345
+ * @example scale.color.discrete({ range: ['red', 'blue', 'green'] })
346
+ */
347
+ discrete: (options?: DiscreteScaleOptions) => DiscreteScaleInput;
348
+ /**
349
+ * Color scale from a named Graphy palette.
350
+ * @example scale.color.palette({ palette: 'Bright' })
351
+ */
352
+ palette: (options?: PaletteScaleOptions) => PaletteScaleInput;
353
+ }
354
+
355
+ declare type ColumnMetadata = Record<string, {
356
+ type: DataType;
357
+ valueFormat: ValueFormat;
358
+ label?: string;
359
+ }>;
360
+
361
+ declare interface ComboOptions {
362
+ comboType?: 'grouped-bars' | 'stacked-bars' | 'lines';
363
+ }
364
+
365
+ export declare interface Command<TParams extends Record<string, unknown> = Record<string, unknown>> {
366
+ /**
367
+ * Command type discriminator for type guards
368
+ */
369
+ readonly type: string;
370
+ /**
371
+ * Metadata for tracking
372
+ */
373
+ readonly metadata: CommandMetadata;
374
+ /**
375
+ * Serializable parameters for this command.
376
+ */
377
+ readonly params: TParams;
378
+ /**
379
+ * Execute the command against a spec.
380
+ * Returns the new spec and a revert command that can undo this change.
381
+ */
382
+ apply: (spec: Spec) => CommandApplyResult | null;
383
+ }
384
+
385
+ /**
386
+ * Result of executing a command.
387
+ * Contains the new spec and a revert command that can undo the change.
388
+ */
389
+ export declare interface CommandApplyResult {
390
+ /** The spec after applying the command */
391
+ readonly spec: Spec;
392
+ /** A standalone command that reverses this execution */
393
+ readonly revert: Command;
394
+ }
395
+
396
+ /**
397
+ * Unique identifier for commands.
398
+ */
399
+ declare type CommandId = string;
400
+
401
+ /**
402
+ * Metadata attached to every command for tracking.
403
+ */
404
+ export declare interface CommandMetadata {
405
+ /** Unique identifier for this command */
406
+ readonly id: CommandId;
407
+ /** When the command was executed */
408
+ readonly timestamp: number;
409
+ /** Human-readable description for UI display */
410
+ readonly description: string;
411
+ /** Author of the command */
412
+ readonly author: string;
413
+ }
414
+
415
+ /**
416
+ * Event types emitted by CommandStackManager.
417
+ */
418
+ export declare type CommandStackEvent = {
419
+ type: 'apply';
420
+ command: Command;
421
+ spec: Spec;
422
+ } | {
423
+ type: 'undo';
424
+ command: Command;
425
+ spec: Spec;
426
+ } | {
427
+ type: 'redo';
428
+ command: Command;
429
+ spec: Spec;
430
+ } | {
431
+ type: 'clear';
432
+ };
433
+
434
+ /**
435
+ * Listener for command stack events.
436
+ */
437
+ export declare type CommandStackListener = (event: CommandStackEvent) => void;
438
+
439
+ /**
440
+ * Manages command execution with undo/redo support using revert commands.
441
+ *
442
+ * Commands are stateless — executing a command returns the new spec and a
443
+ * standalone revert command. The manager stores these revert commands on
444
+ * the undo stack. Undo executes the revert (producing a new forward command
445
+ * for redo), and redo executes that forward command (producing a new revert
446
+ * for undo again).
447
+ *
448
+ * @example
449
+ * ```typescript
450
+ * const manager = new CommandStackManager();
451
+ *
452
+ * // Execute a command
453
+ * let spec = manager.apply(command, spec);
454
+ *
455
+ * // Undo the last command
456
+ * const undoResult = manager.undo(spec);
457
+ * if (undoResult) {
458
+ * spec = undoResult.spec;
459
+ * }
460
+ *
461
+ * // Redo the undone command
462
+ * const redoResult = manager.redo(spec);
463
+ * if (redoResult) {
464
+ * spec = redoResult.spec;
465
+ * }
466
+ * ```
467
+ */
468
+ export declare class CommandStackManager {
469
+ private undoStack;
470
+ private redoStack;
471
+ private listeners;
472
+ private readonly maxHistorySize;
473
+ private isEmitting;
474
+ private cachedSnapshot;
475
+ constructor(options?: CommandStackOptions);
476
+ /**
477
+ * Execute a command and add it to the undo stack.
478
+ * Clears the redo stack (standard undo/redo behavior).
479
+ */
480
+ apply(command: Command, spec: Spec): Spec;
481
+ /**
482
+ * Undo the most recent command.
483
+ * Executes the revert command and moves the entry to the redo stack.
484
+ * Returns the result with new spec and the original command, or null if nothing to undo.
485
+ */
486
+ undo(spec: Spec): UndoRedoResult | null;
487
+ /**
488
+ * Redo the most recently undone command.
489
+ * Executes the redo action and moves the entry back to the undo stack.
490
+ * Returns the result with new spec and the original command, or null if nothing to redo.
491
+ */
492
+ redo(spec: Spec): UndoRedoResult | null;
493
+ /**
494
+ * Clear all history (both undo and redo stacks).
495
+ */
496
+ clear(): void;
497
+ /**
498
+ * Get an immutable snapshot of the command stack state.
499
+ * Returns a cached object with referential stability.
500
+ */
501
+ getSnapshot(): CommandStackSnapshot;
502
+ /**
503
+ * Subscribe to command stack events.
504
+ * @returns Unsubscribe function
505
+ */
506
+ subscribe(listener: CommandStackListener): () => void;
507
+ private withReentrancyGuard;
508
+ private emit;
509
+ }
510
+
511
+ /**
512
+ * Options for CommandStackManager.
513
+ */
514
+ declare interface CommandStackOptions {
515
+ /** Maximum number of commands to keep in history (default: 100) */
516
+ maxHistorySize?: number;
517
+ }
518
+
519
+ /**
520
+ * Immutable snapshot of command stack state.
521
+ * Designed for use with React's `useSyncExternalStore(manager.subscribe, manager.getSnapshot)`.
522
+ */
523
+ export declare interface CommandStackSnapshot {
524
+ readonly canUndo: boolean;
525
+ readonly canRedo: boolean;
526
+ readonly undoDescription: string | null;
527
+ readonly redoDescription: string | null;
528
+ }
529
+
530
+ /** Comparison operators for declarative filtering. */
531
+ declare type ComparisonOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte';
532
+
533
+ /**
534
+ * Convenience entry point to create a fully wired {@link Compiler} and compile a spec.
535
+ *
536
+ * Accepts either a low-level {@link SpecInput} (constructed via `createSpec`/`pipe`)
537
+ * or a high-level {@link GraphConfig}. When given a `GraphConfig`, it parses the raw
538
+ * data and converts it to a `SpecInput` before running the pipeline.
539
+ */
540
+ export declare const compile: (input: CompilerInput) => CompiledSpec;
541
+
542
+ /**
543
+ * Axis guide produced from a position scale (x, y, ySecondary).
544
+ * Tick candidates carry normalized positions so the renderer needs no scale logic (selection
545
+ * happens at layout time).
546
+ */
547
+ export declare interface CompiledAxisGuide {
548
+ /** Which scale this axis represents */
549
+ scaleAestheticKey: ScaledAestheticKey;
550
+ /** The aesthetic this axis serves (always 'x' or 'y') */
551
+ aesthetic: AestheticKey;
552
+ /** Axis placement */
553
+ position: AxisPosition;
554
+ /** Title text, null means no title */
555
+ label: string | null;
556
+ /** Whether the axis (line + ticks + labels) is visible */
557
+ isVisible: boolean;
558
+ /** Candidate tick sets, sorted by ascending count. Runtime picks the densest one that fits. */
559
+ tickCandidates: AxisTickCandidate[];
560
+ /** Resolved format descriptor shared by all ticks on this axis */
561
+ valueFormat: ValueFormat;
562
+ /** Tick mode from config */
563
+ tickMode: AxisLabelMode;
564
+ /** Whether tick marks are visible */
565
+ ticksVisible: boolean;
566
+ /** Whether grid lines are visible at tick positions */
567
+ gridVisible: boolean;
568
+ /** Scale type — the renderer uses this to select a formatting strategy */
569
+ scaleType: ScaleType;
570
+ /** Band width in [0, 1] space for discrete position scales. Undefined otherwise. */
571
+ bandwidth?: number;
572
+ }
573
+
574
+ declare interface CompiledGeom {
575
+ /** The reparameterized dataset (may have new computed variables) */
576
+ data: Dataset;
577
+ /** Any mapping overrides produced by the geom */
578
+ mapping: AesMapping;
579
+ }
580
+
581
+ declare interface CompiledGroup {
582
+ data: Dataset;
583
+ }
584
+
585
+ /**
586
+ * All compiled guides, ready for the renderer.
587
+ */
588
+ export declare interface CompiledGuides {
589
+ axes: CompiledAxisGuide[];
590
+ legends: CompiledLegendGuide[];
591
+ panel: CompiledPanel;
592
+ }
593
+
594
+ /**
595
+ * Identity scales — pass-through, no transformation.
596
+ * Used when data already contains render-ready values.
597
+ */
598
+ export declare interface CompiledIdentityScale extends CompiledScaleBase {
599
+ kind: 'identity';
600
+ map: (value: DataValue) => DataValue;
601
+ }
602
+
603
+ /**
604
+ * Render-ready layer with resolved mappings and transformed data.
605
+ */
606
+ export declare interface CompiledLayer {
607
+ /** Stable identity carried over from `LayerSpec.id`. Preserved across recompiles. */
608
+ id: string;
609
+ data: Dataset;
610
+ geom: GeomName;
611
+ /** Final mapping after merging root + layer + stat + geom overrides */
612
+ mapping: AesMapping;
613
+ position: PositionType;
614
+ yScaleType: YScaleType;
615
+ params: LayerSpec['params'];
616
+ /**
617
+ * When `false`, the runtime hover engine excludes this layer from primary hit-detection — a
618
+ * colocated interactive layer (line/area/bar) wins instead. The layer can still be surfaced as
619
+ * a related companion when another layer is primary.
620
+ */
621
+ interactive: boolean;
622
+ }
623
+
624
+ /**
625
+ * `CompiledLayer` narrowed to a specific `geom`. Lets call sites that already know the geom
626
+ * (geom renderers dispatched off `layer.geom`) take a typed `params` directly, eliminating the
627
+ * `as ...GeomParams` cast that was needed when `params` was the full param union.
628
+ */
629
+ export declare type CompiledLayerFor<G extends GeomName> = Omit<CompiledLayer, 'geom' | 'params'> & {
630
+ geom: G;
631
+ params: Extract<LayerSpec, {
632
+ geom: G;
633
+ }>['params'];
634
+ };
635
+
636
+ export declare interface CompiledLegendGuide {
637
+ /** Which aesthetics this legend represents (may be merged) */
638
+ aesthetics: AestheticKey[];
639
+ /** Title text, null means no title */
640
+ title: string | null;
641
+ /** Resolved legend position (never 'auto' or 'none') */
642
+ position: ResolvedLegendPosition;
643
+ /** Resolved legend display mode (never 'auto') */
644
+ display: ResolvedLegendDisplay;
645
+ /** Legend entries in domain order */
646
+ items: LegendItem[];
647
+ /** Resolved format descriptor shared by all items in this legend */
648
+ valueFormat: ValueFormat;
649
+ }
650
+
651
+ export declare interface CompiledPanel {
652
+ border: {
653
+ isVisible: boolean;
654
+ };
655
+ }
656
+
657
+ declare interface CompiledPositionAdjuster {
658
+ /** The position-adjusted dataset (may have new/modified variables) */
659
+ data: Dataset;
660
+ /** Any mapping overrides produced by the position adjustment */
661
+ mapping: AesMapping;
662
+ }
663
+
664
+ /**
665
+ * Position scales (x, y) — map data values to normalized [0,1] space.
666
+ * The renderer maps [0,1] to pixel coordinates.
667
+ */
668
+ export declare interface CompiledPositionScale<Input = DataValue> extends CompiledScaleBase<Input> {
669
+ kind: 'position';
670
+ map: (value: Input) => number;
671
+ /** Band width in [0,1] space for discrete position scales. Null for continuous/datetime. */
672
+ bandwidth: number | null;
673
+ }
674
+
675
+ declare type CompiledPositionScaleOptions<Input = DataValue> = Omit<CompiledPositionScale<Input>, 'kind' | 'aesthetic' | 'spec'>;
676
+
677
+ export declare type CompiledScale<Input = DataValue> = CompiledPositionScale<Input> | CompiledVisualScale<Input> | CompiledIdentityScale;
678
+
679
+ declare interface CompiledScaleBase<Input = DataValue> {
680
+ aesthetic: AestheticKey;
681
+ domain: Input[];
682
+ spec: ScaleSpec;
683
+ generateTicks: (options?: GenerateTicksOptions) => Input[];
684
+ }
685
+
686
+ export declare type CompiledScales = Partial<Record<ScaledAestheticKey, CompiledScale>>;
687
+
688
+ /**
689
+ * Fully compiled spec, ready for the renderer.
690
+ */
691
+ export declare interface CompiledSpec {
692
+ spec: Spec;
693
+ coordSystem: CoordSystem;
694
+ layers: CompiledLayer[];
695
+ scales: CompiledScales;
696
+ guides: CompiledGuides;
697
+ config: ConfigSpec;
698
+ }
699
+
700
+ declare interface CompiledStat {
701
+ /** The transformed dataset */
702
+ data: Dataset;
703
+ /** Any mapping overrides produced by the stat (e.g., y → 'count' for CountStat) */
704
+ mapping: AesMapping;
705
+ }
706
+
707
+ /**
708
+ * Visual scales (color, size, alpha, …) — map data values to concrete visual outputs
709
+ * (color strings, pixel sizes, opacity values, etc.).
710
+ */
711
+ export declare interface CompiledVisualScale<Input = DataValue> extends CompiledScaleBase<Input> {
712
+ kind: 'visual';
713
+ map: (value: Input) => DataValue;
714
+ }
715
+
716
+ declare type CompiledVisualScaleOptions<Input = DataValue> = Omit<CompiledVisualScale<Input>, 'kind' | 'aesthetic' | 'spec'>;
717
+
718
+ /**
719
+ * The main compiler. It orchestrates the compilation of a spec into a render-ready output.
720
+ *
721
+ * Each layer is processed through the pipeline. Coords and scales are compiled separately as they apply to
722
+ * the entire plot.
723
+ */
724
+ export declare class Compiler {
725
+ private readonly specCompiler;
726
+ private readonly transformCompiler;
727
+ private readonly layerCompiler;
728
+ private readonly scaleCompiler;
729
+ private readonly coordCompiler;
730
+ private readonly positionMapperCompiler;
731
+ private readonly visualMapperCompiler;
732
+ private readonly guideCompiler;
733
+ constructor(specCompiler: SpecResolver, transformCompiler: TransformCompiler, layerCompiler: LayerCompiler, scaleCompiler: ScaleCompiler, coordCompiler: CoordCompiler, positionMapperCompiler: PositionMapperCompiler, visualMapperCompiler: VisualMapperCompiler, guideCompiler: GuideCompiler);
734
+ compile(compilerInput: CompilerInput): CompiledSpec;
735
+ }
736
+
737
+ /**
738
+ * Any value accepted by {@link Compiler.compile}: a low-level {@link SpecInput}, a high-level {@link GraphConfig}
739
+ * or an already-resolved {@link Spec}.
740
+ */
741
+ export declare type CompilerInput = SpecInput | GraphConfig | Spec;
742
+
743
+ /**
744
+ * Create a custom configuration
745
+ */
746
+ export declare function config(options: ConfigInput): ConfigItem;
747
+
748
+ export declare type ConfigInput = DeepPartial<ConfigSpec> & {
749
+ legend?: LegendConfigInput;
750
+ content?: ContentInput;
751
+ };
752
+
753
+ /**
754
+ * Config specification with type tag
755
+ */
756
+ declare interface ConfigItem {
757
+ type: 'config';
758
+ config: ConfigInput;
759
+ }
760
+
761
+ /**
762
+ * Feature configuration with resolved defaults.
763
+ * All fields are required and always populated after resolution.
764
+ */
765
+ export declare interface ConfigSpec {
766
+ mode: ChartMode;
767
+ parsingLocale: Locale;
768
+ legend: LegendConfig;
769
+ axes: AxesConfig;
770
+ panel: PanelConfig;
771
+ headline: HeadlineConfig;
772
+ numberFormat: NumberFormatConfig;
773
+ content: ContentConfig;
774
+ appearance: AppearanceConfig;
775
+ }
776
+
777
+ declare function constant(options: ConstantOptions): ConstantTransformInput;
778
+
779
+ /***************************************************************
780
+ * Constant Transform
781
+ ***************************************************************/
782
+ declare interface ConstantOptions {
783
+ /** The name of the new variable. */
784
+ variableName: VariableName;
785
+ /** The type of the new variable. */
786
+ type: DataType;
787
+ /** The constant value to assign to every observation. */
788
+ value: DataValue;
789
+ }
790
+
791
+ declare interface ConstantTransformInput {
792
+ type: 'transform';
793
+ transformType: 'constant';
794
+ options: ConstantOptions;
795
+ }
796
+
797
+ /** Text content in the graph. */
798
+ declare interface Content {
799
+ title?: string | unknown;
800
+ isTitleHidden?: boolean;
801
+ subtitle?: string | unknown;
802
+ isSubtitleHidden?: boolean;
803
+ caption?: string | unknown;
804
+ isCaptionHidden?: boolean;
805
+ source?: Partial<{
806
+ label: string;
807
+ url: string;
808
+ }>;
809
+ isSourceHidden?: boolean;
810
+ }
811
+
812
+ /** Resolved content configuration (all fields populated). */
813
+ export declare interface ContentConfig {
814
+ isVisible: boolean;
815
+ title: TextContent | null;
816
+ subtitle: TextContent | null;
817
+ caption: TextContent | null;
818
+ }
819
+
820
+ /** Content input — all fields optional, null means no content. */
821
+ declare type ContentInput = Partial<ContentConfig>;
822
+
823
+ declare type ContinuousScaleInput = {
824
+ type: 'scale';
825
+ scaledAesthetic: ScaledAestheticKey;
826
+ scaleType: 'continuous';
827
+ transform?: ScaleTransformType;
828
+ reverse?: boolean;
829
+ nice?: boolean;
830
+ zero?: boolean;
831
+ clamp?: boolean;
832
+ domainMin?: number | null;
833
+ domainMax?: number | null;
834
+ range?: [number, number] | null;
835
+ };
836
+
837
+ declare type ContinuousScaleOptions = {
838
+ /**
839
+ * Mathematical transformation to apply.
840
+ * - 'linear': No transformation (default)
841
+ * - 'log': Base-10 logarithm
842
+ * - 'sqrt': Square root
843
+ */
844
+ transform?: ScaleTransformType;
845
+ /**
846
+ * Reverse the scale direction.
847
+ * Can be combined with any transformation.
848
+ * @default false
849
+ * @example scale.y.continuous({ reverse: true }) // reversed continuous scale
850
+ */
851
+ reverse?: boolean;
852
+ /**
853
+ * Extend domain to nice round values.
854
+ * @example nice: true // [3, 97] becomes [0, 100]
855
+ */
856
+ nice?: boolean;
857
+ /**
858
+ * Include zero in the domain.
859
+ * Default is true for y-axis, false for x-axis.
860
+ * @example zero: false // Allow axis to start above zero
861
+ */
862
+ zero?: boolean;
863
+ /**
864
+ * Restrict output to the scale's range when input falls outside the domain.
865
+ * Without clamping, values extrapolate beyond the range boundaries.
866
+ * Default is false for position aesthetics (x, y), true for non-position (color, size, alpha, …).
867
+ * @example clamp: true // Pin out-of-domain values to range boundaries
868
+ */
869
+ clamp?: boolean;
870
+ /**
871
+ * Override the minimum domain value only.
872
+ * Maximum is still computed from data.
873
+ * @example domainMin: 0 // Ensure axis starts at 0
874
+ */
875
+ domainMin?: number;
876
+ /**
877
+ * Override the maximum domain value only.
878
+ * Minimum is still computed from data.
879
+ * @example domainMax: 100 // Cap axis at 100
880
+ */
881
+ domainMax?: number;
882
+ /**
883
+ * Output range for non-positional scales (size, alpha, strokeWidth).
884
+ * Ignored for position aesthetics (x, y).
885
+ * Aesthetic-specific defaults are applied when not specified:
886
+ * - size: [4, 20]
887
+ * - alpha: [0.1, 1]
888
+ * - strokeWidth: [1, 4]
889
+ * @example range: [2, 30] // custom size range in pixels
890
+ */
891
+ range?: [number, number];
892
+ };
893
+
894
+ declare type ContinuousScaleSpec = Required<ContinuousScaleInput>;
895
+
896
+ export declare const coord: {
897
+ /**
898
+ * Standard cartesian (x-y) coordinate system. This is the default if no coord is specified.
899
+ *
900
+ * @example coord.cartesian() // auto-scaled axes
901
+ * @example coord.cartesian({ yLimits: [0, 100] }) // fixed y-axis
902
+ */
903
+ cartesian: (params?: Partial<CartesianCoordParams>) => CartesianCoordInput;
904
+ /**
905
+ * Flipped cartesian coordinates — swaps x and y axes.
906
+ * Useful for horizontal bar charts or when category labels are long.
907
+ *
908
+ * @example coord.flip() // horizontal bars
909
+ */
910
+ flip: (params?: Partial<FlipCoordParams>) => FlipCoordInput;
911
+ /**
912
+ * Polar coordinate system — maps data to angle (theta) and radius.
913
+ * Used for pie charts, donut charts, and radar/radial visualizations.
914
+ *
915
+ * @example coord.polar() // pie chart
916
+ * @example coord.polar({ innerRadius: 0.5 }) // donut chart
917
+ */
918
+ polar: (params?: Partial<PolarCoordParams>) => PolarCoordInput;
919
+ };
920
+
921
+ /**
922
+ * Resolves a coordinate system by type and delegates compilation.
923
+ */
924
+ declare class CoordCompiler {
925
+ private readonly registry;
926
+ constructor(registry: CoordRegistry);
927
+ setup(input: CoordSetupInput): CoordSystem;
928
+ transform(input: CoordTransformInput): CompiledLayer[];
929
+ }
930
+
931
+ /**
932
+ * Discriminated union of all coordinate input specs (user-provided, optional params).
933
+ */
934
+ declare type CoordInput = CartesianCoordInput | FlipCoordInput | PolarCoordInput;
935
+
936
+ /**
937
+ * Built-in coordinate system implementations keyed by {@link CoordType}.
938
+ */
939
+ declare class CoordRegistry extends Registry<CoordType, CoordStrategy> {
940
+ constructor();
941
+ }
942
+
943
+ declare interface CoordSetupInput {
944
+ coordSpec: CoordSpec;
945
+ }
946
+
947
+ /**
948
+ * Discriminated union of all resolved coordinate specs (params fully defaulted).
949
+ */
950
+ declare type CoordSpec = CartesianCoordSpec | FlipCoordSpec | PolarCoordSpec;
951
+
952
+ /**
953
+ * Strategy interface for compiling a specific coordinate system type
954
+ */
955
+ declare interface CoordStrategy {
956
+ /**
957
+ * The coordinate type this strategy handles.
958
+ * Must match the `coordType` property on the coordinate spec.
959
+ */
960
+ readonly coordType: CoordType;
961
+ /**
962
+ * Produces the coordinate system with axis orientation metadata.
963
+ * Called before the guide compiler.
964
+ */
965
+ setup: (input: CoordSetupInput) => CoordSystem;
966
+ /**
967
+ * Transforms position-mapped layers through the coordinate system.
968
+ * Called after the position mapper to produce render-ready coordinates.
969
+ */
970
+ transform: (input: CoordTransformInput) => CompiledLayer[];
971
+ }
972
+
973
+ /**
974
+ * Render-ready coordinate system (discriminated union).
975
+ * Discriminates on geometric paradigm: cartesian plane vs polar projection.
976
+ */
977
+ export declare type CoordSystem = CartesianCoordSystem | PolarCoordSystem;
978
+
979
+ declare interface CoordTransformInput {
980
+ coordSpec: CoordSpec;
981
+ layers: CompiledLayer[];
982
+ }
983
+
984
+ /**
985
+ * Coordinate system type for transforming geometric positions.
986
+ *
987
+ * - `'cartesian'` — Standard x/y Cartesian plane
988
+ * - `'polar'` — Polar coordinates for pie, radar, and radial charts
989
+ * - `'flip'` — Cartesian with x and y axes swapped
990
+ */
991
+ declare type CoordType = 'cartesian' | 'polar' | 'flip';
992
+
993
+ export declare const createAlphaValueReader: (data: Dataset, mapping: AesMapping) => (observation: Observation) => DataValue;
994
+
995
+ export declare const createColorValueReader: (data: Dataset, mapping: AesMapping) => (observation: Observation) => DataValue;
996
+
997
+ export declare const createGroupValueReader: (data: Dataset, mapping: AesMapping) => (observation: Observation) => DataValue;
998
+
999
+ export declare const createLabelValueReader: (data: Dataset, mapping: AesMapping) => (observation: Observation) => DataValue;
1000
+
1001
+ export declare const createSizeValueReader: (data: Dataset, mapping: AesMapping) => (observation: Observation) => DataValue;
1002
+
1003
+ /**
1004
+ * Create a new spec, optionally piping spec items in one call.
1005
+ *
1006
+ * @example
1007
+ * When using the mapping as second arg:
1008
+ * createSpec(data, { x: 'date', y: 'value' })
1009
+ *
1010
+ * When using the mapping as a spec item (more readable when chaining transforms):
1011
+ * createSpec(
1012
+ * data,
1013
+ * transform.reshape({ reshape: ['revenue'], keyName: 'metric', valueName: 'amount' }),
1014
+ * mapping({ x: 'month', y: 'amount', color: 'metric' }),
1015
+ * geom.bar(),
1016
+ * scale.x(),
1017
+ * )
1018
+ */
1019
+ export declare function createSpec(data: Data, ...items: Array<AesMapping | SpecItem>): SpecInput;
1020
+
1021
+ export declare const createStrokeWidthValueReader: (data: Dataset, mapping: AesMapping) => (observation: Observation) => DataValue;
1022
+
1023
+ export declare const createXValueReader: (data: Dataset, mapping: AesMapping) => (observation: Observation) => DataValue;
1024
+
1025
+ export declare const createYValueReader: (data: Dataset, mapping: AesMapping) => (observation: Observation) => DataValue;
1026
+
1027
+ /** Three letter ISO string representing the currency */
1028
+ declare type CurrencyIso = 'aed' | 'aud' | 'bdt' | 'bhd' | 'brl' | 'cad' | 'chf' | 'clp' | 'cny' | 'cop' | 'czk' | 'dkk' | 'egp' | 'eur' | 'gbp' | 'hkd' | 'huf' | 'idr' | 'ils' | 'inr' | 'jpy' | 'krw' | 'kwd' | 'mxn' | 'myr' | 'ngn' | 'nok' | 'nzd' | 'php' | 'pkr' | 'pln' | 'qar' | 'ron' | 'rub' | 'sar' | 'sek' | 'sgd' | 'thb' | 'try' | 'twd' | 'usd' | 'vnd' | 'zar';
1029
+
1030
+ declare interface CurrencyValueFormat {
1031
+ type: 'currency';
1032
+ iso: CurrencyIso;
1033
+ }
1034
+
1035
+ /**
1036
+ * Data to visualize. Structured as a table.
1037
+ *
1038
+ * The public-API contract. Row values must be {@link DataValue} (string, number,
1039
+ * Date, or null). Internal entry points (e.g. the dataset parser) accept a
1040
+ * looser row type — see {@link RawData} — because they must defensively handle
1041
+ * malformed input.
1042
+ */
1043
+ export declare interface Data {
1044
+ /**
1045
+ * Column definitions. Every column is an object with a stable `key` that matches the keys used in each row and an optional `label` to show in the UI.
1046
+ */
1047
+ columns: Array<{
1048
+ /** Unique, stable identifier. */
1049
+ key: string;
1050
+ /** Friendly label for the column. */
1051
+ label?: string;
1052
+ /* Excluded from this release type: _metadata */
1053
+ }>;
1054
+ /**
1055
+ * Data rows. Each row object must contain keys that match `columns[i].key`.
1056
+ */
1057
+ rows: Array<Record<string, DataValue>>;
1058
+ /* Excluded from this release type: _metadata */
1059
+ }
1060
+
1061
+ declare interface DataLabels {
1062
+ showDataLabels?: boolean;
1063
+ dataLabelFormat?: 'absolute' | 'percentage';
1064
+ showStackTotals?: boolean;
1065
+ showCategoryLabels?: boolean;
1066
+ }
1067
+
1068
+ /**
1069
+ * An immutable, columnar dataset. Uses Arquero internally for filtering, grouping and aggregation.
1070
+ *
1071
+ * Data is organised as **variables** (columns) and **observations** (rows). The values of each variable are typed and must match the variable's {@link DataType}. Missing values are represented as `null`.
1072
+ *
1073
+ * All transformation methods (filter, orderBy, addVariable etc.) return a new instance.
1074
+ *
1075
+ * @example
1076
+ * const data = new Dataset({
1077
+ * age: { type: 'numeric', values: [25, 30, 35, null] },
1078
+ * name: { type: 'categorical', values: ['John', 'Jane', 'Jim', 'Joanna'] },
1079
+ * });
1080
+ *
1081
+ * data.filter('age', 'gt', 30).print();
1082
+ */
1083
+ export declare class Dataset {
1084
+ private table;
1085
+ private variableMetadata;
1086
+ /**
1087
+ * Constructs a new dataset from typed columnar input.
1088
+ * @param variables - A record mapping variable names to their type and values.
1089
+ *
1090
+ * @example
1091
+ * const data = new Dataset({
1092
+ * age: { type: 'numeric', values: [25, 30, 35] },
1093
+ * name: { type: 'categorical', values: ['John', 'Jane', 'Jim'] },
1094
+ * });
1095
+ */
1096
+ constructor(variables?: VariableMap);
1097
+ /**
1098
+ * Merges multiple datasets into a single one.
1099
+ */
1100
+ static merge(...datasets: Dataset[]): Dataset;
1101
+ /* Excluded from this release type: fromTrusted */
1102
+ /**
1103
+ * Returns the number of observations in the dataset.
1104
+ */
1105
+ size(): number;
1106
+ /**
1107
+ * Returns the names of all variables in the dataset.
1108
+ */
1109
+ getVariableNames(): VariableName[];
1110
+ /**
1111
+ * Returns true if the dataset has the given variable.
1112
+ */
1113
+ hasVariable(variable: VariableName): boolean;
1114
+ /**
1115
+ * Returns a JSON-serialisable {@link Data} representation of this dataset. Inverse of
1116
+ * {@link parseDataset}: feeding the result back through the parser reconstructs an
1117
+ * equivalent dataset.
1118
+ */
1119
+ toData(): Data;
1120
+ /**
1121
+ * Adds a new variable to the dataset.
1122
+ */
1123
+ addVariable(variable: VariableName, type: DataType, values: DataValue[]): Dataset;
1124
+ /**
1125
+ * Adds a new constant variable to the dataset.
1126
+ */
1127
+ addConstantVariable(variable: VariableName, type: DataType, value: DataValue): Dataset;
1128
+ /**
1129
+ * Derives a new variable based on existing variables, using a table expression.
1130
+ */
1131
+ deriveVariable(variable: VariableName, type: DataType, expression: (observation: Observation) => DataValue): Dataset;
1132
+ /**
1133
+ * Renames a variable.
1134
+ */
1135
+ renameVariable(oldName: VariableName, newName: VariableName): Dataset;
1136
+ /**
1137
+ * Selects a subset of variables from the dataset.
1138
+ */
1139
+ selectVariables(...variables: VariableName[]): Dataset;
1140
+ /**
1141
+ * Returns the type of a variable.
1142
+ */
1143
+ getType(variable: VariableName): DataType;
1144
+ /**
1145
+ * Groups the variable names by their type.
1146
+ */
1147
+ groupVariableNamesByType(): GroupedVariableNames;
1148
+ /**
1149
+ * Returns the values of a given variable.
1150
+ *
1151
+ * @param options.type - The expected type of the values. If provided, the return type is narrowed to the matching concrete type and a runtime check ensures the variable actually carries that type.
1152
+ * @param options.skipNulls - Whether to skip null values. Defaults to `false`.
1153
+ * @param options.distinct - Whether to remove duplicate values from the result. Defaults to `false`.
1154
+ */
1155
+ getValues(variable: VariableName, options: GetValuesOptions & {
1156
+ type: 'numeric';
1157
+ skipNulls?: false;
1158
+ }): Array<number | null>;
1159
+ getValues(variable: VariableName, options: GetValuesOptions & {
1160
+ type: 'categorical';
1161
+ skipNulls?: false;
1162
+ }): Array<string | null>;
1163
+ getValues(variable: VariableName, options: GetValuesOptions & {
1164
+ type: 'temporal';
1165
+ skipNulls?: false;
1166
+ }): Array<Date | null>;
1167
+ getValues(variable: VariableName, options: GetValuesOptions & {
1168
+ type: 'numeric';
1169
+ skipNulls: true;
1170
+ }): number[];
1171
+ getValues(variable: VariableName, options: GetValuesOptions & {
1172
+ type: 'categorical';
1173
+ skipNulls: true;
1174
+ }): string[];
1175
+ getValues(variable: VariableName, options: GetValuesOptions & {
1176
+ type: 'temporal';
1177
+ skipNulls: true;
1178
+ }): Date[];
1179
+ getValues(variable: VariableName, options?: GetValuesOptions): DataValue[];
1180
+ /**
1181
+ * Filters the dataset using a declarative predicate.
1182
+ */
1183
+ filter(variableName: VariableName, operator: ComparisonOperator, value: DataValue): Dataset;
1184
+ /**
1185
+ * Orders the dataset by a variable, in ascending (default) or descending order.
1186
+ */
1187
+ orderBy(variable: VariableName, direction?: 'asc' | 'desc'): Dataset;
1188
+ /**
1189
+ * Returns the first observation in the dataset.
1190
+ */
1191
+ getFirst(): Observation | null;
1192
+ /**
1193
+ * Returns the last observation in the dataset.
1194
+ */
1195
+ getLast(): Observation | null;
1196
+ /**
1197
+ * Returns the last observation matching a predicate, scanning backwards from the end.
1198
+ */
1199
+ findLast(predicate: (observation: Observation) => boolean): Observation | null;
1200
+ /**
1201
+ * Groups the dataset by one or more variables.
1202
+ */
1203
+ groupBy(...variables: VariableName[]): GroupBy;
1204
+ /**
1205
+ * Aggregates the dataset.
1206
+ */
1207
+ rollup(aggregations: AggregationInput): Dataset;
1208
+ /**
1209
+ * Reshapes data from wide to long format by collapsing multiple numeric variables
1210
+ * into key–value pairs.
1211
+ *
1212
+ * ```
1213
+ * ┌─────────┬──────┬──────┬──────┐ ┌─────────┬──────┬─────┐
1214
+ * │ country │ 2020 │ 2021 │ 2022 │ │ country │ year │ gdp │
1215
+ * ├─────────┼──────┼──────┼──────┤ ───► ├─────────┼──────┼─────┤
1216
+ * │ US │ 100 │ 110 │ 120 │ │ US │ 2020 │ 100 │
1217
+ * │ UK │ 200 │ 210 │ 220 │ │ US │ 2021 │ 110 │
1218
+ * └─────────┴──────┴──────┴──────┘ │ US │ 2022 │ 120 │
1219
+ * │ UK │ 2020 │ 200 │
1220
+ * │ UK │ 2021 │ 210 │
1221
+ * │ UK │ 2022 │ 220 │
1222
+ * └─────────┴──────┴─────┘
1223
+ * ```
1224
+ *
1225
+ * @param keep - Variables to carry through unchanged. Defaults to all
1226
+ * categorical and temporal variables.
1227
+ * @param reshape - Numeric variables to collapse into rows. Defaults to all
1228
+ * numeric variables.
1229
+ * @param keyName - Name of the new variable whose values are the
1230
+ * original variable names (default: 'key').
1231
+ * @param valueName - Name of the new variable whose values are the
1232
+ * original values of the variables to reshape (default: 'value').
1233
+ * @throws If `keyName` or `valueName` conflicts with a variable in `keep`.
1234
+ * @throws If any variable in `reshape` is not numeric.
1235
+ *
1236
+ * @example
1237
+ * const reshaped = data.reshapeFromWideToLong({
1238
+ * keep: ['country'],
1239
+ * reshape: ['2020', '2021'],
1240
+ * keyName: 'year',
1241
+ * valueName: 'gdp',
1242
+ * });
1243
+ */
1244
+ reshapeFromWideToLong({ keep, reshape, keyName, valueName, }?: {
1245
+ keep?: VariableName[];
1246
+ reshape?: VariableName[];
1247
+ keyName?: VariableName;
1248
+ valueName?: VariableName;
1249
+ }): Dataset;
1250
+ /**
1251
+ * Prints the dataset to the console.
1252
+ */
1253
+ print(): void;
1254
+ /**
1255
+ * Returns an iterator over the observations in the dataset.
1256
+ */
1257
+ [Symbol.iterator](): Iterator<Observation>;
1258
+ /**
1259
+ * Parses the variable map into a table and variable metadata.
1260
+ */
1261
+ private parseVariableMap;
1262
+ /**
1263
+ * Normalizes raw values into typed values.
1264
+ */
1265
+ private normalizeRawValues;
1266
+ /**
1267
+ * Skips nulls when retrieving values from a variable.
1268
+ */
1269
+ private skipNulls;
1270
+ /**
1271
+ * Returns distinct values.
1272
+ */
1273
+ private getDistinctValues;
1274
+ }
1275
+
1276
+ /**
1277
+ * Metadata about the dataset (before we reshape it from wide to long format).
1278
+ */
1279
+ declare interface DatasetMetadata {
1280
+ /**
1281
+ * Column metadata, keyed by column key. For each column,
1282
+ * we store the inferred value format and a function to get the default label.
1283
+ */
1284
+ columns: ColumnMetadata;
1285
+ }
1286
+
1287
+ /** The type of a variable's values. Internally, numeric values are stored as numbers, dates as Date objects and categorical values as strings. */
1288
+ export declare type DataType = 'numeric' | 'categorical' | 'temporal';
1289
+
1290
+ /** The smallest unit of data in the dataset. `null` represents a missing value. */
1291
+ export declare type DataValue = number | string | Date | null;
1292
+
1293
+ declare interface DatetimeScaleInput {
1294
+ type: 'scale';
1295
+ scaledAesthetic: ScaledAestheticKey;
1296
+ scaleType: 'datetime';
1297
+ domainMin?: number | null;
1298
+ domainMax?: number | null;
1299
+ nice?: boolean;
1300
+ reverse?: boolean;
1301
+ clamp?: boolean;
1302
+ }
1303
+
1304
+ declare type DatetimeScaleOptions = {
1305
+ /** Minimum domain override (milliseconds since epoch). */
1306
+ domainMin?: number;
1307
+ /** Maximum domain override (milliseconds since epoch). */
1308
+ domainMax?: number;
1309
+ /**
1310
+ * Reverse the scale direction.
1311
+ * Can be combined with any transformation.
1312
+ * @default false
1313
+ * @example scale.y.log({ reverse: true }) // reversed log scale
1314
+ */
1315
+ reverse?: boolean;
1316
+ /**
1317
+ * Extend domain to nice round values.
1318
+ * @example nice: true // [3, 97] becomes [0, 100]
1319
+ */
1320
+ nice?: boolean;
1321
+ /**
1322
+ * Restrict output to the scale's range when input falls outside the domain.
1323
+ * Without clamping, values extrapolate beyond the range boundaries.
1324
+ * Defaults to false for datetime scales (always positional).
1325
+ * @example clamp: true // Pin out-of-domain values to range boundaries
1326
+ */
1327
+ clamp?: boolean;
1328
+ };
1329
+
1330
+ declare type DatetimeScaleSpec = Required<DatetimeScaleInput>;
1331
+
1332
+ declare interface DatetimeTickInterval {
1333
+ unit: DatetimeTickIntervalUnit;
1334
+ step: number;
1335
+ }
1336
+
1337
+ declare type DatetimeTickIntervalUnit = 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
1338
+
1339
+ /**
1340
+ * Recursively makes every property of `T` optional.
1341
+ * Unlike the built-in `Partial`, this applies to nested objects as well.
1342
+ */
1343
+ declare type DeepPartial<T> = {
1344
+ [K in keyof T]?: T[K] extends Array<infer U> ? Array<DeepPartial<U>> : NonNullable<T[K]> extends object ? DeepPartial<NonNullable<T[K]>> : T[K];
1345
+ };
1346
+
1347
+ /**
1348
+ * Default Graphy color palette.
1349
+ *
1350
+ * Used as the built-in palette for `scale.color.palette()` when no
1351
+ * explicit palette name is provided.
1352
+ */
1353
+ export declare const DEFAULT_COLOR_PALETTE: readonly ["#B399FE", "#FC7E91", "#33B6E0", "#FFC849", "#25CDA5", "#FA9B65", "#D93C95", "#845FD8", "#3F8EEB", "#58C8D8", "#F35074", "#6EA0DA"];
1354
+
1355
+ /**
1356
+ * Default font style.
1357
+ */
1358
+ export declare const DEFAULT_FONT_STYLE = "normal";
1359
+
1360
+ /**
1361
+ * Default font weight.
1362
+ */
1363
+ export declare const DEFAULT_FONT_WEIGHT = 500;
1364
+
1365
+ export declare const DEFAULT_LOCALE: Locale;
1366
+
1367
+ export declare const DEFAULT_PALETTE_NAME = "default";
1368
+
1369
+ declare interface DiscreteScaleInput {
1370
+ type: 'scale';
1371
+ scaledAesthetic: ScaledAestheticKey;
1372
+ scaleType: 'discrete';
1373
+ range?: Array<number | string> | null;
1374
+ sort?: DiscreteSort | null;
1375
+ domain?: Array<string | number> | null;
1376
+ padding?: number | null;
1377
+ }
1378
+
1379
+ declare type DiscreteScaleOptions = {
1380
+ /**
1381
+ * Explicit output values mapped to domain categories in order.
1382
+ */
1383
+ range?: Array<number | string>;
1384
+ /**
1385
+ * Sort order for discrete domain values.
1386
+ * @default 'none'
1387
+ */
1388
+ sort?: DiscreteSort | null;
1389
+ /**
1390
+ * Explicit domain values controlling category order and membership.
1391
+ * Only these values appear in the scale; sort is ignored when domain is set.
1392
+ */
1393
+ domain?: Array<string | number>;
1394
+ /**
1395
+ * Padding between bands as a fraction of the band step (0–1).
1396
+ * Applied as `innerPadding = padding` and `outerPadding = padding / 2`.
1397
+ * @default 0.1
1398
+ */
1399
+ padding?: number;
1400
+ };
1401
+
1402
+ declare type DiscreteScaleSpec = Required<DiscreteScaleInput>;
1403
+
1404
+ declare type DiscreteSort = 'ascending' | 'descending' | 'none';
1405
+
1406
+ /** Measured heights of content regions (header: title+subtitle, footer: caption). */
1407
+ export declare interface ExternalMeasurements {
1408
+ headerSize: BoxSize;
1409
+ footerSize: BoxSize;
1410
+ }
1411
+
1412
+ declare function filter(options: FilterOptions): FilterTransformInput;
1413
+
1414
+ /***************************************************************
1415
+ * Filter Transform
1416
+ ***************************************************************/
1417
+ declare interface FilterOptions {
1418
+ /** The variable to filter on. */
1419
+ variableName: VariableName;
1420
+ /** The comparison operator. */
1421
+ operator: ComparisonOperator;
1422
+ /** The value to compare against. */
1423
+ value: DataValue;
1424
+ }
1425
+
1426
+ declare interface FilterTransformInput {
1427
+ type: 'transform';
1428
+ transformType: 'filter';
1429
+ options: FilterOptions;
1430
+ }
1431
+
1432
+ declare interface FlipCoordInput {
1433
+ type: 'coord';
1434
+ coordType: 'flip';
1435
+ params?: Partial<BaseCoordParams>;
1436
+ }
1437
+
1438
+ declare type FlipCoordParams = BaseCoordParams;
1439
+
1440
+ declare interface FlipCoordSpec {
1441
+ type: 'coord';
1442
+ coordType: 'flip';
1443
+ params: BaseCoordParams;
1444
+ }
1445
+
1446
+ export declare interface FontSpec {
1447
+ family: string;
1448
+ size: number;
1449
+ weight?: NamedWeightKey | number;
1450
+ style?: 'normal' | 'italic' | 'oblique';
1451
+ }
1452
+
1453
+ /**
1454
+ * Formats all legend guides by attaching a `formattedLabel` to each item.
1455
+ */
1456
+ export declare const formatLegends: (compiled: CompiledSpec, { formattingLocale }?: {
1457
+ formattingLocale?: Locale;
1458
+ }) => FormattedLegend[];
1459
+
1460
+ export declare interface FormattedAxis extends Omit<CompiledAxisGuide, 'tickCandidates'> {
1461
+ ticks: Array<AxisTick & {
1462
+ formattedLabel: string;
1463
+ }>;
1464
+ /** Rotation in degrees applied uniformly to all tick labels. 0 = no rotation. */
1465
+ labelRotation: number;
1466
+ /** Max label width in px before ellipsis truncation. null = no cap. */
1467
+ labelMaxWidthPx: number | null;
1468
+ }
1469
+
1470
+ export declare interface FormattedLegend extends Omit<CompiledLegendGuide, 'items'> {
1471
+ items: Array<LegendItem & {
1472
+ formattedLabel: string;
1473
+ }>;
1474
+ }
1475
+
1476
+ /**
1477
+ * Options for `generateTicks`:
1478
+ * - `{ count }` — approximate tick count (continuous, datetime).
1479
+ * - `{ interval }` — fixed time interval (datetime only).
1480
+ * - `{ atInputs: true }` — ticks at the deduped input values (datetime only).
1481
+ *
1482
+ * Discrete scales ignore options. Unsupported variants on a given scale fall back to defaults.
1483
+ */
1484
+ declare type GenerateTicksOptions = {
1485
+ count: number;
1486
+ } | {
1487
+ interval: DatetimeTickInterval;
1488
+ } | {
1489
+ atInputs: true;
1490
+ };
1491
+
1492
+ /**
1493
+ * Base class for geoms that turn observations into visual marks (points, bars, lines etc).
1494
+ */
1495
+ declare abstract class Geom {
1496
+ readonly requiredAesthetics: AestheticKey[];
1497
+ abstract readonly type: GeomName;
1498
+ abstract compile(input: GeomCompilerInput): CompiledGeom;
1499
+ }
1500
+
1501
+ export declare const geom: {
1502
+ point: typeof point;
1503
+ line: typeof line;
1504
+ area: typeof area;
1505
+ bar: typeof bar;
1506
+ };
1507
+
1508
+ /**
1509
+ * Resolves a geom by name and delegates compilation.
1510
+ */
1511
+ declare class GeomCompiler {
1512
+ private readonly registry;
1513
+ constructor(registry: GeomRegistry);
1514
+ compile(geomName: GeomName, input: GeomCompilerInput): CompiledGeom;
1515
+ }
1516
+
1517
+ declare interface GeomCompilerInput {
1518
+ /** The dataset after stat transformation */
1519
+ data: Dataset;
1520
+ /** The effective mapping for the layer */
1521
+ mapping: AesMapping;
1522
+ /** Geom-specific params */
1523
+ params: LayerSpec['params'];
1524
+ }
1525
+
1526
+ /**
1527
+ * The type of geometric mark used to represent data in a layer.
1528
+ *
1529
+ * - `'point'` — Scatter-style dot marks
1530
+ * - `'line'` — Connected line marks
1531
+ * - `'area'` — Filled area marks
1532
+ * - `'bar'` — Rectangular bar marks
1533
+ */
1534
+ export declare type GeomName = 'point' | 'line' | 'area' | 'bar';
1535
+
1536
+ declare type GeomOptions<G extends GeomName> = BaseGeomOptions<GeomParamsMap[G]>;
1537
+
1538
+ declare type GeomParams = GeomParamsMap[keyof GeomParamsMap];
1539
+
1540
+ /**
1541
+ * Maps each geom type name to its resolved parameter type.
1542
+ */
1543
+ declare interface GeomParamsMap {
1544
+ point: PointGeomParams;
1545
+ line: LineGeomParams;
1546
+ area: AreaGeomParams;
1547
+ bar: BarGeomParams;
1548
+ }
1549
+
1550
+ /**
1551
+ * Built-in geom implementations keyed by {@link GeomName}.
1552
+ */
1553
+ declare class GeomRegistry extends Registry<GeomName, Geom> {
1554
+ constructor();
1555
+ }
1556
+
1557
+ /** Reads the resolved alpha (opacity) value from an observation. */
1558
+ export declare function getAlpha(observation: Observation): NumericDataValue;
1559
+
1560
+ export declare function getAngleExtent(observation: Observation): AngleExtent;
1561
+
1562
+ /** Reads the resolved color string from an observation. */
1563
+ export declare function getColor(observation: Observation): string | undefined;
1564
+
1565
+ /** Reads the coordinate lying on the cross axis of the coord system. */
1566
+ export declare function getCrossAxisCoordinate(mainAxis: MainAxis, point: XYPoint): number;
1567
+
1568
+ export declare const getGroup: (observation: Observation) => CategoricalDataValue;
1569
+
1570
+ /** Reads the coordinate lying on the main (independent) axis of the coord system. */
1571
+ export declare function getMainAxisCoordinate(mainAxis: MainAxis, point: XYPoint): number;
1572
+
1573
+ export declare function getRadiusExtent(observation: Observation): RadiusExtent;
1574
+
1575
+ /** Reads the resolved size value from an observation. */
1576
+ export declare function getSize(observation: Observation): NumericDataValue;
1577
+
1578
+ /** Reads the resolved stroke width value from an observation. */
1579
+ export declare function getStrokeWidth(observation: Observation): NumericDataValue;
1580
+
1581
+ declare interface GetValuesOptions {
1582
+ /** The expected type of the values. */
1583
+ type?: DataType;
1584
+ /** Whether to skip null values. Defaults to `false`. */
1585
+ skipNulls?: boolean;
1586
+ /** Whether to return distinct values. Defaults to `false`. */
1587
+ distinct?: boolean;
1588
+ }
1589
+
1590
+ /** Reads the normalized x position from an observation. */
1591
+ export declare function getX(observation: Observation): NumericDataValue;
1592
+
1593
+ /** Reads the normalized xMax (right band edge) from an observation. */
1594
+ export declare function getXMax(observation: Observation): NumericDataValue;
1595
+
1596
+ /** Reads the normalized xMin (left band edge) from an observation. */
1597
+ export declare function getXMin(observation: Observation): NumericDataValue;
1598
+
1599
+ /** Reads the normalized y position from an observation. */
1600
+ export declare function getY(observation: Observation): NumericDataValue;
1601
+
1602
+ /** Reads the normalized yMax (upper extent) from an observation. */
1603
+ export declare function getYMax(observation: Observation): NumericDataValue;
1604
+
1605
+ /** Reads the normalized yMin (lower extent) from an observation. */
1606
+ export declare function getYMin(observation: Observation): NumericDataValue;
1607
+
1608
+ /** Goal line with a target value. */
1609
+ declare interface GoalLine {
1610
+ target: number;
1611
+ marker?: DataValue;
1612
+ label?: string;
1613
+ }
1614
+
1615
+ declare type GraphAnnotation = GraphStickerAnnotation | GraphTooltipAnnotation | GraphHighlightAnnotation | GraphTextAnnotation | GraphArrowAnnotation | GraphDifferenceArrowAnnotation | GraphShapeAnnotation;
1616
+
1617
+ declare interface GraphArrowAnnotation {
1618
+ id: string;
1619
+ type: 'arrow';
1620
+ startX: number;
1621
+ startY: number;
1622
+ endX: number;
1623
+ endY: number;
1624
+ color?: string;
1625
+ thickness: 'thin' | 'medium' | 'thick';
1626
+ startArrowheadStyle: 'none' | 'line-arrow';
1627
+ lineStyle: 'solid' | 'dashed';
1628
+ endArrowheadStyle: 'none' | 'line-arrow';
1629
+ hasStickerStyle: boolean;
1630
+ }
1631
+
1632
+ export declare interface GraphConfig {
1633
+ data: Data;
1634
+ type?: GraphType;
1635
+ options?: Options;
1636
+ axes?: Axes;
1637
+ legend?: Legend;
1638
+ appearance?: Appearance;
1639
+ themeOverrides?: unknown;
1640
+ content?: Content;
1641
+ headlineNumbers?: HeadlineNumbers;
1642
+ dataLabels?: DataLabels;
1643
+ annotations?: GraphAnnotation[];
1644
+ referenceLines?: ReferenceLines;
1645
+ }
1646
+
1647
+ declare interface GraphDifferenceArrowAnnotation {
1648
+ id: string;
1649
+ type: 'difference-arrow';
1650
+ show: 'absolute-difference' | 'relative-difference' | 'proportion';
1651
+ start: AnnotationDataPoint;
1652
+ end: AnnotationDataPoint;
1653
+ color?: string;
1654
+ size: 'medium' | 'small' | 'large';
1655
+ labelPosition?: number;
1656
+ }
1657
+
1658
+ declare type GraphHighlightAnnotation = {
1659
+ id: string;
1660
+ type: 'highlight';
1661
+ highlight: 'data-point' | 'series' | 'x-value';
1662
+ } & AnnotationDataPoint;
1663
+
1664
+ /** Output of the layout computation. */
1665
+ export declare interface GraphLayout {
1666
+ /** The full graphical area (axes + panel + axis labels), excluding header and footer. */
1667
+ plot: Rect;
1668
+ /** The panel area where geom layers render i.e. the data rectangle inside the axes. */
1669
+ panel: Rect;
1670
+ /** Rects for axis regions (ticks + tick labels), keyed by edge. */
1671
+ axes: Partial<Record<LayoutEdge, Rect>>;
1672
+ /** Rects for axis title labels, keyed by edge. */
1673
+ axisLabels: Partial<Record<LayoutEdge, Rect>>;
1674
+ /** Rect for the header region (title + subtitle, above the panel). */
1675
+ header: Rect;
1676
+ /** Rect for the footer region (caption, below the panel). */
1677
+ footer: Rect;
1678
+ /** Rects for the legend regions, keyed by edge. */
1679
+ legends: Partial<Record<LayoutEdge, Rect>>;
1680
+ }
1681
+
1682
+ declare interface GraphShapeAnnotation {
1683
+ id: string;
1684
+ type: 'shape';
1685
+ shape: 'rectangle';
1686
+ layer: 'belowPlot' | 'abovePlot';
1687
+ x: number;
1688
+ y: number;
1689
+ width: number;
1690
+ height: number;
1691
+ fillColor: string;
1692
+ fillOpacity: number;
1693
+ strokeWidth: number;
1694
+ }
1695
+
1696
+ declare type GraphStickerAnnotation = {
1697
+ id: string;
1698
+ type: 'sticker';
1699
+ sticker: 'rocket' | 'clapping-hands' | 'thumbs-up' | 'thumbs-down' | 'grinning-face';
1700
+ } & AnnotationDataPoint;
1701
+
1702
+ declare interface GraphTextAnnotation {
1703
+ id: string;
1704
+ type: 'text';
1705
+ content: unknown;
1706
+ x: number;
1707
+ y: number;
1708
+ width: number;
1709
+ backgroundColor?: string;
1710
+ backgroundColorStyle?: 'fade' | 'opaque';
1711
+ }
1712
+
1713
+ declare interface GraphTextStyle {
1714
+ fontId?: string;
1715
+ color?: string;
1716
+ }
1717
+
1718
+ declare type GraphTooltipAnnotation = {
1719
+ id: string;
1720
+ type: 'tooltip';
1721
+ caption: unknown;
1722
+ } & AnnotationDataPoint;
1723
+
1724
+ /** Type of graph to use for the data. */
1725
+ export declare type GraphType = 'line' | 'areaStacked' | 'bar' | 'barStacked' | 'barStackedFill' | 'column' | 'columnStacked' | 'columnStackedFill' | 'combo' | 'pie' | 'donut' | 'funnel' | 'heatmap' | 'scatter' | 'bubble' | 'waterfall' | 'mekko' | 'table';
1726
+
1727
+ export declare const GROUP_VARIABLES: {
1728
+ readonly group: string;
1729
+ };
1730
+
1731
+ /**
1732
+ * A group by operation on a dataset. This is returned when calling `new Dataset(...).groupBy(...)`.
1733
+ */
1734
+ declare class GroupBy {
1735
+ private groupedBy;
1736
+ private grouped;
1737
+ private variableMetadata;
1738
+ constructor(groupedBy: VariableName[], grouped: Table, variableMetadata: VariableMetadata);
1739
+ /**
1740
+ * Iterates over each group.
1741
+ */
1742
+ forEach(callback: (group: Dataset, groupKey: string, groupIndex: number) => void): void;
1743
+ /**
1744
+ * Aggregates the variables in each group.
1745
+ */
1746
+ rollup(aggregations: AggregationInput): Dataset;
1747
+ /**
1748
+ * Computes the group key based on the first value of the grouped variable. If multiple variables are grouped, returns a composite key.
1749
+ */
1750
+ private getStableKey;
1751
+ }
1752
+
1753
+ /**
1754
+ * Computes a `group` variable with composite group keys. If a `group` aesthetic is explicitly mapped, it is used as
1755
+ * the sole group variable. Otherwise, the grouping is determined by discrete aesthetics (where a group is created
1756
+ * for each unique combination of the discrete aesthetics). When no group variables exist, fills the variable with null.
1757
+ */
1758
+ declare class GroupCompiler {
1759
+ compute({ data, mapping }: GroupCompilerInput): CompiledGroup;
1760
+ }
1761
+
1762
+ declare interface GroupCompilerInput {
1763
+ data: Dataset;
1764
+ mapping: AesMapping;
1765
+ }
1766
+
1767
+ /** A map of variable names grouped by their type. */
1768
+ declare type GroupedVariableNames = {
1769
+ [key in DataType]: VariableName[];
1770
+ };
1771
+
1772
+ /**
1773
+ * Compiles guides (axes and legends) from compiled scales and config.
1774
+ *
1775
+ * Legends are compiled first because the resolved legend position influences
1776
+ * axis compilation (e.g. legend on right forces Y-axis to left).
1777
+ *
1778
+ * Axes are produced from position scales (x, y, ySecondary).
1779
+ * Legends are produced from non-position, non-identity visual scales.
1780
+ * Legends that share the same variable and domain are merged.
1781
+ */
1782
+ declare class GuideCompiler {
1783
+ compile(input: GuideCompilerInput): CompiledGuides;
1784
+ }
1785
+
1786
+ declare interface GuideCompilerInput {
1787
+ scales: CompiledScales;
1788
+ config: ConfigSpec;
1789
+ layers: CompiledLayer[];
1790
+ coordSystem: CoordSystem;
1791
+ datasetMetadata: DatasetMetadata;
1792
+ }
1793
+
1794
+ declare type GuideGeometry = 'linear' | 'circular' | 'radial';
1795
+
1796
+ /**
1797
+ * Comparison reference for trend indicator
1798
+ * - 'previous': Compare to preceding data point
1799
+ * - 'first': Compare to initial value in series
1800
+ * - 'none': No comparison indicator
1801
+ */
1802
+ declare type HeadlineCompare = 'previous' | 'first' | 'none';
1803
+
1804
+ /**
1805
+ * Headline numbers configuration
1806
+ */
1807
+ declare interface HeadlineConfig {
1808
+ /**
1809
+ * Which aggregate to display
1810
+ * @default 'none'
1811
+ */
1812
+ show: HeadlineShow;
1813
+ /**
1814
+ * Reference point for trend comparison
1815
+ * @default 'none'
1816
+ */
1817
+ compareWith: HeadlineCompare;
1818
+ /**
1819
+ * Visual size of the headline numbers
1820
+ * @default 'auto'
1821
+ */
1822
+ size: HeadlineSize;
1823
+ /**
1824
+ * Where to display the headline
1825
+ * - 'above': In the header region above the chart (default)
1826
+ * - 'center': In the center of a donut chart hole (only valid for donut charts with inner radius)
1827
+ * @default 'above'
1828
+ */
1829
+ position: HeadlinePosition;
1830
+ }
1831
+
1832
+ declare interface HeadlineNumbers {
1833
+ show?: 'current' | 'average' | 'total' | 'conversion' | 'none';
1834
+ compareWith?: 'previous' | 'first' | 'none';
1835
+ size?: 'auto' | 'small' | 'medium' | 'large';
1836
+ }
1837
+
1838
+ /**
1839
+ * Placement of headline numbers
1840
+ * - 'above': Display above the chart (default, in the header region)
1841
+ * - 'center': Display in the center of a donut chart hole (only valid for donut charts)
1842
+ */
1843
+ declare type HeadlinePosition = 'above' | 'center';
1844
+
1845
+ /**
1846
+ * Display mode for headline numbers
1847
+ * - 'total': Sum of all values
1848
+ * - 'average': Arithmetic mean
1849
+ * - 'current': Last value in series (for time series)
1850
+ * - 'conversion': Percentage change from first to last
1851
+ * - 'none': Disable headline numbers
1852
+ */
1853
+ declare type HeadlineShow = 'total' | 'average' | 'current' | 'conversion' | 'none';
1854
+
1855
+ /**
1856
+ * Size of headline numbers
1857
+ * - 'auto': Automatically scale based on available space and number of series
1858
+ * - 'small': Compact display
1859
+ * - 'medium': Standard display
1860
+ * - 'large': Prominent display
1861
+ */
1862
+ declare type HeadlineSize = 'auto' | 'small' | 'medium' | 'large';
1863
+
1864
+ /**
1865
+ * A zero-dependency text measurer that estimates dimensions using
1866
+ * per-character width ratios calibrated from Inter Regular.
1867
+ *
1868
+ * Accuracy is approximately 5-8% for Inter and 10-15% for other fonts.
1869
+ * Intended for use in test environments (jsdom) where no Canvas API is available.
1870
+ */
1871
+ export declare class HeuristicTextMeasurer implements TextMeasurer {
1872
+ measureText(text: string, font: FontSpec): MeasuredText;
1873
+ }
1874
+
1875
+ /**
1876
+ * The mouse position captured alongside a hit. Present even when the cursor is over no geom.
1877
+ *
1878
+ * Both coordinates are normalized pane-local values in `[0, 1]`. `y` is data-space (0 at the
1879
+ * bottom of the plot, 1 at the top), matching the compiler's `POSITION_VARIABLES.y` convention
1880
+ * — so the tracker is responsible for flipping SVG's top-origin Y before calling `query()`.
1881
+ */
1882
+ export declare interface HoverCursor {
1883
+ x: number;
1884
+ y: number;
1885
+ }
1886
+
1887
+ /**
1888
+ * The transferable hover core. Indexes a compiled spec, diffs on update, and produces a
1889
+ * `HoverState` for any cursor position. No DOM access, no framework coupling.
1890
+ */
1891
+ export declare class HoverEngine {
1892
+ private layerIndexes;
1893
+ private layerRefs;
1894
+ private aspectRatio;
1895
+ private warmStarts;
1896
+ private cachedState;
1897
+ private cachedKey;
1898
+ /**
1899
+ * IDs of layers whose `CompiledLayer.interactive` is `false`. Recomputed on every `update()`
1900
+ * so toggling the flag does not force an index rebuild. Used to filter the layer list before
1901
+ * `hitTest` and `classify` see it — non-interactive layers participate in neither primary
1902
+ * detection nor group/related, so they are visual decoration only as far as hover is concerned.
1903
+ */
1904
+ private nonInteractiveLayerIds;
1905
+ constructor(spec: CompiledSpec);
1906
+ /**
1907
+ * Diff-aware re-index. Layers whose `data`, `geom`, `position` or the graph's coord-system
1908
+ * reference changed are rebuilt; others are retained, including their warm-start seed. All
1909
+ * four references live in `LayerRefSnapshot`, so `areRefsEqual` is the single source of truth
1910
+ * for invalidation.
1911
+ *
1912
+ * Prev state is keyed by the stable `CompiledLayer.id` (== `LayerIndex.layerId`), not by array
1913
+ * position, so reordering, insertion or removal of layers does not spuriously invalidate
1914
+ * untouched layers' indexes or warm-starts.
1915
+ */
1916
+ update(spec: CompiledSpec): void;
1917
+ /**
1918
+ * Renderers call this on mount and on resize. Viewport is set-once, not per-query.
1919
+ *
1920
+ * On every call, viewport-dependent indexes are asked to re-prep themselves for the new
1921
+ * viewport (`reindexPoints2DForAspect` is idempotent on aspect match, so unchanged-aspect
1922
+ * calls are cheap). The renderer is expected to debounce resize events so the underlying
1923
+ * Delaunay rebuild does not fire on every observed frame during a drag.
1924
+ */
1925
+ setViewport(viewport: HoverViewport): void;
1926
+ /**
1927
+ * Synchronous query. Returns the same `HoverState` reference while the primary stays on the
1928
+ * same `(layerId, pointIndex)`, so subscribers using identity-based equality can short-circuit
1929
+ * intra-geom cursor moves without re-rendering. Cache invalidates on `update()`. Warm-start
1930
+ * seeds are written after every match so the next call walks a minimum number of Delaunay edges.
1931
+ */
1932
+ query(cursor: HoverCursor): HoverState;
1933
+ private invalidateCache;
1934
+ }
1935
+
1936
+ /**
1937
+ * A single hit returned by the hover engine.
1938
+ *
1939
+ * `layerId` is the stable `CompiledLayer.id` — *not* an array position. The engine preserves it
1940
+ * across `update()` calls regardless of layer reordering or insertion, so callers must resolve a
1941
+ * layer by matching `layer.id === hit.layerId`, never by `layers[layerId]`.
1942
+ *
1943
+ * `pointIndex` is an opaque per-layer stable handle for the hit geom, used by the engine as a
1944
+ * warm-start seed for subsequent queries. The encoding is per index kind:
1945
+ * - `buckets` / `rects` / `arcs`: the dataset row inside the layer's observations.
1946
+ * - `points`: the entry's position inside the layer's `points[]` (i.e. the Delaunay's array
1947
+ * index). Diverges from the dataset row when the dataset has null x/y gaps, so callers must
1948
+ * read `observation` rather than indexing `data` by `pointIndex`.
1949
+ *
1950
+ * In every case the handle is stable across `update()` calls for layers whose `data`/`geom`/
1951
+ * `position` references were not replaced (the warm-start identity promised by the ADR), and
1952
+ * callers that need the observation row should read `observation` — never index into the dataset
1953
+ * by `pointIndex`.
1954
+ */
1955
+ export declare interface HoverHit {
1956
+ layerId: string;
1957
+ pointIndex: number;
1958
+ /**
1959
+ * Normalized panel-local position. Cartesian: `[0, 1]²` in data-space (y=0 at the bottom,
1960
+ * y=1 at the top — matching the compiler's `POSITION_VARIABLES.y`). Polar: `(angle in radians
1961
+ * clockwise from 12 o'clock, radius in [0, 1])`.
1962
+ */
1963
+ x: number;
1964
+ y: number;
1965
+ /** The observation being hovered over. Renderers read values from here; the engine does not format. */
1966
+ observation: Observation;
1967
+ }
1968
+
1969
+ /** Output of `HoverEngine.query()`. */
1970
+ export declare interface HoverState {
1971
+ primary: HoverHit | null;
1972
+ group: HoverHit[];
1973
+ /**
1974
+ * Cross-layer and same-layer companion hits, bucketed by `CompiledLayer.id` so a per-layer
1975
+ * consumer reads its own hits in O(1) (`related.get(layer.id) ?? []`) instead of filtering
1976
+ * a flat array on every render. Layers with no companions are absent from the map — callers
1977
+ * fall back to an empty array on miss.
1978
+ */
1979
+ related: ReadonlyMap<string, HoverHit[]>;
1980
+ }
1981
+
1982
+ /** Viewport facts the engine needs for aspect-corrected hit testing. */
1983
+ export declare interface HoverViewport {
1984
+ /** Panel width in pixels. */
1985
+ width: number;
1986
+ /** Pane height in pixels. */
1987
+ height: number;
1988
+ }
1989
+
1990
+ declare interface IdentityScaleInput {
1991
+ type: 'scale';
1992
+ scaledAesthetic: ScaledAestheticKey;
1993
+ scaleType: 'identity';
1994
+ }
1995
+
1996
+ declare type IdentityScaleOptions = Record<string, never>;
1997
+
1998
+ declare type IdentityScaleSpec = IdentityScaleInput;
1999
+
2000
+ declare interface InferredScaleInput {
2001
+ type: 'scale';
2002
+ scaledAesthetic: ScaledAestheticKey;
2003
+ scaleType: 'inferred';
2004
+ options?: InferredScaleOptions;
2005
+ }
2006
+
2007
+ declare type InferredScaleOptions = ContinuousScaleOptions | DiscreteScaleOptions | DatetimeScaleOptions;
2008
+
2009
+ /**
2010
+ * Curve interpolation method for lines and areas.
2011
+ *
2012
+ * - `'linear'` — Straight segments between points
2013
+ * - `'catmull-rom'` — Smooth spline through points
2014
+ */
2015
+ export declare type InterpolateType = 'linear' | 'catmull-rom';
2016
+
2017
+ /** Narrows a coord system to the cartesian variant. */
2018
+ export declare function isCartesian(coordSystem: CoordSystem): coordSystem is CartesianCoordSystem;
2019
+
2020
+ /**
2021
+ * Type guard that checks if a value is neither null nor undefined.
2022
+ */
2023
+ export declare function isDefined<T>(value: T | null | undefined): value is T;
2024
+
2025
+ /**
2026
+ * Type guard for narrowing a `CompiledLayer` to its per-geom flavour. Use at dispatch sites that
2027
+ * pick a renderer based on `layer.geom`:
2028
+ *
2029
+ * if (isLayerOf(layer, 'line')) renderLine(layer); // layer is CompiledLayerFor<'line'>
2030
+ */
2031
+ export declare function isLayerOf<G extends GeomName>(layer: CompiledLayer, geom: G): layer is CompiledLayerFor<G>;
2032
+
2033
+ export declare function isStackedPosition(position: PositionType): boolean;
2034
+
2035
+ /**
2036
+ * Compiles each layer through the transforms → stat → group → geom → position adjusters pipeline.
2037
+ */
2038
+ declare class LayerCompiler {
2039
+ private readonly transformCompiler;
2040
+ private readonly statCompiler;
2041
+ private readonly groupCompiler;
2042
+ private readonly geomCompiler;
2043
+ private readonly positionAdjusterCompiler;
2044
+ private readonly layerValidator;
2045
+ constructor(transformCompiler: TransformCompiler, statCompiler: StatCompiler, groupCompiler: GroupCompiler, geomCompiler: GeomCompiler, positionAdjusterCompiler: PositionAdjusterCompiler, layerValidator: LayerValidator);
2046
+ compile(input: LayerCompilerInput): CompiledLayer[];
2047
+ /**
2048
+ * Applies each layer's transforms once and computes its effective mapping.
2049
+ * The resulting data is used for both validation and the stat/group/geom pipeline.
2050
+ */
2051
+ private prepareLayers;
2052
+ /**
2053
+ * Validates each layer against its post-transform dataset and effective mapping.
2054
+ */
2055
+ private validateLayers;
2056
+ private compileLayer;
2057
+ }
2058
+
2059
+ declare interface LayerCompilerInput {
2060
+ /** The input dataset */
2061
+ data: Dataset;
2062
+ /** The layers to compile */
2063
+ layers: LayerSpec[];
2064
+ /** The effective mapping for the layers */
2065
+ mapping: AesMapping;
2066
+ }
2067
+
2068
+ /**
2069
+ * Discriminated union of all layer inputs, keyed on `geom`.
2070
+ * This is the user-facing type — fields are optional and will be resolved with defaults.
2071
+ */
2072
+ declare type LayerInput = {
2073
+ [G in GeomName]: LayerInputOf<G>;
2074
+ }[GeomName];
2075
+
2076
+ declare interface LayerInputBase {
2077
+ type: 'layer';
2078
+ id?: string;
2079
+ mapping?: AesMapping;
2080
+ stat?: StatName;
2081
+ position?: PositionType;
2082
+ yScaleType?: YScaleType;
2083
+ /**
2084
+ * Ordered transforms applied to this layer's view of the data, on top of any
2085
+ * spec-level transforms. Use this when a geom needs a different shape of the
2086
+ * data than its siblings (e.g. a line overlay on top of reshaped stacked bars).
2087
+ */
2088
+ transforms?: TransformInput[];
2089
+ /**
2090
+ * When `false`, the layer is skipped from main hover hit-detection.
2091
+ * @default true
2092
+ */
2093
+ interactive?: boolean;
2094
+ }
2095
+
2096
+ declare type LayerInputOf<G extends GeomName> = LayerInputBase & {
2097
+ geom: G;
2098
+ params?: Partial<GeomParamsMap[G]>;
2099
+ };
2100
+
2101
+ /**
2102
+ * Discriminated union of all resolved layer specs, keyed on `geom`.
2103
+ * All properties are fully resolved — no optionals.
2104
+ */
2105
+ declare type LayerSpec = {
2106
+ [G in GeomName]: LayerSpecOf<G>;
2107
+ }[GeomName];
2108
+
2109
+ declare interface LayerSpecBase {
2110
+ type: 'layer';
2111
+ id: string;
2112
+ mapping: AesMapping;
2113
+ stat: StatName;
2114
+ position: PositionType;
2115
+ yScaleType: YScaleType;
2116
+ transforms: TransformInput[];
2117
+ interactive: boolean;
2118
+ }
2119
+
2120
+ declare type LayerSpecOf<G extends GeomName> = LayerSpecBase & {
2121
+ geom: G;
2122
+ params: GeomParamsMap[G];
2123
+ };
2124
+
2125
+ declare interface LayerValidationInput {
2126
+ layerId: string;
2127
+ geom: GeomName;
2128
+ stat: StatName;
2129
+ /** `spec.mapping` merged with `layer.mapping` */
2130
+ effectiveMapping: AesMapping;
2131
+ /** Layer's dataset after its own transforms have been applied */
2132
+ data: Dataset;
2133
+ }
2134
+
2135
+ /**
2136
+ * Validates a single layer against a set of invariants.
2137
+ *
2138
+ * Checks:
2139
+ * 1. All required aesthetics are present (accounting for stat-computed variables).
2140
+ * 2. All mapped variables exist in the layer's dataset (after transforms).
2141
+ *
2142
+ * Returns issues rather than throwing. The caller (LayerCompiler) batches issues across all layers and throws
2143
+ * a single SpecValidationError at the end.
2144
+ */
2145
+ declare class LayerValidator {
2146
+ private readonly geomRegistry;
2147
+ private readonly statRegistry;
2148
+ constructor(geomRegistry: GeomRegistry, statRegistry: StatRegistry);
2149
+ validate(input: LayerValidationInput): ValidationIssue[];
2150
+ /**
2151
+ * Checks that all aesthetics required by the geom are present (accounting for stat-computed variables).
2152
+ */
2153
+ private validateRequiredAesthetics;
2154
+ /**
2155
+ * Checks that every mapped variable in the effective mapping exists in the layer's dataset (after
2156
+ * transforms). Skips aesthetics that will be computed by stats (e.g. `y` when `stat='count'`).
2157
+ */
2158
+ private validateVariableExistence;
2159
+ }
2160
+
2161
+ /** Outer padding around the whole chart, in pixels. */
2162
+ export declare const LAYOUT_PADDING = 24;
2163
+
2164
+ /**
2165
+ * Compiles layout geometry and final axis ticks. Output rects are in container coordinates.
2166
+ *
2167
+ * Horizontal axis edge height is candidate-independent (~line-height), so `panel.height` is
2168
+ * settled after the first resolve.
2169
+ *
2170
+ * Here's the pipeline:
2171
+ * 1. **Seed**: stamp each axis with a placeholder label so the grid has something to measure.
2172
+ * 2. **Resolve v1**: first grid pass; `panel.height` is now final.
2173
+ * 3. **Finalize vertical**: pick the densest candidate that fits `panel.height` for left/right
2174
+ * axes; horizontal axes keep their seed.
2175
+ * 4. **Resolve v2**: vertical edge widths now reflect final labels, so `panel.width` is final.
2176
+ * 5. **Finalize horizontal**: pick the densest candidate that fits `panel.width` for top/bottom
2177
+ * axes. Vertical axes carry over from step 3.
2178
+ * 6. **Resolve v3**: final grid pass with all axes finalized.
2179
+ */
2180
+ export declare class LayoutCompiler {
2181
+ private readonly measurer;
2182
+ constructor(measurer: LayoutMeasurer);
2183
+ compile(input: LayoutCompilerInput): LayoutCompileResult;
2184
+ /**
2185
+ * Stamps each axis with a single hardcoded-label placeholder tick. This gives the grid something to measure in
2186
+ * the first pass. The finalize pass replaces it with the real candidate selected for the resolved panel size.
2187
+ */
2188
+ private seedAxis;
2189
+ private finalizeAxis;
2190
+ private resolveLayout;
2191
+ /**
2192
+ * Measures all graph elements from the formatted guides.
2193
+ * Returns three EdgeSizes records. A size of 0 means the element is absent.
2194
+ */
2195
+ private measureGuides;
2196
+ }
2197
+
2198
+ /**
2199
+ * Full output of {@link LayoutCompiler.compile} — the geometry plus the axes with their final formatted ticks.
2200
+ */
2201
+ export declare interface LayoutCompileResult {
2202
+ layout: GraphLayout;
2203
+ formattedAxes: FormattedAxis[];
2204
+ }
2205
+
2206
+ /** Input for the layout compiler. */
2207
+ export declare interface LayoutCompilerInput {
2208
+ compiled: CompiledSpec;
2209
+ formattedLegends: FormattedLegend[];
2210
+ containerSize: BoxSize;
2211
+ externalMeasurements: ExternalMeasurements;
2212
+ formattingLocale?: Locale;
2213
+ }
2214
+
2215
+ /** Positions where axes/labels/legends can be placed around the panel. */
2216
+ export declare type LayoutEdge = 'top' | 'right' | 'bottom' | 'left';
2217
+
2218
+ /** Strategy for measuring chart element sizes in pixels. */
2219
+ export declare interface LayoutMeasurer {
2220
+ /** Returns the pixel size for an axis (height for top/bottom, width for left/right). */
2221
+ measureAxis: (axis: FormattedAxis) => number;
2222
+ /** Returns the pixel height for an axis label row. */
2223
+ measureAxisLabel: () => number;
2224
+ /** Returns the pixel size for a legend (height for top/bottom, width for left/right). */
2225
+ measureLegend: (legend: FormattedLegend) => number;
2226
+ /** Returns the size of a single tick label. */
2227
+ measureTickLabel: (label: string) => MeasuredText;
2228
+ }
2229
+
2230
+ declare interface Legend {
2231
+ position?: 'auto' | 'top' | 'right' | 'none';
2232
+ }
2233
+
2234
+ /**
2235
+ * Legend configuration (after defaults applied)
2236
+ */
2237
+ declare interface LegendConfig {
2238
+ /**
2239
+ * Position of the legend
2240
+ * @default 'top'
2241
+ */
2242
+ position: LegendPosition;
2243
+ /**
2244
+ * Display mode for the legend.
2245
+ * - 'pill': Standard boxed legend with icons and labels
2246
+ * - 'direct': Labels rendered directly next to series endpoints
2247
+ * - 'auto': Resolved during compilation based on chart type and legend position
2248
+ *
2249
+ * @default 'auto'
2250
+ */
2251
+ display: LegendDisplay;
2252
+ }
2253
+
2254
+ /**
2255
+ * Legend configuration input type (all fields optional)
2256
+ */
2257
+ declare type LegendConfigInput = Partial<LegendConfig>;
2258
+
2259
+ /**
2260
+ * Legend display mode type
2261
+ * - 'pill': Standard boxed legend with icons and labels
2262
+ * - 'direct': Labels rendered directly next to series endpoints
2263
+ * - 'auto': Resolved during compilation based on chart type
2264
+ */
2265
+ declare type LegendDisplay = 'pill' | 'direct' | 'auto';
2266
+
2267
+ export declare interface LegendItem {
2268
+ /** Raw data value (e.g., "Apples") */
2269
+ value: DataValue;
2270
+ /**
2271
+ * Mapped visual values per aesthetic (e.g., { color: '#ff0000' }).
2272
+ * An array signals multi-swatch rendering — used when a color scale is
2273
+ * collapsed into a single legend item.
2274
+ */
2275
+ visual: Partial<Record<ScaledVisualAestheticKey, string | string[]>>;
2276
+ /** Normalized y position in [0,1]. Null when display is not 'direct' or no endpoint found. */
2277
+ normalizedY: number | null;
2278
+ }
2279
+
2280
+ export declare type LegendPosition = 'auto' | 'right' | 'left' | 'top' | 'bottom' | 'none';
2281
+
2282
+ declare function line(options?: GeomOptions<'line'>): LayerInputOf<'line'>;
2283
+
2284
+ /**
2285
+ * Line-specific parameters
2286
+ */
2287
+ export declare interface LineGeomParams {
2288
+ lineWidth: number | 'auto';
2289
+ lineType: LineStyleType;
2290
+ /**
2291
+ * Interpolation method to use for the line.
2292
+ * @default 'linear'
2293
+ */
2294
+ interpolate: InterpolateType;
2295
+ /**
2296
+ * How to handle missing (NULL/undefined) values.
2297
+ * @default 'gap'
2298
+ */
2299
+ missingValues: MissingValuesType;
2300
+ }
2301
+
2302
+ declare interface LineOptions {
2303
+ isSmoothLine?: boolean;
2304
+ lineThickness?: number | 'auto';
2305
+ showPoints?: boolean;
2306
+ missingValues?: 'gap' | 'connect' | 'zero';
2307
+ }
2308
+
2309
+ /**
2310
+ * Stroke style for line rendering.
2311
+ *
2312
+ * - `'solid'` — Continuous unbroken stroke
2313
+ * - `'dashed'` — Repeating dash pattern
2314
+ * - `'dotted'` — Repeating dot pattern
2315
+ */
2316
+ export declare type LineStyleType = 'solid' | 'dashed' | 'dotted';
2317
+
2318
+ export declare type Locale = (typeof LOCALES)[number];
2319
+
2320
+ /** A BCP-47 string representing a supported locale. */
2321
+ declare const LOCALES: readonly ["en-GB", "en-US", "ar", "pt-PT"];
2322
+
2323
+ /** The data-space axis a `CartesianCoordSystem` uses as the main (independent) axis. */
2324
+ export declare type MainAxis = 'x' | 'y';
2325
+
2326
+ /**
2327
+ * Create a pipeable mapping spec item.
2328
+ *
2329
+ * @example
2330
+ * createSpec(
2331
+ * data,
2332
+ * transform.reshape({ reshape: ['revenue'], keyName: 'metric', valueName: 'amount' }),
2333
+ * mapping({ x: 'month', y: 'amount', color: 'metric' }),
2334
+ * geom.bar(),
2335
+ * )
2336
+ */
2337
+ export declare function mapping(aes: AesMapping): MappingItem;
2338
+
2339
+ /**
2340
+ * A pipeable spec item that sets/merges the global aesthetic mapping.
2341
+ */
2342
+ declare interface MappingItem {
2343
+ type: 'mapping';
2344
+ mapping: AesMapping;
2345
+ }
2346
+
2347
+ export declare interface MeasuredText {
2348
+ width: number;
2349
+ height: number;
2350
+ ascent: number;
2351
+ descent: number;
2352
+ }
2353
+
2354
+ /**
2355
+ * Strategy for handling null/undefined values in lines and areas.
2356
+ *
2357
+ * - `'zero'` — Replace missing values with zero
2358
+ * - `'gap'` — Leave a visible gap where values are missing
2359
+ * - `'connect'` — Skip missing values and connect adjacent valid points
2360
+ */
2361
+ export declare type MissingValuesType = 'zero' | 'gap' | 'connect';
2362
+
2363
+ /**
2364
+ * Named font weights mapped to their numeric values.
2365
+ *
2366
+ * See: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/font-weight#common_weight_name_mapping
2367
+ */
2368
+ declare const NAMED_WEIGHTS: {
2369
+ readonly thin: 100;
2370
+ readonly hairline: 100;
2371
+ readonly extraLight: 200;
2372
+ readonly ultraLight: 200;
2373
+ readonly light: 300;
2374
+ readonly normal: 400;
2375
+ readonly regular: 400;
2376
+ readonly medium: 500;
2377
+ readonly semiBold: 600;
2378
+ readonly demiBold: 600;
2379
+ readonly bold: 700;
2380
+ readonly extraBold: 800;
2381
+ readonly ultraBold: 800;
2382
+ readonly black: 900;
2383
+ readonly heavy: 900;
2384
+ readonly extraBlack: 950;
2385
+ readonly ultraBlack: 950;
2386
+ };
2387
+
2388
+ declare type NamedWeightKey = keyof typeof NAMED_WEIGHTS;
2389
+
2390
+ /**
2391
+ * Configuration for formatting a single number.
2392
+ * Defines how numeric values should be displayed in the chart.
2393
+ */
2394
+ declare interface NumberFormatConfig {
2395
+ /**
2396
+ * Number of decimal places to display.
2397
+ * - number: Fixed decimal places (e.g., 2 → "1234.56")
2398
+ * - 'auto': Automatic based on value magnitude (default)
2399
+ */
2400
+ decimals: number | 'auto';
2401
+ /**
2402
+ * Abbreviation style for large numbers.
2403
+ * - 'none': No abbreviation (1234567 → "1,234,567")
2404
+ * - 'auto': Automatic based on magnitude (1234567 → "1.2M")
2405
+ * - 'k': Force thousands (1234567 → "1,234.6K")
2406
+ * - 'm': Force millions (1234567 → "1.2M")
2407
+ * - 'b': Force billions (1234567890 → "1.2B")
2408
+ */
2409
+ abbreviation: 'auto' | 'k' | 'm' | 'b' | 'none';
2410
+ /**
2411
+ * Thousands separator character.
2412
+ * Default: ',' (US) or locale-aware if locale is set
2413
+ */
2414
+ thousandsSeparator?: string;
2415
+ /**
2416
+ * Decimal separator character.
2417
+ * Default: '.' (US) or locale-aware if locale is set
2418
+ */
2419
+ decimalSeparator?: string;
2420
+ /**
2421
+ * Prefix to prepend (e.g., '$', '€').
2422
+ */
2423
+ prefix?: string;
2424
+ /**
2425
+ * Suffix to append (e.g., '%', ' units').
2426
+ */
2427
+ suffix?: string;
2428
+ }
2429
+
2430
+ declare type NumericDataValue = number | null;
2431
+
2432
+ declare interface NumericValueFormat {
2433
+ type: 'decimal' | 'integer' | 'percentage' | 'duration';
2434
+ }
2435
+
2436
+ /** A single row of data, mapping every variable name to the value in that row. */
2437
+ export declare type Observation = Record<VariableName, DataValue>;
2438
+
2439
+ declare type Options = Partial<LineOptions & BarOptions & ScatterOptions & ComboOptions & PieOptions & TableOptions>;
2440
+
2441
+ /**
2442
+ * A named store for color palettes used by scale compilation.
2443
+ *
2444
+ * Each palette is registered under a unique string key and maps to an ordered
2445
+ * array of color strings (e.g. hex values). The registry is consumed during
2446
+ * scale resolution to look up the concrete colors for a given palette name.
2447
+ *
2448
+ * Inherits `register`, `get`, `has`, and `getAll` from {@link Registry}.
2449
+ * Calling `get` with an unregistered name throws with a descriptive error
2450
+ * listing available palettes.
2451
+ *
2452
+ * @example
2453
+ * ```ts
2454
+ * const palettes = new PaletteRegistry();
2455
+ * palettes.register('brand', ['#1a1a2e', '#16213e', '#0f3460']);
2456
+ *
2457
+ * palettes.has('brand'); // true
2458
+ * palettes.get('brand'); // ['#1a1a2e', '#16213e', '#0f3460']
2459
+ * palettes.get('unknown'); // throws Error: Unknown palette: 'unknown'
2460
+ * ```
2461
+ */
2462
+ declare class PaletteRegistry extends Registry<string, string[]> {
2463
+ constructor();
2464
+ }
2465
+
2466
+ declare interface PaletteScaleInput {
2467
+ type: 'scale';
2468
+ scaledAesthetic: ScaledAestheticKey;
2469
+ scaleType: 'palette';
2470
+ palette?: string | null;
2471
+ }
2472
+
2473
+ declare interface PaletteScaleOptions {
2474
+ /** Graphy palette name. Defaults to the first registered palette. */
2475
+ palette?: string | null;
2476
+ }
2477
+
2478
+ declare type PaletteScaleSpec = Required<PaletteScaleInput> & {
2479
+ palette: string;
2480
+ };
2481
+
2482
+ /**
2483
+ * Panel configuration
2484
+ */
2485
+ declare interface PanelConfig {
2486
+ border: {
2487
+ isVisible: boolean;
2488
+ };
2489
+ }
2490
+
2491
+ declare interface PieOptions {
2492
+ pieTotalPosition?: 'center' | 'outside';
2493
+ }
2494
+
2495
+ /**
2496
+ * Pipe a spec through a series of spec items (left-to-right).
2497
+ */
2498
+ export declare function pipe(spec: SpecInput, ...items: SpecItem[]): SpecInput;
2499
+
2500
+ declare function point(options?: GeomOptions<'point'>): LayerInputOf<'point'>;
2501
+
2502
+ /**
2503
+ * Point-specific parameters
2504
+ */
2505
+ declare interface PointGeomParams {
2506
+ size: number;
2507
+ }
2508
+
2509
+ declare interface PolarCoordInput {
2510
+ type: 'coord';
2511
+ coordType: 'polar';
2512
+ params?: Partial<PolarCoordParams>;
2513
+ }
2514
+
2515
+ /**
2516
+ * Params for polar coordinate system
2517
+ */
2518
+ declare interface PolarCoordParams extends BaseCoordParams {
2519
+ /**
2520
+ * Which aesthetic maps to theta (angle): 'x' or 'y'
2521
+ */
2522
+ theta: 'x' | 'y';
2523
+ /**
2524
+ * Starting angle in degrees
2525
+ */
2526
+ startAngle: number;
2527
+ /**
2528
+ * Inner radius as fraction 0-1 (for donut charts)
2529
+ */
2530
+ innerRadius: number;
2531
+ }
2532
+
2533
+ declare interface PolarCoordSpec {
2534
+ type: 'coord';
2535
+ coordType: 'polar';
2536
+ params: PolarCoordParams;
2537
+ }
2538
+
2539
+ /**
2540
+ * Polar coordinate system - for pie charts, radar charts, etc.
2541
+ * Projection params (theta, startAngle, innerRadius) are consumed by the compiler
2542
+ * during coordTransform — the renderer only needs this for dispatch (drawing strategy, axes).
2543
+ */
2544
+ export declare interface PolarCoordSystem {
2545
+ type: 'polar';
2546
+ /** Axis orientation metadata for the guide compiler */
2547
+ axisMapping: AxisMapping;
2548
+ }
2549
+
2550
+ export declare const POSITION_VARIABLES: {
2551
+ readonly x: string;
2552
+ readonly y: string;
2553
+ readonly xMin: string;
2554
+ readonly xMax: string;
2555
+ readonly yMin: string;
2556
+ readonly yMax: string;
2557
+ };
2558
+
2559
+ /**
2560
+ * Base class for position adjustments that modify mark placement (e.g. stacking, dodging, jittering).
2561
+ */
2562
+ declare abstract class PositionAdjuster {
2563
+ abstract readonly type: PositionType;
2564
+ abstract adjust(input: PositionAdjusterCompilerInput): CompiledPositionAdjuster;
2565
+ }
2566
+
2567
+ /**
2568
+ * Resolves a position adjustment by name and delegates to the appropriate implementation.
2569
+ */
2570
+ declare class PositionAdjusterCompiler {
2571
+ private readonly registry;
2572
+ constructor(registry: PositionAdjusterRegistry);
2573
+ adjust(positionName: PositionType, input: PositionAdjusterCompilerInput): CompiledPositionAdjuster;
2574
+ }
2575
+
2576
+ declare interface PositionAdjusterCompilerInput {
2577
+ /** The dataset after stat and geom transformations */
2578
+ data: Dataset;
2579
+ /** The effective mapping for the layer */
2580
+ mapping: AesMapping;
2581
+ }
2582
+
2583
+ /**
2584
+ * Built-in position adjustments keyed by {@link PositionType}.
2585
+ */
2586
+ declare class PositionAdjusterRegistry extends Registry<PositionType, PositionAdjuster> {
2587
+ constructor();
2588
+ }
2589
+
2590
+ declare interface PositionalScaleMethods {
2591
+ /**
2592
+ * Continuous (numeric) scale. Supports `transform`, `reverse`, `nice`, `zero`, `domainMin`, `domainMax`.
2593
+ * @example scale.x.continuous({ domainMin: 0, nice: true })
2594
+ */
2595
+ continuous: (options?: ContinuousScaleOptions) => ContinuousScaleInput;
2596
+ /**
2597
+ * Discrete (categorical) scale. Supports explicit `range` values.
2598
+ * @example scale.x.discrete({ range: ['A', 'B', 'C'] })
2599
+ */
2600
+ discrete: (options?: DiscreteScaleOptions) => DiscreteScaleInput;
2601
+ /**
2602
+ * Datetime (temporal) scale. Supports `domainMin` / `domainMax` in epoch ms.
2603
+ * @example scale.x.datetime({ domainMin: Date.parse('2020-01-01') })
2604
+ */
2605
+ datetime: (options?: DatetimeScaleOptions) => DatetimeScaleInput;
2606
+ /**
2607
+ * Continuous scale with base-10 logarithmic transformation.
2608
+ * @example scale.y.log({ domainMin: 1 })
2609
+ */
2610
+ log: (options?: ContinuousScaleOptions) => ContinuousScaleInput;
2611
+ /**
2612
+ * Continuous scale with square-root transformation.
2613
+ * @example scale.y.sqrt({ nice: true })
2614
+ */
2615
+ sqrt: (options?: ContinuousScaleOptions) => ContinuousScaleInput;
2616
+ }
2617
+
2618
+ /**
2619
+ * A position variable mapper that applies position scaling for a single concern
2620
+ * (e.g. primary x, band extents, y baseline extents).
2621
+ *
2622
+ * Returns the dataset with any new positional variables added,
2623
+ * or the same dataset unchanged if this mapper does not apply.
2624
+ */
2625
+ declare interface PositionMapper {
2626
+ map: (input: PositionMapperInput) => Dataset;
2627
+ }
2628
+
2629
+ /**
2630
+ * Applies position scales to raw data values, producing scale-normalized
2631
+ * `x` and `y` variables ([0,1]) on each layer's dataset.
2632
+ *
2633
+ * Delegates to an ordered list of {@link PositionMapper} handlers,
2634
+ * each responsible for one position concern.
2635
+ */
2636
+ declare class PositionMapperCompiler {
2637
+ private readonly mappers;
2638
+ constructor(mappers?: PositionMapper[]);
2639
+ compile(input: PositionMapperCompilerInput): CompiledLayer[];
2640
+ private compileLayer;
2641
+ }
2642
+
2643
+ declare interface PositionMapperCompilerInput {
2644
+ layers: CompiledLayer[];
2645
+ scales: CompiledScales;
2646
+ }
2647
+
2648
+ /**
2649
+ * Context passed to each column mapper during position mapping.
2650
+ */
2651
+ declare interface PositionMapperInput {
2652
+ data: Dataset;
2653
+ layer: CompiledLayer;
2654
+ getPositionScale: (scaleAestheticKey: ScaledAestheticKey) => CompiledPositionScale | null;
2655
+ }
2656
+
2657
+ /**
2658
+ * Position adjustment for overlapping geometries.
2659
+ *
2660
+ * - `'stack'` — Stack geometries on top of each other (e.g. stacked bar chart)
2661
+ * - `'dodge'` — Place geometries side by side (e.g. grouped bar chart)
2662
+ * - `'identity'` — No adjustment, use raw positions (e.g. scatter plot, allows overlapping)
2663
+ * - `'fill'` — Normalize stacks to fill 100% of the axis (e.g. 100% stacked bar chart)
2664
+ */
2665
+ export declare type PositionType = 'stack' | 'dodge' | 'identity' | 'fill';
2666
+
2667
+ export declare const prefixInternalVariable: (name: string) => string;
2668
+
2669
+ declare interface QuantitativeScaleMethods {
2670
+ /**
2671
+ * Continuous (numeric) scale. Supports `transform`, `reverse`, `nice`, `zero`, `domainMin`, `domainMax`.
2672
+ * @example scale.size.continuous({ domainMin: 0 })
2673
+ */
2674
+ continuous: (options?: ContinuousScaleOptions) => ContinuousScaleInput;
2675
+ /**
2676
+ * Discrete (categorical) scale. Supports explicit `range` values.
2677
+ * @example scale.size.discrete({ range: [4, 8, 12] })
2678
+ */
2679
+ discrete: (options?: DiscreteScaleOptions) => DiscreteScaleInput;
2680
+ /**
2681
+ * Identity scale — data values used directly as visual values without transformation.
2682
+ * @example scale.size.identity() // { size: 10 } → 10px
2683
+ */
2684
+ identity: (options?: IdentityScaleOptions) => IdentityScaleInput;
2685
+ }
2686
+
2687
+ export declare interface RadiusExtent {
2688
+ innerRadius: NumericDataValue;
2689
+ outerRadius: NumericDataValue;
2690
+ }
2691
+
2692
+ /** A rectangle in pixel coordinates, origin at top-left. */
2693
+ export declare interface Rect {
2694
+ x: number;
2695
+ y: number;
2696
+ width: number;
2697
+ height: number;
2698
+ }
2699
+
2700
+ declare interface ReferenceLines {
2701
+ goalLine?: GoalLine;
2702
+ trendline?: TrendlineType;
2703
+ averageLine?: AverageLine;
2704
+ }
2705
+
2706
+ /**
2707
+ * A typed key-value store for looking up registered implementations by name.
2708
+ *
2709
+ * Used by the compiler to map type names (e.g. `'bar'`, `'stack'`) to
2710
+ * their corresponding implementations (e.g. `BarGeom`, `StackPosition`).
2711
+ *
2712
+ * @typeParam K - The key type (typically a string union like `GeomName`).
2713
+ * @typeParam T - The implementation type (e.g. `Geom`, `Stat`).
2714
+ */
2715
+ declare class Registry<K extends string, T> {
2716
+ private label;
2717
+ private items;
2718
+ constructor(label: string);
2719
+ /**
2720
+ * Add an implementation under the given key.
2721
+ */
2722
+ register(key: K, value: T): this;
2723
+ /**
2724
+ * Retrieve an implementation by key. Throws if not registered.
2725
+ */
2726
+ get(key: K): T;
2727
+ getAll(): T[];
2728
+ /**
2729
+ * Check whether a key has been registered.
2730
+ */
2731
+ has(key: K): boolean;
2732
+ }
2733
+
2734
+ /***************************************************************
2735
+ * Builders
2736
+ ***************************************************************/
2737
+ declare function reshape(options?: ReshapeOptions): ReshapeTransformInput;
2738
+
2739
+ /***************************************************************
2740
+ * Reshape Transform
2741
+ ***************************************************************/
2742
+ declare interface ReshapeOptions {
2743
+ /**
2744
+ * Numeric variables to collapse into rows.
2745
+ * Defaults to all numeric variables
2746
+ * */
2747
+ reshape?: VariableName[];
2748
+ /**
2749
+ * Variables to carry through unchanged.
2750
+ * Defaults to all categorical/temporal variables
2751
+ * */
2752
+ keep?: VariableName[];
2753
+ /**
2754
+ * Name of the output column containing the original variable names.
2755
+ * @default 'key'
2756
+ * */
2757
+ keyName?: VariableName;
2758
+ /**
2759
+ * Name of the output column containing the original values.
2760
+ * @default 'value'
2761
+ * */
2762
+ valueName?: VariableName;
2763
+ }
2764
+
2765
+ declare interface ReshapeTransformInput {
2766
+ type: 'transform';
2767
+ transformType: 'reshape';
2768
+ options: ReshapeOptions;
2769
+ }
2770
+
2771
+ /**
2772
+ * Concrete legend display after 'auto' has been resolved.
2773
+ * - 'auto' is resolved based on legend position and geom characteristics
2774
+ */
2775
+ export declare type ResolvedLegendDisplay = Exclude<LegendDisplay, 'auto'>;
2776
+
2777
+ /**
2778
+ * Discrete legend — one entry per domain value.
2779
+ * Produced from discrete and palette scales.
2780
+ */
2781
+ /**
2782
+ * Concrete legend position after 'auto' and 'none' have been resolved.
2783
+ * - 'none' is handled upstream (compileLegends returns [] when position is 'none')
2784
+ * - 'auto' is resolved to a concrete position by resolveLegendPosition
2785
+ */
2786
+ export declare type ResolvedLegendPosition = Exclude<LegendPosition, 'auto' | 'none'>;
2787
+
2788
+ /**
2789
+ * Canonical resting `HoverState`. Exported so the renderer-side store can reuse this exact
2790
+ * reference instead of maintaining a parallel literal that could drift.
2791
+ */
2792
+ export declare const RESTING_HOVER_STATE: HoverState;
2793
+
2794
+ /** TipTap-compatible rich text node (no tiptap dependency). */
2795
+ export declare interface RichTextContent {
2796
+ type: string;
2797
+ content?: RichTextContent[];
2798
+ text?: string;
2799
+ marks?: Array<{
2800
+ type: string;
2801
+ attrs?: Record<string, unknown>;
2802
+ }>;
2803
+ attrs?: Record<string, unknown>;
2804
+ }
2805
+
2806
+ declare abstract class Scale {
2807
+ /** Data types this scale accepts. */
2808
+ abstract readonly compatibleDataTypes: readonly DataType[];
2809
+ protected createPositionScale<Input extends DataValue = DataValue>(spec: ScaleSpec, options: CompiledPositionScaleOptions<Input>): CompiledScale;
2810
+ protected createVisualScale<Input extends DataValue = DataValue>(spec: ScaleSpec, options: CompiledVisualScaleOptions<Input>): CompiledScale;
2811
+ abstract compile(spec: ScaleSpec, values: DataValue[]): CompiledScale;
2812
+ }
2813
+
2814
+ export declare const scale: ScaleAPI;
2815
+
2816
+ declare interface ScaleAPI {
2817
+ /**
2818
+ * X-axis scale. Callable for inferred (auto-detects type from data), or use explicit methods.
2819
+ * @example scale.x() // inferred
2820
+ * @example scale.x({ nice: true }) // inferred with options
2821
+ * @example scale.x.continuous({ domainMin: 0 })
2822
+ * @example scale.x.log()
2823
+ */
2824
+ x: ((options?: InferredScaleOptions) => InferredScaleInput) & PositionalScaleMethods;
2825
+ /**
2826
+ * Y-axis scale. Callable for inferred (auto-detects type from data), or use explicit methods.
2827
+ * @example scale.y() // inferred
2828
+ * @example scale.y.continuous({ zero: true, nice: true })
2829
+ * @example scale.y.log({ reverse: true })
2830
+ */
2831
+ y: ((options?: InferredScaleOptions) => InferredScaleInput) & PositionalScaleMethods;
2832
+ /**
2833
+ * Secondary Y-axis scale. Independent position scale rendered on the opposite axis.
2834
+ * Callable for inferred (auto-detects type from data), or use explicit methods.
2835
+ * @example scale.ySecondary() // inferred
2836
+ * @example scale.ySecondary.continuous({ nice: true })
2837
+ */
2838
+ ySecondary: ((options?: InferredScaleOptions) => InferredScaleInput) & PositionalScaleMethods;
2839
+ /**
2840
+ * Color scale. Use `.continuous()`, `.discrete()`, or `.palette()`.
2841
+ * @example scale.color.palette({ palette: 'Bright' })
2842
+ * @example scale.color.discrete({ range: ['red', 'blue'] })
2843
+ */
2844
+ color: ColorScaleMethods;
2845
+ /**
2846
+ * Size scale. Use `.continuous()`, `.discrete()`, or `.identity()`.
2847
+ * Defaults to sqrt transform for area-proportional encoding.
2848
+ * @example scale.size.continuous({ range: [2, 30] })
2849
+ * @example scale.size.identity() // use data values directly as px
2850
+ */
2851
+ size: QuantitativeScaleMethods;
2852
+ /**
2853
+ * Alpha (opacity) scale. Use `.continuous()`, `.discrete()`, or `.identity()`.
2854
+ * @example scale.alpha.continuous({ range: [0.2, 0.9] })
2855
+ * @example scale.alpha.identity() // use data values directly as opacity
2856
+ */
2857
+ alpha: QuantitativeScaleMethods;
2858
+ /**
2859
+ * Stroke width scale. Use `.continuous()`, `.discrete()`, or `.identity()`.
2860
+ * @example scale.strokeWidth.continuous({ range: [1, 6] })
2861
+ * @example scale.strokeWidth.identity() // use data values directly as px
2862
+ */
2863
+ strokeWidth: QuantitativeScaleMethods;
2864
+ }
2865
+
2866
+ /**
2867
+ * Compiles scale specs into render-ready CompiledScale objects.
2868
+ */
2869
+ declare class ScaleCompiler {
2870
+ private readonly registry;
2871
+ constructor(registry: ScaleRegistry);
2872
+ compile(input: ScaleCompilerInput): CompiledScales;
2873
+ /**
2874
+ * Pre-pass: each scale's source variable must have a data type the scale can handle.
2875
+ */
2876
+ private validateScaleTypeCompatibility;
2877
+ /**
2878
+ * Walk all layers' mappings and collect data values per scale aesthetic key.
2879
+ *
2880
+ * For layers with `yScaleType: 'secondary'`, the `y` aesthetic values are
2881
+ * collected under the `ySecondary` scale aesthetic key instead of `y`.
2882
+ *
2883
+ * When a position adjuster (e.g. fill/stack) has written `yMin`/`yMax` columns,
2884
+ * those values are collected instead of the raw `y` mapping. This ensures the
2885
+ * y scale domain reflects the position-adjusted range (e.g. [0, 1] after fill).
2886
+ */
2887
+ private collectValues;
2888
+ /**
2889
+ * Determines which dataset variables to collect for a given aesthetic.
2890
+ *
2891
+ * For `y`, if position adjusters have written `yMin`/`yMax`, those columns
2892
+ * are returned instead of the raw mapping variable so the scale domain
2893
+ * reflects the adjusted range.
2894
+ */
2895
+ private resolveVariables;
2896
+ private hasPositionAdjustedY;
2897
+ private collectFromVariables;
2898
+ }
2899
+
2900
+ declare interface ScaleCompilerInput {
2901
+ layers: CompiledLayer[];
2902
+ scales: ScaleSpec[];
2903
+ }
2904
+
2905
+ /**
2906
+ * Identifiers for scales. Superset of AestheticKey — includes `ySecondary`
2907
+ * which is a scale aesthetic key but NOT an aesthetic (layers still map to `y`).
2908
+ */
2909
+ export declare type ScaledAestheticKey = ScaledPositionAestheticKey | ScaledVisualAestheticKey;
2910
+
2911
+ declare type ScaledPositionAestheticKey = 'x' | 'y' | 'ySecondary';
2912
+
2913
+ declare type ScaledVisualAestheticKey = 'color' | 'size' | 'alpha' | 'strokeWidth';
2914
+
2915
+ /**
2916
+ * Union type for all possible scale specifications (including inferred, pre-resolution).
2917
+ */
2918
+ declare type ScaleInput = ContinuousScaleInput | DiscreteScaleInput | PaletteScaleInput | DatetimeScaleInput | IdentityScaleInput | InferredScaleInput;
2919
+
2920
+ declare class ScaleRegistry extends Registry<ScaleType, Scale> {
2921
+ private readonly paletteRegistry;
2922
+ constructor(paletteRegistry: PaletteRegistry);
2923
+ }
2924
+
2925
+ /**
2926
+ * Union of scale specs that can appear after resolution (all fields required).
2927
+ * InferredScaleInput is resolved to a concrete type during spec resolution.
2928
+ */
2929
+ declare type ScaleSpec = ContinuousScaleSpec | DiscreteScaleSpec | DatetimeScaleSpec | IdentityScaleSpec | PaletteScaleSpec;
2930
+
2931
+ /**
2932
+ * Mathematical transformation for continuous scales.
2933
+ *
2934
+ * - `'linear'` — No transformation applied
2935
+ * - `'log'` — Base-10 logarithmic scale
2936
+ * - `'sqrt'` — Square root scale
2937
+ */
2938
+ declare type ScaleTransformType = 'linear' | 'log' | 'sqrt';
2939
+
2940
+ /**
2941
+ * Scale mapping type that defines how data values map to visual properties.
2942
+ *
2943
+ * - `'continuous'` — Continuous numeric range (e.g., min to max)
2944
+ * - `'discrete'` — Discrete categorical values
2945
+ * - `'datetime'` — Date/time range
2946
+ * - `'identity'` — Pass-through, values used as-is
2947
+ */
2948
+ declare type ScaleType = 'continuous' | 'discrete' | 'datetime' | 'identity' | 'palette';
2949
+
2950
+ declare interface ScatterOptions {
2951
+ pointSize?: number | 'auto';
2952
+ }
2953
+
2954
+ /**
2955
+ * Serialized representation of a command for wire transport and persistence.
2956
+ * Only forward commands are serialized — inverses are recomputed at execution time.
2957
+ */
2958
+ export declare interface SerializedCommand {
2959
+ readonly type: string;
2960
+ readonly params: Record<string, unknown>;
2961
+ readonly metadata: CommandMetadata;
2962
+ }
2963
+
2964
+ /** Config for styling a specific series. */
2965
+ declare interface SeriesStyle {
2966
+ paletteColorId?: string;
2967
+ customColor?: string;
2968
+ fillStyle?: 'solid' | 'hatched';
2969
+ lineStyle?: 'solid' | 'dashed' | 'dotted';
2970
+ }
2971
+
2972
+ /**
2973
+ * Sets the chart background color.
2974
+ * When set to null, the renderer falls back to its theme default.
2975
+ */
2976
+ export declare class SetAppearanceBackgroundCommand implements Command<SetAppearanceBackgroundParams> {
2977
+ readonly type: "set-appearance-background";
2978
+ readonly metadata: CommandMetadata;
2979
+ readonly params: SetAppearanceBackgroundParams;
2980
+ constructor(params: SetAppearanceBackgroundParams, metadata?: Partial<CommandMetadata>);
2981
+ apply(spec: Spec): CommandApplyResult | null;
2982
+ }
2983
+
2984
+ export declare type SetAppearanceBackgroundParams = {
2985
+ background: string | null;
2986
+ };
2987
+
2988
+ /**
2989
+ * Toggles visibility of the chart's textual content (title, subtitle, caption) as a group.
2990
+ * Underlying text values are preserved so toggling back restores them.
2991
+ */
2992
+ export declare class SetContentVisibilityCommand implements Command<SetContentVisibilityParams> {
2993
+ readonly type: "set-content-visibility";
2994
+ readonly metadata: CommandMetadata;
2995
+ readonly params: SetContentVisibilityParams;
2996
+ constructor(params: SetContentVisibilityParams, metadata?: Partial<CommandMetadata>);
2997
+ apply(spec: Spec): CommandApplyResult | null;
2998
+ }
2999
+
3000
+ export declare type SetContentVisibilityParams = {
3001
+ isVisible: boolean;
3002
+ };
3003
+
3004
+ /**
3005
+ * Command that swaps the dataset on a spec while preserving layer identity and all other
3006
+ * configuration. Enables data-change transitions — existing layer ids are retained, so
3007
+ * renderers using id-based keys can morph geoms instead of unmounting them.
3008
+ *
3009
+ * Accepts either raw `Data` (parsed on apply) or a pre-parsed `Dataset` (used by the revert
3010
+ * command). Revert commands are not serialized, so carrying a `Dataset` is safe.
3011
+ */
3012
+ export declare class SetDataCommand implements Command<SetDataParams> {
3013
+ readonly type: "set-data";
3014
+ readonly metadata: CommandMetadata;
3015
+ readonly params: SetDataParams;
3016
+ constructor(params: SetDataParams, metadata?: Partial<CommandMetadata>);
3017
+ apply(spec: Spec): CommandApplyResult | null;
3018
+ }
3019
+
3020
+ export declare type SetDataParams = {
3021
+ /** Raw data (will be parsed) or a pre-parsed `Dataset` (used for reverts). */
3022
+ data: Data | Dataset;
3023
+ };
3024
+
3025
+ /**
3026
+ * Controls grid line visibility for both axes simultaneously.
3027
+ * Takes independent x/y visibility flags to allow per-axis grid control and proper revert support.
3028
+ */
3029
+ export declare class SetGridVisibilityCommand implements Command<SetGridVisibilityParams> {
3030
+ readonly type: "set-grid-visibility";
3031
+ readonly metadata: CommandMetadata;
3032
+ readonly params: SetGridVisibilityParams;
3033
+ constructor(params: SetGridVisibilityParams, metadata?: Partial<CommandMetadata>);
3034
+ apply(spec: Spec): CommandApplyResult | null;
3035
+ }
3036
+
3037
+ export declare type SetGridVisibilityParams = {
3038
+ xIsVisible: boolean | null;
3039
+ yIsVisible: boolean | null;
3040
+ };
3041
+
3042
+ /**
3043
+ * Sets the legend placement relative to the chart (e.g. auto, top, bottom, left, right, none).
3044
+ * 'auto' lets the renderer choose the best position; 'none' hides the legend entirely.
3045
+ */
3046
+ export declare class SetLegendPositionCommand implements Command<SetLegendPositionParams> {
3047
+ readonly type: "set-legend-position";
3048
+ readonly metadata: CommandMetadata;
3049
+ readonly params: SetLegendPositionParams;
3050
+ constructor(params: SetLegendPositionParams, metadata?: Partial<CommandMetadata>);
3051
+ apply(spec: Spec): CommandApplyResult | null;
3052
+ }
3053
+
3054
+ export declare type SetLegendPositionParams = {
3055
+ position: LegendPosition;
3056
+ };
3057
+
3058
+ declare function sort(options: SortOptions): SortTransformInput;
3059
+
3060
+ /***************************************************************
3061
+ * Sort Transform
3062
+ ***************************************************************/
3063
+ declare interface SortOptions {
3064
+ /** The variable to sort by. */
3065
+ variableName: VariableName;
3066
+ /** Sort direction. @default 'asc' */
3067
+ direction?: 'asc' | 'desc';
3068
+ }
3069
+
3070
+ declare interface SortTransformInput {
3071
+ type: 'transform';
3072
+ transformType: 'sort';
3073
+ options: SortOptions;
3074
+ }
3075
+
3076
+ /**
3077
+ * Fully resolved spec — all fields populated, defaults applied, inferred types resolved.
3078
+ * This is what the compilation pipeline consumes.
3079
+ *
3080
+ * @example
3081
+ * ```ts
3082
+ * const spec = pipe(
3083
+ * createSpec(data, { x: 'date', y: 'revenue', color: 'region' }),
3084
+ * geom.bar(),
3085
+ * );
3086
+ * const resolved = resolveSpec(spec);
3087
+ *
3088
+ * // resolved.layers → at least one layer with resolved geom params, stat, and position
3089
+ * // resolved.scales → concrete scale types (no 'inferred'), all defaults filled
3090
+ * // resolved.coords → coordinate system with fully defaulted params
3091
+ * // resolved.config → axes, legend, headline, panel, numberFormat with defaults
3092
+ * ```
3093
+ */
3094
+ export declare interface Spec {
3095
+ /** The dataset backing the visualization. */
3096
+ data: Dataset;
3097
+ /** Per-column metadata captured at parse time (inferred value formats). Used by guide compilation to format tick and legend labels. */
3098
+ datasetMetadata: DatasetMetadata;
3099
+ /** Global aesthetic mappings (data columns → visual channels). */
3100
+ mapping: AesMapping;
3101
+ /** Geometry layers to render. Each layer has resolved geom, stat, position, and params. */
3102
+ layers: LayerSpec[];
3103
+ /** Resolved scale specs — one per aesthetic, all defaults filled, no 'inferred' types remaining. */
3104
+ scales: ScaleSpec[];
3105
+ /** Data transforms applied to `data` before layer compilation. */
3106
+ transforms: TransformInput[];
3107
+ /** Coordinate system (cartesian, flip, or polar) with fully defaulted params. */
3108
+ coords: CoordSpec;
3109
+ /** Chart configuration: axes, legend, headline, panel, number formatting. */
3110
+ config: ConfigSpec;
3111
+ }
3112
+
3113
+ /**
3114
+ * The canonical spec type — plain JSON, serializable.
3115
+ * This is what commands operate on and what gets stored in undo/redo snapshots.
3116
+ */
3117
+ export declare interface SpecInput {
3118
+ data: Data;
3119
+ mapping: AesMapping;
3120
+ layers: LayerInput[];
3121
+ scales: ScaleInput[];
3122
+ transforms: TransformInput[];
3123
+ coords?: CoordInput;
3124
+ config: ConfigInput;
3125
+ }
3126
+
3127
+ declare type SpecItem = LayerInput | ScaleInput | CoordInput | ConfigItem | TransformInput | MappingItem;
3128
+
3129
+ /**
3130
+ * Compiles a raw compiler input or graph config into a resolved Spec.
3131
+ */
3132
+ export declare class SpecResolver {
3133
+ compile(compilerInput: SpecInput | GraphConfig): Spec;
3134
+ resolveFromInput(input: SpecInput | GraphConfig, dataset: Dataset, datasetMetadata: DatasetMetadata): Spec;
3135
+ }
3136
+
3137
+ /**
3138
+ * Base class for statistical transformations applied to layer data (e.g. binning, counting, smoothing).
3139
+ */
3140
+ declare abstract class Stat {
3141
+ abstract readonly type: StatName;
3142
+ /**
3143
+ * Aesthetics this stat will compute (e.g. count computes 'y'). Used by validation to skip existence checks.
3144
+ */
3145
+ abstract readonly computedVariables: ReadonlySet<AestheticKey>;
3146
+ compute(input: StatCompilerInput): CompiledStat;
3147
+ protected abstract computeStat(input: StatCompilerInput): CompiledStat;
3148
+ }
3149
+
3150
+ /**
3151
+ * Resolves a stat by name and delegates computation.
3152
+ */
3153
+ declare class StatCompiler {
3154
+ private readonly registry;
3155
+ constructor(registry: StatRegistry);
3156
+ compute(statName: StatName, input: StatCompilerInput): CompiledStat;
3157
+ }
3158
+
3159
+ declare interface StatCompilerInput {
3160
+ /** The input dataset */
3161
+ data: Dataset;
3162
+ /** The effective mapping for the layer */
3163
+ mapping: AesMapping;
3164
+ }
3165
+
3166
+ /**
3167
+ * Statistical transformation applied to data before rendering.
3168
+ *
3169
+ * - `'identity'` — No transformation, data passed through unchanged
3170
+ * - `'count'` — Count the number of observations per x-axis value
3171
+ */
3172
+ declare type StatName = 'identity' | 'count';
3173
+
3174
+ /**
3175
+ * Built-in stat implementations keyed by {@link StatName}.
3176
+ */
3177
+ declare class StatRegistry extends Registry<StatName, Stat> {
3178
+ constructor();
3179
+ }
3180
+
3181
+ /**
3182
+ * Visual signature of the source geom.
3183
+ */
3184
+ export declare type SwatchShape = 'square' | 'line' | 'circle' | 'area' | 'slice';
3185
+
3186
+ declare type Table = internal.ColumnTable;
3187
+
3188
+ declare interface TableOptions {
3189
+ tableColumnRatios?: Record<string, number>;
3190
+ }
3191
+
3192
+ declare interface TemporalValueFormat {
3193
+ type: 'datetime' | 'time' | 'date' | 'year' | 'quarter' | 'month_year' | 'month' | 'weekly_date_range_with_year' | 'weekly_date_range' | 'day_month';
3194
+ /** Template string representing how values of this type have been formatted. ie. dd-mm-yyyy */
3195
+ dateFormat?: string;
3196
+ }
3197
+
3198
+ /** A text value — plain string or structured rich text. */
3199
+ export declare type TextContent = string | RichTextContent;
3200
+
3201
+ export declare interface TextMeasurer {
3202
+ measureText: (text: string, font: FontSpec) => MeasuredText;
3203
+ }
3204
+
3205
+ /** Fully-derived tooltip content. The popover renders directly from this. */
3206
+ export declare interface TooltipContent {
3207
+ /** Formatted main-axis value of the primary's observation. `null` for polar. */
3208
+ header: string | null;
3209
+ rows: TooltipRow[];
3210
+ }
3211
+
3212
+ /**
3213
+ * One row in the chart tooltip popover. Pure projection of a `HoverHit` against the layer's
3214
+ * compiled scales.
3215
+ */
3216
+ export declare interface TooltipRow {
3217
+ /**
3218
+ * Resolved color string applied as the row's swatch fill/stroke. `null` only when the chart
3219
+ * has no color scale at all — the popover suppresses the swatch cell in that edge case.
3220
+ */
3221
+ swatchColor: string | null;
3222
+ /** Visual signature of the row's source geom. Drives the swatch shape. */
3223
+ swatchShape: SwatchShape;
3224
+ /** Row label — color value (multi-series) or layer's Y-axis title (single-series). */
3225
+ label: string;
3226
+ /** Formatted Y reading for this hit. */
3227
+ value: string;
3228
+ /** Styling hint: the row whose hit `=== primary`. Never re-orders. */
3229
+ isPrimary: boolean;
3230
+ /** Stable key — `${layerId}:${pointIndex}`. */
3231
+ key: string;
3232
+ }
3233
+
3234
+ export declare const transform: {
3235
+ reshape: typeof reshape;
3236
+ filter: typeof filter;
3237
+ sort: typeof sort;
3238
+ aggregate: typeof aggregate;
3239
+ constant: typeof constant;
3240
+ };
3241
+
3242
+ /**
3243
+ * Applies spec-level transforms to a dataset by delegating to registered strategies.
3244
+ */
3245
+ declare class TransformCompiler {
3246
+ private readonly registry;
3247
+ constructor(registry: TransformRegistry);
3248
+ compile(data: Dataset, transforms: TransformInput[]): Dataset;
3249
+ }
3250
+
3251
+ /***************************************************************
3252
+ * Transform Input
3253
+ ***************************************************************/
3254
+ declare type TransformInput = ReshapeTransformInput | FilterTransformInput | SortTransformInput | AggregateTransformInput | ConstantTransformInput;
3255
+
3256
+ /**
3257
+ * Built-in transform implementations keyed by transform type.
3258
+ */
3259
+ declare class TransformRegistry extends Registry<TransformType, TransformStrategy> {
3260
+ constructor();
3261
+ }
3262
+
3263
+ /**
3264
+ * Strategy interface for compiling a specific transform type.
3265
+ */
3266
+ declare interface TransformStrategy {
3267
+ readonly transformType: TransformType;
3268
+ apply: (data: Dataset, transform: TransformInput) => Dataset;
3269
+ }
3270
+
3271
+ declare type TransformType = TransformInput['transformType'];
3272
+
3273
+ declare type TrendlineType = 'linear' | 'loess' | 'exponential' | 'logarithmic' | 'quadratic' | 'power' | 'polynomial';
3274
+
3275
+ /**
3276
+ * Result of an undo/redo operation.
3277
+ */
3278
+ declare interface UndoRedoResult {
3279
+ /** The new spec after the operation */
3280
+ spec: Spec;
3281
+ /** The original command that was undone/redone */
3282
+ command: Command;
3283
+ }
3284
+
3285
+ /**
3286
+ * Shared validation types used across compiler stages.
3287
+ *
3288
+ * Each validation stage (e.g. {@link LayerValidator}, the pre-pass in {@link ScaleCompiler}) collects
3289
+ * {@link ValidationIssue}s and throws a single {@link SpecValidationError} at the end of its stage.
3290
+ */
3291
+ declare type ValidationCode = 'UNKNOWN_VARIABLE' | 'INCOMPATIBLE_TYPE' | 'MISSING_AESTHETIC';
3292
+
3293
+ declare interface ValidationIssue {
3294
+ code: ValidationCode;
3295
+ message: string;
3296
+ layerId?: string;
3297
+ aesthetic?: string;
3298
+ }
3299
+
3300
+ declare type ValueFormat = TemporalValueFormat | NumericValueFormat | CurrencyValueFormat | CategoricalValueFormat;
3301
+
3302
+ /**
3303
+ * Constant mapping - a literal value applied to every observation.
3304
+ * Analogous to Vega-Lite's `{datum: X}` / ggplot2's `aes(color = "literal")`.
3305
+ */
3306
+ declare interface ValueMapping {
3307
+ value: DataValue;
3308
+ }
3309
+
3310
+ /** A column of a variable in the dataset. */
3311
+ declare type Variable = {
3312
+ type: DataType;
3313
+ values: DataValue[];
3314
+ };
3315
+
3316
+ /** A map of variable names to their type and values. */
3317
+ declare type VariableMap = Record<VariableName, Variable>;
3318
+
3319
+ /**
3320
+ * Variable mapping - references a column in the data
3321
+ */
3322
+ declare interface VariableMapping {
3323
+ variable: string;
3324
+ }
3325
+
3326
+ declare type VariableMetadata = Record<VariableName, {
3327
+ type: DataType;
3328
+ }>;
3329
+
3330
+ /** A type alias for variable names. */
3331
+ export declare type VariableName = string;
3332
+
3333
+ export declare const VISUAL_VARIABLES: {
3334
+ readonly color: string;
3335
+ readonly size: string;
3336
+ readonly alpha: string;
3337
+ readonly strokeWidth: string;
3338
+ };
3339
+
3340
+ /**
3341
+ * Applies visual scales to raw data values, producing render-ready variables (e.g. `color`, `size`, `alpha`,
3342
+ * `strokeWidth`) on each layer's dataset.
3343
+ */
3344
+ declare class VisualMapperCompiler {
3345
+ compile(input: VisualMapperCompilerInput): CompiledLayer[];
3346
+ private compileLayer;
3347
+ }
3348
+
3349
+ declare interface VisualMapperCompilerInput {
3350
+ layers: CompiledLayer[];
3351
+ scales: CompiledScales;
3352
+ }
3353
+
3354
+ /**
3355
+ * X-axis configuration (after defaults applied)
3356
+ */
3357
+ declare interface XAxisConfig {
3358
+ /**
3359
+ * Whether the x axis is visible.
3360
+ * @default true
3361
+ */
3362
+ isVisible: boolean;
3363
+ /**
3364
+ * Axis title text. null means explicitly no label.
3365
+ * @default null
3366
+ */
3367
+ label: string | null;
3368
+ /**
3369
+ * Position of the y axis.
3370
+ * @default 'bottom'
3371
+ */
3372
+ position: AxisPosition;
3373
+ /** Grid lines for this axis */
3374
+ grid: AxisGridConfig;
3375
+ /** Tick marks for this axis */
3376
+ ticks: AxisTicksConfig;
3377
+ }
3378
+
3379
+ /** Minimal x/y shape — most runtime records satisfy this (HoverCursor, HoverHit, etc.). */
3380
+ export declare interface XYPoint {
3381
+ x: number;
3382
+ y: number;
3383
+ }
3384
+
3385
+ /**
3386
+ * Y-axis configuration (after defaults applied)
3387
+ */
3388
+ declare interface YAxisConfig {
3389
+ /**
3390
+ * Whether the y axis is visible.
3391
+ * @default true
3392
+ */
3393
+ isVisible: boolean;
3394
+ /**
3395
+ * Axis title text. null means explicitly no label.
3396
+ * @default null
3397
+ */
3398
+ label: string | null;
3399
+ /**
3400
+ * Position of the y axis.
3401
+ * @default 'right'
3402
+ */
3403
+ position: AxisPosition;
3404
+ /** Grid lines for this axis */
3405
+ grid: AxisGridConfig;
3406
+ /** Tick marks for this axis */
3407
+ ticks: AxisTicksConfig;
3408
+ }
3409
+
3410
+ /**
3411
+ * Which Y axis a layer binds to.
3412
+ */
3413
+ export declare type YScaleType = 'primary' | 'secondary';
3414
+
3415
+ export { }