@opendata-ai/openchart-engine 8.0.0-rc.17 → 8.0.0-rc.18
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 +69 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15430,11 +15430,9 @@ function compileLayerIndependent(leaves, layerSpec, options, compileChart2) {
|
|
|
15430
15430
|
};
|
|
15431
15431
|
const xField0 = leaf0.encoding?.x?.field;
|
|
15432
15432
|
const xField1 = leaf1.encoding?.x?.field;
|
|
15433
|
-
const
|
|
15434
|
-
|
|
15435
|
-
|
|
15436
|
-
let leaf0WithUnionX = ensureXDomainCoverage(leaf0, xField0, unionXValues);
|
|
15437
|
-
let leaf1WithUnionX = ensureXDomainCoverage(leaf1, xField1, unionXValues);
|
|
15433
|
+
const union = withUnionXDomain(leaf0, leaf1);
|
|
15434
|
+
let leaf0WithUnionX = union.leaf0;
|
|
15435
|
+
let leaf1WithUnionX = union.leaf1;
|
|
15438
15436
|
const aligned = alignYDomains(leaf0WithUnionX, leaf1WithUnionX);
|
|
15439
15437
|
if (aligned) {
|
|
15440
15438
|
leaf0WithUnionX = withYDomain(leaf0WithUnionX, aligned.domain0);
|
|
@@ -15581,20 +15579,75 @@ function compileLayerIndependent(leaves, layerSpec, options, compileChart2) {
|
|
|
15581
15579
|
tooltipDescriptors: mergedTooltips
|
|
15582
15580
|
};
|
|
15583
15581
|
}
|
|
15584
|
-
function
|
|
15585
|
-
if (!
|
|
15586
|
-
|
|
15587
|
-
|
|
15588
|
-
|
|
15589
|
-
|
|
15590
|
-
|
|
15591
|
-
|
|
15582
|
+
function withXDomain(leaf, domain) {
|
|
15583
|
+
if (!leaf.encoding?.x) return leaf;
|
|
15584
|
+
return {
|
|
15585
|
+
...leaf,
|
|
15586
|
+
encoding: {
|
|
15587
|
+
...leaf.encoding,
|
|
15588
|
+
x: {
|
|
15589
|
+
...leaf.encoding.x,
|
|
15590
|
+
scale: {
|
|
15591
|
+
...leaf.encoding.x.scale,
|
|
15592
|
+
domain
|
|
15593
|
+
}
|
|
15594
|
+
}
|
|
15592
15595
|
}
|
|
15596
|
+
};
|
|
15597
|
+
}
|
|
15598
|
+
function withUnionXDomain(leaf0, leaf1) {
|
|
15599
|
+
const xEnc0 = leaf0.encoding?.x;
|
|
15600
|
+
const xEnc1 = leaf1.encoding?.x;
|
|
15601
|
+
const xField0 = xEnc0?.field;
|
|
15602
|
+
const xField1 = xEnc1?.field;
|
|
15603
|
+
if (!xField0 || !xField1) return { leaf0, leaf1 };
|
|
15604
|
+
const xType = xEnc0?.type ?? xEnc1?.type;
|
|
15605
|
+
const pinned0 = xEnc0?.scale?.domain !== void 0;
|
|
15606
|
+
const pinned1 = xEnc1?.scale?.domain !== void 0;
|
|
15607
|
+
if (pinned0 && pinned1) return { leaf0, leaf1 };
|
|
15608
|
+
const values0 = leaf0.data.map((row) => row[xField0]);
|
|
15609
|
+
const values1 = leaf1.data.map((row) => row[xField1]);
|
|
15610
|
+
const allValues = [...values0, ...values1].filter((v) => v != null);
|
|
15611
|
+
if (allValues.length === 0) return { leaf0, leaf1 };
|
|
15612
|
+
let domain;
|
|
15613
|
+
if (xType === "temporal") {
|
|
15614
|
+
let minMs = Number.POSITIVE_INFINITY;
|
|
15615
|
+
let maxMs = Number.NEGATIVE_INFINITY;
|
|
15616
|
+
for (const v of allValues) {
|
|
15617
|
+
const ms = (v instanceof Date ? v : new Date(String(v))).getTime();
|
|
15618
|
+
if (Number.isNaN(ms)) continue;
|
|
15619
|
+
if (ms < minMs) minMs = ms;
|
|
15620
|
+
if (ms > maxMs) maxMs = ms;
|
|
15621
|
+
}
|
|
15622
|
+
if (minMs <= maxMs) {
|
|
15623
|
+
domain = [new Date(minMs).toISOString(), new Date(maxMs).toISOString()];
|
|
15624
|
+
}
|
|
15625
|
+
} else if (xType === "quantitative") {
|
|
15626
|
+
let min4 = Number.POSITIVE_INFINITY;
|
|
15627
|
+
let max4 = Number.NEGATIVE_INFINITY;
|
|
15628
|
+
for (const v of allValues) {
|
|
15629
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
15630
|
+
if (!Number.isFinite(n)) continue;
|
|
15631
|
+
if (n < min4) min4 = n;
|
|
15632
|
+
if (n > max4) max4 = n;
|
|
15633
|
+
}
|
|
15634
|
+
if (min4 <= max4) domain = [min4, max4];
|
|
15635
|
+
} else {
|
|
15636
|
+
const seen = /* @__PURE__ */ new Set();
|
|
15637
|
+
const categories = [];
|
|
15638
|
+
for (const v of allValues) {
|
|
15639
|
+
const s = String(v);
|
|
15640
|
+
if (!seen.has(s)) {
|
|
15641
|
+
seen.add(s);
|
|
15642
|
+
categories.push(s);
|
|
15643
|
+
}
|
|
15644
|
+
}
|
|
15645
|
+
if (categories.length > 0) domain = categories;
|
|
15593
15646
|
}
|
|
15594
|
-
if (
|
|
15647
|
+
if (domain === void 0) return { leaf0, leaf1 };
|
|
15595
15648
|
return {
|
|
15596
|
-
|
|
15597
|
-
|
|
15649
|
+
leaf0: pinned0 ? leaf0 : withXDomain(leaf0, domain),
|
|
15650
|
+
leaf1: pinned1 ? leaf1 : withXDomain(leaf1, domain)
|
|
15598
15651
|
};
|
|
15599
15652
|
}
|
|
15600
15653
|
function alignYDomains(leaf0, leaf1) {
|