@opendata-ai/openchart-engine 9.0.0 → 9.2.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.
package/dist/index.d.ts CHANGED
@@ -1,45 +1,50 @@
1
1
  import * as _opendata_ai_openchart_core from '@opendata-ai/openchart-core';
2
- import { AnimationEase, LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, LegendEntry, CompileOptions, BarListLayout, ChartLayout, GeoMapLayout, LayerSpec, SankeyLayout, CompileTableOptions, TableLayout, TileMapLayout, DataRow, BarListEncoding, BarListSpec, ThemeConfig, AnimationSpec, GeoMapGeo, GeoMapProjection, GeoMapEncoding, LegendConfig, GeoMapPointsLayer, FieldMetadata, GeoCallout, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, TileMapEncoding, TileMapPalette, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, TableDensity, SortState, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, GraphAnimationSpec, GraphInteractionConfig, ResolvedLabel, Rect, ResolvedAnnotation, ChartSpec, ResolvedAnimationPhase, ResolvedAnimation, Point, EncodingChannel, ScaleType, FieldFormatContext, LayoutStrategy, VizSpec, MeasureTextFn, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform, ElementRef, TextAnnotation, DesignDiagnostic, DatasetBinding, ReaderSelection, ObservationIdentity, SpecPatch, ReaderPanelScope, ReaderSlice, ReaderSliceIndexOptions, ReaderComparisonOperand, ReaderComparisonResult, ReaderDomainValue, ReaderSliceSelection, CompositionRecommendation, DesignQuestion, GeoColorKeyLayout, GeoLabelsInput, GeoLabelAffine, GeoLabelOverlay, GeoReaderObservation, GeoMapSpec, TooltipField } from '@opendata-ai/openchart-core';
3
- export { BarListLayout, BarListSpec, ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GeoMapLayout, GeoMapSpec, GraphLayout, GraphSpec, LayerSpec, SankeyLayout, SankeySpec, TableLayout, TableSpec, TileMapLayout, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
2
+ import { AnimationEase, SpringConfig, LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, LegendEntry, DataRow, BarListEncoding, BarListSpec, ThemeConfig, AnimationSpec, GeoMapGeo, GeoMapProjection, GeoMapEncoding, LegendConfig, GeoMapPointsLayer, FieldMetadata, GeoCallout, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, TileMapEncoding, TileMapPalette, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, TableDensity, SortState, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, GraphAnimationSpec, GraphInteractionConfig, RaceSpec, RaceMarkDef, RaceEncoding, EncodingChannel, RacePlayback, RaceFrame, RaceLayout, RaceGeometry, CompileOptions, CompileWarning, BarListLayout, ChartLayout, GeoMapLayout, LayerSpec, SankeyLayout, CompileTableOptions, TableLayout, TileMapLayout, ResolvedLabel, Rect, ResolvedAnnotation, ScaleType, FieldFormatContext, ChartSpec, PlaybackPeriodPosition, PlaybackTimingConfig, LayoutStrategy, Mark, Point, TextMarkLayout, ResolvedAnimationPhase, ResolvedAnimation, VizSpec, MeasureTextFn, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform, ElementRef, TextAnnotation, DesignDiagnostic, DatasetBinding, ReaderSelection, ObservationIdentity, SpecPatch, ReaderPanelScope, ReaderSlice, ReaderSliceIndexOptions, ReaderComparisonOperand, ReaderComparisonResult, ReaderDomainValue, ReaderSliceSelection, CompositionRecommendation, DesignQuestion, GeoColorKeyLayout, GeoLabelsInput, GeoLabelAffine, GeoLabelOverlay, GeoReaderObservation, GeoMapSpec, TooltipField } from '@opendata-ai/openchart-core';
3
+ export { BarListLayout, BarListSpec, ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GeoMapLayout, GeoMapSpec, GraphLayout, GraphSpec, LayerSpec, MAX_TOTAL_STAGGER_MS, SankeyLayout, SankeySpec, TableLayout, TableSpec, TileMapLayout, TileMapSpec, VizSpec, clampStaggerDelay } from '@opendata-ai/openchart-core';
4
4
  import { Series } from 'd3-shape';
5
5
  import { ScaleLinear, ScaleTime, ScaleLogarithmic, ScalePower, ScaleSymLog, ScaleBand, ScalePoint, ScaleOrdinal, ScaleQuantile, ScaleQuantize, ScaleThreshold } from 'd3-scale';
6
6
 
7
7
  /**
8
8
  * Graph animation resolver.
9
9
  *
10
- * Modeled on `compiler/animation.ts` but DEFAULT-ON (the deliberate chart/graph
11
- * divergence): graphs already move on load, so choreography is the default and
12
- * must be opted out of, not into.
10
+ * Modeled on `compiler/animation.ts`. Like every visualization type, graphs
11
+ * animate by default.
13
12
  *
14
- * - `undefined` (omitted) -> full defaults
13
+ * - `undefined` (omitted) or `true` -> full defaults
15
14
  * - `false` -> undefined (no choreography; note `layout.warmup` still applies,
16
15
  * resolved independently into SimulationConfig)
17
16
  * - object -> per-phase resolution; a per-phase `false` -> that phase is `null`
18
17
  *
18
+ * A phase with `spring` lasts `springDuration(spring)`. The enter `stagger` is
19
+ * on/off only: graphs order their reveal by layout, so the deprecated object
20
+ * form counts as `true`.
21
+ *
19
22
  * `reheatAlpha` for the update impulse and the entrance `cameraFit` toggle are
20
23
  * internal vanilla constants, not spec surface. Warmup is NOT part of this block
21
24
  * (it lives in `layout`); `fitOnLoad` is a mount option.
22
25
  */
23
26
 
27
+ /** A resolved graph phase. `spring` is present only when authored; duration is then its settling time. */
28
+ interface ResolvedGraphPhase {
29
+ duration: number;
30
+ ease: AnimationEase;
31
+ spring?: SpringConfig;
32
+ }
24
33
  /** Fully resolved graph animation config consumed by the vanilla adapter. */
25
34
  interface ResolvedGraphAnimation {
26
- /** Entrance reveal, or null if disabled. `cameraFit` flies the camera to the fit on load. */
27
- enter: {
28
- duration: number;
29
- ease: AnimationEase;
35
+ /**
36
+ * Entrance reveal, or null if disabled. `cameraFit` flies the camera to the
37
+ * fit on load. `trigger` is when it starts (default 'visible').
38
+ */
39
+ enter: (ResolvedGraphPhase & {
30
40
  stagger: boolean;
31
41
  cameraFit: boolean;
32
- } | null;
42
+ trigger: 'visible' | 'mount';
43
+ }) | null;
33
44
  /** Data-update enter-fade for newly added marks, or null. */
34
- update: {
35
- duration: number;
36
- ease: AnimationEase;
37
- } | null;
45
+ update: ResolvedGraphPhase | null;
38
46
  /** Ghost fade-out for removed marks, or null. */
39
- exit: {
40
- duration: number;
41
- ease: AnimationEase;
42
- } | null;
47
+ exit: ResolvedGraphPhase | null;
43
48
  /** Camera flight easing, or null. `'auto'` derives duration from zoom distance. */
44
49
  camera: {
45
50
  duration: number | 'auto';
@@ -228,111 +233,24 @@ interface GraphCompilation {
228
233
  declare const MAX_3D_NODES = 2000;
229
234
 
230
235
  /**
231
- * Main compile API: the public entry points for the engine.
232
- *
233
- * Pipeline for charts (see ./compile/chart.ts for the phases):
234
- * validate spec -> normalize -> resolve theme -> dark mode adapt ->
235
- * filter data -> resolveLayoutPlan (measure real labels) ->
236
- * compute dimensions (with plan) -> placeLegend ->
237
- * compute scales -> compute axes (with pinned ticks) -> compute gridlines ->
238
- * get chart renderer -> compute marks -> compute a11y -> return ChartLayout
239
- *
240
- * Table compiler handles full data pipeline (sort, search, pagination, visual enhancements).
236
+ * The error type for data that cannot form a playback matrix. Spec problems go through
237
+ * validation instead; this covers what only the rows reveal.
241
238
  */
239
+ /** Codes for data that cannot form a playback matrix. */
240
+ type PlaybackDataErrorCode = 'DUPLICATE_KEY_PERIOD' | 'TOO_FEW_PERIODS' | 'NO_VALUES';
241
+ /** Data that cannot form a playback timeline. The race's `RaceDataError` extends it. */
242
+ declare class PlaybackDataError extends Error {
243
+ readonly code: PlaybackDataErrorCode;
244
+ readonly name: string;
245
+ constructor(code: PlaybackDataErrorCode, message: string, options?: ErrorOptions);
246
+ }
242
247
 
243
- /**
244
- * Compile a chart spec into a ChartLayout.
245
- *
246
- * This is the main engine entry point. Takes a raw spec (any shape,
247
- * validated at runtime) and compile options, produces a fully resolved
248
- * ChartLayout with positions, colors, and marks ready for rendering.
249
- *
250
- * @param spec - Raw chart spec (validated and normalized internally).
251
- * @param optionsInput - Compile options (width, height, theme, darkMode).
252
- * Top-level spec width/height, when present, override the option values.
253
- * @returns ChartLayout with all computed positions.
254
- * @throws Error if spec is invalid or not a chart type.
255
- */
256
- declare function compileChart(spec: unknown, optionsInput: CompileOptions): ChartLayout;
257
- declare function compileLayer(spec: LayerSpec, options: CompileOptions): ChartLayout;
258
- /**
259
- * Compile a table spec into a TableLayout.
260
- *
261
- * Validates and normalizes the spec, resolves the theme, then delegates
262
- * to compileTableLayout for the full pipeline: column resolution, search,
263
- * sort, pagination, cell formatting, and visual enhancements.
264
- *
265
- * @param spec - Raw table spec.
266
- * @param options - Compile options with sort, search, pagination state.
267
- * @returns Fully resolved TableLayout.
268
- */
269
- declare function compileTable(spec: unknown, options: CompileTableOptions): TableLayout;
270
- /**
271
- * Compile a graph spec into a GraphCompilation.
272
- *
273
- * The graph pipeline resolves visual properties (size, color, stroke) for
274
- * nodes and edges, assigns communities, and builds legend/tooltip/a11y data.
275
- * Unlike charts, the output does NOT include x/y positions since the force
276
- * simulation in the adapter handles layout at runtime.
277
- *
278
- * @param spec - Raw graph spec (validated and normalized internally).
279
- * @param options - Compile options (width, height, theme, darkMode).
280
- * @returns GraphCompilation with resolved visual properties and simulation config.
281
- * @throws Error if spec is invalid or not a graph type.
282
- */
283
- declare function compileGraph(spec: unknown, options: CompileOptions): GraphCompilation;
284
- /**
285
- * Compile a sankey spec into a SankeyLayout.
286
- *
287
- * Takes a raw sankey spec, validates, normalizes, resolves theme and chrome,
288
- * runs the d3-sankey layout algorithm, builds node/link marks with colors and
289
- * labels, and returns a SankeyLayout ready for rendering.
290
- *
291
- * @param spec - Raw sankey spec (validated and normalized internally).
292
- * @param options - Compile options (width, height, theme, darkMode).
293
- * @returns SankeyLayout with computed positions and visual properties.
294
- * @throws Error if spec is invalid or not a sankey type.
295
- */
296
- declare function compileSankey(spec: unknown, options: CompileOptions): SankeyLayout;
297
- /**
298
- * Compile a tilemap spec into a TileMapLayout.
299
- *
300
- * Takes a raw tilemap spec, validates, normalizes, resolves theme and chrome,
301
- * computes tile positions, builds tile marks with colors and labels, and
302
- * returns a TileMapLayout ready for rendering.
303
- *
304
- * @param spec - Raw tilemap spec (validated and normalized internally).
305
- * @param options - Compile options (width, height, theme, darkMode).
306
- * @returns TileMapLayout with computed positions and visual properties.
307
- * @throws Error if spec is invalid or not a tilemap type.
308
- */
309
- declare function compileTileMap(spec: unknown, options: CompileOptions): TileMapLayout;
310
- /**
311
- * Compile a map spec into a GeoMapLayout.
312
- *
313
- * Takes a raw map spec, validates, normalizes, resolves theme and chrome,
314
- * projects geo features, joins data, builds feature marks with color fills,
315
- * and returns a GeoMapLayout ready for rendering.
316
- *
317
- * @param spec - Raw map spec (validated and normalized internally).
318
- * @param options - Compile options (width, height, theme, darkMode).
319
- * @returns GeoMapLayout with computed positions and visual properties.
320
- * @throws Error if spec is invalid or not a map type.
321
- */
322
- declare function compileGeoMap(spec: unknown, options: CompileOptions): GeoMapLayout;
323
- /**
324
- * Compile a barlist spec into a BarListLayout.
325
- *
326
- * Takes a raw barlist spec, validates, normalizes, resolves theme and chrome,
327
- * computes row layout with proportional bars, builds tooltips, and returns
328
- * a BarListLayout ready for rendering.
329
- *
330
- * @param spec - Raw barlist spec (validated and normalized internally).
331
- * @param options - Compile options (width, height, theme, darkMode).
332
- * @returns BarListLayout with computed positions and visual properties.
333
- * @throws Error if spec is invalid or not a barlist type.
334
- */
335
- declare function compileBarList(spec: unknown, options: CompileOptions): BarListLayout;
248
+ /** The race's name for playback data errors, so race callers keep their `instanceof` checks. */
249
+
250
+ /** Data that cannot form a race timeline. A `PlaybackDataError` with the race's name. */
251
+ declare class RaceDataError extends PlaybackDataError {
252
+ readonly name: string;
253
+ }
336
254
 
337
255
  /** Shared area pivot/offset semantics for domain measurement and mark geometry. */
338
256
 
@@ -612,7 +530,7 @@ interface NormalizedGraphSpec {
612
530
  dimensions?: 2 | 3;
613
531
  }
614
532
  /** Discriminated union of all normalized spec types. */
615
- type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedGeoMapSpec | NormalizedBarListSpec;
533
+ type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedGeoMapSpec | NormalizedBarListSpec | NormalizedRaceSpec;
616
534
  /** Machine-readable error code for programmatic handling. */
617
535
  type ValidationErrorCode = 'MISSING_FIELD' | 'INVALID_TYPE' | 'INVALID_VALUE' | 'ENCODING_MISMATCH' | 'DATA_FIELD_MISSING' | 'EMPTY_DATA';
618
536
  /** A single validation error with context. */
@@ -646,6 +564,263 @@ interface CompileResult {
646
564
  warnings: string[];
647
565
  }
648
566
 
567
+ interface NormalizedRaceSpec extends Omit<RaceSpec, 'mark' | 'encoding' | 'race' | 'chrome' | 'theme' | 'watermark'> {
568
+ mark: RaceMarkDef;
569
+ encoding: RaceEncoding & {
570
+ time: EncodingChannel;
571
+ key: EncodingChannel;
572
+ value: EncodingChannel;
573
+ };
574
+ race: ResolvedRaceOptions;
575
+ chrome: NormalizedChrome;
576
+ theme: ThemeConfig;
577
+ watermark: boolean;
578
+ }
579
+ interface ResolvedRaceOptions {
580
+ top: number;
581
+ duration?: number;
582
+ step?: number;
583
+ /** Set when `step` came from the top-level `playback` block, so errors name that block. */
584
+ stepBlock?: 'playback';
585
+ swap: number;
586
+ rescale: 'frame' | 'fixed' | {
587
+ min: number;
588
+ };
589
+ gaps: 'interpolate' | 'hold' | 'drop';
590
+ holdEnd: number;
591
+ loop: boolean;
592
+ autoplay: 'visible' | boolean;
593
+ controls: boolean;
594
+ period: false | {
595
+ format?: string;
596
+ };
597
+ summary: 'sum' | false;
598
+ }
599
+ interface RaceMatrix {
600
+ /** Sorted ascending. Dates become ISO strings. */
601
+ periods: Array<{
602
+ value: string | number;
603
+ sortKey: number;
604
+ }>;
605
+ /** Sorted by localeCompare with locale 'en'. Index order is the final tie-break. */
606
+ keys: string[];
607
+ /** Last non-null label value per key, or the key itself. */
608
+ labels: string[];
609
+ /** Last non-null color field value per key. Null when color is not a field. */
610
+ colorValues: Array<string | null>;
611
+ /** One array per key, with one value per period. NaN represents absence. */
612
+ values: Float64Array[];
613
+ }
614
+ interface RaceSampleItem {
615
+ keyIndex: number;
616
+ value: number;
617
+ rank: number;
618
+ rankPos: number;
619
+ opacity: number;
620
+ change: number;
621
+ }
622
+ interface RaceSample {
623
+ t: number;
624
+ periodIndex: number;
625
+ items: RaceSampleItem[];
626
+ domainMin: number;
627
+ domainMax: number;
628
+ }
629
+ interface RaceTimeline {
630
+ readonly periodCount: number;
631
+ readonly keyCount: number;
632
+ readonly top: number;
633
+ /** Number of rank samples per period interval. */
634
+ readonly samplesPerPeriod: number;
635
+ /** NaN when absent. */
636
+ valueAt(keyIndex: number, t: number): number;
637
+ /** Smoothed rank in [0, top]. */
638
+ rankPos(keyIndex: number, t: number): number;
639
+ /** Present key indices in exact rank order. */
640
+ ranked(t: number): number[];
641
+ /** Zero-based rank among present keys. Infinity when absent. */
642
+ exactRank(keyIndex: number, t: number): number;
643
+ /** Cached exact rank at an integer period index. Infinity when absent. */
644
+ periodRank(keyIndex: number, period: number): number;
645
+ /** Exact and smoothed ranks on the sample grid. A missing exact rank equals keyCount. */
646
+ rankSamples(keyIndex: number): {
647
+ exact: Readonly<Float32Array>;
648
+ smoothed: Readonly<Float32Array>;
649
+ };
650
+ /** Items with rankPos < top, sorted by rankPos. */
651
+ sample(t: number): RaceSample;
652
+ }
653
+ interface RaceColorAssignment {
654
+ slotsFor(paletteSize: number): readonly (number | string)[];
655
+ /** Assignments already used by a spec or layout, available to carry across updates. */
656
+ readonly byPaletteSize: ReadonlyMap<number, readonly (number | string)[]>;
657
+ }
658
+ interface RaceModel {
659
+ spec: NormalizedRaceSpec;
660
+ /** Authored watermark setting, before normalization supplies a default. */
661
+ specWatermark?: boolean;
662
+ matrix: RaceMatrix;
663
+ timeline: RaceTimeline;
664
+ colorAssignment: RaceColorAssignment;
665
+ /** Spec-theme light colors for standalone frames. On-screen geometry uses layout.colors. */
666
+ frameColors: string[];
667
+ periodLabels: string[];
668
+ formatValue: (value: number) => string;
669
+ playback: RacePlayback;
670
+ warnings: string[];
671
+ }
672
+
673
+ /**
674
+ * Return a standalone frame with the prepared spec-theme colors and full labels.
675
+ * Finite times outside the race clamp to its endpoints.
676
+ * @throws {RangeError} The frame time is not finite.
677
+ */
678
+ declare function raceFrameAt(model: RaceModel, t: number): RaceFrame;
679
+ /**
680
+ * Build on-screen geometry with `layout.colors` and fitted labels.
681
+ * Finite times outside the race clamp to its endpoints.
682
+ * @throws {RangeError} The frame time is not finite.
683
+ * @throws {Error} The layout mark is unregistered.
684
+ */
685
+ declare function raceGeometryAt(model: RaceModel, layout: RaceLayout, t: number): RaceGeometry;
686
+
687
+ /**
688
+ * Resolve the race layout for the requested size and theme. An explicit mark overrides the spec's.
689
+ * @throws {Error} The selected mark is unregistered.
690
+ */
691
+ declare function layoutRace(model: RaceModel, options: CompileOptions & {
692
+ mark?: RaceMarkDef;
693
+ }): RaceLayout;
694
+
695
+ /**
696
+ * Validate and prepare the size-independent race model.
697
+ * @throws {Error} Aggregated spec validation errors or a valid non-race spec.
698
+ * @throws {RaceDataError} Duplicate rows, too few periods, or no finite values.
699
+ * @throws {RangeError} The step multiplied by the period intervals overflows.
700
+ */
701
+ declare function prepareRace(spec: unknown, options: {
702
+ onWarn?: (w: CompileWarning) => void;
703
+ previousModel?: RaceModel;
704
+ }): RaceModel;
705
+
706
+ /**
707
+ * Main compile API: the public entry points for the engine.
708
+ *
709
+ * Pipeline for charts (see ./compile/chart.ts for the phases):
710
+ * validate spec -> normalize -> resolve theme -> dark mode adapt ->
711
+ * filter data -> resolveLayoutPlan (measure real labels) ->
712
+ * compute dimensions (with plan) -> placeLegend ->
713
+ * compute scales -> compute axes (with pinned ticks) -> compute gridlines ->
714
+ * get chart renderer -> compute marks -> compute a11y -> return ChartLayout
715
+ *
716
+ * Table compiler handles full data pipeline (sort, search, pagination, visual enhancements).
717
+ */
718
+
719
+ /**
720
+ * Compile a chart spec into a ChartLayout.
721
+ *
722
+ * This is the main engine entry point. Takes a raw spec (any shape,
723
+ * validated at runtime) and compile options, produces a fully resolved
724
+ * ChartLayout with positions, colors, and marks ready for rendering.
725
+ *
726
+ * @param spec - Raw chart spec (validated and normalized internally).
727
+ * @param optionsInput - Compile options (width, height, theme, darkMode).
728
+ * Top-level spec width/height, when present, override the option values.
729
+ * @returns ChartLayout with all computed positions.
730
+ * @throws Error if spec is invalid or not a chart type.
731
+ */
732
+ declare function compileChart(spec: unknown, optionsInput: CompileOptions): ChartLayout;
733
+ declare function compileLayer(spec: LayerSpec, options: CompileOptions): ChartLayout;
734
+ /**
735
+ * Compile a table spec into a TableLayout.
736
+ *
737
+ * Validates and normalizes the spec, resolves the theme, then delegates
738
+ * to compileTableLayout for the full pipeline: column resolution, search,
739
+ * sort, pagination, cell formatting, and visual enhancements.
740
+ *
741
+ * @param spec - Raw table spec.
742
+ * @param options - Compile options with sort, search, pagination state.
743
+ * @returns Fully resolved TableLayout.
744
+ */
745
+ declare function compileTable(spec: unknown, options: CompileTableOptions): TableLayout;
746
+ /**
747
+ * Compile a graph spec into a GraphCompilation.
748
+ *
749
+ * The graph pipeline resolves visual properties (size, color, stroke) for
750
+ * nodes and edges, assigns communities, and builds legend/tooltip/a11y data.
751
+ * Unlike charts, the output does NOT include x/y positions since the force
752
+ * simulation in the adapter handles layout at runtime.
753
+ *
754
+ * @param spec - Raw graph spec (validated and normalized internally).
755
+ * @param options - Compile options (width, height, theme, darkMode).
756
+ * @returns GraphCompilation with resolved visual properties and simulation config.
757
+ * @throws Error if spec is invalid or not a graph type.
758
+ */
759
+ declare function compileGraph(spec: unknown, options: CompileOptions): GraphCompilation;
760
+ /**
761
+ * Compile a sankey spec into a SankeyLayout.
762
+ *
763
+ * Takes a raw sankey spec, validates, normalizes, resolves theme and chrome,
764
+ * runs the d3-sankey layout algorithm, builds node/link marks with colors and
765
+ * labels, and returns a SankeyLayout ready for rendering.
766
+ *
767
+ * @param spec - Raw sankey spec (validated and normalized internally).
768
+ * @param options - Compile options (width, height, theme, darkMode).
769
+ * @returns SankeyLayout with computed positions and visual properties.
770
+ * @throws Error if spec is invalid or not a sankey type.
771
+ */
772
+ declare function compileSankey(spec: unknown, options: CompileOptions): SankeyLayout;
773
+ /**
774
+ * Compile a tilemap spec into a TileMapLayout.
775
+ *
776
+ * Takes a raw tilemap spec, validates, normalizes, resolves theme and chrome,
777
+ * computes tile positions, builds tile marks with colors and labels, and
778
+ * returns a TileMapLayout ready for rendering.
779
+ *
780
+ * @param spec - Raw tilemap spec (validated and normalized internally).
781
+ * @param options - Compile options (width, height, theme, darkMode).
782
+ * @returns TileMapLayout with computed positions and visual properties.
783
+ * @throws Error if spec is invalid or not a tilemap type.
784
+ */
785
+ declare function compileTileMap(spec: unknown, options: CompileOptions): TileMapLayout;
786
+ /**
787
+ * Compile a map spec into a GeoMapLayout.
788
+ *
789
+ * Takes a raw map spec, validates, normalizes, resolves theme and chrome,
790
+ * projects geo features, joins data, builds feature marks with color fills,
791
+ * and returns a GeoMapLayout ready for rendering.
792
+ *
793
+ * @param spec - Raw map spec (validated and normalized internally).
794
+ * @param options - Compile options (width, height, theme, darkMode).
795
+ * @returns GeoMapLayout with computed positions and visual properties.
796
+ * @throws Error if spec is invalid or not a map type.
797
+ */
798
+ declare function compileGeoMap(spec: unknown, options: CompileOptions): GeoMapLayout;
799
+ /**
800
+ * Compile a barlist spec into a BarListLayout.
801
+ *
802
+ * Takes a raw barlist spec, validates, normalizes, resolves theme and chrome,
803
+ * computes row layout with proportional bars, builds tooltips, and returns
804
+ * a BarListLayout ready for rendering.
805
+ *
806
+ * @param spec - Raw barlist spec (validated and normalized internally).
807
+ * @param options - Compile options (width, height, theme, darkMode).
808
+ * @returns BarListLayout with computed positions and visual properties.
809
+ * @throws Error if spec is invalid or not a barlist type.
810
+ */
811
+ declare function compileBarList(spec: unknown, options: CompileOptions): BarListLayout;
812
+
813
+ type BarLabelPlacement = 'adaptive' | 'inside' | 'outside' | 'column' | 'suppress';
814
+ interface BarLabelPlan {
815
+ placement: BarLabelPlacement;
816
+ reserveLeft: number;
817
+ reserveRight: number;
818
+ reserveTop: number;
819
+ reserveBottom: number;
820
+ columnWidth: number;
821
+ fallback?: 'column-to-outside' | 'labels-suppressed';
822
+ }
823
+
649
824
  /** Default font size for annotation labels. */
650
825
  declare const DEFAULT_ANNOTATION_FONT_SIZE = 13;
651
826
  /** Default line height multiplier for annotation text. */
@@ -773,15 +948,48 @@ interface ReferenceLanes {
773
948
  topOverflow?: boolean;
774
949
  }
775
950
 
776
- type BarLabelPlacement = 'adaptive' | 'inside' | 'outside' | 'column' | 'suppress';
777
- interface BarLabelPlan {
778
- placement: BarLabelPlacement;
779
- reserveLeft: number;
780
- reserveRight: number;
781
- reserveTop: number;
782
- reserveBottom: number;
783
- columnWidth: number;
784
- fallback?: 'column-to-outside' | 'labels-suppressed';
951
+ type TemporalInterval = NonNullable<EncodingChannel['interval']>;
952
+ interface ResolvedTemporalInterval {
953
+ value: TemporalInterval;
954
+ offset(date: Date): Date;
955
+ warnings: string[];
956
+ }
957
+
958
+ /** Continuous D3 scales (linear, time, log, pow, sqrt, symlog) that support .ticks() and .nice(). */
959
+ type D3ContinuousScale = ScaleLinear<number, number> | ScaleTime<number, number> | ScaleLogarithmic<number, number> | ScalePower<number, number> | ScaleSymLog<number, number>;
960
+ /** Discretizing D3 scales (quantile, quantize, threshold). */
961
+ type D3DiscretizingScale = ScaleQuantile<number> | ScaleQuantize<number> | ScaleThreshold<number, number>;
962
+ /** Categorical D3 scales (band, point, ordinal) that support .domain() as string[]. */
963
+ type D3CategoricalScale = ScaleBand<string> | ScalePoint<string> | ScaleOrdinal<string, string>;
964
+ /** Union of all D3 scale types used by the engine. */
965
+ type D3Scale = D3ContinuousScale | D3CategoricalScale | D3DiscretizingScale;
966
+ /** All resolved scale type identifiers. */
967
+ type ResolvedScaleType = ScaleType | 'sequential';
968
+ /**
969
+ * A resolved scale wrapping a d3 scale with type metadata.
970
+ * We need to carry the scale type around so axes and marks know
971
+ * how to interpret the domain/range. Consumers use the `type` discriminant
972
+ * to determine which D3 methods are available on the scale.
973
+ */
974
+ interface ResolvedScale {
975
+ /** The d3 scale function. Maps domain value -> pixel position or color. */
976
+ scale: D3Scale;
977
+ /** The scale type for downstream use. */
978
+ type: ResolvedScaleType;
979
+ /** The encoding channel this scale was derived from. */
980
+ channel: EncodingChannel;
981
+ /** Per-field formatting context (extent, allIntegers) from the ORIGINAL data. */
982
+ formatContext?: FieldFormatContext;
983
+ temporalInterval?: ResolvedTemporalInterval;
984
+ }
985
+ /** All resolved scales for a chart. */
986
+ interface ResolvedScales {
987
+ x?: ResolvedScale;
988
+ y?: ResolvedScale;
989
+ color?: ResolvedScale;
990
+ size?: ResolvedScale;
991
+ /** Default color for single-series charts (first categorical palette color or markDef.fill gradient). */
992
+ defaultColor?: string | _opendata_ai_openchart_core.GradientDef;
785
993
  }
786
994
 
787
995
  /**
@@ -817,13 +1025,460 @@ declare function resolveLayerTheme(layerSpec: LayerSpec, primary?: ChartSpec): _
817
1025
  */
818
1026
  declare function buildEdgeTooltip(edge: CompiledGraphEdge): TooltipContent;
819
1027
 
1028
+ /**
1029
+ * Name labels for the points `playback.labels` lists. Each is its own text mark beside the
1030
+ * bubble and is always visible. A label keeps the side chosen for the whole run unless that
1031
+ * side would cover another name label in a frame (see `placeNameLabels`).
1032
+ */
1033
+
1034
+ /** Key prefix of every name label; the rest of the key is its point's key. */
1035
+ declare const PLAYBACK_LABEL_KEY_PREFIX = "oc-playback-label|";
1036
+ /** The name label's identity for the point keyed `pointKey`; frames match it by `data-key`. */
1037
+ declare function playbackLabelKey(pointKey: string): string;
1038
+ /** The point key a name label's key names, or null when `key` isn't a name label's. */
1039
+ declare function playbackLabelPointKey(key: string): string | null;
1040
+
1041
+ /**
1042
+ * Reading raw time values into periods and putting the distinct periods in playback order.
1043
+ */
1044
+
1045
+ /** How a time channel's values are read and ordered. */
1046
+ type PlaybackTimeType = 'temporal' | 'ordinal' | 'quantitative';
1047
+ /** One distinct period. Dates become ISO strings; `sortKey` orders the periods. */
1048
+ interface PlaybackPeriod {
1049
+ value: string | number;
1050
+ sortKey: number;
1051
+ }
1052
+ /** The parts of a time channel that period reading and ordering use. */
1053
+ interface PlaybackTimeEncoding {
1054
+ /** Field holding the period value. */
1055
+ field: string;
1056
+ /** Defaults to `temporal` where a caller omits it. */
1057
+ type?: PlaybackTimeType;
1058
+ /** Ordinal order: a sort array, `descending` (reverse first-seen order), or first-seen order. */
1059
+ sort?: EncodingChannel['sort'];
1060
+ /** Period label format. */
1061
+ format?: string;
1062
+ }
1063
+ /**
1064
+ * Read one raw period value. Temporal values sort by year number or epoch milliseconds
1065
+ * (ISO times without an offset read as UTC), quantitative values numerically, and ordinal
1066
+ * values get a placeholder sort key that `orderPeriods` replaces.
1067
+ * Returns undefined when the value can't be a period of that type.
1068
+ */
1069
+ declare function readPeriod(raw: unknown, type: PlaybackTimeType): PlaybackPeriod | undefined;
1070
+ /**
1071
+ * Sort periods in place and assign final sort keys. Quantitative periods sort numerically.
1072
+ * Temporal periods sort by year when all are numeric, or by epoch milliseconds when any is a
1073
+ * date. Ordinals follow a sort array, reverse first-seen order for `descending`, or first-seen
1074
+ * order, and get their index as the sort key.
1075
+ */
1076
+ declare function orderPeriods(periods: PlaybackPeriod[], time: Pick<PlaybackTimeEncoding, 'sort'> & {
1077
+ type: PlaybackTimeType;
1078
+ }): void;
1079
+
1080
+ /**
1081
+ * The playback matrix: long rows pivoted into keys x periods x channels, with the gap policy
1082
+ * applied, per-key static fields resolved, and data problems warned about or thrown.
1083
+ */
1084
+
1085
+ /** Interior gap policy. Leading and trailing gaps are never filled. */
1086
+ type PlaybackGaps = 'interpolate' | 'hold' | 'drop';
1087
+ /** One numeric channel the frames read, named by the caller. */
1088
+ interface PlaybackChannel {
1089
+ /** Name the matrix keys this channel's values under, e.g. `x`, `y`, `size`, `value`. */
1090
+ name: string;
1091
+ /** Data field holding the channel's numbers. */
1092
+ field: string;
1093
+ /** Log-scale channel: interpolate fills geometrically and values <= 0 are absent. */
1094
+ log?: boolean;
1095
+ }
1096
+ /** What to pivot and how strictly to check it. */
1097
+ interface PlaybackMatrixOptions {
1098
+ /** Identity field. Its stringified value carries a mark from one period to the next. */
1099
+ identity: string;
1100
+ /** Time channel. `type` defaults to `temporal`. */
1101
+ time: PlaybackTimeEncoding;
1102
+ /** Numeric channels, one Float64Array per key each. */
1103
+ channels: PlaybackChannel[];
1104
+ /** Per-key fields that take the last non-null value in time (color category, label, nominal tooltips). */
1105
+ staticFields?: string[];
1106
+ /**
1107
+ * Throw `TOO_FEW_PERIODS` below two periods and `NO_VALUES` when no channel has a finite
1108
+ * value. The race passes true; charts and maps leave it off and warn instead.
1109
+ */
1110
+ requireTwoPeriods?: boolean;
1111
+ /** Noun for the 500-key warning, e.g. `bars`. Defaults to `keys`. */
1112
+ noun?: string;
1113
+ /** Replaces the advice after "N distinct <noun> in '<identity>'" in the 500-key warning. */
1114
+ manyKeysAdvice?: string;
1115
+ }
1116
+ /** The pivoted rows, ready for frames to read. */
1117
+ interface PlaybackMatrix {
1118
+ /** Sorted by `orderPeriods`. */
1119
+ periods: PlaybackPeriod[];
1120
+ /** Sorted by localeCompare with locale 'en'. */
1121
+ keys: string[];
1122
+ /** Per channel name: one array per key with one value per period. NaN represents absence. */
1123
+ values: Record<string, Float64Array[]>;
1124
+ /** Per key, in key order: each static field's last non-null value, absent when always null. */
1125
+ statics: Array<Record<string, unknown>>;
1126
+ /** Per channel name: how many values <= 0 a log channel treated as absent. Zero elsewhere. */
1127
+ nonPositiveCounts: Record<string, number>;
1128
+ }
1129
+ /**
1130
+ * Pivot long rows into a keys x periods x channels matrix with the gap policy applied to
1131
+ * interior gaps of each channel (geometrically on log channels). Warns about skipped rows,
1132
+ * non-finite values, and more than 500 distinct keys.
1133
+ *
1134
+ * @throws {PlaybackDataError} DUPLICATE_KEY_PERIOD, naming the identity value and period.
1135
+ * @throws {PlaybackDataError} TOO_FEW_PERIODS and NO_VALUES, only with `requireTwoPeriods`.
1136
+ */
1137
+ declare function buildPlaybackMatrix(rows: DataRow[], options: PlaybackMatrixOptions, gaps: PlaybackGaps, warn: (message: string) => void): PlaybackMatrix;
1138
+
1139
+ /** Playback timing defaults shared by the race and the playback charts and maps. */
1140
+
1141
+ /** Playback timing with every default applied. */
1142
+ interface ResolvedPlayback {
1143
+ /** Total run length at 1×, excluding the end hold. */
1144
+ durationMs: number;
1145
+ holdEndMs: number;
1146
+ loop: boolean;
1147
+ autoplay: 'visible' | boolean;
1148
+ controls: boolean;
1149
+ gaps: PlaybackGaps;
1150
+ /** False hides the period label. `format` is set only when authored here. */
1151
+ period: false | {
1152
+ format?: string;
1153
+ position: PlaybackPeriodPosition;
1154
+ };
1155
+ }
1156
+ /**
1157
+ * Apply the shared playback defaults: holdEnd 1500, loop false, autoplay "visible",
1158
+ * controls true, gaps "interpolate", period { position: "auto" }. Duration is `step x
1159
+ * (periods - 1)` when step is set (0 with no periods), else the authored duration, else periods x 700 clamped
1160
+ * to 8000..90000 (the race's rule).
1161
+ *
1162
+ * @param blockName Names the block in the step overflow message. Defaults to `playback`.
1163
+ * @throws {RangeError} `<blockName>.step is too large for N periods. Use a shorter step.`
1164
+ */
1165
+ declare function resolvePlayback(block: PlaybackTimingConfig | undefined, periodCount: number, blockName?: 'race' | 'playback'): ResolvedPlayback;
1166
+
1167
+ /**
1168
+ * Shared types for chart playback: the frozen frame compiled once per size and theme, and
1169
+ * the per-frame values `compileChartPlayback` hands to the vanilla frame writer.
1170
+ */
1171
+
1172
+ /**
1173
+ * Everything that stays still for a playback run, from one compile of the envelope spec
1174
+ * (every present, gap-filled cell across all periods).
1175
+ */
1176
+ interface FrozenChartFrame {
1177
+ /** Chrome, axes, gridlines, legend, annotations. `marks` is always empty. */
1178
+ layout: ChartLayout;
1179
+ /** Scales from the envelope: all-period extents with nice rounding, every color category. */
1180
+ scales: ResolvedScales;
1181
+ /** Plot area the renderer draws into. */
1182
+ chartArea: Rect;
1183
+ /** Bar label plan sized for the widest label over all periods. */
1184
+ labelPlan?: BarLabelPlan;
1185
+ theme: ResolvedTheme;
1186
+ /** Scatter fill opacity chosen once from the largest per-period key count. */
1187
+ pointOpacity: number;
1188
+ /** One formatter per data field, resolved over all matrix values. */
1189
+ formatters: Record<string, (value: number) => string>;
1190
+ /** The envelope's normalized render spec; frames replace its `data` and keep the rest. */
1191
+ spec: NormalizedChartSpec;
1192
+ /** Responsive strategy the envelope compiled with; passed to the renderer each frame. */
1193
+ strategy: LayoutStrategy;
1194
+ }
1195
+ /** One base key's mark at a playhead. */
1196
+ interface FrameMark {
1197
+ /** Identity: `encoding.key` for points, `color|category` for bars. */
1198
+ key: string;
1199
+ /** The renderer's mark for this key's interpolated values, with `key` set. */
1200
+ mark: Mark;
1201
+ /** Fade multiplier, 0..1, applied on top of the mark's own opacity. */
1202
+ presence: number;
1203
+ }
1204
+ /** A key's values at the nearest period, for tooltips. */
1205
+ interface ObservedValues {
1206
+ /** Label of the nearest period, e.g. "1987". */
1207
+ periodLabel: string;
1208
+ /** True when that period's values were filled by the gap policy rather than observed. */
1209
+ filled: boolean;
1210
+ /** Field name to value formatted with the frozen formatter (nominal fields as-is). */
1211
+ values: Record<string, string>;
1212
+ }
1213
+ /** A key's past positions up to the playhead, in frozen pixel space. */
1214
+ interface TrailPath {
1215
+ key: string;
1216
+ /** Positions at each period up to and including floor(t) where the key has values. */
1217
+ points: Point[];
1218
+ /** Interpolated position at t. */
1219
+ head: Point;
1220
+ }
1221
+ /** A compiled playback chart: the frozen frame plus pure functions of the playhead `t`. */
1222
+ interface ChartPlayback {
1223
+ frame: FrozenChartFrame;
1224
+ /**
1225
+ * The layout the DOM is built from: the frozen layout with one mark per key in the union
1226
+ * of all periods, drawn at the final period, ordered by maximum size so small marks draw
1227
+ * on top. The period label comes before those marks and the name labels after them.
1228
+ */
1229
+ base: ChartLayout;
1230
+ /** Periods in playback order. */
1231
+ periods: PlaybackPeriod[];
1232
+ /** Display label per period. */
1233
+ periodLabels: string[];
1234
+ timing: ResolvedPlayback;
1235
+ /** Base keys in base mark order. */
1236
+ keys: string[];
1237
+ /** Advisory warnings found while building the playback (also sent to `onWarn`). */
1238
+ warnings: string[];
1239
+ /** One entry per base key, in base order. `t` is a continuous period index, clamped. */
1240
+ marksAt(t: number): FrameMark[];
1241
+ /**
1242
+ * Text marks drawn over the run at `t`: the period label (key `oc-playback-period`, absent
1243
+ * when `playback.period` is false) first, then one name label per `playback.labels` key
1244
+ * (key `oc-playback-label|<key>`) beside its point, with the point's presence.
1245
+ */
1246
+ overlaysAt(t: number): FrameMark[];
1247
+ /** Trails for the keys `playback.trails` names; empty when trails are off. */
1248
+ trailsAt(t: number): TrailPath[];
1249
+ /** The key's values at the period nearest `t`, or null when the key has none there. */
1250
+ observedAt(key: string, t: number): ObservedValues | null;
1251
+ /** One-line summary of the frame at `t` for the live region. */
1252
+ describe(t: number): string;
1253
+ }
1254
+
1255
+ /**
1256
+ * Chart playback compile: matrix, frozen frame, base layout and the per-frame functions for
1257
+ * point, circle and bar charts with `encoding.time`.
1258
+ */
1259
+
1260
+ /**
1261
+ * Validate a time spec, pivot its rows into the playback matrix, freeze the frame and
1262
+ * return the base layout plus `marksAt`, `overlaysAt`, `trailsAt`, `observedAt` and
1263
+ * `describe`. Frames call the registered chart renderer with the frozen scales, plot area
1264
+ * and label plan; no frame compiles. Warnings (RFC 2.7) go to `warnings` and to
1265
+ * `options.onWarn`.
1266
+ *
1267
+ * @throws The validation error `compileChart` throws for an invalid spec.
1268
+ * @throws {PlaybackDataError} DUPLICATE_KEY_PERIOD when two rows share a key and period.
1269
+ * @throws {RangeError} When `playback.step` overflows over the period count.
1270
+ */
1271
+ declare function compileChartPlayback(spec: ChartSpec, options: CompileOptions): ChartPlayback;
1272
+
1273
+ /**
1274
+ * Value interpolation between two periods of one key's series, linear or in log space.
1275
+ * Playback frames and gap filling read in-between values through these functions.
1276
+ */
1277
+ /**
1278
+ * Interpolate from a period to the next period or a specified endpoint across a gap.
1279
+ * A zero fraction reads the starting value. Interpolation needs two finite endpoints.
1280
+ */
1281
+ declare function interpolatePlaybackValue(values: Float64Array, periodIndex: number, fraction: number, nextPeriodIndex?: number): number;
1282
+ /**
1283
+ * Log-space variant of `interpolatePlaybackValue`: exp(lerp(log a, log b)), so the midpoint
1284
+ * of 1 and 100 is 10. Needs two finite, positive endpoints; otherwise returns NaN.
1285
+ */
1286
+ declare function interpolatePlaybackLogValue(values: Float64Array, periodIndex: number, fraction: number, nextPeriodIndex?: number): number;
1287
+
1288
+ /**
1289
+ * Shared types for map playback: what the geo and tile map compiles hand the playback layer
1290
+ * (the frozen scales a compile resolved), and what a compiled map playback hands the vanilla
1291
+ * frame writer (fills, points and overlays at a playhead).
1292
+ */
1293
+
1294
+ /**
1295
+ * A map layout that may carry playback overlays (the period label). Map layouts have no
1296
+ * generic mark list, so the overlays ride alongside and the map renderers draw them.
1297
+ */
1298
+ type PlaybackOverlayLayout = {
1299
+ /** Text marks drawn over the map at the compiled playhead, matched by `key`. */
1300
+ playbackOverlays?: TextMarkLayout[];
1301
+ };
1302
+ /** One feature's or tile's paint at a playhead, matched to the DOM by `data-key`. */
1303
+ interface MapFillFrame {
1304
+ /** Geo feature id, or tile state code. */
1305
+ key: string;
1306
+ fill: string;
1307
+ /** True when the feature has no value here and takes the no-data treatment. */
1308
+ noData: boolean;
1309
+ /** Class index for classed geo fills; absent for no data and on tile maps. */
1310
+ binIndex?: number;
1311
+ /** Tile maps only: the fill opacity the sequential scale encodes. */
1312
+ fillOpacity?: number;
1313
+ /** Tile maps only: the tile border. */
1314
+ stroke?: string;
1315
+ /** Tile maps only: the ink and text of the tile's code and value labels. */
1316
+ labels?: {
1317
+ codeFill: string;
1318
+ valueText: string;
1319
+ valueFill: string;
1320
+ };
1321
+ /**
1322
+ * Geo maps only, while a feature crossfades between its class and no data (RFC 3.5): the
1323
+ * class `fill` shows at `opacity` over the no-data treatment. `noDataFill` is the plain
1324
+ * no-data color, for maps that define no hatch.
1325
+ */
1326
+ fade?: {
1327
+ opacity: number;
1328
+ noDataFill: string;
1329
+ };
1330
+ /** The element's accessible label with the values of the period nearest the playhead. */
1331
+ ariaLabel: string;
1332
+ }
1333
+ /** One map point's size and paint at a playhead, matched by `data-point-key`. */
1334
+ interface MapPointFrame {
1335
+ key: string;
1336
+ r: number;
1337
+ fill: string;
1338
+ /** Fade multiplier, 0..1, on top of the point's own fill opacity. */
1339
+ presence: number;
1340
+ /** The point's accessible label at the period nearest the playhead. */
1341
+ ariaLabel: string;
1342
+ }
1343
+ /** A compiled map playback: the base layout plus pure functions of the playhead `t`. */
1344
+ interface MapPlayback<Layout> {
1345
+ /** The layout the DOM is built from, at the final period. */
1346
+ base: Layout & PlaybackOverlayLayout;
1347
+ /** Periods in playback order. */
1348
+ periods: PlaybackPeriod[];
1349
+ /** Display label per period. */
1350
+ periodLabels: string[];
1351
+ timing: ResolvedPlayback;
1352
+ /** Advisory warnings found while building the playback (also sent to `onWarn`). */
1353
+ warnings: string[];
1354
+ /** One entry per feature or tile with a value in any period. `t` is clamped. */
1355
+ fillsAt(t: number): MapFillFrame[];
1356
+ /** One entry per point key with a value in any period; empty without `points.time`. */
1357
+ pointsAt(t: number): MapPointFrame[];
1358
+ /** The period label at `t` (key `oc-playback-period`); empty when `period` is false. */
1359
+ overlaysAt(t: number): TextMarkLayout[];
1360
+ /**
1361
+ * Tooltip for a DOM key (feature id, tile state code or `point:<key>`) with the values of
1362
+ * the period nearest `t`, or undefined for keys the playback doesn't drive.
1363
+ */
1364
+ tooltipAt(domKey: string, t: number): TooltipContent | undefined;
1365
+ /**
1366
+ * The colors the run paints, the ones that carry meaning first (legend classes, the
1367
+ * no-data fill, tile shades as composited), for seeding a GIF palette.
1368
+ */
1369
+ paletteColors(): string[];
1370
+ /** One-line summary of the frame at `t` for the live region. */
1371
+ describe(t: number): string;
1372
+ }
1373
+ /** A geo map playback. */
1374
+ type GeoMapPlayback = MapPlayback<GeoMapLayout>;
1375
+ /** A tile map playback. */
1376
+ type TileMapPlayback = MapPlayback<TileMapLayout>;
1377
+
1378
+ /**
1379
+ * Map playback compiles: geo maps and tile maps with `encoding.time` (and geo points with
1380
+ * `points.time`). One frame compile per size and theme freezes the classes, sizes and legend
1381
+ * over every period; frames then read fills, points and the period label from the frozen
1382
+ * scales, never compiling per period.
1383
+ */
1384
+
1385
+ /** Whether a map spec plays: `encoding.time`, or `points.time` on a geo map. */
1386
+ declare function hasMapTimeEncoding(spec: unknown): boolean;
1387
+ /**
1388
+ * Compile a geo map with `encoding.time` or `points.time` into its playback: the base layout
1389
+ * at the final period with every point that ever shows, plus pure functions of `t`.
1390
+ *
1391
+ * @throws The validation error compile throws for an invalid spec.
1392
+ * @throws {PlaybackDataError} DUPLICATE_KEY_PERIOD when two rows share a key and period.
1393
+ * @throws {RangeError} When `playback.step` overflows over the period count.
1394
+ * @throws {Error} When the map has no room to draw at this size.
1395
+ */
1396
+ declare function compileGeoMapPlayback(spec: unknown, options: CompileOptions): GeoMapPlayback;
1397
+ /**
1398
+ * Compile a tile map with `encoding.time` into its playback: the base layout at the final
1399
+ * period plus pure functions of `t`.
1400
+ *
1401
+ * @throws The validation error compile throws for an invalid spec.
1402
+ * @throws {PlaybackDataError} DUPLICATE_KEY_PERIOD when two rows share a state and period.
1403
+ * @throws {RangeError} When `playback.step` overflows over the period count.
1404
+ * @throws {Error} When the tile map has no room to draw at this size.
1405
+ */
1406
+ declare function compileTileMapPlayback(spec: unknown, options: CompileOptions): TileMapPlayback;
1407
+
1408
+ /**
1409
+ * Playback overlays: the large faint period label behind the marks and the name labels
1410
+ * `playback.labels` draws beside its points. Both are text marks the frame writer matches by
1411
+ * key, built per frame from the frame's marks.
1412
+ */
1413
+
1414
+ /** Key of the period label's text mark. */
1415
+ declare const PERIOD_LABEL_KEY = "oc-playback-period";
1416
+
1417
+ /** Display labels for the matrix's periods: the readout under the controls and the big period label. */
1418
+
1419
+ /**
1420
+ * Formats temporal periods from the matrix's UTC sort keys. A four-digit integer
1421
+ * equal to its sort key prints as a year by default and uses January 1 for explicit formats.
1422
+ * Automatic labels use years if all dates are January 1, months if all dates are
1423
+ * the first of a month, and days otherwise.
1424
+ */
1425
+ declare function formatPeriodLabels(periods: PlaybackPeriod[], time: EncodingChannel): string[];
1426
+
1427
+ /**
1428
+ * Whether a raw spec sets `encoding.time` (any non-null value, so a malformed channel still
1429
+ * reaches time validation). Compile, validation and the mounts branch on this, so a spec
1430
+ * without `time` never reaches playback code.
1431
+ */
1432
+ declare function hasTimeEncoding(spec: unknown): boolean;
1433
+
1434
+ /**
1435
+ * Playback trails as layout marks: the one description of how a trail looks (a thin line
1436
+ * through the key's observed positions to its head, a small dot at each observed position,
1437
+ * in the key's color, faded) shared by the static compile, exports and the live writer.
1438
+ */
1439
+
1440
+ /** How every trail is drawn, live and static. */
1441
+ declare const TRAIL_STYLE: {
1442
+ readonly strokeWidth: 1.5;
1443
+ /** Applied to the line and to each dot's fill. */
1444
+ readonly opacity: 0.45;
1445
+ readonly dotRadius: 2;
1446
+ };
1447
+ /**
1448
+ * Key prefix of every trail mark. It sits under the `oc-playback-` prefix the stylesheet
1449
+ * makes click-through, so trails never take pointer events from the marks.
1450
+ */
1451
+ declare const TRAIL_KEY_PREFIX = "oc-playback-trail";
1452
+ /** The trail line's key for a mark key. */
1453
+ declare function trailLineKey(key: string): string;
1454
+ /** The key of the dot at observed position `index` of a key's trail. */
1455
+ declare function trailDotKey(key: string, index: number): string;
1456
+ /** The points the trail line passes through: every observed position, then the head. */
1457
+ declare function trailLinePoints(trail: TrailPath): TrailPath['points'];
1458
+ /** Each keyed point's plain fill, the color its trail borrows. */
1459
+ declare function trailColorsByKey(base: ChartLayout): Map<string, string>;
1460
+ /**
1461
+ * Decorative marks drawing `trails`: per trail, its line and then one dot per observed
1462
+ * position, colored by the key's entry in `colors`. Paint them before the data marks so
1463
+ * trails sit underneath.
1464
+ */
1465
+ declare function trailMarks(trails: readonly TrailPath[], colors: Map<string, string>): Mark[];
1466
+ /** Whether a mark is part of a trail. */
1467
+ declare function isTrailMark(mark: Mark): boolean;
1468
+
1469
+ /** Read up to three leaders for a live announcement, including any hidden by a transition. */
1470
+ declare function raceA11yLeaders(model: RaceModel, t: number): string[];
1471
+ /** Build the size-independent description and period table once per prepared model. */
1472
+ declare function raceA11y(model: RaceModel): A11yMetadata;
1473
+
820
1474
  /**
821
1475
  * Animation resolver: normalizes AnimationSpec into fully resolved config.
822
1476
  *
823
1477
  * Handles the shorthand forms:
824
- * - true -> all three phases with defaults
1478
+ * - true/undefined -> all three phases with defaults (animation is on by
1479
+ * default; omitting the field is the same as `true`)
825
1480
  * - { enter: { duration: 800 } } -> merge with defaults per phase
826
- * - false/undefined -> undefined (no animation)
1481
+ * - false -> undefined (no animation)
827
1482
  *
828
1483
  * Each phase resolves independently:
829
1484
  * - true/config-object -> resolved phase merged onto that phase's defaults
@@ -837,17 +1492,17 @@ declare function buildEdgeTooltip(edge: CompiledGraphEdge): TooltipContent;
837
1492
  declare const ENTER_DEFAULTS: ResolvedAnimationPhase;
838
1493
  /** Default values for update (data transition) animation. */
839
1494
  declare const UPDATE_DEFAULTS: ResolvedAnimationPhase;
840
- /** Default values for exit animation. */
1495
+ /**
1496
+ * Default values for exit animation: a quick fade that clears before survivors
1497
+ * move into the removed mark's slot (choreography's EXIT_FADE_MS/EXIT_CURVE).
1498
+ */
841
1499
  declare const EXIT_DEFAULTS: ResolvedAnimationPhase;
842
1500
  /**
843
1501
  * Resolve an AnimationSpec into a fully resolved config with all defaults filled.
844
- * Returns undefined if animation is disabled (false or omitted).
1502
+ * Omitted behaves like `true` (animation is on by default); returns undefined
1503
+ * only when animation is disabled (`false`, or every phase set to false).
845
1504
  */
846
1505
  declare function resolveAnimation(spec: AnimationSpec | undefined): ResolvedAnimation | undefined;
847
- /**
848
- * Clamp stagger delay so total stagger time doesn't exceed MAX_TOTAL_STAGGER_MS.
849
- */
850
- declare function clampStaggerDelay(delay: number, elementCount: number): number;
851
1506
 
852
1507
  /**
853
1508
  * Mark key utilities for data-update transitions.
@@ -877,50 +1532,6 @@ declare function buildLinePath(points: Point[], interpolate?: string): string;
877
1532
  */
878
1533
  declare function buildAreaPath(topPoints: Point[], bottomPoints: Point[], interpolate?: string): string;
879
1534
 
880
- type TemporalInterval = NonNullable<EncodingChannel['interval']>;
881
- interface ResolvedTemporalInterval {
882
- value: TemporalInterval;
883
- offset(date: Date): Date;
884
- warnings: string[];
885
- }
886
-
887
- /** Continuous D3 scales (linear, time, log, pow, sqrt, symlog) that support .ticks() and .nice(). */
888
- type D3ContinuousScale = ScaleLinear<number, number> | ScaleTime<number, number> | ScaleLogarithmic<number, number> | ScalePower<number, number> | ScaleSymLog<number, number>;
889
- /** Discretizing D3 scales (quantile, quantize, threshold). */
890
- type D3DiscretizingScale = ScaleQuantile<number> | ScaleQuantize<number> | ScaleThreshold<number, number>;
891
- /** Categorical D3 scales (band, point, ordinal) that support .domain() as string[]. */
892
- type D3CategoricalScale = ScaleBand<string> | ScalePoint<string> | ScaleOrdinal<string, string>;
893
- /** Union of all D3 scale types used by the engine. */
894
- type D3Scale = D3ContinuousScale | D3CategoricalScale | D3DiscretizingScale;
895
- /** All resolved scale type identifiers. */
896
- type ResolvedScaleType = ScaleType | 'sequential';
897
- /**
898
- * A resolved scale wrapping a d3 scale with type metadata.
899
- * We need to carry the scale type around so axes and marks know
900
- * how to interpret the domain/range. Consumers use the `type` discriminant
901
- * to determine which D3 methods are available on the scale.
902
- */
903
- interface ResolvedScale {
904
- /** The d3 scale function. Maps domain value -> pixel position or color. */
905
- scale: D3Scale;
906
- /** The scale type for downstream use. */
907
- type: ResolvedScaleType;
908
- /** The encoding channel this scale was derived from. */
909
- channel: EncodingChannel;
910
- /** Per-field formatting context (extent, allIntegers) from the ORIGINAL data. */
911
- formatContext?: FieldFormatContext;
912
- temporalInterval?: ResolvedTemporalInterval;
913
- }
914
- /** All resolved scales for a chart. */
915
- interface ResolvedScales {
916
- x?: ResolvedScale;
917
- y?: ResolvedScale;
918
- color?: ResolvedScale;
919
- size?: ResolvedScale;
920
- /** Default color for single-series charts (first categorical palette color or markDef.fill gradient). */
921
- defaultColor?: string | _opendata_ai_openchart_core.GradientDef;
922
- }
923
-
924
1535
  /**
925
1536
  * Pie / donut chart mark computation.
926
1537
  *
@@ -1430,4 +2041,4 @@ declare function migrateSpecV8<T>(input: T, options?: {
1430
2041
  /** Author order and supplementary fields survive; formatted text never decides identity. */
1431
2042
  declare function sharedTooltipFields(content: TooltipContent): TooltipField[];
1432
2043
 
1433
- export { ARROWHEAD_LENGTH, AUTO_CANVAS_THRESHOLD, type AnnotationContext, type AnnotationEditContext, type AnnotationMeasureTextFn, type AppliedSpecPatch, type ArrowheadPoints, BOLD_SPAN_FONT_WEIGHT, type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, DEFAULT_ANNOTATION_FONT_SIZE, DEFAULT_LINE_HEIGHT, ENTER_DEFAULTS, EXIT_DEFAULTS, type GeoReaderIndex, type GeoReaderRecord, type GraphCompilation, MAX_3D_NODES, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGeoMapSpec, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObservationComparison, type ObstacleKind, type PlacementObstacle, type ReaderPanelIndex, type ReaderSliceIndex, type RecommendationResult, type RecommendationRoles, type RichSpan, type SimulationConfig, type SpecRepair, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, applySpecPatch, automaticControlPoint, buildArcPath, buildAreaPath, buildEdgeTooltip, buildGeoReaderIndex, buildLinePath, buildReaderSliceIndex, clampStaggerDelay, clearRenderers, compareObservations, compareReaderValues, compile, compileBarList, compileChart, compileGeoMap, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, computeArrowheadPoints, createAnnotationEditContext, dedupeKeys, diagnoseChart, evaluatePredicate, facetMinHeight, flattenLayers, geoColorKeyPosition, getChartRenderer, heuristicMeasure, interpolateAnnotationGeometry, inverseLabelPlacement, isConditionalValueDef, legendGap, linkedEntityKeys, migrateSpecV8, nearestReaderSlice, normalizeSpec, observationKey, parseAnnotationSpans, previewAnnotationMove, previewConnectorBend, previewConnectorOffset, queryGeoReaderRecords, readerDomainValue, readerSliceByKey, recommendCompositions, reconcileReaderSelection, reconcileReaderSlices, refreshConnector, registerChartRenderer, resolveAnimation, resolveConditionalValue, resolveGeoOverlay, resolveLayerTheme, resolveObservationIdentities, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, sharedTooltipFields, validateSpec };
2044
+ export { ARROWHEAD_LENGTH, AUTO_CANVAS_THRESHOLD, type AnnotationContext, type AnnotationEditContext, type AnnotationMeasureTextFn, type AppliedSpecPatch, type ArrowheadPoints, BOLD_SPAN_FONT_WEIGHT, type ChartPlayback, type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, DEFAULT_ANNOTATION_FONT_SIZE, DEFAULT_LINE_HEIGHT, ENTER_DEFAULTS, EXIT_DEFAULTS, type FrameMark, type FrozenChartFrame, type GeoMapPlayback, type GeoReaderIndex, type GeoReaderRecord, type GraphCompilation, MAX_3D_NODES, type MapFillFrame, type MapPlayback, type MapPointFrame, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGeoMapSpec, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObservationComparison, type ObservedValues, type ObstacleKind, PERIOD_LABEL_KEY, PLAYBACK_LABEL_KEY_PREFIX, type PlacementObstacle, type PlaybackChannel, PlaybackDataError, type PlaybackDataErrorCode, type PlaybackGaps, type PlaybackMatrix, type PlaybackMatrixOptions, type PlaybackOverlayLayout, type PlaybackPeriod, type PlaybackTimeEncoding, type PlaybackTimeType, RaceDataError, type RaceModel, type ReaderPanelIndex, type ReaderSliceIndex, type RecommendationResult, type RecommendationRoles, type ResolvedPlayback, type RichSpan, type SimulationConfig, type SpecRepair, TRAIL_KEY_PREFIX, TRAIL_STYLE, type TileMapPlayback, type TrailPath, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, applySpecPatch, automaticControlPoint, buildArcPath, buildAreaPath, buildEdgeTooltip, buildGeoReaderIndex, buildLinePath, buildPlaybackMatrix, buildReaderSliceIndex, clearRenderers, compareObservations, compareReaderValues, compile, compileBarList, compileChart, compileChartPlayback, compileGeoMap, compileGeoMapPlayback, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, compileTileMapPlayback, computeArrowheadPoints, createAnnotationEditContext, dedupeKeys, diagnoseChart, evaluatePredicate, facetMinHeight, flattenLayers, formatPeriodLabels, geoColorKeyPosition, getChartRenderer, hasMapTimeEncoding, hasTimeEncoding, heuristicMeasure, interpolateAnnotationGeometry, interpolatePlaybackLogValue, interpolatePlaybackValue, inverseLabelPlacement, isConditionalValueDef, isTrailMark, layoutRace, legendGap, linkedEntityKeys, migrateSpecV8, nearestReaderSlice, normalizeSpec, observationKey, orderPeriods, parseAnnotationSpans, playbackLabelKey, playbackLabelPointKey, prepareRace, previewAnnotationMove, previewConnectorBend, previewConnectorOffset, queryGeoReaderRecords, raceA11y, raceA11yLeaders, raceFrameAt, raceGeometryAt, readPeriod, readerDomainValue, readerSliceByKey, recommendCompositions, reconcileReaderSelection, reconcileReaderSlices, refreshConnector, registerChartRenderer, resolveAnimation, resolveConditionalValue, resolveGeoOverlay, resolveLayerTheme, resolveObservationIdentities, resolvePlayback, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, sharedTooltipFields, trailColorsByKey, trailDotKey, trailLineKey, trailLinePoints, trailMarks, validateSpec };