@opendata-ai/openchart-engine 6.5.1 → 6.6.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 CHANGED
@@ -1,6 +1,6 @@
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, AnimationSpec, ResolvedAnimation, MarkType, MarkDef, DataRow, Encoding, ChromeText, Annotation, LabelConfig, LegendConfig, ThemeConfig, DarkMode, ColumnConfig, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, VizSpec, ScaleType, EncodingChannel, Rect, LayoutStrategy, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform } from '@opendata-ai/openchart-core';
3
- export { ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GraphLayout, GraphSpec, LayerSpec, TableLayout, TableSpec, VizSpec } from '@opendata-ai/openchart-core';
2
+ import { LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, CompileOptions, ChartLayout, LayerSpec, CompileTableOptions, TableLayout, AnimationSpec, ResolvedAnimation, MarkType, MarkDef, DataRow, Encoding, ChromeText, Annotation, LabelConfig, LegendConfig, ThemeConfig, DarkMode, ColumnConfig, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, VizSpec, ScaleType, EncodingChannel, Rect, LayoutStrategy, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform } from '@opendata-ai/openchart-core';
3
+ export { ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GraphLayout, GraphSpec, LayerSpec, SankeyLayout, SankeySpec, TableLayout, TableSpec, 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
6
  /**
@@ -103,19 +103,6 @@ interface GraphCompilation {
103
103
  simulationConfig: SimulationConfig;
104
104
  }
105
105
 
106
- /**
107
- * Main compile API: the public entry points for the engine.
108
- *
109
- * Pipeline for charts:
110
- * validate spec -> normalize -> resolve theme -> dark mode adapt ->
111
- * compute legend -> compute dimensions (with legend space) ->
112
- * compute scales -> compute axes -> compute gridlines ->
113
- * get chart renderer -> compute marks -> compute a11y -> return ChartLayout
114
- *
115
- * Table compiler handles full data pipeline (sort, search, pagination, visual enhancements).
116
- * Graph compiler is a stub for future implementation.
117
- */
118
-
119
106
  /**
120
107
  * Compile a chart spec into a ChartLayout.
121
108
  *
@@ -167,6 +154,19 @@ declare function compileTable(spec: unknown, options: CompileTableOptions): Tabl
167
154
  * @throws Error if spec is invalid or not a graph type.
168
155
  */
169
156
  declare function compileGraph(spec: unknown, options: CompileOptions): GraphCompilation;
157
+ /**
158
+ * Compile a sankey spec into a SankeyLayout.
159
+ *
160
+ * Takes a raw sankey spec, validates, normalizes, resolves theme and chrome,
161
+ * runs the d3-sankey layout algorithm, builds node/link marks with colors and
162
+ * labels, and returns a SankeyLayout ready for rendering.
163
+ *
164
+ * @param spec - Raw sankey spec (validated and normalized internally).
165
+ * @param options - Compile options (width, height, theme, darkMode).
166
+ * @returns SankeyLayout with computed positions and visual properties.
167
+ * @throws Error if spec is invalid or not a sankey type.
168
+ */
169
+ declare function compileSankey(spec: unknown, options: CompileOptions): _opendata_ai_openchart_core.SankeyLayout;
170
170
 
171
171
  /**
172
172
  * Animation resolver: normalizes AnimationSpec into fully resolved config.
@@ -249,7 +249,7 @@ interface NormalizedGraphSpec {
249
249
  darkMode: DarkMode;
250
250
  }
251
251
  /** Discriminated union of all normalized spec types. */
252
- type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec;
252
+ type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec;
253
253
  /** Machine-readable error code for programmatic handling. */
254
254
  type ValidationErrorCode = 'MISSING_FIELD' | 'INVALID_TYPE' | 'INVALID_VALUE' | 'ENCODING_MISMATCH' | 'DATA_FIELD_MISSING' | 'EMPTY_DATA';
255
255
  /** A single validation error with context. */
@@ -280,6 +280,31 @@ interface CompileResult {
280
280
  warnings: string[];
281
281
  }
282
282
 
283
+ /**
284
+ * Internal normalized sankey spec type used by the compilation pipeline.
285
+ *
286
+ * This mirrors NormalizedChartSpec/NormalizedGraphSpec: all optional fields
287
+ * have been filled with sensible defaults. It's an engine implementation
288
+ * detail, not a public contract.
289
+ */
290
+
291
+ /** A SankeySpec with all optional fields filled with defaults. */
292
+ interface NormalizedSankeySpec {
293
+ type: 'sankey';
294
+ data: Record<string, unknown>[];
295
+ encoding: SankeyEncoding;
296
+ nodeWidth: number;
297
+ nodePadding: number;
298
+ nodeAlign: SankeyNodeAlign;
299
+ iterations: number;
300
+ linkStyle: SankeyLinkColor;
301
+ chrome: NormalizedChrome;
302
+ legend?: LegendConfig;
303
+ theme: ThemeConfig;
304
+ darkMode: DarkMode;
305
+ animation?: AnimationSpec;
306
+ }
307
+
283
308
  /**
284
309
  * Normalize a validated VizSpec, filling in all defaults.
285
310
  *
@@ -530,4 +555,4 @@ declare function runTimeUnit(data: DataRow[], transform: TimeUnitTransform): Dat
530
555
  */
531
556
  declare function runTransforms(data: DataRow[], transforms: Transform[]): DataRow[];
532
557
 
533
- export { type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, type GraphCompilation, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGraphSpec, type NormalizedSpec, type NormalizedTableSpec, type SimulationConfig, type ValidationError, type ValidationErrorCode, type ValidationResult, clampStaggerDelay, clearRenderers, compile, compileChart, compileGraph, compileLayer, compileTable, evaluatePredicate, getChartRenderer, isConditionalValueDef, normalizeSpec, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, validateSpec };
558
+ export { type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, type GraphCompilation, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type SimulationConfig, type ValidationError, type ValidationErrorCode, type ValidationResult, clampStaggerDelay, clearRenderers, compile, compileChart, compileGraph, compileLayer, compileSankey, compileTable, evaluatePredicate, getChartRenderer, isConditionalValueDef, normalizeSpec, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, validateSpec };