@opendata-ai/openchart-engine 6.25.1 → 6.25.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.js +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/compile.ts +18 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendata-ai/openchart-engine",
|
|
3
|
-
"version": "6.25.
|
|
3
|
+
"version": "6.25.2",
|
|
4
4
|
"description": "Headless compiler for openchart: spec validation, data compilation, scales, and layout",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Riley Hilliard",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"typecheck": "tsc --noEmit"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@opendata-ai/openchart-core": "6.25.
|
|
51
|
+
"@opendata-ai/openchart-core": "6.25.2",
|
|
52
52
|
"d3-array": "^3.2.0",
|
|
53
53
|
"d3-format": "^3.1.2",
|
|
54
54
|
"d3-interpolate": "^3.0.0",
|
package/src/compile.ts
CHANGED
|
@@ -500,7 +500,15 @@ export function compileLayer(spec: LayerSpec, options: CompileOptions): ChartLay
|
|
|
500
500
|
seenLabels.add(entry.label);
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
-
for
|
|
503
|
+
// Sort leaves by zIndex for render order while preserving original indices
|
|
504
|
+
// for axis assignment. Default zIndex is the array position.
|
|
505
|
+
const indexedLeaves = leaves.map((leaf, i) => ({
|
|
506
|
+
leaf,
|
|
507
|
+
zIndex: (leaf as ChartSpec).zIndex ?? i,
|
|
508
|
+
}));
|
|
509
|
+
indexedLeaves.sort((a, b) => a.zIndex - b.zIndex);
|
|
510
|
+
|
|
511
|
+
for (const { leaf } of indexedLeaves) {
|
|
504
512
|
const leafLayout = compileChart(leaf as unknown, options);
|
|
505
513
|
|
|
506
514
|
allMarks.push(...leafLayout.marks);
|
|
@@ -821,6 +829,14 @@ function compileLayerIndependent(
|
|
|
821
829
|
}
|
|
822
830
|
}
|
|
823
831
|
|
|
832
|
+
// Determine mark render order. By default, layer 0 paints first (behind),
|
|
833
|
+
// layer 1 paints second (on top). zIndex on the original leaf specs can
|
|
834
|
+
// reverse this so e.g. a line in layer 0 renders on top of bars in layer 1.
|
|
835
|
+
const z0 = leaf0.zIndex ?? 0;
|
|
836
|
+
const z1 = leaf1.zIndex ?? 1;
|
|
837
|
+
const marks =
|
|
838
|
+
z0 <= z1 ? [...adjustedMarks0, ...taggedMarks1] : [...taggedMarks1, ...adjustedMarks0];
|
|
839
|
+
|
|
824
840
|
return {
|
|
825
841
|
...layout0,
|
|
826
842
|
axes: {
|
|
@@ -828,7 +844,7 @@ function compileLayerIndependent(
|
|
|
828
844
|
y: layout0.axes.y,
|
|
829
845
|
y2: y2Axis,
|
|
830
846
|
},
|
|
831
|
-
marks
|
|
847
|
+
marks,
|
|
832
848
|
legend: {
|
|
833
849
|
...layout0.legend,
|
|
834
850
|
entries: mergedLegendEntries,
|