@bicharts/chart-host 0.6.60 → 0.6.61
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.
|
@@ -2895,14 +2895,22 @@ function svgInkReach(svg) {
|
|
|
2895
2895
|
const box = svg.getBoundingClientRect();
|
|
2896
2896
|
if (!(box.width > 0) || !(box.height > 0)) return null;
|
|
2897
2897
|
const els = svg.querySelectorAll(FIT_CONTENT_SELECTOR);
|
|
2898
|
+
const clipOf = clipWindowReader(svg);
|
|
2898
2899
|
let right = -Infinity, bottom = -Infinity, seen = 0;
|
|
2899
2900
|
for (let i = 0; i < els.length && seen < FIT_WALK_CAP; i++) {
|
|
2900
2901
|
const r2 = els[i].getBoundingClientRect();
|
|
2901
2902
|
if (r2.width <= 0 && r2.height <= 0) continue;
|
|
2902
2903
|
if (isPhantomBox(r2.width, r2.height, box.width, box.height)) continue;
|
|
2904
|
+
let rr = r2.right, rb = r2.bottom;
|
|
2905
|
+
const clip = clipOf(els[i]);
|
|
2906
|
+
if (clip) {
|
|
2907
|
+
if (r2.left >= clip.right || r2.top >= clip.bottom) continue;
|
|
2908
|
+
rr = Math.min(rr, clip.right);
|
|
2909
|
+
rb = Math.min(rb, clip.bottom);
|
|
2910
|
+
}
|
|
2903
2911
|
seen++;
|
|
2904
|
-
if (
|
|
2905
|
-
if (
|
|
2912
|
+
if (rr > right) right = rr;
|
|
2913
|
+
if (rb > bottom) bottom = rb;
|
|
2906
2914
|
}
|
|
2907
2915
|
if (seen === 0) return null;
|
|
2908
2916
|
return { right: right - box.left, bottom: bottom - box.top };
|
|
@@ -2910,6 +2918,56 @@ function svgInkReach(svg) {
|
|
|
2910
2918
|
return null;
|
|
2911
2919
|
}
|
|
2912
2920
|
}
|
|
2921
|
+
function clipWindowReader(svg) {
|
|
2922
|
+
const own = /* @__PURE__ */ new Map();
|
|
2923
|
+
const byId = (id) => {
|
|
2924
|
+
try {
|
|
2925
|
+
return svg.querySelector(`clipPath[id="${id.replace(/"/g, '\\"')}"]`);
|
|
2926
|
+
} catch {
|
|
2927
|
+
return null;
|
|
2928
|
+
}
|
|
2929
|
+
};
|
|
2930
|
+
const windowOf = (el) => {
|
|
2931
|
+
if (own.has(el)) return own.get(el);
|
|
2932
|
+
let win = null;
|
|
2933
|
+
try {
|
|
2934
|
+
const ref = el.getAttribute("clip-path") || "";
|
|
2935
|
+
const m4 = /url\(\s*['"]?#([^'")\s]+)['"]?\s*\)/.exec(ref);
|
|
2936
|
+
const cp = m4 ? byId(m4[1]) : null;
|
|
2937
|
+
const ctm = cp ? el.getScreenCTM?.() : null;
|
|
2938
|
+
if (cp && ctm && cp.getAttribute("clipPathUnits") !== "objectBoundingBox") {
|
|
2939
|
+
let r2 = -Infinity, b4 = -Infinity;
|
|
2940
|
+
for (let i = 0; i < cp.children.length; i++) {
|
|
2941
|
+
const bb = cp.children[i].getBBox?.();
|
|
2942
|
+
if (!bb || !(bb.width > 0) || !(bb.height > 0)) continue;
|
|
2943
|
+
for (const [x3, y2] of [
|
|
2944
|
+
[bb.x, bb.y],
|
|
2945
|
+
[bb.x + bb.width, bb.y],
|
|
2946
|
+
[bb.x, bb.y + bb.height],
|
|
2947
|
+
[bb.x + bb.width, bb.y + bb.height]
|
|
2948
|
+
]) {
|
|
2949
|
+
const sx = ctm.a * x3 + ctm.c * y2 + ctm.e, sy = ctm.b * x3 + ctm.d * y2 + ctm.f;
|
|
2950
|
+
if (sx > r2) r2 = sx;
|
|
2951
|
+
if (sy > b4) b4 = sy;
|
|
2952
|
+
}
|
|
2953
|
+
}
|
|
2954
|
+
if (isFinite(r2) && isFinite(b4)) win = { right: r2, bottom: b4 };
|
|
2955
|
+
}
|
|
2956
|
+
} catch {
|
|
2957
|
+
win = null;
|
|
2958
|
+
}
|
|
2959
|
+
own.set(el, win);
|
|
2960
|
+
return win;
|
|
2961
|
+
};
|
|
2962
|
+
return (el) => {
|
|
2963
|
+
let acc = null;
|
|
2964
|
+
for (let a3 = el; a3 && a3 !== svg; a3 = a3.parentElement) {
|
|
2965
|
+
const w3 = windowOf(a3);
|
|
2966
|
+
if (w3) acc = acc ? { right: Math.min(acc.right, w3.right), bottom: Math.min(acc.bottom, w3.bottom) } : w3;
|
|
2967
|
+
}
|
|
2968
|
+
return acc;
|
|
2969
|
+
};
|
|
2970
|
+
}
|
|
2913
2971
|
function measureContainerBoxes(c2, inkOf) {
|
|
2914
2972
|
const boxes = [];
|
|
2915
2973
|
if (!c2 || !c2.children) return boxes;
|
package/dist/index.mjs
CHANGED
package/dist/react.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bicharts/chart-host",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.61",
|
|
4
4
|
"description": "Run a BIC-generated D3 chart in any web host: compiles the generated render() function, applies the shared option defaults, resolves mark clicks (through tooltip overlays), owns the selection affordance, and translates row indices between cross-filtered charts. The same contract the BIC Power BI visual implements, minus Power BI. React bindings at @bicharts/chart-host/react.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|