@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,1300 @@
1
+ // Chart model: props are
2
+ // compiled into an id-keyed spec and laid out by a pure function of
3
+ // (spec, size, view state). No React, no DOM: the server renders from the
4
+ // same model as the client's first render, and tests assert it directly.
5
+ import { aggregateOhlc, areaPath, bandScale, binPoints, boxPlotStats, createScale, decimateLine, errorBarExtents, fillEmpty, histogramBins, FRAME_PADDING, layoutFrame, lineHeight, linePath, n2, normalCurve, paretoOrder, seriesColor, planHorizontalLabels, planVerticalLabels, resolveLabelOverlaps, rectPath, resolveDomain, SEMANTIC, seriesStats, stack, symbolPath, tableModel, textWidth, trendOf, trendlinePoints, truncateText, visibleRange, waterfall, TICK_SIZE, LABEL_GAP, } from '#viz';
6
+ import { formatMessage } from '../internal/message.js';
7
+ import { readField } from '../internal/viz/fields.js';
8
+ import { makeNumberFormat, makeTimeFormat } from '../internal/viz/format.js';
9
+ export { readField };
10
+ export const DEFAULT_TEXT = {
11
+ chart: 'Chart',
12
+ noData: 'No data',
13
+ legend: 'Legend',
14
+ table: 'Chart data',
15
+ moreRows: ((n) => `${n} more rows not shown`),
16
+ zoomToolbar: 'Zoom',
17
+ zoomTool: 'Select to zoom',
18
+ zoomIn: 'Zoom in',
19
+ zoomOut: 'Zoom out',
20
+ pan: 'Pan',
21
+ resetZoom: 'Reset zoom',
22
+ previousLegendPage: 'Previous legend page',
23
+ nextLegendPage: 'Next legend page',
24
+ line: 'Line chart',
25
+ area: 'Area chart',
26
+ column: 'Column chart',
27
+ bar: 'Bar chart',
28
+ scatter: 'Scatter chart',
29
+ bubble: 'Bubble chart',
30
+ hilo: 'High-low chart',
31
+ ohlc: 'Open-high-low-close chart',
32
+ candle: 'Candlestick chart',
33
+ waterfall: 'Waterfall chart',
34
+ histogram: 'Histogram chart',
35
+ boxPlot: 'Box plot chart',
36
+ pareto: 'Pareto chart',
37
+ bullet: 'Bullet chart',
38
+ summary: '{chart}, {count} series.',
39
+ summaryRange: '{chart}, {count} series, {axis} from {from} to {to}.',
40
+ summaryEmpty: '{chart}. {noData}.',
41
+ up: 'trending up',
42
+ down: 'trending down',
43
+ flat: 'flat',
44
+ xAxis: 'x',
45
+ point: '{series}, {x}: {value}. {index} of {count}.',
46
+ open: 'O {value}',
47
+ high: 'H {value}',
48
+ low: 'L {value}',
49
+ close: 'C {value}',
50
+ volume: 'V {value}',
51
+ box: 'min {min}, Q1 {q1}, median {median}, Q3 {q3}, max {max}',
52
+ trendline: '{series} {kind}',
53
+ };
54
+ // ---------------------------------------------------------------------------
55
+ // Field access
56
+ // ---------------------------------------------------------------------------
57
+ const PRICES = ['open', 'high', 'low', 'close'];
58
+ const toNumber = (v) => {
59
+ if (typeof v === 'number')
60
+ return v;
61
+ if (v instanceof Date)
62
+ return v.getTime();
63
+ if (typeof v === 'string' && v.trim() !== '')
64
+ return Number(v);
65
+ return Number.NaN;
66
+ };
67
+ const ISO = /^\d{4}-\d{2}-\d{2}([T ][\d:.]+)?(Z|[+-]\d{2}:?\d{2})?$/;
68
+ const isDateLike = (v) => v instanceof Date || (typeof v === 'string' && ISO.test(v));
69
+ const toTime = (v) => (v instanceof Date ? v.getTime() : typeof v === 'string' ? Date.parse(v.length === 10 ? `${v}T00:00:00Z` : v) : toNumber(v));
70
+ /** @internal The id of series `i`: its `id`, `name` or `yField`, else `series-<i>`. */
71
+ export const seriesId = (s, i) => s.id ?? s.name ?? s.yField ?? `series-${i}`;
72
+ /** Normalizes series options into columns. `hidden` is the effective hidden-series set. */
73
+ export function compileSpec(props, seriesList, hidden) {
74
+ const xOpt = props.xAxis ?? {};
75
+ const yOpt = props.yAxis ?? {};
76
+ const allBars = seriesList.length > 0 && seriesList.every((s) => (s.type ?? 'line') === 'bar');
77
+ const horizontal = props.orientation === 'horizontal' || allBars;
78
+ const axisDefs = new Map();
79
+ axisDefs.set('x', { direction: 'x', options: { ...xOpt, id: 'x' } });
80
+ axisDefs.set('y', { direction: 'y', options: { ...yOpt, id: 'y' } });
81
+ for (const a of props.axes ?? [])
82
+ axisDefs.set(a.id, { direction: a.direction, options: a });
83
+ // Categories and x scale kind per x axis.
84
+ const categories = new Map();
85
+ const kinds = new Map();
86
+ const ids = new Set();
87
+ const ordered = seriesList.map((s, i) => ({ s, i })).sort((a, b) => (a.s.order ?? 0) - (b.s.order ?? 0) || a.i - b.i);
88
+ for (const { s } of ordered) {
89
+ const axisId = s.xAxis ?? 'x';
90
+ const def = axisDefs.get(axisId) ?? axisDefs.get('x');
91
+ let kind = kinds.get(axisId) ?? def?.options.scale;
92
+ const data = s.data ?? props.data ?? [];
93
+ const type = s.type ?? 'line';
94
+ if (!kind) {
95
+ const sample = data.find((d) => readField(d, s.xField) != null);
96
+ const v = readField(sample, s.xField);
97
+ kind = type === 'histogram' ? 'linear' : typeof v === 'number' ? 'linear' : isDateLike(v) ? 'time' : 'category';
98
+ if (type === 'boxPlot' || type === 'pareto' || type === 'waterfall' || type === 'bullet')
99
+ kind = kind === 'linear' ? 'category' : kind;
100
+ }
101
+ kinds.set(axisId, kind);
102
+ if (kind === 'category' || kind === 'timeCategory') {
103
+ let list = categories.get(axisId);
104
+ if (!list)
105
+ categories.set(axisId, (list = []));
106
+ const seen = new Set(list);
107
+ for (const [k, d] of data.entries()) {
108
+ const raw = readField(d, s.xField);
109
+ const label = raw instanceof Date ? raw.toISOString() : String(raw ?? '');
110
+ // Indexed: one category per point index, duplicates kept.
111
+ if (def?.options.indexed)
112
+ list[k] ??= label;
113
+ else if (!seen.has(label)) {
114
+ seen.add(label);
115
+ list.push(label);
116
+ }
117
+ }
118
+ }
119
+ }
120
+ const axes = new Map();
121
+ for (const [id, def] of axisDefs) {
122
+ const scale = def.direction === 'x' ? (kinds.get(id) ?? def.options.scale ?? 'linear') : (def.options.scale ?? 'linear');
123
+ axes.set(id, { id, direction: def.direction, options: def.options, scale, categories: categories.get(id) ?? [], position: def.options.position ?? 'start' });
124
+ }
125
+ const out = [];
126
+ let slot = 0;
127
+ for (const { s, i } of ordered) {
128
+ let id = seriesId(s, i);
129
+ while (ids.has(id))
130
+ id = `${id}-${i}`;
131
+ ids.add(id);
132
+ const type = s.type ?? 'line';
133
+ const data = s.data ?? props.data ?? [];
134
+ const xAxis = s.xAxis ?? 'x';
135
+ const yAxis = s.yAxis ?? 'y';
136
+ const axis = axes.get(xAxis);
137
+ const catIndex = new Map(axis.categories.map((c, k) => [c, k]));
138
+ const n = data.length;
139
+ const x = new Float64Array(n);
140
+ const y = new Float64Array(n);
141
+ const col = (field) => (field ? Float64Array.from(data, (d) => toNumber(readField(d, field))) : undefined);
142
+ for (let k = 0; k < n; k++) {
143
+ const d = data[k];
144
+ const raw = readField(d, s.xField);
145
+ x[k] =
146
+ axis.options.indexed
147
+ ? k
148
+ : axis.scale === 'category' || axis.scale === 'timeCategory'
149
+ ? (catIndex.get(raw instanceof Date ? raw.toISOString() : String(raw ?? '')) ?? k)
150
+ : axis.scale === 'time'
151
+ ? toTime(raw)
152
+ : s.xField
153
+ ? toNumber(raw)
154
+ : k;
155
+ y[k] = toNumber(readField(d, s.yField));
156
+ }
157
+ const yFilled = s.emptyPoints && s.emptyPoints !== 'gap' ? fillEmpty(y, s.emptyPoints) : y;
158
+ const color = s.color ?? seriesColor(slot, props.palette);
159
+ const boxes = type === 'boxPlot' ? data.map((d) => (Array.isArray(readField(d, s.yField)) ? readField(d, s.yField).map(toNumber) : [toNumber(readField(d, s.yField))])) : undefined;
160
+ const targetFields = s.targetField === undefined ? [] : typeof s.targetField === 'string' ? [s.targetField] : s.targetField;
161
+ out.push({
162
+ id,
163
+ slot,
164
+ type,
165
+ name: s.name ?? s.yField ?? id,
166
+ options: s,
167
+ data,
168
+ color,
169
+ xAxis,
170
+ yAxis,
171
+ x,
172
+ y: yFilled,
173
+ low: col(s.lowField),
174
+ high: col(s.highField),
175
+ open: col(s.openField),
176
+ close: col(s.closeField),
177
+ size: col(s.sizeField),
178
+ boxes,
179
+ targets: targetFields.map((f) => col(f)),
180
+ hidden: s.hidden === true || hidden.has(id),
181
+ });
182
+ slot++;
183
+ }
184
+ return { series: out, axes, horizontal };
185
+ }
186
+ const DASH = { solid: undefined, dashed: '6 4', dotted: '2 3' };
187
+ const isPrice = (t) => t === 'candle' || t === 'ohlc' || t === 'hilo';
188
+ const isBandType = (t) => t === 'column' || t === 'bar' || t === 'waterfall' || t === 'histogram' || t === 'candle' || t === 'ohlc' || t === 'hilo' || t === 'boxPlot' || t === 'pareto' || t === 'bullet';
189
+ const grow = (e, v) => {
190
+ if (!Number.isFinite(v))
191
+ return;
192
+ if (v < e.lo)
193
+ e.lo = v;
194
+ if (v > e.hi)
195
+ e.hi = v;
196
+ };
197
+ /** Grows `e` by every value of the given columns (absent columns skipped). */
198
+ const growAll = (e, columns) => {
199
+ for (const c of columns)
200
+ if (c)
201
+ for (let i = 0; i < c.length; i++)
202
+ grow(e, c[i]);
203
+ };
204
+ function interval(options) {
205
+ return typeof options.interval === 'object' ? options.interval : undefined;
206
+ }
207
+ /** Builds the full layout model for a size and view state. */
208
+ /** The y values of a series as a column (a plain loop: `Float64Array.from` with a map function is slow on 1,000,000 points). */
209
+ function yColumn(m) {
210
+ const out = new Float64Array(m.count);
211
+ for (let i = 0; i < m.count; i++)
212
+ out[i] = m.yValue(i);
213
+ return out;
214
+ }
215
+ export function buildModel(props, spec, view, indicators) {
216
+ const extra = props.indicators?.length ? indicators?.(props, spec) : undefined;
217
+ const width = Math.max(1, view.width);
218
+ const height = Math.max(1, view.height);
219
+ const text = { ...DEFAULT_TEXT, ...props.text };
220
+ const say = (message, params) => formatMessage(message, params, props.locale);
221
+ const fmtCtx = { locale: props.locale, timeZone: props.timeZone };
222
+ // Data values (labels, tooltips, the table): up to two decimals.
223
+ const valueFmt = (f) => makeNumberFormat(f, fmtCtx, 0);
224
+ const yFmt = valueFmt();
225
+ const visible = spec.series.filter((s) => !s.hidden);
226
+ // Pareto: sort categories by value and add the cumulative line on a generated secondary axis.
227
+ const prepared = [];
228
+ const extraAxes = [];
229
+ const allSeries = [];
230
+ for (const s of spec.series) {
231
+ if (s.type === 'pareto') {
232
+ const { order, cumulativePercent } = paretoOrder(s.y);
233
+ const axisId = `${s.id}-pareto`;
234
+ const x = Float64Array.from(order.map((_, k) => k));
235
+ const sorted = { ...s, type: 'column', x, y: Float64Array.from(order, (i) => s.y[i]), data: order.map((i) => s.data[i]) };
236
+ const pareto = s.options.pareto ?? {};
237
+ // The cumulative line takes the next palette color so it stays visible over the bars.
238
+ const line = { ...s, id: `${s.id}-cumulative`, name: `${s.name} %`, type: 'line', yAxis: axisId, x, y: cumulativePercent, generated: true, color: pareto.color ?? seriesColor(s.slot + 1, props.palette), options: { ...s.options, markers: pareto.markers ?? true, labels: false } };
239
+ allSeries.push(sorted);
240
+ if (pareto.line !== false)
241
+ allSeries.push(line);
242
+ const xAxis = spec.axes.get(s.xAxis);
243
+ if (xAxis && xAxis.categories.length) {
244
+ const cats = order.map((i) => {
245
+ const raw = readField(s.data[i], s.options.xField);
246
+ return String(raw ?? '');
247
+ });
248
+ extraAxes.push({ ...xAxis, categories: cats });
249
+ }
250
+ extraAxes.push({ id: axisId, direction: 'y', options: { id: axisId, min: 0, max: 100, format: '{value}%', gridLines: false }, scale: 'linear', categories: [], position: 'end' });
251
+ }
252
+ else
253
+ allSeries.push(s);
254
+ // Trendlines as generated line series on the same axes.
255
+ for (const [k, t] of (s.options.trendlines ?? []).entries()) {
256
+ const pts = trendlinePoints(s.x, s.y, { kind: t.kind, order: t.order, period: t.period, intercept: t.intercept, forecast: t.forecast, samples: t.markers ? Math.min(s.x.length, 256) : undefined });
257
+ allSeries.push({ ...s, id: `${s.id}-trend-${k}`, name: t.name ?? say(text.trendline, { series: s.name, kind: text[t.kind] ?? t.kind }), type: 'line', x: pts.xs, y: pts.ys, color: t.color ?? s.color, generated: true, options: { ...s.options, type: 'line', curve: 'linear', lineStyle: 'dashed', markers: t.markers ?? false, tooltip: t.tooltip ?? s.options.tooltip, tooltipField: undefined, getPointStyle: undefined, labels: false, trendlines: undefined, data: undefined } });
258
+ }
259
+ }
260
+ // Indicators (the opt-in `chart/indicators.ts` feature) come after every series.
261
+ allSeries.push(...(extra?.series ?? []));
262
+ const axes = new Map(spec.axes);
263
+ for (const a of [...extraAxes, ...(extra?.axes ?? [])])
264
+ axes.set(a.id, a);
265
+ // Stacks per (y axis, group, mode).
266
+ const stackInputs = new Map();
267
+ for (const s of allSeries) {
268
+ if (s.hidden || !s.options.stack)
269
+ continue;
270
+ const key = `${s.xAxis}|${s.yAxis}`;
271
+ let list = stackInputs.get(key);
272
+ if (!list)
273
+ stackInputs.set(key, (list = []));
274
+ list.push({ id: s.id, values: s.y, group: `${s.type === 'column' || s.type === 'bar' ? 'b' : 'l'}:${s.options.stackGroup ?? ''}`, mode: s.options.stack === 'percent' ? 'percent' : 'normal' });
275
+ }
276
+ const stacked = new Map();
277
+ const stackTotals = [];
278
+ for (const [key, list] of stackInputs) {
279
+ const length = Math.max(...list.map((l) => l.values.length));
280
+ // Align by x index: series share category positions, so index k is the same x.
281
+ const r = stack(list, length);
282
+ for (const [id, v] of r.series)
283
+ stacked.set(id, v);
284
+ const [xAxis, yAxis] = key.split('|');
285
+ const first = allSeries.find((s) => s.id === list[0]?.id);
286
+ for (const t of r.totals.values())
287
+ stackTotals.push({ xAxis, yAxis, totals: Float64Array.from(t.positive, (p, i) => p + t.negative[i]), top: t.positive, x: first?.x ?? new Float64Array(length) });
288
+ }
289
+ const xExt = new Map();
290
+ const yExt = new Map();
291
+ const ext = (m, id) => {
292
+ let e = m.get(id);
293
+ if (!e)
294
+ m.set(id, (e = { lo: Number.POSITIVE_INFINITY, hi: Number.NEGATIVE_INFINITY }));
295
+ return e;
296
+ };
297
+ for (const s of allSeries) {
298
+ const p = { s, y1: s.y };
299
+ // Point styles: one call per point; `hidden` points leave a gap.
300
+ const gps = s.options.getPointStyle;
301
+ if (gps) {
302
+ p.styles = Array.from(s.y, (y, i) => gps({ seriesId: s.id, seriesName: s.name, index: i, datum: s.data[i] ?? {}, x: readField(s.data[i], s.options.xField), y, xText: '', yText: '', color: s.color }) ?? null);
303
+ if (p.styles.some((st) => st?.hidden))
304
+ p.y1 = Float64Array.from(s.y, (y, i) => (p.styles?.[i]?.hidden ? Number.NaN : y));
305
+ }
306
+ const st = stacked.get(s.id);
307
+ if (st) {
308
+ p.y0 = st.y0;
309
+ p.y1 = st.y1;
310
+ }
311
+ if (s.type === 'waterfall') {
312
+ const w = waterfall(s.y, { totals: s.options.totals, subtotals: s.options.subtotals });
313
+ p.y0 = w.y0;
314
+ p.y1 = w.y1;
315
+ p.kinds = w.kind;
316
+ }
317
+ if (s.type === 'histogram') {
318
+ const h = histogramBins(s.y, { binWidth: s.options.binWidth });
319
+ p.hist = h;
320
+ if (s.options.normalCurve) {
321
+ const xsCurve = Array.from({ length: 64 }, (_, k) => (h.x0[0] ?? 0) + (((h.x1[h.x1.length - 1] ?? 1) - (h.x0[0] ?? 0)) * k) / 63);
322
+ p.hist = { ...h, curve: normalCurve(s.y, h.binWidth, xsCurve), curveX: xsCurve };
323
+ }
324
+ }
325
+ if (s.type === 'boxPlot' && s.boxes)
326
+ p.boxes = s.boxes.map((b) => boxPlotStats(b, s.options.quartileMethod ?? 'exclusive'));
327
+ if (s.options.errorBars) {
328
+ const e = s.options.errorBars;
329
+ const ext = (values) => errorBarExtents(values, { kind: e.kind, amount: e.amount, direction: e.direction, plus: e.plusField ? Float64Array.from(s.data, (d) => toNumber(readField(d, e.plusField))) : undefined, minus: e.minusField ? Float64Array.from(s.data, (d) => toNumber(readField(d, e.minusField))) : undefined });
330
+ if (e.axis !== 'x') {
331
+ const eb = ext(s.y);
332
+ p.errLow = eb.low;
333
+ p.errHigh = eb.high;
334
+ }
335
+ if ((e.axis === 'x' || e.axis === 'both') && spec.axes.get(s.xAxis)?.categories.length === 0) {
336
+ const eb = ext(s.x);
337
+ p.errXLow = eb.low;
338
+ p.errXHigh = eb.high;
339
+ }
340
+ }
341
+ prepared.push(p);
342
+ if (s.hidden)
343
+ continue;
344
+ const xe = ext(xExt, s.xAxis);
345
+ const ye = ext(yExt, s.yAxis);
346
+ if (p.hist) {
347
+ growAll(xe, [[p.hist.x0[0] ?? 0, p.hist.x1[p.hist.x1.length - 1] ?? 1]]);
348
+ growAll(ye, [p.hist.count, p.hist.curve, [0]]);
349
+ continue;
350
+ }
351
+ growAll(xe, [s.x, p.errXLow, p.errXHigh]);
352
+ growAll(ye, [p.y1, p.y0, s.low, s.high, p.errLow, p.errHigh, ...(s.targets ?? [])]);
353
+ if (p.boxes)
354
+ growAll(ye, p.boxes.map((b) => [b.min, b.max, ...b.outliers]));
355
+ // Bars and areas grow from zero; price bars (candle, OHLC, high-low) span their own range.
356
+ if ((isBandType(s.type) && !isPrice(s.type)) || s.type === 'area')
357
+ grow(ye, 0);
358
+ }
359
+ const empty = visible.every((s) => s.data.length === 0);
360
+ // Axis layout: which side, label texts (two passes: estimate, then real plot size).
361
+ const usedAxes = [...axes.values()].filter((a) => a.id === 'x' || a.id === 'y' || allSeries.some((s) => s.xAxis === a.id || s.yAxis === a.id));
362
+ const sideOf = (a) => {
363
+ const horizontalAxis = (a.direction === 'x') !== spec.horizontal;
364
+ if (horizontalAxis)
365
+ return a.position === 'end' ? 'top' : 'bottom';
366
+ return a.position === 'end' ? 'right' : 'left';
367
+ };
368
+ const makeScale = (a, full) => {
369
+ const o = a.options;
370
+ const off = (o.plotOffset ?? 0) * Math.sign(full[1] - full[0]);
371
+ const range = [full[0] + off, full[1] - off];
372
+ const reversed = o.reversed === true;
373
+ if (a.scale === 'category' || a.scale === 'timeCategory') {
374
+ return bandScale({ domain: a.categories, range, reversed, paddingInner: 0, placement: o.labelPlacement ?? 'between', kind: a.scale });
375
+ }
376
+ const e = (a.direction === 'x' ? xExt : yExt).get(a.id);
377
+ const extent = e && Number.isFinite(e.lo) ? [e.lo, e.hi] : null;
378
+ const kind = a.scale === 'log' ? 'log' : a.scale === 'time' ? 'time' : 'linear';
379
+ const isX = a.direction === 'x';
380
+ const tickCount = o.tickCount ?? Math.max(2, Math.round(Math.abs(range[1] - range[0]) / (isX !== spec.horizontal ? 90 : 45)));
381
+ let domain = resolveDomain(extent, {
382
+ min: o.min === undefined ? undefined : toTime(o.min),
383
+ max: o.max === undefined ? undefined : toTime(o.max),
384
+ includeZero: o.includeZero ?? (isX ? false : undefined),
385
+ padding: o.padding ?? (isX ? 'none' : 'auto'),
386
+ tickCount,
387
+ kind,
388
+ });
389
+ if (o.domain)
390
+ domain = [...o.domain(domain)];
391
+ const z = view.zoom[a.id];
392
+ if (z)
393
+ domain = [z[0], z[1]];
394
+ return createScale({ kind, domain, range, reversed, base: o.base, timeZone: props.timeZone, interval: interval(o) });
395
+ };
396
+ const tickValues = (a, scale) => {
397
+ const o = a.options;
398
+ if (scale.kind === 'category' || scale.kind === 'timeCategory')
399
+ return scale.ticks();
400
+ const length = Math.abs(scale.range[1] - scale.range[0]);
401
+ const count = o.tickCount ?? Math.max(2, Math.round(length / (sideIsHorizontal(a) ? 90 : 45)));
402
+ if (typeof o.interval === 'number' && scale.kind !== 'time') {
403
+ const [d0, d1] = scale.domain;
404
+ const lo = Math.min(d0, d1);
405
+ const hi = Math.max(d0, d1);
406
+ const out = [];
407
+ const first = Math.ceil(lo / o.interval - 1e-9) * o.interval;
408
+ for (let v = first, k = 0; v <= hi + 1e-9 && k < 1000; v += o.interval, k++)
409
+ out.push(Number(v.toPrecision(12)));
410
+ return out;
411
+ }
412
+ return scale.ticks(count);
413
+ };
414
+ const sideIsHorizontal = (a) => {
415
+ const s = sideOf(a);
416
+ return s === 'top' || s === 'bottom';
417
+ };
418
+ // Panes: vertical-side axes take a row band of the plot, horizontal-side axes a column band.
419
+ const paneOf = (a) => (sideIsHorizontal(a) ? a.options.pane?.column : a.options.pane?.row) ?? 0;
420
+ const paneRange = (a, p) => {
421
+ const h = sideIsHorizontal(a);
422
+ const [lo, hi] = paneSpan(h ? props.panes?.columns : props.panes?.rows, paneOf(a), a.options.pane?.span ?? 1, h ? p.x : p.y, h ? p.width : p.height);
423
+ return h ? [lo, hi] : [hi, lo];
424
+ };
425
+ // Same-side axes in different panes share a slot instead of stacking outward.
426
+ const slotOf = new Map();
427
+ if (props.panes) {
428
+ const seen = new Map();
429
+ for (const a of usedAxes) {
430
+ const key = `${sideOf(a)}:${paneOf(a)}`;
431
+ const k = seen.get(key) ?? 0;
432
+ seen.set(key, k + 1);
433
+ slotOf.set(a.id, `${sideOf(a)}:${k}`);
434
+ }
435
+ }
436
+ const formatterFor = (a, scale, ticks) => {
437
+ const o = a.options;
438
+ if (o.formatLabel) {
439
+ const f = o.formatLabel;
440
+ return scale.kind === 'category' || scale.kind === 'timeCategory' ? (i) => f(a.categories[i]) : scale.kind === 'time' ? (v) => f(new Date(v)) : (v) => f(v);
441
+ }
442
+ if (scale.kind === 'category' || scale.kind === 'timeCategory') {
443
+ if (scale.kind === 'timeCategory' || a.categories.every((c) => ISO.test(c))) {
444
+ const tf = makeTimeFormat(o.format, fmtCtx, 'day');
445
+ return (i) => {
446
+ const c = a.categories[i] ?? '';
447
+ const t = Date.parse(c);
448
+ return Number.isFinite(t) && ISO.test(c) ? tf(t) : c;
449
+ };
450
+ }
451
+ return (i) => a.categories[i] ?? '';
452
+ }
453
+ if (scale.kind === 'time')
454
+ return makeTimeFormat(o.format, fmtCtx, scale.interval?.unit ?? 'day');
455
+ const step = ticks.length > 1 ? Math.abs(ticks[1] - ticks[0]) : 1;
456
+ return makeNumberFormat(o.format, fmtCtx, step);
457
+ };
458
+ // Multi-level label rows: a text row per group on horizontal sides, a column on vertical ones.
459
+ const groupSize = (a, horizontalSide) => {
460
+ const g = a.options.labelGroups ?? [];
461
+ if (!g.length)
462
+ return 0;
463
+ return horizontalSide ? g.length * GROUP_ROW : g.reduce((t, x) => t + Math.ceil(Math.max(0, ...x.levels.map((l) => textWidth(l.label)))) + 10, 0);
464
+ };
465
+ const planOf = (a, scale, labels, positions) => planHorizontalLabels(labels, positions, a.options.labelOverlap ?? (scale.kind === 'category' ? 'auto' : 'hide'), { spacing: scale.kind === 'category' ? scale.step : undefined, maxWidth: a.options.maxLabelWidth, ...(a.options.labelAngle !== undefined ? { angle: a.options.labelAngle } : {}) });
466
+ // Width of the vertical-side labels.
467
+ const labelWidth = (a, labels) => Math.ceil(Math.min(a.options.maxLabelWidth ?? 120, Math.max(8, ...labels.map((l) => textWidth(l)))));
468
+ // Pass 1: estimated ranges.
469
+ const estimate = layoutFrame({ width, height, title: props.title, subtitle: props.subtitle, legend: legendSpec(props, allSeries), axes: mergeSlots(slotOf, usedAxes.map((a) => ({ id: a.id, side: sideOf(a), labelThickness: sideIsHorizontal(a) ? lineHeight('sm') : 40, title: a.options.title, hidden: a.options.hidden }))) });
470
+ const blocks = [];
471
+ let endPad = 0;
472
+ // Scale, ticks, label texts and the horizontal label plan of an axis inside a plot rectangle.
473
+ const axisPass = (a, p) => {
474
+ const horizontalSide = sideIsHorizontal(a);
475
+ const range = paneRange(a, p);
476
+ const scale = makeScale(a, horizontalAxisRange(a, range, spec.horizontal, horizontalSide));
477
+ const ticks = tickValues(a, scale);
478
+ const fmt = formatterFor(a, scale, ticks);
479
+ const labels = ticks.map((t) => fmt(t));
480
+ const positions = ticks.map((t) => scale.map(t));
481
+ return { horizontalSide, range, scale, ticks, fmt, labels, positions, plan: horizontalSide ? planOf(a, scale, labels, positions) : null };
482
+ };
483
+ for (const a of usedAxes) {
484
+ const { horizontalSide, labels, positions, plan } = axisPass(a, estimate.plot);
485
+ blocks.push({ id: a.id, side: sideOf(a), labelThickness: (plan ? plan.thickness : labelWidth(a, labels)) + groupSize(a, horizontalSide), title: a.options.title, hidden: a.options.hidden, inside: a.options.labelPosition === 'inside' });
486
+ // With `edgeLabels: 'none'` an unrotated end label centered on the plot's end would be cut
487
+ // by the drawing: the frame keeps room for it instead.
488
+ if (plan && (a.options.edgeLabels ?? 'none') === 'none' && !a.options.hidden && !plan.angle)
489
+ positions.forEach((pos, k) => {
490
+ if (!plan.hidden[k])
491
+ endPad = Math.max(endPad, Math.ceil(pos + textWidth(labels[k] ?? '') / 2 - width + 1));
492
+ });
493
+ }
494
+ // Pass 2: the real frame.
495
+ const frame = alignLegend(layoutFrame({ width: width - endPad, height, title: props.title, subtitle: props.subtitle, legend: legendSpec(props, allSeries), axes: mergeSlots(slotOf, blocks), plotInset: 0 }), props);
496
+ const plot = frame.plot;
497
+ const axisModels = [];
498
+ const scales = new Map();
499
+ for (const a of usedAxes) {
500
+ const { horizontalSide, range, scale, ticks, fmt, labels, positions, plan } = axisPass(a, plot);
501
+ scales.set(a.id, scale);
502
+ const frameBlock = frame.axes.get(slotOf.get(a.id) ?? a.id) ?? { x: 0, y: 0, width: 0, height: 0, line: 0, id: a.id, side: sideOf(a) };
503
+ // A pane axis's block spans its pane only (title and axis line).
504
+ const block = props.panes ? (horizontalSide ? { ...frameBlock, id: a.id, x: Math.min(...range), width: Math.abs(range[1] - range[0]) } : { ...frameBlock, id: a.id, y: Math.min(...range), height: Math.abs(range[1] - range[0]) }) : frameBlock;
505
+ const vHidden = horizontalSide ? null : planVerticalLabels(positions);
506
+ const edge = a.options.edgeLabels ?? 'none';
507
+ const tickModels = ticks.map((t, k) => {
508
+ let pos = positions[k];
509
+ let hiddenLabel = plan ? (plan.hidden[k] ?? false) : (vHidden?.[k] ?? false);
510
+ if (horizontalSide && edge !== 'none') {
511
+ const w = textWidth(labels[k] ?? '') / 2;
512
+ if (pos - w < 0 || pos + w > width) {
513
+ if (edge === 'hide')
514
+ hiddenLabel = true;
515
+ else
516
+ pos = Math.min(width - w, Math.max(w, pos));
517
+ }
518
+ }
519
+ return { key: `${a.id}-${t}`, value: t, pos, text: plan ? (plan.lines[k] ?? [labels[k] ?? '']) : [truncateText(labels[k] ?? '', a.options.maxLabelWidth ?? 120)], hidden: hiddenLabel, row: plan?.rows[k] ?? 0 };
520
+ });
521
+ const grid = a.options.gridLines === false ? 'none' : a.options.gridLines === 'both' ? 'both' : a.options.gridLines === true || a.options.gridLines === 'major' ? 'major' : a.direction === 'y' && a.id === 'y' ? 'major' : 'none';
522
+ const minor = [];
523
+ if ((a.options.minorTicks ?? 0) > 0 && scale.kind !== 'category' && scale.kind !== 'timeCategory') {
524
+ const m = a.options.minorTicks;
525
+ for (let k = 0; k < ticks.length - 1; k++)
526
+ for (let j = 1; j <= m; j++)
527
+ minor.push(scale.map(ticks[k] + ((ticks[k + 1] - ticks[k]) * j) / (m + 1)));
528
+ }
529
+ const lineMarks = (a.options.lines ?? []).map((l, k) => {
530
+ const p = scale.map(l.value);
531
+ return horizontalSide
532
+ ? { key: `${a.id}-line-${k}`, d: `M${n2(p)},${n2(plot.y)}V${n2(plot.y + plot.height)}`, label: l.label, lx: p + 4, ly: plot.y + 12, color: l.color, dash: DASH[l.lineStyle ?? 'dashed'] }
533
+ : { key: `${a.id}-line-${k}`, d: `M${n2(plot.x)},${n2(p)}H${n2(plot.x + plot.width)}`, label: l.label, lx: plot.x + plot.width - 4, ly: p - 4, color: l.color, dash: DASH[l.lineStyle ?? 'dashed'] };
534
+ });
535
+ axisModels.push({
536
+ id: a.id,
537
+ direction: a.direction,
538
+ side: block.side,
539
+ scale,
540
+ ticks: tickModels,
541
+ minor,
542
+ angle: plan?.angle ?? 0,
543
+ line: block.line,
544
+ title: a.options.title,
545
+ hidden: a.options.hidden === true,
546
+ grid,
547
+ format: fmt,
548
+ bands: [],
549
+ lines: lineMarks,
550
+ block,
551
+ options: a.options,
552
+ labelLine: block.line,
553
+ groups: labelGroupCells(a, scale, horizontalSide),
554
+ groupOffset: TICK_SIZE + LABEL_GAP + (plan ? plan.thickness : labelWidth(a, labels)),
555
+ });
556
+ }
557
+ // Post pass: crossing lines and bands, whose segments need the crossing scale.
558
+ const crossOf = (m, id) => scales.get(id ?? (m.direction === 'x' ? 'y' : 'x'));
559
+ for (const [k, m] of axisModels.entries()) {
560
+ const horizontalSide = m.side === 'top' || m.side === 'bottom';
561
+ const scale = m.scale;
562
+ const bands = [];
563
+ for (const [bi, b] of (m.options.bands ?? []).entries()) {
564
+ const reps = [];
565
+ if (b.every && b.every > 0) {
566
+ const until = b.until ?? Math.max(scale.domain[0], scale.domain[1]);
567
+ for (let from = b.from, j = 0; from <= until && j < 500; from += b.every, j++)
568
+ reps.push([from, from + (b.to - b.from)]);
569
+ }
570
+ else
571
+ reps.push([b.from, b.to]);
572
+ const cross = crossOf(m);
573
+ let c0 = horizontalSide ? plot.y : plot.x;
574
+ let c1 = horizontalSide ? plot.y + plot.height : plot.x + plot.width;
575
+ if (cross && (b.crossFrom !== undefined || b.crossTo !== undefined)) {
576
+ const q0 = b.crossFrom === undefined ? c0 : cross.map(b.crossFrom);
577
+ const q1 = b.crossTo === undefined ? c1 : cross.map(b.crossTo);
578
+ [c0, c1] = [Math.min(q0, q1), Math.max(q0, q1)];
579
+ }
580
+ for (const [j, [f, t]] of reps.entries()) {
581
+ const p0 = scale.map(f);
582
+ const p1 = scale.map(t);
583
+ const d = horizontalSide ? rectPath(Math.min(p0, p1), c0, Math.abs(p1 - p0), c1 - c0) : rectPath(c0, Math.min(p0, p1), c1 - c0, Math.abs(p1 - p0));
584
+ bands.push({ key: `${m.id}-band-${bi}-${j}`, d, fill: b.color ?? 'var(--salmon-surface-sunken)', opacity: b.color ? 0.25 : 1, className: b.layer === 'over' ? 'over' : 'behind' });
585
+ }
586
+ }
587
+ let line = m.line;
588
+ const ca = m.options.crossAt;
589
+ if (ca) {
590
+ const cross = crossOf(m, ca.axis);
591
+ const q = cross ? cross.map(toTime(ca.value)) : Number.NaN;
592
+ if (Number.isFinite(q))
593
+ line = q;
594
+ }
595
+ axisModels[k] = { ...m, bands, line, labelLine: ca && m.options.labelsAtCross ? line : m.line };
596
+ }
597
+ // Marks.
598
+ const toPx = (xs, ys, x, y) => (spec.horizontal ? [ys.map(y), xs.map(x)] : [xs.map(x), ys.map(y)]);
599
+ // Column slots per x axis: side-by-side groups.
600
+ const bandSeries = prepared.filter((p) => !p.s.hidden && (p.s.type === 'column' || p.s.type === 'bar' || p.s.type === 'waterfall'));
601
+ const slotKeys = [];
602
+ for (const p of bandSeries) {
603
+ const key = props.grouping === 'overlap' ? 'all' : p.s.options.stack ? `stack:${p.s.options.stackGroup ?? ''}` : (p.s.options.group ?? p.s.id);
604
+ if (!slotKeys.includes(key))
605
+ slotKeys.push(key);
606
+ }
607
+ let drawn = 0;
608
+ const seriesModels = [];
609
+ const allLabels = [];
610
+ const smart = [];
611
+ for (const p of prepared) {
612
+ const s = p.s;
613
+ const xs = scales.get(s.xAxis) ?? scales.get('x');
614
+ const ys = scales.get(s.yAxis) ?? scales.get('y');
615
+ const xAxisModel = axisModels.find((a) => a.id === s.xAxis) ?? axisModels.find((a) => a.id === 'x');
616
+ if (!xs || !ys)
617
+ continue;
618
+ const n = s.x.length;
619
+ const px = new Float64Array(n).fill(Number.NaN);
620
+ const py = new Float64Array(n).fill(Number.NaN);
621
+ const marks = [];
622
+ const labels = [];
623
+ const xCat = xs.kind === 'category' || xs.kind === 'timeCategory';
624
+ const band = xCat ? xs.step : estimateBand(s.x, xs);
625
+ const lineStyle = DASH[s.options.lineStyle ?? 'solid'];
626
+ const opacity = s.options.opacity;
627
+ const xFmt = (i) => {
628
+ const raw = readField(s.data[i], s.options.xField);
629
+ if (xCat)
630
+ return xAxisModel ? xAxisModel.format(s.x[i]) : String(raw ?? '');
631
+ if (xs.kind === 'time')
632
+ return makeTimeFormat(undefined, fmtCtx, 'day')(s.x[i]);
633
+ return raw === undefined ? String(s.x[i]) : xAxisModel ? xAxisModel.format(s.x[i]) : String(raw);
634
+ };
635
+ const yAxisModel = axisModels.find((a) => a.id === s.yAxis);
636
+ const yvFmt = valueFmt(yAxisModel?.options.format);
637
+ // A waterfall total or subtotal shows the sum its bar spans, not its (empty) data value.
638
+ const valueAt = (i) => (p.kinds?.[i]?.endsWith('total') ? p.y1[i] - p.y0?.[i] : s.y[i]);
639
+ const yTextOf = (i) => {
640
+ if (s.options.tooltipField) {
641
+ const t = readField(s.data[i], s.options.tooltipField);
642
+ if (t != null && t !== '')
643
+ return String(t);
644
+ }
645
+ if (isPrice(s.type)) {
646
+ const vf = s.options.volumeField;
647
+ const parts = PRICES.flatMap((k) => (s[k] ? [say(text[k], { value: yFmt(s[k][i]) })] : []));
648
+ if (vf)
649
+ parts.push(say(text.volume, { value: yFmt(toNumber(readField(s.data[i], vf))) }));
650
+ return parts.join(' ');
651
+ }
652
+ if (p.boxes) {
653
+ const b = p.boxes[i];
654
+ return b ? say(text.box, { min: yFmt(b.min), q1: yFmt(b.q1), median: yFmt(b.median), q3: yFmt(b.q3), max: yFmt(b.max) }) : '';
655
+ }
656
+ const v = valueAt(i);
657
+ if (!Number.isFinite(v))
658
+ return '';
659
+ return yvFmt(v);
660
+ };
661
+ const pointColor = (i) => {
662
+ const field = s.options.colorField ? readField(s.data[i], s.options.colorField) : undefined;
663
+ if (typeof field === 'string')
664
+ return field;
665
+ const st = p.styles?.[i];
666
+ if (st?.color)
667
+ return st.color;
668
+ // Range colors: the range the y value falls in; several colors spread across it.
669
+ for (const r of props.colorRanges ?? []) {
670
+ const v = s.y[i];
671
+ if (v >= r.from && v <= r.to && r.colors.length)
672
+ return rangeColor(r, v);
673
+ }
674
+ if (s.options.segments?.length) {
675
+ const axisV = s.options.segmentAxis === 'x' ? s.x[i] : s.y[i];
676
+ for (const seg of s.options.segments)
677
+ if (seg.until === undefined || axisV <= seg.until)
678
+ return seg.color;
679
+ }
680
+ return s.color;
681
+ };
682
+ const legendShape = s.options.legendShape && s.options.legendShape !== 'seriesType' ? s.options.legendShape : s.type === 'line' ? 'line' : s.type === 'area' ? 'area' : s.type === 'scatter' || s.type === 'bubble' ? 'circle' : 'column';
683
+ if (!s.hidden && !empty) {
684
+ if (s.type === 'line' || s.type === 'area') {
685
+ const yTop = p.y1;
686
+ const yBase = p.y0;
687
+ // Pixel anchors for every point (hit-test, focus, tooltips on the original data).
688
+ for (let i = 0; i < n; i++) {
689
+ const yv = s.low && s.high && !Number.isFinite(yTop[i]) ? s.high[i] : yTop[i];
690
+ const [a, b] = toPx(xs, ys, s.x[i], yv);
691
+ px[i] = a;
692
+ py[i] = b;
693
+ }
694
+ // Decimate in data order on the x pixel (sorted x only).
695
+ const sorted = isSorted(s.x);
696
+ let from = 0;
697
+ let to = n;
698
+ if (sorted && !xCat)
699
+ [from, to] = visibleRange(s.x, xs.domain[0], xs.domain[1]);
700
+ const along = spec.horizontal ? py : px;
701
+ const idx = sorted ? decimateLine(s.x, yTop, (x) => xs.map(x), spec.horizontal ? plot.height : plot.width, props.decimation ?? 'auto', from, to) : null;
702
+ const pick = (arr) => (idx ? Float64Array.from(idx, (i) => arr[i]) : Float64Array.from({ length: to - from }, (_, k) => arr[from + k]));
703
+ const dx = pick(along);
704
+ const dy = pick(spec.horizontal ? px : py);
705
+ drawn += dx.length;
706
+ const curve = { curve: s.options.curve, tension: s.options.tension, stepPosition: s.options.stepPosition, risers: s.options.risers };
707
+ const xsP = spec.horizontal ? dy : dx;
708
+ const ysP = spec.horizontal ? dx : dy;
709
+ const hasRange = Boolean(s.low && s.high);
710
+ if (s.type === 'area') {
711
+ let base;
712
+ if (hasRange) {
713
+ const lo = pick(Float64Array.from({ length: n }, (_, i) => toPx(xs, ys, s.x[i], s.low?.[i])[spec.horizontal ? 0 : 1]));
714
+ const hi = pick(Float64Array.from({ length: n }, (_, i) => toPx(xs, ys, s.x[i], s.high?.[i])[spec.horizontal ? 0 : 1]));
715
+ marks.push({ key: 'area', d: spec.horizontal ? areaPathH(dx, hi, lo) : areaPath(dx, hi, lo, curve), fill: s.color, opacity: opacity ?? 0.35 });
716
+ marks.push({ key: 'line-hi', d: spec.horizontal ? linePath(hi, dx, curve) : linePath(dx, hi, curve), stroke: s.color, strokeWidth: 2, dash: lineStyle });
717
+ marks.push({ key: 'line-lo', d: spec.horizontal ? linePath(lo, dx, curve) : linePath(dx, lo, curve), stroke: s.color, strokeWidth: 2, dash: lineStyle });
718
+ }
719
+ else {
720
+ if (yBase)
721
+ base = pick(Float64Array.from({ length: n }, (_, i) => toPx(xs, ys, s.x[i], yBase[i])[spec.horizontal ? 0 : 1]));
722
+ else
723
+ base = toPx(xs, ys, 0, Math.max(Math.min(0, Math.max(ys.domain[0], ys.domain[1])), Math.min(ys.domain[0], ys.domain[1])))[spec.horizontal ? 0 : 1];
724
+ marks.push({ key: 'area', d: spec.horizontal ? areaPathH(dx, dy, base) : areaPath(dx, dy, base, curve), fill: s.color, opacity: opacity ?? 0.35 });
725
+ marks.push({ key: 'line', d: linePath(xsP, ysP, curve), stroke: s.color, strokeWidth: 2, dash: lineStyle });
726
+ }
727
+ }
728
+ else if (s.options.segments?.length && !idx) {
729
+ // Multi-colored line: one path per run of equal color.
730
+ let start = from;
731
+ for (let i = from + 1; i <= to; i++) {
732
+ if (i < to && pointColor(i) === pointColor(start))
733
+ continue;
734
+ const end = Math.min(to - 1, i);
735
+ const sx = Float64Array.from({ length: end - start + 1 }, (_, k) => px[start + k]);
736
+ const sy = Float64Array.from({ length: end - start + 1 }, (_, k) => py[start + k]);
737
+ const seg = s.options.segments.find((g) => g.color === pointColor(start));
738
+ marks.push({ key: `seg-${start}`, d: linePath(sx, sy, curve), stroke: pointColor(start), strokeWidth: 2, dash: DASH[seg?.lineStyle ?? s.options.lineStyle ?? 'solid'] });
739
+ start = i;
740
+ }
741
+ }
742
+ else {
743
+ marks.push({ key: 'line', d: linePath(xsP, ysP, curve), stroke: s.color, strokeWidth: 2, dash: lineStyle, opacity });
744
+ }
745
+ if (s.options.markers && n <= 2000)
746
+ addMarkers(marks, s, px, py, pointColor, from, to);
747
+ }
748
+ else if (s.type === 'scatter' || s.type === 'bubble') {
749
+ let sMin = Number.POSITIVE_INFINITY;
750
+ let sMax = Number.NEGATIVE_INFINITY;
751
+ if (s.size)
752
+ for (const v of s.size)
753
+ if (Number.isFinite(v)) {
754
+ sMin = Math.min(sMin, v);
755
+ sMax = Math.max(sMax, v);
756
+ }
757
+ const [rMin, rMax] = s.options.radius ?? [4, Math.max(8, Math.min(plot.width, plot.height) / 10)];
758
+ const markerOpt = typeof s.options.markers === 'object' ? s.options.markers : {};
759
+ const shape = markerOpt.shape ?? 'circle';
760
+ const groups = new Map();
761
+ for (let i = 0; i < n; i++) {
762
+ const [a, b] = toPx(xs, ys, s.x[i], s.y[i]);
763
+ px[i] = a;
764
+ py[i] = b;
765
+ }
766
+ // Pixel binning: above four points per plot pixel column, one point per pixel cell is drawn.
767
+ const keep = props.decimation !== false && s.type === 'scatter' && n > plot.width * 4 ? new Set(binPoints(px, py, 1)) : null;
768
+ for (let i = 0; i < n; i++) {
769
+ const a = px[i];
770
+ const b = py[i];
771
+ if (!Number.isFinite(a) || !Number.isFinite(b) || (keep && !keep.has(i)))
772
+ continue;
773
+ const size = s.type === 'bubble' && s.size ? (rMin + ((rMax - rMin) * Math.sqrt(Math.max(0, (s.size[i] - sMin) / (sMax - sMin || 1))))) * 2 : (markerOpt.size ?? 8);
774
+ const c = pointColor(i);
775
+ if (n > 2000)
776
+ groups.set(c, (groups.get(c) ?? '') + symbolPath(shape, a, b, size));
777
+ else
778
+ marks.push({ key: `p${i}`, d: symbolPath(shape, a, b, size), fill: c, opacity: opacity ?? (s.type === 'bubble' ? 0.6 : 0.85), index: i });
779
+ }
780
+ for (const [c, d] of groups)
781
+ marks.push({ key: `g${c}`, d, fill: c, opacity: opacity ?? 0.85 });
782
+ drawn += keep ? keep.size : n;
783
+ }
784
+ else if (p.hist) {
785
+ const h = p.hist;
786
+ for (let i = 0; i < h.count.length; i++) {
787
+ const [x0, y0] = toPx(xs, ys, h.x0[i], 0);
788
+ const [x1, y1] = toPx(xs, ys, h.x1[i], h.count[i]);
789
+ marks.push({ key: `b${i}`, d: rectPath(x0 + 0.5, y1, x1 - x0 - 1, y0 - y1), fill: s.color, opacity, index: i });
790
+ }
791
+ if (h.curve && h.curveX) {
792
+ const cx = Float64Array.from(h.curveX, (x) => xs.map(x));
793
+ const cy = Float64Array.from(h.curve, (y) => ys.map(y));
794
+ marks.push({ key: 'normal', d: linePath(cx, cy, { curve: 'natural' }), stroke: SEMANTIC.neutral, strokeWidth: 2 });
795
+ }
796
+ drawn += h.count.length;
797
+ }
798
+ else if (isBandType(s.type)) {
799
+ const slotKey = props.grouping === 'overlap' ? 'all' : s.options.stack ? `stack:${s.options.stackGroup ?? ''}` : (s.options.group ?? s.id);
800
+ const isColumnLike = s.type === 'column' || s.type === 'bar' || s.type === 'waterfall';
801
+ const slots = isColumnLike ? Math.max(1, slotKeys.length) : 1;
802
+ const slotIndex = isColumnLike ? Math.max(0, slotKeys.indexOf(slotKey)) : 0;
803
+ const bw = s.options.bandWidth;
804
+ // Time-bucket OHLC aggregation per pixel bucket for large financial series.
805
+ const isOhlc = isPrice(s.type);
806
+ const alongPx = spec.horizontal ? plot.height : plot.width;
807
+ const agg = isOhlc && s.open && s.high && s.low && s.close && !xCat && props.decimation !== false && n > alongPx / 3 && isSorted(s.x) ? aggregateOhlc(s.x, s.open, s.high, s.low, s.close, (x) => xs.map(x), 3) : null;
808
+ const count = agg ? agg.x.length : n;
809
+ const groupWidth = bw !== undefined && bw > 1 ? bw * slots : (agg ? 3 : band) * (bw ?? (s.type === 'bullet' ? 0.6 : 0.7));
810
+ const one = groupWidth / slots;
811
+ const gap = s.options.gap ?? 0;
812
+ // Volume of a financial series: columns along the bottom fifth of the plot, in the candle colors.
813
+ const vf = isOhlc ? s.options.volumeField : undefined;
814
+ const vol = vf ? Float64Array.from(s.data, (d) => toNumber(readField(d, vf))) : null;
815
+ const vMax = vol ? Math.max(0, ...Array.from(vol).filter(Number.isFinite)) : 0;
816
+ for (let k = 0; k < count; k++) {
817
+ const i = agg ? agg.source[k] : k;
818
+ const center = xs.map(agg ? agg.x[k] : s.x[i]);
819
+ const start = center - groupWidth / 2 + slotIndex * one + (one * gap) / 2;
820
+ const w = one * (1 - gap);
821
+ const mid = start + w / 2;
822
+ const rectBetween = (v0, v1, key, fill, extra = {}) => {
823
+ const a = ys.map(v0);
824
+ const b = ys.map(v1);
825
+ if (!Number.isFinite(a) || !Number.isFinite(b))
826
+ return;
827
+ const d = spec.horizontal ? rectPath(Math.min(a, b), start, Math.abs(b - a), w) : rectPath(start, Math.min(a, b), w, Math.abs(b - a));
828
+ marks.push({ key, d, fill, index: i, opacity, ...extra });
829
+ };
830
+ const anchorAt = (v) => {
831
+ const [a, b] = spec.horizontal ? [ys.map(v), mid] : [mid, ys.map(v)];
832
+ px[i] = a;
833
+ py[i] = b;
834
+ };
835
+ if (isOhlc) {
836
+ const o = agg ? agg.open[k] : s.open?.[i];
837
+ const c = agg ? agg.close[k] : s.close?.[i];
838
+ const hi = agg ? agg.high[k] : s.high?.[i];
839
+ const lo = agg ? agg.low[k] : s.low?.[i];
840
+ const up = !(c < o);
841
+ const col = s.type === 'hilo' ? s.color : up ? (s.options.upColor ?? SEMANTIC.up) : (s.options.downColor ?? SEMANTIC.down);
842
+ const a = ys.map(hi);
843
+ const b = ys.map(lo);
844
+ if (!Number.isFinite(a) || !Number.isFinite(b))
845
+ continue;
846
+ const wick = spec.horizontal ? `M${n2(a)},${n2(mid)}H${n2(b)}` : `M${n2(mid)},${n2(a)}V${n2(b)}`;
847
+ let d = wick;
848
+ if (s.type === 'ohlc') {
849
+ const yo = ys.map(o);
850
+ const yc = ys.map(c);
851
+ d += spec.horizontal ? `M${n2(yo)},${n2(start)}V${n2(mid)}M${n2(yc)},${n2(mid)}V${n2(start + w)}` : `M${n2(start)},${n2(yo)}H${n2(mid)}M${n2(mid)},${n2(yc)}H${n2(start + w)}`;
852
+ }
853
+ if (vol && vMax > 0) {
854
+ const h = (Math.max(0, vol[i]) / vMax) * (spec.horizontal ? plot.width : plot.height) * 0.2;
855
+ if (h > 0)
856
+ marks.push({ key: `v${i}`, d: spec.horizontal ? rectPath(plot.x, start, h, w) : rectPath(start, plot.y + plot.height - h, w, h), fill: col, opacity: 0.3, className: 'volume' });
857
+ }
858
+ marks.push({ key: `w${i}`, d, stroke: col, strokeWidth: 1.5, index: i });
859
+ if (s.type === 'candle')
860
+ rectBetween(o, c === o ? c + 1e-9 : c, `c${i}`, s.options.hollow && up ? 'none' : col, { stroke: col, strokeWidth: 1 });
861
+ anchorAt(c);
862
+ }
863
+ else if (s.type === 'boxPlot' && p.boxes) {
864
+ const b = p.boxes[i];
865
+ if (!b || !Number.isFinite(b.median))
866
+ continue;
867
+ rectBetween(b.q1, b.q3, `box${i}`, s.color, { opacity: opacity ?? 0.5, stroke: s.color, strokeWidth: 1.5 });
868
+ const line = (v, x0, x1) => {
869
+ const q = ys.map(v);
870
+ return spec.horizontal ? `M${n2(q)},${n2(x0)}V${n2(x1)}` : `M${n2(x0)},${n2(q)}H${n2(x1)}`;
871
+ };
872
+ const stem = spec.horizontal ? `M${n2(ys.map(b.min))},${n2(mid)}H${n2(ys.map(b.q1))}M${n2(ys.map(b.q3))},${n2(mid)}H${n2(ys.map(b.max))}` : `M${n2(mid)},${n2(ys.map(b.min))}V${n2(ys.map(b.q1))}M${n2(mid)},${n2(ys.map(b.q3))}V${n2(ys.map(b.max))}`;
873
+ marks.push({ key: `wh${i}`, d: stem + line(b.min, start + w / 4, start + (3 * w) / 4) + line(b.max, start + w / 4, start + (3 * w) / 4) + line(b.median, start, start + w), stroke: s.color, strokeWidth: 1.5, index: i });
874
+ if (s.options.mean !== false) {
875
+ const [mx, my] = spec.horizontal ? [ys.map(b.mean), mid] : [mid, ys.map(b.mean)];
876
+ marks.push({ key: `mean${i}`, d: symbolPath('multiply', mx, my, 6), stroke: s.color, strokeWidth: 1.5 });
877
+ }
878
+ if (s.options.outliers !== false)
879
+ for (const [k, o] of b.outliers.entries()) {
880
+ const [ox, oy] = spec.horizontal ? [ys.map(o), mid] : [mid, ys.map(o)];
881
+ marks.push({ key: `out${i}-${k}`, d: symbolPath('circle', ox, oy, 6), stroke: s.color, strokeWidth: 1.5, fill: 'none' });
882
+ }
883
+ anchorAt(b.median);
884
+ }
885
+ else if (s.type === 'bullet') {
886
+ const vq = ys.map(s.y[i]);
887
+ if (s.options.valueShape !== 'dot')
888
+ rectBetween(0, s.y[i], `v${i}`, s.color);
889
+ else if (Number.isFinite(vq))
890
+ marks.push({ key: `v${i}`, d: symbolPath('circle', spec.horizontal ? vq : mid, spec.horizontal ? mid : vq, Math.min(14, w)), fill: s.color, index: i, className: 'dot' });
891
+ for (const [k, t] of (s.targets ?? []).entries()) {
892
+ const q = ys.map(t[i]);
893
+ if (!Number.isFinite(q))
894
+ continue;
895
+ const shape = s.options.targetShapes?.[k] ?? 'line';
896
+ const tc = s.options.targetColor ?? SEMANTIC.text;
897
+ const [tx, ty] = spec.horizontal ? [q, mid] : [mid, q];
898
+ const d = shape === 'circle'
899
+ ? symbolPath('circle', tx, ty, Math.min(14, w * 1.2))
900
+ : shape === 'cross'
901
+ ? symbolPath('multiply', tx, ty, Math.min(14, w * 1.2))
902
+ : spec.horizontal
903
+ ? `M${n2(q)},${n2(start - w * 0.25)}V${n2(start + w * 1.25)}`
904
+ : `M${n2(start - w * 0.25)},${n2(q)}H${n2(start + w * 1.25)}`;
905
+ marks.push(shape === 'circle' ? { key: `t${i}-${k}`, d, fill: tc, index: i, className: 'target' } : { key: `t${i}-${k}`, d, stroke: tc, strokeWidth: 3, index: i, className: 'target' });
906
+ }
907
+ anchorAt(s.y[i]);
908
+ }
909
+ else {
910
+ // column, bar, waterfall, range column
911
+ const hasRange = s.low && s.high;
912
+ const v0 = hasRange ? s.low?.[i] : p.y0 ? p.y0[i] : 0;
913
+ const v1 = hasRange ? s.high?.[i] : p.y1[i];
914
+ if (!Number.isFinite(v1))
915
+ continue;
916
+ let fill = pointColor(i);
917
+ if (p.kinds) {
918
+ const k = p.kinds[i];
919
+ fill = k === 'down' ? (s.options.downColor ?? SEMANTIC.down) : k === 'total' || k === 'subtotal' ? (s.options.color ?? SEMANTIC.accent) : (s.options.upColor ?? s.color);
920
+ }
921
+ rectBetween(v0, v1, `r${i}`, fill);
922
+ anchorAt(v1);
923
+ if (p.kinds && s.options.connectors !== false && i < n - 1) {
924
+ const q = ys.map(p.y1[i]);
925
+ const nextStart = xs.map(s.x[i + 1]) - groupWidth / 2 + slotIndex * one;
926
+ marks.push({ key: `cn${i}`, d: spec.horizontal ? `M${n2(q)},${n2(start + w)}V${n2(nextStart)}` : `M${n2(start + w)},${n2(q)}H${n2(nextStart)}`, stroke: SEMANTIC.axis, strokeWidth: 1 });
927
+ }
928
+ }
929
+ }
930
+ drawn += count;
931
+ }
932
+ // Error bars.
933
+ if ((p.errLow && p.errHigh) || (p.errXLow && p.errXHigh)) {
934
+ const caps = s.options.errorBars?.caps !== false;
935
+ let d = '';
936
+ // One whisker from a to b across the value axis (`alongY`) or the x axis, at the point.
937
+ const whisker = (a, b, alongY, i) => {
938
+ const vertical = alongY !== spec.horizontal;
939
+ const c = vertical ? px[i] : py[i];
940
+ d += vertical ? `M${n2(c)},${n2(a)}V${n2(b)}` : `M${n2(a)},${n2(c)}H${n2(b)}`;
941
+ if (caps)
942
+ d += vertical ? `M${n2(c - 4)},${n2(a)}H${n2(c + 4)}M${n2(c - 4)},${n2(b)}H${n2(c + 4)}` : `M${n2(a)},${n2(c - 4)}V${n2(c + 4)}M${n2(b)},${n2(c - 4)}V${n2(c + 4)}`;
943
+ };
944
+ for (let i = 0; i < n; i++) {
945
+ if (!Number.isFinite(px[i]))
946
+ continue;
947
+ if (p.errLow && p.errHigh)
948
+ whisker(ys.map(p.errLow[i]), ys.map(p.errHigh[i]), true, i);
949
+ if (p.errXLow && p.errXHigh)
950
+ whisker(xs.map(p.errXLow[i]), xs.map(p.errXHigh[i]), false, i);
951
+ }
952
+ marks.push({ key: 'err', d, stroke: SEMANTIC.text, strokeWidth: 1.25 });
953
+ }
954
+ // Data labels.
955
+ if (s.options.labels && n <= 2000) {
956
+ const opt = typeof s.options.labels === 'object' ? s.options.labels : {};
957
+ // Without a label format, labels read like the value axis (`yAxis.format`).
958
+ const f = typeof opt.format === 'function' ? null : (opt.format === undefined ? yvFmt : valueFmt(opt.format));
959
+ for (let i = 0; i < n; i++) {
960
+ const x = px[i];
961
+ const y = py[i];
962
+ const v = valueAt(i);
963
+ if (!Number.isFinite(x) || !Number.isFinite(y) || (!Number.isFinite(v) && !p.boxes))
964
+ continue;
965
+ if (v === 0 && opt.showZero === false)
966
+ continue;
967
+ const label = typeof opt.format === 'function' ? opt.format({ seriesId: s.id, seriesName: s.name, index: i, datum: s.data[i] ?? {}, x: readField(s.data[i], s.options.xField), y: v, xText: xFmt(i), yText: yTextOf(i), color: s.color }) : f(v);
968
+ const pos = opt.position ?? 'auto';
969
+ const neg = v < 0;
970
+ const off = pos === 'middle' ? 0 : pos === 'bottom' ? -1 : 1;
971
+ if (spec.horizontal)
972
+ labels.push({ key: `l${i}`, x: x + (neg ? -1 : 1) * off * 6, y: y + 4, text: label, anchor: off === 0 ? 'middle' : neg ? 'end' : 'start', angle: opt.angle, index: i });
973
+ else
974
+ labels.push({ key: `l${i}`, x, y: y - (neg ? -1 : 1) * off * 8 + (neg && off ? 12 : 0), text: label, anchor: 'middle', angle: opt.angle, index: i });
975
+ }
976
+ }
977
+ if (s.options.lastValue && n > 0) {
978
+ let last = n - 1;
979
+ while (last >= 0 && !Number.isFinite(s.y[last]))
980
+ last--;
981
+ if (last >= 0) {
982
+ const fmtL = typeof s.options.lastValue === 'object' ? valueFmt(s.options.lastValue.format) : (yAxisModel?.format ?? yFmt);
983
+ labels.push({ key: 'last', x: spec.horizontal ? px[last] : plot.x + plot.width + 4, y: spec.horizontal ? plot.y - 4 : py[last] + 4, text: fmtL(s.y[last]), anchor: 'start' });
984
+ }
985
+ }
986
+ if (s.options.inlineLabel && n > 0) {
987
+ let last = n - 1;
988
+ while (last >= 0 && !Number.isFinite(py[last]))
989
+ last--;
990
+ if (last >= 0)
991
+ labels.push({ key: 'inline', x: px[last] + 6, y: py[last] + 4, text: s.name, anchor: 'start' });
992
+ }
993
+ }
994
+ allLabels.push(...labels);
995
+ const lo = typeof s.options.labels === 'object' ? s.options.labels : null;
996
+ if (lo && ((lo.overlap ?? 'none') !== 'none' || lo.dedupe))
997
+ smart.push({ at: seriesModels.length, mode: lo.overlap ?? 'none', dedupe: lo.dedupe === true });
998
+ seriesModels.push({
999
+ id: s.id,
1000
+ name: s.name,
1001
+ type: s.type,
1002
+ color: s.color,
1003
+ hidden: s.hidden,
1004
+ marks,
1005
+ labels,
1006
+ px,
1007
+ py,
1008
+ count: n,
1009
+ legendShape,
1010
+ tooltip: s.options.tooltip !== false,
1011
+ xText: xFmt,
1012
+ yText: yTextOf,
1013
+ yValue: (i) => s.y[i],
1014
+ inTable: !s.generated,
1015
+ sortedX: isSorted(spec.horizontal ? py : px),
1016
+ colorAt: pointColor,
1017
+ });
1018
+ }
1019
+ // Smart labels: one collision pass over the data labels, earlier series first; a colliding label hides,
1020
+ // shifts along y or x, or turns 90 degrees.
1021
+ const placed = [];
1022
+ const lh = lineHeight('sm');
1023
+ for (const { at, mode, dedupe } of smart) {
1024
+ const sm = seriesModels[at];
1025
+ let prev = '';
1026
+ const list = sm.labels.filter((l) => {
1027
+ const same = dedupe && l.index !== undefined && l.text === prev;
1028
+ if (l.index !== undefined)
1029
+ prev = l.text;
1030
+ return !same;
1031
+ });
1032
+ const boxes = list.map((l) => {
1033
+ const w = textWidth(l.text) + 2;
1034
+ return { x: l.anchor === 'middle' ? l.x : l.anchor === 'start' ? l.x + w / 2 : l.x - w / 2, y: l.y - lh * 0.32, width: w, height: lh };
1035
+ });
1036
+ const before = boxes.map((b) => [b.x, b.y]);
1037
+ const vis = resolveLabelOverlaps([...placed, ...boxes], mode === 'rotate90' ? 'hide' : mode, plot).slice(placed.length);
1038
+ const labels = [];
1039
+ list.forEach((l, k) => {
1040
+ const b = boxes[k];
1041
+ const [bx, by] = before[k];
1042
+ if (vis[k]) {
1043
+ placed.push(b);
1044
+ labels.push({ ...l, x: l.x + b.x - bx, y: l.y + b.y - by });
1045
+ }
1046
+ else if (mode === 'rotate90')
1047
+ labels.push({ ...l, angle: -90, anchor: 'start' });
1048
+ });
1049
+ seriesModels[at] = { ...sm, labels };
1050
+ }
1051
+ // Stack total labels.
1052
+ const stackLabels = [];
1053
+ if (props.stackLabels) {
1054
+ const f = valueFmt(typeof props.stackLabels === 'object' ? props.stackLabels.format : undefined);
1055
+ for (const [k, t] of stackTotals.entries()) {
1056
+ const xs = scales.get(t.xAxis);
1057
+ const ys = scales.get(t.yAxis);
1058
+ if (!xs || !ys)
1059
+ continue;
1060
+ for (let i = 0; i < t.totals.length; i++) {
1061
+ // The label sits past the end of the positive stack (negative parts hang below zero).
1062
+ const [x, y] = toPx(xs, ys, t.x[i], t.top[i] || t.totals[i]);
1063
+ if (!Number.isFinite(x) || !Number.isFinite(y))
1064
+ continue;
1065
+ stackLabels.push(spec.horizontal ? { key: `st${k}-${i}`, x: x + 6, y: y + 4, text: f(t.totals[i]), anchor: 'start' } : { key: `st${k}-${i}`, x, y: y - 6, text: f(t.totals[i]), anchor: 'middle' });
1066
+ }
1067
+ }
1068
+ }
1069
+ // Summary and table.
1070
+ const kindName = text[visible[0]?.type ?? 'chart'];
1071
+ const xAxisModel = axisModels.find((a) => a.id === 'x');
1072
+ const tableSeries = seriesModels.filter((m) => m.inTable && !m.hidden);
1073
+ const firstX = xAxisModel?.ticks.find((t) => !t.hidden);
1074
+ const lastX = xAxisModel ? [...xAxisModel.ticks].reverse().find((t) => !t.hidden) : undefined;
1075
+ // Series descriptions follow the summary and the table caption.
1076
+ const seriesText = tableSeries.flatMap((m) => {
1077
+ const d = allSeries.find((s) => s.id === m.id)?.options.description;
1078
+ return d ? [`${m.name}: ${d}.`] : [];
1079
+ }).join(' ');
1080
+ const axis = xAxisModel?.title ?? text.xAxis;
1081
+ // "Line chart, 2 series, x from Jan to Dec. Sales: 12 points, minimum 3, maximum 9, trending up."
1082
+ const describe = () => {
1083
+ const stats = tableSeries.map((m) => seriesStats(yColumn(m)));
1084
+ return [
1085
+ say(!stats.some((s) => s.count) ? text.summaryEmpty : firstX ? text.summaryRange : text.summary, { chart: props.title ? `${kindName}: ${props.title}` : kindName, noData: text.noData, count: stats.length, axis, from: `${firstX?.text.join(' ')}`, to: `${lastX?.text.join(' ')}` }),
1086
+ // Detail of the first five series.
1087
+ ...stats.slice(0, 5).flatMap((s, i) => (s.count ? [say(text.seriesSummary ?? `{series}: {count} point${s.count === 1 ? '' : 's'}, minimum {min}, maximum {max}, {trend}.`, { series: tableSeries[i].name, count: s.count, min: yFmt(s.min), max: yFmt(s.max), trend: text[trendOf(s)] })] : [])),
1088
+ ].join(' ');
1089
+ };
1090
+ const summaryText = props.description ?? describe();
1091
+ const summary = seriesText ? `${summaryText} ${seriesText}` : summaryText;
1092
+ let table = null;
1093
+ if (props.accessibleTable !== false && tableSeries.length > 0) {
1094
+ const longest = tableSeries.reduce((a, b) => (b.count > a.count ? b : a));
1095
+ table = tableModel(seriesText ? `${props.title ?? text.table}. ${seriesText}` : (props.title ?? text.table), [axis, ...tableSeries.map((m) => m.name)], longest.count, (r, c) => (c === 0 ? longest.xText(r) : (tableSeries[c - 1]?.yText(r) ?? '')));
1096
+ }
1097
+ const legend = props.legend === false ? [] : legendItems(props, allSeries, seriesModels);
1098
+ return {
1099
+ width,
1100
+ height,
1101
+ frame,
1102
+ plot,
1103
+ axes: axisModels,
1104
+ series: seriesModels,
1105
+ legend,
1106
+ horizontal: spec.horizontal,
1107
+ empty,
1108
+ summary,
1109
+ table,
1110
+ pointText: (s, i) => say(text.point, { series: s.name, x: s.xText(i), value: s.yText(i), index: i + 1, count: s.count }),
1111
+ drawnPoints: drawn,
1112
+ stackLabels,
1113
+ xAxisId: 'x',
1114
+ yAxisId: 'y',
1115
+ };
1116
+ }
1117
+ const GROUP_ROW = lineHeight('sm') + 6;
1118
+ /** Pixel spans of the multi-level label cells; `from` / `to` are categories or axis values. */
1119
+ function labelGroupCells(a, scale, horizontalSide) {
1120
+ const band = scale.kind === 'category' || scale.kind === 'timeCategory';
1121
+ const at = (v, end) => {
1122
+ if (!band)
1123
+ return scale.map(typeof v === 'string' ? toTime(v) : v);
1124
+ const i = typeof v === 'string' ? a.categories.indexOf(v) : v;
1125
+ const b = scale;
1126
+ return b.map(i) + ((end ? 1 : -1) * b.step) / 2;
1127
+ };
1128
+ let off = 0;
1129
+ return (a.options.labelGroups ?? []).flatMap((g, row) => {
1130
+ const size = horizontalSide ? GROUP_ROW : Math.ceil(Math.max(0, ...g.levels.map((l) => textWidth(l.label)))) + 10;
1131
+ const cells = g.levels.map((l, k) => {
1132
+ const p0 = at(l.from, false);
1133
+ const p1 = at(l.to, true);
1134
+ return { key: `${row}-${k}`, a: Math.min(p0, p1), b: Math.max(p0, p1), off, size, label: l.label, border: g.border ?? 'rectangle' };
1135
+ });
1136
+ off += size;
1137
+ return cells;
1138
+ });
1139
+ }
1140
+ /** The spec with every axis hidden and without grid lines (the polar frame). */
1141
+ export function hideAxes(spec, series = spec.series) {
1142
+ return { ...spec, series, axes: new Map([...spec.axes].map(([id, a]) => [id, { ...a, options: { ...a.options, hidden: true, gridLines: false } }])) };
1143
+ }
1144
+ /** Current domains of the continuous axes (the zoom range that shows the present view). */
1145
+ export function currentZoom(model) {
1146
+ const out = {};
1147
+ for (const a of model.axes)
1148
+ if (a.scale.kind !== 'category' && a.scale.kind !== 'timeCategory')
1149
+ out[a.id] = [a.scale.domain[0], a.scale.domain[1]];
1150
+ return out;
1151
+ }
1152
+ function horizontalAxisRange(a, range, horizontal, horizontalSide) {
1153
+ // In a horizontal (transposed) chart the category axis runs top to bottom.
1154
+ if (horizontal && a.direction === 'x' && !horizontalSide)
1155
+ return [range[1], range[0]];
1156
+ return range;
1157
+ }
1158
+ /** Same-side axes of different panes share one frame block per slot: the thickest sets its size. */
1159
+ function mergeSlots(slotOf, list) {
1160
+ if (!slotOf.size)
1161
+ return [...list];
1162
+ const out = new Map();
1163
+ for (const b of list) {
1164
+ const k = slotOf.get(b.id) ?? b.id;
1165
+ const p = out.get(k);
1166
+ out.set(k, p ? { ...p, labelThickness: Math.max(p.labelThickness, b.labelThickness), title: p.title ?? b.title, hidden: p.hidden && b.hidden } : { ...b, id: k });
1167
+ }
1168
+ return [...out.values()];
1169
+ }
1170
+ /** Moves a centered legend to the start or end of its edge (`legend.align`); the plot does not change. */
1171
+ function alignLegend(frame, props) {
1172
+ const l = frame.legend;
1173
+ const align = typeof props.legend === 'object' ? props.legend.align : undefined;
1174
+ if (!l || !align || align === 'center')
1175
+ return frame;
1176
+ const side = l.position === 'start' || l.position === 'end';
1177
+ const end = align === 'end' ? 1 : -1;
1178
+ // A centered legend has equal room on both sides: (x - padding) horizontally; vertically the room ends at the bottom padding.
1179
+ const room = side ? frame.height - FRAME_PADDING - l.y - l.height : l.x - FRAME_PADDING;
1180
+ const dx = side ? 0 : end * room;
1181
+ const dy = side ? end * room : 0;
1182
+ const move = (r) => ({ ...r, x: r.x + dx, y: r.y + dy });
1183
+ return { ...frame, legend: { ...move(l), items: l.items.map(move), title: l.title ? move(l.title) : undefined } };
1184
+ }
1185
+ /** Color of `v` inside a color range: one color, or several splitting the range into equal steps. */
1186
+ function rangeColor(r, v) {
1187
+ const k = r.to > r.from ? Math.floor(((v - r.from) / (r.to - r.from)) * r.colors.length) : 0;
1188
+ return r.colors[Math.min(r.colors.length - 1, Math.max(0, k))];
1189
+ }
1190
+ /** Start and end pixel of panes `index` .. `index + span - 1`: sizes in px or `'n%'`, the rest shared evenly. */
1191
+ export function paneSpan(sizes, index, span, start, length) {
1192
+ if (!sizes?.length)
1193
+ return [start, start + length];
1194
+ // Panes are PANE_GAP apart, so the edge labels of neighboring panes never meet.
1195
+ const gap = sizes.length > 1 ? PANE_GAP : 0;
1196
+ const room = length - gap * (sizes.length - 1);
1197
+ const px = sizes.map((x) => {
1198
+ const v = typeof x === 'object' ? x.size : x;
1199
+ return typeof v === 'number' ? v : typeof v === 'string' ? (Number.parseFloat(v) / 100) * room : Number.NaN;
1200
+ });
1201
+ const free = px.filter((v) => !Number.isFinite(v)).length;
1202
+ const each = free ? Math.max(0, room - px.reduce((t, v) => t + (Number.isFinite(v) ? v : 0), 0)) / free : 0;
1203
+ const edges = [start];
1204
+ for (const v of px)
1205
+ edges.push(edges[edges.length - 1] + (Number.isFinite(v) ? v : each) + gap);
1206
+ const i = Math.min(Math.max(0, index), sizes.length - 1);
1207
+ return [edges[i], edges[Math.min(sizes.length, i + Math.max(1, span))] - gap];
1208
+ }
1209
+ /** Space between chart panes. */
1210
+ const PANE_GAP = 16;
1211
+ function isSorted(xs) {
1212
+ let prev = Number.NEGATIVE_INFINITY;
1213
+ for (let i = 0; i < xs.length; i++) {
1214
+ const v = xs[i];
1215
+ if (!Number.isFinite(v))
1216
+ continue;
1217
+ if (v < prev)
1218
+ return false;
1219
+ prev = v;
1220
+ }
1221
+ return true;
1222
+ }
1223
+ /** Smallest x distance in px (band width for columns on numeric axes). */
1224
+ function estimateBand(xs, scale) {
1225
+ let min = Number.POSITIVE_INFINITY;
1226
+ for (let i = 1; i < Math.min(xs.length, 5000); i++) {
1227
+ const d = Math.abs(scale.map(xs[i]) - scale.map(xs[i - 1]));
1228
+ if (d > 0 && d < min)
1229
+ min = d;
1230
+ }
1231
+ const length = Math.abs(scale.range[1] - scale.range[0]);
1232
+ return Number.isFinite(min) ? min : length / Math.max(1, xs.length);
1233
+ }
1234
+ function areaPathH(along, top, base) {
1235
+ // Horizontal areas: swap coordinates of a vertical area path.
1236
+ const n = along.length;
1237
+ let d = '';
1238
+ const topAt = (i) => (typeof top === 'number' ? top : top[i]);
1239
+ const baseAt = (i) => (typeof base === 'number' ? base : base[i]);
1240
+ for (let i = 0; i < n; i++)
1241
+ d += `${i ? 'L' : 'M'}${n2(topAt(i))},${n2(along[i])}`;
1242
+ for (let i = n - 1; i >= 0; i--)
1243
+ d += `L${n2(baseAt(i))},${n2(along[i])}`;
1244
+ return n ? `${d}Z` : '';
1245
+ }
1246
+ function addMarkers(marks, s, px, py, color, from, to) {
1247
+ const o = typeof s.options.markers === 'object' ? s.options.markers : {};
1248
+ const shape = (o.shape ?? 'circle');
1249
+ const size = o.size ?? 7;
1250
+ const stroke = shape === 'cross' || shape === 'plus' || shape === 'multiply' || shape === 'horizontalLine' || shape === 'verticalLine';
1251
+ for (let i = from; i < to; i++) {
1252
+ const x = px[i];
1253
+ const y = py[i];
1254
+ if (!Number.isFinite(x) || !Number.isFinite(y))
1255
+ continue;
1256
+ const c = color(i);
1257
+ marks.push(stroke || o.filled === false ? { key: `m${i}`, d: symbolPath(shape, x, y, size), stroke: c, strokeWidth: 2, fill: o.filled === false && !stroke ? 'var(--salmon-surface-base)' : 'none', index: i, className: 'marker' } : { key: `m${i}`, d: symbolPath(shape, x, y, size), fill: c, stroke: 'var(--salmon-surface-base)', strokeWidth: 1, index: i, className: 'marker' });
1258
+ }
1259
+ }
1260
+ /** Legend entries per `legend.mode`: series, the first series' points, color ranges or one gradient key. */
1261
+ function legendEntries(props, series) {
1262
+ const o = typeof props.legend === 'object' ? props.legend : {};
1263
+ const ranges = props.colorRanges ?? [];
1264
+ let list;
1265
+ if (o.mode === 'point') {
1266
+ const s = series.find((x) => !x.hidden && !x.generated);
1267
+ list = s ? s.data.map((d, index) => ({ id: `${s.id}:${index}`, label: String(readField(d, s.options.tooltipField ?? s.options.xField) ?? index + 1), series: s, index })) : [];
1268
+ }
1269
+ else if (o.mode === 'range')
1270
+ list = ranges.map((r, k) => ({ id: `range-${k}`, label: r.label ?? `${n2(r.from)} – ${n2(r.to)}`, range: r }));
1271
+ else if (o.mode === 'gradient')
1272
+ list = ranges.length ? [{ id: 'gradient', label: `${n2(Math.min(...ranges.map((r) => r.from)))} – ${n2(Math.max(...ranges.map((r) => r.to)))}` }] : [];
1273
+ else
1274
+ list = series.map((s) => ({ id: s.id, label: s.name, series: s }));
1275
+ return o.reverse ? list.reverse() : list;
1276
+ }
1277
+ function legendSpec(props, series) {
1278
+ const o = typeof props.legend === 'object' ? props.legend : {};
1279
+ if (props.legend === false || (props.legend === undefined && series.filter((s) => !s.generated || s.options.trendlines).length < 2))
1280
+ return null;
1281
+ const items = legendEntries(props, series).map((e) => ({ label: e.label }));
1282
+ return { position: o.position ?? 'auto', items, title: o.title, maxLabelWidth: o.maxLabelWidth, overflow: o.overflow, columns: o.orientation === 'vertical' ? 1 : o.columns };
1283
+ }
1284
+ function legendItems(props, series, models) {
1285
+ if (!legendSpec(props, series))
1286
+ return [];
1287
+ const ranges = props.colorRanges ?? [];
1288
+ return legendEntries(props, series).map((e) => {
1289
+ const s = e.series;
1290
+ const m = s ? models.find((x) => x.id === s.id) : undefined;
1291
+ if (e.range)
1292
+ return { id: e.id, label: e.label, color: e.range.colors[0] ?? '', shape: 'rectangle', hidden: false };
1293
+ if (!s)
1294
+ return { id: e.id, label: e.label, color: ranges[0]?.colors[0] ?? '', shape: 'gradient', hidden: false, stops: ranges.flatMap((r) => r.colors) };
1295
+ if (e.index !== undefined)
1296
+ return { id: e.id, label: e.label, color: m?.colorAt(e.index) ?? s.color, shape: m?.legendShape ?? 'column', hidden: false, seriesId: s.id, index: e.index };
1297
+ return { id: s.id, label: s.name, color: s.color, shape: m?.legendShape ?? 'column', hidden: s.hidden, lineStyle: s.options.lineStyle, seriesId: s.id };
1298
+ });
1299
+ }
1300
+ //# sourceMappingURL=model.js.map