@opendata-ai/openchart-engine 9.2.1 → 9.2.3
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 +446 -452
- package/dist/index.js +13383 -13840
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,257 +1,9 @@
|
|
|
1
1
|
import * as _opendata_ai_openchart_core from '@opendata-ai/openchart-core';
|
|
2
|
-
import {
|
|
2
|
+
import { DataRow, GeoMapGeo, GeoMapProjection, GeoMapEncoding, LegendConfig, ThemeConfig, AnimationSpec, GeoMapPointsLayer, FieldMetadata, GeoCallout, RaceSpec, RaceMarkDef, RaceEncoding, EncodingChannel, RacePlayback, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, TileMapEncoding, TileMapPalette, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, TableDensity, SortState, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, GraphAnimationSpec, GraphInteractionConfig, BarListEncoding, BarListSpec, LayerSpec, ChartSpec, VizSpec, AnimationEase, SpringConfig, LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, LegendEntry, RaceFrame, RaceLayout, RaceGeometry, CompileOptions, CompileWarning, BarListLayout, ChartLayout, GeoMapLayout, SankeyLayout, CompileTableOptions, TableLayout, TileMapLayout, ResolvedLabel, Rect, ResolvedAnnotation, ScaleType, FieldFormatContext, PlaybackPeriodPosition, PlaybackTimingConfig, LayoutStrategy, Mark, Point, TextMarkLayout, ResolvedAnimationPhase, ResolvedAnimation, 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';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Graph animation resolver.
|
|
9
|
-
*
|
|
10
|
-
* Modeled on `compiler/animation.ts`. Like every visualization type, graphs
|
|
11
|
-
* animate by default.
|
|
12
|
-
*
|
|
13
|
-
* - `undefined` (omitted) or `true` -> full defaults
|
|
14
|
-
* - `false` -> undefined (no choreography; note `layout.warmup` still applies,
|
|
15
|
-
* resolved independently into SimulationConfig)
|
|
16
|
-
* - object -> per-phase resolution; a per-phase `false` -> that phase is `null`
|
|
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
|
-
*
|
|
22
|
-
* `reheatAlpha` for the update impulse and the entrance `cameraFit` toggle are
|
|
23
|
-
* internal vanilla constants, not spec surface. Warmup is NOT part of this block
|
|
24
|
-
* (it lives in `layout`); `fitOnLoad` is a mount option.
|
|
25
|
-
*/
|
|
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
|
-
}
|
|
33
|
-
/** Fully resolved graph animation config consumed by the vanilla adapter. */
|
|
34
|
-
interface ResolvedGraphAnimation {
|
|
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 & {
|
|
40
|
-
stagger: boolean;
|
|
41
|
-
cameraFit: boolean;
|
|
42
|
-
trigger: 'visible' | 'mount';
|
|
43
|
-
}) | null;
|
|
44
|
-
/** Data-update enter-fade for newly added marks, or null. */
|
|
45
|
-
update: ResolvedGraphPhase | null;
|
|
46
|
-
/** Ghost fade-out for removed marks, or null. */
|
|
47
|
-
exit: ResolvedGraphPhase | null;
|
|
48
|
-
/** Camera flight easing, or null. `'auto'` derives duration from zoom distance. */
|
|
49
|
-
camera: {
|
|
50
|
-
duration: number | 'auto';
|
|
51
|
-
ease: AnimationEase;
|
|
52
|
-
} | null;
|
|
53
|
-
/** Hover emphasis crossfade, or null. */
|
|
54
|
-
hover: {
|
|
55
|
-
duration: number;
|
|
56
|
-
ease: AnimationEase;
|
|
57
|
-
} | null;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Graph interaction resolver.
|
|
62
|
-
*
|
|
63
|
-
* Resolves `GraphInteractionConfig` into a flat, defaulted shape the vanilla
|
|
64
|
-
* adapter consumes. Category sets for `'category'` hover mode and
|
|
65
|
-
* `highlight({ category })` derive from the compilation's sort-resolved domains
|
|
66
|
-
* (not raw node data), so `getLegend()` and `highlight()` always agree.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
/** Hover emphasis behavior. */
|
|
70
|
-
type GraphHoverMode = 'neighbors' | 'category' | 'node' | 'none';
|
|
71
|
-
/** Fully resolved graph interaction config. */
|
|
72
|
-
interface ResolvedGraphInteraction {
|
|
73
|
-
/** Hover emphasis mode. Default `'neighbors'`. */
|
|
74
|
-
hoverMode: GraphHoverMode;
|
|
75
|
-
/** Node dim tier during hover/focus. Default 0.3. */
|
|
76
|
-
dimOpacity: number;
|
|
77
|
-
/** Whether selecting a node flies the camera to it. Default false. */
|
|
78
|
-
selectFlyTo: boolean;
|
|
79
|
-
/** Cursor repulsion config, or null if disabled. */
|
|
80
|
-
cursorRepulsion: {
|
|
81
|
-
radius: number;
|
|
82
|
-
strength: number;
|
|
83
|
-
} | null;
|
|
84
|
-
/** Whether springy node drag is enabled. Default false. */
|
|
85
|
-
springyDrag: boolean;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Graph compilation types.
|
|
90
|
-
*
|
|
91
|
-
* These types represent the engine output for graph specs. Unlike GraphLayout
|
|
92
|
-
* (which includes x/y positions for adapter rendering), GraphCompilation
|
|
93
|
-
* contains resolved visual properties WITHOUT positional layout. The force
|
|
94
|
-
* simulation in the adapter sets node positions at runtime.
|
|
95
|
-
*/
|
|
96
|
-
|
|
97
|
-
/** A compiled graph node with resolved visual properties (no x/y position). */
|
|
98
|
-
interface CompiledGraphNode {
|
|
99
|
-
/** Node identifier from the spec. */
|
|
100
|
-
id: string;
|
|
101
|
-
/** Computed radius from nodeSize encoding (3-20px range, default 5px). */
|
|
102
|
-
radius: number;
|
|
103
|
-
/** Computed fill color from nodeColor encoding or community assignment. */
|
|
104
|
-
fill: string;
|
|
105
|
-
/** Stroke color, slightly darker than fill. */
|
|
106
|
-
stroke: string;
|
|
107
|
-
/** Stroke width in pixels. Default 1. */
|
|
108
|
-
strokeWidth: number;
|
|
109
|
-
/** Label text from nodeLabel encoding or node id. */
|
|
110
|
-
label: string | undefined;
|
|
111
|
-
/** Label priority for level-of-detail rendering (0-1, degree/maxDegree). */
|
|
112
|
-
labelPriority: number;
|
|
113
|
-
/** Community/cluster assignment from the clustering field. */
|
|
114
|
-
community: string | undefined;
|
|
115
|
-
/** Opacity from the nodeOpacity encoding (default 1). Renderer multiplies into fill/stroke alpha. */
|
|
116
|
-
opacity: number;
|
|
117
|
-
/** Original node data (all fields from the spec node). */
|
|
118
|
-
data: Record<string, unknown>;
|
|
119
|
-
}
|
|
120
|
-
/** A compiled graph edge with resolved visual properties (no positional endpoints). */
|
|
121
|
-
interface CompiledGraphEdge {
|
|
122
|
-
/** Source node id. */
|
|
123
|
-
source: string;
|
|
124
|
-
/** Target node id. */
|
|
125
|
-
target: string;
|
|
126
|
-
/** Stroke color from edgeColor encoding or theme default. */
|
|
127
|
-
stroke: string;
|
|
128
|
-
/** Stroke width from edgeWidth encoding (0.5-4px range, default 1px). */
|
|
129
|
-
strokeWidth: number;
|
|
130
|
-
/** Line style. */
|
|
131
|
-
style: 'solid' | 'dashed' | 'dotted';
|
|
132
|
-
/** Original edge data (all fields from the spec edge). */
|
|
133
|
-
data: Record<string, unknown>;
|
|
134
|
-
}
|
|
135
|
-
/** Configuration for the force simulation, derived from the spec layout. */
|
|
136
|
-
interface SimulationConfig {
|
|
137
|
-
/** Repulsion strength between nodes. Negative = repulsion. */
|
|
138
|
-
chargeStrength: number;
|
|
139
|
-
/** Target distance between linked nodes. */
|
|
140
|
-
linkDistance: number;
|
|
141
|
-
/** Clustering configuration, or null if no clustering. */
|
|
142
|
-
clustering: {
|
|
143
|
-
field: string;
|
|
144
|
-
strength: number;
|
|
145
|
-
} | null;
|
|
146
|
-
/** How quickly the simulation cools. Default 0.0228. */
|
|
147
|
-
alphaDecay: number;
|
|
148
|
-
/** Velocity damping. Default 0.4. */
|
|
149
|
-
velocityDecay: number;
|
|
150
|
-
/** Collision radius: max node radius + padding. */
|
|
151
|
-
collisionRadius: number;
|
|
152
|
-
/** Extra px added to node radius for collision (default 2). */
|
|
153
|
-
collisionPadding?: number;
|
|
154
|
-
/** Link force strength override. */
|
|
155
|
-
linkStrength?: number;
|
|
156
|
-
/** Whether to apply center force (default true). */
|
|
157
|
-
centerForce?: boolean;
|
|
158
|
-
/** Deterministic layout seed (hashes into initial node positions). */
|
|
159
|
-
seed?: number;
|
|
160
|
-
/** Headless settle ticks run before first paint. 0/undefined disables warmup. */
|
|
161
|
-
warmupTicks?: number;
|
|
162
|
-
/** Wall-clock budget (ms) that caps warmup at scale. Default 250. */
|
|
163
|
-
warmupBudgetMs?: number;
|
|
164
|
-
/** Initial alpha for the simulation (update reheat / entrance). Default d3's 1. */
|
|
165
|
-
initialAlpha?: number;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* The complete engine output for graph specs.
|
|
169
|
-
*
|
|
170
|
-
* Contains resolved visual properties for nodes and edges, but does NOT
|
|
171
|
-
* include x/y positions. The adapter's force simulation assigns positions
|
|
172
|
-
* at runtime using the simulationConfig.
|
|
173
|
-
*/
|
|
174
|
-
interface GraphCompilation {
|
|
175
|
-
/** Compiled nodes with visual properties. */
|
|
176
|
-
nodes: CompiledGraphNode[];
|
|
177
|
-
/** Compiled edges with visual properties. */
|
|
178
|
-
edges: CompiledGraphEdge[];
|
|
179
|
-
/** Legend layout (community colors or nodeColor categories). */
|
|
180
|
-
legend: LegendLayout;
|
|
181
|
-
/** Resolved chrome text elements. */
|
|
182
|
-
chrome: ResolvedChrome;
|
|
183
|
-
/** Tooltip descriptors keyed by node id. */
|
|
184
|
-
tooltipDescriptors: Map<string, TooltipContent>;
|
|
185
|
-
/** Accessibility metadata. */
|
|
186
|
-
a11y: A11yMetadata;
|
|
187
|
-
/** Resolved theme used for rendering. */
|
|
188
|
-
theme: ResolvedTheme;
|
|
189
|
-
/** Total available dimensions. */
|
|
190
|
-
dimensions: {
|
|
191
|
-
width: number;
|
|
192
|
-
height: number;
|
|
193
|
-
};
|
|
194
|
-
/** Force simulation configuration. */
|
|
195
|
-
simulationConfig: SimulationConfig;
|
|
196
|
-
/** Whether to show the brand watermark. */
|
|
197
|
-
watermark: boolean;
|
|
198
|
-
/** Resolved motion config, or undefined when `animation: false`. */
|
|
199
|
-
animation?: ResolvedGraphAnimation;
|
|
200
|
-
/** Resolved interaction config (always present, defaulted). */
|
|
201
|
-
interaction: ResolvedGraphInteraction;
|
|
202
|
-
/** The nodeColor field backing the legend/category emphasis, or null. */
|
|
203
|
-
legendField: string | null;
|
|
204
|
-
/** Categories to emphasize on load, captured from nodeColor.highlight. */
|
|
205
|
-
initialHighlight?: {
|
|
206
|
-
field: string;
|
|
207
|
-
values: string[];
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* Ids exempt from highlight/filter dimming (currently just `spec.seedNode`).
|
|
211
|
-
* Empty when no seed is set. Array-shaped so a future `pinnedNodes` needs no
|
|
212
|
-
* type change.
|
|
213
|
-
*/
|
|
214
|
-
seedNodeIds: string[];
|
|
215
|
-
/** Edge legend entries (nominal edgeColor with >1 category), or undefined. */
|
|
216
|
-
edgeLegend?: LegendEntry[];
|
|
217
|
-
/**
|
|
218
|
-
* Resolved render dimensionality. `3` only when the spec asked for it AND the
|
|
219
|
-
* node count is within {@link MAX_3D_NODES}; otherwise `2`.
|
|
220
|
-
*/
|
|
221
|
-
numDimensions: 2 | 3;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Node ceiling for 3D rendering. The 3D simulation runs on the main thread, so
|
|
225
|
-
* a spec above this falls back to 2D with a warning rather than freezing the
|
|
226
|
-
* page.
|
|
227
|
-
*
|
|
228
|
-
* The number is measured, not guessed. On the RFC 27 gate rig (headed Chromium,
|
|
229
|
-
* ANGLE/Metal, 900x600, DPR 2) an idle 3,000-node / ~6,000-edge scene held
|
|
230
|
-
* 22-27fps against a 30fps floor, while 2,000 held 38-44fps. Every edge is a
|
|
231
|
-
* separate draw call, which is what the ceiling is really made of.
|
|
232
|
-
*/
|
|
233
|
-
declare const MAX_3D_NODES = 2000;
|
|
234
|
-
|
|
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;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
7
|
/** Shared area pivot/offset semantics for domain measurement and mark geometry. */
|
|
256
8
|
|
|
257
9
|
interface AreaStackGeometry {
|
|
@@ -263,28 +15,6 @@ interface AreaStackGeometry {
|
|
|
263
15
|
/** Created per compilation; never retained by a module or an authored input. */
|
|
264
16
|
type AreaStackCache = WeakMap<DataRow[], Map<string, AreaStackGeometry>>;
|
|
265
17
|
|
|
266
|
-
/**
|
|
267
|
-
* Internal normalized barlist spec type used by the compilation pipeline.
|
|
268
|
-
*/
|
|
269
|
-
|
|
270
|
-
interface NormalizedBarListSpec {
|
|
271
|
-
type: 'barlist';
|
|
272
|
-
data: DataRow[];
|
|
273
|
-
encoding: BarListEncoding;
|
|
274
|
-
barHeight: number;
|
|
275
|
-
cornerRadius: number | 'pill';
|
|
276
|
-
maxItems: number;
|
|
277
|
-
sort: 'descending' | 'ascending' | null;
|
|
278
|
-
height?: BarListSpec['height'];
|
|
279
|
-
annotations?: BarListSpec['annotations'];
|
|
280
|
-
labels?: BarListSpec['labels'];
|
|
281
|
-
a11y?: BarListSpec['a11y'];
|
|
282
|
-
chrome: NormalizedChrome;
|
|
283
|
-
theme: ThemeConfig;
|
|
284
|
-
watermark: boolean;
|
|
285
|
-
animation?: AnimationSpec;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
18
|
interface NormalizedGeoMapSpec {
|
|
289
19
|
type: 'map';
|
|
290
20
|
geo: Required<Pick<GeoMapGeo, 'features' | 'idField' | 'focus'>> & Omit<GeoMapGeo, 'features' | 'idField' | 'focus'> & {
|
|
@@ -307,6 +37,112 @@ interface NormalizedGeoMapSpec {
|
|
|
307
37
|
};
|
|
308
38
|
}
|
|
309
39
|
|
|
40
|
+
interface NormalizedRaceSpec extends Omit<RaceSpec, 'mark' | 'encoding' | 'race' | 'chrome' | 'theme' | 'watermark'> {
|
|
41
|
+
mark: RaceMarkDef;
|
|
42
|
+
encoding: RaceEncoding & {
|
|
43
|
+
time: EncodingChannel;
|
|
44
|
+
key: EncodingChannel;
|
|
45
|
+
value: EncodingChannel;
|
|
46
|
+
};
|
|
47
|
+
race: ResolvedRaceOptions;
|
|
48
|
+
chrome: NormalizedChrome;
|
|
49
|
+
theme: ThemeConfig;
|
|
50
|
+
watermark: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface ResolvedRaceOptions {
|
|
53
|
+
top: number;
|
|
54
|
+
duration?: number;
|
|
55
|
+
step?: number;
|
|
56
|
+
/** Set when `step` came from the top-level `playback` block, so errors name that block. */
|
|
57
|
+
stepBlock?: 'playback';
|
|
58
|
+
swap: number;
|
|
59
|
+
rescale: 'frame' | 'fixed' | {
|
|
60
|
+
min: number;
|
|
61
|
+
};
|
|
62
|
+
gaps: 'interpolate' | 'hold' | 'drop';
|
|
63
|
+
holdEnd: number;
|
|
64
|
+
loop: boolean;
|
|
65
|
+
autoplay: 'visible' | boolean;
|
|
66
|
+
controls: boolean;
|
|
67
|
+
period: false | {
|
|
68
|
+
format?: string;
|
|
69
|
+
};
|
|
70
|
+
summary: 'sum' | false;
|
|
71
|
+
}
|
|
72
|
+
interface RaceMatrix {
|
|
73
|
+
/** Sorted ascending. Dates become ISO strings. */
|
|
74
|
+
periods: Array<{
|
|
75
|
+
value: string | number;
|
|
76
|
+
sortKey: number;
|
|
77
|
+
}>;
|
|
78
|
+
/** Sorted by localeCompare with locale 'en'. Index order is the final tie-break. */
|
|
79
|
+
keys: string[];
|
|
80
|
+
/** Last non-null label value per key, or the key itself. */
|
|
81
|
+
labels: string[];
|
|
82
|
+
/** Last non-null color field value per key. Null when color is not a field. */
|
|
83
|
+
colorValues: Array<string | null>;
|
|
84
|
+
/** One array per key, with one value per period. NaN represents absence. */
|
|
85
|
+
values: Float64Array[];
|
|
86
|
+
}
|
|
87
|
+
interface RaceSampleItem {
|
|
88
|
+
keyIndex: number;
|
|
89
|
+
value: number;
|
|
90
|
+
rank: number;
|
|
91
|
+
rankPos: number;
|
|
92
|
+
opacity: number;
|
|
93
|
+
change: number;
|
|
94
|
+
}
|
|
95
|
+
interface RaceSample {
|
|
96
|
+
t: number;
|
|
97
|
+
periodIndex: number;
|
|
98
|
+
items: RaceSampleItem[];
|
|
99
|
+
domainMin: number;
|
|
100
|
+
domainMax: number;
|
|
101
|
+
}
|
|
102
|
+
interface RaceTimeline {
|
|
103
|
+
readonly periodCount: number;
|
|
104
|
+
readonly keyCount: number;
|
|
105
|
+
readonly top: number;
|
|
106
|
+
/** Number of rank samples per period interval. */
|
|
107
|
+
readonly samplesPerPeriod: number;
|
|
108
|
+
/** NaN when absent. */
|
|
109
|
+
valueAt(keyIndex: number, t: number): number;
|
|
110
|
+
/** Smoothed rank in [0, top]. */
|
|
111
|
+
rankPos(keyIndex: number, t: number): number;
|
|
112
|
+
/** Present key indices in exact rank order. */
|
|
113
|
+
ranked(t: number): number[];
|
|
114
|
+
/** Zero-based rank among present keys. Infinity when absent. */
|
|
115
|
+
exactRank(keyIndex: number, t: number): number;
|
|
116
|
+
/** Cached exact rank at an integer period index. Infinity when absent. */
|
|
117
|
+
periodRank(keyIndex: number, period: number): number;
|
|
118
|
+
/** Exact and smoothed ranks on the sample grid. A missing exact rank equals keyCount. */
|
|
119
|
+
rankSamples(keyIndex: number): {
|
|
120
|
+
exact: Readonly<Float32Array>;
|
|
121
|
+
smoothed: Readonly<Float32Array>;
|
|
122
|
+
};
|
|
123
|
+
/** Items with rankPos < top, sorted by rankPos. */
|
|
124
|
+
sample(t: number): RaceSample;
|
|
125
|
+
}
|
|
126
|
+
interface RaceColorAssignment {
|
|
127
|
+
slotsFor(paletteSize: number): readonly (number | string)[];
|
|
128
|
+
/** Assignments already used by a spec or layout, available to carry across updates. */
|
|
129
|
+
readonly byPaletteSize: ReadonlyMap<number, readonly (number | string)[]>;
|
|
130
|
+
}
|
|
131
|
+
interface RaceModel {
|
|
132
|
+
spec: NormalizedRaceSpec;
|
|
133
|
+
/** Authored watermark setting, before normalization supplies a default. */
|
|
134
|
+
specWatermark?: boolean;
|
|
135
|
+
matrix: RaceMatrix;
|
|
136
|
+
timeline: RaceTimeline;
|
|
137
|
+
colorAssignment: RaceColorAssignment;
|
|
138
|
+
/** Spec-theme light colors for standalone frames. On-screen geometry uses layout.colors. */
|
|
139
|
+
frameColors: string[];
|
|
140
|
+
periodLabels: string[];
|
|
141
|
+
formatValue: (value: number) => string;
|
|
142
|
+
playback: RacePlayback;
|
|
143
|
+
warnings: string[];
|
|
144
|
+
}
|
|
145
|
+
|
|
310
146
|
/**
|
|
311
147
|
* Internal normalized sankey spec type used by the compilation pipeline.
|
|
312
148
|
*
|
|
@@ -454,7 +290,7 @@ interface NormalizedChartSpec {
|
|
|
454
290
|
autoThin: boolean;
|
|
455
291
|
compactAnnotationLimit?: number | null;
|
|
456
292
|
theme: ThemeConfig;
|
|
457
|
-
/** Whether the
|
|
293
|
+
/** Whether the OpenChart watermark is enabled. */
|
|
458
294
|
watermark: boolean;
|
|
459
295
|
/** Series names to hide from rendering. */
|
|
460
296
|
hiddenSeries: string[];
|
|
@@ -503,171 +339,349 @@ interface NormalizedTableSpec {
|
|
|
503
339
|
responsive: boolean;
|
|
504
340
|
animation?: AnimationSpec;
|
|
505
341
|
}
|
|
506
|
-
/** A GraphSpec with all optional fields filled with sensible defaults. */
|
|
507
|
-
interface NormalizedGraphSpec {
|
|
508
|
-
type: 'graph';
|
|
509
|
-
nodes: GraphSpec['nodes'];
|
|
510
|
-
edges: GraphSpec['edges'];
|
|
511
|
-
encoding: GraphEncoding;
|
|
512
|
-
layout: GraphLayoutConfig;
|
|
513
|
-
nodeOverrides?: Record<string, NodeOverride>;
|
|
514
|
-
/** Seed node, always in object form (the string shorthand is expanded). */
|
|
515
|
-
seedNode?: {
|
|
516
|
-
id: string;
|
|
517
|
-
style?: NodeOverride;
|
|
342
|
+
/** A GraphSpec with all optional fields filled with sensible defaults. */
|
|
343
|
+
interface NormalizedGraphSpec {
|
|
344
|
+
type: 'graph';
|
|
345
|
+
nodes: GraphSpec['nodes'];
|
|
346
|
+
edges: GraphSpec['edges'];
|
|
347
|
+
encoding: GraphEncoding;
|
|
348
|
+
layout: GraphLayoutConfig;
|
|
349
|
+
nodeOverrides?: Record<string, NodeOverride>;
|
|
350
|
+
/** Seed node, always in object form (the string shorthand is expanded). */
|
|
351
|
+
seedNode?: {
|
|
352
|
+
id: string;
|
|
353
|
+
style?: NodeOverride;
|
|
354
|
+
};
|
|
355
|
+
chrome: NormalizedChrome;
|
|
356
|
+
annotations: Annotation[];
|
|
357
|
+
theme: ThemeConfig;
|
|
358
|
+
watermark: boolean;
|
|
359
|
+
animation?: GraphAnimationSpec;
|
|
360
|
+
interaction?: GraphInteractionConfig;
|
|
361
|
+
legend?: boolean | {
|
|
362
|
+
interactive?: boolean;
|
|
363
|
+
counts?: boolean;
|
|
364
|
+
};
|
|
365
|
+
/** Requested render dimensionality. Validated (and gated) in compileGraph. */
|
|
366
|
+
dimensions?: 2 | 3;
|
|
367
|
+
}
|
|
368
|
+
/** Discriminated union of all normalized spec types. */
|
|
369
|
+
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedGeoMapSpec | NormalizedBarListSpec | NormalizedRaceSpec;
|
|
370
|
+
/** Machine-readable error code for programmatic handling. */
|
|
371
|
+
type ValidationErrorCode = 'MISSING_FIELD' | 'INVALID_TYPE' | 'INVALID_VALUE' | 'ENCODING_MISMATCH' | 'DATA_FIELD_MISSING' | 'EMPTY_DATA';
|
|
372
|
+
/** A single validation error with context. */
|
|
373
|
+
interface ValidationError {
|
|
374
|
+
/** Error message describing what's wrong. */
|
|
375
|
+
message: string;
|
|
376
|
+
/**
|
|
377
|
+
* Root-relative RFC 6901 JSON Pointer to the problematic value, e.g.
|
|
378
|
+
* `/encoding/x/field` or `/layer/1/data/0/value`. The root is `''`.
|
|
379
|
+
*/
|
|
380
|
+
path: string;
|
|
381
|
+
/** Machine-readable error code for programmatic handling. */
|
|
382
|
+
code: ValidationErrorCode;
|
|
383
|
+
/** Actionable suggestion for fixing the error. */
|
|
384
|
+
suggestion: string;
|
|
385
|
+
}
|
|
386
|
+
/** Result of spec validation. */
|
|
387
|
+
interface ValidationResult {
|
|
388
|
+
/** Whether the spec is valid. */
|
|
389
|
+
valid: boolean;
|
|
390
|
+
/** Validation errors (empty if valid). */
|
|
391
|
+
errors: ValidationError[];
|
|
392
|
+
/** The validated spec cast to VizSpec, or null if invalid. */
|
|
393
|
+
normalized: _opendata_ai_openchart_core.VizSpec | null;
|
|
394
|
+
}
|
|
395
|
+
/** Result of the compile pipeline (validate + normalize). */
|
|
396
|
+
interface CompileResult {
|
|
397
|
+
/** The normalized spec with all defaults applied. */
|
|
398
|
+
spec: NormalizedSpec;
|
|
399
|
+
/** Non-fatal warnings (e.g. type mismatches that were auto-corrected). */
|
|
400
|
+
warnings: string[];
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Internal normalized barlist spec type used by the compilation pipeline.
|
|
405
|
+
*/
|
|
406
|
+
|
|
407
|
+
interface NormalizedBarListSpec {
|
|
408
|
+
type: 'barlist';
|
|
409
|
+
data: DataRow[];
|
|
410
|
+
encoding: BarListEncoding;
|
|
411
|
+
barHeight: number;
|
|
412
|
+
cornerRadius: number | 'pill';
|
|
413
|
+
maxItems: number;
|
|
414
|
+
sort: 'descending' | 'ascending' | null;
|
|
415
|
+
height?: BarListSpec['height'];
|
|
416
|
+
annotations?: BarListSpec['annotations'];
|
|
417
|
+
labels?: BarListSpec['labels'];
|
|
418
|
+
a11y?: BarListSpec['a11y'];
|
|
419
|
+
chrome: NormalizedChrome;
|
|
420
|
+
theme: ThemeConfig;
|
|
421
|
+
watermark: boolean;
|
|
422
|
+
animation?: AnimationSpec;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Normalize a validated VizSpec, filling in all defaults.
|
|
427
|
+
*
|
|
428
|
+
* @param spec - A validated VizSpec (must pass validateSpec first).
|
|
429
|
+
* @param warnings - Mutable array to collect non-fatal warnings.
|
|
430
|
+
* @returns A NormalizedSpec with all optionals filled.
|
|
431
|
+
*/
|
|
432
|
+
declare function normalizeSpec(spec: VizSpec, warnings?: string[]): NormalizedSpec;
|
|
433
|
+
/**
|
|
434
|
+
* Recursively flatten a LayerSpec into leaf ChartSpecs.
|
|
435
|
+
* Merges parent data, encoding, and transforms down to children.
|
|
436
|
+
*/
|
|
437
|
+
declare function flattenLayers(spec: LayerSpec, parentData?: DataRow[], parentEncoding?: Encoding, parentTransforms?: _opendata_ai_openchart_core.Transform[], parentWatermark?: boolean, parentEndpointLabels?: boolean | _opendata_ai_openchart_core.EndpointLabelsConfig, parentFigure?: Pick<LayerSpec, 'display' | 'a11y' | 'frame' | 'labels'>): ChartSpec[];
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Graph animation resolver.
|
|
441
|
+
*
|
|
442
|
+
* Modeled on `compiler/animation.ts`. Like every visualization type, graphs
|
|
443
|
+
* animate by default.
|
|
444
|
+
*
|
|
445
|
+
* - `undefined` (omitted) or `true` -> full defaults
|
|
446
|
+
* - `false` -> undefined (no choreography; note `layout.warmup` still applies,
|
|
447
|
+
* resolved independently into SimulationConfig)
|
|
448
|
+
* - object -> per-phase resolution; a per-phase `false` -> that phase is `null`
|
|
449
|
+
*
|
|
450
|
+
* A phase with `spring` lasts `springDuration(spring)`. The enter `stagger` is
|
|
451
|
+
* on/off only: graphs order their reveal by layout, so the deprecated object
|
|
452
|
+
* form counts as `true`.
|
|
453
|
+
*
|
|
454
|
+
* `reheatAlpha` for the update impulse and the entrance `cameraFit` toggle are
|
|
455
|
+
* internal vanilla constants, not spec surface. Warmup is NOT part of this block
|
|
456
|
+
* (it lives in `layout`); `fitOnLoad` is a mount option.
|
|
457
|
+
*/
|
|
458
|
+
|
|
459
|
+
/** A resolved graph phase. `spring` is present only when authored; duration is then its settling time. */
|
|
460
|
+
interface ResolvedGraphPhase {
|
|
461
|
+
duration: number;
|
|
462
|
+
ease: AnimationEase;
|
|
463
|
+
spring?: SpringConfig;
|
|
464
|
+
}
|
|
465
|
+
/** Fully resolved graph animation config consumed by the vanilla adapter. */
|
|
466
|
+
interface ResolvedGraphAnimation {
|
|
467
|
+
/**
|
|
468
|
+
* Entrance reveal, or null if disabled. `cameraFit` flies the camera to the
|
|
469
|
+
* fit on load. `trigger` is when it starts (default 'visible').
|
|
470
|
+
*/
|
|
471
|
+
enter: (ResolvedGraphPhase & {
|
|
472
|
+
stagger: boolean;
|
|
473
|
+
cameraFit: boolean;
|
|
474
|
+
trigger: 'visible' | 'mount';
|
|
475
|
+
}) | null;
|
|
476
|
+
/** Data-update enter-fade for newly added marks, or null. */
|
|
477
|
+
update: ResolvedGraphPhase | null;
|
|
478
|
+
/** Ghost fade-out for removed marks, or null. */
|
|
479
|
+
exit: ResolvedGraphPhase | null;
|
|
480
|
+
/** Camera flight easing, or null. `'auto'` derives duration from zoom distance. */
|
|
481
|
+
camera: {
|
|
482
|
+
duration: number | 'auto';
|
|
483
|
+
ease: AnimationEase;
|
|
484
|
+
} | null;
|
|
485
|
+
/** Hover emphasis crossfade, or null. */
|
|
486
|
+
hover: {
|
|
487
|
+
duration: number;
|
|
488
|
+
ease: AnimationEase;
|
|
489
|
+
} | null;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Graph interaction resolver.
|
|
494
|
+
*
|
|
495
|
+
* Resolves `GraphInteractionConfig` into a flat, defaulted shape the vanilla
|
|
496
|
+
* adapter consumes. Category sets for `'category'` hover mode and
|
|
497
|
+
* `highlight({ category })` derive from the compilation's sort-resolved domains
|
|
498
|
+
* (not raw node data), so `getLegend()` and `highlight()` always agree.
|
|
499
|
+
*/
|
|
500
|
+
|
|
501
|
+
/** Hover emphasis behavior. */
|
|
502
|
+
type GraphHoverMode = 'neighbors' | 'category' | 'node' | 'none';
|
|
503
|
+
/** Fully resolved graph interaction config. */
|
|
504
|
+
interface ResolvedGraphInteraction {
|
|
505
|
+
/** Hover emphasis mode. Default `'neighbors'`. */
|
|
506
|
+
hoverMode: GraphHoverMode;
|
|
507
|
+
/** Node dim tier during hover/focus. Default 0.3. */
|
|
508
|
+
dimOpacity: number;
|
|
509
|
+
/** Whether selecting a node flies the camera to it. Default false. */
|
|
510
|
+
selectFlyTo: boolean;
|
|
511
|
+
/** Cursor repulsion config, or null if disabled. */
|
|
512
|
+
cursorRepulsion: {
|
|
513
|
+
radius: number;
|
|
514
|
+
strength: number;
|
|
515
|
+
} | null;
|
|
516
|
+
/** Whether springy node drag is enabled. Default false. */
|
|
517
|
+
springyDrag: boolean;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Graph compilation types.
|
|
522
|
+
*
|
|
523
|
+
* These types represent the engine output for graph specs. Unlike GraphLayout
|
|
524
|
+
* (which includes x/y positions for adapter rendering), GraphCompilation
|
|
525
|
+
* contains resolved visual properties WITHOUT positional layout. The force
|
|
526
|
+
* simulation in the adapter sets node positions at runtime.
|
|
527
|
+
*/
|
|
528
|
+
|
|
529
|
+
/** A compiled graph node with resolved visual properties (no x/y position). */
|
|
530
|
+
interface CompiledGraphNode {
|
|
531
|
+
/** Node identifier from the spec. */
|
|
532
|
+
id: string;
|
|
533
|
+
/** Computed radius from nodeSize encoding (3-20px range, default 5px). */
|
|
534
|
+
radius: number;
|
|
535
|
+
/** Computed fill color from nodeColor encoding or community assignment. */
|
|
536
|
+
fill: string;
|
|
537
|
+
/** Stroke color, slightly darker than fill. */
|
|
538
|
+
stroke: string;
|
|
539
|
+
/** Stroke width in pixels. Default 1. */
|
|
540
|
+
strokeWidth: number;
|
|
541
|
+
/** Label text from nodeLabel encoding or node id. */
|
|
542
|
+
label: string | undefined;
|
|
543
|
+
/** Label priority for level-of-detail rendering (0-1, degree/maxDegree). */
|
|
544
|
+
labelPriority: number;
|
|
545
|
+
/** Community/cluster assignment from the clustering field. */
|
|
546
|
+
community: string | undefined;
|
|
547
|
+
/** Opacity from the nodeOpacity encoding (default 1). Renderer multiplies into fill/stroke alpha. */
|
|
548
|
+
opacity: number;
|
|
549
|
+
/** Original node data (all fields from the spec node). */
|
|
550
|
+
data: Record<string, unknown>;
|
|
551
|
+
}
|
|
552
|
+
/** A compiled graph edge with resolved visual properties (no positional endpoints). */
|
|
553
|
+
interface CompiledGraphEdge {
|
|
554
|
+
/** Source node id. */
|
|
555
|
+
source: string;
|
|
556
|
+
/** Target node id. */
|
|
557
|
+
target: string;
|
|
558
|
+
/** Stroke color from edgeColor encoding or theme default. */
|
|
559
|
+
stroke: string;
|
|
560
|
+
/** Stroke width from edgeWidth encoding (0.5-4px range, default 1px). */
|
|
561
|
+
strokeWidth: number;
|
|
562
|
+
/** Line style. */
|
|
563
|
+
style: 'solid' | 'dashed' | 'dotted';
|
|
564
|
+
/** Original edge data (all fields from the spec edge). */
|
|
565
|
+
data: Record<string, unknown>;
|
|
566
|
+
}
|
|
567
|
+
/** Configuration for the force simulation, derived from the spec layout. */
|
|
568
|
+
interface SimulationConfig {
|
|
569
|
+
/** Repulsion strength between nodes. Negative = repulsion. */
|
|
570
|
+
chargeStrength: number;
|
|
571
|
+
/** Target distance between linked nodes. */
|
|
572
|
+
linkDistance: number;
|
|
573
|
+
/** Clustering configuration, or null if no clustering. */
|
|
574
|
+
clustering: {
|
|
575
|
+
field: string;
|
|
576
|
+
strength: number;
|
|
577
|
+
} | null;
|
|
578
|
+
/** How quickly the simulation cools. Default 0.0228. */
|
|
579
|
+
alphaDecay: number;
|
|
580
|
+
/** Velocity damping. Default 0.4. */
|
|
581
|
+
velocityDecay: number;
|
|
582
|
+
/** Collision radius: max node radius + padding. */
|
|
583
|
+
collisionRadius: number;
|
|
584
|
+
/** Extra px added to node radius for collision (default 2). */
|
|
585
|
+
collisionPadding?: number;
|
|
586
|
+
/** Link force strength override. */
|
|
587
|
+
linkStrength?: number;
|
|
588
|
+
/** Whether to apply center force (default true). */
|
|
589
|
+
centerForce?: boolean;
|
|
590
|
+
/** Deterministic layout seed (hashes into initial node positions). */
|
|
591
|
+
seed?: number;
|
|
592
|
+
/** Headless settle ticks run before first paint. 0/undefined disables warmup. */
|
|
593
|
+
warmupTicks?: number;
|
|
594
|
+
/** Wall-clock budget (ms) that caps warmup at scale. Default 250. */
|
|
595
|
+
warmupBudgetMs?: number;
|
|
596
|
+
/** Initial alpha for the simulation (update reheat / entrance). Default d3's 1. */
|
|
597
|
+
initialAlpha?: number;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* The complete engine output for graph specs.
|
|
601
|
+
*
|
|
602
|
+
* Contains resolved visual properties for nodes and edges, but does NOT
|
|
603
|
+
* include x/y positions. The adapter's force simulation assigns positions
|
|
604
|
+
* at runtime using the simulationConfig.
|
|
605
|
+
*/
|
|
606
|
+
interface GraphCompilation {
|
|
607
|
+
/** Compiled nodes with visual properties. */
|
|
608
|
+
nodes: CompiledGraphNode[];
|
|
609
|
+
/** Compiled edges with visual properties. */
|
|
610
|
+
edges: CompiledGraphEdge[];
|
|
611
|
+
/** Legend layout (community colors or nodeColor categories). */
|
|
612
|
+
legend: LegendLayout;
|
|
613
|
+
/** Resolved chrome text elements. */
|
|
614
|
+
chrome: ResolvedChrome;
|
|
615
|
+
/** Tooltip descriptors keyed by node id. */
|
|
616
|
+
tooltipDescriptors: Map<string, TooltipContent>;
|
|
617
|
+
/** Accessibility metadata. */
|
|
618
|
+
a11y: A11yMetadata;
|
|
619
|
+
/** Resolved theme used for rendering. */
|
|
620
|
+
theme: ResolvedTheme;
|
|
621
|
+
/** Total available dimensions. */
|
|
622
|
+
dimensions: {
|
|
623
|
+
width: number;
|
|
624
|
+
height: number;
|
|
518
625
|
};
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
626
|
+
/** Force simulation configuration. */
|
|
627
|
+
simulationConfig: SimulationConfig;
|
|
628
|
+
/** Whether to show the brand watermark. */
|
|
522
629
|
watermark: boolean;
|
|
523
|
-
animation
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
630
|
+
/** Resolved motion config, or undefined when `animation: false`. */
|
|
631
|
+
animation?: ResolvedGraphAnimation;
|
|
632
|
+
/** Resolved interaction config (always present, defaulted). */
|
|
633
|
+
interaction: ResolvedGraphInteraction;
|
|
634
|
+
/** The nodeColor field backing the legend/category emphasis, or null. */
|
|
635
|
+
legendField: string | null;
|
|
636
|
+
/** Categories to emphasize on load, captured from nodeColor.highlight. */
|
|
637
|
+
initialHighlight?: {
|
|
638
|
+
field: string;
|
|
639
|
+
values: string[];
|
|
528
640
|
};
|
|
529
|
-
/** Requested render dimensionality. Validated (and gated) in compileGraph. */
|
|
530
|
-
dimensions?: 2 | 3;
|
|
531
|
-
}
|
|
532
|
-
/** Discriminated union of all normalized spec types. */
|
|
533
|
-
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedGeoMapSpec | NormalizedBarListSpec | NormalizedRaceSpec;
|
|
534
|
-
/** Machine-readable error code for programmatic handling. */
|
|
535
|
-
type ValidationErrorCode = 'MISSING_FIELD' | 'INVALID_TYPE' | 'INVALID_VALUE' | 'ENCODING_MISMATCH' | 'DATA_FIELD_MISSING' | 'EMPTY_DATA';
|
|
536
|
-
/** A single validation error with context. */
|
|
537
|
-
interface ValidationError {
|
|
538
|
-
/** Error message describing what's wrong. */
|
|
539
|
-
message: string;
|
|
540
641
|
/**
|
|
541
|
-
*
|
|
542
|
-
*
|
|
642
|
+
* Ids exempt from highlight/filter dimming (currently just `spec.seedNode`).
|
|
643
|
+
* Empty when no seed is set. Array-shaped so a future `pinnedNodes` needs no
|
|
644
|
+
* type change.
|
|
543
645
|
*/
|
|
544
|
-
|
|
545
|
-
/**
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
/** Whether the spec is valid. */
|
|
553
|
-
valid: boolean;
|
|
554
|
-
/** Validation errors (empty if valid). */
|
|
555
|
-
errors: ValidationError[];
|
|
556
|
-
/** The validated spec cast to VizSpec, or null if invalid. */
|
|
557
|
-
normalized: _opendata_ai_openchart_core.VizSpec | null;
|
|
558
|
-
}
|
|
559
|
-
/** Result of the compile pipeline (validate + normalize). */
|
|
560
|
-
interface CompileResult {
|
|
561
|
-
/** The normalized spec with all defaults applied. */
|
|
562
|
-
spec: NormalizedSpec;
|
|
563
|
-
/** Non-fatal warnings (e.g. type mismatches that were auto-corrected). */
|
|
564
|
-
warnings: string[];
|
|
646
|
+
seedNodeIds: string[];
|
|
647
|
+
/** Edge legend entries (nominal edgeColor with >1 category), or undefined. */
|
|
648
|
+
edgeLegend?: LegendEntry[];
|
|
649
|
+
/**
|
|
650
|
+
* Resolved render dimensionality. `3` only when the spec asked for it AND the
|
|
651
|
+
* node count is within {@link MAX_3D_NODES}; otherwise `2`.
|
|
652
|
+
*/
|
|
653
|
+
numDimensions: 2 | 3;
|
|
565
654
|
}
|
|
655
|
+
/**
|
|
656
|
+
* Node ceiling for 3D rendering. The 3D simulation runs on the main thread, so
|
|
657
|
+
* a spec above this falls back to 2D with a warning rather than freezing the
|
|
658
|
+
* page.
|
|
659
|
+
*
|
|
660
|
+
* The number is measured, not guessed. On the RFC 27 gate rig (headed Chromium,
|
|
661
|
+
* ANGLE/Metal, 900x600, DPR 2) an idle 3,000-node / ~6,000-edge scene held
|
|
662
|
+
* 22-27fps against a 30fps floor, while 2,000 held 38-44fps. Every edge is a
|
|
663
|
+
* separate draw call, which is what the ceiling is really made of.
|
|
664
|
+
*/
|
|
665
|
+
declare const MAX_3D_NODES = 2000;
|
|
566
666
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
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)[]>;
|
|
667
|
+
/**
|
|
668
|
+
* The error type for data that cannot form a playback matrix. Spec problems go through
|
|
669
|
+
* validation instead; this covers what only the rows reveal.
|
|
670
|
+
*/
|
|
671
|
+
/** Codes for data that cannot form a playback matrix. */
|
|
672
|
+
type PlaybackDataErrorCode = 'DUPLICATE_KEY_PERIOD' | 'TOO_FEW_PERIODS' | 'NO_VALUES';
|
|
673
|
+
/** Data that cannot form a playback timeline. The race's `RaceDataError` extends it. */
|
|
674
|
+
declare class PlaybackDataError extends Error {
|
|
675
|
+
readonly code: PlaybackDataErrorCode;
|
|
676
|
+
readonly name: string;
|
|
677
|
+
constructor(code: PlaybackDataErrorCode, message: string, options?: ErrorOptions);
|
|
657
678
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
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[];
|
|
679
|
+
|
|
680
|
+
/** The race's name for playback data errors, so race callers keep their `instanceof` checks. */
|
|
681
|
+
|
|
682
|
+
/** Data that cannot form a race timeline. A `PlaybackDataError` with the race's name. */
|
|
683
|
+
declare class RaceDataError extends PlaybackDataError {
|
|
684
|
+
readonly name: string;
|
|
671
685
|
}
|
|
672
686
|
|
|
673
687
|
/**
|
|
@@ -694,7 +708,7 @@ declare function layoutRace(model: RaceModel, options: CompileOptions & {
|
|
|
694
708
|
|
|
695
709
|
/**
|
|
696
710
|
* Validate and prepare the size-independent race model.
|
|
697
|
-
* @throws {Error} Aggregated spec validation errors or a
|
|
711
|
+
* @throws {Error} Aggregated spec validation errors or a non-race spec.
|
|
698
712
|
* @throws {RaceDataError} Duplicate rows, too few periods, or no finite values.
|
|
699
713
|
* @throws {RangeError} The step multiplied by the period intervals overflows.
|
|
700
714
|
*/
|
|
@@ -1618,20 +1632,6 @@ declare const BOLD_SPAN_FONT_WEIGHT = 700;
|
|
|
1618
1632
|
*/
|
|
1619
1633
|
declare function parseAnnotationSpans(line: string): RichSpan[];
|
|
1620
1634
|
|
|
1621
|
-
/**
|
|
1622
|
-
* Normalize a validated VizSpec, filling in all defaults.
|
|
1623
|
-
*
|
|
1624
|
-
* @param spec - A validated VizSpec (must pass validateSpec first).
|
|
1625
|
-
* @param warnings - Mutable array to collect non-fatal warnings.
|
|
1626
|
-
* @returns A NormalizedSpec with all optionals filled.
|
|
1627
|
-
*/
|
|
1628
|
-
declare function normalizeSpec(spec: VizSpec, warnings?: string[]): NormalizedSpec;
|
|
1629
|
-
/**
|
|
1630
|
-
* Recursively flatten a LayerSpec into leaf ChartSpecs.
|
|
1631
|
-
* Merges parent data, encoding, and transforms down to children.
|
|
1632
|
-
*/
|
|
1633
|
-
declare function flattenLayers(spec: LayerSpec, parentData?: DataRow[], parentEncoding?: Encoding, parentTransforms?: _opendata_ai_openchart_core.Transform[], parentWatermark?: boolean, parentEndpointLabels?: boolean | _opendata_ai_openchart_core.EndpointLabelsConfig, parentFigure?: Pick<LayerSpec, 'display' | 'a11y' | 'frame' | 'labels'>): ChartSpec[];
|
|
1634
|
-
|
|
1635
1635
|
/** Validate authored mark contracts before any sugar transformation. */
|
|
1636
1636
|
declare function validateSpec(spec: unknown): ValidationResult;
|
|
1637
1637
|
|
|
@@ -1692,20 +1692,14 @@ type ChartRenderer = (spec: NormalizedChartSpec, scales: ResolvedScales, chartAr
|
|
|
1692
1692
|
*/
|
|
1693
1693
|
declare function registerChartRenderer(type: string, renderer: ChartRenderer): void;
|
|
1694
1694
|
/**
|
|
1695
|
-
* Get the registered chart renderer for a type.
|
|
1695
|
+
* Get the registered chart renderer for a type, installing missing built-ins on the first lookup.
|
|
1696
1696
|
*
|
|
1697
1697
|
* @param type - Chart type string.
|
|
1698
1698
|
* @returns The renderer, or undefined if no renderer is registered.
|
|
1699
1699
|
*/
|
|
1700
1700
|
declare function getChartRenderer(type: string): ChartRenderer | undefined;
|
|
1701
1701
|
/**
|
|
1702
|
-
* Clear all registered renderers
|
|
1703
|
-
*
|
|
1704
|
-
* Note: the built-in renderers (line, bar, column, ...) register as a
|
|
1705
|
-
* side-effect of importing `./builtin`. Once cleared, they do not come
|
|
1706
|
-
* back on their own — subsequent `compileChart(...)` calls will return
|
|
1707
|
-
* empty marks. Tests that call `clearRenderers()` should follow up with
|
|
1708
|
-
* `registerBuiltinRenderers()` from `./builtin` to restore the defaults.
|
|
1702
|
+
* Clear all registered renderers and skip lazy installation on later lookups.
|
|
1709
1703
|
*/
|
|
1710
1704
|
declare function clearRenderers(): void;
|
|
1711
1705
|
|