@opendata-ai/openchart-engine 7.8.0 → 7.9.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 +63 -4
- package/dist/index.js +1644 -1428
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/compile-snapshot.test.ts.snap +31 -0
- package/src/__tests__/axes.test.ts +76 -0
- package/src/__tests__/compile-animation.test.ts +8 -8
- package/src/__tests__/compile-chart.test.ts +5 -5
- package/src/__tests__/dimensions.test.ts +116 -5
- package/src/__tests__/mark-keys.test.ts +294 -0
- package/src/charts/__tests__/post-process.test.ts +5 -26
- package/src/charts/bar/compute.ts +18 -0
- package/src/charts/column/compute.ts +18 -0
- package/src/charts/dot/compute.ts +30 -13
- package/src/charts/line/area.ts +20 -0
- package/src/charts/line/compute.ts +35 -1
- package/src/charts/line/curves.ts +47 -2
- package/src/charts/pie/compute.ts +13 -0
- package/src/charts/post-process.ts +2 -2
- package/src/charts/rule/index.ts +9 -0
- package/src/charts/scatter/compute.ts +15 -0
- package/src/charts/text/index.ts +9 -0
- package/src/charts/tick/index.ts +9 -0
- package/src/compiler/__tests__/animation.test.ts +78 -22
- package/src/compiler/__tests__/keys.test.ts +89 -0
- package/src/compiler/animation.ts +70 -50
- package/src/compiler/keys.ts +54 -0
- package/src/compiler/normalize.ts +1 -1
- package/src/index.ts +19 -1
- package/src/layout/axes.ts +125 -34
- package/src/layout/dimensions.ts +10 -11
- package/src/layout/plan.ts +11 -12
- package/src/tables/__tests__/compile-table.test.ts +5 -5
- package/src/tilemap/compile-tilemap.ts +93 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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, DataRow, BarListEncoding, ThemeConfig, DarkMode, TileMapEncoding, TileMapPalette, LegendConfig, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, ScaleType, EncodingChannel, Rect, LayoutStrategy, VizSpec, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform } 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, TileMapEncoding, TileMapPalette, LegendConfig, MarkType, MarkDef, Encoding, ChromeText, Annotation, LabelConfig, Display, ColumnConfig, GraphSpec, GraphEncoding, GraphLayoutConfig, NodeOverride, SankeyEncoding, SankeyNodeAlign, SankeyLinkColor, ScaleType, EncodingChannel, 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, 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
|
|
|
@@ -189,11 +189,24 @@ declare function compileBarList(spec: unknown, options: CompileOptions): _openda
|
|
|
189
189
|
* Animation resolver: normalizes AnimationSpec into fully resolved config.
|
|
190
190
|
*
|
|
191
191
|
* Handles the shorthand forms:
|
|
192
|
-
* - true ->
|
|
193
|
-
* - { enter: { duration: 800 } } -> merge with defaults
|
|
192
|
+
* - true -> all three phases with defaults
|
|
193
|
+
* - { enter: { duration: 800 } } -> merge with defaults per phase
|
|
194
194
|
* - false/undefined -> undefined (no animation)
|
|
195
|
+
*
|
|
196
|
+
* Each phase resolves independently:
|
|
197
|
+
* - true/config-object -> resolved phase merged onto that phase's defaults
|
|
198
|
+
* - false -> phase absent
|
|
199
|
+
* - undefined -> phase present with defaults (animation: {} behaves like true)
|
|
200
|
+
*
|
|
201
|
+
* Returns undefined only when ALL phases resolve absent.
|
|
195
202
|
*/
|
|
196
203
|
|
|
204
|
+
/** Default values for entrance animation. */
|
|
205
|
+
declare const ENTER_DEFAULTS: ResolvedAnimationPhase;
|
|
206
|
+
/** Default values for update (data transition) animation. */
|
|
207
|
+
declare const UPDATE_DEFAULTS: ResolvedAnimationPhase;
|
|
208
|
+
/** Default values for exit animation. */
|
|
209
|
+
declare const EXIT_DEFAULTS: ResolvedAnimationPhase;
|
|
197
210
|
/**
|
|
198
211
|
* Resolve an AnimationSpec into a fully resolved config with all defaults filled.
|
|
199
212
|
* Returns undefined if animation is disabled (false or omitted).
|
|
@@ -204,6 +217,52 @@ declare function resolveAnimation(spec: AnimationSpec | undefined): ResolvedAnim
|
|
|
204
217
|
*/
|
|
205
218
|
declare function clampStaggerDelay(delay: number, elementCount: number): number;
|
|
206
219
|
|
|
220
|
+
/**
|
|
221
|
+
* Mark key utilities for data-update transitions.
|
|
222
|
+
*
|
|
223
|
+
* Keys uniquely identify marks across data updates so the renderer can
|
|
224
|
+
* match old marks to new marks and animate the difference. Each chart
|
|
225
|
+
* type stamps keys during its compute phase; these helpers provide the
|
|
226
|
+
* shared serialization and deduplication logic.
|
|
227
|
+
*/
|
|
228
|
+
/**
|
|
229
|
+
* Serialize a datum value into a stable key fragment.
|
|
230
|
+
* - Date -> epoch ms string (avoids locale-dependent Date.toString)
|
|
231
|
+
* - number/string/boolean -> String(v)
|
|
232
|
+
* - null/undefined -> null sentinel
|
|
233
|
+
*/
|
|
234
|
+
declare function serializeKeyValue(v: unknown): string;
|
|
235
|
+
/**
|
|
236
|
+
* Append occurrence suffixes to duplicate keys, in order.
|
|
237
|
+
*
|
|
238
|
+
* Only keys that appear more than once get suffixed. Unique keys pass
|
|
239
|
+
* through unchanged so keys remain human-readable when possible.
|
|
240
|
+
* Uses SOH (\x01) as separator to avoid collisions with real data values.
|
|
241
|
+
*/
|
|
242
|
+
declare function dedupeKeys(keys: string[]): string[];
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Curve interpolation mapping and path builders.
|
|
246
|
+
*
|
|
247
|
+
* Maps Vega-Lite-style interpolation strings to d3-shape curve factories.
|
|
248
|
+
* Used by both line and area chart computations.
|
|
249
|
+
*
|
|
250
|
+
* Also exports pure path-builder helpers (`buildLinePath`, `buildAreaPath`)
|
|
251
|
+
* so downstream consumers (e.g. transition interpolators) can reconstruct
|
|
252
|
+
* SVG paths from point arrays without pulling in chart-specific code.
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Build an SVG path string from an array of points using d3 line generator.
|
|
257
|
+
* Accepts an optional interpolation string (defaults to 'monotone').
|
|
258
|
+
*/
|
|
259
|
+
declare function buildLinePath(points: Point[], interpolate?: string): string;
|
|
260
|
+
/**
|
|
261
|
+
* Build an SVG path string for a filled area from top and bottom point arrays.
|
|
262
|
+
* Accepts an optional interpolation string (defaults to 'monotone').
|
|
263
|
+
*/
|
|
264
|
+
declare function buildAreaPath(topPoints: Point[], bottomPoints: Point[], interpolate?: string): string;
|
|
265
|
+
|
|
207
266
|
/**
|
|
208
267
|
* Internal normalized barlist spec type used by the compilation pipeline.
|
|
209
268
|
*/
|
|
@@ -733,4 +792,4 @@ declare function runTimeUnit(data: DataRow[], transform: TimeUnitTransform): Dat
|
|
|
733
792
|
*/
|
|
734
793
|
declare function runTransforms(data: DataRow[], transforms: Transform[]): DataRow[];
|
|
735
794
|
|
|
736
|
-
export { type AnnotationContext, type AnnotationMeasureTextFn, type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, type GraphCompilation, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObstacleKind, type PlacementObstacle, type SimulationConfig, type ValidationError, type ValidationErrorCode, type ValidationResult, clampStaggerDelay, clearRenderers, compile, compileBarList, compileChart, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, evaluatePredicate, getChartRenderer, heuristicMeasure, isConditionalValueDef, normalizeSpec, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, validateSpec };
|
|
795
|
+
export { type AnnotationContext, type AnnotationMeasureTextFn, type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, ENTER_DEFAULTS, EXIT_DEFAULTS, type GraphCompilation, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObstacleKind, type PlacementObstacle, type SimulationConfig, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, buildAreaPath, buildLinePath, clampStaggerDelay, clearRenderers, compile, compileBarList, compileChart, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, dedupeKeys, evaluatePredicate, getChartRenderer, heuristicMeasure, isConditionalValueDef, normalizeSpec, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, validateSpec };
|