@opendata-ai/openchart-engine 6.28.5 → 7.0.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.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/dist/index.d.ts +8 -11
  3. package/dist/index.js +12297 -11338
  4. package/dist/index.js.map +1 -1
  5. package/package.json +2 -2
  6. package/src/__test-fixtures__/specs.ts +3 -0
  7. package/src/__tests__/__snapshots__/compile-snapshot.test.ts.snap +452 -377
  8. package/src/__tests__/axes.test.ts +75 -0
  9. package/src/__tests__/compile-chart.test.ts +304 -0
  10. package/src/__tests__/dimensions.test.ts +224 -0
  11. package/src/__tests__/legend.test.ts +44 -3
  12. package/src/annotations/__tests__/compute.test.ts +111 -0
  13. package/src/annotations/__tests__/resolve-text.test.ts +288 -0
  14. package/src/annotations/constants.ts +20 -0
  15. package/src/annotations/resolve-text.ts +161 -7
  16. package/src/charts/bar/compute.ts +24 -0
  17. package/src/charts/bar/labels.ts +1 -0
  18. package/src/charts/column/compute.ts +33 -1
  19. package/src/charts/column/labels.ts +1 -0
  20. package/src/charts/dot/labels.ts +1 -0
  21. package/src/charts/line/__tests__/compute.test.ts +153 -3
  22. package/src/charts/line/area.ts +111 -23
  23. package/src/charts/line/compute.ts +40 -10
  24. package/src/charts/line/index.ts +34 -7
  25. package/src/charts/line/labels.ts +29 -0
  26. package/src/charts/pie/labels.ts +1 -0
  27. package/src/compile/layer.ts +497 -0
  28. package/src/compile.ts +211 -586
  29. package/src/compiler/__tests__/sparkline-defaults.test.ts +153 -0
  30. package/src/compiler/normalize.ts +6 -1
  31. package/src/compiler/sparkline-defaults.ts +138 -0
  32. package/src/compiler/types.ts +8 -0
  33. package/src/endpoint-labels/__tests__/compute.test.ts +438 -0
  34. package/src/endpoint-labels/compute.ts +417 -0
  35. package/src/endpoint-labels/constants.ts +54 -0
  36. package/src/endpoint-labels/format.ts +30 -0
  37. package/src/endpoint-labels/predict.ts +108 -0
  38. package/src/graphs/compile-graph.ts +1 -0
  39. package/src/layout/axes.ts +27 -2
  40. package/src/layout/dimensions.ts +270 -33
  41. package/src/layout/metrics.ts +118 -0
  42. package/src/layout/scales.ts +41 -4
  43. package/src/legend/__tests__/suppression.test.ts +294 -0
  44. package/src/legend/compute.ts +50 -40
  45. package/src/legend/suppression.ts +204 -0
  46. package/src/sankey/compile-sankey.ts +2 -0
  47. package/src/tables/__tests__/heatmap.test.ts +4 -27
  48. package/src/tables/heatmap.ts +6 -2
package/README.md CHANGED
@@ -38,6 +38,7 @@ const layout = compileChart(chartSpec, { width: 600, height: 400 });
38
38
  // layout.marks: positioned line paths, bar rects, arc segments, etc.
39
39
  // layout.axes: tick positions, labels, format strings
40
40
  // layout.legend: entries, position, dimensions
41
+ // layout.endpointLabels: per-series chip+swatch labels at the trailing point (line/area), driven by `layout.endpointLabels: EndpointLabelsLayout` on the spec
41
42
  // layout.annotations: pixel-positioned annotation elements
42
43
  // layout.theme: fully resolved theme with all defaults filled
43
44
  ```
package/dist/index.d.ts CHANGED
@@ -118,17 +118,6 @@ interface GraphCompilation {
118
118
  * @throws Error if spec is invalid or not a chart type.
119
119
  */
120
120
  declare function compileChart(spec: unknown, options: CompileOptions): ChartLayout;
121
- /**
122
- * Compile a LayerSpec into a single ChartLayout.
123
- *
124
- * Flattens nested layers, merges inherited data/encoding/transforms,
125
- * compiles each leaf layer independently, unions scale domains (shared
126
- * by default), and concatenates marks in layer order.
127
- *
128
- * @param spec - A LayerSpec with child layers.
129
- * @param options - Compile options (width, height, theme, darkMode).
130
- * @returns A single ChartLayout with combined marks from all layers.
131
- */
132
121
  declare function compileLayer(spec: LayerSpec, options: CompileOptions): ChartLayout;
133
122
  /**
134
123
  * Compile a table spec into a TableLayout.
@@ -258,11 +247,13 @@ interface NormalizedTileMapSpec {
258
247
 
259
248
  /** Chrome with all string values normalized to ChromeText objects. */
260
249
  interface NormalizedChrome {
250
+ eyebrow?: ChromeText;
261
251
  title?: ChromeText;
262
252
  subtitle?: ChromeText;
263
253
  source?: ChromeText;
264
254
  byline?: ChromeText;
265
255
  footer?: ChromeText;
256
+ brand?: ChromeText;
266
257
  }
267
258
  /**
268
259
  * Tracks which top-level fields the user explicitly set in their input spec.
@@ -279,6 +270,8 @@ interface UserExplicit {
279
270
  chrome: boolean;
280
271
  /** True if user wrote `legend`. */
281
272
  legend: boolean;
273
+ /** True if user wrote `endpointLabels`. */
274
+ endpointLabels: boolean;
282
275
  /** True if user wrote `encoding.x.axis`. */
283
276
  xAxis: boolean;
284
277
  /** True if user wrote `encoding.y.axis`. */
@@ -301,11 +294,15 @@ interface NormalizedChartSpec {
301
294
  data: DataRow[];
302
295
  encoding: Encoding;
303
296
  chrome: NormalizedChrome;
297
+ /** Optional KPI metric cells, passed through unchanged. */
298
+ metrics?: _opendata_ai_openchart_core.Metric[];
304
299
  annotations: Annotation[];
305
300
  /** Normalized label configuration with defaults applied. density, format, and prefix are always set; offsets and color stay optional. */
306
301
  labels: Required<Pick<LabelConfig, 'density' | 'format' | 'prefix'>> & Pick<LabelConfig, 'offsets' | 'color'>;
307
302
  /** Legend configuration (position override). */
308
303
  legend?: LegendConfig;
304
+ /** Right-side endpoint labels column config (multi-series line/area only). */
305
+ endpointLabels?: boolean | _opendata_ai_openchart_core.EndpointLabelsConfig;
309
306
  responsive: boolean;
310
307
  theme: ThemeConfig;
311
308
  darkMode: DarkMode;