@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,885 @@
1
+ import { renderAxisSvg, renderAxisCanvas } from './chunk-ZTL2FQEW.mjs';
2
+ import { renderReferenceBandsSvg, computeReferenceBands, renderReferenceLinesSvg, computeReferenceLines, renderReferenceBandsCanvas, renderReferenceLinesCanvas, renderCustomMarkersCanvas } from './chunk-ZT2Z7ERM.mjs';
3
+ import { createDrawImage } from './chunk-7CMVDIOU.mjs';
4
+ import { adjustLabelForRotation } from './chunk-R6Y3R7EW.mjs';
5
+ import { DEFAULT_BRACKET_GAP, DEFAULT_BRACKET_LABEL_OFFSET, resolveFontFamily, resolveFontSize, DEFAULT_GROUP_LABEL_FONT_SIZE, resolveAxisColor, DEFAULT_GROUP_LABEL_FONT_WEIGHT, DEFAULT_BRACKET_DEPTH_LAYER_SIZE, DEFAULT_BRACKET_AXIS_TITLE_SPACE, DEFAULT_BG_FILL_EVEN, DEFAULT_BG_FILL_ODD, DEFAULT_BRACKET_TICK_SIZE } from './chunk-NKUYIWAP.mjs';
6
+ import { createSvgGroup, appendChild, createSvgRect, withCanvasState, createSvgText, svgNode, materializeSvgGroup, createSvgLine } from './chunk-SSLTFJ3U.mjs';
7
+ import { createLinearScale } from './chunk-RQ3CKQOX.mjs';
8
+
9
+ // src/cartesian/backgroundFill.utils.ts
10
+ function resolveDefaultFillColor(index, color) {
11
+ return color ?? (index % 2 === 0 ? DEFAULT_BG_FILL_EVEN : DEFAULT_BG_FILL_ODD);
12
+ }
13
+ function computeCategoryFills(boundaries, categoryScale, cartesianArea, orientation) {
14
+ const fills = [];
15
+ const categories = categoryScale.domain();
16
+ const bw = categoryScale.bandwidth();
17
+ for (let i = 0; i < boundaries.length; i++) {
18
+ const gb = boundaries[i];
19
+ if (!gb.fill) continue;
20
+ const color = resolveDefaultFillColor(i, gb.fill.color);
21
+ const opacity = gb.fill.opacity ?? 1;
22
+ if (orientation === "horizontal") {
23
+ const startY = categoryScale(categories[gb.startIdx]) - 1;
24
+ const endY = categoryScale(categories[gb.endIdx]) + bw + 1;
25
+ fills.push({ x: cartesianArea.x, y: startY, width: cartesianArea.width, height: endY - startY, color, opacity });
26
+ } else {
27
+ const startX = categoryScale(categories[gb.startIdx]) - 1;
28
+ const endX = categoryScale(categories[gb.endIdx]) + bw + 1;
29
+ fills.push({ x: startX, y: cartesianArea.y, width: endX - startX, height: cartesianArea.height, color, opacity });
30
+ }
31
+ }
32
+ return fills;
33
+ }
34
+ function computeRangeFills(boundaries, valueDomain, valueScaleRange, cartesianArea, orientation) {
35
+ const fills = [];
36
+ const valueScale = createLinearScale(valueDomain, valueScaleRange);
37
+ for (let i = 0; i < boundaries.length; i++) {
38
+ const rb = boundaries[i];
39
+ if (!rb.fill) continue;
40
+ const color = resolveDefaultFillColor(i, rb.fill.color);
41
+ const opacity = rb.fill.opacity ?? 1;
42
+ if (orientation === "vertical") {
43
+ const topY = valueScale(rb.to);
44
+ const botY = valueScale(rb.from);
45
+ fills.push({ x: cartesianArea.x, y: topY, width: cartesianArea.width, height: botY - topY, color, opacity });
46
+ } else {
47
+ const leftX = valueScale(rb.from);
48
+ const rightX = valueScale(rb.to);
49
+ fills.push({ x: leftX, y: cartesianArea.y, width: rightX - leftX, height: cartesianArea.height, color, opacity });
50
+ }
51
+ }
52
+ return fills;
53
+ }
54
+ function renderFillsSvg(fills) {
55
+ if (fills.length === 0) return null;
56
+ const fillGroup = createSvgGroup();
57
+ for (const f of fills) {
58
+ appendChild(fillGroup, createSvgRect(f.x, f.y, f.width, f.height, { fill: f.color, opacity: f.opacity }));
59
+ }
60
+ return fillGroup;
61
+ }
62
+ function renderFillsCanvas(ctx, fills) {
63
+ for (const f of fills) {
64
+ withCanvasState(ctx, () => {
65
+ ctx.globalAlpha = f.opacity;
66
+ ctx.fillStyle = f.color;
67
+ ctx.fillRect(f.x, f.y, f.width, f.height);
68
+ });
69
+ }
70
+ }
71
+
72
+ // src/cartesian/bracket.ts
73
+ function resolveStyle(val, defaultColor) {
74
+ return {
75
+ color: typeof val === "object" ? val.color ?? defaultColor : defaultColor,
76
+ width: typeof val === "object" ? val.width ?? 1 : 1,
77
+ dash: typeof val === "object" ? val.dash : void 0
78
+ };
79
+ }
80
+ function appendBracketShape(result, placement, axisCoord, start, end, color, width, dash) {
81
+ if (placement === "left") {
82
+ result.bracketLines.push({ x1: axisCoord, y1: start, x2: axisCoord, y2: end, color, width, dash });
83
+ result.bracketLines.push({ x1: axisCoord, y1: start, x2: axisCoord + DEFAULT_BRACKET_TICK_SIZE, y2: start, color, width });
84
+ result.bracketLines.push({ x1: axisCoord, y1: end, x2: axisCoord + DEFAULT_BRACKET_TICK_SIZE, y2: end, color, width });
85
+ } else {
86
+ result.bracketLines.push({ x1: start, y1: axisCoord, x2: end, y2: axisCoord, color, width, dash });
87
+ result.bracketLines.push({ x1: start, y1: axisCoord, x2: start, y2: axisCoord - DEFAULT_BRACKET_TICK_SIZE, color, width });
88
+ result.bracketLines.push({ x1: end, y1: axisCoord, x2: end, y2: axisCoord - DEFAULT_BRACKET_TICK_SIZE, color, width });
89
+ }
90
+ }
91
+ function appendLineSvg(group, line) {
92
+ const attrs = { stroke: line.color, "stroke-width": line.width };
93
+ if (line.dash) attrs["stroke-dasharray"] = line.dash.join(",");
94
+ appendChild(group, createSvgLine(line.x1, line.y1, line.x2, line.y2, attrs));
95
+ }
96
+ function strokeLine(ctx, line) {
97
+ ctx.beginPath();
98
+ ctx.strokeStyle = line.color;
99
+ ctx.lineWidth = line.width;
100
+ if (line.dash) ctx.setLineDash(line.dash);
101
+ ctx.moveTo(line.x1, line.y1);
102
+ ctx.lineTo(line.x2, line.y2);
103
+ ctx.stroke();
104
+ ctx.setLineDash([]);
105
+ }
106
+ function computeCategoryBracketGeometry(boundaries, categoryScale, cartesianArea, categoryAxisSpace, orientation, theme) {
107
+ const result = { separators: [], tickSeparators: [], bracketLines: [], labels: [] };
108
+ if (boundaries.length === 0) return result;
109
+ const categories = categoryScale.domain();
110
+ const bw = categoryScale.bandwidth();
111
+ const boundariesByDepth = /* @__PURE__ */ new Map();
112
+ for (const gb of boundaries) {
113
+ const d = gb.depth;
114
+ if (!boundariesByDepth.has(d)) boundariesByDepth.set(d, []);
115
+ boundariesByDepth.get(d).push(gb);
116
+ }
117
+ const maxDepth = Math.max(0, ...boundariesByDepth.keys());
118
+ for (const [depth, depthBoundaries] of boundariesByDepth) {
119
+ const depthOffset = (maxDepth - depth) * DEFAULT_BRACKET_DEPTH_LAYER_SIZE;
120
+ for (let i = 0; i < depthBoundaries.length; i++) {
121
+ const gb = depthBoundaries[i];
122
+ const displayLabel = gb.labelFormat ? gb.labelFormat(gb.label) : gb.label;
123
+ const labelColor = gb.labelStyle?.color ?? theme.groupLabelColor;
124
+ const labelFontSize = gb.labelStyle?.fontSize ?? theme.defaultFontSize;
125
+ const labelFontWeight = gb.labelStyle?.fontWeight ?? theme.defaultFontWeight;
126
+ const labelFontFamily = gb.labelStyle?.fontFamily ?? theme.defaultFontFamily;
127
+ if (orientation === "horizontal") {
128
+ const startY = categoryScale(categories[gb.startIdx]) - 1;
129
+ const endY = categoryScale(categories[gb.endIdx]) + bw + 1;
130
+ const midY = (startY + endY) / 2;
131
+ const bracketX = cartesianArea.x - categoryAxisSpace - DEFAULT_BRACKET_GAP - depthOffset;
132
+ if (gb.separator && i < depthBoundaries.length - 1) {
133
+ const nextGb = depthBoundaries[i + 1];
134
+ const nextStartY = categoryScale(categories[nextGb.startIdx]) - 1;
135
+ const sepY = (endY + nextStartY) / 2;
136
+ result.separators.push({
137
+ x1: cartesianArea.x,
138
+ y1: sepY,
139
+ x2: cartesianArea.x + cartesianArea.width,
140
+ y2: sepY,
141
+ color: gb.separator.color ?? theme.bracketColor,
142
+ width: gb.separator.width ?? 1,
143
+ dash: gb.separator.dash
144
+ });
145
+ }
146
+ if (gb.tickSeparator) {
147
+ const tsColor = gb.tickSeparator.color ?? theme.bracketColor;
148
+ const tsWidth = gb.tickSeparator.width ?? 1;
149
+ const tsDash = gb.tickSeparator.dash;
150
+ const axisLineX = cartesianArea.x;
151
+ const tickEndX = axisLineX - categoryAxisSpace;
152
+ if (i === 0 || !depthBoundaries[i - 1].tickSeparator) {
153
+ const edgeY = i === 0 ? cartesianArea.y : (categoryScale(categories[depthBoundaries[i - 1].endIdx]) + bw + 1 + startY) / 2;
154
+ result.tickSeparators.push({ x1: tickEndX, y1: edgeY, x2: axisLineX, y2: edgeY, color: tsColor, width: tsWidth, dash: tsDash });
155
+ }
156
+ if (i < depthBoundaries.length - 1) {
157
+ const nextGb = depthBoundaries[i + 1];
158
+ const nextStartY = categoryScale(categories[nextGb.startIdx]) - 1;
159
+ const boundaryY = (endY + nextStartY) / 2;
160
+ result.tickSeparators.push({ x1: tickEndX, y1: boundaryY, x2: axisLineX, y2: boundaryY, color: tsColor, width: tsWidth, dash: tsDash });
161
+ } else {
162
+ result.tickSeparators.push({
163
+ x1: tickEndX,
164
+ y1: cartesianArea.y + cartesianArea.height,
165
+ x2: axisLineX,
166
+ y2: cartesianArea.y + cartesianArea.height,
167
+ color: tsColor,
168
+ width: tsWidth,
169
+ dash: tsDash
170
+ });
171
+ }
172
+ }
173
+ if (gb.bracket !== false) {
174
+ const bStyle = resolveStyle(gb.bracket ?? true, theme.bracketColor);
175
+ appendBracketShape(result, "left", bracketX, startY, endY, bStyle.color, bStyle.width, bStyle.dash);
176
+ }
177
+ result.labels.push({
178
+ x: bracketX - DEFAULT_BRACKET_LABEL_OFFSET,
179
+ y: midY,
180
+ text: displayLabel,
181
+ color: labelColor,
182
+ fontSize: labelFontSize,
183
+ fontWeight: labelFontWeight,
184
+ fontFamily: labelFontFamily,
185
+ textAnchor: "end",
186
+ dominantBaseline: "central",
187
+ canvasTextAlign: "right",
188
+ canvasTextBaseline: "middle",
189
+ render: gb.render,
190
+ categories: categories.slice(gb.startIdx, gb.endIdx + 1),
191
+ depth: gb.depth
192
+ });
193
+ } else {
194
+ const startX = categoryScale(categories[gb.startIdx]) - 1;
195
+ const endX = categoryScale(categories[gb.endIdx]) + bw + 1;
196
+ const midX = (startX + endX) / 2;
197
+ const bracketY = cartesianArea.y + cartesianArea.height + categoryAxisSpace + DEFAULT_BRACKET_GAP + depthOffset;
198
+ if (gb.separator && i < depthBoundaries.length - 1) {
199
+ const nextGb = depthBoundaries[i + 1];
200
+ const nextStartX = categoryScale(categories[nextGb.startIdx]) - 1;
201
+ const sepX = (endX + nextStartX) / 2;
202
+ result.separators.push({
203
+ x1: sepX,
204
+ y1: cartesianArea.y,
205
+ x2: sepX,
206
+ y2: cartesianArea.y + cartesianArea.height,
207
+ color: gb.separator.color ?? theme.bracketColor,
208
+ width: gb.separator.width ?? 1,
209
+ dash: gb.separator.dash
210
+ });
211
+ }
212
+ if (gb.tickSeparator) {
213
+ const tsColor = gb.tickSeparator.color ?? theme.bracketColor;
214
+ const tsWidth = gb.tickSeparator.width ?? 1;
215
+ const tsDash = gb.tickSeparator.dash;
216
+ const axisLineY = cartesianArea.y + cartesianArea.height;
217
+ const tickEndY = axisLineY + categoryAxisSpace;
218
+ if (i === 0 || !depthBoundaries[i - 1].tickSeparator) {
219
+ const edgeX = i === 0 ? cartesianArea.x : (categoryScale(categories[depthBoundaries[i - 1].endIdx]) + bw + 1 + startX) / 2;
220
+ result.tickSeparators.push({ x1: edgeX, y1: axisLineY, x2: edgeX, y2: tickEndY, color: tsColor, width: tsWidth, dash: tsDash });
221
+ }
222
+ if (i < depthBoundaries.length - 1) {
223
+ const nextGb = depthBoundaries[i + 1];
224
+ const nextStartX = categoryScale(categories[nextGb.startIdx]) - 1;
225
+ const boundaryX = (endX + nextStartX) / 2;
226
+ result.tickSeparators.push({ x1: boundaryX, y1: axisLineY, x2: boundaryX, y2: tickEndY, color: tsColor, width: tsWidth, dash: tsDash });
227
+ } else {
228
+ result.tickSeparators.push({
229
+ x1: cartesianArea.x + cartesianArea.width,
230
+ y1: axisLineY,
231
+ x2: cartesianArea.x + cartesianArea.width,
232
+ y2: tickEndY,
233
+ color: tsColor,
234
+ width: tsWidth,
235
+ dash: tsDash
236
+ });
237
+ }
238
+ }
239
+ if (gb.bracket !== false) {
240
+ const bStyle = resolveStyle(gb.bracket ?? true, theme.bracketColor);
241
+ appendBracketShape(result, "bottom", bracketY, startX, endX, bStyle.color, bStyle.width, bStyle.dash);
242
+ }
243
+ result.labels.push({
244
+ x: midX,
245
+ y: bracketY + DEFAULT_BRACKET_LABEL_OFFSET,
246
+ text: displayLabel,
247
+ color: labelColor,
248
+ fontSize: labelFontSize,
249
+ fontWeight: labelFontWeight,
250
+ fontFamily: labelFontFamily,
251
+ textAnchor: "middle",
252
+ dominantBaseline: "hanging",
253
+ canvasTextAlign: "center",
254
+ canvasTextBaseline: "top",
255
+ render: gb.render,
256
+ categories: categories.slice(gb.startIdx, gb.endIdx + 1),
257
+ depth: gb.depth
258
+ });
259
+ }
260
+ }
261
+ }
262
+ return result;
263
+ }
264
+ function computeRangeBracketGeometry(boundaries, valueDomain, valueScaleRange, cartesianArea, valueAxisSpace, hasAxisTitle, orientation, theme) {
265
+ const result = { separators: [], tickSeparators: [], bracketLines: [], labels: [] };
266
+ if (boundaries.length === 0) return result;
267
+ const valueScale = createLinearScale(valueDomain, valueScaleRange);
268
+ const valueTickSpace = hasAxisTitle ? valueAxisSpace - DEFAULT_BRACKET_AXIS_TITLE_SPACE : valueAxisSpace;
269
+ for (let i = 0; i < boundaries.length; i++) {
270
+ const rb = boundaries[i];
271
+ const displayLabel = rb.label;
272
+ const labelColor = rb.labelStyle?.color ?? theme.groupLabelColor;
273
+ const labelFontSize = rb.labelStyle?.fontSize ?? theme.defaultFontSize;
274
+ const labelFontWeight = rb.labelStyle?.fontWeight ?? theme.defaultFontWeight;
275
+ const labelFontFamily = rb.labelStyle?.fontFamily ?? theme.defaultFontFamily;
276
+ if (orientation === "vertical") {
277
+ const topY = valueScale(rb.to);
278
+ const botY = valueScale(rb.from);
279
+ const midY = (topY + botY) / 2;
280
+ const bracketX = cartesianArea.x - valueTickSpace - DEFAULT_BRACKET_GAP;
281
+ if (rb.separator && i < boundaries.length - 1) {
282
+ const nextRb = boundaries[i + 1];
283
+ const sepY = (valueScale(rb.to) + valueScale(nextRb.from)) / 2;
284
+ const s = resolveStyle(rb.separator, theme.bracketColor);
285
+ result.separators.push({ x1: cartesianArea.x, y1: sepY, x2: cartesianArea.x + cartesianArea.width, y2: sepY, color: s.color, width: s.width, dash: s.dash });
286
+ }
287
+ if (rb.tickSeparator) {
288
+ const ts = resolveStyle(rb.tickSeparator, theme.bracketColor);
289
+ const axisLineX = cartesianArea.x;
290
+ const tickEndX = axisLineX - valueAxisSpace;
291
+ if (i === 0 || !boundaries[i - 1].tickSeparator) {
292
+ result.tickSeparators.push({ x1: tickEndX, y1: topY, x2: axisLineX, y2: topY, color: ts.color, width: ts.width, dash: ts.dash });
293
+ }
294
+ if (i < boundaries.length - 1) {
295
+ const nextRb = boundaries[i + 1];
296
+ const boundaryY = (valueScale(rb.to) + valueScale(nextRb.from)) / 2;
297
+ result.tickSeparators.push({ x1: tickEndX, y1: boundaryY, x2: axisLineX, y2: boundaryY, color: ts.color, width: ts.width, dash: ts.dash });
298
+ } else {
299
+ result.tickSeparators.push({ x1: tickEndX, y1: botY, x2: axisLineX, y2: botY, color: ts.color, width: ts.width, dash: ts.dash });
300
+ }
301
+ }
302
+ if (rb.bracket !== false) {
303
+ const bStyle = resolveStyle(rb.bracket ?? true, theme.bracketColor);
304
+ appendBracketShape(result, "left", bracketX, topY, botY, bStyle.color, bStyle.width, bStyle.dash);
305
+ }
306
+ result.labels.push({
307
+ x: bracketX - DEFAULT_BRACKET_LABEL_OFFSET,
308
+ y: midY,
309
+ text: displayLabel,
310
+ color: labelColor,
311
+ fontSize: labelFontSize,
312
+ fontWeight: labelFontWeight,
313
+ fontFamily: labelFontFamily,
314
+ textAnchor: "end",
315
+ dominantBaseline: "central",
316
+ canvasTextAlign: "right",
317
+ canvasTextBaseline: "middle"
318
+ });
319
+ } else {
320
+ const leftX = valueScale(rb.from);
321
+ const rightX = valueScale(rb.to);
322
+ const midX = (leftX + rightX) / 2;
323
+ const bracketY = cartesianArea.y + cartesianArea.height + valueTickSpace + DEFAULT_BRACKET_GAP;
324
+ if (rb.separator && i < boundaries.length - 1) {
325
+ const nextRb = boundaries[i + 1];
326
+ const sepX = (valueScale(rb.to) + valueScale(nextRb.from)) / 2;
327
+ const s = resolveStyle(rb.separator, theme.bracketColor);
328
+ result.separators.push({ x1: sepX, y1: cartesianArea.y, x2: sepX, y2: cartesianArea.y + cartesianArea.height, color: s.color, width: s.width, dash: s.dash });
329
+ }
330
+ if (rb.tickSeparator) {
331
+ const ts = resolveStyle(rb.tickSeparator, theme.bracketColor);
332
+ const axisLineY = cartesianArea.y + cartesianArea.height;
333
+ const tickEndY = axisLineY + valueAxisSpace;
334
+ if (i === 0 || !boundaries[i - 1].tickSeparator) {
335
+ result.tickSeparators.push({ x1: leftX, y1: axisLineY, x2: leftX, y2: tickEndY, color: ts.color, width: ts.width, dash: ts.dash });
336
+ }
337
+ if (i < boundaries.length - 1) {
338
+ const nextRb = boundaries[i + 1];
339
+ const boundaryX = (valueScale(rb.to) + valueScale(nextRb.from)) / 2;
340
+ result.tickSeparators.push({ x1: boundaryX, y1: axisLineY, x2: boundaryX, y2: tickEndY, color: ts.color, width: ts.width, dash: ts.dash });
341
+ } else {
342
+ result.tickSeparators.push({ x1: rightX, y1: axisLineY, x2: rightX, y2: tickEndY, color: ts.color, width: ts.width, dash: ts.dash });
343
+ }
344
+ }
345
+ if (rb.bracket !== false) {
346
+ const bStyle = resolveStyle(rb.bracket ?? true, theme.bracketColor);
347
+ appendBracketShape(result, "bottom", bracketY, leftX, rightX, bStyle.color, bStyle.width, bStyle.dash);
348
+ }
349
+ result.labels.push({
350
+ x: midX,
351
+ y: bracketY + DEFAULT_BRACKET_LABEL_OFFSET,
352
+ text: displayLabel,
353
+ color: labelColor,
354
+ fontSize: labelFontSize,
355
+ fontWeight: labelFontWeight,
356
+ fontFamily: labelFontFamily,
357
+ textAnchor: "middle",
358
+ dominantBaseline: "hanging",
359
+ canvasTextAlign: "center",
360
+ canvasTextBaseline: "top"
361
+ });
362
+ }
363
+ }
364
+ return result;
365
+ }
366
+ function renderBracketsSvg(geometry) {
367
+ const total = geometry.separators.length + geometry.tickSeparators.length + geometry.bracketLines.length + geometry.labels.length;
368
+ if (total === 0) return null;
369
+ const group = createSvgGroup();
370
+ for (const line of geometry.separators) appendLineSvg(group, line);
371
+ for (const line of geometry.tickSeparators) appendLineSvg(group, line);
372
+ for (const line of geometry.bracketLines) appendLineSvg(group, line);
373
+ for (const lbl of geometry.labels) {
374
+ if (lbl.render) continue;
375
+ appendChild(
376
+ group,
377
+ createSvgText(lbl.x, lbl.y, lbl.text, {
378
+ "text-anchor": lbl.textAnchor,
379
+ "dominant-baseline": lbl.dominantBaseline,
380
+ fill: lbl.color,
381
+ "font-size": lbl.fontSize,
382
+ "font-weight": lbl.fontWeight,
383
+ "font-family": lbl.fontFamily
384
+ })
385
+ );
386
+ }
387
+ return group;
388
+ }
389
+ function renderBracketsCanvas(ctx, geometry) {
390
+ const total = geometry.separators.length + geometry.tickSeparators.length + geometry.bracketLines.length + geometry.labels.length;
391
+ if (total === 0) return;
392
+ withCanvasState(ctx, () => {
393
+ for (const line of geometry.separators) strokeLine(ctx, line);
394
+ for (const line of geometry.tickSeparators) strokeLine(ctx, line);
395
+ for (const line of geometry.bracketLines) strokeLine(ctx, line);
396
+ for (const lbl of geometry.labels) {
397
+ if (lbl.render) {
398
+ withCanvasState(ctx, () => {
399
+ ctx.translate(lbl.x, lbl.y);
400
+ lbl.render({
401
+ label: lbl.text,
402
+ x: lbl.x,
403
+ y: lbl.y,
404
+ categories: lbl.categories ?? [],
405
+ depth: lbl.depth ?? 0,
406
+ ctx
407
+ });
408
+ });
409
+ } else {
410
+ ctx.font = `${lbl.fontWeight} ${lbl.fontSize}px ${lbl.fontFamily}`;
411
+ ctx.fillStyle = lbl.color;
412
+ ctx.textAlign = lbl.canvasTextAlign;
413
+ ctx.textBaseline = lbl.canvasTextBaseline;
414
+ ctx.fillText(lbl.text, lbl.x, lbl.y);
415
+ }
416
+ }
417
+ });
418
+ }
419
+
420
+ // src/renderers/overlay.ts
421
+ function renderCanvasOverlay(params) {
422
+ const { canvas, registry, clipArea, draw } = params;
423
+ const ctx = canvas.getContext("2d");
424
+ if (!ctx) return;
425
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
426
+ if (clipArea) {
427
+ ctx.save();
428
+ ctx.beginPath();
429
+ ctx.rect(clipArea.x, clipArea.y, clipArea.width, clipArea.height);
430
+ ctx.clip();
431
+ }
432
+ const createAnimate = (seriesId, itemIndex) => (config) => {
433
+ const id = `${seriesId}-${itemIndex}-${config.key}`;
434
+ if (!registry.has(id)) registry.register({ ...config, id });
435
+ return registry.getValue(id) ?? config.from;
436
+ };
437
+ draw(ctx, createAnimate);
438
+ if (clipArea) {
439
+ ctx.restore();
440
+ }
441
+ }
442
+
443
+ // src/renderers/cartesian.renderer.ts
444
+ var _globalClipId = 0;
445
+ var DEFAULT_BAND_PLACEMENT = "beforeData";
446
+ var DEFAULT_LINE_PLACEMENT = "afterData";
447
+ var bandPlacement = (b) => b.placement ?? DEFAULT_BAND_PLACEMENT;
448
+ var linePlacement = (l) => l.placement ?? DEFAULT_LINE_PLACEMENT;
449
+ function renderResolvedLabels(labels, config, options) {
450
+ const { renderer: rendererType, svgGroup, ctx, onImageLoad, theme } = options;
451
+ for (const lbl of labels) {
452
+ const itemFontSize = lbl.fontSize ?? config.fontSize;
453
+ const itemFill = lbl.textColor ?? config.color ?? theme.dataLabel;
454
+ if (config.render) {
455
+ const renderContext = {
456
+ index: lbl.dataIndex,
457
+ value: lbl.value,
458
+ percentage: lbl.percentage,
459
+ formattedText: lbl.text,
460
+ label: lbl.seriesName ?? lbl.category,
461
+ // Per-label color override wins; the series-level color is the fallback.
462
+ color: lbl.textColor ?? lbl.color,
463
+ x: lbl.x,
464
+ y: lbl.y
465
+ };
466
+ if (rendererType === "canvas" && ctx) {
467
+ withCanvasState(ctx, () => {
468
+ ctx.translate(lbl.x, lbl.y);
469
+ renderContext.ctx = ctx;
470
+ renderContext.drawImage = createDrawImage(ctx, onImageLoad ?? (() => {
471
+ }));
472
+ config.render(renderContext);
473
+ });
474
+ }
475
+ continue;
476
+ }
477
+ const { textAnchor, baseline } = config.rotation ? adjustLabelForRotation(config.rotation, lbl.textAnchor, lbl.baseline) : { textAnchor: lbl.textAnchor, baseline: lbl.baseline };
478
+ if (rendererType === "svg" && svgGroup) {
479
+ const svgBaseline = baseline === "hanging" ? "text-before-edge" : baseline === "auto" ? "alphabetic" : baseline;
480
+ const attrs = {
481
+ class: "p-chart-data-label",
482
+ "text-anchor": textAnchor,
483
+ "dominant-baseline": svgBaseline,
484
+ fill: itemFill,
485
+ "font-size": itemFontSize,
486
+ "font-weight": config.fontWeight,
487
+ "font-family": config.fontFamily
488
+ };
489
+ if (config.rotation) {
490
+ attrs.transform = `rotate(${config.rotation}, ${lbl.x}, ${lbl.y})`;
491
+ }
492
+ appendChild(svgGroup, createSvgText(lbl.x, lbl.y, lbl.text, attrs));
493
+ }
494
+ if (rendererType === "canvas" && ctx) {
495
+ const canvasAlign = textAnchor === "middle" ? "center" : textAnchor;
496
+ const canvasBaseline = baseline === "central" ? "middle" : baseline === "hanging" ? "top" : "alphabetic";
497
+ ctx.save();
498
+ ctx.font = `${config.fontWeight} ${itemFontSize}px ${config.fontFamily}`;
499
+ ctx.fillStyle = itemFill;
500
+ ctx.textAlign = canvasAlign;
501
+ ctx.textBaseline = canvasBaseline;
502
+ if (config.rotation) {
503
+ const rad = config.rotation * Math.PI / 180;
504
+ ctx.translate(lbl.x, lbl.y);
505
+ ctx.rotate(rad);
506
+ ctx.fillText(lbl.text, 0, 0);
507
+ } else {
508
+ ctx.fillText(lbl.text, lbl.x, lbl.y);
509
+ }
510
+ ctx.restore();
511
+ }
512
+ }
513
+ }
514
+ function addNode(parent, node) {
515
+ if (node) appendChild(parent, node);
516
+ }
517
+ function replaceGroupContent(live, virtual) {
518
+ while (live.firstChild) live.removeChild(live.firstChild);
519
+ const materialized = materializeSvgGroup(virtual);
520
+ while (materialized.firstChild) live.appendChild(materialized.firstChild);
521
+ }
522
+ function renderCartesianFrame(params) {
523
+ const {
524
+ renderer,
525
+ theme,
526
+ group,
527
+ canvas,
528
+ orientation,
529
+ styledBoundaries,
530
+ categoryScale,
531
+ cartesianArea,
532
+ categoryAxisSpace = 0,
533
+ styledRangeBoundaries,
534
+ valueAxisSpace = 0,
535
+ valueDomain,
536
+ valueScaleRange,
537
+ axisLayouts,
538
+ phase = "all",
539
+ rtl,
540
+ globalFont
541
+ } = params;
542
+ const clipBase = _globalClipId += 100;
543
+ let _clipId = clipBase;
544
+ const yAxisIndexMap = /* @__PURE__ */ new Map();
545
+ let _yAxisIdx = 0;
546
+ for (const [axisKey, info] of axisLayouts) {
547
+ if (info.axis === "y") yAxisIndexMap.set(axisKey, _yAxisIdx++);
548
+ }
549
+ const gridAxisKeys = /* @__PURE__ */ new Set();
550
+ for (const dir of ["x", "y"]) {
551
+ const axesForDir = [...axisLayouts.entries()].filter(([, info]) => info.axis === dir);
552
+ const primary = axesForDir.find(([, info]) => info.isPrimary && !info.isHidden);
553
+ const fallback = primary ? null : axesForDir.find(([, info]) => !info.isHidden);
554
+ const winner = primary ?? fallback;
555
+ if (winner) gridAxisKeys.add(winner[0]);
556
+ }
557
+ if (renderer === "svg") {
558
+ const svgGridGroup = params.gridGroup ?? null;
559
+ const bracketTheme2 = {
560
+ bracketColor: resolveAxisColor(theme, 0),
561
+ groupLabelColor: theme.tickLabel,
562
+ defaultFontSize: resolveFontSize(DEFAULT_GROUP_LABEL_FONT_SIZE, globalFont),
563
+ defaultFontWeight: DEFAULT_GROUP_LABEL_FONT_WEIGHT,
564
+ defaultFontFamily: resolveFontFamily(void 0, globalFont)
565
+ };
566
+ const gridRoot = svgNode("g");
567
+ const mainRoot = svgNode("g");
568
+ if (cartesianArea) {
569
+ const gridClipId = `grid-clip-${++_clipId}`;
570
+ const clippedGrid = svgNode("g", { "clip-path": `url(#${gridClipId})` });
571
+ for (const [axisKey, axisInfo] of axisLayouts) {
572
+ if (gridAxisKeys.has(axisKey) && axisInfo.layout.gridLines.length > 0) {
573
+ appendChild(clippedGrid, renderAxisSvg(axisInfo.layout, theme, { gridOnly: true, rtl }, yAxisIndexMap.get(axisKey) ?? 0));
574
+ }
575
+ }
576
+ appendChild(gridRoot, svgNode("clipPath", { id: gridClipId }, [createSvgRect(cartesianArea.x - 1, cartesianArea.y - 1, cartesianArea.width + 2, cartesianArea.height + 2)]));
577
+ appendChild(gridRoot, clippedGrid);
578
+ } else {
579
+ for (const [axisKey, axisInfo] of axisLayouts) {
580
+ if (gridAxisKeys.has(axisKey) && axisInfo.layout.gridLines.length > 0) {
581
+ appendChild(gridRoot, renderAxisSvg(axisInfo.layout, theme, { gridOnly: true, rtl }, yAxisIndexMap.get(axisKey) ?? 0));
582
+ }
583
+ }
584
+ }
585
+ if (styledBoundaries && styledBoundaries.length > 0 && categoryScale && cartesianArea) {
586
+ addNode(gridRoot, renderFillsSvg(computeCategoryFills(styledBoundaries, categoryScale, cartesianArea, orientation)));
587
+ }
588
+ if (styledRangeBoundaries && styledRangeBoundaries.length > 0 && cartesianArea && valueDomain && valueScaleRange) {
589
+ addNode(gridRoot, renderFillsSvg(computeRangeFills(styledRangeBoundaries, valueDomain, valueScaleRange, cartesianArea, orientation)));
590
+ }
591
+ if (cartesianArea) {
592
+ const beforeRefClipId = `before-ref-clip-${++_clipId}`;
593
+ const beforeRefGroup = svgNode("g");
594
+ if (params.referenceBands && params.referenceBands.length > 0) {
595
+ const beforeBands = params.referenceBands.filter((b) => bandPlacement(b) === "beforeData" && !b.render);
596
+ if (beforeBands.length > 0) {
597
+ addNode(beforeRefGroup, renderReferenceBandsSvg(computeReferenceBands(beforeBands, axisLayouts, cartesianArea, categoryScale ?? null, orientation), globalFont));
598
+ }
599
+ }
600
+ if (params.referenceLines && params.referenceLines.length > 0) {
601
+ const beforeLines = params.referenceLines.filter((l) => linePlacement(l) === "beforeData" && !l.render);
602
+ if (beforeLines.length > 0) {
603
+ addNode(beforeRefGroup, renderReferenceLinesSvg(computeReferenceLines(beforeLines, axisLayouts, cartesianArea, categoryScale ?? null, orientation), globalFont));
604
+ }
605
+ }
606
+ appendChild(gridRoot, svgNode("clipPath", { id: beforeRefClipId }, [createSvgRect(cartesianArea.x, cartesianArea.y, cartesianArea.width, cartesianArea.height)]));
607
+ appendChild(gridRoot, svgNode("g", { "clip-path": `url(#${beforeRefClipId})` }, beforeRefGroup.children));
608
+ }
609
+ let refClipId = "";
610
+ const afterDataRoot = cartesianArea ? svgNode("g") : mainRoot;
611
+ if (cartesianArea) {
612
+ refClipId = `ref-clip-${++_clipId}`;
613
+ appendChild(mainRoot, svgNode("clipPath", { id: refClipId }, [createSvgRect(cartesianArea.x, cartesianArea.y, cartesianArea.width, cartesianArea.height)]));
614
+ }
615
+ if (cartesianArea) {
616
+ if (params.referenceBands && params.referenceBands.length > 0) {
617
+ const afterBands = params.referenceBands.filter((b) => bandPlacement(b) === "afterData" && !b.render);
618
+ if (afterBands.length > 0) {
619
+ addNode(afterDataRoot, renderReferenceBandsSvg(computeReferenceBands(afterBands, axisLayouts, cartesianArea, categoryScale ?? null, orientation), globalFont));
620
+ }
621
+ }
622
+ if (params.referenceLines && params.referenceLines.length > 0) {
623
+ const afterLines = params.referenceLines.filter((l) => linePlacement(l) === "afterData" && !l.render);
624
+ if (afterLines.length > 0) {
625
+ addNode(afterDataRoot, renderReferenceLinesSvg(computeReferenceLines(afterLines, axisLayouts, cartesianArea, categoryScale ?? null, orientation), globalFont));
626
+ }
627
+ }
628
+ }
629
+ if (refClipId && afterDataRoot !== mainRoot) {
630
+ appendChild(mainRoot, svgNode("g", { "clip-path": `url(#${refClipId})` }, afterDataRoot.children));
631
+ }
632
+ for (const [axisKey, axisInfo] of axisLayouts) {
633
+ const ap = axisInfo.props;
634
+ if (ap.visible === false) continue;
635
+ appendChild(mainRoot, renderAxisSvg(axisInfo.layout, theme, { skipGrid: true, skipLabels: !!ap.render, skipAxisLine: ap.showLine === false, skipTicks: ap.showTicks === false, rtl }, yAxisIndexMap.get(axisKey) ?? 0));
636
+ }
637
+ if (styledBoundaries && styledBoundaries.length > 0 && categoryScale && cartesianArea) {
638
+ addNode(mainRoot, renderBracketsSvg(computeCategoryBracketGeometry(styledBoundaries, categoryScale, cartesianArea, categoryAxisSpace, orientation, bracketTheme2)));
639
+ }
640
+ if (styledRangeBoundaries && styledRangeBoundaries.length > 0 && cartesianArea && valueDomain && valueScaleRange) {
641
+ const primaryValAxisId = orientation === "vertical" ? "y" : "x";
642
+ const primaryValAxis = [...axisLayouts.values()].find((a) => a.axis === primaryValAxisId && a.isPrimary);
643
+ const hasAxisTitle = !!primaryValAxis?.props?.label;
644
+ addNode(mainRoot, renderBracketsSvg(computeRangeBracketGeometry(styledRangeBoundaries, valueDomain, valueScaleRange, cartesianArea, valueAxisSpace, hasAxisTitle, orientation, bracketTheme2)));
645
+ }
646
+ if (svgGridGroup && svgGridGroup !== group) {
647
+ replaceGroupContent(svgGridGroup, gridRoot);
648
+ if (group) replaceGroupContent(group, mainRoot);
649
+ } else if (group) {
650
+ while (group.firstChild) group.removeChild(group.firstChild);
651
+ const gridMat = materializeSvgGroup(gridRoot);
652
+ const mainMat = materializeSvgGroup(mainRoot);
653
+ while (gridMat.firstChild) group.appendChild(gridMat.firstChild);
654
+ while (mainMat.firstChild) group.appendChild(mainMat.firstChild);
655
+ }
656
+ if (params.customTickOverlayRefs) {
657
+ for (const [axisKey, axisInfo] of axisLayouts) {
658
+ const ap = axisInfo.props;
659
+ const opacity = String(axisInfo.layout.opacity ?? 1);
660
+ if (ap.render) {
661
+ params.customTickOverlayRefs.get(axisKey)?.setAttribute("opacity", opacity);
662
+ }
663
+ if (ap.renderTick) {
664
+ params.customTickOverlayRefs.get(`${axisKey}-tick`)?.setAttribute("opacity", opacity);
665
+ }
666
+ }
667
+ }
668
+ return;
669
+ }
670
+ const ctx = canvas?.getContext("2d") ?? null;
671
+ const paintBg = phase === "all" || phase === "background";
672
+ const paintFg = phase === "all" || phase === "foreground";
673
+ const bracketTheme = {
674
+ bracketColor: resolveAxisColor(theme, 0),
675
+ groupLabelColor: theme.tickLabel,
676
+ defaultFontSize: resolveFontSize(DEFAULT_GROUP_LABEL_FONT_SIZE, globalFont),
677
+ defaultFontWeight: DEFAULT_GROUP_LABEL_FONT_WEIGHT,
678
+ defaultFontFamily: resolveFontFamily(void 0, globalFont)
679
+ };
680
+ if (paintBg) {
681
+ if (ctx && canvas && phase === "all") {
682
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
683
+ }
684
+ if (ctx) {
685
+ for (const [axisKey, axisInfo] of axisLayouts) {
686
+ if (gridAxisKeys.has(axisKey) && axisInfo.layout.gridLines.length > 0) {
687
+ renderAxisCanvas(ctx, axisInfo.layout, { gridOnly: true, rtl }, theme, yAxisIndexMap.get(axisKey) ?? 0);
688
+ }
689
+ }
690
+ }
691
+ if (styledBoundaries && styledBoundaries.length > 0 && categoryScale && cartesianArea && ctx) {
692
+ renderFillsCanvas(ctx, computeCategoryFills(styledBoundaries, categoryScale, cartesianArea, orientation));
693
+ }
694
+ if (styledRangeBoundaries && styledRangeBoundaries.length > 0 && cartesianArea && valueDomain && valueScaleRange && ctx) {
695
+ renderFillsCanvas(ctx, computeRangeFills(styledRangeBoundaries, valueDomain, valueScaleRange, cartesianArea, orientation));
696
+ }
697
+ if (cartesianArea && ctx) {
698
+ ctx.save();
699
+ ctx.beginPath();
700
+ ctx.rect(cartesianArea.x, cartesianArea.y, cartesianArea.width, cartesianArea.height);
701
+ ctx.clip();
702
+ if (params.referenceBands && params.referenceBands.length > 0) {
703
+ const beforeBands = params.referenceBands.filter((b) => bandPlacement(b) === "beforeData");
704
+ const defaultBeforeBands = beforeBands.filter((b) => !b.render);
705
+ if (defaultBeforeBands.length > 0) {
706
+ renderReferenceBandsCanvas(ctx, computeReferenceBands(defaultBeforeBands, axisLayouts, cartesianArea, categoryScale ?? null, orientation), globalFont, theme);
707
+ }
708
+ for (let i = 0; i < beforeBands.length; i++) {
709
+ if (beforeBands[i].render) {
710
+ const geometries = computeReferenceBands([beforeBands[i]], axisLayouts, cartesianArea, categoryScale ?? null, orientation);
711
+ ctx.save();
712
+ beforeBands[i].render({ ...geometries[0], ctx });
713
+ ctx.restore();
714
+ }
715
+ }
716
+ }
717
+ if (params.referenceLines && params.referenceLines.length > 0) {
718
+ const beforeLines = params.referenceLines.filter((l) => linePlacement(l) === "beforeData");
719
+ const defaultBeforeLines = beforeLines.filter((l) => !l.render);
720
+ if (defaultBeforeLines.length > 0) {
721
+ renderReferenceLinesCanvas(ctx, computeReferenceLines(defaultBeforeLines, axisLayouts, cartesianArea, categoryScale ?? null, orientation), globalFont, theme);
722
+ }
723
+ for (let i = 0; i < beforeLines.length; i++) {
724
+ if (beforeLines[i].render) {
725
+ const geometries = computeReferenceLines([beforeLines[i]], axisLayouts, cartesianArea, categoryScale ?? null, orientation);
726
+ ctx.save();
727
+ beforeLines[i].render({ ...geometries[0], ctx });
728
+ ctx.restore();
729
+ }
730
+ }
731
+ }
732
+ ctx.restore();
733
+ }
734
+ if (cartesianArea && ctx) {
735
+ ctx.save();
736
+ ctx.beginPath();
737
+ ctx.rect(cartesianArea.x, cartesianArea.y, cartesianArea.width, cartesianArea.height);
738
+ ctx.clip();
739
+ }
740
+ }
741
+ if (paintFg) {
742
+ if (cartesianArea && ctx) {
743
+ ctx.save();
744
+ ctx.beginPath();
745
+ ctx.rect(cartesianArea.x, cartesianArea.y, cartesianArea.width, cartesianArea.height);
746
+ ctx.clip();
747
+ if (params.referenceBands && params.referenceBands.length > 0) {
748
+ const afterBands = params.referenceBands.filter((b) => bandPlacement(b) === "afterData");
749
+ const defaultAfterBands = afterBands.filter((b) => !b.render);
750
+ if (defaultAfterBands.length > 0) {
751
+ renderReferenceBandsCanvas(ctx, computeReferenceBands(defaultAfterBands, axisLayouts, cartesianArea, categoryScale ?? null, orientation), globalFont, theme);
752
+ }
753
+ for (let i = 0; i < afterBands.length; i++) {
754
+ if (afterBands[i].render) {
755
+ const geometries = computeReferenceBands([afterBands[i]], axisLayouts, cartesianArea, categoryScale ?? null, orientation);
756
+ ctx.save();
757
+ afterBands[i].render({ ...geometries[0], ctx });
758
+ ctx.restore();
759
+ }
760
+ }
761
+ }
762
+ if (params.referenceLines && params.referenceLines.length > 0) {
763
+ const afterLines = params.referenceLines.filter((l) => linePlacement(l) === "afterData");
764
+ const defaultAfterLines = afterLines.filter((l) => !l.render);
765
+ if (defaultAfterLines.length > 0) {
766
+ renderReferenceLinesCanvas(ctx, computeReferenceLines(defaultAfterLines, axisLayouts, cartesianArea, categoryScale ?? null, orientation), globalFont, theme);
767
+ }
768
+ for (let i = 0; i < afterLines.length; i++) {
769
+ if (afterLines[i].render) {
770
+ const geometries = computeReferenceLines([afterLines[i]], axisLayouts, cartesianArea, categoryScale ?? null, orientation);
771
+ ctx.save();
772
+ afterLines[i].render({ ...geometries[0], ctx });
773
+ ctx.restore();
774
+ }
775
+ }
776
+ }
777
+ ctx.restore();
778
+ }
779
+ if (cartesianArea && ctx) ctx.restore();
780
+ if (ctx) {
781
+ for (const [axisKey, axisInfo] of axisLayouts) {
782
+ const ap = axisInfo.props;
783
+ if (ap.visible === false) continue;
784
+ renderAxisCanvas(ctx, axisInfo.layout, { skipGrid: true, skipLabels: !!ap.render, skipAxisLine: ap.showLine === false, skipTicks: ap.showTicks === false, rtl }, theme, yAxisIndexMap.get(axisKey) ?? 0);
785
+ }
786
+ }
787
+ if (styledBoundaries && styledBoundaries.length > 0 && categoryScale && cartesianArea && ctx) {
788
+ renderBracketsCanvas(ctx, computeCategoryBracketGeometry(styledBoundaries, categoryScale, cartesianArea, categoryAxisSpace, orientation, bracketTheme));
789
+ }
790
+ if (styledRangeBoundaries && styledRangeBoundaries.length > 0 && cartesianArea && valueDomain && valueScaleRange && ctx) {
791
+ const primaryValAxisId = orientation === "vertical" ? "y" : "x";
792
+ const primaryValAxis = [...axisLayouts.values()].find((a) => a.axis === primaryValAxisId && a.isPrimary);
793
+ const hasAxisTitle = !!primaryValAxis?.props?.label;
794
+ renderBracketsCanvas(ctx, computeRangeBracketGeometry(styledRangeBoundaries, valueDomain, valueScaleRange, cartesianArea, valueAxisSpace, hasAxisTitle, orientation, bracketTheme));
795
+ }
796
+ }
797
+ }
798
+ function renderCartesianOverlay(params) {
799
+ const { canvas, axisLayouts, hover, registry, cartesianArea, onImageLoad, markerOverlays } = params;
800
+ renderCanvasOverlay({
801
+ canvas,
802
+ registry,
803
+ clipArea: cartesianArea,
804
+ draw: (ctx, createAnimate) => {
805
+ if (markerOverlays) {
806
+ renderCustomMarkersCanvas(ctx, markerOverlays, hover, {
807
+ createAnimate,
808
+ onImageLoad
809
+ });
810
+ }
811
+ if (cartesianArea) ctx.restore();
812
+ drawAxisOverlay(ctx, createAnimate, axisLayouts, onImageLoad);
813
+ if (cartesianArea) {
814
+ ctx.save();
815
+ ctx.beginPath();
816
+ ctx.rect(cartesianArea.x, cartesianArea.y, cartesianArea.width, cartesianArea.height);
817
+ ctx.clip();
818
+ }
819
+ }
820
+ });
821
+ }
822
+ function drawAxisOverlay(ctx, createAnimate, axisLayouts, onImageLoad) {
823
+ if (!axisLayouts) return;
824
+ for (const [axisKey, axisInfo] of axisLayouts) {
825
+ const renderFn = axisInfo.props.render;
826
+ if (renderFn) {
827
+ const effectiveOpacity = axisInfo.layout.opacity ?? 1;
828
+ if (effectiveOpacity > 0.01) {
829
+ ctx.save();
830
+ ctx.globalAlpha *= effectiveOpacity;
831
+ for (const tick of axisInfo.layout.ticks) {
832
+ const animate = createAnimate(`${axisKey}-label`, tick.tickIndex);
833
+ withCanvasState(ctx, () => {
834
+ ctx.translate(tick.labelX, tick.labelY);
835
+ if (tick.rotation) {
836
+ ctx.rotate(tick.rotation * Math.PI / 180);
837
+ }
838
+ renderFn({
839
+ value: tick.value,
840
+ label: tick.label,
841
+ index: tick.tickIndex,
842
+ position: axisInfo.layout.position,
843
+ x: tick.labelX,
844
+ y: tick.labelY,
845
+ ctx,
846
+ drawImage: createDrawImage(ctx, onImageLoad ?? (() => {
847
+ })),
848
+ animate
849
+ });
850
+ });
851
+ }
852
+ ctx.restore();
853
+ }
854
+ }
855
+ const renderTickFn = axisInfo.props.renderTick;
856
+ if (renderTickFn) {
857
+ const effectiveOpacity = axisInfo.layout.opacity ?? 1;
858
+ if (effectiveOpacity > 0.01) {
859
+ ctx.save();
860
+ ctx.globalAlpha *= effectiveOpacity;
861
+ for (const tick of axisInfo.layout.ticks) {
862
+ const animate = createAnimate(`${axisKey}-tick`, tick.tickIndex);
863
+ withCanvasState(ctx, () => {
864
+ ctx.translate(tick.x1, tick.y1);
865
+ renderTickFn({
866
+ value: tick.value,
867
+ label: tick.label,
868
+ index: tick.tickIndex,
869
+ position: axisInfo.layout.position,
870
+ x: tick.x1,
871
+ y: tick.y1,
872
+ ctx,
873
+ drawImage: createDrawImage(ctx, onImageLoad ?? (() => {
874
+ })),
875
+ animate
876
+ });
877
+ });
878
+ }
879
+ ctx.restore();
880
+ }
881
+ }
882
+ }
883
+ }
884
+
885
+ export { computeCategoryBracketGeometry, computeCategoryFills, computeRangeBracketGeometry, computeRangeFills, renderBracketsCanvas, renderBracketsSvg, renderCanvasOverlay, renderCartesianFrame, renderCartesianOverlay, renderFillsCanvas, renderFillsSvg, renderResolvedLabels };