@salmonui/charts 0.0.0-stage → 0.3.0

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 (521) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +61 -2
  3. package/dist/barcode/Barcode.d.ts +48 -0
  4. package/dist/barcode/Barcode.d.ts.map +1 -0
  5. package/dist/barcode/Barcode.js +31 -0
  6. package/dist/barcode/Barcode.js.map +1 -0
  7. package/dist/barcode/DotCode.d.ts +12 -0
  8. package/dist/barcode/DotCode.d.ts.map +1 -0
  9. package/dist/barcode/DotCode.js +21 -0
  10. package/dist/barcode/DotCode.js.map +1 -0
  11. package/dist/barcode/Gs1DataBar.d.ts +16 -0
  12. package/dist/barcode/Gs1DataBar.d.ts.map +1 -0
  13. package/dist/barcode/Gs1DataBar.js +27 -0
  14. package/dist/barcode/Gs1DataBar.js.map +1 -0
  15. package/dist/barcode/Pdf417.d.ts +24 -0
  16. package/dist/barcode/Pdf417.d.ts.map +1 -0
  17. package/dist/barcode/Pdf417.js +21 -0
  18. package/dist/barcode/Pdf417.js.map +1 -0
  19. package/dist/barcode/QRCode.d.ts +39 -0
  20. package/dist/barcode/QRCode.d.ts.map +1 -0
  21. package/dist/barcode/QRCode.js +24 -0
  22. package/dist/barcode/QRCode.js.map +1 -0
  23. package/dist/barcode/SymbolSvg.d.ts +44 -0
  24. package/dist/barcode/SymbolSvg.d.ts.map +1 -0
  25. package/dist/barcode/SymbolSvg.js +62 -0
  26. package/dist/barcode/SymbolSvg.js.map +1 -0
  27. package/dist/barcode/encode/databar.d.ts +18 -0
  28. package/dist/barcode/encode/databar.d.ts.map +1 -0
  29. package/dist/barcode/encode/databar.js +506 -0
  30. package/dist/barcode/encode/databar.js.map +1 -0
  31. package/dist/barcode/encode/datamatrix.d.ts +41 -0
  32. package/dist/barcode/encode/datamatrix.d.ts.map +1 -0
  33. package/dist/barcode/encode/datamatrix.js +300 -0
  34. package/dist/barcode/encode/datamatrix.js.map +1 -0
  35. package/dist/barcode/encode/dotcode.d.ts +31 -0
  36. package/dist/barcode/encode/dotcode.d.ts.map +1 -0
  37. package/dist/barcode/encode/dotcode.js +470 -0
  38. package/dist/barcode/encode/dotcode.js.map +1 -0
  39. package/dist/barcode/encode/fail.d.ts +10 -0
  40. package/dist/barcode/encode/fail.d.ts.map +1 -0
  41. package/dist/barcode/encode/fail.js +6 -0
  42. package/dist/barcode/encode/fail.js.map +1 -0
  43. package/dist/barcode/encode/index.d.ts +15 -0
  44. package/dist/barcode/encode/index.d.ts.map +1 -0
  45. package/dist/barcode/encode/index.js +31 -0
  46. package/dist/barcode/encode/index.js.map +1 -0
  47. package/dist/barcode/encode/linear.d.ts +85 -0
  48. package/dist/barcode/encode/linear.d.ts.map +1 -0
  49. package/dist/barcode/encode/linear.js +516 -0
  50. package/dist/barcode/encode/linear.js.map +1 -0
  51. package/dist/barcode/encode/pdf417.d.ts +26 -0
  52. package/dist/barcode/encode/pdf417.d.ts.map +1 -0
  53. package/dist/barcode/encode/pdf417.js +371 -0
  54. package/dist/barcode/encode/pdf417.js.map +1 -0
  55. package/dist/barcode/encode/qr.d.ts +51 -0
  56. package/dist/barcode/encode/qr.d.ts.map +1 -0
  57. package/dist/barcode/encode/qr.js +454 -0
  58. package/dist/barcode/encode/qr.js.map +1 -0
  59. package/dist/barcode/encode/svg.d.ts +5 -0
  60. package/dist/barcode/encode/svg.d.ts.map +1 -0
  61. package/dist/barcode/encode/svg.js +40 -0
  62. package/dist/barcode/encode/svg.js.map +1 -0
  63. package/dist/barcode/props.d.ts +59 -0
  64. package/dist/barcode/props.d.ts.map +1 -0
  65. package/dist/barcode/props.js +14 -0
  66. package/dist/barcode/props.js.map +1 -0
  67. package/dist/barcode/render.d.ts +60 -0
  68. package/dist/barcode/render.d.ts.map +1 -0
  69. package/dist/barcode/render.js +95 -0
  70. package/dist/barcode/render.js.map +1 -0
  71. package/dist/barcode/rows.d.ts +27 -0
  72. package/dist/barcode/rows.d.ts.map +1 -0
  73. package/dist/barcode/rows.js +31 -0
  74. package/dist/barcode/rows.js.map +1 -0
  75. package/dist/barcode-dotcode.d.ts +7 -0
  76. package/dist/barcode-dotcode.d.ts.map +1 -0
  77. package/dist/barcode-dotcode.js +8 -0
  78. package/dist/barcode-dotcode.js.map +1 -0
  79. package/dist/barcode-gs1-databar.d.ts +7 -0
  80. package/dist/barcode-gs1-databar.d.ts.map +1 -0
  81. package/dist/barcode-gs1-databar.js +7 -0
  82. package/dist/barcode-gs1-databar.js.map +1 -0
  83. package/dist/barcode-pdf417.d.ts +7 -0
  84. package/dist/barcode-pdf417.d.ts.map +1 -0
  85. package/dist/barcode-pdf417.js +8 -0
  86. package/dist/barcode-pdf417.js.map +1 -0
  87. package/dist/barcode.css +30 -0
  88. package/dist/barcode.d.ts +10 -0
  89. package/dist/barcode.d.ts.map +1 -0
  90. package/dist/barcode.js +13 -0
  91. package/dist/barcode.js.map +1 -0
  92. package/dist/chart/BulletChart.d.ts +59 -0
  93. package/dist/chart/BulletChart.d.ts.map +1 -0
  94. package/dist/chart/BulletChart.js +107 -0
  95. package/dist/chart/BulletChart.js.map +1 -0
  96. package/dist/chart/Chart.d.ts +41 -0
  97. package/dist/chart/Chart.d.ts.map +1 -0
  98. package/dist/chart/Chart.js +572 -0
  99. package/dist/chart/Chart.js.map +1 -0
  100. package/dist/chart/ChartSeries.d.ts +14 -0
  101. package/dist/chart/ChartSeries.d.ts.map +1 -0
  102. package/dist/chart/ChartSeries.js +13 -0
  103. package/dist/chart/ChartSeries.js.map +1 -0
  104. package/dist/chart/ChartSyncGroup.d.ts +37 -0
  105. package/dist/chart/ChartSyncGroup.d.ts.map +1 -0
  106. package/dist/chart/ChartSyncGroup.js +19 -0
  107. package/dist/chart/ChartSyncGroup.js.map +1 -0
  108. package/dist/chart/features.d.ts +11 -0
  109. package/dist/chart/features.d.ts.map +1 -0
  110. package/dist/chart/features.js +10 -0
  111. package/dist/chart/features.js.map +1 -0
  112. package/dist/chart/indicators.d.ts +17 -0
  113. package/dist/chart/indicators.d.ts.map +1 -0
  114. package/dist/chart/indicators.js +121 -0
  115. package/dist/chart/indicators.js.map +1 -0
  116. package/dist/chart/interact.d.ts +65 -0
  117. package/dist/chart/interact.d.ts.map +1 -0
  118. package/dist/chart/interact.js +249 -0
  119. package/dist/chart/interact.js.map +1 -0
  120. package/dist/chart/model.d.ts +239 -0
  121. package/dist/chart/model.d.ts.map +1 -0
  122. package/dist/chart/model.js +1300 -0
  123. package/dist/chart/model.js.map +1 -0
  124. package/dist/chart/overlay.d.ts +50 -0
  125. package/dist/chart/overlay.d.ts.map +1 -0
  126. package/dist/chart/overlay.js +221 -0
  127. package/dist/chart/overlay.js.map +1 -0
  128. package/dist/chart/polar.d.ts +5 -0
  129. package/dist/chart/polar.d.ts.map +1 -0
  130. package/dist/chart/polar.js +164 -0
  131. package/dist/chart/polar.js.map +1 -0
  132. package/dist/chart/render.d.ts +23 -0
  133. package/dist/chart/render.d.ts.map +1 -0
  134. package/dist/chart/render.js +81 -0
  135. package/dist/chart/render.js.map +1 -0
  136. package/dist/chart/types.d.ts +616 -0
  137. package/dist/chart/types.d.ts.map +1 -0
  138. package/dist/chart/types.js +5 -0
  139. package/dist/chart/types.js.map +1 -0
  140. package/dist/chart/zoom-toolbar.d.ts +14 -0
  141. package/dist/chart/zoom-toolbar.d.ts.map +1 -0
  142. package/dist/chart/zoom-toolbar.js +11 -0
  143. package/dist/chart/zoom-toolbar.js.map +1 -0
  144. package/dist/chart-bullet.d.ts +3 -0
  145. package/dist/chart-bullet.d.ts.map +1 -0
  146. package/dist/chart-bullet.js +9 -0
  147. package/dist/chart-bullet.js.map +1 -0
  148. package/dist/chart-export.d.ts +3 -0
  149. package/dist/chart-export.d.ts.map +1 -0
  150. package/dist/chart-export.js +6 -0
  151. package/dist/chart-export.js.map +1 -0
  152. package/dist/chart.css +552 -0
  153. package/dist/chart.d.ts +7 -0
  154. package/dist/chart.d.ts.map +1 -0
  155. package/dist/chart.js +12 -0
  156. package/dist/chart.js.map +1 -0
  157. package/dist/gauge/Gauge.d.ts +139 -0
  158. package/dist/gauge/Gauge.d.ts.map +1 -0
  159. package/dist/gauge/Gauge.js +254 -0
  160. package/dist/gauge/Gauge.js.map +1 -0
  161. package/dist/gauge/animate.d.ts +4 -0
  162. package/dist/gauge/animate.d.ts.map +1 -0
  163. package/dist/gauge/animate.js +41 -0
  164. package/dist/gauge/animate.js.map +1 -0
  165. package/dist/gauge/drag.d.ts +9 -0
  166. package/dist/gauge/drag.d.ts.map +1 -0
  167. package/dist/gauge/drag.js +28 -0
  168. package/dist/gauge/drag.js.map +1 -0
  169. package/dist/gauge/layout.d.ts +257 -0
  170. package/dist/gauge/layout.d.ts.map +1 -0
  171. package/dist/gauge/layout.js +399 -0
  172. package/dist/gauge/layout.js.map +1 -0
  173. package/dist/gauge/tooltip.d.ts +20 -0
  174. package/dist/gauge/tooltip.d.ts.map +1 -0
  175. package/dist/gauge/tooltip.js +19 -0
  176. package/dist/gauge/tooltip.js.map +1 -0
  177. package/dist/gauge.css +379 -0
  178. package/dist/gauge.d.ts +5 -0
  179. package/dist/gauge.d.ts.map +1 -0
  180. package/dist/gauge.js +9 -0
  181. package/dist/gauge.js.map +1 -0
  182. package/dist/geo-map/GeoMap.d.ts +198 -0
  183. package/dist/geo-map/GeoMap.d.ts.map +1 -0
  184. package/dist/geo-map/GeoMap.js +621 -0
  185. package/dist/geo-map/GeoMap.js.map +1 -0
  186. package/dist/geo-map/model.d.ts +270 -0
  187. package/dist/geo-map/model.d.ts.map +1 -0
  188. package/dist/geo-map/model.js +265 -0
  189. package/dist/geo-map/model.js.map +1 -0
  190. package/dist/geo-map/tiles.d.ts +13 -0
  191. package/dist/geo-map/tiles.d.ts.map +1 -0
  192. package/dist/geo-map/tiles.js +13 -0
  193. package/dist/geo-map/tiles.js.map +1 -0
  194. package/dist/geo-map.css +522 -0
  195. package/dist/geo-map.d.ts +6 -0
  196. package/dist/geo-map.d.ts.map +1 -0
  197. package/dist/geo-map.js +11 -0
  198. package/dist/geo-map.js.map +1 -0
  199. package/dist/heat-map/HeatMap.d.ts +6 -0
  200. package/dist/heat-map/HeatMap.d.ts.map +1 -0
  201. package/dist/heat-map/HeatMap.js +329 -0
  202. package/dist/heat-map/HeatMap.js.map +1 -0
  203. package/dist/heat-map/canvas.d.ts +12 -0
  204. package/dist/heat-map/canvas.d.ts.map +1 -0
  205. package/dist/heat-map/canvas.js +71 -0
  206. package/dist/heat-map/canvas.js.map +1 -0
  207. package/dist/heat-map/model.d.ts +41 -0
  208. package/dist/heat-map/model.d.ts.map +1 -0
  209. package/dist/heat-map/model.js +194 -0
  210. package/dist/heat-map/model.js.map +1 -0
  211. package/dist/heat-map/types.d.ts +168 -0
  212. package/dist/heat-map/types.d.ts.map +1 -0
  213. package/dist/heat-map/types.js +2 -0
  214. package/dist/heat-map/types.js.map +1 -0
  215. package/dist/heat-map.css +362 -0
  216. package/dist/heat-map.d.ts +5 -0
  217. package/dist/heat-map.d.ts.map +1 -0
  218. package/dist/heat-map.js +11 -0
  219. package/dist/heat-map.js.map +1 -0
  220. package/dist/internal/data-colors.d.ts +11 -0
  221. package/dist/internal/data-colors.d.ts.map +1 -0
  222. package/dist/internal/data-colors.js +60 -0
  223. package/dist/internal/data-colors.js.map +1 -0
  224. package/dist/internal/message.d.ts +7 -0
  225. package/dist/internal/message.d.ts.map +1 -0
  226. package/dist/internal/message.js +12 -0
  227. package/dist/internal/message.js.map +1 -0
  228. package/dist/internal/viz/animate.d.ts +10 -0
  229. package/dist/internal/viz/animate.d.ts.map +1 -0
  230. package/dist/internal/viz/animate.js +21 -0
  231. package/dist/internal/viz/animate.js.map +1 -0
  232. package/dist/internal/viz/canvas.d.ts +14 -0
  233. package/dist/internal/viz/canvas.d.ts.map +1 -0
  234. package/dist/internal/viz/canvas.js +34 -0
  235. package/dist/internal/viz/canvas.js.map +1 -0
  236. package/dist/internal/viz/children.d.ts +4 -0
  237. package/dist/internal/viz/children.d.ts.map +1 -0
  238. package/dist/internal/viz/children.js +11 -0
  239. package/dist/internal/viz/children.js.map +1 -0
  240. package/dist/internal/viz/export-all.d.ts +27 -0
  241. package/dist/internal/viz/export-all.d.ts.map +1 -0
  242. package/dist/internal/viz/export-all.js +8 -0
  243. package/dist/internal/viz/export-all.js.map +1 -0
  244. package/dist/internal/viz/export-data.d.ts +32 -0
  245. package/dist/internal/viz/export-data.d.ts.map +1 -0
  246. package/dist/internal/viz/export-data.js +100 -0
  247. package/dist/internal/viz/export-data.js.map +1 -0
  248. package/dist/internal/viz/export.d.ts +48 -0
  249. package/dist/internal/viz/export.d.ts.map +1 -0
  250. package/dist/internal/viz/export.js +199 -0
  251. package/dist/internal/viz/export.js.map +1 -0
  252. package/dist/internal/viz/fields.d.ts +2 -0
  253. package/dist/internal/viz/fields.d.ts.map +1 -0
  254. package/dist/internal/viz/fields.js +5 -0
  255. package/dist/internal/viz/fields.js.map +1 -0
  256. package/dist/internal/viz/figure.d.ts +48 -0
  257. package/dist/internal/viz/figure.d.ts.map +1 -0
  258. package/dist/internal/viz/figure.js +28 -0
  259. package/dist/internal/viz/figure.js.map +1 -0
  260. package/dist/internal/viz/format.d.ts +21 -0
  261. package/dist/internal/viz/format.d.ts.map +1 -0
  262. package/dist/internal/viz/format.js +77 -0
  263. package/dist/internal/viz/format.js.map +1 -0
  264. package/dist/internal/viz/frame.d.ts +81 -0
  265. package/dist/internal/viz/frame.d.ts.map +1 -0
  266. package/dist/internal/viz/frame.js +78 -0
  267. package/dist/internal/viz/frame.js.map +1 -0
  268. package/dist/internal/viz/instance-run.d.ts +6 -0
  269. package/dist/internal/viz/instance-run.d.ts.map +1 -0
  270. package/dist/internal/viz/instance-run.js +43 -0
  271. package/dist/internal/viz/instance-run.js.map +1 -0
  272. package/dist/internal/viz/instance.d.ts +59 -0
  273. package/dist/internal/viz/instance.d.ts.map +1 -0
  274. package/dist/internal/viz/instance.js +23 -0
  275. package/dist/internal/viz/instance.js.map +1 -0
  276. package/dist/internal/viz/keyboard.d.ts +21 -0
  277. package/dist/internal/viz/keyboard.d.ts.map +1 -0
  278. package/dist/internal/viz/keyboard.js +78 -0
  279. package/dist/internal/viz/keyboard.js.map +1 -0
  280. package/dist/internal/viz/legend.d.ts +63 -0
  281. package/dist/internal/viz/legend.d.ts.map +1 -0
  282. package/dist/internal/viz/legend.js +76 -0
  283. package/dist/internal/viz/legend.js.map +1 -0
  284. package/dist/internal/viz/plot-canvas.d.ts +16 -0
  285. package/dist/internal/viz/plot-canvas.d.ts.map +1 -0
  286. package/dist/internal/viz/plot-canvas.js +62 -0
  287. package/dist/internal/viz/plot-canvas.js.map +1 -0
  288. package/dist/internal/viz/size.d.ts +20 -0
  289. package/dist/internal/viz/size.d.ts.map +1 -0
  290. package/dist/internal/viz/size.js +61 -0
  291. package/dist/internal/viz/size.js.map +1 -0
  292. package/dist/internal/viz/store.d.ts +20 -0
  293. package/dist/internal/viz/store.d.ts.map +1 -0
  294. package/dist/internal/viz/store.js +74 -0
  295. package/dist/internal/viz/store.js.map +1 -0
  296. package/dist/internal/viz/svg-server.d.ts +15 -0
  297. package/dist/internal/viz/svg-server.d.ts.map +1 -0
  298. package/dist/internal/viz/svg-server.js +105 -0
  299. package/dist/internal/viz/svg-server.js.map +1 -0
  300. package/dist/internal/viz/tooltip.d.ts +14 -0
  301. package/dist/internal/viz/tooltip.d.ts.map +1 -0
  302. package/dist/internal/viz/tooltip.js +34 -0
  303. package/dist/internal/viz/tooltip.js.map +1 -0
  304. package/dist/pie-chart/Accumulation.d.ts +93 -0
  305. package/dist/pie-chart/Accumulation.d.ts.map +1 -0
  306. package/dist/pie-chart/Accumulation.js +243 -0
  307. package/dist/pie-chart/Accumulation.js.map +1 -0
  308. package/dist/pie-chart/FunnelChart.d.ts +4 -0
  309. package/dist/pie-chart/FunnelChart.d.ts.map +1 -0
  310. package/dist/pie-chart/FunnelChart.js +47 -0
  311. package/dist/pie-chart/FunnelChart.js.map +1 -0
  312. package/dist/pie-chart/PieChart.d.ts +4 -0
  313. package/dist/pie-chart/PieChart.d.ts.map +1 -0
  314. package/dist/pie-chart/PieChart.js +87 -0
  315. package/dist/pie-chart/PieChart.js.map +1 -0
  316. package/dist/pie-chart/types.d.ts +243 -0
  317. package/dist/pie-chart/types.d.ts.map +1 -0
  318. package/dist/pie-chart/types.js +2 -0
  319. package/dist/pie-chart/types.js.map +1 -0
  320. package/dist/pie-chart.css +389 -0
  321. package/dist/pie-chart.d.ts +6 -0
  322. package/dist/pie-chart.d.ts.map +1 -0
  323. package/dist/pie-chart.js +12 -0
  324. package/dist/pie-chart.js.map +1 -0
  325. package/dist/range-selector/PeriodSelector.d.ts +19 -0
  326. package/dist/range-selector/PeriodSelector.d.ts.map +1 -0
  327. package/dist/range-selector/PeriodSelector.js +11 -0
  328. package/dist/range-selector/PeriodSelector.js.map +1 -0
  329. package/dist/range-selector/RangeSelector.d.ts +71 -0
  330. package/dist/range-selector/RangeSelector.d.ts.map +1 -0
  331. package/dist/range-selector/RangeSelector.js +220 -0
  332. package/dist/range-selector/RangeSelector.js.map +1 -0
  333. package/dist/range-selector/model.d.ts +77 -0
  334. package/dist/range-selector/model.d.ts.map +1 -0
  335. package/dist/range-selector/model.js +162 -0
  336. package/dist/range-selector/model.js.map +1 -0
  337. package/dist/range-selector/period.d.ts +17 -0
  338. package/dist/range-selector/period.d.ts.map +1 -0
  339. package/dist/range-selector/period.js +31 -0
  340. package/dist/range-selector/period.js.map +1 -0
  341. package/dist/range-selector.css +407 -0
  342. package/dist/range-selector.d.ts +8 -0
  343. package/dist/range-selector.d.ts.map +1 -0
  344. package/dist/range-selector.js +11 -0
  345. package/dist/range-selector.js.map +1 -0
  346. package/dist/sankey-chart/SankeyChart.d.ts +4 -0
  347. package/dist/sankey-chart/SankeyChart.d.ts.map +1 -0
  348. package/dist/sankey-chart/SankeyChart.js +308 -0
  349. package/dist/sankey-chart/SankeyChart.js.map +1 -0
  350. package/dist/sankey-chart/types.d.ts +131 -0
  351. package/dist/sankey-chart/types.d.ts.map +1 -0
  352. package/dist/sankey-chart/types.js +2 -0
  353. package/dist/sankey-chart/types.js.map +1 -0
  354. package/dist/sankey-chart.css +344 -0
  355. package/dist/sankey-chart.d.ts +5 -0
  356. package/dist/sankey-chart.d.ts.map +1 -0
  357. package/dist/sankey-chart.js +10 -0
  358. package/dist/sankey-chart.js.map +1 -0
  359. package/dist/server-visualization.d.ts +3 -0
  360. package/dist/server-visualization.d.ts.map +1 -0
  361. package/dist/server-visualization.js +7 -0
  362. package/dist/server-visualization.js.map +1 -0
  363. package/dist/sparkline/Sparkline.d.ts +4 -0
  364. package/dist/sparkline/Sparkline.d.ts.map +1 -0
  365. package/dist/sparkline/Sparkline.js +103 -0
  366. package/dist/sparkline/Sparkline.js.map +1 -0
  367. package/dist/sparkline/canvas.d.ts +4 -0
  368. package/dist/sparkline/canvas.d.ts.map +1 -0
  369. package/dist/sparkline/canvas.js +68 -0
  370. package/dist/sparkline/canvas.js.map +1 -0
  371. package/dist/sparkline/model.d.ts +29 -0
  372. package/dist/sparkline/model.d.ts.map +1 -0
  373. package/dist/sparkline/model.js +116 -0
  374. package/dist/sparkline/model.js.map +1 -0
  375. package/dist/sparkline/tooltip.d.ts +15 -0
  376. package/dist/sparkline/tooltip.d.ts.map +1 -0
  377. package/dist/sparkline/tooltip.js +138 -0
  378. package/dist/sparkline/tooltip.js.map +1 -0
  379. package/dist/sparkline/types.d.ts +119 -0
  380. package/dist/sparkline/types.d.ts.map +1 -0
  381. package/dist/sparkline/types.js +2 -0
  382. package/dist/sparkline/types.js.map +1 -0
  383. package/dist/sparkline.css +70 -0
  384. package/dist/sparkline.d.ts +3 -0
  385. package/dist/sparkline.d.ts.map +1 -0
  386. package/dist/sparkline.js +10 -0
  387. package/dist/sparkline.js.map +1 -0
  388. package/dist/stock-chart/StockChart.d.ts +118 -0
  389. package/dist/stock-chart/StockChart.d.ts.map +1 -0
  390. package/dist/stock-chart/StockChart.js +223 -0
  391. package/dist/stock-chart/StockChart.js.map +1 -0
  392. package/dist/stock-chart.css +54 -0
  393. package/dist/stock-chart.d.ts +3 -0
  394. package/dist/stock-chart.d.ts.map +1 -0
  395. package/dist/stock-chart.js +10 -0
  396. package/dist/stock-chart.js.map +1 -0
  397. package/dist/styles.css +1284 -0
  398. package/dist/tree-map/TreeMap.d.ts +4 -0
  399. package/dist/tree-map/TreeMap.d.ts.map +1 -0
  400. package/dist/tree-map/TreeMap.js +309 -0
  401. package/dist/tree-map/TreeMap.js.map +1 -0
  402. package/dist/tree-map/types.d.ts +158 -0
  403. package/dist/tree-map/types.d.ts.map +1 -0
  404. package/dist/tree-map/types.js +2 -0
  405. package/dist/tree-map/types.js.map +1 -0
  406. package/dist/tree-map.css +425 -0
  407. package/dist/tree-map.d.ts +5 -0
  408. package/dist/tree-map.d.ts.map +1 -0
  409. package/dist/tree-map.js +10 -0
  410. package/dist/tree-map.js.map +1 -0
  411. package/dist/viz/accumulation.d.ts +135 -0
  412. package/dist/viz/accumulation.d.ts.map +1 -0
  413. package/dist/viz/accumulation.js +233 -0
  414. package/dist/viz/accumulation.js.map +1 -0
  415. package/dist/viz/cluster.d.ts +13 -0
  416. package/dist/viz/cluster.d.ts.map +1 -0
  417. package/dist/viz/cluster.js +26 -0
  418. package/dist/viz/cluster.js.map +1 -0
  419. package/dist/viz/color.d.ts +33 -0
  420. package/dist/viz/color.d.ts.map +1 -0
  421. package/dist/viz/color.js +77 -0
  422. package/dist/viz/color.js.map +1 -0
  423. package/dist/viz/decimate.d.ts +41 -0
  424. package/dist/viz/decimate.d.ts.map +1 -0
  425. package/dist/viz/decimate.js +205 -0
  426. package/dist/viz/decimate.js.map +1 -0
  427. package/dist/viz/field.d.ts +5 -0
  428. package/dist/viz/field.d.ts.map +1 -0
  429. package/dist/viz/field.js +23 -0
  430. package/dist/viz/field.js.map +1 -0
  431. package/dist/viz/format.d.ts +11 -0
  432. package/dist/viz/format.d.ts.map +1 -0
  433. package/dist/viz/format.js +45 -0
  434. package/dist/viz/format.js.map +1 -0
  435. package/dist/viz/geometry.d.ts +36 -0
  436. package/dist/viz/geometry.d.ts.map +1 -0
  437. package/dist/viz/geometry.js +290 -0
  438. package/dist/viz/geometry.js.map +1 -0
  439. package/dist/viz/heatmap.d.ts +37 -0
  440. package/dist/viz/heatmap.d.ts.map +1 -0
  441. package/dist/viz/heatmap.js +131 -0
  442. package/dist/viz/heatmap.js.map +1 -0
  443. package/dist/viz/hit-test.d.ts +30 -0
  444. package/dist/viz/hit-test.d.ts.map +1 -0
  445. package/dist/viz/hit-test.js +116 -0
  446. package/dist/viz/hit-test.js.map +1 -0
  447. package/dist/viz/index.d.ts +27 -0
  448. package/dist/viz/index.d.ts.map +1 -0
  449. package/dist/viz/index.js +32 -0
  450. package/dist/viz/index.js.map +1 -0
  451. package/dist/viz/indicators.d.ts +26 -0
  452. package/dist/viz/indicators.d.ts.map +1 -0
  453. package/dist/viz/indicators.js +166 -0
  454. package/dist/viz/indicators.js.map +1 -0
  455. package/dist/viz/labels.d.ts +48 -0
  456. package/dist/viz/labels.d.ts.map +1 -0
  457. package/dist/viz/labels.js +136 -0
  458. package/dist/viz/labels.js.map +1 -0
  459. package/dist/viz/layout.d.ts +134 -0
  460. package/dist/viz/layout.d.ts.map +1 -0
  461. package/dist/viz/layout.js +243 -0
  462. package/dist/viz/layout.js.map +1 -0
  463. package/dist/viz/palette.d.ts +40 -0
  464. package/dist/viz/palette.d.ts.map +1 -0
  465. package/dist/viz/palette.js +89 -0
  466. package/dist/viz/palette.js.map +1 -0
  467. package/dist/viz/polygon.d.ts +3 -0
  468. package/dist/viz/polygon.d.ts.map +1 -0
  469. package/dist/viz/polygon.js +18 -0
  470. package/dist/viz/polygon.js.map +1 -0
  471. package/dist/viz/polyline.d.ts +21 -0
  472. package/dist/viz/polyline.d.ts.map +1 -0
  473. package/dist/viz/polyline.js +52 -0
  474. package/dist/viz/polyline.js.map +1 -0
  475. package/dist/viz/projection.d.ts +63 -0
  476. package/dist/viz/projection.d.ts.map +1 -0
  477. package/dist/viz/projection.js +252 -0
  478. package/dist/viz/projection.js.map +1 -0
  479. package/dist/viz/sankey.d.ts +75 -0
  480. package/dist/viz/sankey.d.ts.map +1 -0
  481. package/dist/viz/sankey.js +292 -0
  482. package/dist/viz/sankey.js.map +1 -0
  483. package/dist/viz/scale.d.ts +95 -0
  484. package/dist/viz/scale.d.ts.map +1 -0
  485. package/dist/viz/scale.js +157 -0
  486. package/dist/viz/scale.js.map +1 -0
  487. package/dist/viz/stack.d.ts +25 -0
  488. package/dist/viz/stack.d.ts.map +1 -0
  489. package/dist/viz/stack.js +62 -0
  490. package/dist/viz/stack.js.map +1 -0
  491. package/dist/viz/stats.d.ts +52 -0
  492. package/dist/viz/stats.d.ts.map +1 -0
  493. package/dist/viz/stats.js +198 -0
  494. package/dist/viz/stats.js.map +1 -0
  495. package/dist/viz/summary.d.ts +30 -0
  496. package/dist/viz/summary.d.ts.map +1 -0
  497. package/dist/viz/summary.js +61 -0
  498. package/dist/viz/summary.js.map +1 -0
  499. package/dist/viz/text.d.ts +21 -0
  500. package/dist/viz/text.d.ts.map +1 -0
  501. package/dist/viz/text.js +99 -0
  502. package/dist/viz/text.js.map +1 -0
  503. package/dist/viz/ticks.d.ts +23 -0
  504. package/dist/viz/ticks.d.ts.map +1 -0
  505. package/dist/viz/ticks.js +146 -0
  506. package/dist/viz/ticks.js.map +1 -0
  507. package/dist/viz/time-ticks.d.ts +44 -0
  508. package/dist/viz/time-ticks.d.ts.map +1 -0
  509. package/dist/viz/time-ticks.js +246 -0
  510. package/dist/viz/time-ticks.js.map +1 -0
  511. package/dist/viz/treemap.d.ts +61 -0
  512. package/dist/viz/treemap.d.ts.map +1 -0
  513. package/dist/viz/treemap.js +171 -0
  514. package/dist/viz/treemap.js.map +1 -0
  515. package/dist/viz/trend.d.ts +31 -0
  516. package/dist/viz/trend.d.ts.map +1 -0
  517. package/dist/viz/trend.js +130 -0
  518. package/dist/viz/trend.js.map +1 -0
  519. package/dist/viz-animations.css +40 -0
  520. package/dist/viz-rtl.css +31 -0
  521. package/package.json +146 -4
@@ -0,0 +1,41 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type PointTarget } from '../internal/viz/keyboard.js';
3
+ import type { ChartProps, ChartZoomRange } from './types.js';
4
+ export interface ChartState {
5
+ readonly width: number;
6
+ readonly height: number;
7
+ /** Hovered or focused point. */
8
+ readonly active: PointTarget | null;
9
+ readonly activeSource: 'pointer' | 'keyboard' | 'api' | null;
10
+ /** Crosshair position in drawing px. */
11
+ readonly pointer: {
12
+ readonly x: number;
13
+ readonly y: number;
14
+ } | null;
15
+ /** Transient zoom frame during a pan drag. */
16
+ readonly frame: ChartZoomRange | null;
17
+ /** Rubber-band selection in drawing px (`mode`: the constrained axes). */
18
+ readonly selecting: {
19
+ readonly x0: number;
20
+ readonly y0: number;
21
+ readonly x1: number;
22
+ readonly y1: number;
23
+ readonly mode: 'x' | 'y' | 'xy';
24
+ } | null;
25
+ /** Lasso outline in drawing px. */
26
+ readonly lasso: string | null;
27
+ /** Point drag preview. */
28
+ readonly dragPoint: {
29
+ readonly series: number;
30
+ readonly index: number;
31
+ readonly y: number;
32
+ } | null;
33
+ /** Zoom toolbar drag tool. */
34
+ readonly tool: 'zoom' | 'pan';
35
+ readonly legendPage: number;
36
+ readonly highlight: string | null;
37
+ /** Bumped by `api.appendPoints` (store-driven re-layout). */
38
+ readonly version: number;
39
+ }
40
+ export declare function Chart(props: ChartProps): ReactNode;
41
+ //# sourceMappingURL=Chart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/chart/Chart.tsx"],"names":[],"mappings":"AASA,OAAO,EAAsK,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAQ3M,OAAO,EAAiC,KAAK,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAc9F,OAAO,KAAK,EAAmG,UAAU,EAAgE,cAAc,EAAE,MAAM,YAAY,CAAC;AAM5N,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,YAAY,EAAE,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC;IAC7D,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACpE,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAAC;IACtC,0EAA0E;IAC1E,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACnJ,mCAAmC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,0BAA0B;IAC1B,QAAQ,CAAC,SAAS,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACnG,8BAA8B;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAgCD,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,CA6iBlD"}
@@ -0,0 +1,572 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // `Chart`: props compile to
4
+ // an id-keyed spec, the pure model lays it out for the stored size and zoom
5
+ // frame, `ChartSvg` draws it (or the lazy canvas layer draws the marks), and
6
+ // a store-driven overlay shows the tooltip, crosshair, focus ring and zoom
7
+ // selection. Pointer, wheel and drag transients live in the store and refs,
8
+ // never React state; committed changes go through the controlled triads.
9
+ import { Children, isValidElement, lazy, Suspense, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
10
+ import { lineHeight, nearestSorted, pct, textWidth } from '#viz';
11
+ import { useControllableState } from '@salmonui/core/internal/controllable';
12
+ import { useLocale, useLocaleText } from '@salmonui/core/internal/locale';
13
+ import { warnOnce } from '@salmonui/core/internal/dev';
14
+ import { useHydrated } from '@salmonui/core/internal/hydrated';
15
+ import { VizCanvas } from '../internal/viz/canvas.js';
16
+ import { NamedVizFigure, SENTENCE_END } from '../internal/viz/figure.js';
17
+ import { movePointFocus, plotKeyAction } from '../internal/viz/keyboard.js';
18
+ import { LegendButtons, LegendPager } from '../internal/viz/legend.js';
19
+ import { svgMarkup } from '../internal/viz/instance.js';
20
+ import { initialSize, useMeasuredSize } from '../internal/viz/size.js';
21
+ import { useVizSelector, useVizStore } from '../internal/viz/store.js';
22
+ import { ChartAxis, ChartSeries } from './ChartSeries.js';
23
+ import { useChartSync } from './ChartSyncGroup.js';
24
+ import { pluralOf } from '../internal/message.js';
25
+ import { buildModel, compileSpec, currentZoom, DEFAULT_TEXT, hideAxes, readField, seriesId } from './model.js';
26
+ import { ChartSvg } from './render.js';
27
+ const ZoomToolbar = lazy(() => import('./zoom-toolbar.js'));
28
+ const ChartOverlay = lazy(() => import('./overlay.js'));
29
+ const OVERLAY_TOOLS = { pointContext, nearestSorted, textWidth, lineHeight };
30
+ const ALL_TOOLS = ['zoom', 'zoomIn', 'zoomOut', 'pan', 'reset'];
31
+ const EMPTY = [];
32
+ const EMPTY_POINTS = [];
33
+ const EMPTY_ZOOM = {};
34
+ function collectChildren(children) {
35
+ const series = [];
36
+ const axes = [];
37
+ // Reading direct children's props is pure, so JSX series render on the server like the array form.
38
+ for (const child of Children.toArray(children)) {
39
+ if (!isValidElement(child))
40
+ continue;
41
+ if (child.type === ChartSeries)
42
+ series.push(child.props);
43
+ else if (child.type === ChartAxis) {
44
+ const p = child.props;
45
+ axes.push({ ...p, id: p.id ?? p.direction });
46
+ }
47
+ }
48
+ return { series, axes };
49
+ }
50
+ const toggle = (list, id) => (list.includes(id) ? list.filter((x) => x !== id) : [...list, id]);
51
+ function pointContext(m, index, datum, xField) {
52
+ return { seriesId: m.id, seriesName: m.name, index, datum: datum ?? {}, x: readField(datum, xField), y: m.yValue(index), xText: m.xText(index), yText: m.yText(index), color: m.color };
53
+ }
54
+ export function Chart(props) {
55
+ const uid = useId().replace(/:/g, '');
56
+ const store = useVizStore(() => ({
57
+ ...initialSize({ width: props.width, height: props.height ?? 300 }),
58
+ active: null,
59
+ activeSource: null,
60
+ pointer: null,
61
+ frame: null,
62
+ selecting: null,
63
+ lasso: null,
64
+ dragPoint: null,
65
+ tool: 'zoom',
66
+ legendPage: 0,
67
+ highlight: null,
68
+ version: 0,
69
+ }));
70
+ const surfaceRef = useRef(null);
71
+ const rootRef = useRef(null);
72
+ const plotRef = useRef(null);
73
+ const svgHost = useRef(null);
74
+ // without `height` the surface is a flex item of the root (300 px basis, filling a root whose height CSS
75
+ // fixes); the measured height relays out.
76
+ useMeasuredSize(surfaceRef, store, { width: props.width, height: props.height }, props.onResize);
77
+ const width = useVizSelector(store, (s) => s.width);
78
+ const height = useVizSelector(store, (s) => s.height);
79
+ const frameZoom = useVizSelector(store, (s) => s.frame);
80
+ const legendPage = useVizSelector(store, (s) => s.legendPage);
81
+ const highlightId = useVizSelector(store, (s) => s.highlight);
82
+ const tool = useVizSelector(store, (s) => s.tool);
83
+ const hydrated = useHydrated();
84
+ const version = useVizSelector(store, (s) => s.version);
85
+ const sync = useChartSync();
86
+ const ownSync = useVizStore(() => ({ x: null, source: null, zoom: null }));
87
+ const syncStore = sync?.store ?? ownSync;
88
+ const syncZoom = useVizSelector(syncStore, (s) => s.zoom);
89
+ const [hidden, setHidden] = useControllableState(props.hiddenSeries, props.defaultHiddenSeries ?? EMPTY, props.onHiddenSeriesChange, 'Chart hiddenSeries');
90
+ const [zoomRange, setZoomRange] = useControllableState(props.zoomRange, props.defaultZoomRange ?? EMPTY_ZOOM, props.onZoomRangeChange, 'Chart zoomRange');
91
+ const [selected, setSelected] = useControllableState(props.selectedPoints, props.defaultSelectedPoints ?? EMPTY_POINTS, props.onSelectedPointsChange, 'Chart selectedPoints');
92
+ // Streamed points (api.appendPoints) per series id, kept outside React state.
93
+ const appended = useRef(new Map());
94
+ // The chart's own text and locale over the nearest LocaleProvider's (the model reads them from the props).
95
+ const ownText = useLocaleText('chart', props.text);
96
+ const locale = useLocale(props.locale);
97
+ const children = useMemo(() => collectChildren(props.children), [props.children]);
98
+ const seriesList = useMemo(() => {
99
+ const list = [...(props.series ?? []), ...children.series];
100
+ if (version === 0 || appended.current.size === 0)
101
+ return list;
102
+ return list.map((s, i) => {
103
+ const id = seriesId(s, i);
104
+ const extra = appended.current.get(id);
105
+ if (!extra)
106
+ return s;
107
+ let data = [...(s.data ?? props.data ?? []), ...extra.points];
108
+ if (extra.maxPoints && data.length > extra.maxPoints)
109
+ data = data.slice(data.length - extra.maxPoints);
110
+ return { ...s, data };
111
+ });
112
+ }, [props.series, props.data, children.series, version]);
113
+ // One object per props, text, locale and child axes, so the model memo holds across store-only renders.
114
+ const effectiveProps = useMemo(() => {
115
+ const own = { ...props, text: ownText, locale };
116
+ return children.axes.length ? { ...own, xAxis: { ...props.xAxis, ...children.axes.find((a) => a.id === 'x') }, yAxis: { ...props.yAxis, ...children.axes.find((a) => a.id === 'y') }, axes: [...(props.axes ?? []), ...children.axes.filter((a) => a.id !== 'x' && a.id !== 'y')] } : own;
117
+ }, [props, ownText, locale, children.axes]);
118
+ const hiddenSet = useMemo(() => new Set(hidden), [hidden]);
119
+ const spec = useMemo(() => compileSpec(effectiveProps, seriesList, hiddenSet), [effectiveProps.data, effectiveProps.xAxis, effectiveProps.yAxis, effectiveProps.axes, effectiveProps.orientation, effectiveProps.palette, seriesList, hiddenSet]); // eslint-disable-line react-hooks/exhaustive-deps
120
+ const zoom = frameZoom ?? (sync?.zoom && syncZoom ? { ...zoomRange, x: syncZoom } : zoomRange);
121
+ // Polar and radar: the opt-in `polar` feature of `@salmonui/charts/chart/features`.
122
+ const polarOn = props.coordinate === 'polar' || props.coordinate === 'radar';
123
+ const polar = polarOn ? (props.features?.find((f) => f.name === 'polar')?.layout ?? null) : null;
124
+ // Technical indicators: the opt-in `@salmonui/charts/chart/indicators` feature.
125
+ const indicatorLayout = props.features?.find((f) => f.name === 'indicators')?.layout ?? null;
126
+ const model = useMemo(() => (polar ? polar(effectiveProps, spec, { width, height, zoom }) : buildModel(effectiveProps, polarOn ? hideAxes(spec, []) : spec, { width, height, zoom }, indicatorLayout)), [spec, width, height, zoom, effectiveProps, polar, polarOn, indicatorLayout]);
127
+ const tooltipOpt = props.tooltip === false ? null : typeof props.tooltip === 'object' ? props.tooltip : {};
128
+ const sharedTooltip = tooltipOpt?.mode === 'shared' || tooltipOpt?.mode === 'split' || Boolean(props.crosshair && typeof props.crosshair === 'object' && props.crosshair.snap);
129
+ const zoomOpt = props.zoom ? (typeof props.zoom === 'object' ? props.zoom : { wheel: true, selection: true, pan: true }) : null;
130
+ const legendOpt = typeof props.legend === 'object' ? props.legend : {};
131
+ // Point, range and gradient legends are keys: only series items toggle.
132
+ const legendToggle = legendOpt.toggle !== false && (legendOpt.mode ?? 'series') === 'series';
133
+ const text = { ...DEFAULT_TEXT, ...ownText };
134
+ const renderer = props.renderer ?? 'svg';
135
+ const canvas = renderer === 'canvas' || (renderer === 'auto' && model.drawnPoints > 20_000);
136
+ const selectedKeys = useMemo(() => new Set(selected.map((p) => `${p.seriesId}:${p.index}`)), [selected]);
137
+ const dimmed = useMemo(() => {
138
+ const out = new Set();
139
+ if (highlightId && (legendOpt.highlight !== false || props.highlight === 'series'))
140
+ for (const s of model.series)
141
+ if (s.id !== highlightId)
142
+ out.add(s.id);
143
+ return out;
144
+ }, [highlightId, model, legendOpt.highlight, props.highlight]);
145
+ // Custom markers and labels: SVG content from the series options, per drawn point.
146
+ const customPoints = seriesList.some((s) => s.renderMarker || (typeof s.labels === 'object' && s.labels.render));
147
+ const pointContent = customPoints
148
+ ? (kind, id, index) => {
149
+ const opt = spec.series.find((c) => c.id === id)?.options;
150
+ const fn = kind === 'marker' ? opt?.renderMarker : typeof opt?.labels === 'object' ? opt.labels.render : undefined;
151
+ const m = model.series.find((x) => x.id === id);
152
+ return fn && m ? fn(pointContext(m, index, datumOf(m, index), opt?.xField)) : undefined;
153
+ }
154
+ : undefined;
155
+ const legendItems = model.legend.map((l) => ({ id: l.id, label: l.label, color: l.color, shape: l.shape === 'gradient' ? 'rectangle' : l.shape, hidden: l.hidden, lineStyle: l.lineStyle }));
156
+ // Custom legend content and the gradient key: HTML over the item boxes, in place of the drawn item.
157
+ const legendContent = model.legend.map((l) => legendOpt.renderItem ? (legendOpt.renderItem({ id: l.id, label: l.label, color: l.color, hidden: l.hidden, seriesId: l.seriesId, index: l.index })) : l.shape === 'gradient' ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "salmon-chart-gradient-key", style: { background: `linear-gradient(to right, ${(l.stops ?? []).join(', ')})` } }), l.label] })) : undefined);
158
+ const customLegend = new Set(legendContent.flatMap((x, i) => (x === undefined ? [] : [i])));
159
+ const xFieldOf = (m) => seriesList.find((s, i) => seriesId(s, i) === m.id)?.xField;
160
+ const datumOf = (m, index) => spec.series.find((s) => s.id === m.id)?.data[index];
161
+ // --- latest values for event handlers (no stale closures, no re-subscription) ---
162
+ const latest = useRef({ model, props, zoomRange, selected, hidden, syncSelection: null });
163
+ useEffect(() => {
164
+ latest.current = { ...latest.current, model, props, zoomRange, selected, hidden };
165
+ // Development checks of the opt-in features (production drops them, leaving no empty effect).
166
+ if (process.env.NODE_ENV !== 'production') {
167
+ if (polarOn && !polar)
168
+ warnOnce('chart-polar', 'Chart coordinate="polar" or "radar" needs features={[polar]} from @salmonui/charts/chart/features.');
169
+ if (effectiveProps.indicators?.length && !indicatorLayout)
170
+ warnOnce('chart-indicators', 'Chart indicators need features={[technicalIndicators]} from @salmonui/charts/chart/indicators.');
171
+ }
172
+ });
173
+ // Hit-testing lives in the overlay chunk (pointer events only arrive after hydration, when it loads).
174
+ const hover = useRef(null);
175
+ useEffect(() => {
176
+ if (hydrated && !hover.current)
177
+ void import('./overlay.js').then((m) => {
178
+ hover.current = m;
179
+ });
180
+ }, [hydrated]);
181
+ const hitPoint = (m, x, y, shared) => hover.current?.hitPoint(m, x, y, shared, nearestSorted) ?? null;
182
+ // Entrance and update transitions: CSS keyed on `data-animate`, set after hydration only, so the server
183
+ // markup and the first client render match and reduced motion turns them off in CSS.
184
+ // Path transitions start once the entrance is over, so the first measured relayout does not slide.
185
+ useEffect(() => {
186
+ const el = rootRef.current;
187
+ if (!el || props.animated === false)
188
+ return el?.removeAttribute('data-animate');
189
+ el.setAttribute('data-animate', '');
190
+ const t = setTimeout(() => el.setAttribute('data-animate', 'update'), 700);
191
+ return () => clearTimeout(t);
192
+ }, [props.animated]);
193
+ // Committed visible ranges: reported after the commit, never per drag frame.
194
+ const visibleRanges = useRef(null);
195
+ useEffect(() => {
196
+ if (!props.onVisibleRangeChange || frameZoom)
197
+ return;
198
+ const prev = visibleRanges.current;
199
+ const next = {};
200
+ for (const [axisId, range] of Object.entries(currentZoom(model))) {
201
+ next[axisId] = `${range[0]}:${range[1]}`;
202
+ if (prev && prev[axisId] !== next[axisId])
203
+ props.onVisibleRangeChange({ axisId, range });
204
+ }
205
+ visibleRanges.current = next;
206
+ });
207
+ // Point and cluster highlight: fades the other marks through a DOM attribute, no React render.
208
+ useEffect(() => {
209
+ if (props.highlight !== 'point' && props.highlight !== 'cluster')
210
+ return;
211
+ return store.subscribe(() => {
212
+ const a = store.get().active;
213
+ const m = latest.current.model;
214
+ const id = a ? m.series[a.series]?.id : undefined;
215
+ for (const el of svgHost.current?.querySelectorAll('.salmon-viz-mark[data-index]') ?? []) {
216
+ const keep = !a || (Number(el.dataset['index']) === a.index && (props.highlight === 'cluster' || el.closest('[data-series]')?.getAttribute('data-series') === id));
217
+ if (keep)
218
+ el.removeAttribute('data-faded');
219
+ else
220
+ el.setAttribute('data-faded', '');
221
+ }
222
+ });
223
+ }, [store, props.highlight]);
224
+ const toDrawing = (clientX, clientY) => {
225
+ const el = surfaceRef.current;
226
+ if (!el)
227
+ return null;
228
+ const r = el.getBoundingClientRect();
229
+ if (r.width === 0)
230
+ return null;
231
+ const k = latest.current.model.width / r.width;
232
+ return { x: (clientX - r.left) * k, y: (clientY - r.top) * k };
233
+ };
234
+ const setActive = (target, source) => {
235
+ const prev = store.get().active;
236
+ if (prev?.series === target?.series && prev?.index === target?.index && store.get().activeSource === source)
237
+ return;
238
+ store.set({ active: target, activeSource: target ? source : null });
239
+ const m = latest.current.model;
240
+ const s = target ? m.series[target.series] : undefined;
241
+ if (sync && s && target) {
242
+ const xValue = m.horizontal ? s.py[target.index] : s.px[target.index];
243
+ sync.store.set({ x: invertX(m, xValue), source: uid });
244
+ }
245
+ else if (sync && !target && sync.store.get().source === uid)
246
+ sync.store.set({ x: null, source: null });
247
+ props.onPointHover?.(s && target ? pointContext(s, target.index, datumOf(s, target.index), xFieldOf(s)) : null);
248
+ };
249
+ // Drag, wheel and pinch interactions live in a lazy chunk, loaded after hydration when a feature needs it.
250
+ const selOpt = typeof props.selection === 'object' ? props.selection : {};
251
+ const dragSel = selOpt.mode === 'range' || selOpt.mode === 'lasso';
252
+ const interactive = Boolean(zoomOpt || dragSel || props.onPointChange);
253
+ const fx = useRef(null);
254
+ useEffect(() => {
255
+ const ready = (create) => {
256
+ fx.current ??= create();
257
+ plotRef.current?.setAttribute('data-interactive', '');
258
+ };
259
+ const pre = props.features?.find((f) => f.name === 'interactions');
260
+ if (interactive && !fx.current) {
261
+ if (pre?.create)
262
+ ready(pre.create);
263
+ else
264
+ void import('./interact.js').then((m) => ready(m.createInteractions));
265
+ }
266
+ }, [interactive]);
267
+ const ctx = () => {
268
+ const l = latest.current;
269
+ return {
270
+ store,
271
+ model: l.model,
272
+ props: l.props,
273
+ series: seriesList,
274
+ yAxisOf: (id) => spec.series.find((c) => c.id === id)?.yAxis,
275
+ zoomed: Object.keys(l.zoomRange).length > 0,
276
+ zoom: zoomOpt,
277
+ host: svgHost.current,
278
+ toDrawing,
279
+ hit: (x, y) => hitPoint(l.model, x, y, false),
280
+ commitZoom,
281
+ select: (points, reason) => commitSelection(points, { source: 'pointer', reason }),
282
+ };
283
+ };
284
+ const onPointerMove = (event) => {
285
+ if (fx.current?.move(ctx(), event))
286
+ return;
287
+ const p = toDrawing(event.clientX, event.clientY);
288
+ if (!p)
289
+ return;
290
+ // A moving touch cancels a pending long press.
291
+ if (press.current && Math.hypot(p.x - press.current.x, p.y - press.current.y) > 10)
292
+ clearTimeout(press.current.t);
293
+ const m = latest.current.model;
294
+ if (props.onPlotPointerMove)
295
+ props.onPlotPointerMove(hover.current?.plotPoint(m, p) ?? { ...p, xValue: undefined, yValue: undefined }, event);
296
+ if (event.pointerType === 'touch')
297
+ return;
298
+ store.set({ pointer: p });
299
+ if (tooltipOpt || props.crosshair || props.onPointHover || props.highlight === 'point' || props.highlight === 'cluster')
300
+ setActive(hitPoint(latest.current.model, p.x, p.y, sharedTooltip), 'pointer');
301
+ };
302
+ const onPointerLeave = () => {
303
+ if (store.get().selecting || store.get().dragPoint || store.get().lasso || store.get().frame)
304
+ return;
305
+ store.set({ pointer: null });
306
+ if (store.get().activeSource === 'pointer')
307
+ setActive(null, null);
308
+ };
309
+ const commitSelection = (points, event) => {
310
+ setSelected(points, event);
311
+ if (sync?.selection)
312
+ sync.store.set({ selection: { source: uid, indices: [...new Set(points.map((p) => p.index))] } });
313
+ };
314
+ useEffect(() => {
315
+ if (!sync?.selection || !props.selection)
316
+ return;
317
+ return sync.store.subscribe(() => {
318
+ const sel = sync.store.get().selection;
319
+ // Hover writes the same store: act on a new selection object only.
320
+ if (!sel || sel.source === uid || sel === latest.current.syncSelection)
321
+ return;
322
+ latest.current.syncSelection = sel;
323
+ const points = latest.current.model.series.filter((s) => !s.hidden).flatMap((s) => sel.indices.filter((i) => i < s.count).map((index) => ({ seriesId: s.id, index })));
324
+ setSelected(points, { source: 'api', reason: 'sync' });
325
+ });
326
+ }, [sync, props.selection]); // eslint-disable-line react-hooks/exhaustive-deps
327
+ const commitZoom = (range, reason, source) => {
328
+ setZoomRange(range, { source, reason });
329
+ if (sync?.zoom)
330
+ sync.store.set({ zoom: range.x ? [range.x[0], range.x[1]] : null });
331
+ };
332
+ // Wheel zoom needs a non-passive listener to keep the page from scrolling.
333
+ useEffect(() => {
334
+ const el = plotRef.current;
335
+ if (!el || !zoomOpt || zoomOpt.wheel === false)
336
+ return;
337
+ const onWheel = (event) => fx.current?.wheel(ctx(), event);
338
+ el.addEventListener('wheel', onWheel, { passive: false });
339
+ return () => el.removeEventListener('wheel', onWheel);
340
+ });
341
+ // Touch: a long press shows the tooltip of the nearest point; moving the finger cancels it.
342
+ const press = useRef(null);
343
+ const onPointerDown = (event) => {
344
+ fx.current?.down(ctx(), event);
345
+ const p = event.pointerType === 'touch' && toDrawing(event.clientX, event.clientY);
346
+ if (!p || !tooltipOpt)
347
+ return;
348
+ if (press.current)
349
+ clearTimeout(press.current.t);
350
+ press.current = {
351
+ ...p,
352
+ t: setTimeout(() => {
353
+ store.set({ pointer: p });
354
+ setActive(hitPoint(latest.current.model, p.x, p.y, sharedTooltip), 'pointer');
355
+ }, 500),
356
+ };
357
+ };
358
+ const onClick = (event) => {
359
+ const p = toDrawing(event.clientX, event.clientY);
360
+ if (!p)
361
+ return;
362
+ const m = latest.current.model;
363
+ // Plot clicks with data coordinates.
364
+ if (props.onPlotClick)
365
+ props.onPlotClick(hover.current?.plotPoint(m, p) ?? { ...p, xValue: undefined, yValue: undefined }, event);
366
+ const hit = hitPoint(m, p.x, p.y, false);
367
+ if (!hit)
368
+ return;
369
+ const s = m.series[hit.series];
370
+ if (!s)
371
+ return;
372
+ props.onPointClick?.(pointContext(s, hit.index, datumOf(s, hit.index), xFieldOf(s)), event);
373
+ if (props.selection && !dragSel)
374
+ selectPoint(s.id, hit.index, event.ctrlKey || event.metaKey, 'pointer', 'click');
375
+ };
376
+ // Axis label and label-group clicks: the drawn text carries its tick index.
377
+ const onDrawingClick = (event) => {
378
+ const t = event.target;
379
+ const axis = latest.current.model.axes.find((a) => a.id === t.closest('[data-axis]')?.getAttribute('data-axis'));
380
+ const tick = t.closest('[data-tick]');
381
+ const group = t.closest('[data-group]')?.getAttribute('data-group');
382
+ if (!axis)
383
+ return;
384
+ if (tick) {
385
+ const k = Number(tick.getAttribute('data-tick'));
386
+ const at = axis.ticks[k];
387
+ if (at)
388
+ props.onAxisLabelClick?.({ axisId: axis.id, value: axis.scale.kind === 'category' || axis.scale.kind === 'timeCategory' ? axis.scale.domain[at.value] : axis.scale.kind === 'time' ? new Date(at.value) : at.value, text: at.text.join(' '), index: k }, event);
389
+ }
390
+ else if (group) {
391
+ const [g, l] = group.split('-').map(Number);
392
+ props.onAxisLabelGroupClick?.({ axisId: axis.id, group: g, level: l, label: axis.options.labelGroups?.[g]?.levels[l]?.label ?? '' }, event);
393
+ }
394
+ };
395
+ const selectPoint = (seriesIdValue, index, additive, source, reason) => {
396
+ const opt = typeof props.selection === 'object' ? props.selection : {};
397
+ const cur = latest.current.selected;
398
+ const m = latest.current.model;
399
+ let next;
400
+ if (opt.mode === 'cluster') {
401
+ // Every visible series' point at the same index.
402
+ const all = m.series.filter((x) => !x.hidden && index < x.count).map((x) => ({ seriesId: x.id, index }));
403
+ next = cur.some((p) => p.index === index) ? cur.filter((p) => p.index !== index) : opt.multiple || additive ? [...cur, ...all] : all;
404
+ }
405
+ else if (opt.mode === 'series') {
406
+ const s = m.series.find((x) => x.id === seriesIdValue);
407
+ const all = Array.from({ length: s?.count ?? 0 }, (_, i) => ({ seriesId: seriesIdValue, index: i }));
408
+ next = cur.some((p) => p.seriesId === seriesIdValue) ? cur.filter((p) => p.seriesId !== seriesIdValue) : opt.multiple || additive ? [...cur, ...all] : all;
409
+ }
410
+ else {
411
+ const exists = cur.some((p) => p.seriesId === seriesIdValue && p.index === index);
412
+ next = exists ? cur.filter((p) => !(p.seriesId === seriesIdValue && p.index === index)) : opt.multiple || additive ? [...cur, { seriesId: seriesIdValue, index }] : [{ seriesId: seriesIdValue, index }];
413
+ }
414
+ commitSelection(next, { source, reason });
415
+ };
416
+ const onKeyDown = (event) => {
417
+ const m = latest.current.model;
418
+ if (fx.current?.key(ctx(), event))
419
+ return;
420
+ const action = plotKeyAction(event.key, { horizontal: m.horizontal, zoom: Boolean(zoomOpt) });
421
+ if (!action)
422
+ return;
423
+ event.preventDefault();
424
+ const state = store.get();
425
+ if (action === 'escape') {
426
+ setActive(null, null);
427
+ return;
428
+ }
429
+ if (action === 'zoomIn' || action === 'zoomOut') {
430
+ fx.current?.zoomBy(ctx(), action === 'zoomIn' ? 0.8 : 1.25, 'keyboard', 'keyboard');
431
+ return;
432
+ }
433
+ if (action === 'zoomReset') {
434
+ commitZoom({}, 'reset', 'keyboard');
435
+ return;
436
+ }
437
+ if (action === 'select') {
438
+ const a = state.active;
439
+ const s = a ? m.series[a.series] : undefined;
440
+ if (a && s && props.selection)
441
+ selectPoint(s.id, a.index, event.ctrlKey || event.metaKey, 'keyboard', 'keyboard');
442
+ return;
443
+ }
444
+ const counts = m.series.map((s) => (s.hidden || !s.tooltip ? 0 : s.count));
445
+ setActive(movePointFocus(state.active, action, counts), 'keyboard');
446
+ };
447
+ const onLegendToggle = (id, event) => {
448
+ if (!legendToggle)
449
+ return;
450
+ setHidden(toggle(latest.current.hidden, id), { source: event.type === 'click' && event.detail === 0 ? 'keyboard' : 'pointer', reason: 'legend' });
451
+ };
452
+ // Export: one lazy chunk, `export-data.ts`: images and print, CSV through the core writer, XLSX and
453
+ // PDF through `exportWriters`.
454
+ const runExport = (method, arg) => import('../internal/viz/export-data.js').then((m) => m.runImage(rootRef.current, method, arg, latest.current.props.title ?? text.chart));
455
+ const api = {
456
+ get element() {
457
+ return rootRef.current;
458
+ },
459
+ export: (options = {}) => import('../internal/viz/export-data.js').then((m) => m.exportDocument(rootRef.current, latest.current.model.table, latest.current.props.exportWriters, options, latest.current.props.title ?? text.chart, 'chart')),
460
+ toBlob: (format) => runExport('toBlob', format),
461
+ toDataURL: (format) => runExport('toDataURL', format),
462
+ // synchronous on every family.
463
+ toSVGString: () => svgMarkup(svgHost.current?.querySelector('svg')),
464
+ print: () => runExport('print'),
465
+ focus() {
466
+ plotRef.current?.focus();
467
+ },
468
+ resetZoom() {
469
+ commitZoom({}, 'reset', 'api');
470
+ },
471
+ showTooltip(point) {
472
+ const si = latest.current.model.series.findIndex((s) => s.id === point.seriesId);
473
+ if (si >= 0)
474
+ setActive({ series: si, index: point.index }, 'api');
475
+ },
476
+ hideTooltip() {
477
+ setActive(null, null);
478
+ },
479
+ showCrosshair(at) {
480
+ // The overlay chunk resolves the position (it is loaded after hydration, before any API call can show a crosshair).
481
+ const m = latest.current.model;
482
+ const hit = hover.current?.crosshairAt(m, at);
483
+ if (!hit)
484
+ return;
485
+ store.set({ pointer: hit.pointer });
486
+ if (hit.target)
487
+ setActive(hit.target, 'api');
488
+ },
489
+ hideCrosshair() {
490
+ store.set({ pointer: null });
491
+ if (store.get().activeSource === 'api')
492
+ setActive(null, null);
493
+ },
494
+ appendPoints(id, points, options) {
495
+ const cur = appended.current.get(id) ?? { points: [] };
496
+ let next = [...cur.points, ...points];
497
+ if (options?.maxPoints && next.length > options.maxPoints)
498
+ next = next.slice(next.length - options.maxPoints);
499
+ appended.current.set(id, { points: next, maxPoints: options?.maxPoints });
500
+ store.set({ version: store.get().version + 1 });
501
+ },
502
+ };
503
+ useImperativeHandle(props.ref, () => api);
504
+ // an application name wins over `title` and the summary, on the figure and the focusable plot.
505
+ const labelledBy = props['aria-labelledby'] || undefined;
506
+ const label = labelledBy ? undefined : props['aria-label'] || undefined;
507
+ const plot = model.plot;
508
+ const canvasMarks = canvas
509
+ ? model.series.flatMap((s) => (s.hidden ? [] : s.marks.map((m) => ({ d: m.d, fill: m.fill, stroke: m.stroke, strokeWidth: m.strokeWidth, opacity: m.opacity, dash: m.dash ? m.dash.split(' ').map(Number) : undefined }))))
510
+ : [];
511
+ return (_jsxs(NamedVizFigure, { family: "salmon-chart", className: props.className, style: props.style, rootRef: rootRef, surfaceRef: surfaceRef, surfaceStyle: { ...(props.height ? { height, flex: 'none' } : {}), ...(props.width ? { width: props.width } : {}) }, idBase: uid, title: props.title, subtitle: props.subtitle, summary: model.summary, table: model.table, showTable: props.showDataTable, tableSummary: (n) => text.moreRows(n, pluralOf(n, locale)), announcement: _jsx(ChartAnnouncer, { store: store, model: model }), naming: labelledBy || label ? { 'aria-labelledby': labelledBy, 'aria-label': label } : undefined, extra: { onClick: props.onClick, onDoubleClick: props.onDoubleClick, onContextMenu: props.onContextMenu, onPointerDown: props.onPointerDown, onPointerUp: props.onPointerUp, onPointerMove: props.onPointerMove, onPointerLeave: props.onPointerLeave }, children: [_jsx("div", { ref: svgHost, className: "salmon-chart-drawing", onClick: props.onAxisLabelClick || props.onAxisLabelGroupClick ? onDrawingClick : undefined, children: _jsx(ChartSvg, { model: model, clipId: `${uid}-clip`, canvas: canvas, legendItems: legendItems, legendPage: legendPage, selected: selectedKeys, dimmed: dimmed, highlighted: highlightId, emptyText: polarOn && !polar ? '' : text.noData, renderEmpty: props.renderEmpty, pointContent: pointContent, legendCustom: customLegend }) }), canvas ? (_jsx("div", { className: "salmon-viz-canvas", style: { left: pct(plot.x - 1, model.width), top: pct(plot.y - 1, model.height), width: pct(plot.width + 2, model.width), height: pct(plot.height + 2, model.height) }, children: _jsx(VizCanvas, { marks: canvasMarks, originX: plot.x - 1, originY: plot.y - 1, width: Math.ceil(plot.width + 2), height: Math.ceil(plot.height + 2), className: "salmon-chart-canvas" }) })) : null, model.empty && props.renderEmpty ? (_jsx("div", { className: "salmon-chart-empty", style: { left: pct(plot.x, model.width), top: pct(plot.y, model.height), width: pct(plot.width, model.width), height: pct(plot.height, model.height) }, children: props.renderEmpty() })) : null, hydrated ? (_jsx(Suspense, { fallback: null, children: _jsx(ChartOverlay, { store: store, syncStore: syncStore, model: model, tooltip: tooltipOpt, crosshair: props.crosshair, shared: sharedTooltip, sync: sync, uid: uid, datumOf: datumOf, xFieldOf: xFieldOf, tools: OVERLAY_TOOLS }) })) : null, _jsx("div", { ref: plotRef, className: "salmon-viz-plot", role: "group", "aria-roledescription": text.chart.toLowerCase(), "aria-labelledby": labelledBy, "aria-label": labelledBy ? undefined : (label ?? props.title ?? model.summary.split(SENTENCE_END)[0]), "aria-describedby": `${uid}-summary`, tabIndex: 0, style: { left: pct(plot.x, model.width), top: pct(plot.y, model.height), width: pct(plot.width, model.width), height: pct(plot.height, model.height), touchAction: interactive ? 'none' : 'pan-y', cursor: zoomOpt || dragSel ? 'crosshair' : undefined }, onPointerMove: onPointerMove, onPointerLeave: onPointerLeave, onPointerDown: onPointerDown, onPointerUp: (event) => {
512
+ if (press.current)
513
+ clearTimeout(press.current.t);
514
+ fx.current?.up(ctx(), event);
515
+ }, onPointerCancel: (event) => fx.current?.up(ctx(), event), onClick: onClick, onDoubleClick: props.onPointDoubleClick
516
+ ? (event) => {
517
+ const p = toDrawing(event.clientX, event.clientY);
518
+ const m = latest.current.model;
519
+ const hit = p && hitPoint(m, p.x, p.y, false);
520
+ const s = hit ? m.series[hit.series] : undefined;
521
+ if (hit && s)
522
+ props.onPointDoubleClick?.(pointContext(s, hit.index, datumOf(s, hit.index), xFieldOf(s)), event);
523
+ }
524
+ : undefined, onKeyDown: onKeyDown, onBlur: () => {
525
+ if (store.get().activeSource === 'keyboard')
526
+ setActive(null, null);
527
+ } }), (props.annotations ?? []).map((a, i) => (_jsx(ChartAnnotationView, { model: model, annotation: a }, i))), hydrated && zoomOpt?.toolbar ? (_jsx(Suspense, { fallback: null, children: _jsx(ZoomToolbar, { tools: zoomOpt.toolbar === true ? ALL_TOOLS : zoomOpt.toolbar, tool: tool, zoomed: Object.keys(zoomRange).length > 0, position: zoomOpt.toolbarPosition ?? 'topEnd', text: text, onTool: (t) => store.set({ tool: t }), onZoom: (f) => fx.current?.zoomBy(ctx(), f, 'toolbar', 'pointer'), onReset: () => commitZoom({}, 'reset', 'pointer') }) })) : null, model.frame.legend && customLegend.size
528
+ ? model.frame.legend.items.map((b) => customLegend.has(b.index) && b.page === legendPage ? (_jsx("span", { className: "salmon-chart-legend-content", "aria-hidden": "true", style: { left: pct(b.x, model.width), top: pct(b.y, model.height), width: pct(b.width, model.width), height: pct(b.height, model.height) }, children: legendContent[b.index] }, b.index)) : null)
529
+ : null, model.frame.legend ? (_jsx(LegendButtons
530
+ // A one-column top or bottom legend (`orientation: 'vertical'`) takes the vertical keyboard model of a side legend.
531
+ , {
532
+ // A one-column top or bottom legend (`orientation: 'vertical'`) takes the vertical keyboard model of a side legend.
533
+ layout: legendOpt.orientation === 'vertical' ? { ...model.frame.legend, position: 'start' } : model.frame.legend, items: legendItems, width: model.width, height: model.height, page: legendPage, label: legendOpt.title ?? text.legend, toggle: legendToggle, onToggle: onLegendToggle, onHighlight: (id) => store.set({ highlight: id }), children: _jsx(LegendPager, { layout: model.frame.legend, width: model.width, height: model.height, page: legendPage, text: text, onPage: (page) => store.set({ legendPage: page }) }) })) : null] }));
534
+ }
535
+ function invertX(model, pixel) {
536
+ const a = model.axes.find((x) => x.id === model.xAxisId);
537
+ if (!a)
538
+ return pixel;
539
+ return a.scale.invert(pixel);
540
+ }
541
+ /** Live region text for the keyboard-focused point. */
542
+ function ChartAnnouncer({ store, model }) {
543
+ const active = useVizSelector(store, (s) => (s.activeSource === 'keyboard' ? s.active : null));
544
+ if (!active)
545
+ return null;
546
+ const s = model.series[active.series];
547
+ if (!s)
548
+ return null;
549
+ return model.pointText(s, active.index);
550
+ }
551
+ function ChartAnnotationView({ model, annotation }) {
552
+ let x;
553
+ let y;
554
+ if (annotation.units === 'pixel') {
555
+ x = Number(annotation.x);
556
+ y = annotation.y;
557
+ }
558
+ else {
559
+ const xa = model.axes.find((a) => a.id === (annotation.xAxis ?? 'x'));
560
+ const ya = model.axes.find((a) => a.id === (annotation.yAxis ?? 'y'));
561
+ if (!xa || !ya)
562
+ return null;
563
+ const xv = xa.scale.kind === 'category' || xa.scale.kind === 'timeCategory' ? Math.max(0, xa.scale.domain.indexOf(String(annotation.x))) : annotation.x instanceof Date ? annotation.x.getTime() : Number(annotation.x);
564
+ const px = xa.scale.map(xv);
565
+ const py = ya.scale.map(annotation.y);
566
+ [x, y] = model.horizontal ? [py, px] : [px, py];
567
+ }
568
+ if (!Number.isFinite(x) || !Number.isFinite(y))
569
+ return null;
570
+ return (_jsx("div", { className: "salmon-chart-annotation", style: { left: pct(x, model.width), top: pct(y, model.height) }, children: annotation.content }));
571
+ }
572
+ //# sourceMappingURL=Chart.js.map