@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.
Files changed (299) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +1 -0
  3. package/dist/animations/index.d.mts +136 -0
  4. package/dist/animations/index.mjs +18 -0
  5. package/dist/annotation.utils-Bm0lOO1o.d.mts +290 -0
  6. package/dist/borderRadius.utils-Cz73LLR_.d.mts +54 -0
  7. package/dist/canvas-D4vigq47.d.mts +34 -0
  8. package/dist/canvas.utils-D2WHi2gL.d.mts +167 -0
  9. package/dist/cartesian/index.d.mts +94 -0
  10. package/dist/cartesian/index.mjs +93 -0
  11. package/dist/chunk-22ST6YPP.mjs +304 -0
  12. package/dist/chunk-2QK2KOBN.mjs +10 -0
  13. package/dist/chunk-2QRS4YQ5.mjs +18 -0
  14. package/dist/chunk-3FFJEX4A.mjs +261 -0
  15. package/dist/chunk-3IYSJ2U7.mjs +567 -0
  16. package/dist/chunk-3OZLP4I4.mjs +190 -0
  17. package/dist/chunk-3WEMHXZI.mjs +198 -0
  18. package/dist/chunk-3Z62EUJN.mjs +138 -0
  19. package/dist/chunk-4C6EVJ54.mjs +362 -0
  20. package/dist/chunk-53HW45JB.mjs +102 -0
  21. package/dist/chunk-55Y3WI6S.mjs +186 -0
  22. package/dist/chunk-5JCI2DEB.mjs +97 -0
  23. package/dist/chunk-66T4MRC5.mjs +113 -0
  24. package/dist/chunk-6HSEJLSR.mjs +376 -0
  25. package/dist/chunk-6STOLMCA.mjs +187 -0
  26. package/dist/chunk-7CMVDIOU.mjs +54 -0
  27. package/dist/chunk-7QQ6ETB4.mjs +228 -0
  28. package/dist/chunk-A6ZQZFL2.mjs +272 -0
  29. package/dist/chunk-ADKLH73T.mjs +1 -0
  30. package/dist/chunk-AGU3NG6D.mjs +22 -0
  31. package/dist/chunk-AHYIS6EB.mjs +230 -0
  32. package/dist/chunk-AP3UYWYT.mjs +4 -0
  33. package/dist/chunk-ARB5T6MP.mjs +326 -0
  34. package/dist/chunk-ARRGOEFX.mjs +585 -0
  35. package/dist/chunk-AUF4CHDP.mjs +422 -0
  36. package/dist/chunk-B4FTADAZ.mjs +561 -0
  37. package/dist/chunk-BABQKA6K.mjs +339 -0
  38. package/dist/chunk-BETFQBM2.mjs +197 -0
  39. package/dist/chunk-BKP26M4K.mjs +413 -0
  40. package/dist/chunk-BZN2QHGP.mjs +200 -0
  41. package/dist/chunk-C36VWQ7A.mjs +86 -0
  42. package/dist/chunk-CHW4RKY3.mjs +16 -0
  43. package/dist/chunk-CINXJIRR.mjs +120 -0
  44. package/dist/chunk-DN6AXQYZ.mjs +667 -0
  45. package/dist/chunk-DP2IZNN3.mjs +92 -0
  46. package/dist/chunk-DTWTCFRG.mjs +119 -0
  47. package/dist/chunk-EAMUNLRU.mjs +172 -0
  48. package/dist/chunk-EDAKJLNA.mjs +17 -0
  49. package/dist/chunk-ERVQB2VZ.mjs +59 -0
  50. package/dist/chunk-FFMT6OCO.mjs +92 -0
  51. package/dist/chunk-FHTC2YDB.mjs +102 -0
  52. package/dist/chunk-FRST55HY.mjs +16 -0
  53. package/dist/chunk-HDFGCN2F.mjs +132 -0
  54. package/dist/chunk-IEGLX7VL.mjs +42 -0
  55. package/dist/chunk-ILUWFYGY.mjs +220 -0
  56. package/dist/chunk-IXOWSEHO.mjs +114 -0
  57. package/dist/chunk-J4RI2C2G.mjs +172 -0
  58. package/dist/chunk-J65DBT4R.mjs +13 -0
  59. package/dist/chunk-JGOVWSKH.mjs +179 -0
  60. package/dist/chunk-JO7VACY2.mjs +25 -0
  61. package/dist/chunk-JWFBOPM6.mjs +122 -0
  62. package/dist/chunk-KNDZP446.mjs +895 -0
  63. package/dist/chunk-KP2TWD4Z.mjs +90 -0
  64. package/dist/chunk-KQIFO5I3.mjs +225 -0
  65. package/dist/chunk-KVDEROP6.mjs +59 -0
  66. package/dist/chunk-LKC7MZKK.mjs +87 -0
  67. package/dist/chunk-LVMDQ4OJ.mjs +305 -0
  68. package/dist/chunk-M7B3JF43.mjs +90 -0
  69. package/dist/chunk-MTGMXRNF.mjs +136 -0
  70. package/dist/chunk-N3TIT3OH.mjs +1040 -0
  71. package/dist/chunk-NHRK5KU2.mjs +890 -0
  72. package/dist/chunk-NKUYIWAP.mjs +243 -0
  73. package/dist/chunk-NPDZLYIF.mjs +238 -0
  74. package/dist/chunk-O2X6FF45.mjs +499 -0
  75. package/dist/chunk-OGJ6IIBW.mjs +176 -0
  76. package/dist/chunk-OHGCZZPZ.mjs +403 -0
  77. package/dist/chunk-OWW3K55O.mjs +351 -0
  78. package/dist/chunk-OXTFAWSK.mjs +60 -0
  79. package/dist/chunk-PLSDU3C2.mjs +890 -0
  80. package/dist/chunk-PRDVPOZX.mjs +223 -0
  81. package/dist/chunk-Q6PPVIHU.mjs +21 -0
  82. package/dist/chunk-QQBXUDM4.mjs +885 -0
  83. package/dist/chunk-QS76E3TD.mjs +111 -0
  84. package/dist/chunk-QWQ6HY4I.mjs +209 -0
  85. package/dist/chunk-R6Y3R7EW.mjs +135 -0
  86. package/dist/chunk-RBLZRT5K.mjs +190 -0
  87. package/dist/chunk-RO4N6YFS.mjs +167 -0
  88. package/dist/chunk-RQ3CKQOX.mjs +984 -0
  89. package/dist/chunk-SALTGZFR.mjs +208 -0
  90. package/dist/chunk-SANZPAJ4.mjs +14 -0
  91. package/dist/chunk-SDBPQ5CF.mjs +624 -0
  92. package/dist/chunk-SSLTFJ3U.mjs +364 -0
  93. package/dist/chunk-SXHVDJGF.mjs +77 -0
  94. package/dist/chunk-TA4MVAEX.mjs +243 -0
  95. package/dist/chunk-TAHCOZHF.mjs +1772 -0
  96. package/dist/chunk-TQ6S34QZ.mjs +152 -0
  97. package/dist/chunk-UPRXABX5.mjs +90 -0
  98. package/dist/chunk-VGLSBZDN.mjs +71 -0
  99. package/dist/chunk-VN7CKCSE.mjs +364 -0
  100. package/dist/chunk-VVI3OBPJ.mjs +524 -0
  101. package/dist/chunk-VWF57TS3.mjs +62 -0
  102. package/dist/chunk-WA3OVISZ.mjs +179 -0
  103. package/dist/chunk-WCG35U6M.mjs +964 -0
  104. package/dist/chunk-WFTX4AQJ.mjs +194 -0
  105. package/dist/chunk-WFVOQ2QZ.mjs +18 -0
  106. package/dist/chunk-WH3C3Y7P.mjs +149 -0
  107. package/dist/chunk-WPFUV7K3.mjs +488 -0
  108. package/dist/chunk-WRULPWHD.mjs +492 -0
  109. package/dist/chunk-WS64BZXT.mjs +1 -0
  110. package/dist/chunk-WY4AURRE.mjs +2419 -0
  111. package/dist/chunk-WYLILAOO.mjs +167 -0
  112. package/dist/chunk-X4D7FKUS.mjs +62 -0
  113. package/dist/chunk-X7T34OLW.mjs +139 -0
  114. package/dist/chunk-XIHBK5D3.mjs +68 -0
  115. package/dist/chunk-XQQCGFYB.mjs +50 -0
  116. package/dist/chunk-XTVE4P3L.mjs +214 -0
  117. package/dist/chunk-XUAASRXW.mjs +579 -0
  118. package/dist/chunk-Y3L3D4GQ.mjs +685 -0
  119. package/dist/chunk-YBJ56XJS.mjs +132 -0
  120. package/dist/chunk-ZQFK6CAE.mjs +1 -0
  121. package/dist/chunk-ZT2Z7ERM.mjs +874 -0
  122. package/dist/chunk-ZTL2FQEW.mjs +714 -0
  123. package/dist/circular/arc/index.d.mts +8 -0
  124. package/dist/circular/arc/index.mjs +3 -0
  125. package/dist/circular/index.d.mts +44 -0
  126. package/dist/circular/index.mjs +13 -0
  127. package/dist/collect.utils-DiKB4ciO.d.mts +12 -0
  128. package/dist/computeChartState-BTVIqwyO.d.mts +304 -0
  129. package/dist/controller-BJE1AZ3q.d.mts +82 -0
  130. package/dist/controller-BoNigQJr.d.mts +63 -0
  131. package/dist/controllers/index.d.mts +16 -0
  132. package/dist/controllers/index.mjs +110 -0
  133. package/dist/datalabel.utils-CkjGeB8S.d.mts +122 -0
  134. package/dist/decimation.utils-CcvJVhI4.d.mts +244 -0
  135. package/dist/geometry-DUUQJXVM.d.mts +60 -0
  136. package/dist/index-DseIZa1j.d.mts +167 -0
  137. package/dist/index.d.mts +88 -0
  138. package/dist/index.mjs +110 -0
  139. package/dist/orchestrator/index.d.mts +264 -0
  140. package/dist/orchestrator/index.mjs +33 -0
  141. package/dist/plugins/index.d.mts +18 -0
  142. package/dist/plugins/index.mjs +1 -0
  143. package/dist/property-animations-D433wXzz.d.mts +580 -0
  144. package/dist/property-store-NORUWFND.d.mts +17 -0
  145. package/dist/radial/index.d.mts +14 -0
  146. package/dist/radial/index.mjs +37 -0
  147. package/dist/renderers/axis/index.d.mts +39 -0
  148. package/dist/renderers/axis/index.mjs +8 -0
  149. package/dist/renderers/circular/index.d.mts +13 -0
  150. package/dist/renderers/circular/index.mjs +13 -0
  151. package/dist/renderers/index.d.mts +83 -0
  152. package/dist/renderers/index.mjs +75 -0
  153. package/dist/renderers/navigator/index.d.mts +103 -0
  154. package/dist/renderers/navigator/index.mjs +8 -0
  155. package/dist/resize.utils-D_2qm6rv.d.mts +142 -0
  156. package/dist/ring.utils-DXvrxMkU.d.mts +138 -0
  157. package/dist/scale-KFv30jqZ.d.mts +307 -0
  158. package/dist/scales-Drf8AIhL.d.mts +75 -0
  159. package/dist/series/bar/canvas/index.d.mts +8 -0
  160. package/dist/series/bar/canvas/index.mjs +10 -0
  161. package/dist/series/bar/controller/index.d.mts +105 -0
  162. package/dist/series/bar/controller/index.mjs +44 -0
  163. package/dist/series/bar/controller-canvas/index.d.mts +7 -0
  164. package/dist/series/bar/controller-canvas/index.mjs +49 -0
  165. package/dist/series/bar/controller-svg/index.d.mts +7 -0
  166. package/dist/series/bar/controller-svg/index.mjs +49 -0
  167. package/dist/series/bar/index.d.mts +60 -0
  168. package/dist/series/bar/index.mjs +13 -0
  169. package/dist/series/bar/svg/index.d.mts +8 -0
  170. package/dist/series/bar/svg/index.mjs +11 -0
  171. package/dist/series/candlestick/canvas/index.d.mts +8 -0
  172. package/dist/series/candlestick/canvas/index.mjs +8 -0
  173. package/dist/series/candlestick/controller/index.d.mts +123 -0
  174. package/dist/series/candlestick/controller/index.mjs +40 -0
  175. package/dist/series/candlestick/controller-canvas/index.d.mts +7 -0
  176. package/dist/series/candlestick/controller-canvas/index.mjs +45 -0
  177. package/dist/series/candlestick/controller-svg/index.d.mts +7 -0
  178. package/dist/series/candlestick/controller-svg/index.mjs +45 -0
  179. package/dist/series/candlestick/index.d.mts +11 -0
  180. package/dist/series/candlestick/index.mjs +10 -0
  181. package/dist/series/candlestick/svg/index.d.mts +8 -0
  182. package/dist/series/candlestick/svg/index.mjs +8 -0
  183. package/dist/series/heatmap/canvas/index.d.mts +16 -0
  184. package/dist/series/heatmap/canvas/index.mjs +9 -0
  185. package/dist/series/heatmap/controller/index.d.mts +110 -0
  186. package/dist/series/heatmap/controller/index.mjs +23 -0
  187. package/dist/series/heatmap/controller-canvas/index.d.mts +7 -0
  188. package/dist/series/heatmap/controller-canvas/index.mjs +28 -0
  189. package/dist/series/heatmap/controller-svg/index.d.mts +7 -0
  190. package/dist/series/heatmap/controller-svg/index.mjs +28 -0
  191. package/dist/series/heatmap/index.d.mts +34 -0
  192. package/dist/series/heatmap/index.mjs +13 -0
  193. package/dist/series/heatmap/svg/index.d.mts +15 -0
  194. package/dist/series/heatmap/svg/index.mjs +10 -0
  195. package/dist/series/line/canvas/index.d.mts +6 -0
  196. package/dist/series/line/canvas/index.mjs +9 -0
  197. package/dist/series/line/controller/index.d.mts +111 -0
  198. package/dist/series/line/controller/index.mjs +47 -0
  199. package/dist/series/line/controller-canvas/index.d.mts +7 -0
  200. package/dist/series/line/controller-canvas/index.mjs +54 -0
  201. package/dist/series/line/controller-svg/index.d.mts +7 -0
  202. package/dist/series/line/controller-svg/index.mjs +54 -0
  203. package/dist/series/line/index.d.mts +49 -0
  204. package/dist/series/line/index.mjs +13 -0
  205. package/dist/series/line/svg/index.d.mts +6 -0
  206. package/dist/series/line/svg/index.mjs +9 -0
  207. package/dist/series/pie/canvas/index.d.mts +8 -0
  208. package/dist/series/pie/canvas/index.mjs +10 -0
  209. package/dist/series/pie/controller/index.d.mts +174 -0
  210. package/dist/series/pie/controller/index.mjs +110 -0
  211. package/dist/series/pie/controller-canvas/index.d.mts +8 -0
  212. package/dist/series/pie/controller-canvas/index.mjs +119 -0
  213. package/dist/series/pie/controller-svg/index.d.mts +8 -0
  214. package/dist/series/pie/controller-svg/index.mjs +118 -0
  215. package/dist/series/pie/index.d.mts +59 -0
  216. package/dist/series/pie/index.mjs +15 -0
  217. package/dist/series/pie/svg/index.d.mts +6 -0
  218. package/dist/series/pie/svg/index.mjs +11 -0
  219. package/dist/series/polar/canvas/index.d.mts +6 -0
  220. package/dist/series/polar/canvas/index.mjs +7 -0
  221. package/dist/series/polar/controller/index.d.mts +102 -0
  222. package/dist/series/polar/controller/index.mjs +46 -0
  223. package/dist/series/polar/controller-canvas/index.d.mts +8 -0
  224. package/dist/series/polar/controller-canvas/index.mjs +52 -0
  225. package/dist/series/polar/controller-svg/index.d.mts +8 -0
  226. package/dist/series/polar/controller-svg/index.mjs +52 -0
  227. package/dist/series/polar/index.d.mts +25 -0
  228. package/dist/series/polar/index.mjs +16 -0
  229. package/dist/series/polar/svg/index.d.mts +10 -0
  230. package/dist/series/polar/svg/index.mjs +8 -0
  231. package/dist/series/radar/canvas/index.d.mts +6 -0
  232. package/dist/series/radar/canvas/index.mjs +8 -0
  233. package/dist/series/radar/controller/index.d.mts +121 -0
  234. package/dist/series/radar/controller/index.mjs +43 -0
  235. package/dist/series/radar/controller-canvas/index.d.mts +8 -0
  236. package/dist/series/radar/controller-canvas/index.mjs +51 -0
  237. package/dist/series/radar/controller-svg/index.d.mts +8 -0
  238. package/dist/series/radar/controller-svg/index.mjs +51 -0
  239. package/dist/series/radar/index.d.mts +40 -0
  240. package/dist/series/radar/index.mjs +13 -0
  241. package/dist/series/radar/svg/index.d.mts +12 -0
  242. package/dist/series/radar/svg/index.mjs +9 -0
  243. package/dist/series/scatter/canvas/index.d.mts +8 -0
  244. package/dist/series/scatter/canvas/index.mjs +11 -0
  245. package/dist/series/scatter/controller/index.d.mts +124 -0
  246. package/dist/series/scatter/controller/index.mjs +44 -0
  247. package/dist/series/scatter/controller-canvas/index.d.mts +7 -0
  248. package/dist/series/scatter/controller-canvas/index.mjs +51 -0
  249. package/dist/series/scatter/controller-svg/index.d.mts +7 -0
  250. package/dist/series/scatter/controller-svg/index.mjs +51 -0
  251. package/dist/series/scatter/index.d.mts +25 -0
  252. package/dist/series/scatter/index.mjs +14 -0
  253. package/dist/series/scatter/svg/index.d.mts +8 -0
  254. package/dist/series/scatter/svg/index.mjs +12 -0
  255. package/dist/series/treemap/canvas/index.d.mts +50 -0
  256. package/dist/series/treemap/canvas/index.mjs +10 -0
  257. package/dist/series/treemap/controller/index.d.mts +130 -0
  258. package/dist/series/treemap/controller/index.mjs +20 -0
  259. package/dist/series/treemap/controller-canvas/index.d.mts +7 -0
  260. package/dist/series/treemap/controller-canvas/index.mjs +25 -0
  261. package/dist/series/treemap/controller-svg/index.d.mts +7 -0
  262. package/dist/series/treemap/controller-svg/index.mjs +25 -0
  263. package/dist/series/treemap/index.d.mts +15 -0
  264. package/dist/series/treemap/index.mjs +12 -0
  265. package/dist/series/treemap/svg/index.d.mts +15 -0
  266. package/dist/series/treemap/svg/index.mjs +9 -0
  267. package/dist/slices-DtewiwJx.d.mts +72 -0
  268. package/dist/spatialIndex.utils-B_GJkotZ.d.mts +5 -0
  269. package/dist/squarify.utils-B9CQBpa1.d.mts +50 -0
  270. package/dist/stacking-CChuAcLN.d.mts +319 -0
  271. package/dist/streaming.utils-DH-g1gNP.d.mts +49 -0
  272. package/dist/sync/index.d.mts +130 -0
  273. package/dist/sync/index.mjs +5 -0
  274. package/dist/tooltip.renderer-D5wpSlBa.d.mts +210 -0
  275. package/dist/utils/color/index.d.mts +58 -0
  276. package/dist/utils/color/index.mjs +4 -0
  277. package/dist/utils/data/index.d.mts +180 -0
  278. package/dist/utils/data/index.mjs +7 -0
  279. package/dist/utils/export/index.d.mts +14 -0
  280. package/dist/utils/export/index.mjs +6 -0
  281. package/dist/utils/index.d.mts +49 -0
  282. package/dist/utils/index.mjs +29 -0
  283. package/dist/utils/interaction/index.d.mts +255 -0
  284. package/dist/utils/interaction/index.mjs +9 -0
  285. package/dist/utils/layout/index.d.mts +3 -0
  286. package/dist/utils/layout/index.mjs +10 -0
  287. package/dist/utils/math/index.d.mts +162 -0
  288. package/dist/utils/math/index.mjs +1 -0
  289. package/dist/utils/render/index.d.mts +19 -0
  290. package/dist/utils/render/index.mjs +3 -0
  291. package/dist/utils/specialized/index.d.mts +37 -0
  292. package/dist/utils/specialized/index.mjs +66 -0
  293. package/dist/utils/text/index.d.mts +39 -0
  294. package/dist/utils/text/index.mjs +8 -0
  295. package/dist/utils/theme/index.d.mts +295 -0
  296. package/dist/utils/theme/index.mjs +5 -0
  297. package/dist/utils/zoom/index.d.mts +90 -0
  298. package/dist/utils/zoom/index.mjs +3 -0
  299. package/package.json +56 -0
@@ -0,0 +1,339 @@
1
+ import { handleSyncedHighlightCartesian, handleSyncedHighlightRect, handleSyncedHighlightRadial, buildDatasetRegistrations } from './chunk-WYLILAOO.mjs';
2
+
3
+ // src/sync/SyncBus.ts
4
+ function resolveAxis(value, fallback) {
5
+ if (value === void 0 || value === false) return false;
6
+ if (value === true) return fallback;
7
+ return value;
8
+ }
9
+ function resolveSyncConfig(sync) {
10
+ if (sync === false) {
11
+ return { extremes: false, highlight: false, visibility: false };
12
+ }
13
+ if (sync === true || sync === void 0) {
14
+ return { extremes: "x", highlight: "x", visibility: true };
15
+ }
16
+ return {
17
+ extremes: resolveAxis(sync.extremes, "x"),
18
+ highlight: resolveAxis(sync.highlight, "x"),
19
+ visibility: sync.visibility ?? true
20
+ };
21
+ }
22
+ function includesAxis(config, axis) {
23
+ if (config === false) return false;
24
+ return config === axis || config === "xy";
25
+ }
26
+ function ensureRegistration(charts, chartId) {
27
+ let reg = charts.get(chartId);
28
+ if (!reg) {
29
+ reg = {
30
+ config: { extremes: false, highlight: false, visibility: false },
31
+ extremes: /* @__PURE__ */ new Set(),
32
+ highlight: /* @__PURE__ */ new Set(),
33
+ visibility: /* @__PURE__ */ new Set()
34
+ };
35
+ charts.set(chartId, reg);
36
+ }
37
+ return reg;
38
+ }
39
+ var SyncBus = class {
40
+ constructor() {
41
+ this.charts = /* @__PURE__ */ new Map();
42
+ // --- Axis width registry for stacked-pane alignment ---
43
+ this.axisWidthsMap = /* @__PURE__ */ new Map();
44
+ this._maxAxisWidths = { left: 0, right: 0 };
45
+ this.axisWidthsListeners = /* @__PURE__ */ new Set();
46
+ // --- Dataset registry for shared legend ---
47
+ this.datasetRegistry = /* @__PURE__ */ new Map();
48
+ this.datasetListeners = /* @__PURE__ */ new Set();
49
+ }
50
+ /** Publish this chart's natural (un-padded) Y-axis left/right widths. No-op if unchanged. */
51
+ publishAxisWidths(chartId, widths) {
52
+ const prev = this.axisWidthsMap.get(chartId);
53
+ if (prev && prev.left === widths.left && prev.right === widths.right) return;
54
+ this.axisWidthsMap.set(chartId, widths);
55
+ this.recomputeMaxAxisWidths();
56
+ }
57
+ /** Get the current max axis widths across all registered charts. */
58
+ getMaxAxisWidths() {
59
+ return this._maxAxisWidths;
60
+ }
61
+ /** Subscribe to max axis width changes. Returns an unsubscribe function. */
62
+ subscribeAxisWidths(callback) {
63
+ this.axisWidthsListeners.add(callback);
64
+ return () => {
65
+ this.axisWidthsListeners.delete(callback);
66
+ };
67
+ }
68
+ recomputeMaxAxisWidths() {
69
+ let left = 0;
70
+ let right = 0;
71
+ for (const w of this.axisWidthsMap.values()) {
72
+ if (w.left > left) left = w.left;
73
+ if (w.right > right) right = w.right;
74
+ }
75
+ const changed = left !== this._maxAxisWidths.left || right !== this._maxAxisWidths.right;
76
+ this._maxAxisWidths = { left, right };
77
+ if (changed) {
78
+ for (const cb of this.axisWidthsListeners) cb(this._maxAxisWidths);
79
+ }
80
+ }
81
+ /** Register datasets from a chart (for shared legend). Replaces previous entry for this chartId. */
82
+ registerDatasets(chartId, datasets) {
83
+ this.datasetRegistry.set(chartId, datasets);
84
+ this.notifyDatasetListeners();
85
+ }
86
+ /** Unregister datasets when a chart unmounts */
87
+ unregisterDatasets(chartId) {
88
+ if (this.datasetRegistry.delete(chartId)) {
89
+ this.notifyDatasetListeners();
90
+ }
91
+ }
92
+ /** Get all registered datasets across all charts */
93
+ getAllDatasets() {
94
+ return this.datasetRegistry;
95
+ }
96
+ /** Subscribe to dataset registry changes. Returns unsubscribe function. */
97
+ subscribeDatasets(callback) {
98
+ this.datasetListeners.add(callback);
99
+ return () => {
100
+ this.datasetListeners.delete(callback);
101
+ };
102
+ }
103
+ notifyDatasetListeners() {
104
+ for (const cb of this.datasetListeners) {
105
+ cb();
106
+ }
107
+ }
108
+ /** Register a chart instance with its sync config (no callbacks) */
109
+ register(chartId, config) {
110
+ const reg = ensureRegistration(this.charts, chartId);
111
+ reg.config = config;
112
+ }
113
+ subscribe(chartId, type, callback) {
114
+ const reg = ensureRegistration(this.charts, chartId);
115
+ const set = reg[type];
116
+ set.add(callback);
117
+ return () => {
118
+ set.delete(callback);
119
+ };
120
+ }
121
+ /** Update a chart's sync config (e.g. when sync prop changes) */
122
+ updateConfig(chartId, config) {
123
+ const registration = this.charts.get(chartId);
124
+ if (registration) {
125
+ registration.config = config;
126
+ }
127
+ }
128
+ /** Unregister a chart instance and all its subscriptions */
129
+ unregister(chartId) {
130
+ this.charts.delete(chartId);
131
+ this.unregisterDatasets(chartId);
132
+ if (this.axisWidthsMap.delete(chartId)) {
133
+ this.recomputeMaxAxisWidths();
134
+ }
135
+ }
136
+ /** Broadcast an extremes (zoom/pan) event from a source chart */
137
+ broadcastExtremes(event) {
138
+ for (const [chartId, reg] of this.charts) {
139
+ if (chartId === event.sourceId) continue;
140
+ if (!includesAxis(reg.config.extremes, event.axis)) continue;
141
+ for (const cb of reg.extremes) {
142
+ cb(event);
143
+ }
144
+ }
145
+ }
146
+ /** Broadcast a highlight (cursor) event from a source chart */
147
+ broadcastHighlight(event) {
148
+ for (const [chartId, reg] of this.charts) {
149
+ if (chartId === event.sourceId) continue;
150
+ if (!includesAxis(reg.config.highlight, event.axis)) continue;
151
+ for (const cb of reg.highlight) {
152
+ cb(event);
153
+ }
154
+ }
155
+ }
156
+ /** Broadcast a visibility (series toggle) event from a source chart */
157
+ broadcastVisibility(event) {
158
+ for (const [chartId, reg] of this.charts) {
159
+ if (chartId === event.sourceId) continue;
160
+ if (!reg.config.visibility) continue;
161
+ for (const cb of reg.visibility) {
162
+ cb(event);
163
+ }
164
+ }
165
+ }
166
+ /** Get number of registered charts */
167
+ get size() {
168
+ return this.charts.size;
169
+ }
170
+ };
171
+
172
+ // src/sync/ChartSyncCoordinator.ts
173
+ function zoomWindowEquals(a, b) {
174
+ if (a === null || b === null) return a === b;
175
+ return a.min === b.min && a.max === b.max;
176
+ }
177
+ function zoomStateEquals(a, b) {
178
+ return zoomWindowEquals(a.x, b.x) && zoomWindowEquals(a.y, b.y);
179
+ }
180
+ var ChartSyncCoordinator = class {
181
+ constructor(syncInfo) {
182
+ this._isSyncing = false;
183
+ this.prevVisibility = /* @__PURE__ */ new Map();
184
+ this.prevZoomState = { x: null, y: null };
185
+ /**
186
+ * The last zoom value applied from an incoming sync event. Used by onZoomChange
187
+ * to suppress the echo even when the wrapper's apply effect fires asynchronously
188
+ * (after the `_isSyncing` microtask reset). Cleared once matched.
189
+ */
190
+ this._lastSyncedZoom = null;
191
+ this.syncInfo = syncInfo;
192
+ }
193
+ get isSyncing() {
194
+ return this._isSyncing;
195
+ }
196
+ // ========== Setup ==========
197
+ /**
198
+ * Wire up all incoming sync subscriptions.
199
+ * Call once after constructing the coordinator; store the returned
200
+ * cleanup function and invoke it on component unmount.
201
+ */
202
+ start(options) {
203
+ const { bus, chartId, config } = this.syncInfo;
204
+ const unsubs = [];
205
+ if (config.extremes) {
206
+ unsubs.push(
207
+ bus.subscribe(chartId, "extremes", (event) => {
208
+ this._isSyncing = true;
209
+ const current = options.getZoomState();
210
+ const next = event.reset ? {
211
+ x: event.axis === "x" ? null : current.x,
212
+ y: event.axis === "y" ? null : current.y
213
+ } : {
214
+ x: event.axis === "x" ? { min: event.min, max: event.max } : current.x,
215
+ y: event.axis === "y" ? { min: event.min, max: event.max } : current.y
216
+ };
217
+ this._lastSyncedZoom = next;
218
+ options.applyZoom(next);
219
+ queueMicrotask(() => {
220
+ this._isSyncing = false;
221
+ });
222
+ })
223
+ );
224
+ }
225
+ if (config.visibility) {
226
+ unsubs.push(
227
+ bus.subscribe(chartId, "visibility", (event) => {
228
+ if (event.itemLabel !== void 0) {
229
+ this._isSyncing = true;
230
+ options.applyItemToggle(event.seriesId, event.itemLabel);
231
+ queueMicrotask(() => {
232
+ this._isSyncing = false;
233
+ });
234
+ return;
235
+ }
236
+ if (!event.seriesId) return;
237
+ const datasets = options.getDatasets();
238
+ let localId = datasets.has(event.seriesId) ? event.seriesId : null;
239
+ if (!localId) {
240
+ const allEntries = [...bus.getAllDatasets().values()].flat();
241
+ const sourceDs = allEntries.find((ds) => ds.datasetId === event.seriesId);
242
+ if (sourceDs) {
243
+ const localDs = allEntries.find((ds) => ds.chartId === chartId && ds.label === sourceDs.label);
244
+ localId = localDs?.datasetId ?? null;
245
+ }
246
+ }
247
+ if (!localId) return;
248
+ this._isSyncing = true;
249
+ options.applyVisibility(localId, event.visible);
250
+ queueMicrotask(() => {
251
+ this._isSyncing = false;
252
+ });
253
+ })
254
+ );
255
+ }
256
+ if (config.highlight) {
257
+ unsubs.push(
258
+ bus.subscribe(chartId, "highlight", (event) => {
259
+ if (event.normalized === null) {
260
+ options.applyHighlight({ tooltip: null, hoverDatasetId: null, hoverIndex: null });
261
+ return;
262
+ }
263
+ const normalizedEvent = {
264
+ normalized: event.normalized,
265
+ categoryIndex: event.categoryIndex ?? void 0,
266
+ sourceType: event.sourceType
267
+ };
268
+ const { width, height } = options.getDimensions();
269
+ const datasets = options.getDatasets();
270
+ if (options.getIsCartesian()) {
271
+ options.applyHighlight(handleSyncedHighlightCartesian(normalizedEvent, options.getRendererDelegate(), options.getHasCrosshair(), options.getIsSharedMode(), datasets));
272
+ } else if (options.getIsRect() && event.categoryIndex != null) {
273
+ options.applyHighlight(handleSyncedHighlightRect(normalizedEvent, datasets, width, height));
274
+ } else if (event.categoryIndex != null) {
275
+ options.applyHighlight(handleSyncedHighlightRadial(normalizedEvent, datasets, options.getRendererDelegate(), width, height));
276
+ }
277
+ })
278
+ );
279
+ }
280
+ return () => {
281
+ for (const unsub of unsubs) unsub();
282
+ bus.unregisterDatasets(chartId);
283
+ };
284
+ }
285
+ // ========== Outgoing ==========
286
+ /** Re-register datasets with the shared legend bus. Call whenever datasets or theme change. */
287
+ updateDatasets(datasets, theme) {
288
+ const infos = buildDatasetRegistrations(this.syncInfo.chartId, datasets, theme);
289
+ this.syncInfo.bus.registerDatasets(this.syncInfo.chartId, infos);
290
+ }
291
+ /**
292
+ * Broadcast zoom state changes to other charts.
293
+ * Always call this when zoom state changes — the guard is handled internally.
294
+ */
295
+ onZoomChange(current) {
296
+ const prev = this.prevZoomState;
297
+ this.prevZoomState = current;
298
+ if (this._isSyncing || !this.syncInfo.config.extremes) return;
299
+ if (this._lastSyncedZoom && zoomStateEquals(this._lastSyncedZoom, current)) {
300
+ this._lastSyncedZoom = null;
301
+ return;
302
+ }
303
+ this._lastSyncedZoom = null;
304
+ const axis = this.syncInfo.config.extremes;
305
+ if (axis === "x" || axis === "xy") {
306
+ if (current.x) {
307
+ this.syncInfo.bus.broadcastExtremes({ sourceId: this.syncInfo.chartId, axis: "x", min: current.x.min, max: current.x.max });
308
+ } else if (prev.x) {
309
+ this.syncInfo.bus.broadcastExtremes({ sourceId: this.syncInfo.chartId, axis: "x", min: 0, max: 0, reset: true });
310
+ }
311
+ }
312
+ if (axis === "y" || axis === "xy") {
313
+ if (current.y) {
314
+ this.syncInfo.bus.broadcastExtremes({ sourceId: this.syncInfo.chartId, axis: "y", min: current.y.min, max: current.y.max });
315
+ } else if (prev.y) {
316
+ this.syncInfo.bus.broadcastExtremes({ sourceId: this.syncInfo.chartId, axis: "y", min: 0, max: 0, reset: true });
317
+ }
318
+ }
319
+ }
320
+ /**
321
+ * Diff visibility state and broadcast changes to other charts.
322
+ * Always call this on visibility change — guard and diffing are handled internally.
323
+ * prevVisibility is always updated regardless of isSyncing to prevent stale state
324
+ * on the next outgoing broadcast.
325
+ */
326
+ onVisibilityChange(visibility) {
327
+ const shouldBroadcast = !this._isSyncing && !!this.syncInfo.config.visibility;
328
+ for (const [dsId, visible] of visibility) {
329
+ const was = this.prevVisibility.get(dsId) ?? true;
330
+ if (visible !== was && shouldBroadcast) {
331
+ this.syncInfo.bus.broadcastVisibility({ sourceId: this.syncInfo.chartId, seriesId: dsId, visible });
332
+ }
333
+ }
334
+ this.prevVisibility.clear();
335
+ for (const [k, v] of visibility) this.prevVisibility.set(k, v);
336
+ }
337
+ };
338
+
339
+ export { ChartSyncCoordinator, SyncBus, resolveSyncConfig };
@@ -0,0 +1,197 @@
1
+ // src/utils/specialized/squarify.utils.ts
2
+ function worstAspectRatio(row, sideLength, totalRowArea) {
3
+ if (row.length === 0 || sideLength === 0) return Infinity;
4
+ const rowWidth = totalRowArea / sideLength;
5
+ if (rowWidth === 0) return Infinity;
6
+ let worst = 0;
7
+ for (const area of row) {
8
+ const itemLength = area / rowWidth;
9
+ const ratio = rowWidth > itemLength ? rowWidth / itemLength : itemLength / rowWidth;
10
+ if (ratio > worst) worst = ratio;
11
+ }
12
+ return worst;
13
+ }
14
+ function layoutRow(row, rect, totalArea, rowIndex) {
15
+ const rects = [];
16
+ const rowArea = row.reduce((s, item) => s + item.value, 0);
17
+ const isHorizontal = rect.w >= rect.h;
18
+ if (isHorizontal) {
19
+ const stripWidth = totalArea > 0 ? rowArea / totalArea * rect.w : 0;
20
+ let y = rect.y;
21
+ for (const item of row) {
22
+ const itemHeight = rowArea > 0 ? item.value / rowArea * rect.h : 0;
23
+ rects.push({ x: rect.x, y, width: stripWidth, height: itemHeight, index: item.index, depth: 0, _row: rowIndex });
24
+ y += itemHeight;
25
+ }
26
+ return {
27
+ rects,
28
+ remaining: { x: rect.x + stripWidth, y: rect.y, w: rect.w - stripWidth, h: rect.h }
29
+ };
30
+ } else {
31
+ const stripHeight = totalArea > 0 ? rowArea / totalArea * rect.h : 0;
32
+ let x = rect.x;
33
+ for (const item of row) {
34
+ const itemWidth = rowArea > 0 ? item.value / rowArea * rect.w : 0;
35
+ rects.push({ x, y: rect.y, width: itemWidth, height: stripHeight, index: item.index, depth: 0, _row: rowIndex });
36
+ x += itemWidth;
37
+ }
38
+ return {
39
+ rects,
40
+ remaining: { x: rect.x, y: rect.y + stripHeight, w: rect.w, h: rect.h - stripHeight }
41
+ };
42
+ }
43
+ }
44
+ function squarify(items, x, y, w, h) {
45
+ if (items.length === 0 || w <= 0 || h <= 0) return [];
46
+ const sorted = [...items].sort((a, b) => b.value - a.value);
47
+ const totalValue = sorted.reduce((s, item) => s + item.value, 0);
48
+ if (totalValue <= 0) return [];
49
+ const totalArea = w * h;
50
+ const scaled = sorted.map((item) => ({
51
+ value: item.value / totalValue * totalArea,
52
+ index: item.index
53
+ }));
54
+ const results = [];
55
+ let rect = { x, y, w, h };
56
+ let i = 0;
57
+ let rowIndex = 0;
58
+ while (i < scaled.length) {
59
+ const sideLength = Math.min(rect.w, rect.h);
60
+ const remainingArea = scaled.slice(i).reduce((s, item) => s + item.value, 0);
61
+ const row = [scaled[i]];
62
+ let rowAreaSum = scaled[i].value;
63
+ let currentWorst = worstAspectRatio([scaled[i].value], sideLength, rowAreaSum);
64
+ i++;
65
+ while (i < scaled.length) {
66
+ const candidate = scaled[i].value;
67
+ const newRowArea = rowAreaSum + candidate;
68
+ const newWorst = worstAspectRatio([...row.map((r) => r.value), candidate], sideLength, newRowArea);
69
+ if (newWorst > currentWorst) break;
70
+ row.push(scaled[i]);
71
+ rowAreaSum = newRowArea;
72
+ currentWorst = newWorst;
73
+ i++;
74
+ }
75
+ const { rects, remaining } = layoutRow(row, rect, remainingArea, rowIndex);
76
+ results.push(...rects);
77
+ rect = remaining;
78
+ rowIndex++;
79
+ }
80
+ return results;
81
+ }
82
+ function resquarify(items, x, y, w, h, previousRects) {
83
+ if (!previousRects || previousRects.length === 0 || previousRects.length !== items.length) {
84
+ return squarify(items, x, y, w, h);
85
+ }
86
+ if (items.length === 0 || w <= 0 || h <= 0) return [];
87
+ const sorted = [...items].sort((a, b) => b.value - a.value);
88
+ const totalValue = sorted.reduce((s, item) => s + item.value, 0);
89
+ if (totalValue <= 0) return [];
90
+ for (let k = 0; k < sorted.length; k++) {
91
+ if (sorted[k].index !== previousRects[k].index) {
92
+ return squarify(items, x, y, w, h);
93
+ }
94
+ }
95
+ let prevMinX = Infinity;
96
+ let prevMinY = Infinity;
97
+ let prevMaxX = -Infinity;
98
+ let prevMaxY = -Infinity;
99
+ for (const r of previousRects) {
100
+ if (r.x < prevMinX) prevMinX = r.x;
101
+ if (r.y < prevMinY) prevMinY = r.y;
102
+ if (r.x + r.width > prevMaxX) prevMaxX = r.x + r.width;
103
+ if (r.y + r.height > prevMaxY) prevMaxY = r.y + r.height;
104
+ }
105
+ const prevWidth = prevMaxX - prevMinX;
106
+ const prevHeight = prevMaxY - prevMinY;
107
+ const EPSILON = 0.5;
108
+ if (Math.abs(prevMinX - x) > EPSILON || Math.abs(prevMinY - y) > EPSILON || Math.abs(prevWidth - w) > EPSILON || Math.abs(prevHeight - h) > EPSILON) {
109
+ return squarify(items, x, y, w, h);
110
+ }
111
+ const totalArea = w * h;
112
+ const scaled = sorted.map((item) => ({
113
+ value: item.value / totalValue * totalArea,
114
+ index: item.index
115
+ }));
116
+ const result = new Array(sorted.length);
117
+ let i = 0;
118
+ while (i < previousRects.length) {
119
+ const rowIdx = previousRects[i]._row;
120
+ const rowStart = i;
121
+ while (i < previousRects.length && previousRects[i]._row === rowIdx) i++;
122
+ const rowEnd = i;
123
+ const first = previousRects[rowStart];
124
+ const sameX = previousRects.slice(rowStart, rowEnd).every((r) => r.x === first.x && r.width === first.width);
125
+ const rowItems = scaled.slice(rowStart, rowEnd);
126
+ const rowAreaSum = rowItems.reduce((s, it) => s + it.value, 0);
127
+ if (sameX) {
128
+ const stripX = first.x;
129
+ const stripWidth = first.width;
130
+ const stripY = first.y;
131
+ const stripHeight = previousRects[rowEnd - 1].y + previousRects[rowEnd - 1].height - stripY;
132
+ let cy = stripY;
133
+ for (let k = rowStart; k < rowEnd; k++) {
134
+ const cellHeight = rowAreaSum > 0 ? scaled[k].value / rowAreaSum * stripHeight : 0;
135
+ result[k] = {
136
+ x: stripX,
137
+ y: cy,
138
+ width: stripWidth,
139
+ height: cellHeight,
140
+ index: scaled[k].index,
141
+ depth: 0,
142
+ _row: rowIdx
143
+ };
144
+ cy += cellHeight;
145
+ }
146
+ } else {
147
+ const stripY = first.y;
148
+ const stripHeight = first.height;
149
+ const stripX = first.x;
150
+ const stripWidth = previousRects[rowEnd - 1].x + previousRects[rowEnd - 1].width - stripX;
151
+ let cx = stripX;
152
+ for (let k = rowStart; k < rowEnd; k++) {
153
+ const cellWidth = rowAreaSum > 0 ? scaled[k].value / rowAreaSum * stripWidth : 0;
154
+ result[k] = {
155
+ x: cx,
156
+ y: stripY,
157
+ width: cellWidth,
158
+ height: stripHeight,
159
+ index: scaled[k].index,
160
+ depth: 0,
161
+ _row: rowIdx
162
+ };
163
+ cx += cellWidth;
164
+ }
165
+ }
166
+ }
167
+ return result;
168
+ }
169
+ function sliceLayout(items, x, y, w, h) {
170
+ const total = items.reduce((s, item) => s + item.value, 0);
171
+ if (total <= 0) return [];
172
+ const rects = [];
173
+ let cy = y;
174
+ for (const item of items) {
175
+ const itemH = item.value / total * h;
176
+ rects.push({ x, y: cy, width: w, height: itemH, index: item.index, depth: 0 });
177
+ cy += itemH;
178
+ }
179
+ return rects;
180
+ }
181
+ function diceLayout(items, x, y, w, h) {
182
+ const total = items.reduce((s, item) => s + item.value, 0);
183
+ if (total <= 0) return [];
184
+ const rects = [];
185
+ let cx = x;
186
+ for (const item of items) {
187
+ const itemW = item.value / total * w;
188
+ rects.push({ x: cx, y, width: itemW, height: h, index: item.index, depth: 0 });
189
+ cx += itemW;
190
+ }
191
+ return rects;
192
+ }
193
+ function sliceDiceLayout(items, x, y, w, h, depth = 0) {
194
+ return depth % 2 === 0 ? sliceLayout(items, x, y, w, h) : diceLayout(items, x, y, w, h);
195
+ }
196
+
197
+ export { diceLayout, resquarify, sliceDiceLayout, sliceLayout, squarify };