@opendata-ai/openchart-engine 8.0.0-rc.11 → 8.0.0-rc.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,8 +1,84 @@
1
1
  import * as _opendata_ai_openchart_core from '@opendata-ai/openchart-core';
2
- import { LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, CompileOptions, ChartLayout, LayerSpec, CompileTableOptions, TableLayout, ResolvedAnimationPhase, AnimationSpec, ResolvedAnimation, Point, DataRow, BarListEncoding, ThemeConfig, DarkMode, MapGeo, MapEncoding, LegendConfig, MapPointsLayer, TileMapEncoding, TileMapPalette, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, ScaleType, EncodingChannel, FieldFormatContext, Rect, LayoutStrategy, VizSpec, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform } from '@opendata-ai/openchart-core';
2
+ import { AnimationEase, LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, LegendEntry, CompileOptions, ChartLayout, LayerSpec, CompileTableOptions, TableLayout, ResolvedAnimationPhase, AnimationSpec, ResolvedAnimation, Point, DataRow, BarListEncoding, ThemeConfig, DarkMode, MapGeo, MapEncoding, LegendConfig, MapPointsLayer, TileMapEncoding, TileMapPalette, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, GraphAnimationSpec, GraphInteractionConfig, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, ScaleType, EncodingChannel, FieldFormatContext, Rect, LayoutStrategy, VizSpec, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform } from '@opendata-ai/openchart-core';
3
3
  export { BarListLayout, BarListSpec, ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GraphLayout, GraphSpec, LayerSpec, MapLayout, MapSpec, SankeyLayout, SankeySpec, TableLayout, TableSpec, TileMapLayout, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
4
4
  import { ScaleLinear, ScaleTime, ScaleLogarithmic, ScalePower, ScaleSymLog, ScaleBand, ScalePoint, ScaleOrdinal, ScaleQuantile, ScaleQuantize, ScaleThreshold } from 'd3-scale';
5
5
 
6
+ /**
7
+ * Graph animation resolver.
8
+ *
9
+ * Modeled on `compiler/animation.ts` but DEFAULT-ON (the deliberate chart/graph
10
+ * divergence): graphs already move on load, so choreography is the default and
11
+ * must be opted out of, not into.
12
+ *
13
+ * - `undefined` (omitted) -> 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
+ * `reheatAlpha` for the update impulse and the entrance `cameraFit` toggle are
19
+ * internal vanilla constants, not spec surface. Warmup is NOT part of this block
20
+ * (it lives in `layout`); `fitOnLoad` is a mount option.
21
+ */
22
+
23
+ /** Fully resolved graph animation config consumed by the vanilla adapter. */
24
+ interface ResolvedGraphAnimation {
25
+ /** Entrance reveal, or null if disabled. `cameraFit` flies the camera to the fit on load. */
26
+ enter: {
27
+ duration: number;
28
+ ease: AnimationEase;
29
+ stagger: boolean;
30
+ cameraFit: boolean;
31
+ } | null;
32
+ /** Data-update enter-fade for newly added marks, or null. */
33
+ update: {
34
+ duration: number;
35
+ ease: AnimationEase;
36
+ } | null;
37
+ /** Ghost fade-out for removed marks, or null. */
38
+ exit: {
39
+ duration: number;
40
+ ease: AnimationEase;
41
+ } | null;
42
+ /** Camera flight easing, or null. `'auto'` derives duration from zoom distance. */
43
+ camera: {
44
+ duration: number | 'auto';
45
+ ease: AnimationEase;
46
+ } | null;
47
+ /** Hover emphasis crossfade, or null. */
48
+ hover: {
49
+ duration: number;
50
+ ease: AnimationEase;
51
+ } | null;
52
+ }
53
+
54
+ /**
55
+ * Graph interaction resolver.
56
+ *
57
+ * Resolves `GraphInteractionConfig` into a flat, defaulted shape the vanilla
58
+ * adapter consumes. Category sets for `'category'` hover mode and
59
+ * `highlight({ category })` derive from the compilation's sort-resolved domains
60
+ * (not raw node data), so `getLegend()` and `highlight()` always agree.
61
+ */
62
+
63
+ /** Hover emphasis behavior. */
64
+ type GraphHoverMode = 'neighbors' | 'category' | 'node' | 'none';
65
+ /** Fully resolved graph interaction config. */
66
+ interface ResolvedGraphInteraction {
67
+ /** Hover emphasis mode. Default `'neighbors'`. */
68
+ hoverMode: GraphHoverMode;
69
+ /** Node dim tier during hover/focus. Default 0.15. */
70
+ dimOpacity: number;
71
+ /** Whether selecting a node flies the camera to it. Default false. */
72
+ selectFlyTo: boolean;
73
+ /** Cursor repulsion config, or null if disabled. */
74
+ cursorRepulsion: {
75
+ radius: number;
76
+ strength: number;
77
+ } | null;
78
+ /** Whether springy node drag is enabled. Default false. */
79
+ springyDrag: boolean;
80
+ }
81
+
6
82
  /**
7
83
  * Graph compilation types.
8
84
  *
@@ -30,6 +106,8 @@ interface CompiledGraphNode {
30
106
  labelPriority: number;
31
107
  /** Community/cluster assignment from the clustering field. */
32
108
  community: string | undefined;
109
+ /** Opacity from the nodeOpacity encoding (default 1). Renderer multiplies into fill/stroke alpha. */
110
+ opacity: number;
33
111
  /** Original node data (all fields from the spec node). */
34
112
  data: Record<string, unknown>;
35
113
  }
@@ -71,6 +149,14 @@ interface SimulationConfig {
71
149
  linkStrength?: number;
72
150
  /** Whether to apply center force (default true). */
73
151
  centerForce?: boolean;
152
+ /** Deterministic layout seed (hashes into initial node positions). */
153
+ seed?: number;
154
+ /** Headless settle ticks run before first paint. 0/undefined disables warmup. */
155
+ warmupTicks?: number;
156
+ /** Wall-clock budget (ms) that caps warmup at scale. Default 250. */
157
+ warmupBudgetMs?: number;
158
+ /** Initial alpha for the simulation (update reheat / entrance). Default d3's 1. */
159
+ initialAlpha?: number;
74
160
  }
75
161
  /**
76
162
  * The complete engine output for graph specs.
@@ -103,6 +189,19 @@ interface GraphCompilation {
103
189
  simulationConfig: SimulationConfig;
104
190
  /** Whether to show the brand watermark. */
105
191
  watermark: boolean;
192
+ /** Resolved motion config, or undefined when `animation: false`. */
193
+ animation?: ResolvedGraphAnimation;
194
+ /** Resolved interaction config (always present, defaulted). */
195
+ interaction: ResolvedGraphInteraction;
196
+ /** The nodeColor field backing the legend/category emphasis, or null. */
197
+ legendField: string | null;
198
+ /** Categories to emphasize on load, captured from nodeColor.highlight. */
199
+ initialHighlight?: {
200
+ field: string;
201
+ values: string[];
202
+ };
203
+ /** Edge legend entries (nominal edgeColor with >1 category), or undefined. */
204
+ edgeLegend?: LegendEntry[];
106
205
  }
107
206
 
108
207
  /**
@@ -199,6 +298,31 @@ declare function compileMap(spec: unknown, options: CompileOptions): _opendata_a
199
298
  */
200
299
  declare function compileBarList(spec: unknown, options: CompileOptions): _opendata_ai_openchart_core.BarListLayout;
201
300
 
301
+ /**
302
+ * Graph compilation pipeline.
303
+ *
304
+ * Takes a raw graph spec (unknown shape), validates, normalizes, resolves
305
+ * encoding channels to visual properties, assigns communities, builds
306
+ * legend/tooltips/a11y, and returns a GraphCompilation.
307
+ *
308
+ * The pipeline mirrors compileChart's structure:
309
+ * validate -> normalize -> resolve theme -> resolve visuals ->
310
+ * community assignment -> legend -> tooltips -> a11y -> return
311
+ *
312
+ * Key difference from charts: the output does NOT include x/y positions.
313
+ * The force simulation in the adapter handles layout at runtime.
314
+ */
315
+
316
+ /**
317
+ * Build a tooltip for a single edge, on demand.
318
+ *
319
+ * Construction is LAZY (called for the one hovered edge), not an eager O(E)
320
+ * descriptor map — edges outnumber nodes 5–10× and an eager map on every
321
+ * compile (including updateVisuals) would be pure bloat. Shows source → target
322
+ * and all non-structural data fields.
323
+ */
324
+ declare function buildEdgeTooltip(edge: CompiledGraphEdge): TooltipContent;
325
+
202
326
  /**
203
327
  * Animation resolver: normalizes AnimationSpec into fully resolved config.
204
328
  *
@@ -376,6 +500,13 @@ interface NormalizedChartSpec {
376
500
  data: DataRow[];
377
501
  encoding: Encoding;
378
502
  chrome: NormalizedChrome;
503
+ /**
504
+ * How chrome height interacts with the height budget. `'grow'` treats the
505
+ * container height as the plot budget and grows the SVG by the chrome height;
506
+ * `'subtract'` (default) shrinks the plot to fit chrome. Carried through from
507
+ * the spec so the layout pipeline can honor it.
508
+ */
509
+ chromeLayout?: 'subtract' | 'grow';
379
510
  /** Optional KPI metric cells, passed through unchanged. */
380
511
  metrics?: _opendata_ai_openchart_core.Metric[];
381
512
  /**
@@ -454,6 +585,12 @@ interface NormalizedGraphSpec {
454
585
  theme: ThemeConfig;
455
586
  darkMode: DarkMode;
456
587
  watermark: boolean;
588
+ animation?: GraphAnimationSpec;
589
+ interaction?: GraphInteractionConfig;
590
+ legend?: boolean | {
591
+ interactive?: boolean;
592
+ counts?: boolean;
593
+ };
457
594
  }
458
595
  /** Discriminated union of all normalized spec types. */
459
596
  type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedMapSpec | NormalizedBarListSpec;
@@ -921,4 +1058,4 @@ declare function runTimeUnit(data: DataRow[], transform: TimeUnitTransform): Dat
921
1058
  */
922
1059
  declare function runTransforms(data: DataRow[], transforms: Transform[]): DataRow[];
923
1060
 
924
- export { ARROWHEAD_LENGTH, type AnnotationContext, type AnnotationMeasureTextFn, 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 GraphCompilation, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGraphSpec, type NormalizedMapSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObstacleKind, type PlacementObstacle, type RichSpan, type SimulationConfig, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, buildAreaPath, buildLinePath, clampStaggerDelay, clearRenderers, compile, compileBarList, compileChart, compileGraph, compileLayer, compileMap, compileSankey, compileTable, compileTileMap, computeArrowheadPoints, dedupeKeys, evaluatePredicate, facetMinHeight, getChartRenderer, heuristicMeasure, isConditionalValueDef, legendGap, normalizeSpec, parseAnnotationSpans, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, validateSpec };
1061
+ export { ARROWHEAD_LENGTH, type AnnotationContext, type AnnotationMeasureTextFn, 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 GraphCompilation, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGraphSpec, type NormalizedMapSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObstacleKind, type PlacementObstacle, type RichSpan, type SimulationConfig, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, buildAreaPath, buildEdgeTooltip, buildLinePath, clampStaggerDelay, clearRenderers, compile, compileBarList, compileChart, compileGraph, compileLayer, compileMap, compileSankey, compileTable, compileTileMap, computeArrowheadPoints, dedupeKeys, evaluatePredicate, facetMinHeight, getChartRenderer, heuristicMeasure, isConditionalValueDef, legendGap, normalizeSpec, parseAnnotationSpans, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, validateSpec };