@opendata-ai/openchart-engine 6.27.2 → 6.28.4
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 +38 -6
- package/dist/index.js +1032 -521
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/compile-snapshot.test.ts.snap +31 -4
- package/src/__tests__/legend.test.ts +2 -2
- package/src/barlist/__tests__/compile-barlist.test.ts +200 -0
- package/src/barlist/compile-barlist.ts +380 -0
- package/src/barlist/types.ts +28 -0
- package/src/charts/bar/__tests__/compute.test.ts +120 -0
- package/src/charts/bar/compute.ts +77 -45
- package/src/charts/bar/index.ts +1 -0
- package/src/charts/bar/labels.ts +3 -2
- package/src/charts/column/compute.ts +60 -27
- package/src/charts/column/index.ts +1 -0
- package/src/charts/column/labels.ts +2 -1
- package/src/charts/line/__tests__/compute.test.ts +2 -2
- package/src/charts/line/area.ts +25 -4
- package/src/charts/line/compute.ts +15 -5
- package/src/compile.ts +26 -1
- package/src/compiler/normalize.ts +25 -1
- package/src/compiler/types.ts +5 -3
- package/src/compiler/validate.ts +120 -5
- package/src/index.ts +5 -0
- package/src/layout/axes/ticks.ts +6 -4
- package/src/layout/axes.ts +2 -2
- package/src/layout/dimensions.ts +10 -4
- package/src/layout/scales.ts +10 -0
- package/src/legend/wrap.ts +1 -1
- package/src/tables/__tests__/heatmap.test.ts +22 -0
- package/src/tables/heatmap.ts +28 -0
- package/src/tilemap/__tests__/compile-tilemap.test.ts +10 -5
- package/src/tilemap/compile-tilemap.ts +51 -30
- package/src/tooltips/compute.ts +4 -2
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,
|
|
3
|
-
export { ChartLayout, ChartSpec, CompileOptions, CompileTableOptions, GraphLayout, GraphSpec, LayerSpec, SankeyLayout, SankeySpec, TableLayout, TableSpec, TileMapLayout, TileMapSpec, VizSpec } 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, VizSpec, ScaleType, EncodingChannel, Rect, LayoutStrategy, Mark, BinTransform, CalculateTransform, ConditionalValueDef, FilterPredicate, TimeUnitTransform, Transform } from '@opendata-ai/openchart-core';
|
|
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
|
|
|
6
6
|
/**
|
|
@@ -182,6 +182,19 @@ declare function compileSankey(spec: unknown, options: CompileOptions): _opendat
|
|
|
182
182
|
* @throws Error if spec is invalid or not a tilemap type.
|
|
183
183
|
*/
|
|
184
184
|
declare function compileTileMap(spec: unknown, options: CompileOptions): _opendata_ai_openchart_core.TileMapLayout;
|
|
185
|
+
/**
|
|
186
|
+
* Compile a barlist spec into a BarListLayout.
|
|
187
|
+
*
|
|
188
|
+
* Takes a raw barlist spec, validates, normalizes, resolves theme and chrome,
|
|
189
|
+
* computes row layout with proportional bars, builds tooltips, and returns
|
|
190
|
+
* a BarListLayout ready for rendering.
|
|
191
|
+
*
|
|
192
|
+
* @param spec - Raw barlist spec (validated and normalized internally).
|
|
193
|
+
* @param options - Compile options (width, height, theme, darkMode).
|
|
194
|
+
* @returns BarListLayout with computed positions and visual properties.
|
|
195
|
+
* @throws Error if spec is invalid or not a barlist type.
|
|
196
|
+
*/
|
|
197
|
+
declare function compileBarList(spec: unknown, options: CompileOptions): _opendata_ai_openchart_core.BarListLayout;
|
|
185
198
|
|
|
186
199
|
/**
|
|
187
200
|
* Animation resolver: normalizes AnimationSpec into fully resolved config.
|
|
@@ -202,6 +215,25 @@ declare function resolveAnimation(spec: AnimationSpec | undefined): ResolvedAnim
|
|
|
202
215
|
*/
|
|
203
216
|
declare function clampStaggerDelay(delay: number, elementCount: number): number;
|
|
204
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Internal normalized barlist spec type used by the compilation pipeline.
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
interface NormalizedBarListSpec {
|
|
223
|
+
type: 'barlist';
|
|
224
|
+
data: DataRow[];
|
|
225
|
+
encoding: BarListEncoding;
|
|
226
|
+
barHeight: number;
|
|
227
|
+
cornerRadius: number | 'pill';
|
|
228
|
+
maxItems: number;
|
|
229
|
+
chrome: NormalizedChrome;
|
|
230
|
+
theme: ThemeConfig;
|
|
231
|
+
darkMode: DarkMode;
|
|
232
|
+
watermark: boolean;
|
|
233
|
+
animation?: AnimationSpec;
|
|
234
|
+
valueFormat?: string;
|
|
235
|
+
}
|
|
236
|
+
|
|
205
237
|
/**
|
|
206
238
|
* Internal normalized tilemap spec type used by the compilation pipeline.
|
|
207
239
|
*
|
|
@@ -270,8 +302,8 @@ interface NormalizedChartSpec {
|
|
|
270
302
|
encoding: Encoding;
|
|
271
303
|
chrome: NormalizedChrome;
|
|
272
304
|
annotations: Annotation[];
|
|
273
|
-
/** Normalized label configuration with defaults applied. density, format, and prefix are always set; offsets
|
|
274
|
-
labels: Required<Pick<LabelConfig, 'density' | 'format' | 'prefix'>> & Pick<LabelConfig, 'offsets'>;
|
|
305
|
+
/** Normalized label configuration with defaults applied. density, format, and prefix are always set; offsets and color stay optional. */
|
|
306
|
+
labels: Required<Pick<LabelConfig, 'density' | 'format' | 'prefix'>> & Pick<LabelConfig, 'offsets' | 'color'>;
|
|
275
307
|
/** Legend configuration (position override). */
|
|
276
308
|
legend?: LegendConfig;
|
|
277
309
|
responsive: boolean;
|
|
@@ -326,7 +358,7 @@ interface NormalizedGraphSpec {
|
|
|
326
358
|
watermark: boolean;
|
|
327
359
|
}
|
|
328
360
|
/** Discriminated union of all normalized spec types. */
|
|
329
|
-
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec;
|
|
361
|
+
type NormalizedSpec = NormalizedChartSpec | NormalizedTableSpec | NormalizedGraphSpec | NormalizedSankeySpec | NormalizedTileMapSpec | NormalizedBarListSpec;
|
|
330
362
|
/** Machine-readable error code for programmatic handling. */
|
|
331
363
|
type ValidationErrorCode = 'MISSING_FIELD' | 'INVALID_TYPE' | 'INVALID_VALUE' | 'ENCODING_MISMATCH' | 'DATA_FIELD_MISSING' | 'EMPTY_DATA';
|
|
332
364
|
/** A single validation error with context. */
|
|
@@ -642,4 +674,4 @@ declare function runTimeUnit(data: DataRow[], transform: TimeUnitTransform): Dat
|
|
|
642
674
|
*/
|
|
643
675
|
declare function runTransforms(data: DataRow[], transforms: Transform[]): DataRow[];
|
|
644
676
|
|
|
645
|
-
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 };
|
|
677
|
+
export { 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 SimulationConfig, type ValidationError, type ValidationErrorCode, type ValidationResult, clampStaggerDelay, clearRenderers, compile, compileBarList, compileChart, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, evaluatePredicate, getChartRenderer, isConditionalValueDef, normalizeSpec, registerChartRenderer, resolveAnimation, resolveConditionalValue, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, validateSpec };
|