@primeui/chart-core 0.0.1-alpha.1
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/LICENSE +23 -0
- package/README.md +1 -0
- package/dist/animations/index.d.mts +136 -0
- package/dist/animations/index.mjs +18 -0
- package/dist/annotation.utils-Bm0lOO1o.d.mts +290 -0
- package/dist/borderRadius.utils-Cz73LLR_.d.mts +54 -0
- package/dist/canvas-D4vigq47.d.mts +34 -0
- package/dist/canvas.utils-D2WHi2gL.d.mts +167 -0
- package/dist/cartesian/index.d.mts +94 -0
- package/dist/cartesian/index.mjs +93 -0
- package/dist/chunk-22ST6YPP.mjs +304 -0
- package/dist/chunk-2QK2KOBN.mjs +10 -0
- package/dist/chunk-2QRS4YQ5.mjs +18 -0
- package/dist/chunk-3FFJEX4A.mjs +261 -0
- package/dist/chunk-3IYSJ2U7.mjs +567 -0
- package/dist/chunk-3OZLP4I4.mjs +190 -0
- package/dist/chunk-3WEMHXZI.mjs +198 -0
- package/dist/chunk-3Z62EUJN.mjs +138 -0
- package/dist/chunk-4C6EVJ54.mjs +362 -0
- package/dist/chunk-53HW45JB.mjs +102 -0
- package/dist/chunk-55Y3WI6S.mjs +186 -0
- package/dist/chunk-5JCI2DEB.mjs +97 -0
- package/dist/chunk-66T4MRC5.mjs +113 -0
- package/dist/chunk-6HSEJLSR.mjs +376 -0
- package/dist/chunk-6STOLMCA.mjs +187 -0
- package/dist/chunk-7CMVDIOU.mjs +54 -0
- package/dist/chunk-7QQ6ETB4.mjs +228 -0
- package/dist/chunk-A6ZQZFL2.mjs +272 -0
- package/dist/chunk-ADKLH73T.mjs +1 -0
- package/dist/chunk-AGU3NG6D.mjs +22 -0
- package/dist/chunk-AHYIS6EB.mjs +230 -0
- package/dist/chunk-AP3UYWYT.mjs +4 -0
- package/dist/chunk-ARB5T6MP.mjs +326 -0
- package/dist/chunk-ARRGOEFX.mjs +585 -0
- package/dist/chunk-AUF4CHDP.mjs +422 -0
- package/dist/chunk-B4FTADAZ.mjs +561 -0
- package/dist/chunk-BABQKA6K.mjs +339 -0
- package/dist/chunk-BETFQBM2.mjs +197 -0
- package/dist/chunk-BKP26M4K.mjs +413 -0
- package/dist/chunk-BZN2QHGP.mjs +200 -0
- package/dist/chunk-C36VWQ7A.mjs +86 -0
- package/dist/chunk-CHW4RKY3.mjs +16 -0
- package/dist/chunk-CINXJIRR.mjs +120 -0
- package/dist/chunk-DN6AXQYZ.mjs +667 -0
- package/dist/chunk-DP2IZNN3.mjs +92 -0
- package/dist/chunk-DTWTCFRG.mjs +119 -0
- package/dist/chunk-EAMUNLRU.mjs +172 -0
- package/dist/chunk-EDAKJLNA.mjs +17 -0
- package/dist/chunk-ERVQB2VZ.mjs +59 -0
- package/dist/chunk-FFMT6OCO.mjs +92 -0
- package/dist/chunk-FHTC2YDB.mjs +102 -0
- package/dist/chunk-FRST55HY.mjs +16 -0
- package/dist/chunk-HDFGCN2F.mjs +132 -0
- package/dist/chunk-IEGLX7VL.mjs +42 -0
- package/dist/chunk-ILUWFYGY.mjs +220 -0
- package/dist/chunk-IXOWSEHO.mjs +114 -0
- package/dist/chunk-J4RI2C2G.mjs +172 -0
- package/dist/chunk-J65DBT4R.mjs +13 -0
- package/dist/chunk-JGOVWSKH.mjs +179 -0
- package/dist/chunk-JO7VACY2.mjs +25 -0
- package/dist/chunk-JWFBOPM6.mjs +122 -0
- package/dist/chunk-KNDZP446.mjs +895 -0
- package/dist/chunk-KP2TWD4Z.mjs +90 -0
- package/dist/chunk-KQIFO5I3.mjs +225 -0
- package/dist/chunk-KVDEROP6.mjs +59 -0
- package/dist/chunk-LKC7MZKK.mjs +87 -0
- package/dist/chunk-LVMDQ4OJ.mjs +305 -0
- package/dist/chunk-M7B3JF43.mjs +90 -0
- package/dist/chunk-MTGMXRNF.mjs +136 -0
- package/dist/chunk-N3TIT3OH.mjs +1040 -0
- package/dist/chunk-NHRK5KU2.mjs +890 -0
- package/dist/chunk-NKUYIWAP.mjs +243 -0
- package/dist/chunk-NPDZLYIF.mjs +238 -0
- package/dist/chunk-O2X6FF45.mjs +499 -0
- package/dist/chunk-OGJ6IIBW.mjs +176 -0
- package/dist/chunk-OHGCZZPZ.mjs +403 -0
- package/dist/chunk-OWW3K55O.mjs +351 -0
- package/dist/chunk-OXTFAWSK.mjs +60 -0
- package/dist/chunk-PLSDU3C2.mjs +890 -0
- package/dist/chunk-PRDVPOZX.mjs +223 -0
- package/dist/chunk-Q6PPVIHU.mjs +21 -0
- package/dist/chunk-QQBXUDM4.mjs +885 -0
- package/dist/chunk-QS76E3TD.mjs +111 -0
- package/dist/chunk-QWQ6HY4I.mjs +209 -0
- package/dist/chunk-R6Y3R7EW.mjs +135 -0
- package/dist/chunk-RBLZRT5K.mjs +190 -0
- package/dist/chunk-RO4N6YFS.mjs +167 -0
- package/dist/chunk-RQ3CKQOX.mjs +984 -0
- package/dist/chunk-SALTGZFR.mjs +208 -0
- package/dist/chunk-SANZPAJ4.mjs +14 -0
- package/dist/chunk-SDBPQ5CF.mjs +624 -0
- package/dist/chunk-SSLTFJ3U.mjs +364 -0
- package/dist/chunk-SXHVDJGF.mjs +77 -0
- package/dist/chunk-TA4MVAEX.mjs +243 -0
- package/dist/chunk-TAHCOZHF.mjs +1772 -0
- package/dist/chunk-TQ6S34QZ.mjs +152 -0
- package/dist/chunk-UPRXABX5.mjs +90 -0
- package/dist/chunk-VGLSBZDN.mjs +71 -0
- package/dist/chunk-VN7CKCSE.mjs +364 -0
- package/dist/chunk-VVI3OBPJ.mjs +524 -0
- package/dist/chunk-VWF57TS3.mjs +62 -0
- package/dist/chunk-WA3OVISZ.mjs +179 -0
- package/dist/chunk-WCG35U6M.mjs +964 -0
- package/dist/chunk-WFTX4AQJ.mjs +194 -0
- package/dist/chunk-WFVOQ2QZ.mjs +18 -0
- package/dist/chunk-WH3C3Y7P.mjs +149 -0
- package/dist/chunk-WPFUV7K3.mjs +488 -0
- package/dist/chunk-WRULPWHD.mjs +492 -0
- package/dist/chunk-WS64BZXT.mjs +1 -0
- package/dist/chunk-WY4AURRE.mjs +2419 -0
- package/dist/chunk-WYLILAOO.mjs +167 -0
- package/dist/chunk-X4D7FKUS.mjs +62 -0
- package/dist/chunk-X7T34OLW.mjs +139 -0
- package/dist/chunk-XIHBK5D3.mjs +68 -0
- package/dist/chunk-XQQCGFYB.mjs +50 -0
- package/dist/chunk-XTVE4P3L.mjs +214 -0
- package/dist/chunk-XUAASRXW.mjs +579 -0
- package/dist/chunk-Y3L3D4GQ.mjs +685 -0
- package/dist/chunk-YBJ56XJS.mjs +132 -0
- package/dist/chunk-ZQFK6CAE.mjs +1 -0
- package/dist/chunk-ZT2Z7ERM.mjs +874 -0
- package/dist/chunk-ZTL2FQEW.mjs +714 -0
- package/dist/circular/arc/index.d.mts +8 -0
- package/dist/circular/arc/index.mjs +3 -0
- package/dist/circular/index.d.mts +44 -0
- package/dist/circular/index.mjs +13 -0
- package/dist/collect.utils-DiKB4ciO.d.mts +12 -0
- package/dist/computeChartState-BTVIqwyO.d.mts +304 -0
- package/dist/controller-BJE1AZ3q.d.mts +82 -0
- package/dist/controller-BoNigQJr.d.mts +63 -0
- package/dist/controllers/index.d.mts +16 -0
- package/dist/controllers/index.mjs +110 -0
- package/dist/datalabel.utils-CkjGeB8S.d.mts +122 -0
- package/dist/decimation.utils-CcvJVhI4.d.mts +244 -0
- package/dist/geometry-DUUQJXVM.d.mts +60 -0
- package/dist/index-DseIZa1j.d.mts +167 -0
- package/dist/index.d.mts +88 -0
- package/dist/index.mjs +110 -0
- package/dist/orchestrator/index.d.mts +264 -0
- package/dist/orchestrator/index.mjs +33 -0
- package/dist/plugins/index.d.mts +18 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/property-animations-D433wXzz.d.mts +580 -0
- package/dist/property-store-NORUWFND.d.mts +17 -0
- package/dist/radial/index.d.mts +14 -0
- package/dist/radial/index.mjs +37 -0
- package/dist/renderers/axis/index.d.mts +39 -0
- package/dist/renderers/axis/index.mjs +8 -0
- package/dist/renderers/circular/index.d.mts +13 -0
- package/dist/renderers/circular/index.mjs +13 -0
- package/dist/renderers/index.d.mts +83 -0
- package/dist/renderers/index.mjs +75 -0
- package/dist/renderers/navigator/index.d.mts +103 -0
- package/dist/renderers/navigator/index.mjs +8 -0
- package/dist/resize.utils-D_2qm6rv.d.mts +142 -0
- package/dist/ring.utils-DXvrxMkU.d.mts +138 -0
- package/dist/scale-KFv30jqZ.d.mts +307 -0
- package/dist/scales-Drf8AIhL.d.mts +75 -0
- package/dist/series/bar/canvas/index.d.mts +8 -0
- package/dist/series/bar/canvas/index.mjs +10 -0
- package/dist/series/bar/controller/index.d.mts +105 -0
- package/dist/series/bar/controller/index.mjs +44 -0
- package/dist/series/bar/controller-canvas/index.d.mts +7 -0
- package/dist/series/bar/controller-canvas/index.mjs +49 -0
- package/dist/series/bar/controller-svg/index.d.mts +7 -0
- package/dist/series/bar/controller-svg/index.mjs +49 -0
- package/dist/series/bar/index.d.mts +60 -0
- package/dist/series/bar/index.mjs +13 -0
- package/dist/series/bar/svg/index.d.mts +8 -0
- package/dist/series/bar/svg/index.mjs +11 -0
- package/dist/series/candlestick/canvas/index.d.mts +8 -0
- package/dist/series/candlestick/canvas/index.mjs +8 -0
- package/dist/series/candlestick/controller/index.d.mts +123 -0
- package/dist/series/candlestick/controller/index.mjs +40 -0
- package/dist/series/candlestick/controller-canvas/index.d.mts +7 -0
- package/dist/series/candlestick/controller-canvas/index.mjs +45 -0
- package/dist/series/candlestick/controller-svg/index.d.mts +7 -0
- package/dist/series/candlestick/controller-svg/index.mjs +45 -0
- package/dist/series/candlestick/index.d.mts +11 -0
- package/dist/series/candlestick/index.mjs +10 -0
- package/dist/series/candlestick/svg/index.d.mts +8 -0
- package/dist/series/candlestick/svg/index.mjs +8 -0
- package/dist/series/heatmap/canvas/index.d.mts +16 -0
- package/dist/series/heatmap/canvas/index.mjs +9 -0
- package/dist/series/heatmap/controller/index.d.mts +110 -0
- package/dist/series/heatmap/controller/index.mjs +23 -0
- package/dist/series/heatmap/controller-canvas/index.d.mts +7 -0
- package/dist/series/heatmap/controller-canvas/index.mjs +28 -0
- package/dist/series/heatmap/controller-svg/index.d.mts +7 -0
- package/dist/series/heatmap/controller-svg/index.mjs +28 -0
- package/dist/series/heatmap/index.d.mts +34 -0
- package/dist/series/heatmap/index.mjs +13 -0
- package/dist/series/heatmap/svg/index.d.mts +15 -0
- package/dist/series/heatmap/svg/index.mjs +10 -0
- package/dist/series/line/canvas/index.d.mts +6 -0
- package/dist/series/line/canvas/index.mjs +9 -0
- package/dist/series/line/controller/index.d.mts +111 -0
- package/dist/series/line/controller/index.mjs +47 -0
- package/dist/series/line/controller-canvas/index.d.mts +7 -0
- package/dist/series/line/controller-canvas/index.mjs +54 -0
- package/dist/series/line/controller-svg/index.d.mts +7 -0
- package/dist/series/line/controller-svg/index.mjs +54 -0
- package/dist/series/line/index.d.mts +49 -0
- package/dist/series/line/index.mjs +13 -0
- package/dist/series/line/svg/index.d.mts +6 -0
- package/dist/series/line/svg/index.mjs +9 -0
- package/dist/series/pie/canvas/index.d.mts +8 -0
- package/dist/series/pie/canvas/index.mjs +10 -0
- package/dist/series/pie/controller/index.d.mts +174 -0
- package/dist/series/pie/controller/index.mjs +110 -0
- package/dist/series/pie/controller-canvas/index.d.mts +8 -0
- package/dist/series/pie/controller-canvas/index.mjs +119 -0
- package/dist/series/pie/controller-svg/index.d.mts +8 -0
- package/dist/series/pie/controller-svg/index.mjs +118 -0
- package/dist/series/pie/index.d.mts +59 -0
- package/dist/series/pie/index.mjs +15 -0
- package/dist/series/pie/svg/index.d.mts +6 -0
- package/dist/series/pie/svg/index.mjs +11 -0
- package/dist/series/polar/canvas/index.d.mts +6 -0
- package/dist/series/polar/canvas/index.mjs +7 -0
- package/dist/series/polar/controller/index.d.mts +102 -0
- package/dist/series/polar/controller/index.mjs +46 -0
- package/dist/series/polar/controller-canvas/index.d.mts +8 -0
- package/dist/series/polar/controller-canvas/index.mjs +52 -0
- package/dist/series/polar/controller-svg/index.d.mts +8 -0
- package/dist/series/polar/controller-svg/index.mjs +52 -0
- package/dist/series/polar/index.d.mts +25 -0
- package/dist/series/polar/index.mjs +16 -0
- package/dist/series/polar/svg/index.d.mts +10 -0
- package/dist/series/polar/svg/index.mjs +8 -0
- package/dist/series/radar/canvas/index.d.mts +6 -0
- package/dist/series/radar/canvas/index.mjs +8 -0
- package/dist/series/radar/controller/index.d.mts +121 -0
- package/dist/series/radar/controller/index.mjs +43 -0
- package/dist/series/radar/controller-canvas/index.d.mts +8 -0
- package/dist/series/radar/controller-canvas/index.mjs +51 -0
- package/dist/series/radar/controller-svg/index.d.mts +8 -0
- package/dist/series/radar/controller-svg/index.mjs +51 -0
- package/dist/series/radar/index.d.mts +40 -0
- package/dist/series/radar/index.mjs +13 -0
- package/dist/series/radar/svg/index.d.mts +12 -0
- package/dist/series/radar/svg/index.mjs +9 -0
- package/dist/series/scatter/canvas/index.d.mts +8 -0
- package/dist/series/scatter/canvas/index.mjs +11 -0
- package/dist/series/scatter/controller/index.d.mts +124 -0
- package/dist/series/scatter/controller/index.mjs +44 -0
- package/dist/series/scatter/controller-canvas/index.d.mts +7 -0
- package/dist/series/scatter/controller-canvas/index.mjs +51 -0
- package/dist/series/scatter/controller-svg/index.d.mts +7 -0
- package/dist/series/scatter/controller-svg/index.mjs +51 -0
- package/dist/series/scatter/index.d.mts +25 -0
- package/dist/series/scatter/index.mjs +14 -0
- package/dist/series/scatter/svg/index.d.mts +8 -0
- package/dist/series/scatter/svg/index.mjs +12 -0
- package/dist/series/treemap/canvas/index.d.mts +50 -0
- package/dist/series/treemap/canvas/index.mjs +10 -0
- package/dist/series/treemap/controller/index.d.mts +130 -0
- package/dist/series/treemap/controller/index.mjs +20 -0
- package/dist/series/treemap/controller-canvas/index.d.mts +7 -0
- package/dist/series/treemap/controller-canvas/index.mjs +25 -0
- package/dist/series/treemap/controller-svg/index.d.mts +7 -0
- package/dist/series/treemap/controller-svg/index.mjs +25 -0
- package/dist/series/treemap/index.d.mts +15 -0
- package/dist/series/treemap/index.mjs +12 -0
- package/dist/series/treemap/svg/index.d.mts +15 -0
- package/dist/series/treemap/svg/index.mjs +9 -0
- package/dist/slices-DtewiwJx.d.mts +72 -0
- package/dist/spatialIndex.utils-B_GJkotZ.d.mts +5 -0
- package/dist/squarify.utils-B9CQBpa1.d.mts +50 -0
- package/dist/stacking-CChuAcLN.d.mts +319 -0
- package/dist/streaming.utils-DH-g1gNP.d.mts +49 -0
- package/dist/sync/index.d.mts +130 -0
- package/dist/sync/index.mjs +5 -0
- package/dist/tooltip.renderer-D5wpSlBa.d.mts +210 -0
- package/dist/utils/color/index.d.mts +58 -0
- package/dist/utils/color/index.mjs +4 -0
- package/dist/utils/data/index.d.mts +180 -0
- package/dist/utils/data/index.mjs +7 -0
- package/dist/utils/export/index.d.mts +14 -0
- package/dist/utils/export/index.mjs +6 -0
- package/dist/utils/index.d.mts +49 -0
- package/dist/utils/index.mjs +29 -0
- package/dist/utils/interaction/index.d.mts +255 -0
- package/dist/utils/interaction/index.mjs +9 -0
- package/dist/utils/layout/index.d.mts +3 -0
- package/dist/utils/layout/index.mjs +10 -0
- package/dist/utils/math/index.d.mts +162 -0
- package/dist/utils/math/index.mjs +1 -0
- package/dist/utils/render/index.d.mts +19 -0
- package/dist/utils/render/index.mjs +3 -0
- package/dist/utils/specialized/index.d.mts +37 -0
- package/dist/utils/specialized/index.mjs +66 -0
- package/dist/utils/text/index.d.mts +39 -0
- package/dist/utils/text/index.mjs +8 -0
- package/dist/utils/theme/index.d.mts +295 -0
- package/dist/utils/theme/index.mjs +5 -0
- package/dist/utils/zoom/index.d.mts +90 -0
- package/dist/utils/zoom/index.mjs +3 -0
- package/package.json +56 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { materializeSvgNode } from './chunk-SSLTFJ3U.mjs';
|
|
2
|
+
|
|
3
|
+
// src/utils/render/reconcile.ts
|
|
4
|
+
var PROTECTED_ATTRS = /* @__PURE__ */ new Set(["style", "tabindex"]);
|
|
5
|
+
function keyOf(el) {
|
|
6
|
+
const ds = el.getAttribute("data-dataset");
|
|
7
|
+
if (ds !== null) return "ds:" + ds;
|
|
8
|
+
const i = el.getAttribute("data-index");
|
|
9
|
+
if (i !== null) return "i:" + i;
|
|
10
|
+
const id = el.getAttribute("id");
|
|
11
|
+
if (id !== null) return "id:" + id;
|
|
12
|
+
const layer = el.getAttribute("data-layer");
|
|
13
|
+
if (layer !== null) return "layer:" + layer;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
function keyOfNode(node) {
|
|
17
|
+
const a = node.attributes;
|
|
18
|
+
if (a["data-dataset"] != null) return "ds:" + a["data-dataset"];
|
|
19
|
+
if (a["data-index"] != null) return "i:" + a["data-index"];
|
|
20
|
+
if (a["id"] != null) return "id:" + a["id"];
|
|
21
|
+
if (a["data-layer"] != null) return "layer:" + a["data-layer"];
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function reconcileSvgElement(live, next) {
|
|
25
|
+
const fp = next.attributes["data-fp"];
|
|
26
|
+
if (fp != null && live.getAttribute("data-fp") === fp) return;
|
|
27
|
+
for (const k in next.attributes) {
|
|
28
|
+
if (live.getAttribute(k) !== next.attributes[k]) live.setAttribute(k, next.attributes[k]);
|
|
29
|
+
}
|
|
30
|
+
const liveAttrs = live.attributes;
|
|
31
|
+
for (let i = liveAttrs.length - 1; i >= 0; i--) {
|
|
32
|
+
const name = liveAttrs[i].name;
|
|
33
|
+
if (!(name in next.attributes) && !PROTECTED_ATTRS.has(name)) live.removeAttribute(name);
|
|
34
|
+
}
|
|
35
|
+
if (next.children.length === 1 && typeof next.children[0] === "string") {
|
|
36
|
+
if (live.textContent !== next.children[0]) live.textContent = next.children[0];
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (next.children.length > 0) {
|
|
40
|
+
reconcileSvgChildren(live, next.children);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function reconcileSvgChildren(parent, nextChildren) {
|
|
44
|
+
const liveByKey = /* @__PURE__ */ new Map();
|
|
45
|
+
const liveByTag = /* @__PURE__ */ new Map();
|
|
46
|
+
for (const child of Array.from(parent.children)) {
|
|
47
|
+
const k = keyOf(child);
|
|
48
|
+
if (k !== null) {
|
|
49
|
+
const arr = liveByKey.get(k);
|
|
50
|
+
if (arr) arr.push(child);
|
|
51
|
+
else liveByKey.set(k, [child]);
|
|
52
|
+
} else {
|
|
53
|
+
const tag = child.tagName;
|
|
54
|
+
const arr = liveByTag.get(tag);
|
|
55
|
+
if (arr) arr.push(child);
|
|
56
|
+
else liveByTag.set(tag, [child]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const desired = [];
|
|
60
|
+
for (const child of nextChildren) {
|
|
61
|
+
if (typeof child === "string") continue;
|
|
62
|
+
const k = keyOfNode(child);
|
|
63
|
+
let match;
|
|
64
|
+
if (k !== null) {
|
|
65
|
+
const arr = liveByKey.get(k);
|
|
66
|
+
if (arr && arr.length && arr[0].tagName === child.tag) match = arr.shift();
|
|
67
|
+
} else {
|
|
68
|
+
const arr = liveByTag.get(child.tag);
|
|
69
|
+
if (arr && arr.length) match = arr.shift();
|
|
70
|
+
}
|
|
71
|
+
if (match) {
|
|
72
|
+
reconcileSvgElement(match, child);
|
|
73
|
+
desired.push(match);
|
|
74
|
+
} else {
|
|
75
|
+
desired.push(materializeSvgNode(child));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const arr of liveByKey.values()) for (const el of arr) parent.removeChild(el);
|
|
79
|
+
for (const arr of liveByTag.values()) for (const el of arr) parent.removeChild(el);
|
|
80
|
+
let cur = parent.firstElementChild;
|
|
81
|
+
for (const want of desired) {
|
|
82
|
+
if (cur === want) {
|
|
83
|
+
cur = want.nextElementSibling;
|
|
84
|
+
} else {
|
|
85
|
+
parent.insertBefore(want, cur);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export { keyOf, keyOfNode, reconcileSvgChildren, reconcileSvgElement };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { createCanvasLinePathBuilder, traceCurve, reversedBaseEdge } from './chunk-HDFGCN2F.mjs';
|
|
2
|
+
import { resolveBoostActive, MARKER_SHAPE_NAMES, traceMarkerShapeCanvasAt, drawMarkerCanvas } from './chunk-PRDVPOZX.mjs';
|
|
3
|
+
import { computeItemHoverState, applyHoverEffects } from './chunk-BZN2QHGP.mjs';
|
|
4
|
+
import { DEFAULT_LINE_WIDTH, DEFAULT_LINE_MARKER_SIZE, DEFAULT_AREA_FILL_OPACITY, DEFAULT_HOVER_DIM_OPACITY, LINE_BOOST_AUTO_THRESHOLD, DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER } from './chunk-NKUYIWAP.mjs';
|
|
5
|
+
import { makeItemContext, resolveDash, resolveAccessor, getDefaultColor, isGradientColor, createCanvasGradientFromColor, getPrimaryColor } from './chunk-O2X6FF45.mjs';
|
|
6
|
+
import { withCanvasState } from './chunk-SSLTFJ3U.mjs';
|
|
7
|
+
|
|
8
|
+
// src/series/line/canvas/index.ts
|
|
9
|
+
var DEFAULT_CURVE = "linear";
|
|
10
|
+
var DEFAULT_TENSION = 0.5;
|
|
11
|
+
var DEFAULT_SHOW_MARKERS = true;
|
|
12
|
+
var DEFAULT_MARKER_SHAPE = "circle";
|
|
13
|
+
function renderLineCanvas(props, layout, ctx, context) {
|
|
14
|
+
const lineWidth = props.lineStrokeWidth ?? DEFAULT_LINE_WIDTH;
|
|
15
|
+
const borderColor = typeof props.borderColor === "string" ? props.borderColor : void 0;
|
|
16
|
+
const borderWidth = typeof props.borderStrokeWidth === "number" ? props.borderStrokeWidth : 0;
|
|
17
|
+
const lineStyle = props.lineStyle ?? "solid";
|
|
18
|
+
const showMarkers = props.showMarkers ?? DEFAULT_SHOW_MARKERS;
|
|
19
|
+
const markerSizeAccessor = props.markerSize;
|
|
20
|
+
const defaultMarkerSize = props.pointRadius ?? DEFAULT_LINE_MARKER_SIZE;
|
|
21
|
+
const resolveMarkerSize = (ctx2) => markerSizeAccessor === void 0 ? defaultMarkerSize : resolveAccessor(markerSizeAccessor, ctx2, { arrayMode: "clip", fallback: defaultMarkerSize }) ?? defaultMarkerSize;
|
|
22
|
+
const resolveMarkerShape = (ctx2, size) => props.markerShape === void 0 ? DEFAULT_MARKER_SHAPE : resolveAccessor(props.markerShape, typeof props.markerShape === "function" ? { ...ctx2, size } : ctx2, { arrayMode: "clip" }) ?? DEFAULT_MARKER_SHAPE;
|
|
23
|
+
const rotationAccessor = props.pointRotation;
|
|
24
|
+
const resolveMarkerRotation = (ctx2) => rotationAccessor === void 0 ? 0 : resolveAccessor(rotationAccessor, ctx2, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
25
|
+
const seriesDashCtx = makeItemContext(props.data?.[0], 0);
|
|
26
|
+
const seriesBorderDash = resolveDash(props.borderDash, seriesDashCtx);
|
|
27
|
+
const seriesBorderDashOffset = resolveAccessor(props.borderDashOffset, seriesDashCtx, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
28
|
+
const resolvePointDash = (ctx2) => props.pointBorderDash === void 0 ? void 0 : resolveDash(props.pointBorderDash, ctx2);
|
|
29
|
+
const resolvePointDashOffset = (ctx2) => props.pointBorderDashOffset === void 0 ? 0 : resolveAccessor(props.pointBorderDashOffset, ctx2, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
30
|
+
const curve = props.curve ?? DEFAULT_CURVE;
|
|
31
|
+
const tension = props.tension ?? DEFAULT_TENSION;
|
|
32
|
+
const fillOpacity = props.fillOpacity ?? DEFAULT_AREA_FILL_OPACITY;
|
|
33
|
+
const hoveredIndex = props.interaction?.hoveredIndex ?? null;
|
|
34
|
+
const isSeriesDimmed = props.interaction?.isSeriesDimmed ?? false;
|
|
35
|
+
const effects = props.effects;
|
|
36
|
+
const seriesDimOpacity = isSeriesDimmed ? effects?.dimOpacity ?? context.theme.dimOpacity ?? DEFAULT_HOVER_DIM_OPACITY : 1;
|
|
37
|
+
const lineColor = layout.lineColor ?? getDefaultColor(layout.seriesIdx, context.theme);
|
|
38
|
+
const seriesExtras = { seriesIndex: layout.seriesIdx, seriesId: layout.datasetId };
|
|
39
|
+
let strokeStyle;
|
|
40
|
+
if (isGradientColor(lineColor)) {
|
|
41
|
+
const cx = layout.chartArea.x + layout.chartArea.width / 2;
|
|
42
|
+
const cy = layout.chartArea.y + layout.chartArea.height / 2;
|
|
43
|
+
const r = Math.max(layout.chartArea.width, layout.chartArea.height) / 2;
|
|
44
|
+
strokeStyle = createCanvasGradientFromColor(ctx, lineColor, { x: cx, y: cy }, r, layout.chartArea, "horizontal");
|
|
45
|
+
} else {
|
|
46
|
+
strokeStyle = lineColor;
|
|
47
|
+
}
|
|
48
|
+
let areaFillStyle = strokeStyle;
|
|
49
|
+
if (layout.isArea && isGradientColor(lineColor)) {
|
|
50
|
+
const acx = layout.chartArea.x + layout.chartArea.width / 2;
|
|
51
|
+
const acy = layout.chartArea.y + layout.chartArea.height / 2;
|
|
52
|
+
const ar = Math.max(layout.chartArea.width, layout.chartArea.height) / 2;
|
|
53
|
+
areaFillStyle = createCanvasGradientFromColor(ctx, lineColor, { x: acx, y: acy }, ar, layout.chartArea, "vertical");
|
|
54
|
+
}
|
|
55
|
+
let dashPattern = [];
|
|
56
|
+
if (props.lineDash && props.lineDash.length > 0) {
|
|
57
|
+
dashPattern = props.lineDash;
|
|
58
|
+
} else if (lineStyle === "dashed") {
|
|
59
|
+
dashPattern = [lineWidth * 4, lineWidth * 3];
|
|
60
|
+
} else if (lineStyle === "dotted") {
|
|
61
|
+
dashPattern = [lineWidth, lineWidth * 2];
|
|
62
|
+
}
|
|
63
|
+
withCanvasState(ctx, () => {
|
|
64
|
+
if (seriesDimOpacity < 1) ctx.globalAlpha = seriesDimOpacity;
|
|
65
|
+
if (layout.isArea) {
|
|
66
|
+
ctx.globalAlpha = fillOpacity * seriesDimOpacity;
|
|
67
|
+
for (const seg of layout.segments) {
|
|
68
|
+
if (seg.points.length === 0) continue;
|
|
69
|
+
ctx.fillStyle = seg.style?.segmentFillColor ?? areaFillStyle;
|
|
70
|
+
ctx.beginPath();
|
|
71
|
+
const builder = createCanvasLinePathBuilder(ctx);
|
|
72
|
+
builder.moveTo(seg.points[0].x, seg.points[0].y);
|
|
73
|
+
traceCurve(builder, seg.points, curve, tension);
|
|
74
|
+
const hasBaseY = seg.points[0].baseY !== void 0;
|
|
75
|
+
if (hasBaseY) {
|
|
76
|
+
const basePoints = reversedBaseEdge(seg.points);
|
|
77
|
+
builder.lineTo(basePoints[0].x, basePoints[0].y);
|
|
78
|
+
traceCurve(builder, basePoints, curve, tension);
|
|
79
|
+
} else {
|
|
80
|
+
builder.lineTo(seg.points[seg.points.length - 1].x, layout.baselineY);
|
|
81
|
+
builder.lineTo(seg.points[0].x, layout.baselineY);
|
|
82
|
+
}
|
|
83
|
+
builder.closePath();
|
|
84
|
+
ctx.fill();
|
|
85
|
+
}
|
|
86
|
+
ctx.globalAlpha = seriesDimOpacity;
|
|
87
|
+
}
|
|
88
|
+
if (borderColor && borderWidth > 0) {
|
|
89
|
+
const usingLineDash = dashPattern.length > 0;
|
|
90
|
+
const borderDashPattern = usingLineDash ? dashPattern : seriesBorderDash && seriesBorderDash.length > 0 ? seriesBorderDash : [];
|
|
91
|
+
const effectiveBorderDashOffset = usingLineDash ? props.lineDashOffset ?? seriesBorderDashOffset : seriesBorderDashOffset;
|
|
92
|
+
ctx.strokeStyle = borderColor;
|
|
93
|
+
ctx.lineWidth = lineWidth + borderWidth * 2;
|
|
94
|
+
ctx.lineCap = props.borderCapStyle ?? props.lineCapStyle ?? "round";
|
|
95
|
+
ctx.lineJoin = props.borderJoinStyle ?? props.lineJoinStyle ?? "round";
|
|
96
|
+
ctx.setLineDash(borderDashPattern);
|
|
97
|
+
if (effectiveBorderDashOffset) ctx.lineDashOffset = effectiveBorderDashOffset;
|
|
98
|
+
for (const seg of layout.segments) {
|
|
99
|
+
if (seg.points.length === 0) continue;
|
|
100
|
+
ctx.beginPath();
|
|
101
|
+
const builder = createCanvasLinePathBuilder(ctx);
|
|
102
|
+
builder.moveTo(seg.points[0].x, seg.points[0].y);
|
|
103
|
+
traceCurve(builder, seg.points, curve, tension);
|
|
104
|
+
ctx.stroke();
|
|
105
|
+
}
|
|
106
|
+
ctx.setLineDash([]);
|
|
107
|
+
ctx.lineDashOffset = 0;
|
|
108
|
+
}
|
|
109
|
+
ctx.lineCap = props.lineCapStyle ?? "round";
|
|
110
|
+
ctx.lineJoin = props.lineJoinStyle ?? "round";
|
|
111
|
+
if (props.lineDashOffset) ctx.lineDashOffset = props.lineDashOffset;
|
|
112
|
+
if (props.segmentColor || props.segmentStrokeWidth || props.segmentDash || props.segmentFillColor) {
|
|
113
|
+
for (const seg of layout.segments) {
|
|
114
|
+
if (seg.points.length === 0) continue;
|
|
115
|
+
ctx.strokeStyle = seg.style?.segmentColor ?? strokeStyle;
|
|
116
|
+
ctx.lineWidth = seg.style?.segmentStrokeWidth ?? lineWidth;
|
|
117
|
+
ctx.setLineDash(seg.style?.segmentDash ?? dashPattern);
|
|
118
|
+
ctx.beginPath();
|
|
119
|
+
const builder = createCanvasLinePathBuilder(ctx);
|
|
120
|
+
builder.moveTo(seg.points[0].x, seg.points[0].y);
|
|
121
|
+
traceCurve(builder, seg.points, curve, tension);
|
|
122
|
+
ctx.stroke();
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
ctx.strokeStyle = strokeStyle;
|
|
126
|
+
ctx.lineWidth = lineWidth;
|
|
127
|
+
ctx.setLineDash(dashPattern);
|
|
128
|
+
for (const seg of layout.segments) {
|
|
129
|
+
if (seg.points.length === 0) continue;
|
|
130
|
+
ctx.beginPath();
|
|
131
|
+
const builder = createCanvasLinePathBuilder(ctx);
|
|
132
|
+
builder.moveTo(seg.points[0].x, seg.points[0].y);
|
|
133
|
+
traceCurve(builder, seg.points, curve, tension);
|
|
134
|
+
ctx.stroke();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
ctx.setLineDash([]);
|
|
138
|
+
const hasCustomRenderMarkerCanvas = !!props.renderMarker;
|
|
139
|
+
if ((showMarkers || hoveredIndex !== null) && !hasCustomRenderMarkerCanvas) {
|
|
140
|
+
const anyHovered = hoveredIndex !== null && !!effects;
|
|
141
|
+
if (resolveBoostActive(props.boost, layout.visiblePoints.length, LINE_BOOST_AUTO_THRESHOLD) && showMarkers && typeof props.markerShape !== "function" && layout.visiblePoints.length > 0) {
|
|
142
|
+
const firstB = layout.visiblePoints[0];
|
|
143
|
+
const firstCtxB = makeItemContext(props.data?.[firstB.dataIndex], firstB.dataIndex, { value: firstB.value, category: firstB.category, ...seriesExtras });
|
|
144
|
+
const seriesShapeB = resolveMarkerShape(firstCtxB, resolveMarkerSize(firstCtxB));
|
|
145
|
+
if (MARKER_SHAPE_NAMES.has(seriesShapeB)) {
|
|
146
|
+
const BOOST_CHUNK_SIZE = 5e3;
|
|
147
|
+
const batches = /* @__PURE__ */ new Map();
|
|
148
|
+
for (const pt of layout.visiblePoints) {
|
|
149
|
+
const ptCtxB = makeItemContext(props.data?.[pt.dataIndex], pt.dataIndex, { value: pt.value, category: pt.category, ...seriesExtras });
|
|
150
|
+
const markerColor = props.pointColors?.[pt.dataIndex] ?? resolveAccessor(props.pointBackgroundColor, ptCtxB, { arrayMode: "cycle" }) ?? lineColor;
|
|
151
|
+
const key = getPrimaryColor(markerColor);
|
|
152
|
+
let bucket = batches.get(key);
|
|
153
|
+
if (!bucket) batches.set(key, bucket = []);
|
|
154
|
+
bucket.push(pt);
|
|
155
|
+
}
|
|
156
|
+
const boostBorderColor = resolveAccessor(props.pointBorderColor, firstCtxB, { arrayMode: "cycle" });
|
|
157
|
+
const boostBorderWidth = resolveAccessor(props.pointBorderStrokeWidth, firstCtxB, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
158
|
+
for (const [fillColor, pts] of batches) {
|
|
159
|
+
ctx.globalAlpha = seriesDimOpacity;
|
|
160
|
+
ctx.fillStyle = fillColor;
|
|
161
|
+
for (let i = 0; i < pts.length; i += BOOST_CHUNK_SIZE) {
|
|
162
|
+
ctx.beginPath();
|
|
163
|
+
for (let j = i, end = Math.min(i + BOOST_CHUNK_SIZE, pts.length); j < end; j++) {
|
|
164
|
+
const pt = pts[j];
|
|
165
|
+
traceMarkerShapeCanvasAt(ctx, seriesShapeB, pt.x, pt.y, resolveMarkerSize(makeItemContext(props.data?.[pt.dataIndex], pt.dataIndex, { value: pt.value, category: pt.category, ...seriesExtras })), 0);
|
|
166
|
+
}
|
|
167
|
+
ctx.fill();
|
|
168
|
+
}
|
|
169
|
+
if (boostBorderWidth > 0) {
|
|
170
|
+
ctx.strokeStyle = getPrimaryColor(boostBorderColor ?? fillColor);
|
|
171
|
+
ctx.lineWidth = boostBorderWidth;
|
|
172
|
+
for (let i = 0; i < pts.length; i += BOOST_CHUNK_SIZE) {
|
|
173
|
+
ctx.beginPath();
|
|
174
|
+
for (let j = i, end = Math.min(i + BOOST_CHUNK_SIZE, pts.length); j < end; j++) {
|
|
175
|
+
const pt = pts[j];
|
|
176
|
+
traceMarkerShapeCanvasAt(ctx, seriesShapeB, pt.x, pt.y, resolveMarkerSize(makeItemContext(props.data?.[pt.dataIndex], pt.dataIndex, { value: pt.value, category: pt.category, ...seriesExtras })), 0);
|
|
177
|
+
}
|
|
178
|
+
ctx.stroke();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
for (const pt of layout.visiblePoints) {
|
|
186
|
+
const hoverState = computeItemHoverState(pt.dataIndex, hoveredIndex, anyHovered);
|
|
187
|
+
if (!showMarkers && !hoverState.isHovered) continue;
|
|
188
|
+
const pointColor = props.pointColors?.[pt.dataIndex];
|
|
189
|
+
const ptCtxC = makeItemContext(props.data?.[pt.dataIndex], pt.dataIndex, { value: pt.value, category: pt.category, ...seriesExtras });
|
|
190
|
+
const baseColor = pointColor ?? resolveAccessor(props.pointBackgroundColor, ptCtxC, { arrayMode: "cycle" }) ?? (typeof lineColor === "string" ? lineColor : "#000");
|
|
191
|
+
const baseBorderColor = resolveAccessor(props.pointBorderColor, ptCtxC, { arrayMode: "cycle" }) ?? baseColor;
|
|
192
|
+
const baseBorderWidth = resolveAccessor(props.pointBorderStrokeWidth, ptCtxC, { arrayMode: "clip", fallback: 0 }) ?? 0;
|
|
193
|
+
const ptHoverBgC = resolveAccessor(props.pointHoverBackgroundColor, ptCtxC, { arrayMode: "cycle" });
|
|
194
|
+
const ptHoverBorderC = resolveAccessor(props.pointHoverBorderColor, ptCtxC, { arrayMode: "cycle" });
|
|
195
|
+
const ptHoverBorderWidthC = resolveAccessor(props.pointHoverBorderStrokeWidth, ptCtxC, { arrayMode: "clip" });
|
|
196
|
+
const effectConfig = effects ? {
|
|
197
|
+
hoverBrightness: effects.hoverBrightness,
|
|
198
|
+
dimOpacity: effects.dimOpacity,
|
|
199
|
+
hoverBackgroundColor: ptHoverBgC ?? effects.hoverBackgroundColor,
|
|
200
|
+
hoverBorderColor: ptHoverBorderC ?? effects.hoverBorderColor,
|
|
201
|
+
hoverBorderStrokeWidth: ptHoverBorderWidthC ?? effects.hoverBorderStrokeWidth
|
|
202
|
+
} : void 0;
|
|
203
|
+
const effectResult = applyHoverEffects(baseColor, baseBorderColor, baseBorderWidth, props.lineDash, props.lineDashOffset ?? 0, hoverState, effectConfig, context.theme);
|
|
204
|
+
const ptMarkerSize = resolveMarkerSize(ptCtxC);
|
|
205
|
+
const currentSize = hoverState.isHovered ? effects?.hoverPointRadius ?? ptMarkerSize * (effects?.hoverRadiusMultiplier ?? DEFAULT_HOVER_POINT_RADIUS_MULTIPLIER) : ptMarkerSize;
|
|
206
|
+
drawMarkerCanvas(ctx, {
|
|
207
|
+
x: pt.x,
|
|
208
|
+
y: pt.y,
|
|
209
|
+
size: currentSize,
|
|
210
|
+
shape: resolveMarkerShape(ptCtxC, currentSize),
|
|
211
|
+
fillStyle: effectResult.color,
|
|
212
|
+
strokeStyle: effectResult.borderColor,
|
|
213
|
+
lineStrokeWidth: effectResult.borderStrokeWidth,
|
|
214
|
+
opacity: effectResult.opacity,
|
|
215
|
+
rotation: resolveMarkerRotation(ptCtxC),
|
|
216
|
+
lineDash: resolvePointDash(ptCtxC),
|
|
217
|
+
lineDashOffset: resolvePointDashOffset(ptCtxC),
|
|
218
|
+
lineJoin: props.pointBorderJoinStyle
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export { renderLineCanvas };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { raf, cancelRaf } from './chunk-EDAKJLNA.mjs';
|
|
2
|
+
|
|
3
|
+
// src/utils/layout/resize.utils.ts
|
|
4
|
+
var ResizeDebouncer = class {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.pending = null;
|
|
7
|
+
this.rafId = null;
|
|
8
|
+
this.timerId = null;
|
|
9
|
+
this.delayMs = options?.delayMs ?? 0;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Schedule a dimension update. The callback fires after debounce settles.
|
|
13
|
+
* Subsequent calls before settlement replace the pending dimensions.
|
|
14
|
+
*/
|
|
15
|
+
schedule(dims, apply) {
|
|
16
|
+
if (this.delayMs > 0) {
|
|
17
|
+
this.pending = dims;
|
|
18
|
+
if (this.timerId !== null) {
|
|
19
|
+
clearTimeout(this.timerId);
|
|
20
|
+
}
|
|
21
|
+
this.timerId = setTimeout(() => {
|
|
22
|
+
if (this.pending) {
|
|
23
|
+
apply(this.pending);
|
|
24
|
+
this.pending = null;
|
|
25
|
+
}
|
|
26
|
+
this.timerId = null;
|
|
27
|
+
}, this.delayMs);
|
|
28
|
+
} else {
|
|
29
|
+
this.pending = dims;
|
|
30
|
+
if (this.rafId === null) {
|
|
31
|
+
this.rafId = raf(() => {
|
|
32
|
+
if (this.pending) {
|
|
33
|
+
apply(this.pending);
|
|
34
|
+
this.pending = null;
|
|
35
|
+
}
|
|
36
|
+
this.rafId = null;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Cancel any pending debounce. Call on unmount. */
|
|
42
|
+
cancel() {
|
|
43
|
+
if (this.rafId !== null) {
|
|
44
|
+
cancelRaf(this.rafId);
|
|
45
|
+
this.rafId = null;
|
|
46
|
+
}
|
|
47
|
+
if (this.timerId !== null) {
|
|
48
|
+
clearTimeout(this.timerId);
|
|
49
|
+
this.timerId = null;
|
|
50
|
+
}
|
|
51
|
+
this.pending = null;
|
|
52
|
+
}
|
|
53
|
+
/** Update debounce options (e.g. when props change). */
|
|
54
|
+
updateOptions(options) {
|
|
55
|
+
this.delayMs = options.delayMs ?? 0;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export { ResizeDebouncer };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { DEFAULT_SCATTER_HIT_RADIUS, SCATTER_SPATIAL_INDEX_THRESHOLD } from './chunk-NKUYIWAP.mjs';
|
|
2
|
+
import { buildQuadtree } from './chunk-C36VWQ7A.mjs';
|
|
3
|
+
import { getDefaultColor, resolveSwatchColor, asGradient, getPrimaryColor } from './chunk-O2X6FF45.mjs';
|
|
4
|
+
|
|
5
|
+
// src/cartesian/hittest-wrappers/scatter.ts
|
|
6
|
+
function scatterHitTest(x, y, ctx) {
|
|
7
|
+
let bestResult = null;
|
|
8
|
+
let bestDistSq = Infinity;
|
|
9
|
+
for (const [datasetId, scatterLayout] of ctx.layouts) {
|
|
10
|
+
if (!ctx.renderPropsCache.has(datasetId)) continue;
|
|
11
|
+
let hitPoint = null;
|
|
12
|
+
const layoutDefaultColor = scatterLayout.seriesColor ?? getDefaultColor(scatterLayout.seriesIdx, ctx.theme);
|
|
13
|
+
const scatterProps = ctx.renderPropsCache.get(datasetId);
|
|
14
|
+
const configuredHitRadius = scatterProps?.pointHitRadius ?? DEFAULT_SCATTER_HIT_RADIUS;
|
|
15
|
+
if (scatterLayout.visiblePoints.length > SCATTER_SPATIAL_INDEX_THRESHOLD) {
|
|
16
|
+
if (!scatterLayout.spatialIndex) {
|
|
17
|
+
const area = scatterLayout.chartArea;
|
|
18
|
+
const quadPoints = new Array(scatterLayout.visiblePoints.length);
|
|
19
|
+
const map = /* @__PURE__ */ new Map();
|
|
20
|
+
for (let i = 0; i < scatterLayout.visiblePoints.length; i++) {
|
|
21
|
+
const pt = scatterLayout.visiblePoints[i];
|
|
22
|
+
quadPoints[i] = { x: pt.px, y: pt.py, idx: pt.dataIndex, r: pt.radius };
|
|
23
|
+
map.set(pt.dataIndex, pt);
|
|
24
|
+
}
|
|
25
|
+
scatterLayout.spatialIndex = buildQuadtree(quadPoints, { x0: area.x, y0: area.y, x1: area.x + area.width, y1: area.y + area.height });
|
|
26
|
+
scatterLayout.pointByDataIndex = map;
|
|
27
|
+
}
|
|
28
|
+
const result = scatterLayout.spatialIndex.queryNearest(x, y, configuredHitRadius);
|
|
29
|
+
if (result && result.distSq < bestDistSq) {
|
|
30
|
+
const pt = scatterLayout.pointByDataIndex?.get(result.idx);
|
|
31
|
+
if (pt) {
|
|
32
|
+
hitPoint = {
|
|
33
|
+
dataIndex: pt.dataIndex,
|
|
34
|
+
px: pt.px,
|
|
35
|
+
py: pt.py,
|
|
36
|
+
xValue: pt.xValue,
|
|
37
|
+
yValue: pt.yValue,
|
|
38
|
+
sizeValue: pt.sizeValue,
|
|
39
|
+
color: pt.color ?? layoutDefaultColor,
|
|
40
|
+
swatchColor: resolveSwatchColor({ color: pt.color ?? scatterLayout.seriesColor }, scatterLayout.seriesIdx, void 0, ctx.theme),
|
|
41
|
+
distSq: result.distSq
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
for (const pt of scatterLayout.visiblePoints) {
|
|
47
|
+
const hitRadius = Math.max(configuredHitRadius, pt.radius);
|
|
48
|
+
const dx = pt.px - x;
|
|
49
|
+
const dy = pt.py - y;
|
|
50
|
+
const distSq = dx * dx + dy * dy;
|
|
51
|
+
if (distSq <= hitRadius * hitRadius && distSq < bestDistSq && (!hitPoint || distSq < hitPoint.distSq)) {
|
|
52
|
+
hitPoint = {
|
|
53
|
+
dataIndex: pt.dataIndex,
|
|
54
|
+
px: pt.px,
|
|
55
|
+
py: pt.py,
|
|
56
|
+
xValue: pt.xValue,
|
|
57
|
+
yValue: pt.yValue,
|
|
58
|
+
sizeValue: pt.sizeValue,
|
|
59
|
+
color: pt.color ?? layoutDefaultColor,
|
|
60
|
+
swatchColor: resolveSwatchColor({ color: pt.color ?? scatterLayout.seriesColor }, scatterLayout.seriesIdx, void 0, ctx.theme),
|
|
61
|
+
distSq
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (hitPoint && hitPoint.distSq < bestDistSq) {
|
|
67
|
+
bestDistSq = hitPoint.distSq;
|
|
68
|
+
const seriesName = ctx.renderPropsCache.get(datasetId)?.name ?? datasetId;
|
|
69
|
+
bestResult = {
|
|
70
|
+
datasetId,
|
|
71
|
+
index: hitPoint.dataIndex,
|
|
72
|
+
label: seriesName,
|
|
73
|
+
xValue: hitPoint.xValue,
|
|
74
|
+
yValue: hitPoint.yValue,
|
|
75
|
+
...hitPoint.sizeValue != null ? { bubbleValue: hitPoint.sizeValue } : {},
|
|
76
|
+
x: hitPoint.px,
|
|
77
|
+
y: hitPoint.py,
|
|
78
|
+
color: getPrimaryColor(hitPoint.color),
|
|
79
|
+
colorGradient: asGradient(hitPoint.color),
|
|
80
|
+
swatchColor: hitPoint.swatchColor
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return bestResult;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { scatterHitTest };
|