@opendata-ai/openchart-engine 8.9.0 → 9.0.0-rc.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 +429 -203
- package/dist/index.js +24607 -17267
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _opendata_ai_openchart_core from '@opendata-ai/openchart-core';
|
|
2
|
-
import { AnimationEase, LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, LegendEntry, CompileOptions,
|
|
2
|
+
import { AnimationEase, LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, LegendEntry, CompileOptions, BarListLayout, ChartLayout, GeoMapLayout, LayerSpec, SankeyLayout, CompileTableOptions, TableLayout, TileMapLayout, DataRow, BarListEncoding, ThemeConfig, AnimationSpec, GeoMapGeo, GeoMapProjection, GeoMapEncoding, LegendConfig, GeoMapPointsLayer, FieldMetadata, GeoCallout, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, TileMapEncoding, TileMapPalette, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, TableDensity, SortState, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, GraphAnimationSpec, GraphInteractionConfig, ResolvedLabel, Rect, ResolvedAnnotation, ChartSpec, ResolvedAnimationPhase, ResolvedAnimation, Point, ScaleType, EncodingChannel, 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
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';
|
|
4
|
+
import { Series } from 'd3-shape';
|
|
4
5
|
import { ScaleLinear, ScaleTime, ScaleLogarithmic, ScalePower, ScaleSymLog, ScaleBand, ScalePoint, ScaleOrdinal, ScaleQuantile, ScaleQuantize, ScaleThreshold } from 'd3-scale';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -226,6 +227,19 @@ interface GraphCompilation {
|
|
|
226
227
|
*/
|
|
227
228
|
declare const MAX_3D_NODES = 2000;
|
|
228
229
|
|
|
230
|
+
/**
|
|
231
|
+
* Main compile API: the public entry points for the engine.
|
|
232
|
+
*
|
|
233
|
+
* Pipeline for charts (see ./compile/chart.ts for the phases):
|
|
234
|
+
* validate spec -> normalize -> resolve theme -> dark mode adapt ->
|
|
235
|
+
* filter data -> resolveLayoutPlan (measure real labels) ->
|
|
236
|
+
* compute dimensions (with plan) -> placeLegend ->
|
|
237
|
+
* compute scales -> compute axes (with pinned ticks) -> compute gridlines ->
|
|
238
|
+
* get chart renderer -> compute marks -> compute a11y -> return ChartLayout
|
|
239
|
+
*
|
|
240
|
+
* Table compiler handles full data pipeline (sort, search, pagination, visual enhancements).
|
|
241
|
+
*/
|
|
242
|
+
|
|
229
243
|
/**
|
|
230
244
|
* Compile a chart spec into a ChartLayout.
|
|
231
245
|
*
|
|
@@ -279,7 +293,7 @@ declare function compileGraph(spec: unknown, options: CompileOptions): GraphComp
|
|
|
279
293
|
* @returns SankeyLayout with computed positions and visual properties.
|
|
280
294
|
* @throws Error if spec is invalid or not a sankey type.
|
|
281
295
|
*/
|
|
282
|
-
declare function compileSankey(spec: unknown, options: CompileOptions):
|
|
296
|
+
declare function compileSankey(spec: unknown, options: CompileOptions): SankeyLayout;
|
|
283
297
|
/**
|
|
284
298
|
* Compile a tilemap spec into a TileMapLayout.
|
|
285
299
|
*
|
|
@@ -292,7 +306,7 @@ declare function compileSankey(spec: unknown, options: CompileOptions): _opendat
|
|
|
292
306
|
* @returns TileMapLayout with computed positions and visual properties.
|
|
293
307
|
* @throws Error if spec is invalid or not a tilemap type.
|
|
294
308
|
*/
|
|
295
|
-
declare function compileTileMap(spec: unknown, options: CompileOptions):
|
|
309
|
+
declare function compileTileMap(spec: unknown, options: CompileOptions): TileMapLayout;
|
|
296
310
|
/**
|
|
297
311
|
* Compile a map spec into a GeoMapLayout.
|
|
298
312
|
*
|
|
@@ -305,7 +319,7 @@ declare function compileTileMap(spec: unknown, options: CompileOptions): _openda
|
|
|
305
319
|
* @returns GeoMapLayout with computed positions and visual properties.
|
|
306
320
|
* @throws Error if spec is invalid or not a map type.
|
|
307
321
|
*/
|
|
308
|
-
declare function compileGeoMap(spec: unknown, options: CompileOptions):
|
|
322
|
+
declare function compileGeoMap(spec: unknown, options: CompileOptions): GeoMapLayout;
|
|
309
323
|
/**
|
|
310
324
|
* Compile a barlist spec into a BarListLayout.
|
|
311
325
|
*
|
|
@@ -318,103 +332,18 @@ declare function compileGeoMap(spec: unknown, options: CompileOptions): _opendat
|
|
|
318
332
|
* @returns BarListLayout with computed positions and visual properties.
|
|
319
333
|
* @throws Error if spec is invalid or not a barlist type.
|
|
320
334
|
*/
|
|
321
|
-
declare function compileBarList(spec: unknown, options: CompileOptions):
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* Graph compilation pipeline.
|
|
325
|
-
*
|
|
326
|
-
* Takes a raw graph spec (unknown shape), validates, normalizes, resolves
|
|
327
|
-
* encoding channels to visual properties, assigns communities, builds
|
|
328
|
-
* legend/tooltips/a11y, and returns a GraphCompilation.
|
|
329
|
-
*
|
|
330
|
-
* The pipeline mirrors compileChart's structure:
|
|
331
|
-
* validate -> normalize -> resolve theme -> resolve visuals ->
|
|
332
|
-
* community assignment -> legend -> tooltips -> a11y -> return
|
|
333
|
-
*
|
|
334
|
-
* Key difference from charts: the output does NOT include x/y positions.
|
|
335
|
-
* The force simulation in the adapter handles layout at runtime.
|
|
336
|
-
*/
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Build a tooltip for a single edge, on demand.
|
|
340
|
-
*
|
|
341
|
-
* Construction is LAZY (called for the one hovered edge), not an eager O(E)
|
|
342
|
-
* descriptor map — edges outnumber nodes 5–10× and an eager map on every
|
|
343
|
-
* compile (including updateVisuals) would be pure bloat. Shows source → target
|
|
344
|
-
* and all non-structural data fields.
|
|
345
|
-
*/
|
|
346
|
-
declare function buildEdgeTooltip(edge: CompiledGraphEdge): TooltipContent;
|
|
335
|
+
declare function compileBarList(spec: unknown, options: CompileOptions): BarListLayout;
|
|
347
336
|
|
|
348
|
-
/**
|
|
349
|
-
* Animation resolver: normalizes AnimationSpec into fully resolved config.
|
|
350
|
-
*
|
|
351
|
-
* Handles the shorthand forms:
|
|
352
|
-
* - true -> all three phases with defaults
|
|
353
|
-
* - { enter: { duration: 800 } } -> merge with defaults per phase
|
|
354
|
-
* - false/undefined -> undefined (no animation)
|
|
355
|
-
*
|
|
356
|
-
* Each phase resolves independently:
|
|
357
|
-
* - true/config-object -> resolved phase merged onto that phase's defaults
|
|
358
|
-
* - false -> phase absent
|
|
359
|
-
* - undefined -> phase present with defaults (animation: {} behaves like true)
|
|
360
|
-
*
|
|
361
|
-
* Returns undefined only when ALL phases resolve absent.
|
|
362
|
-
*/
|
|
337
|
+
/** Shared area pivot/offset semantics for domain measurement and mark geometry. */
|
|
363
338
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
|
|
372
|
-
* Returns undefined if animation is disabled (false or omitted).
|
|
373
|
-
*/
|
|
374
|
-
declare function resolveAnimation(spec: AnimationSpec | undefined): ResolvedAnimation | undefined;
|
|
375
|
-
/**
|
|
376
|
-
* Clamp stagger delay so total stagger time doesn't exceed MAX_TOTAL_STAGGER_MS.
|
|
377
|
-
*/
|
|
378
|
-
declare function clampStaggerDelay(delay: number, elementCount: number): number;
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Mark key utilities for data-update transitions.
|
|
382
|
-
*
|
|
383
|
-
* Keys uniquely identify marks across data updates so the renderer can
|
|
384
|
-
* match old marks to new marks and animate the difference. Each chart
|
|
385
|
-
* type stamps keys during its compute phase; these helpers provide the
|
|
386
|
-
* shared serialization and deduplication logic.
|
|
387
|
-
*/
|
|
388
|
-
/**
|
|
389
|
-
* Serialize a datum value into a stable key fragment.
|
|
390
|
-
* - Date -> epoch ms string (avoids locale-dependent Date.toString)
|
|
391
|
-
* - number/string/boolean -> String(v)
|
|
392
|
-
* - null/undefined -> null sentinel
|
|
393
|
-
*/
|
|
394
|
-
declare function serializeKeyValue(v: unknown): string;
|
|
395
|
-
declare function dedupeKeys(keys: string[]): string[];
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Curve interpolation mapping and path builders.
|
|
399
|
-
*
|
|
400
|
-
* Maps Vega-Lite-style interpolation strings to d3-shape curve factories.
|
|
401
|
-
* Used by both line and area chart computations.
|
|
402
|
-
*
|
|
403
|
-
* Also exports pure path-builder helpers (`buildLinePath`, `buildAreaPath`)
|
|
404
|
-
* so downstream consumers (e.g. transition interpolators) can reconstruct
|
|
405
|
-
* SVG paths from point arrays without pulling in chart-specific code.
|
|
406
|
-
*/
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Build an SVG path string from an array of points using d3 line generator.
|
|
410
|
-
* Accepts an optional interpolation string (defaults to 'monotone').
|
|
411
|
-
*/
|
|
412
|
-
declare function buildLinePath(points: Point[], interpolate?: string): string;
|
|
413
|
-
/**
|
|
414
|
-
* Build an SVG path string for a filled area from top and bottom point arrays.
|
|
415
|
-
* Accepts an optional interpolation string (defaults to 'monotone').
|
|
416
|
-
*/
|
|
417
|
-
declare function buildAreaPath(topPoints: Point[], bottomPoints: Point[], interpolate?: string): string;
|
|
339
|
+
interface AreaStackGeometry {
|
|
340
|
+
stackedData: Series<Record<string, unknown>, string>[];
|
|
341
|
+
rowsByXSeries: Map<string, DataRow>;
|
|
342
|
+
missingBoundaries: Set<string>;
|
|
343
|
+
extent: [number, number];
|
|
344
|
+
}
|
|
345
|
+
/** Created per compilation; never retained by a module or an authored input. */
|
|
346
|
+
type AreaStackCache = WeakMap<DataRow[], Map<string, AreaStackGeometry>>;
|
|
418
347
|
|
|
419
348
|
/**
|
|
420
349
|
* Internal normalized barlist spec type used by the compilation pipeline.
|
|
@@ -429,27 +358,30 @@ interface NormalizedBarListSpec {
|
|
|
429
358
|
maxItems: number;
|
|
430
359
|
chrome: NormalizedChrome;
|
|
431
360
|
theme: ThemeConfig;
|
|
432
|
-
darkMode: DarkMode;
|
|
433
361
|
watermark: boolean;
|
|
434
362
|
animation?: AnimationSpec;
|
|
435
|
-
valueFormat?: string;
|
|
436
363
|
}
|
|
437
364
|
|
|
438
365
|
interface NormalizedGeoMapSpec {
|
|
439
366
|
type: 'map';
|
|
440
|
-
geo: Required<
|
|
367
|
+
geo: Required<Pick<GeoMapGeo, 'features' | 'idField' | 'focus'>> & Omit<GeoMapGeo, 'features' | 'idField' | 'focus'> & {
|
|
441
368
|
projection?: GeoMapProjection;
|
|
369
|
+
zoom?: GeoMapGeo['zoom'];
|
|
442
370
|
};
|
|
443
371
|
data: Record<string, unknown>[];
|
|
444
372
|
encoding: GeoMapEncoding;
|
|
445
373
|
chrome: NormalizedChrome;
|
|
446
374
|
legend?: LegendConfig;
|
|
447
375
|
theme: ThemeConfig;
|
|
448
|
-
darkMode: DarkMode;
|
|
449
376
|
watermark: boolean;
|
|
450
377
|
animation?: AnimationSpec;
|
|
451
|
-
valueFormat?: string;
|
|
452
378
|
points?: GeoMapPointsLayer;
|
|
379
|
+
fields?: Record<string, FieldMetadata>;
|
|
380
|
+
callouts?: GeoCallout[];
|
|
381
|
+
colorKey?: {
|
|
382
|
+
activeValue?: boolean;
|
|
383
|
+
distribution?: boolean;
|
|
384
|
+
};
|
|
453
385
|
}
|
|
454
386
|
|
|
455
387
|
/**
|
|
@@ -475,10 +407,8 @@ interface NormalizedSankeySpec {
|
|
|
475
407
|
chrome: NormalizedChrome;
|
|
476
408
|
legend?: LegendConfig;
|
|
477
409
|
theme: ThemeConfig;
|
|
478
|
-
darkMode: DarkMode;
|
|
479
410
|
watermark: boolean;
|
|
480
411
|
animation?: AnimationSpec;
|
|
481
|
-
valueFormat?: string;
|
|
482
412
|
linkOpacity?: number;
|
|
483
413
|
other?: number | {
|
|
484
414
|
threshold: number;
|
|
@@ -503,7 +433,6 @@ interface NormalizedTileMapSpec {
|
|
|
503
433
|
chrome: NormalizedChrome;
|
|
504
434
|
legend?: LegendConfig;
|
|
505
435
|
theme: ThemeConfig;
|
|
506
|
-
darkMode: DarkMode;
|
|
507
436
|
watermark: boolean;
|
|
508
437
|
animation?: AnimationSpec;
|
|
509
438
|
valueFormat?: string;
|
|
@@ -549,13 +478,24 @@ interface UserExplicit {
|
|
|
549
478
|
/** True if user wrote `crosshair`. */
|
|
550
479
|
crosshair: boolean;
|
|
551
480
|
}
|
|
481
|
+
/** Internal renderer configuration: sugar can change the mark type while
|
|
482
|
+
* retaining visual options. Keep this wide shape outside the authored contract. */
|
|
483
|
+
type UnionKeys<T> = T extends unknown ? keyof T : never;
|
|
484
|
+
type UnionValue<T, K extends PropertyKey> = T extends unknown ? K extends keyof T ? T[K] : never : never;
|
|
485
|
+
type NormalizedMarkDef = {
|
|
486
|
+
type: MarkType;
|
|
487
|
+
} & {
|
|
488
|
+
[K in Exclude<UnionKeys<MarkDef>, 'type'>]?: UnionValue<MarkDef, K>;
|
|
489
|
+
};
|
|
552
490
|
/** A ChartSpec with all optional fields filled with sensible defaults. */
|
|
553
491
|
interface NormalizedChartSpec {
|
|
554
492
|
/** Resolved mark type string (extracted from spec.mark). */
|
|
555
493
|
markType: MarkType;
|
|
556
494
|
/** Resolved mark definition with defaults filled in. */
|
|
557
|
-
markDef:
|
|
495
|
+
markDef: NormalizedMarkDef;
|
|
558
496
|
data: DataRow[];
|
|
497
|
+
/** @internal Compile-local stack reuse; never authored or emitted in a layout. */
|
|
498
|
+
areaStackCache?: AreaStackCache;
|
|
559
499
|
encoding: Encoding;
|
|
560
500
|
chrome: NormalizedChrome;
|
|
561
501
|
/**
|
|
@@ -564,7 +504,7 @@ interface NormalizedChartSpec {
|
|
|
564
504
|
* `'subtract'` (default) shrinks the plot to fit chrome. Carried through from
|
|
565
505
|
* the spec so the layout pipeline can honor it.
|
|
566
506
|
*/
|
|
567
|
-
chromeLayout
|
|
507
|
+
chromeLayout: 'subtract' | 'grow' | 'notes';
|
|
568
508
|
/** Optional KPI metric cells, passed through unchanged. */
|
|
569
509
|
metrics?: _opendata_ai_openchart_core.Metric[];
|
|
570
510
|
/**
|
|
@@ -576,7 +516,7 @@ interface NormalizedChartSpec {
|
|
|
576
516
|
youDrawIt?: _opendata_ai_openchart_core.YouDrawItConfig;
|
|
577
517
|
annotations: Annotation[];
|
|
578
518
|
/** Normalized label configuration with defaults applied. density, format, and prefix are always set; offsets and color stay optional. */
|
|
579
|
-
labels: Required<Pick<LabelConfig, 'density' | 'format' | 'prefix'>> & Pick<LabelConfig, '
|
|
519
|
+
labels: Required<Pick<LabelConfig, 'density' | 'format' | 'prefix'>> & Pick<LabelConfig, 'color' | 'fontSize' | 'suffix' | 'placement'>;
|
|
580
520
|
/** Legend configuration (position override). */
|
|
581
521
|
legend?: LegendConfig;
|
|
582
522
|
/** Right-side endpoint labels column config (multi-series line/area only). */
|
|
@@ -584,8 +524,8 @@ interface NormalizedChartSpec {
|
|
|
584
524
|
responsive: boolean;
|
|
585
525
|
/** Whether auto-thinning of annotations at narrow widths is enabled. Resolved from `responsive.autoThin`. */
|
|
586
526
|
autoThin: boolean;
|
|
527
|
+
compactAnnotationLimit?: number | null;
|
|
587
528
|
theme: ThemeConfig;
|
|
588
|
-
darkMode: DarkMode;
|
|
589
529
|
/** Whether the OpenData watermark is enabled. */
|
|
590
530
|
watermark: boolean;
|
|
591
531
|
/** Series names to hide from rendering. */
|
|
@@ -619,7 +559,6 @@ interface NormalizedTableSpec {
|
|
|
619
559
|
rowKey?: string;
|
|
620
560
|
chrome: NormalizedChrome;
|
|
621
561
|
theme: ThemeConfig;
|
|
622
|
-
darkMode: DarkMode;
|
|
623
562
|
watermark: boolean;
|
|
624
563
|
search: boolean;
|
|
625
564
|
pagination: boolean | {
|
|
@@ -633,7 +572,6 @@ interface NormalizedTableSpec {
|
|
|
633
572
|
label: string;
|
|
634
573
|
};
|
|
635
574
|
/** Mirrors `density === 'condensed'` for back-compat. */
|
|
636
|
-
compact: boolean;
|
|
637
575
|
responsive: boolean;
|
|
638
576
|
animation?: AnimationSpec;
|
|
639
577
|
}
|
|
@@ -653,7 +591,6 @@ interface NormalizedGraphSpec {
|
|
|
653
591
|
chrome: NormalizedChrome;
|
|
654
592
|
annotations: Annotation[];
|
|
655
593
|
theme: ThemeConfig;
|
|
656
|
-
darkMode: DarkMode;
|
|
657
594
|
watermark: boolean;
|
|
658
595
|
animation?: GraphAnimationSpec;
|
|
659
596
|
interaction?: GraphInteractionConfig;
|
|
@@ -672,8 +609,11 @@ type ValidationErrorCode = 'MISSING_FIELD' | 'INVALID_TYPE' | 'INVALID_VALUE' |
|
|
|
672
609
|
interface ValidationError {
|
|
673
610
|
/** Error message describing what's wrong. */
|
|
674
611
|
message: string;
|
|
675
|
-
/**
|
|
676
|
-
|
|
612
|
+
/**
|
|
613
|
+
* Root-relative RFC 6901 JSON Pointer to the problematic value, e.g.
|
|
614
|
+
* `/encoding/x/field` or `/layer/1/data/0/value`. The root is `''`.
|
|
615
|
+
*/
|
|
616
|
+
path: string;
|
|
677
617
|
/** Machine-readable error code for programmatic handling. */
|
|
678
618
|
code: ValidationErrorCode;
|
|
679
619
|
/** Actionable suggestion for fixing the error. */
|
|
@@ -696,63 +636,6 @@ interface CompileResult {
|
|
|
696
636
|
warnings: string[];
|
|
697
637
|
}
|
|
698
638
|
|
|
699
|
-
/** Continuous D3 scales (linear, time, log, pow, sqrt, symlog) that support .ticks() and .nice(). */
|
|
700
|
-
type D3ContinuousScale = ScaleLinear<number, number> | ScaleTime<number, number> | ScaleLogarithmic<number, number> | ScalePower<number, number> | ScaleSymLog<number, number>;
|
|
701
|
-
/** Discretizing D3 scales (quantile, quantize, threshold). */
|
|
702
|
-
type D3DiscretizingScale = ScaleQuantile<number> | ScaleQuantize<number> | ScaleThreshold<number, number>;
|
|
703
|
-
/** Categorical D3 scales (band, point, ordinal) that support .domain() as string[]. */
|
|
704
|
-
type D3CategoricalScale = ScaleBand<string> | ScalePoint<string> | ScaleOrdinal<string, string>;
|
|
705
|
-
/** Union of all D3 scale types used by the engine. */
|
|
706
|
-
type D3Scale = D3ContinuousScale | D3CategoricalScale | D3DiscretizingScale;
|
|
707
|
-
/** All resolved scale type identifiers. */
|
|
708
|
-
type ResolvedScaleType = ScaleType | 'sequential';
|
|
709
|
-
/**
|
|
710
|
-
* A resolved scale wrapping a d3 scale with type metadata.
|
|
711
|
-
* We need to carry the scale type around so axes and marks know
|
|
712
|
-
* how to interpret the domain/range. Consumers use the `type` discriminant
|
|
713
|
-
* to determine which D3 methods are available on the scale.
|
|
714
|
-
*/
|
|
715
|
-
interface ResolvedScale {
|
|
716
|
-
/** The d3 scale function. Maps domain value -> pixel position or color. */
|
|
717
|
-
scale: D3Scale;
|
|
718
|
-
/** The scale type for downstream use. */
|
|
719
|
-
type: ResolvedScaleType;
|
|
720
|
-
/** The encoding channel this scale was derived from. */
|
|
721
|
-
channel: EncodingChannel;
|
|
722
|
-
/** Per-field formatting context (extent, allIntegers) from the ORIGINAL data. */
|
|
723
|
-
formatContext?: FieldFormatContext;
|
|
724
|
-
}
|
|
725
|
-
/** All resolved scales for a chart. */
|
|
726
|
-
interface ResolvedScales {
|
|
727
|
-
x?: ResolvedScale;
|
|
728
|
-
y?: ResolvedScale;
|
|
729
|
-
color?: ResolvedScale;
|
|
730
|
-
size?: ResolvedScale;
|
|
731
|
-
/** Default color for single-series charts (first categorical palette color or markDef.fill gradient). */
|
|
732
|
-
defaultColor?: string | _opendata_ai_openchart_core.GradientDef;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
/**
|
|
736
|
-
* Pie / donut chart mark computation.
|
|
737
|
-
*
|
|
738
|
-
* Uses d3.pie() for angle calculation and d3.arc() for SVG path
|
|
739
|
-
* generation. Supports sorting by value (largest first), small-slice
|
|
740
|
-
* grouping into "Other", and donut variant with inner radius.
|
|
741
|
-
*/
|
|
742
|
-
|
|
743
|
-
/**
|
|
744
|
-
* Rebuild the SVG path for an arc from its resolved geometry. Used by the
|
|
745
|
-
* vanilla transition driver to interpolate arc marks per frame; must stay in
|
|
746
|
-
* lockstep with the `arcGenerator` below or the tween's final frame won't
|
|
747
|
-
* match the rendered mark.
|
|
748
|
-
*/
|
|
749
|
-
declare function buildArcPath(geom: {
|
|
750
|
-
innerRadius: number;
|
|
751
|
-
outerRadius: number;
|
|
752
|
-
startAngle: number;
|
|
753
|
-
endAngle: number;
|
|
754
|
-
}): string;
|
|
755
|
-
|
|
756
639
|
/** Default font size for annotation labels. */
|
|
757
640
|
declare const DEFAULT_ANNOTATION_FONT_SIZE = 13;
|
|
758
641
|
/** Default line height multiplier for annotation text. */
|
|
@@ -813,6 +696,29 @@ interface ArrowheadPoints {
|
|
|
813
696
|
* @param halfWidth - Arrow half-width perpendicular to tangent (default ARROWHEAD_HALF_WIDTH)
|
|
814
697
|
*/
|
|
815
698
|
declare function computeArrowheadPoints(tipX: number, tipY: number, tangentX: number, tangentY: number, length?: number, halfWidth?: number): ArrowheadPoints;
|
|
699
|
+
/**
|
|
700
|
+
* Rebuild a connector's geometry against a (possibly moved) annotation bounds.
|
|
701
|
+
*
|
|
702
|
+
* `from` comes from the ray-box exit; `to` is recomputed by pulling back from
|
|
703
|
+
* `connector.endpoint` — never from the already-pulled-back `to`, which would
|
|
704
|
+
* shrink the line a little more on every pass.
|
|
705
|
+
*
|
|
706
|
+
* Returns `undefined` when the connector should be suppressed: the target sits
|
|
707
|
+
* inside the text block, or the resulting line is shorter than
|
|
708
|
+
* `MIN_CONNECTOR_LENGTH`.
|
|
709
|
+
*/
|
|
710
|
+
declare function automaticControlPoint(from: {
|
|
711
|
+
x: number;
|
|
712
|
+
y: number;
|
|
713
|
+
}, to: {
|
|
714
|
+
x: number;
|
|
715
|
+
y: number;
|
|
716
|
+
}, exit?: 'horizontal' | 'vertical', bend?: number): {
|
|
717
|
+
x: number;
|
|
718
|
+
y: number;
|
|
719
|
+
};
|
|
720
|
+
type Connector = NonNullable<ResolvedLabel['connector']>;
|
|
721
|
+
declare function refreshConnector(connector: Connector, bounds: Rect, markerRadius: number, keepVisible?: boolean): ResolvedLabel['connector'];
|
|
816
722
|
|
|
817
723
|
/**
|
|
818
724
|
* Annotation placement engine: typed obstacles, candidate generation,
|
|
@@ -824,22 +730,210 @@ interface PlacementObstacle extends Rect {
|
|
|
824
730
|
kind: ObstacleKind;
|
|
825
731
|
}
|
|
826
732
|
|
|
733
|
+
/** A vertical outside label measured for the top lane. */
|
|
734
|
+
interface ReferenceLaneLabel {
|
|
735
|
+
/** Index of the annotation in the spec's annotation list. */
|
|
736
|
+
index: number;
|
|
737
|
+
width: number;
|
|
738
|
+
height: number;
|
|
739
|
+
}
|
|
740
|
+
/** An admitted top-lane row, positioned by the distance from its top to the plot top. */
|
|
741
|
+
interface ReferenceLaneSlot {
|
|
742
|
+
members: number[];
|
|
743
|
+
above: number;
|
|
744
|
+
}
|
|
745
|
+
interface ReferenceReserve {
|
|
746
|
+
right: number;
|
|
747
|
+
/** Height reserved above the plot for the top lane. */
|
|
748
|
+
top: number;
|
|
749
|
+
labelWidth: number;
|
|
750
|
+
/** Vertical outside labels, measured at `labelWidth`, in source order. */
|
|
751
|
+
labels: ReferenceLaneLabel[];
|
|
752
|
+
/**
|
|
753
|
+
* Admitted top-lane rows. A vertical outside label in no row places inside
|
|
754
|
+
* the plot. Placement reads these; it never re-derives the lane.
|
|
755
|
+
*/
|
|
756
|
+
rows: ReferenceLaneSlot[];
|
|
757
|
+
/** Whether any top-lane row was admitted. */
|
|
758
|
+
topLane?: boolean;
|
|
759
|
+
}
|
|
760
|
+
interface ReferenceLanes {
|
|
761
|
+
rightLabels?: ResolvedAnnotation[];
|
|
762
|
+
/** A lane overflowed once already; one warning per compile covers every label. */
|
|
763
|
+
topOverflow?: boolean;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
type BarLabelPlacement = 'adaptive' | 'inside' | 'outside' | 'column' | 'suppress';
|
|
767
|
+
interface BarLabelPlan {
|
|
768
|
+
placement: BarLabelPlacement;
|
|
769
|
+
reserveLeft: number;
|
|
770
|
+
reserveRight: number;
|
|
771
|
+
reserveTop: number;
|
|
772
|
+
reserveBottom: number;
|
|
773
|
+
columnWidth: number;
|
|
774
|
+
fallback?: 'column-to-outside' | 'labels-suppressed';
|
|
775
|
+
}
|
|
776
|
+
|
|
827
777
|
/**
|
|
828
|
-
*
|
|
829
|
-
*
|
|
778
|
+
* Root (chrome, axes, legend) theme of a layer, shared by layer compilation and
|
|
779
|
+
* host text measurement. Like every other root property, the layer's value wins
|
|
780
|
+
* whole and the first leaf's is the fallback. Leaf marks are themed separately:
|
|
781
|
+
* each leaf's theme deep-merges over the layer theme for its own marks.
|
|
782
|
+
*/
|
|
783
|
+
declare function resolveLayerTheme(layerSpec: LayerSpec, primary?: ChartSpec): _opendata_ai_openchart_core.ThemeConfig | undefined;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* Graph compilation pipeline.
|
|
830
787
|
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
833
|
-
*
|
|
834
|
-
*
|
|
788
|
+
* Takes a raw graph spec (unknown shape), validates, normalizes, resolves
|
|
789
|
+
* encoding channels to visual properties, assigns communities, builds
|
|
790
|
+
* legend/tooltips/a11y, and returns a GraphCompilation.
|
|
791
|
+
*
|
|
792
|
+
* The pipeline mirrors compileChart's structure:
|
|
793
|
+
* validate -> normalize -> resolve theme -> resolve visuals ->
|
|
794
|
+
* community assignment -> legend -> tooltips -> a11y -> return
|
|
795
|
+
*
|
|
796
|
+
* Key difference from charts: the output does NOT include x/y positions.
|
|
797
|
+
* The force simulation in the adapter handles layout at runtime.
|
|
798
|
+
*/
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* Build a tooltip for a single edge, on demand.
|
|
802
|
+
*
|
|
803
|
+
* Construction is LAZY (called for the one hovered edge), not an eager O(E)
|
|
804
|
+
* descriptor map — edges outnumber nodes 5–10× and an eager map on every
|
|
805
|
+
* compile (including graph updates) would be pure bloat. Shows source → target
|
|
806
|
+
* and all non-structural data fields.
|
|
807
|
+
*/
|
|
808
|
+
declare function buildEdgeTooltip(edge: CompiledGraphEdge): TooltipContent;
|
|
809
|
+
|
|
810
|
+
/**
|
|
811
|
+
* Animation resolver: normalizes AnimationSpec into fully resolved config.
|
|
835
812
|
*
|
|
836
|
-
*
|
|
837
|
-
*
|
|
813
|
+
* Handles the shorthand forms:
|
|
814
|
+
* - true -> all three phases with defaults
|
|
815
|
+
* - { enter: { duration: 800 } } -> merge with defaults per phase
|
|
816
|
+
* - false/undefined -> undefined (no animation)
|
|
817
|
+
*
|
|
818
|
+
* Each phase resolves independently:
|
|
819
|
+
* - true/config-object -> resolved phase merged onto that phase's defaults
|
|
820
|
+
* - false -> phase absent
|
|
821
|
+
* - undefined -> phase present with defaults (animation: {} behaves like true)
|
|
822
|
+
*
|
|
823
|
+
* Returns undefined only when ALL phases resolve absent.
|
|
838
824
|
*/
|
|
839
825
|
|
|
826
|
+
/** Default values for entrance animation. */
|
|
827
|
+
declare const ENTER_DEFAULTS: ResolvedAnimationPhase;
|
|
828
|
+
/** Default values for update (data transition) animation. */
|
|
829
|
+
declare const UPDATE_DEFAULTS: ResolvedAnimationPhase;
|
|
830
|
+
/** Default values for exit animation. */
|
|
831
|
+
declare const EXIT_DEFAULTS: ResolvedAnimationPhase;
|
|
832
|
+
/**
|
|
833
|
+
* Resolve an AnimationSpec into a fully resolved config with all defaults filled.
|
|
834
|
+
* Returns undefined if animation is disabled (false or omitted).
|
|
835
|
+
*/
|
|
836
|
+
declare function resolveAnimation(spec: AnimationSpec | undefined): ResolvedAnimation | undefined;
|
|
837
|
+
/**
|
|
838
|
+
* Clamp stagger delay so total stagger time doesn't exceed MAX_TOTAL_STAGGER_MS.
|
|
839
|
+
*/
|
|
840
|
+
declare function clampStaggerDelay(delay: number, elementCount: number): number;
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* Mark key utilities for data-update transitions.
|
|
844
|
+
*
|
|
845
|
+
* Keys uniquely identify marks across data updates so the renderer can
|
|
846
|
+
* match old marks to new marks and animate the difference. Each chart
|
|
847
|
+
* type stamps keys during its compute phase; these helpers provide the
|
|
848
|
+
* shared serialization and deduplication logic.
|
|
849
|
+
*/
|
|
850
|
+
/**
|
|
851
|
+
* Serialize a datum value into a stable key fragment.
|
|
852
|
+
* - Date -> epoch ms string (avoids locale-dependent Date.toString)
|
|
853
|
+
* - number/string/boolean -> String(v)
|
|
854
|
+
* - null/undefined -> null sentinel
|
|
855
|
+
*/
|
|
856
|
+
declare function serializeKeyValue(v: unknown): string;
|
|
857
|
+
declare function dedupeKeys(keys: string[]): string[];
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Build an SVG path string from an array of points using d3 line generator.
|
|
861
|
+
* Accepts an optional interpolation string (defaults to 'monotone').
|
|
862
|
+
*/
|
|
863
|
+
declare function buildLinePath(points: Point[], interpolate?: string): string;
|
|
864
|
+
/**
|
|
865
|
+
* Build an SVG path string for a filled area from top and bottom point arrays.
|
|
866
|
+
* Accepts an optional interpolation string (defaults to 'monotone').
|
|
867
|
+
*/
|
|
868
|
+
declare function buildAreaPath(topPoints: Point[], bottomPoints: Point[], interpolate?: string): string;
|
|
869
|
+
|
|
870
|
+
/** Continuous D3 scales (linear, time, log, pow, sqrt, symlog) that support .ticks() and .nice(). */
|
|
871
|
+
type D3ContinuousScale = ScaleLinear<number, number> | ScaleTime<number, number> | ScaleLogarithmic<number, number> | ScalePower<number, number> | ScaleSymLog<number, number>;
|
|
872
|
+
/** Discretizing D3 scales (quantile, quantize, threshold). */
|
|
873
|
+
type D3DiscretizingScale = ScaleQuantile<number> | ScaleQuantize<number> | ScaleThreshold<number, number>;
|
|
874
|
+
/** Categorical D3 scales (band, point, ordinal) that support .domain() as string[]. */
|
|
875
|
+
type D3CategoricalScale = ScaleBand<string> | ScalePoint<string> | ScaleOrdinal<string, string>;
|
|
876
|
+
/** Union of all D3 scale types used by the engine. */
|
|
877
|
+
type D3Scale = D3ContinuousScale | D3CategoricalScale | D3DiscretizingScale;
|
|
878
|
+
/** All resolved scale type identifiers. */
|
|
879
|
+
type ResolvedScaleType = ScaleType | 'sequential';
|
|
880
|
+
/**
|
|
881
|
+
* A resolved scale wrapping a d3 scale with type metadata.
|
|
882
|
+
* We need to carry the scale type around so axes and marks know
|
|
883
|
+
* how to interpret the domain/range. Consumers use the `type` discriminant
|
|
884
|
+
* to determine which D3 methods are available on the scale.
|
|
885
|
+
*/
|
|
886
|
+
interface ResolvedScale {
|
|
887
|
+
/** The d3 scale function. Maps domain value -> pixel position or color. */
|
|
888
|
+
scale: D3Scale;
|
|
889
|
+
/** The scale type for downstream use. */
|
|
890
|
+
type: ResolvedScaleType;
|
|
891
|
+
/** The encoding channel this scale was derived from. */
|
|
892
|
+
channel: EncodingChannel;
|
|
893
|
+
/** Per-field formatting context (extent, allIntegers) from the ORIGINAL data. */
|
|
894
|
+
formatContext?: FieldFormatContext;
|
|
895
|
+
}
|
|
896
|
+
/** All resolved scales for a chart. */
|
|
897
|
+
interface ResolvedScales {
|
|
898
|
+
x?: ResolvedScale;
|
|
899
|
+
y?: ResolvedScale;
|
|
900
|
+
color?: ResolvedScale;
|
|
901
|
+
size?: ResolvedScale;
|
|
902
|
+
/** Default color for single-series charts (first categorical palette color or markDef.fill gradient). */
|
|
903
|
+
defaultColor?: string | _opendata_ai_openchart_core.GradientDef;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Pie / donut chart mark computation.
|
|
908
|
+
*
|
|
909
|
+
* Uses d3.pie() for angle calculation and d3.arc() for SVG path
|
|
910
|
+
* generation. Supports sorting by value (largest first), small-slice
|
|
911
|
+
* grouping into "Other", and donut variant with inner radius.
|
|
912
|
+
*/
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Rebuild the SVG path for an arc from its resolved geometry. Used by the
|
|
916
|
+
* vanilla transition driver to interpolate arc marks per frame; must stay in
|
|
917
|
+
* lockstep with the `arcGenerator` below or the tween's final frame won't
|
|
918
|
+
* match the rendered mark.
|
|
919
|
+
*/
|
|
920
|
+
declare function buildArcPath(geom: {
|
|
921
|
+
innerRadius: number;
|
|
922
|
+
outerRadius: number;
|
|
923
|
+
startAngle: number;
|
|
924
|
+
endAngle: number;
|
|
925
|
+
}): string;
|
|
926
|
+
|
|
840
927
|
interface AnnotationContext {
|
|
841
928
|
scales: ResolvedScales;
|
|
842
929
|
chartArea: Rect;
|
|
930
|
+
referenceContainer?: Rect;
|
|
931
|
+
referenceLanes?: ReferenceLanes;
|
|
932
|
+
/**
|
|
933
|
+
* Outside reference lanes resolved by the figure budget, the only source of
|
|
934
|
+
* the reserve. Without one, outside labels place inside the plot.
|
|
935
|
+
*/
|
|
936
|
+
referenceReserve?: ReferenceReserve;
|
|
843
937
|
strategy: LayoutStrategy;
|
|
844
938
|
isDark: boolean;
|
|
845
939
|
obstacles: PlacementObstacle[];
|
|
@@ -850,7 +944,11 @@ interface AnnotationContext {
|
|
|
850
944
|
measure: AnnotationMeasureTextFn;
|
|
851
945
|
/** Theme font stack, so annotation text is measured and rendered in the same face. */
|
|
852
946
|
fontFamily?: string;
|
|
947
|
+
padding?: number;
|
|
948
|
+
smallFontSize?: number;
|
|
949
|
+
colors?: _opendata_ai_openchart_core.ThemeColors;
|
|
853
950
|
debugPlacement?: boolean;
|
|
951
|
+
onWarn?: (message: string) => void;
|
|
854
952
|
/** When true, annotations that overlap are demoted to footnote markers instead of being hidden. */
|
|
855
953
|
autoThin?: boolean;
|
|
856
954
|
/**
|
|
@@ -859,6 +957,13 @@ interface AnnotationContext {
|
|
|
859
957
|
* the title/subtitle. Defaults to the plain SVG clamp margin.
|
|
860
958
|
*/
|
|
861
959
|
topBound?: number;
|
|
960
|
+
/** Endpoint markers drawn on data points (see `adoptPointMarker`). */
|
|
961
|
+
pointMarkers?: ReadonlyArray<{
|
|
962
|
+
x: number;
|
|
963
|
+
y: number;
|
|
964
|
+
fill: string;
|
|
965
|
+
stroke: string;
|
|
966
|
+
}>;
|
|
862
967
|
}
|
|
863
968
|
|
|
864
969
|
/**
|
|
@@ -893,24 +998,7 @@ declare function parseAnnotationSpans(line: string): RichSpan[];
|
|
|
893
998
|
*/
|
|
894
999
|
declare function normalizeSpec(spec: VizSpec, warnings?: string[]): NormalizedSpec;
|
|
895
1000
|
|
|
896
|
-
/**
|
|
897
|
-
* Runtime spec validation.
|
|
898
|
-
*
|
|
899
|
-
* TypeScript catches compile-time errors for specs written in code.
|
|
900
|
-
* This module catches runtime errors for specs coming from JSON, APIs,
|
|
901
|
-
* or Claude-generated output where the TypeScript compiler can't help.
|
|
902
|
-
*
|
|
903
|
-
* Every error includes a machine-readable code and an actionable suggestion
|
|
904
|
-
* so consumers (and LLMs) can fix issues programmatically.
|
|
905
|
-
*/
|
|
906
|
-
|
|
907
|
-
/**
|
|
908
|
-
* Validate a spec at runtime.
|
|
909
|
-
*
|
|
910
|
-
* Checks structure, required fields, encoding rules, data shape, and
|
|
911
|
-
* field type compatibility. Returns structured errors with machine-readable
|
|
912
|
-
* codes and actionable suggestions for each problem found.
|
|
913
|
-
*/
|
|
1001
|
+
/** Validate authored mark contracts before any sugar transformation. */
|
|
914
1002
|
declare function validateSpec(spec: unknown): ValidationResult;
|
|
915
1003
|
|
|
916
1004
|
/**
|
|
@@ -961,7 +1049,7 @@ declare const AUTO_CANVAS_THRESHOLD = 1000;
|
|
|
961
1049
|
* full container width (used by geometry gates that must key off the
|
|
962
1050
|
* container, not the derived plot width). Returns an array of marks to render.
|
|
963
1051
|
*/
|
|
964
|
-
type ChartRenderer = (spec: NormalizedChartSpec, scales: ResolvedScales, chartArea: Rect, strategy: LayoutStrategy, theme: ResolvedTheme, containerWidth: number) => Mark[];
|
|
1052
|
+
type ChartRenderer = (spec: NormalizedChartSpec, scales: ResolvedScales, chartArea: Rect, strategy: LayoutStrategy, theme: ResolvedTheme, containerWidth: number, labelPlan?: BarLabelPlan, measureText?: MeasureTextFn) => Mark[];
|
|
965
1053
|
/**
|
|
966
1054
|
* Register a chart renderer for a specific chart type.
|
|
967
1055
|
*
|
|
@@ -1146,6 +1234,32 @@ declare function runTimeUnit(data: DataRow[], transform: TimeUnitTransform): Dat
|
|
|
1146
1234
|
*/
|
|
1147
1235
|
declare function runTransforms(data: DataRow[], transforms: Transform[]): DataRow[];
|
|
1148
1236
|
|
|
1237
|
+
/** Frozen, engine-owned geometry for a single annotation editing gesture. */
|
|
1238
|
+
|
|
1239
|
+
/** Opaque gesture snapshot. Create a new context after a committed edit or resize. */
|
|
1240
|
+
interface AnnotationEditContext {
|
|
1241
|
+
readonly kind: 'annotation-edit-context';
|
|
1242
|
+
}
|
|
1243
|
+
/** Snapshot a compiled layout without asking callers to reconstruct scales or obstacles. */
|
|
1244
|
+
declare function createAnnotationEditContext(layout: ChartLayout, spec: unknown): AnnotationEditContext;
|
|
1245
|
+
/** Convert the rendered block box to an explicit placement, preserving its alignment. */
|
|
1246
|
+
declare function inverseLabelPlacement(ctx: AnnotationEditContext, ref: ElementRef, renderedBox: Rect): Pick<TextAnnotation, 'anchor' | 'offset' | 'responsive'>;
|
|
1247
|
+
/** Move only the label block; keep its data anchor and the surrounding layout frozen. */
|
|
1248
|
+
declare function previewAnnotationMove(ctx: AnnotationEditContext, ref: ElementRef, delta: {
|
|
1249
|
+
dx: number;
|
|
1250
|
+
dy: number;
|
|
1251
|
+
}): ResolvedAnnotation;
|
|
1252
|
+
/** Change a curve without moving its label, attachment, or marker. */
|
|
1253
|
+
declare function previewConnectorBend(ctx: AnnotationEditContext, ref: ElementRef, bend: number): ResolvedAnnotation;
|
|
1254
|
+
/** Preview a connector endpoint nudge without parsing rendered path geometry. */
|
|
1255
|
+
declare function previewConnectorOffset(ctx: AnnotationEditContext, ref: ElementRef, end: 'from' | 'to', delta: {
|
|
1256
|
+
dx: number;
|
|
1257
|
+
dy: number;
|
|
1258
|
+
}): ResolvedAnnotation;
|
|
1259
|
+
|
|
1260
|
+
/** Sample label and attachment independently. Leader visibility is chosen by the final layout. */
|
|
1261
|
+
declare function interpolateAnnotationGeometry(before: ResolvedAnnotation, after: ResolvedAnnotation, t: number): ResolvedAnnotation;
|
|
1262
|
+
|
|
1149
1263
|
/** Checks use resolved geometry and authored metadata, never headline interpretation. */
|
|
1150
1264
|
declare function diagnoseChart(spec: ChartSpec, layout: ChartLayout): DesignDiagnostic[];
|
|
1151
1265
|
|
|
@@ -1163,8 +1277,46 @@ interface ObservationComparison {
|
|
|
1163
1277
|
declare function compareObservations(before: number, after: number, a: FieldMetadata, b: FieldMetadata): ObservationComparison | null;
|
|
1164
1278
|
declare function linkedEntityKeys(row: DataRow, source: DatasetBinding, target: DatasetBinding): string[];
|
|
1165
1279
|
|
|
1166
|
-
|
|
1167
|
-
|
|
1280
|
+
interface AppliedSpecPatch {
|
|
1281
|
+
spec: VizSpec;
|
|
1282
|
+
/** Undoes the patch; its precondition is the patched document. */
|
|
1283
|
+
inverse: SpecPatch;
|
|
1284
|
+
}
|
|
1285
|
+
/**
|
|
1286
|
+
* Apply a patch atomically through `applyEditTransaction`. Throws when the
|
|
1287
|
+
* document changed since the patch was produced or any operation is invalid;
|
|
1288
|
+
* the input spec is never mutated.
|
|
1289
|
+
*/
|
|
1290
|
+
declare function applySpecPatch(spec: VizSpec, patch: SpecPatch): AppliedSpecPatch;
|
|
1291
|
+
|
|
1292
|
+
interface ReaderPanelIndex {
|
|
1293
|
+
scope: ReaderPanelScope;
|
|
1294
|
+
area: Rect;
|
|
1295
|
+
slices: ReaderSlice[];
|
|
1296
|
+
positions: number[];
|
|
1297
|
+
}
|
|
1298
|
+
interface ReaderSliceIndex {
|
|
1299
|
+
supported: boolean;
|
|
1300
|
+
panels: ReaderPanelIndex[];
|
|
1301
|
+
diagnostics: DesignDiagnostic[];
|
|
1302
|
+
revision: string;
|
|
1303
|
+
/** Source identity inventory keeps filtered rows distinct from deletions. */
|
|
1304
|
+
sourceObservationKeys: ReadonlySet<string>;
|
|
1305
|
+
sourceObservationData: ReadonlyMap<string, DataRow>;
|
|
1306
|
+
byKey: ReadonlyMap<string, ReaderSlice>;
|
|
1307
|
+
bindingKey: string;
|
|
1308
|
+
}
|
|
1309
|
+
declare function readerDomainValue(value: unknown): ReaderDomainValue | null;
|
|
1310
|
+
declare function compareReaderValues(before: ReaderComparisonOperand, after: ReaderComparisonOperand, options?: {
|
|
1311
|
+
allowNegativeRelative?: boolean;
|
|
1312
|
+
}): ReaderComparisonResult;
|
|
1313
|
+
declare function buildReaderSliceIndex(source: ChartSpec | LayerSpec, layout: ChartLayout, options: ReaderSliceIndexOptions): ReaderSliceIndex;
|
|
1314
|
+
declare function nearestReaderSlice(index: ReaderSliceIndex, pixelX: number, panelId?: string): ReaderSlice | null;
|
|
1315
|
+
declare function readerSliceByKey(index: ReaderSliceIndex, key: string): ReaderSlice | null;
|
|
1316
|
+
declare function reconcileReaderSlices(selection: ReaderSliceSelection, next: ReaderSliceIndex, options: {
|
|
1317
|
+
dataReplaced: boolean;
|
|
1318
|
+
visibleObservationKeys?: ReadonlySet<string>;
|
|
1319
|
+
}): ReaderSliceSelection;
|
|
1168
1320
|
|
|
1169
1321
|
interface RecommendationRoles {
|
|
1170
1322
|
measure?: string;
|
|
@@ -1181,4 +1333,78 @@ interface RecommendationResult {
|
|
|
1181
1333
|
/** Deterministic suggestions require an explicit question and field roles. No aggregation is inferred. */
|
|
1182
1334
|
declare function recommendCompositions(data: DataRow[], question: DesignQuestion, roles: RecommendationRoles): RecommendationResult;
|
|
1183
1335
|
|
|
1184
|
-
|
|
1336
|
+
/** Marker coordinates use the actual key mapping: discrete classes or raw gradient position. */
|
|
1337
|
+
declare function geoColorKeyPosition(key: GeoColorKeyLayout, value: unknown): {
|
|
1338
|
+
x?: number;
|
|
1339
|
+
y?: number;
|
|
1340
|
+
category?: string;
|
|
1341
|
+
outside: boolean;
|
|
1342
|
+
missing: boolean;
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
/** Stateless settle/export layout. Measurements and authored inventory arrive precompiled. */
|
|
1346
|
+
declare function resolveGeoOverlay(input: GeoLabelsInput, affine: GeoLabelAffine): GeoLabelOverlay;
|
|
1347
|
+
|
|
1348
|
+
/** Destination-layout map observations; no renderer or DOM joins. */
|
|
1349
|
+
|
|
1350
|
+
interface GeoReaderRecord {
|
|
1351
|
+
observation: GeoReaderObservation;
|
|
1352
|
+
name: string;
|
|
1353
|
+
valueLabel: string;
|
|
1354
|
+
valueStatus: 'value' | 'missing' | 'ambiguous';
|
|
1355
|
+
unit?: string;
|
|
1356
|
+
identityStatus: 'persistent' | 'ephemeral' | 'ambiguous';
|
|
1357
|
+
primary?: {
|
|
1358
|
+
channel: 'color' | 'size';
|
|
1359
|
+
field: string;
|
|
1360
|
+
value: number | undefined;
|
|
1361
|
+
metadata?: FieldMetadata;
|
|
1362
|
+
};
|
|
1363
|
+
color?: {
|
|
1364
|
+
field: string;
|
|
1365
|
+
value: unknown;
|
|
1366
|
+
};
|
|
1367
|
+
fields: Array<{
|
|
1368
|
+
label: string;
|
|
1369
|
+
value: string;
|
|
1370
|
+
}>;
|
|
1371
|
+
point?: {
|
|
1372
|
+
cx: number;
|
|
1373
|
+
cy: number;
|
|
1374
|
+
r: number;
|
|
1375
|
+
};
|
|
1376
|
+
viewIds?: string[];
|
|
1377
|
+
}
|
|
1378
|
+
interface GeoReaderIndex {
|
|
1379
|
+
records: GeoReaderRecord[];
|
|
1380
|
+
byObservation: Map<string, GeoReaderRecord>;
|
|
1381
|
+
diagnostics: DesignDiagnostic[];
|
|
1382
|
+
}
|
|
1383
|
+
declare function buildGeoReaderIndex(spec: GeoMapSpec, layout: GeoMapLayout): GeoReaderIndex;
|
|
1384
|
+
declare function queryGeoReaderRecords(index: GeoReaderIndex, query: string, rank?: 'ascending' | 'descending', kind?: 'feature' | 'point'): Array<GeoReaderRecord & {
|
|
1385
|
+
rank?: number;
|
|
1386
|
+
}>;
|
|
1387
|
+
|
|
1388
|
+
/** A documented authored-spec change made by migrateSpecV8. */
|
|
1389
|
+
interface SpecRepair {
|
|
1390
|
+
path: string;
|
|
1391
|
+
from: unknown;
|
|
1392
|
+
to: unknown;
|
|
1393
|
+
reason: string;
|
|
1394
|
+
}
|
|
1395
|
+
/**
|
|
1396
|
+
* Rewrite v8 aliases without mutating the input. Safe to run repeatedly.
|
|
1397
|
+
* Legacy end-of-line labels become endpoint labels; their manual offsets are
|
|
1398
|
+
* reported as lost repairs because the two placement models are different.
|
|
1399
|
+
*/
|
|
1400
|
+
declare function migrateSpecV8<T>(input: T, options?: {
|
|
1401
|
+
styling?: 'v8' | 'v9';
|
|
1402
|
+
}): {
|
|
1403
|
+
spec: T;
|
|
1404
|
+
repairs: SpecRepair[];
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
/** Author order and supplementary fields survive; formatted text never decides identity. */
|
|
1408
|
+
declare function sharedTooltipFields(content: TooltipContent): TooltipField[];
|
|
1409
|
+
|
|
1410
|
+
export { ARROWHEAD_LENGTH, AUTO_CANVAS_THRESHOLD, type AnnotationContext, type AnnotationEditContext, type AnnotationMeasureTextFn, type AppliedSpecPatch, type ArrowheadPoints, BOLD_SPAN_FONT_WEIGHT, type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, DEFAULT_ANNOTATION_FONT_SIZE, DEFAULT_LINE_HEIGHT, ENTER_DEFAULTS, EXIT_DEFAULTS, type GeoReaderIndex, type GeoReaderRecord, type GraphCompilation, MAX_3D_NODES, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGeoMapSpec, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObservationComparison, type ObstacleKind, type PlacementObstacle, type ReaderPanelIndex, type ReaderSliceIndex, type RecommendationResult, type RecommendationRoles, type RichSpan, type SimulationConfig, type SpecRepair, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, applySpecPatch, automaticControlPoint, buildArcPath, buildAreaPath, buildEdgeTooltip, buildGeoReaderIndex, buildLinePath, buildReaderSliceIndex, clampStaggerDelay, clearRenderers, compareObservations, compareReaderValues, compile, compileBarList, compileChart, compileGeoMap, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, computeArrowheadPoints, createAnnotationEditContext, dedupeKeys, diagnoseChart, evaluatePredicate, facetMinHeight, geoColorKeyPosition, getChartRenderer, heuristicMeasure, interpolateAnnotationGeometry, inverseLabelPlacement, isConditionalValueDef, legendGap, linkedEntityKeys, migrateSpecV8, nearestReaderSlice, normalizeSpec, observationKey, parseAnnotationSpans, previewAnnotationMove, previewConnectorBend, previewConnectorOffset, queryGeoReaderRecords, readerDomainValue, readerSliceByKey, recommendCompositions, reconcileReaderSelection, reconcileReaderSlices, refreshConnector, registerChartRenderer, resolveAnimation, resolveConditionalValue, resolveGeoOverlay, resolveLayerTheme, resolveObservationIdentities, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, sharedTooltipFields, validateSpec };
|