@opendata-ai/openchart-engine 9.0.0-rc.1 → 9.0.0-rc.2

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
@@ -997,6 +997,11 @@ declare function parseAnnotationSpans(line: string): RichSpan[];
997
997
  * @returns A NormalizedSpec with all optionals filled.
998
998
  */
999
999
  declare function normalizeSpec(spec: VizSpec, warnings?: string[]): NormalizedSpec;
1000
+ /**
1001
+ * Recursively flatten a LayerSpec into leaf ChartSpecs.
1002
+ * Merges parent data, encoding, and transforms down to children.
1003
+ */
1004
+ declare function flattenLayers(spec: LayerSpec, parentData?: DataRow[], parentEncoding?: Encoding, parentTransforms?: _opendata_ai_openchart_core.Transform[], parentWatermark?: boolean, parentEndpointLabels?: boolean | _opendata_ai_openchart_core.EndpointLabelsConfig): ChartSpec[];
1000
1005
 
1001
1006
  /** Validate authored mark contracts before any sugar transformation. */
1002
1007
  declare function validateSpec(spec: unknown): ValidationResult;
@@ -1407,4 +1412,4 @@ declare function migrateSpecV8<T>(input: T, options?: {
1407
1412
  /** Author order and supplementary fields survive; formatted text never decides identity. */
1408
1413
  declare function sharedTooltipFields(content: TooltipContent): TooltipField[];
1409
1414
 
1410
- export { ARROWHEAD_LENGTH, AUTO_CANVAS_THRESHOLD, type AnnotationContext, type AnnotationEditContext, type AnnotationMeasureTextFn, type AppliedSpecPatch, type ArrowheadPoints, BOLD_SPAN_FONT_WEIGHT, type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, DEFAULT_ANNOTATION_FONT_SIZE, DEFAULT_LINE_HEIGHT, ENTER_DEFAULTS, EXIT_DEFAULTS, type GeoReaderIndex, type GeoReaderRecord, type GraphCompilation, MAX_3D_NODES, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGeoMapSpec, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObservationComparison, type ObstacleKind, type PlacementObstacle, type ReaderPanelIndex, type ReaderSliceIndex, type RecommendationResult, type RecommendationRoles, type RichSpan, type SimulationConfig, type SpecRepair, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, applySpecPatch, automaticControlPoint, buildArcPath, buildAreaPath, buildEdgeTooltip, buildGeoReaderIndex, buildLinePath, buildReaderSliceIndex, clampStaggerDelay, clearRenderers, compareObservations, compareReaderValues, compile, compileBarList, compileChart, compileGeoMap, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, computeArrowheadPoints, createAnnotationEditContext, dedupeKeys, diagnoseChart, evaluatePredicate, facetMinHeight, geoColorKeyPosition, getChartRenderer, heuristicMeasure, interpolateAnnotationGeometry, inverseLabelPlacement, isConditionalValueDef, legendGap, linkedEntityKeys, migrateSpecV8, nearestReaderSlice, normalizeSpec, observationKey, parseAnnotationSpans, previewAnnotationMove, previewConnectorBend, previewConnectorOffset, queryGeoReaderRecords, readerDomainValue, readerSliceByKey, recommendCompositions, reconcileReaderSelection, reconcileReaderSlices, refreshConnector, registerChartRenderer, resolveAnimation, resolveConditionalValue, resolveGeoOverlay, resolveLayerTheme, resolveObservationIdentities, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, sharedTooltipFields, validateSpec };
1415
+ export { ARROWHEAD_LENGTH, AUTO_CANVAS_THRESHOLD, type AnnotationContext, type AnnotationEditContext, type AnnotationMeasureTextFn, type AppliedSpecPatch, type ArrowheadPoints, BOLD_SPAN_FONT_WEIGHT, type ChartRenderer, type CompileResult, type CompiledGraphEdge, type CompiledGraphNode, DEFAULT_ANNOTATION_FONT_SIZE, DEFAULT_LINE_HEIGHT, ENTER_DEFAULTS, EXIT_DEFAULTS, type GeoReaderIndex, type GeoReaderRecord, type GraphCompilation, MAX_3D_NODES, type NormalizedBarListSpec, type NormalizedChartSpec, type NormalizedChrome, type NormalizedGeoMapSpec, type NormalizedGraphSpec, type NormalizedSankeySpec, type NormalizedSpec, type NormalizedTableSpec, type NormalizedTileMapSpec, type ObservationComparison, type ObstacleKind, type PlacementObstacle, type ReaderPanelIndex, type ReaderSliceIndex, type RecommendationResult, type RecommendationRoles, type RichSpan, type SimulationConfig, type SpecRepair, UPDATE_DEFAULTS, type ValidationError, type ValidationErrorCode, type ValidationResult, applySpecPatch, automaticControlPoint, buildArcPath, buildAreaPath, buildEdgeTooltip, buildGeoReaderIndex, buildLinePath, buildReaderSliceIndex, clampStaggerDelay, clearRenderers, compareObservations, compareReaderValues, compile, compileBarList, compileChart, compileGeoMap, compileGraph, compileLayer, compileSankey, compileTable, compileTileMap, computeArrowheadPoints, createAnnotationEditContext, dedupeKeys, diagnoseChart, evaluatePredicate, facetMinHeight, flattenLayers, geoColorKeyPosition, getChartRenderer, heuristicMeasure, interpolateAnnotationGeometry, inverseLabelPlacement, isConditionalValueDef, legendGap, linkedEntityKeys, migrateSpecV8, nearestReaderSlice, normalizeSpec, observationKey, parseAnnotationSpans, previewAnnotationMove, previewConnectorBend, previewConnectorOffset, queryGeoReaderRecords, readerDomainValue, readerSliceByKey, recommendCompositions, reconcileReaderSelection, reconcileReaderSlices, refreshConnector, registerChartRenderer, resolveAnimation, resolveConditionalValue, resolveGeoOverlay, resolveLayerTheme, resolveObservationIdentities, runBin, runCalculate, runFilter, runTimeUnit, runTransforms, serializeKeyValue, sharedTooltipFields, validateSpec };
package/dist/index.js CHANGED
@@ -4158,7 +4158,7 @@ function computeRuleMarks(spec, scales, chartArea) {
4158
4158
  aria
4159
4159
  });
4160
4160
  }
4161
- const posField = xChannel?.field ?? yChannel?.field;
4161
+ const posField = (encoding.key && "field" in encoding.key ? encoding.key.field : void 0) ?? xChannel?.field ?? yChannel?.field;
4162
4162
  const rawKeys = marks.map((m, i) => posField ? serializeKeyValue(m.data[posField]) : String(i));
4163
4163
  const keys = dedupeKeys(rawKeys);
4164
4164
  for (let i = 0; i < marks.length; i++) {
@@ -18445,19 +18445,18 @@ function mergeEncoding(base, bpEnc) {
18445
18445
  for (const channel of Object.keys(bpEnc)) {
18446
18446
  const baseCh = mergedEncoding[channel];
18447
18447
  const bpCh = bpEnc[channel];
18448
- if (bpCh && baseCh) {
18449
- const merged = { ...baseCh, ...bpCh };
18450
- for (const key of NESTED_CHANNEL_KEYS) {
18451
- const baseNested = baseCh[key];
18452
- const bpNested = bpCh[key];
18453
- if (baseNested && bpNested && typeof baseNested === "object" && typeof bpNested === "object" && !Array.isArray(baseNested) && !Array.isArray(bpNested)) {
18454
- merged[key] = { ...baseNested, ...bpNested };
18455
- }
18448
+ if (!baseCh || typeof baseCh !== "object" || Array.isArray(baseCh) || !bpCh || typeof bpCh !== "object" || Array.isArray(bpCh)) {
18449
+ continue;
18450
+ }
18451
+ const merged = { ...baseCh, ...bpCh };
18452
+ for (const key of NESTED_CHANNEL_KEYS) {
18453
+ const baseNested = baseCh[key];
18454
+ const bpNested = bpCh[key];
18455
+ if (baseNested && bpNested && typeof baseNested === "object" && typeof bpNested === "object" && !Array.isArray(baseNested) && !Array.isArray(bpNested)) {
18456
+ merged[key] = { ...baseNested, ...bpNested };
18456
18457
  }
18457
- mergedEncoding[channel] = merged;
18458
- } else if (bpCh) {
18459
- mergedEncoding[channel] = bpCh;
18460
18458
  }
18459
+ mergedEncoding[channel] = merged;
18461
18460
  }
18462
18461
  return mergedEncoding;
18463
18462
  }
@@ -20024,6 +20023,7 @@ function buildPrimarySpec(leaves, layerSpec) {
20024
20023
  ...leaves[0],
20025
20024
  data: allData,
20026
20025
  chrome: layerSpec.chrome ?? leaves[0].chrome,
20026
+ animation: layerSpec.animation ?? leaves[0].animation,
20027
20027
  // Annotations come from the parent LayerSpec when present, otherwise
20028
20028
  // the first flattened leaf's. Later leaves' annotations are silently
20029
20029
  // dropped. The dual-axis path (compileLayerIndependent) explicitly
@@ -28685,6 +28685,7 @@ export {
28685
28685
  diagnoseChart,
28686
28686
  evaluatePredicate,
28687
28687
  facetMinHeight,
28688
+ flattenLayers,
28688
28689
  geoColorKeyPosition,
28689
28690
  getChartRenderer,
28690
28691
  heuristicMeasure,