@opendata-ai/openchart-engine 9.1.0 → 9.2.1

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,5 +1,5 @@
1
1
  import * as _opendata_ai_openchart_core 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, ChartSpec, ResolvedAnimationPhase, ResolvedAnimation, Point, 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';
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
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';
@@ -232,11 +232,24 @@ interface GraphCompilation {
232
232
  */
233
233
  declare const MAX_3D_NODES = 2000;
234
234
 
235
- /** Data that cannot form a race timeline. */
236
- declare class RaceDataError extends Error {
237
- readonly code: 'DUPLICATE_KEY_PERIOD' | 'TOO_FEW_PERIODS' | 'NO_VALUES';
238
- readonly name = "RaceDataError";
239
- constructor(code: 'DUPLICATE_KEY_PERIOD' | 'TOO_FEW_PERIODS' | 'NO_VALUES', message: string);
235
+ /**
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.
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
+ }
247
+
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;
240
253
  }
241
254
 
242
255
  /** Shared area pivot/offset semantics for domain measurement and mark geometry. */
@@ -567,6 +580,8 @@ interface ResolvedRaceOptions {
567
580
  top: number;
568
581
  duration?: number;
569
582
  step?: number;
583
+ /** Set when `step` came from the top-level `playback` block, so errors name that block. */
584
+ stepBlock?: 'playback';
570
585
  swap: number;
571
586
  rescale: 'frame' | 'fixed' | {
572
587
  min: number;
@@ -795,6 +810,17 @@ declare function compileGeoMap(spec: unknown, options: CompileOptions): GeoMapLa
795
810
  */
796
811
  declare function compileBarList(spec: unknown, options: CompileOptions): BarListLayout;
797
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
+
798
824
  /** Default font size for annotation labels. */
799
825
  declare const DEFAULT_ANNOTATION_FONT_SIZE = 13;
800
826
  /** Default line height multiplier for annotation text. */
@@ -922,15 +948,48 @@ interface ReferenceLanes {
922
948
  topOverflow?: boolean;
923
949
  }
924
950
 
925
- type BarLabelPlacement = 'adaptive' | 'inside' | 'outside' | 'column' | 'suppress';
926
- interface BarLabelPlan {
927
- placement: BarLabelPlacement;
928
- reserveLeft: number;
929
- reserveRight: number;
930
- reserveTop: number;
931
- reserveBottom: number;
932
- columnWidth: number;
933
- 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;
934
993
  }
935
994
 
936
995
  /**
@@ -966,6 +1025,447 @@ declare function resolveLayerTheme(layerSpec: LayerSpec, primary?: ChartSpec): _
966
1025
  */
967
1026
  declare function buildEdgeTooltip(edge: CompiledGraphEdge): TooltipContent;
968
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
+
969
1469
  /** Read up to three leaders for a live announcement, including any hidden by a transition. */
970
1470
  declare function raceA11yLeaders(model: RaceModel, t: number): string[];
971
1471
  /** Build the size-independent description and period table once per prepared model. */
@@ -1032,50 +1532,6 @@ declare function buildLinePath(points: Point[], interpolate?: string): string;
1032
1532
  */
1033
1533
  declare function buildAreaPath(topPoints: Point[], bottomPoints: Point[], interpolate?: string): string;
1034
1534
 
1035
- type TemporalInterval = NonNullable<EncodingChannel['interval']>;
1036
- interface ResolvedTemporalInterval {
1037
- value: TemporalInterval;
1038
- offset(date: Date): Date;
1039
- warnings: string[];
1040
- }
1041
-
1042
- /** Continuous D3 scales (linear, time, log, pow, sqrt, symlog) that support .ticks() and .nice(). */
1043
- type D3ContinuousScale = ScaleLinear<number, number> | ScaleTime<number, number> | ScaleLogarithmic<number, number> | ScalePower<number, number> | ScaleSymLog<number, number>;
1044
- /** Discretizing D3 scales (quantile, quantize, threshold). */
1045
- type D3DiscretizingScale = ScaleQuantile<number> | ScaleQuantize<number> | ScaleThreshold<number, number>;
1046
- /** Categorical D3 scales (band, point, ordinal) that support .domain() as string[]. */
1047
- type D3CategoricalScale = ScaleBand<string> | ScalePoint<string> | ScaleOrdinal<string, string>;
1048
- /** Union of all D3 scale types used by the engine. */
1049
- type D3Scale = D3ContinuousScale | D3CategoricalScale | D3DiscretizingScale;
1050
- /** All resolved scale type identifiers. */
1051
- type ResolvedScaleType = ScaleType | 'sequential';
1052
- /**
1053
- * A resolved scale wrapping a d3 scale with type metadata.
1054
- * We need to carry the scale type around so axes and marks know
1055
- * how to interpret the domain/range. Consumers use the `type` discriminant
1056
- * to determine which D3 methods are available on the scale.
1057
- */
1058
- interface ResolvedScale {
1059
- /** The d3 scale function. Maps domain value -> pixel position or color. */
1060
- scale: D3Scale;
1061
- /** The scale type for downstream use. */
1062
- type: ResolvedScaleType;
1063
- /** The encoding channel this scale was derived from. */
1064
- channel: EncodingChannel;
1065
- /** Per-field formatting context (extent, allIntegers) from the ORIGINAL data. */
1066
- formatContext?: FieldFormatContext;
1067
- temporalInterval?: ResolvedTemporalInterval;
1068
- }
1069
- /** All resolved scales for a chart. */
1070
- interface ResolvedScales {
1071
- x?: ResolvedScale;
1072
- y?: ResolvedScale;
1073
- color?: ResolvedScale;
1074
- size?: ResolvedScale;
1075
- /** Default color for single-series charts (first categorical palette color or markDef.fill gradient). */
1076
- defaultColor?: string | _opendata_ai_openchart_core.GradientDef;
1077
- }
1078
-
1079
1535
  /**
1080
1536
  * Pie / donut chart mark computation.
1081
1537
  *
@@ -1585,4 +2041,4 @@ declare function migrateSpecV8<T>(input: T, options?: {
1585
2041
  /** Author order and supplementary fields survive; formatted text never decides identity. */
1586
2042
  declare function sharedTooltipFields(content: TooltipContent): TooltipField[];
1587
2043
 
1588
- 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, RaceDataError, type RaceModel, 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, 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, layoutRace, legendGap, linkedEntityKeys, migrateSpecV8, nearestReaderSlice, normalizeSpec, observationKey, parseAnnotationSpans, prepareRace, previewAnnotationMove, previewConnectorBend, previewConnectorOffset, queryGeoReaderRecords, raceA11y, raceA11yLeaders, raceFrameAt, raceGeometryAt, 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 };