@opendata-ai/openchart-engine 6.25.4 → 6.26.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 +46 -4
- package/dist/index.js +862 -66
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/compound-labels.test.ts +147 -0
- package/src/compile.ts +47 -13
- package/src/compiler/normalize.ts +57 -1
- package/src/compiler/types.ts +3 -1
- package/src/compiler/validate.ts +124 -5
- package/src/index.ts +16 -1
- package/src/layout/axes/ticks.ts +34 -2
- package/src/layout/axes.ts +27 -1
- package/src/layout/dimensions.ts +21 -3
- package/src/sankey/compile-sankey.ts +1 -1
- package/src/tilemap/__tests__/compile-tilemap.test.ts +322 -0
- package/src/tilemap/compile-tilemap.ts +383 -0
- package/src/tilemap/layout.ts +172 -0
- package/src/tilemap/types.ts +32 -0
- package/src/transforms/__tests__/filter-relative.test.ts +202 -0
- package/src/transforms/__tests__/window.test.ts +286 -0
- package/src/transforms/filter.ts +108 -3
- package/src/transforms/index.ts +5 -1
- package/src/transforms/predicates.ts +39 -9
- package/src/transforms/window.ts +185 -0
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,
|
|
3
|
-
export { ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GraphLayout, GraphSpec, LayerSpec, SankeyLayout, SankeySpec, TableLayout, TableSpec, VizSpec } from '@opendata-ai/openchart-core';
|
|
2
|
+
import { LegendLayout, ResolvedChrome, TooltipContent, A11yMetadata, ResolvedTheme, CompileOptions, ChartLayout, LayerSpec, CompileTableOptions, TableLayout, AnimationSpec, ResolvedAnimation, TileMapEncoding, TileMapPalette, LegendConfig, ThemeConfig, DarkMode, MarkType, MarkDef, DataRow, Encoding, ChromeText, Annotation, LabelConfig, 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, 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
6
|
/**
|
|
@@ -169,6 +169,19 @@ declare function compileGraph(spec: unknown, options: CompileOptions): GraphComp
|
|
|
169
169
|
* @throws Error if spec is invalid or not a sankey type.
|
|
170
170
|
*/
|
|
171
171
|
declare function compileSankey(spec: unknown, options: CompileOptions): _opendata_ai_openchart_core.SankeyLayout;
|
|
172
|
+
/**
|
|
173
|
+
* Compile a tilemap spec into a TileMapLayout.
|
|
174
|
+
*
|
|
175
|
+
* Takes a raw tilemap spec, validates, normalizes, resolves theme and chrome,
|
|
176
|
+
* computes tile positions, builds tile marks with colors and labels, and
|
|
177
|
+
* returns a TileMapLayout ready for rendering.
|
|
178
|
+
*
|
|
179
|
+
* @param spec - Raw tilemap spec (validated and normalized internally).
|
|
180
|
+
* @param options - Compile options (width, height, theme, darkMode).
|
|
181
|
+
* @returns TileMapLayout with computed positions and visual properties.
|
|
182
|
+
* @throws Error if spec is invalid or not a tilemap type.
|
|
183
|
+
*/
|
|
184
|
+
declare function compileTileMap(spec: unknown, options: CompileOptions): _opendata_ai_openchart_core.TileMapLayout;
|
|
172
185
|
|
|
173
186
|
/**
|
|
174
187
|
* Animation resolver: normalizes AnimationSpec into fully resolved config.
|
|
@@ -189,6 +202,28 @@ declare function resolveAnimation(spec: AnimationSpec | undefined): ResolvedAnim
|
|
|
189
202
|
*/
|
|
190
203
|
declare function clampStaggerDelay(delay: number, elementCount: number): number;
|
|
191
204
|
|
|
205
|
+
/**
|
|
206
|
+
* Internal normalized tilemap spec type used by the compilation pipeline.
|
|
207
|
+
*
|
|
208
|
+
* This mirrors NormalizedSankeySpec: all optional fields have been filled
|
|
209
|
+
* with sensible defaults. It's an engine implementation detail, not a public contract.
|
|
210
|
+
*/
|
|
211
|
+
|
|
212
|
+
/** A TileMapSpec with all optional fields filled with defaults. */
|
|
213
|
+
interface NormalizedTileMapSpec {
|
|
214
|
+
type: 'tilemap';
|
|
215
|
+
data: Record<string, unknown>[];
|
|
216
|
+
encoding: TileMapEncoding;
|
|
217
|
+
palette: TileMapPalette;
|
|
218
|
+
chrome: NormalizedChrome;
|
|
219
|
+
legend?: LegendConfig;
|
|
220
|
+
theme: ThemeConfig;
|
|
221
|
+
darkMode: DarkMode;
|
|
222
|
+
watermark: boolean;
|
|
223
|
+
animation?: AnimationSpec;
|
|
224
|
+
valueFormat?: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
192
227
|
/** Chrome with all string values normalized to ChromeText objects. */
|
|
193
228
|
interface NormalizedChrome {
|
|
194
229
|
title?: ChromeText;
|
|
@@ -255,7 +290,7 @@ interface NormalizedGraphSpec {
|
|
|
255
290
|
watermark: boolean;
|
|
256
291
|
}
|
|
257
292
|
/** Discriminated union of all normalized spec types. */
|
|
258
|
-
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec;
|
|
293
|
+
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec;
|
|
259
294
|
/** Machine-readable error code for programmatic handling. */
|
|
260
295
|
type ValidationErrorCode = 'MISSING_FIELD' | 'INVALID_TYPE' | 'INVALID_VALUE' | 'ENCODING_MISMATCH' | 'DATA_FIELD_MISSING' | 'EMPTY_DATA';
|
|
261
296
|
/** A single validation error with context. */
|
|
@@ -499,11 +534,18 @@ declare function isConditionalValueDef(def: unknown): def is ConditionalValueDef
|
|
|
499
534
|
|
|
500
535
|
/**
|
|
501
536
|
* Filter transform: removes rows that don't match a predicate.
|
|
537
|
+
*
|
|
538
|
+
* Supports RelativeTimeRef values on comparison properties (lt, lte, gt, gte, range).
|
|
539
|
+
* These are resolved against the data extent before filtering.
|
|
502
540
|
*/
|
|
503
541
|
|
|
504
542
|
/**
|
|
505
543
|
* Filter data rows by a predicate.
|
|
506
544
|
*
|
|
545
|
+
* If the predicate contains RelativeTimeRef values, they are resolved
|
|
546
|
+
* against the data extent first, then the standard evaluatePredicate
|
|
547
|
+
* logic runs per-row.
|
|
548
|
+
*
|
|
507
549
|
* @param data - Input rows.
|
|
508
550
|
* @param predicate - Filter predicate to evaluate per row.
|
|
509
551
|
* @returns Rows that pass the predicate.
|
|
@@ -564,4 +606,4 @@ declare function runTimeUnit(data: DataRow[], transform: TimeUnitTransform): Dat
|
|
|
564
606
|
*/
|
|
565
607
|
declare function runTransforms(data: DataRow[], transforms: Transform[]): DataRow[];
|
|
566
608
|
|
|
567
|
-
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 };
|
|
609
|
+
export { type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, type GraphCompilation, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type SimulationConfig, type ValidationError, type ValidationErrorCode, type ValidationResult, clampStaggerDelay, clearRenderers, compile, compileChart, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, evaluatePredicate, getChartRenderer, isConditionalValueDef, normalizeSpec, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, validateSpec };
|