@opendata-ai/openchart-engine 9.0.0 → 9.1.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 +290 -135
- package/dist/index.js +3305 -390
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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,
|
|
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, 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';
|
|
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
|
|
11
|
-
*
|
|
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
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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';
|
|
@@ -227,112 +232,12 @@ interface GraphCompilation {
|
|
|
227
232
|
*/
|
|
228
233
|
declare const MAX_3D_NODES = 2000;
|
|
229
234
|
|
|
230
|
-
/**
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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).
|
|
241
|
-
*/
|
|
242
|
-
|
|
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;
|
|
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);
|
|
240
|
+
}
|
|
336
241
|
|
|
337
242
|
/** Shared area pivot/offset semantics for domain measurement and mark geometry. */
|
|
338
243
|
|
|
@@ -612,7 +517,7 @@ interface NormalizedGraphSpec {
|
|
|
612
517
|
dimensions?: 2 | 3;
|
|
613
518
|
}
|
|
614
519
|
/** Discriminated union of all normalized spec types. */
|
|
615
|
-
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedGeoMapSpec | NormalizedBarListSpec;
|
|
520
|
+
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedGeoMapSpec | NormalizedBarListSpec | NormalizedRaceSpec;
|
|
616
521
|
/** Machine-readable error code for programmatic handling. */
|
|
617
522
|
type ValidationErrorCode = 'MISSING_FIELD' | 'INVALID_TYPE' | 'INVALID_VALUE' | 'ENCODING_MISMATCH' | 'DATA_FIELD_MISSING' | 'EMPTY_DATA';
|
|
618
523
|
/** A single validation error with context. */
|
|
@@ -646,6 +551,250 @@ interface CompileResult {
|
|
|
646
551
|
warnings: string[];
|
|
647
552
|
}
|
|
648
553
|
|
|
554
|
+
interface NormalizedRaceSpec extends Omit<RaceSpec, 'mark' | 'encoding' | 'race' | 'chrome' | 'theme' | 'watermark'> {
|
|
555
|
+
mark: RaceMarkDef;
|
|
556
|
+
encoding: RaceEncoding & {
|
|
557
|
+
time: EncodingChannel;
|
|
558
|
+
key: EncodingChannel;
|
|
559
|
+
value: EncodingChannel;
|
|
560
|
+
};
|
|
561
|
+
race: ResolvedRaceOptions;
|
|
562
|
+
chrome: NormalizedChrome;
|
|
563
|
+
theme: ThemeConfig;
|
|
564
|
+
watermark: boolean;
|
|
565
|
+
}
|
|
566
|
+
interface ResolvedRaceOptions {
|
|
567
|
+
top: number;
|
|
568
|
+
duration?: number;
|
|
569
|
+
step?: number;
|
|
570
|
+
swap: number;
|
|
571
|
+
rescale: 'frame' | 'fixed' | {
|
|
572
|
+
min: number;
|
|
573
|
+
};
|
|
574
|
+
gaps: 'interpolate' | 'hold' | 'drop';
|
|
575
|
+
holdEnd: number;
|
|
576
|
+
loop: boolean;
|
|
577
|
+
autoplay: 'visible' | boolean;
|
|
578
|
+
controls: boolean;
|
|
579
|
+
period: false | {
|
|
580
|
+
format?: string;
|
|
581
|
+
};
|
|
582
|
+
summary: 'sum' | false;
|
|
583
|
+
}
|
|
584
|
+
interface RaceMatrix {
|
|
585
|
+
/** Sorted ascending. Dates become ISO strings. */
|
|
586
|
+
periods: Array<{
|
|
587
|
+
value: string | number;
|
|
588
|
+
sortKey: number;
|
|
589
|
+
}>;
|
|
590
|
+
/** Sorted by localeCompare with locale 'en'. Index order is the final tie-break. */
|
|
591
|
+
keys: string[];
|
|
592
|
+
/** Last non-null label value per key, or the key itself. */
|
|
593
|
+
labels: string[];
|
|
594
|
+
/** Last non-null color field value per key. Null when color is not a field. */
|
|
595
|
+
colorValues: Array<string | null>;
|
|
596
|
+
/** One array per key, with one value per period. NaN represents absence. */
|
|
597
|
+
values: Float64Array[];
|
|
598
|
+
}
|
|
599
|
+
interface RaceSampleItem {
|
|
600
|
+
keyIndex: number;
|
|
601
|
+
value: number;
|
|
602
|
+
rank: number;
|
|
603
|
+
rankPos: number;
|
|
604
|
+
opacity: number;
|
|
605
|
+
change: number;
|
|
606
|
+
}
|
|
607
|
+
interface RaceSample {
|
|
608
|
+
t: number;
|
|
609
|
+
periodIndex: number;
|
|
610
|
+
items: RaceSampleItem[];
|
|
611
|
+
domainMin: number;
|
|
612
|
+
domainMax: number;
|
|
613
|
+
}
|
|
614
|
+
interface RaceTimeline {
|
|
615
|
+
readonly periodCount: number;
|
|
616
|
+
readonly keyCount: number;
|
|
617
|
+
readonly top: number;
|
|
618
|
+
/** Number of rank samples per period interval. */
|
|
619
|
+
readonly samplesPerPeriod: number;
|
|
620
|
+
/** NaN when absent. */
|
|
621
|
+
valueAt(keyIndex: number, t: number): number;
|
|
622
|
+
/** Smoothed rank in [0, top]. */
|
|
623
|
+
rankPos(keyIndex: number, t: number): number;
|
|
624
|
+
/** Present key indices in exact rank order. */
|
|
625
|
+
ranked(t: number): number[];
|
|
626
|
+
/** Zero-based rank among present keys. Infinity when absent. */
|
|
627
|
+
exactRank(keyIndex: number, t: number): number;
|
|
628
|
+
/** Cached exact rank at an integer period index. Infinity when absent. */
|
|
629
|
+
periodRank(keyIndex: number, period: number): number;
|
|
630
|
+
/** Exact and smoothed ranks on the sample grid. A missing exact rank equals keyCount. */
|
|
631
|
+
rankSamples(keyIndex: number): {
|
|
632
|
+
exact: Readonly<Float32Array>;
|
|
633
|
+
smoothed: Readonly<Float32Array>;
|
|
634
|
+
};
|
|
635
|
+
/** Items with rankPos < top, sorted by rankPos. */
|
|
636
|
+
sample(t: number): RaceSample;
|
|
637
|
+
}
|
|
638
|
+
interface RaceColorAssignment {
|
|
639
|
+
slotsFor(paletteSize: number): readonly (number | string)[];
|
|
640
|
+
/** Assignments already used by a spec or layout, available to carry across updates. */
|
|
641
|
+
readonly byPaletteSize: ReadonlyMap<number, readonly (number | string)[]>;
|
|
642
|
+
}
|
|
643
|
+
interface RaceModel {
|
|
644
|
+
spec: NormalizedRaceSpec;
|
|
645
|
+
/** Authored watermark setting, before normalization supplies a default. */
|
|
646
|
+
specWatermark?: boolean;
|
|
647
|
+
matrix: RaceMatrix;
|
|
648
|
+
timeline: RaceTimeline;
|
|
649
|
+
colorAssignment: RaceColorAssignment;
|
|
650
|
+
/** Spec-theme light colors for standalone frames. On-screen geometry uses layout.colors. */
|
|
651
|
+
frameColors: string[];
|
|
652
|
+
periodLabels: string[];
|
|
653
|
+
formatValue: (value: number) => string;
|
|
654
|
+
playback: RacePlayback;
|
|
655
|
+
warnings: string[];
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Return a standalone frame with the prepared spec-theme colors and full labels.
|
|
660
|
+
* Finite times outside the race clamp to its endpoints.
|
|
661
|
+
* @throws {RangeError} The frame time is not finite.
|
|
662
|
+
*/
|
|
663
|
+
declare function raceFrameAt(model: RaceModel, t: number): RaceFrame;
|
|
664
|
+
/**
|
|
665
|
+
* Build on-screen geometry with `layout.colors` and fitted labels.
|
|
666
|
+
* Finite times outside the race clamp to its endpoints.
|
|
667
|
+
* @throws {RangeError} The frame time is not finite.
|
|
668
|
+
* @throws {Error} The layout mark is unregistered.
|
|
669
|
+
*/
|
|
670
|
+
declare function raceGeometryAt(model: RaceModel, layout: RaceLayout, t: number): RaceGeometry;
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Resolve the race layout for the requested size and theme. An explicit mark overrides the spec's.
|
|
674
|
+
* @throws {Error} The selected mark is unregistered.
|
|
675
|
+
*/
|
|
676
|
+
declare function layoutRace(model: RaceModel, options: CompileOptions & {
|
|
677
|
+
mark?: RaceMarkDef;
|
|
678
|
+
}): RaceLayout;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Validate and prepare the size-independent race model.
|
|
682
|
+
* @throws {Error} Aggregated spec validation errors or a valid non-race spec.
|
|
683
|
+
* @throws {RaceDataError} Duplicate rows, too few periods, or no finite values.
|
|
684
|
+
* @throws {RangeError} The step multiplied by the period intervals overflows.
|
|
685
|
+
*/
|
|
686
|
+
declare function prepareRace(spec: unknown, options: {
|
|
687
|
+
onWarn?: (w: CompileWarning) => void;
|
|
688
|
+
previousModel?: RaceModel;
|
|
689
|
+
}): RaceModel;
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Main compile API: the public entry points for the engine.
|
|
693
|
+
*
|
|
694
|
+
* Pipeline for charts (see ./compile/chart.ts for the phases):
|
|
695
|
+
* validate spec -> normalize -> resolve theme -> dark mode adapt ->
|
|
696
|
+
* filter data -> resolveLayoutPlan (measure real labels) ->
|
|
697
|
+
* compute dimensions (with plan) -> placeLegend ->
|
|
698
|
+
* compute scales -> compute axes (with pinned ticks) -> compute gridlines ->
|
|
699
|
+
* get chart renderer -> compute marks -> compute a11y -> return ChartLayout
|
|
700
|
+
*
|
|
701
|
+
* Table compiler handles full data pipeline (sort, search, pagination, visual enhancements).
|
|
702
|
+
*/
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Compile a chart spec into a ChartLayout.
|
|
706
|
+
*
|
|
707
|
+
* This is the main engine entry point. Takes a raw spec (any shape,
|
|
708
|
+
* validated at runtime) and compile options, produces a fully resolved
|
|
709
|
+
* ChartLayout with positions, colors, and marks ready for rendering.
|
|
710
|
+
*
|
|
711
|
+
* @param spec - Raw chart spec (validated and normalized internally).
|
|
712
|
+
* @param optionsInput - Compile options (width, height, theme, darkMode).
|
|
713
|
+
* Top-level spec width/height, when present, override the option values.
|
|
714
|
+
* @returns ChartLayout with all computed positions.
|
|
715
|
+
* @throws Error if spec is invalid or not a chart type.
|
|
716
|
+
*/
|
|
717
|
+
declare function compileChart(spec: unknown, optionsInput: CompileOptions): ChartLayout;
|
|
718
|
+
declare function compileLayer(spec: LayerSpec, options: CompileOptions): ChartLayout;
|
|
719
|
+
/**
|
|
720
|
+
* Compile a table spec into a TableLayout.
|
|
721
|
+
*
|
|
722
|
+
* Validates and normalizes the spec, resolves the theme, then delegates
|
|
723
|
+
* to compileTableLayout for the full pipeline: column resolution, search,
|
|
724
|
+
* sort, pagination, cell formatting, and visual enhancements.
|
|
725
|
+
*
|
|
726
|
+
* @param spec - Raw table spec.
|
|
727
|
+
* @param options - Compile options with sort, search, pagination state.
|
|
728
|
+
* @returns Fully resolved TableLayout.
|
|
729
|
+
*/
|
|
730
|
+
declare function compileTable(spec: unknown, options: CompileTableOptions): TableLayout;
|
|
731
|
+
/**
|
|
732
|
+
* Compile a graph spec into a GraphCompilation.
|
|
733
|
+
*
|
|
734
|
+
* The graph pipeline resolves visual properties (size, color, stroke) for
|
|
735
|
+
* nodes and edges, assigns communities, and builds legend/tooltip/a11y data.
|
|
736
|
+
* Unlike charts, the output does NOT include x/y positions since the force
|
|
737
|
+
* simulation in the adapter handles layout at runtime.
|
|
738
|
+
*
|
|
739
|
+
* @param spec - Raw graph spec (validated and normalized internally).
|
|
740
|
+
* @param options - Compile options (width, height, theme, darkMode).
|
|
741
|
+
* @returns GraphCompilation with resolved visual properties and simulation config.
|
|
742
|
+
* @throws Error if spec is invalid or not a graph type.
|
|
743
|
+
*/
|
|
744
|
+
declare function compileGraph(spec: unknown, options: CompileOptions): GraphCompilation;
|
|
745
|
+
/**
|
|
746
|
+
* Compile a sankey spec into a SankeyLayout.
|
|
747
|
+
*
|
|
748
|
+
* Takes a raw sankey spec, validates, normalizes, resolves theme and chrome,
|
|
749
|
+
* runs the d3-sankey layout algorithm, builds node/link marks with colors and
|
|
750
|
+
* labels, and returns a SankeyLayout ready for rendering.
|
|
751
|
+
*
|
|
752
|
+
* @param spec - Raw sankey spec (validated and normalized internally).
|
|
753
|
+
* @param options - Compile options (width, height, theme, darkMode).
|
|
754
|
+
* @returns SankeyLayout with computed positions and visual properties.
|
|
755
|
+
* @throws Error if spec is invalid or not a sankey type.
|
|
756
|
+
*/
|
|
757
|
+
declare function compileSankey(spec: unknown, options: CompileOptions): SankeyLayout;
|
|
758
|
+
/**
|
|
759
|
+
* Compile a tilemap spec into a TileMapLayout.
|
|
760
|
+
*
|
|
761
|
+
* Takes a raw tilemap spec, validates, normalizes, resolves theme and chrome,
|
|
762
|
+
* computes tile positions, builds tile marks with colors and labels, and
|
|
763
|
+
* returns a TileMapLayout ready for rendering.
|
|
764
|
+
*
|
|
765
|
+
* @param spec - Raw tilemap spec (validated and normalized internally).
|
|
766
|
+
* @param options - Compile options (width, height, theme, darkMode).
|
|
767
|
+
* @returns TileMapLayout with computed positions and visual properties.
|
|
768
|
+
* @throws Error if spec is invalid or not a tilemap type.
|
|
769
|
+
*/
|
|
770
|
+
declare function compileTileMap(spec: unknown, options: CompileOptions): TileMapLayout;
|
|
771
|
+
/**
|
|
772
|
+
* Compile a map spec into a GeoMapLayout.
|
|
773
|
+
*
|
|
774
|
+
* Takes a raw map spec, validates, normalizes, resolves theme and chrome,
|
|
775
|
+
* projects geo features, joins data, builds feature marks with color fills,
|
|
776
|
+
* and returns a GeoMapLayout ready for rendering.
|
|
777
|
+
*
|
|
778
|
+
* @param spec - Raw map spec (validated and normalized internally).
|
|
779
|
+
* @param options - Compile options (width, height, theme, darkMode).
|
|
780
|
+
* @returns GeoMapLayout with computed positions and visual properties.
|
|
781
|
+
* @throws Error if spec is invalid or not a map type.
|
|
782
|
+
*/
|
|
783
|
+
declare function compileGeoMap(spec: unknown, options: CompileOptions): GeoMapLayout;
|
|
784
|
+
/**
|
|
785
|
+
* Compile a barlist spec into a BarListLayout.
|
|
786
|
+
*
|
|
787
|
+
* Takes a raw barlist spec, validates, normalizes, resolves theme and chrome,
|
|
788
|
+
* computes row layout with proportional bars, builds tooltips, and returns
|
|
789
|
+
* a BarListLayout ready for rendering.
|
|
790
|
+
*
|
|
791
|
+
* @param spec - Raw barlist spec (validated and normalized internally).
|
|
792
|
+
* @param options - Compile options (width, height, theme, darkMode).
|
|
793
|
+
* @returns BarListLayout with computed positions and visual properties.
|
|
794
|
+
* @throws Error if spec is invalid or not a barlist type.
|
|
795
|
+
*/
|
|
796
|
+
declare function compileBarList(spec: unknown, options: CompileOptions): BarListLayout;
|
|
797
|
+
|
|
649
798
|
/** Default font size for annotation labels. */
|
|
650
799
|
declare const DEFAULT_ANNOTATION_FONT_SIZE = 13;
|
|
651
800
|
/** Default line height multiplier for annotation text. */
|
|
@@ -817,13 +966,19 @@ declare function resolveLayerTheme(layerSpec: LayerSpec, primary?: ChartSpec): _
|
|
|
817
966
|
*/
|
|
818
967
|
declare function buildEdgeTooltip(edge: CompiledGraphEdge): TooltipContent;
|
|
819
968
|
|
|
969
|
+
/** Read up to three leaders for a live announcement, including any hidden by a transition. */
|
|
970
|
+
declare function raceA11yLeaders(model: RaceModel, t: number): string[];
|
|
971
|
+
/** Build the size-independent description and period table once per prepared model. */
|
|
972
|
+
declare function raceA11y(model: RaceModel): A11yMetadata;
|
|
973
|
+
|
|
820
974
|
/**
|
|
821
975
|
* Animation resolver: normalizes AnimationSpec into fully resolved config.
|
|
822
976
|
*
|
|
823
977
|
* Handles the shorthand forms:
|
|
824
|
-
* - true -> all three phases with defaults
|
|
978
|
+
* - true/undefined -> all three phases with defaults (animation is on by
|
|
979
|
+
* default; omitting the field is the same as `true`)
|
|
825
980
|
* - { enter: { duration: 800 } } -> merge with defaults per phase
|
|
826
|
-
* - false
|
|
981
|
+
* - false -> undefined (no animation)
|
|
827
982
|
*
|
|
828
983
|
* Each phase resolves independently:
|
|
829
984
|
* - true/config-object -> resolved phase merged onto that phase's defaults
|
|
@@ -837,17 +992,17 @@ declare function buildEdgeTooltip(edge: CompiledGraphEdge): TooltipContent;
|
|
|
837
992
|
declare const ENTER_DEFAULTS: ResolvedAnimationPhase;
|
|
838
993
|
/** Default values for update (data transition) animation. */
|
|
839
994
|
declare const UPDATE_DEFAULTS: ResolvedAnimationPhase;
|
|
840
|
-
/**
|
|
995
|
+
/**
|
|
996
|
+
* Default values for exit animation: a quick fade that clears before survivors
|
|
997
|
+
* move into the removed mark's slot (choreography's EXIT_FADE_MS/EXIT_CURVE).
|
|
998
|
+
*/
|
|
841
999
|
declare const EXIT_DEFAULTS: ResolvedAnimationPhase;
|
|
842
1000
|
/**
|
|
843
1001
|
* Resolve an AnimationSpec into a fully resolved config with all defaults filled.
|
|
844
|
-
*
|
|
1002
|
+
* Omitted behaves like `true` (animation is on by default); returns undefined
|
|
1003
|
+
* only when animation is disabled (`false`, or every phase set to false).
|
|
845
1004
|
*/
|
|
846
1005
|
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
1006
|
|
|
852
1007
|
/**
|
|
853
1008
|
* Mark key utilities for data-update transitions.
|
|
@@ -1430,4 +1585,4 @@ declare function migrateSpecV8<T>(input: T, options?: {
|
|
|
1430
1585
|
/** Author order and supplementary fields survive; formatted text never decides identity. */
|
|
1431
1586
|
declare function sharedTooltipFields(content: TooltipContent): TooltipField[];
|
|
1432
1587
|
|
|
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,
|
|
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 };
|