@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,499 @@
1
+ import { hexToRgba, createSvgRadialGradient, createSvgLinearGradient, createCanvasRadialGradient, createCanvasLinearGradient, parseColorToRGB } from './chunk-SSLTFJ3U.mjs';
2
+
3
+ // src/utils/color/gradient.ts
4
+ function isGradientColor(color) {
5
+ return color != null && typeof color === "object" && "stops" in color;
6
+ }
7
+ function getPrimaryColor(color) {
8
+ if (isGradientColor(color)) {
9
+ return color.stops[0]?.color ?? "#808080";
10
+ }
11
+ return color;
12
+ }
13
+ function asGradient(color) {
14
+ return color != null && isGradientColor(color) ? color : void 0;
15
+ }
16
+ function gradientToCssBackground(gradient) {
17
+ const stops = resolveSwatchGradientStops(gradient);
18
+ if (stops.length === 0) return "transparent";
19
+ const stopList = stops.map((s) => `${s.color} ${Math.round(s.offset * 100)}%`).join(", ");
20
+ return gradient.radialGradient ? `radial-gradient(circle, ${stopList})` : `linear-gradient(to bottom, ${stopList})`;
21
+ }
22
+ function resolveSwatchGradientStops(gradient) {
23
+ return (gradient.stops ?? []).map((s) => ({
24
+ offset: s.offset,
25
+ color: s.opacity != null && s.color.startsWith("#") ? hexToRgba(s.color, s.opacity) : s.color
26
+ }));
27
+ }
28
+ function remapStopsForDonut(stops, innerRatio) {
29
+ const range = 1 - innerRatio;
30
+ if (range <= 0) return stops;
31
+ return stops.map((s) => ({
32
+ ...s,
33
+ offset: innerRatio + s.offset * range
34
+ }));
35
+ }
36
+ function normalizeGradient(color, center, radius, chartArea, defaultDirection) {
37
+ const stops = color.stops.map((s) => ({
38
+ offset: s.offset,
39
+ color: s.color,
40
+ opacity: s.opacity
41
+ }));
42
+ if (color.radialGradient) {
43
+ const r = (color.radialGradient.r ?? 1) * radius;
44
+ return {
45
+ type: "radial",
46
+ stops,
47
+ coords: {
48
+ x1: center.x,
49
+ y1: center.y,
50
+ x2: center.x,
51
+ y2: center.y,
52
+ r1: 0,
53
+ r2: r
54
+ }
55
+ };
56
+ }
57
+ const lg = color.linearGradient;
58
+ if (lg && lg.x1 !== void 0 && lg.y1 !== void 0 && lg.x2 !== void 0 && lg.y2 !== void 0) {
59
+ const area = chartArea ?? { x: center.x - radius, y: center.y - radius, width: radius * 2, height: radius * 2 };
60
+ return {
61
+ type: "linear",
62
+ stops,
63
+ coords: {
64
+ x1: area.x + lg.x1 * area.width,
65
+ y1: area.y + lg.y1 * area.height,
66
+ x2: area.x + lg.x2 * area.width,
67
+ y2: area.y + lg.y2 * area.height
68
+ }
69
+ };
70
+ }
71
+ const direction = lg?.direction ?? defaultDirection ?? "vertical";
72
+ if (direction === "horizontal") {
73
+ const area = chartArea ?? { x: center.x - radius, y: center.y, width: radius * 2};
74
+ return {
75
+ type: "linear",
76
+ stops,
77
+ coords: {
78
+ x1: area.x,
79
+ y1: center.y,
80
+ x2: area.x + area.width,
81
+ y2: center.y
82
+ }
83
+ };
84
+ }
85
+ const vArea = chartArea ?? { x: center.x, y: center.y - radius, height: radius * 2 };
86
+ return {
87
+ type: "linear",
88
+ stops,
89
+ coords: {
90
+ x1: center.x,
91
+ y1: vArea.y,
92
+ x2: center.x,
93
+ y2: vArea.y + vArea.height
94
+ }
95
+ };
96
+ }
97
+ function createSvgGradientFromColor(color, id, center, radius, chartArea, defaultDirection) {
98
+ const normalized = normalizeGradient(color, center, radius, chartArea, defaultDirection);
99
+ if (normalized.type === "radial") {
100
+ return createSvgRadialGradient(id, normalized.coords.x1, normalized.coords.y1, normalized.coords.r2, normalized.stops, { useAbsoluteCoords: true });
101
+ }
102
+ return createSvgLinearGradient(id, normalized.coords.x1, normalized.coords.y1, normalized.coords.x2, normalized.coords.y2, normalized.stops, { useAbsoluteCoords: true });
103
+ }
104
+ function createCanvasGradientFromColor(ctx, color, center, radius, chartArea, defaultDirection) {
105
+ const normalized = normalizeGradient(color, center, radius, chartArea, defaultDirection);
106
+ if (normalized.type === "radial") {
107
+ return createCanvasRadialGradient(ctx, normalized.coords.x1, normalized.coords.y1, normalized.coords.r1, normalized.coords.r2, normalized.stops);
108
+ }
109
+ return createCanvasLinearGradient(ctx, normalized.coords.x1, normalized.coords.y1, normalized.coords.x2, normalized.coords.y2, normalized.stops);
110
+ }
111
+ function sampleGradientAt(color, point, center, radius, chartArea, defaultDirection) {
112
+ const normalized = normalizeGradient(color, center, radius, chartArea, defaultDirection);
113
+ const stops = normalized.stops;
114
+ if (stops.length === 0) return "#000";
115
+ if (stops.length === 1) return stops[0].color;
116
+ let t;
117
+ if (normalized.type === "radial") {
118
+ const { x1, y1, r2 } = normalized.coords;
119
+ const dist = Math.hypot(point.x - x1, point.y - y1);
120
+ t = !r2 ? 0 : dist / r2;
121
+ } else {
122
+ const { x1, y1, x2, y2 } = normalized.coords;
123
+ const dx = x2 - x1;
124
+ const dy = y2 - y1;
125
+ const len2 = dx * dx + dy * dy;
126
+ t = len2 === 0 ? 0 : ((point.x - x1) * dx + (point.y - y1) * dy) / len2;
127
+ }
128
+ t = Math.max(0, Math.min(1, t));
129
+ const sorted = stops.slice().sort((a, b) => a.offset - b.offset);
130
+ if (t <= sorted[0].offset) return sorted[0].color;
131
+ if (t >= sorted[sorted.length - 1].offset) return sorted[sorted.length - 1].color;
132
+ for (let i = 0; i < sorted.length - 1; i++) {
133
+ const a = sorted[i];
134
+ const b = sorted[i + 1];
135
+ if (t >= a.offset && t <= b.offset) {
136
+ const span = b.offset - a.offset;
137
+ const localT = span === 0 ? 0 : (t - a.offset) / span;
138
+ const rgbA = parseColorToRGB(a.color);
139
+ const rgbB = parseColorToRGB(b.color);
140
+ if (!rgbA || !rgbB) return a.color;
141
+ const r = Math.round(rgbA.r + (rgbB.r - rgbA.r) * localT);
142
+ const g = Math.round(rgbA.g + (rgbB.g - rgbA.g) * localT);
143
+ const bl = Math.round(rgbA.b + (rgbB.b - rgbA.b) * localT);
144
+ return `rgb(${r},${g},${bl})`;
145
+ }
146
+ }
147
+ return sorted[sorted.length - 1].color;
148
+ }
149
+
150
+ // src/themes/default.ts
151
+ var defaultLightTheme = {
152
+ // Series — 10-hue Studio palette, hand-tuned for white backgrounds.
153
+ series: [
154
+ "#3563e9",
155
+ // cobalt
156
+ "#e8722d",
157
+ // persimmon
158
+ "#1fbe8b",
159
+ // jade
160
+ "#dc2f4f",
161
+ // crimson
162
+ "#6852d9",
163
+ // lavender
164
+ "#1dafd9",
165
+ // cerulean
166
+ "#d63384",
167
+ // magenta
168
+ "#88b83f",
169
+ // olive
170
+ "#a855cc",
171
+ // plum
172
+ "#d9a422"
173
+ // saffron
174
+ ],
175
+ // Chrome — drives axes, grid, labels, title, caption.
176
+ // All 4 axis slots default to the same neutral; override individual entries for multi-axis charts.
177
+ axes: ["#666666", "#666666", "#666666", "#666666"],
178
+ grid: "#e2e8f0",
179
+ gridMinor: "#cbd5e1",
180
+ tickLabel: "#666666",
181
+ dataLabel: "#334155",
182
+ dataLabelBackground: "#00000000",
183
+ // transparent by default
184
+ dataLabelBorder: "#00000000",
185
+ annotation: "#334155",
186
+ annotationBackground: "#00000000",
187
+ // transparent by default
188
+ annotationBorder: "#00000000",
189
+ titleColor: "#0f172a",
190
+ captionColor: "#64748b",
191
+ bandFill: "#f1f5f9",
192
+ // Direction signals — independent of series ramp so candlestick charts
193
+ // don't collide with series-colored overlays.
194
+ positive: "#1eb854",
195
+ negative: "#dc2828",
196
+ candleNeutral: "#6b7280",
197
+ // Effect coefficients — mirror state class CSS defaults.
198
+ hoverBrightness: 1.1,
199
+ dimOpacity: 0.6,
200
+ barStrokeWidth: 0,
201
+ // Tick halo — opposite-luma from text fill so labels pop against
202
+ // series-colored backgrounds. `#ffffffd9` = rgba(255,255,255,0.85).
203
+ tickHalo: "#ffffffd9",
204
+ // Heatmap defaults — mirror `--p-chart-heat-min/max/empty/null`.
205
+ heatColorMin: "#fde68a",
206
+ heatColorMax: "#ee1c1c",
207
+ heatEmpty: "#e5e7eb",
208
+ heatNull: "#f3f4f6",
209
+ // Tooltip — semi-transparent surface with subtle border. `f2` ≈ 0.95 alpha,
210
+ // `1a` ≈ 0.10 alpha. Hex w/ alpha keeps parity-test regex simple.
211
+ tooltipBackground: "#ffffffd9",
212
+ tooltipBorder: "#0000001a",
213
+ tooltipColor: "#374151",
214
+ tooltipRadius: "8px",
215
+ tooltipBlur: "12px",
216
+ tooltipShadow: "0 8px 24px #0000001f",
217
+ tooltipPadding: "10px 14px",
218
+ legendColor: "#374151",
219
+ legendBackground: "#00000000",
220
+ // transparent by default
221
+ legendBorder: "#00000000",
222
+ // Reference lines/bands — neutral-40 stroke, 10% opacity fill.
223
+ referenceLineColor: "#94a3b8",
224
+ referenceBandFill: "#0000001a",
225
+ // rgba(0,0,0,0.10)
226
+ // Navigator chrome — series line/area, dim mask outside the selection window,
227
+ // and the selection border + interior. Hex-with-alpha keeps the parity-test regex
228
+ // happy: `#3b82f6b3` ≈ rgba(59,130,246,0.70), `#3b82f614` ≈ rgba(59,130,246,0.08),
229
+ // `#0000001f` ≈ rgba(0,0,0,0.12).
230
+ navigatorSeries: "#94a3b8",
231
+ navigatorMask: "#0000001f",
232
+ navigatorSelectionColor: "#3b82f6b3",
233
+ navigatorSelectionFill: "#3b82f614",
234
+ // Treemap defaults — mirror existing `--p-chart-treemap-*` vars.
235
+ treemapCell: "#3563e9",
236
+ treemapCellBorder: "#00000026",
237
+ // rgba(0,0,0,0.15)
238
+ treemapHeaderBg: "#ffffffe6",
239
+ // near-white header band in light mode
240
+ treemapHeaderText: "#1f2937",
241
+ // dark slate text on the light band
242
+ // Generic fallback border (final fallback in pie/bar canvas paths).
243
+ borderColor: "#000000",
244
+ // Crosshair line color — falls back to axes[0] by default.
245
+ crosshairColor: "#666666",
246
+ // Base typography — chart-level `fontFamily`/`fontSize` props still win.
247
+ fontFamily: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',
248
+ fontSize: 12
249
+ };
250
+ var defaultDarkTheme = {
251
+ series: ["#5790ff", "#ff8838", "#14e5a4", "#ff4d6d", "#8270ff", "#33cdff", "#ff4da0", "#b8e92f", "#c766ff", "#ffc633"],
252
+ axes: ["#a1a1aa", "#a1a1aa", "#a1a1aa", "#a1a1aa"],
253
+ grid: "#3f3f46",
254
+ gridMinor: "#52525b",
255
+ tickLabel: "#a1a1aa",
256
+ dataLabel: "#e4e4e7",
257
+ dataLabelBackground: "#00000000",
258
+ dataLabelBorder: "#00000000",
259
+ annotation: "#e4e4e7",
260
+ annotationBackground: "#00000000",
261
+ annotationBorder: "#00000000",
262
+ titleColor: "#fafafa",
263
+ captionColor: "#a1a1aa",
264
+ bandFill: "#27272a",
265
+ positive: "#22d96a",
266
+ negative: "#ff4d4d",
267
+ candleNeutral: "#a1a1a1",
268
+ hoverBrightness: 1.1,
269
+ dimOpacity: 0.6,
270
+ barStrokeWidth: 0,
271
+ // `#000000d9` = rgba(0,0,0,0.85) — dark halo for light text in dark mode.
272
+ tickHalo: "#000000d9",
273
+ heatColorMin: "#fde68a",
274
+ heatColorMax: "#ee1c1c",
275
+ heatEmpty: "#3f3f46",
276
+ heatNull: "#27272a",
277
+ // Tooltip — dark surface, subtle light border for separation against dark page bg.
278
+ tooltipBackground: "#0a0a0acc",
279
+ // near-black + 0.80 (frosted glass)
280
+ tooltipBorder: "#ffffff1a",
281
+ // 0.10 alpha
282
+ tooltipColor: "#e4e4e7",
283
+ tooltipRadius: "8px",
284
+ tooltipBlur: "12px",
285
+ tooltipShadow: "0 8px 24px #00000066",
286
+ tooltipPadding: "10px 14px",
287
+ legendColor: "#e4e4e7",
288
+ legendBackground: "#00000000",
289
+ legendBorder: "#00000000",
290
+ referenceLineColor: "#71717a",
291
+ referenceBandFill: "#ffffff14",
292
+ // rgba(255,255,255,0.08)
293
+ // Navigator chrome — Highcharts-style: light overlay dims dark bg so selection stands out;
294
+ // brighter blue (blue-400) for selection so it pops on dark surfaces.
295
+ // `#ffffff14` ≈ rgba(255,255,255,0.08), `#60a5fab3` ≈ rgba(96,165,250,0.70),
296
+ // `#60a5fa1f` ≈ rgba(96,165,250,0.12).
297
+ navigatorSeries: "#a1a1aa",
298
+ navigatorMask: "#ffffff14",
299
+ navigatorSelectionColor: "#60a5fab3",
300
+ navigatorSelectionFill: "#60a5fa1f",
301
+ // Treemap defaults — same Studio cobalt for cell, mirrored borders/headers.
302
+ treemapCell: "#5790ff",
303
+ // theme.series[0] dark
304
+ treemapCellBorder: "#ffffff26",
305
+ // rgba(255,255,255,0.15)
306
+ treemapHeaderBg: "#00000099",
307
+ // rgba(0,0,0,0.6) — dark header band in dark mode
308
+ treemapHeaderText: "#ffffff",
309
+ borderColor: "#ffffff",
310
+ crosshairColor: "#a1a1aa",
311
+ fontFamily: 'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',
312
+ fontSize: 12
313
+ };
314
+
315
+ // src/utils/accessor.utils.ts
316
+ function isAccessorFunction(accessor) {
317
+ return typeof accessor === "function";
318
+ }
319
+ function isAccessorArray(accessor) {
320
+ return Array.isArray(accessor);
321
+ }
322
+ function isAccessorString(accessor) {
323
+ return typeof accessor === "string";
324
+ }
325
+ function makeItemContext(datum, index, extras) {
326
+ return {
327
+ datum,
328
+ index,
329
+ value: extras?.value ?? null,
330
+ seriesIndex: extras?.seriesIndex ?? 0,
331
+ seriesId: extras?.seriesId ?? "",
332
+ category: extras?.category,
333
+ size: extras?.size
334
+ };
335
+ }
336
+ function resolveNestedPath(obj, path) {
337
+ const parts = path.split(".");
338
+ let current = obj;
339
+ for (const part of parts) {
340
+ if (current === null || current === void 0) {
341
+ return void 0;
342
+ }
343
+ if (typeof current === "object" && part in current) {
344
+ current = current[part];
345
+ } else {
346
+ return void 0;
347
+ }
348
+ }
349
+ return current;
350
+ }
351
+ function isNestedPath(str) {
352
+ return str.includes(".") && !str.startsWith("#") && !str.startsWith("rgb") && !str.startsWith("hsl");
353
+ }
354
+ function resolveAccessor(accessor, ctx, opts) {
355
+ const fallback = opts?.fallback;
356
+ const arrayMode = opts?.arrayMode ?? "cycle";
357
+ if (accessor === void 0) return fallback;
358
+ if (typeof accessor === "function") {
359
+ const result = accessor(ctx);
360
+ return result ?? fallback;
361
+ }
362
+ if (Array.isArray(accessor)) {
363
+ const arr = accessor;
364
+ if (arr.length === 0) return fallback;
365
+ if (arrayMode === "cycle") {
366
+ return arr[(ctx.index % arr.length + arr.length) % arr.length] ?? fallback;
367
+ }
368
+ if (ctx.index >= 0 && ctx.index < arr.length) {
369
+ const v = arr[ctx.index];
370
+ return v === void 0 ? fallback : v;
371
+ }
372
+ return fallback;
373
+ }
374
+ if (typeof accessor === "string") {
375
+ const item = ctx.datum;
376
+ if (item !== null && typeof item === "object") {
377
+ if (accessor in item) {
378
+ return item[accessor];
379
+ }
380
+ if (isNestedPath(accessor)) {
381
+ const value = resolveNestedPath(item, accessor);
382
+ return value === void 0 ? fallback : value;
383
+ }
384
+ }
385
+ return accessor;
386
+ }
387
+ return accessor;
388
+ }
389
+ function batchResolveAccessor(accessor, data) {
390
+ return data.map((item, index) => resolveAccessor(accessor, makeItemContext(item, index)));
391
+ }
392
+ function resolveRequired(value, fieldName, rowIndex) {
393
+ if (value === void 0) {
394
+ const where = rowIndex !== void 0 ? ` at row ${rowIndex}` : "";
395
+ throw new Error(`Chart: required accessor "${fieldName}" returned undefined${where}. Provide a value for every row. Use null as an explicit gap sentinel where supported (line/area).`);
396
+ }
397
+ return value;
398
+ }
399
+ function batchResolveRequired(accessor, data, fieldName) {
400
+ if (accessor === void 0) {
401
+ throw new Error(`Chart: required accessor "${fieldName}" was not provided.`);
402
+ }
403
+ return data.map((item, index) => resolveRequired(resolveAccessor(accessor, makeItemContext(item, index)), fieldName, index));
404
+ }
405
+ var DASH_PATTERNS = {
406
+ solid: [],
407
+ dashed: [5, 5],
408
+ dotted: [1, 3],
409
+ dashdot: [5, 3, 1, 3],
410
+ longdash: [10, 5]
411
+ };
412
+ function resolveDash(accessor, ctx) {
413
+ if (accessor === void 0) return void 0;
414
+ let resolved;
415
+ if (typeof accessor === "function") {
416
+ resolved = accessor(ctx);
417
+ } else if (typeof accessor === "string") {
418
+ if (accessor in DASH_PATTERNS) {
419
+ resolved = accessor;
420
+ } else if (ctx.datum != null && accessor in ctx.datum) {
421
+ resolved = ctx.datum[accessor];
422
+ } else {
423
+ return void 0;
424
+ }
425
+ } else if (Array.isArray(accessor)) {
426
+ resolved = accessor;
427
+ }
428
+ if (resolved === void 0) return void 0;
429
+ if (Array.isArray(resolved)) return resolved;
430
+ return DASH_PATTERNS[resolved];
431
+ }
432
+ var FIELD_DEFAULTS = {
433
+ categoryField: "category",
434
+ valueField: "value",
435
+ xField: "x",
436
+ yField: "y",
437
+ columnField: "column",
438
+ rowField: "row",
439
+ openField: "open",
440
+ highField: "high",
441
+ lowField: "low",
442
+ closeField: "close"
443
+ };
444
+ function getDefaultColor(index, theme = defaultLightTheme) {
445
+ return theme.series[index % theme.series.length];
446
+ }
447
+ function resolveColor(accessor, ctx, theme = defaultLightTheme) {
448
+ if (accessor === void 0) {
449
+ return getDefaultColor(ctx.index, theme);
450
+ }
451
+ const resolved = resolveAccessor(accessor, ctx);
452
+ return typeof resolved === "string" && resolved ? resolved : getDefaultColor(ctx.index, theme);
453
+ }
454
+
455
+ // src/utils/color/resolution.ts
456
+ function getColorValue(props, index, item, theme = defaultLightTheme, extras) {
457
+ if (props.color != null) {
458
+ const resolved = resolveAccessor(props.color, makeItemContext(item, index, extras), { arrayMode: "cycle" });
459
+ if (resolved != null) return resolved;
460
+ }
461
+ return getDefaultColor(index, theme);
462
+ }
463
+ function getMostOpaqueStopColor(stops) {
464
+ if (!stops || stops.length === 0) return void 0;
465
+ if (stops.length === 1) return stops[0].color;
466
+ let bestStop = stops[0];
467
+ let bestAlpha = 0;
468
+ for (const stop of stops) {
469
+ const match = stop.color.match(/rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*([\d.]+)\s*)?\)/);
470
+ const alpha = match ? match[1] !== void 0 ? parseFloat(match[1]) : 1 : 1;
471
+ if (alpha > bestAlpha) {
472
+ bestAlpha = alpha;
473
+ bestStop = stop;
474
+ }
475
+ }
476
+ return bestStop.color;
477
+ }
478
+ function extractGradientColor(gradient) {
479
+ return getMostOpaqueStopColor(gradient.stops);
480
+ }
481
+ function getColor(props, index, item, theme = defaultLightTheme, extras) {
482
+ if (props.color != null) {
483
+ const resolved = resolveAccessor(props.color, makeItemContext(item, index, extras), { arrayMode: "cycle" });
484
+ if (resolved != null) {
485
+ if (typeof resolved === "string") return resolved;
486
+ const extracted = extractGradientColor(resolved);
487
+ if (extracted) return extracted;
488
+ }
489
+ }
490
+ return getDefaultColor(index, theme);
491
+ }
492
+ function resolveSwatchColor(props, index, item, theme, extras) {
493
+ if (props.color != null) {
494
+ return getColor(props, index, item, theme, extras);
495
+ }
496
+ return `var(--p-chart-color-${index % 10}, ${getDefaultColor(index, theme)})`;
497
+ }
498
+
499
+ export { FIELD_DEFAULTS, asGradient, batchResolveAccessor, batchResolveRequired, createCanvasGradientFromColor, createSvgGradientFromColor, defaultDarkTheme, defaultLightTheme, getColor, getColorValue, getDefaultColor, getPrimaryColor, gradientToCssBackground, isAccessorArray, isAccessorFunction, isAccessorString, isGradientColor, isNestedPath, makeItemContext, normalizeGradient, remapStopsForDonut, resolveAccessor, resolveColor, resolveDash, resolveNestedPath, resolveRequired, resolveSwatchColor, resolveSwatchGradientStops, sampleGradientAt };
@@ -0,0 +1,176 @@
1
+ import { batchResolveAccessor, FIELD_DEFAULTS } from './chunk-O2X6FF45.mjs';
2
+
3
+ // src/utils/interaction/accessibility.utils.ts
4
+ var CHART_TYPE_LABELS = {
5
+ bar: "Bar",
6
+ line: "Line",
7
+ area: "Area",
8
+ scatter: "Scatter",
9
+ pie: "Pie",
10
+ radar: "Radar",
11
+ polar: "Polar",
12
+ candlestick: "Candlestick",
13
+ heatmap: "Heatmap",
14
+ treemap: "Treemap"
15
+ };
16
+ function generateChartTypeDescription(datasets) {
17
+ if (datasets.size === 0) return "Empty chart.";
18
+ const typeCounts = /* @__PURE__ */ new Map();
19
+ for (const [, ds] of datasets) {
20
+ typeCounts.set(ds.type, (typeCounts.get(ds.type) ?? 0) + 1);
21
+ }
22
+ const types = Array.from(typeCounts.keys());
23
+ if (types.length === 1) {
24
+ const type = types[0];
25
+ const count = typeCounts.get(type);
26
+ const label = CHART_TYPE_LABELS[type] ?? type;
27
+ if (type === "pie") {
28
+ const totalSlices = getTotalDataPoints(datasets);
29
+ return `${label} chart with ${totalSlices} ${totalSlices === 1 ? "slice" : "slices"}.`;
30
+ }
31
+ if (count === 1) {
32
+ const totalPoints = getTotalDataPoints(datasets);
33
+ return `${label} chart with ${totalPoints} data ${totalPoints === 1 ? "point" : "points"}.`;
34
+ }
35
+ return `${label} chart with ${count} data series.`;
36
+ }
37
+ return `Combination chart with ${datasets.size} data series.`;
38
+ }
39
+ function generateSeriesDescription(name, type, pointCount) {
40
+ const label = CHART_TYPE_LABELS[type] ?? type;
41
+ return `${name}, ${label.toLowerCase()} series with ${pointCount} data ${pointCount === 1 ? "point" : "points"}.`;
42
+ }
43
+ function buildAccessibilityRenderContext(features) {
44
+ const a11yConfig = features?.get("accessibility")?.props;
45
+ if (a11yConfig?.enabled === false) return void 0;
46
+ return {
47
+ enabled: true,
48
+ pointDescriptionThreshold: a11yConfig?.pointDescriptionThreshold ?? 200,
49
+ pointDescriptionFormatter: a11yConfig?.pointDescriptionFormatter,
50
+ landmarkVerbosity: a11yConfig?.landmarkVerbosity ?? "all"
51
+ };
52
+ }
53
+ function generatePointDescription(category, value, seriesName) {
54
+ return `${seriesName}: ${category}, ${value}.`;
55
+ }
56
+ function generatePiePointDescription(label, value, percentage) {
57
+ if (percentage !== void 0) {
58
+ return `${label}: ${value}, ${percentage.toFixed(1)}%.`;
59
+ }
60
+ return `${label}: ${value}.`;
61
+ }
62
+ function formatPointDescription(context, formatter) {
63
+ if (formatter) return formatter(context);
64
+ if (context.percentage !== void 0) {
65
+ return generatePiePointDescription(context.category, context.value, context.percentage);
66
+ }
67
+ return generatePointDescription(context.category, context.value, context.seriesName);
68
+ }
69
+ function generateChartSummary(title, caption, typeDescription, axisDescriptions) {
70
+ const parts = [];
71
+ if (title) parts.push(title + ".");
72
+ if (caption) parts.push(caption + ".");
73
+ parts.push(typeDescription);
74
+ for (const axisDesc of axisDescriptions) {
75
+ parts.push(axisDesc);
76
+ }
77
+ return parts.join(" ");
78
+ }
79
+ function getTotalDataPoints(datasets) {
80
+ let total = 0;
81
+ for (const [, ds] of datasets) {
82
+ const props = ds.props;
83
+ if (Array.isArray(props.data)) {
84
+ total += props.data.length;
85
+ }
86
+ }
87
+ return total;
88
+ }
89
+ var DEFAULT_DATA_TABLE_MAX_ROWS = 200;
90
+ function pickField(props, prop, fallback) {
91
+ const v = props[prop];
92
+ return typeof v === "string" ? v : fallback;
93
+ }
94
+ function buildChartDataTable(datasets, maxRows = DEFAULT_DATA_TABLE_MAX_ROWS, cellFormatter) {
95
+ if (datasets.size === 0) return null;
96
+ const entries = [...datasets.values()].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
97
+ const type = entries[0].type;
98
+ const multi = entries.length > 1;
99
+ const rows = [];
100
+ let columns;
101
+ let caption;
102
+ const seriesName = (props, i) => typeof props.name === "string" ? props.name : `Series ${i + 1}`;
103
+ if (type === "scatter") {
104
+ columns = multi ? ["Series", "X", "Y"] : ["X", "Y"];
105
+ caption = "Scatter chart data";
106
+ entries.forEach((ds, i) => {
107
+ const props = ds.props;
108
+ const data = props.data ?? [];
109
+ const xs = batchResolveAccessor(pickField(props, "xField", FIELD_DEFAULTS.xField), data);
110
+ const ys = batchResolveAccessor(pickField(props, "yField", FIELD_DEFAULTS.yField), data);
111
+ data.forEach((_, r) => {
112
+ const row = [xs[r] ?? "", ys[r] ?? ""];
113
+ rows.push(multi ? [seriesName(props, i), ...row] : row);
114
+ });
115
+ });
116
+ } else if (type === "candlestick") {
117
+ columns = ["Time", "Open", "High", "Low", "Close"];
118
+ caption = "Candlestick chart data";
119
+ const props = entries[0].props;
120
+ const data = props.data ?? [];
121
+ const times = batchResolveAccessor(pickField(props, "timeField", "time"), data);
122
+ const opens = batchResolveAccessor(pickField(props, "openField", FIELD_DEFAULTS.openField), data);
123
+ const highs = batchResolveAccessor(pickField(props, "highField", FIELD_DEFAULTS.highField), data);
124
+ const lows = batchResolveAccessor(pickField(props, "lowField", FIELD_DEFAULTS.lowField), data);
125
+ const closes = batchResolveAccessor(pickField(props, "closeField", FIELD_DEFAULTS.closeField), data);
126
+ data.forEach((_, r) => rows.push([String(times[r] ?? r), opens[r] ?? "", highs[r] ?? "", lows[r] ?? "", closes[r] ?? ""]));
127
+ } else if (type === "heatmap") {
128
+ columns = ["Row", "Column", "Value"];
129
+ caption = "Heatmap chart data";
130
+ const props = entries[0].props;
131
+ const data = props.data ?? [];
132
+ const ys = batchResolveAccessor(pickField(props, "yField", FIELD_DEFAULTS.yField), data);
133
+ const xs = batchResolveAccessor(pickField(props, "xField", FIELD_DEFAULTS.xField), data);
134
+ const vals = batchResolveAccessor(pickField(props, "valueField", FIELD_DEFAULTS.valueField), data);
135
+ data.forEach((_, r) => rows.push([String(ys[r] ?? r), String(xs[r] ?? r), vals[r] ?? ""]));
136
+ } else if (type === "pie") {
137
+ columns = ["Slice", "Value"];
138
+ caption = "Pie chart data";
139
+ const props = entries[0].props;
140
+ const data = props.data ?? [];
141
+ const cats = batchResolveAccessor(pickField(props, "categoryField", FIELD_DEFAULTS.categoryField), data);
142
+ const vals = batchResolveAccessor(pickField(props, "valueField", FIELD_DEFAULTS.valueField), data);
143
+ data.forEach((_, r) => rows.push([String(cats[r] ?? r), vals[r] ?? ""]));
144
+ } else {
145
+ columns = multi ? ["Series", "Category", "Value"] : ["Category", "Value"];
146
+ caption = `${CHART_TYPE_LABELS[type] ?? "Chart"} chart data`;
147
+ entries.forEach((ds, i) => {
148
+ const props = ds.props;
149
+ const data = props.data ?? [];
150
+ const cats = batchResolveAccessor(pickField(props, "categoryField", FIELD_DEFAULTS.categoryField), data);
151
+ const vals = batchResolveAccessor(pickField(props, "valueField", FIELD_DEFAULTS.valueField), data);
152
+ data.forEach((_, r) => {
153
+ const row = [String(cats[r] ?? r), vals[r] ?? ""];
154
+ rows.push(multi ? [seriesName(props, i), ...row] : row);
155
+ });
156
+ });
157
+ }
158
+ if (rows.length === 0) return null;
159
+ const limit = maxRows > 0 ? maxRows : DEFAULT_DATA_TABLE_MAX_ROWS;
160
+ const truncatedRowCount = rows.length > limit ? rows.length - limit : 0;
161
+ let visibleRows = truncatedRowCount > 0 ? rows.slice(0, limit) : rows;
162
+ if (cellFormatter) {
163
+ visibleRows = visibleRows.map((row, rowIndex) => row.map((value, columnIndex) => cellFormatter({ value, column: columns[columnIndex] ?? "", columnIndex, rowIndex, isNumeric: typeof value === "number" })));
164
+ }
165
+ return { caption, columns, rows: visibleRows, truncatedRowCount };
166
+ }
167
+ function dataTableToCsv(table) {
168
+ const escape = (cell) => {
169
+ const s = String(cell);
170
+ return /[",\n\r]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
171
+ };
172
+ const lines = [table.columns.map(escape).join(","), ...table.rows.map((row) => row.map(escape).join(","))];
173
+ return lines.join("\r\n");
174
+ }
175
+
176
+ export { buildAccessibilityRenderContext, buildChartDataTable, dataTableToCsv, formatPointDescription, generateChartSummary, generateChartTypeDescription, generatePiePointDescription, generatePointDescription, generateSeriesDescription };