@k2b/ui 0.51.0 → 0.53.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 (442) hide show
  1. package/dist/base.css +20 -0
  2. package/dist/browser/actions/SplitButton.js +10 -1
  3. package/dist/browser/actions/SplitButton.js.map +1 -1
  4. package/dist/browser/actions/Toolbar.js +91 -53
  5. package/dist/browser/actions/Toolbar.js.map +1 -1
  6. package/dist/browser/actions/index.js +1 -1
  7. package/dist/browser/actions/index.js.map +1 -1
  8. package/dist/browser/charts/core/area.js +1 -1
  9. package/dist/browser/charts/core/area.js.map +1 -1
  10. package/dist/browser/charts/core/bar-base-render.js +10 -0
  11. package/dist/browser/charts/core/bar-base-render.js.map +1 -0
  12. package/dist/browser/charts/core/bar-common.js +63 -0
  13. package/dist/browser/charts/core/bar-common.js.map +1 -0
  14. package/dist/browser/charts/core/bar-labels.js +17 -0
  15. package/dist/browser/charts/core/bar-labels.js.map +1 -0
  16. package/dist/browser/charts/core/bar-render.js +10 -0
  17. package/dist/browser/charts/core/bar-render.js.map +1 -0
  18. package/dist/browser/charts/core/bar-series.js +112 -0
  19. package/dist/browser/charts/core/bar-series.js.map +1 -0
  20. package/dist/browser/charts/core/bubble.js +166 -0
  21. package/dist/browser/charts/core/bubble.js.map +1 -0
  22. package/dist/browser/charts/core/calendar.js +63 -47
  23. package/dist/browser/charts/core/calendar.js.map +1 -1
  24. package/dist/browser/charts/core/default-styles.js +83 -0
  25. package/dist/browser/charts/core/default-styles.js.map +1 -0
  26. package/dist/browser/charts/core/dot-options.js +28 -0
  27. package/dist/browser/charts/core/dot-options.js.map +1 -0
  28. package/dist/browser/charts/core/dots.js +12 -0
  29. package/dist/browser/charts/core/dots.js.map +1 -0
  30. package/dist/browser/charts/core/funnel-layout.js +79 -0
  31. package/dist/browser/charts/core/funnel-layout.js.map +1 -0
  32. package/dist/browser/charts/core/funnel.js +27 -0
  33. package/dist/browser/charts/core/funnel.js.map +1 -0
  34. package/dist/browser/charts/core/index.js +19 -2
  35. package/dist/browser/charts/core/index.js.map +1 -1
  36. package/dist/browser/charts/core/line-base.js +102 -0
  37. package/dist/browser/charts/core/line-base.js.map +1 -0
  38. package/dist/browser/charts/core/line-details.js +264 -0
  39. package/dist/browser/charts/core/line-details.js.map +1 -0
  40. package/dist/browser/charts/core/line-options.js +32 -0
  41. package/dist/browser/charts/core/line-options.js.map +1 -0
  42. package/dist/browser/charts/core/line-paths.js +60 -0
  43. package/dist/browser/charts/core/line-paths.js.map +1 -0
  44. package/dist/browser/charts/core/line.js +15 -0
  45. package/dist/browser/charts/core/line.js.map +1 -0
  46. package/dist/browser/charts/core/palette.js +11 -0
  47. package/dist/browser/charts/core/palette.js.map +1 -0
  48. package/dist/browser/charts/core/pareto.js +138 -0
  49. package/dist/browser/charts/core/pareto.js.map +1 -0
  50. package/dist/browser/charts/core/radar.js +101 -0
  51. package/dist/browser/charts/core/radar.js.map +1 -0
  52. package/dist/browser/charts/core/registry.js +14 -2
  53. package/dist/browser/charts/core/registry.js.map +1 -1
  54. package/dist/browser/charts/core/render-size.js +7 -2
  55. package/dist/browser/charts/core/render-size.js.map +1 -1
  56. package/dist/browser/charts/core/render.js +42 -7
  57. package/dist/browser/charts/core/render.js.map +1 -1
  58. package/dist/browser/charts/core/sankey-size.js +105 -0
  59. package/dist/browser/charts/core/sankey-size.js.map +1 -0
  60. package/dist/browser/charts/core/sankey.js +280 -0
  61. package/dist/browser/charts/core/sankey.js.map +1 -0
  62. package/dist/browser/charts/core/snapshot.js +5 -3
  63. package/dist/browser/charts/core/snapshot.js.map +1 -1
  64. package/dist/browser/charts/core/svg-barGauge.js +67 -0
  65. package/dist/browser/charts/core/svg-barGauge.js.map +1 -0
  66. package/dist/browser/charts/core/svg-boxplot.js +127 -0
  67. package/dist/browser/charts/core/svg-boxplot.js.map +1 -0
  68. package/dist/browser/charts/core/svg-common.js +1003 -0
  69. package/dist/browser/charts/core/svg-common.js.map +1 -0
  70. package/dist/browser/charts/core/svg-format.js +7 -0
  71. package/dist/browser/charts/core/svg-format.js.map +1 -0
  72. package/dist/browser/charts/core/svg-gauge.js +185 -0
  73. package/dist/browser/charts/core/svg-gauge.js.map +1 -0
  74. package/dist/browser/charts/core/svg-heatmap.js +80 -0
  75. package/dist/browser/charts/core/svg-heatmap.js.map +1 -0
  76. package/dist/browser/charts/core/svg-histogram.js +73 -0
  77. package/dist/browser/charts/core/svg-histogram.js.map +1 -0
  78. package/dist/browser/charts/core/svg-renderers.js +10 -1876
  79. package/dist/browser/charts/core/svg-renderers.js.map +1 -1
  80. package/dist/browser/charts/core/svg-scatter.js +114 -0
  81. package/dist/browser/charts/core/svg-scatter.js.map +1 -0
  82. package/dist/browser/charts/core/treemap.js +138 -0
  83. package/dist/browser/charts/core/treemap.js.map +1 -0
  84. package/dist/browser/charts/description.js.map +1 -1
  85. package/dist/browser/charts.js +2 -1
  86. package/dist/browser/charts.js.map +1 -1
  87. package/dist/browser/content/ChartExplorer.js +22 -7
  88. package/dist/browser/content/ChartExplorer.js.map +1 -1
  89. package/dist/browser/content/ChartRoot.js +88 -57
  90. package/dist/browser/content/ChartRoot.js.map +1 -1
  91. package/dist/browser/content/ChartSnapshotView.js +22 -12
  92. package/dist/browser/content/ChartSnapshotView.js.map +1 -1
  93. package/dist/browser/content/DataTable.js +186 -193
  94. package/dist/browser/content/DataTable.js.map +1 -1
  95. package/dist/browser/content/Lightbox.js +55 -23
  96. package/dist/browser/content/Lightbox.js.map +1 -1
  97. package/dist/browser/content/ThumbnailStrip.js +174 -0
  98. package/dist/browser/content/ThumbnailStrip.js.map +1 -0
  99. package/dist/browser/content/chart-bar.js +139 -191
  100. package/dist/browser/content/chart-bar.js.map +1 -1
  101. package/dist/browser/content/chart-calendar.js +30 -14
  102. package/dist/browser/content/chart-calendar.js.map +1 -1
  103. package/dist/browser/content/chart-inspection-core.js +41 -14
  104. package/dist/browser/content/chart-inspection-core.js.map +1 -1
  105. package/dist/browser/content/chart-message-catalog.js +26 -0
  106. package/dist/browser/content/chart-message-catalog.js.map +1 -1
  107. package/dist/browser/content/chart-sankey.js +13 -0
  108. package/dist/browser/content/chart-sankey.js.map +1 -0
  109. package/dist/browser/content/chart-svg.js +1 -1
  110. package/dist/browser/content/chart-svg.js.map +1 -1
  111. package/dist/browser/content/chart-time-axis.js +10 -108
  112. package/dist/browser/content/chart-time-axis.js.map +1 -1
  113. package/dist/browser/content/chart-time-calendar.js +108 -0
  114. package/dist/browser/content/chart-time-calendar.js.map +1 -0
  115. package/dist/browser/content/index.js +1 -0
  116. package/dist/browser/content/index.js.map +1 -1
  117. package/dist/browser/content/thumbnail-strip-messages.js +24 -0
  118. package/dist/browser/content/thumbnail-strip-messages.js.map +1 -0
  119. package/dist/browser/inputs/ChoiceInputs.js +132 -101
  120. package/dist/browser/inputs/ChoiceInputs.js.map +1 -1
  121. package/dist/browser/inputs/DatePicker.js +30 -21
  122. package/dist/browser/inputs/DatePicker.js.map +1 -1
  123. package/dist/browser/inputs/NumberInput.js +188 -160
  124. package/dist/browser/inputs/NumberInput.js.map +1 -1
  125. package/dist/browser/inputs/Select.js +433 -400
  126. package/dist/browser/inputs/Select.js.map +1 -1
  127. package/dist/browser/inputs/Switch.js +203 -77
  128. package/dist/browser/inputs/Switch.js.map +1 -1
  129. package/dist/browser/inputs/TextInput.js +212 -188
  130. package/dist/browser/inputs/TextInput.js.map +1 -1
  131. package/dist/browser/inputs/field-contract.js.map +1 -1
  132. package/dist/browser/inputs/field-suggestion-slot.js +21 -0
  133. package/dist/browser/inputs/field-suggestion-slot.js.map +1 -0
  134. package/dist/browser/inputs/field-suggestion-types.js +2 -0
  135. package/dist/browser/inputs/field-suggestion-types.js.map +1 -0
  136. package/dist/browser/inputs/field-suggestion.js +502 -0
  137. package/dist/browser/inputs/field-suggestion.js.map +1 -0
  138. package/dist/browser/inputs/index.js +2 -0
  139. package/dist/browser/inputs/index.js.map +1 -1
  140. package/dist/browser/inputs/markdown/MarkdownSelectionToolbar.js +330 -0
  141. package/dist/browser/inputs/markdown/MarkdownSelectionToolbar.js.map +1 -0
  142. package/dist/browser/inputs/suggestion-messages.js +160 -0
  143. package/dist/browser/inputs/suggestion-messages.js.map +1 -0
  144. package/dist/browser/internal/field.js +96 -77
  145. package/dist/browser/internal/field.js.map +1 -1
  146. package/dist/browser/layout/AppOverview.js +15 -5
  147. package/dist/browser/layout/AppOverview.js.map +1 -1
  148. package/dist/browser/layout/AppWorkspace.js +7 -5
  149. package/dist/browser/layout/AppWorkspace.js.map +1 -1
  150. package/dist/browser/layout/DetailPanel.js +66 -411
  151. package/dist/browser/layout/DetailPanel.js.map +1 -1
  152. package/dist/browser/layout/DetailSections.js +8 -7
  153. package/dist/browser/layout/DetailSections.js.map +1 -1
  154. package/dist/browser/layout/Discussion.js +194 -246
  155. package/dist/browser/layout/Discussion.js.map +1 -1
  156. package/dist/browser/layout/PanelDialog.js +92 -68
  157. package/dist/browser/layout/PanelDialog.js.map +1 -1
  158. package/dist/browser/layout/detail-panel-messages.js +1 -1
  159. package/dist/browser/layout/detail-panel-messages.js.map +1 -1
  160. package/dist/browser/layout/index.js.map +1 -1
  161. package/dist/browser/surfaces/Field.js +102 -0
  162. package/dist/browser/surfaces/Field.js.map +1 -0
  163. package/dist/browser/surfaces/LinkCard.js +70 -21
  164. package/dist/browser/surfaces/LinkCard.js.map +1 -1
  165. package/dist/browser/surfaces/NoticeRow.js +75 -0
  166. package/dist/browser/surfaces/NoticeRow.js.map +1 -0
  167. package/dist/browser/surfaces/Section.js +441 -0
  168. package/dist/browser/surfaces/Section.js.map +1 -0
  169. package/dist/browser/surfaces/StatCell.js +82 -70
  170. package/dist/browser/surfaces/StatCell.js.map +1 -1
  171. package/dist/browser/surfaces/index.js +3 -0
  172. package/dist/browser/surfaces/index.js.map +1 -1
  173. package/dist/browser/surfaces/section-messages.js +25 -0
  174. package/dist/browser/surfaces/section-messages.js.map +1 -0
  175. package/dist/browser/surfaces/stat-cell-messages.js +4 -2
  176. package/dist/browser/surfaces/stat-cell-messages.js.map +1 -1
  177. package/dist/browser/widgets/DashboardFrame.js +93 -88
  178. package/dist/browser/widgets/DashboardFrame.js.map +1 -1
  179. package/dist/ssr/actions/SplitButton.js +10 -1
  180. package/dist/ssr/actions/SplitButton.js.map +1 -1
  181. package/dist/ssr/actions/Toolbar.js +48 -18
  182. package/dist/ssr/actions/Toolbar.js.map +1 -1
  183. package/dist/ssr/actions/index.js +1 -1
  184. package/dist/ssr/actions/index.js.map +1 -1
  185. package/dist/ssr/charts/core/area.js +1 -1
  186. package/dist/ssr/charts/core/area.js.map +1 -1
  187. package/dist/ssr/charts/core/bar-base-render.js +10 -0
  188. package/dist/ssr/charts/core/bar-base-render.js.map +1 -0
  189. package/dist/ssr/charts/core/bar-common.js +63 -0
  190. package/dist/ssr/charts/core/bar-common.js.map +1 -0
  191. package/dist/ssr/charts/core/bar-labels.js +17 -0
  192. package/dist/ssr/charts/core/bar-labels.js.map +1 -0
  193. package/dist/ssr/charts/core/bar-render.js +10 -0
  194. package/dist/ssr/charts/core/bar-render.js.map +1 -0
  195. package/dist/ssr/charts/core/bar-series.js +112 -0
  196. package/dist/ssr/charts/core/bar-series.js.map +1 -0
  197. package/dist/ssr/charts/core/bubble.js +166 -0
  198. package/dist/ssr/charts/core/bubble.js.map +1 -0
  199. package/dist/ssr/charts/core/calendar.js +63 -47
  200. package/dist/ssr/charts/core/calendar.js.map +1 -1
  201. package/dist/ssr/charts/core/default-styles.js +83 -0
  202. package/dist/ssr/charts/core/default-styles.js.map +1 -0
  203. package/dist/ssr/charts/core/dot-options.js +28 -0
  204. package/dist/ssr/charts/core/dot-options.js.map +1 -0
  205. package/dist/ssr/charts/core/dots.js +12 -0
  206. package/dist/ssr/charts/core/dots.js.map +1 -0
  207. package/dist/ssr/charts/core/funnel-layout.js +79 -0
  208. package/dist/ssr/charts/core/funnel-layout.js.map +1 -0
  209. package/dist/ssr/charts/core/funnel.js +27 -0
  210. package/dist/ssr/charts/core/funnel.js.map +1 -0
  211. package/dist/ssr/charts/core/index.js +19 -2
  212. package/dist/ssr/charts/core/index.js.map +1 -1
  213. package/dist/ssr/charts/core/line-base.js +102 -0
  214. package/dist/ssr/charts/core/line-base.js.map +1 -0
  215. package/dist/ssr/charts/core/line-details.js +264 -0
  216. package/dist/ssr/charts/core/line-details.js.map +1 -0
  217. package/dist/ssr/charts/core/line-options.js +32 -0
  218. package/dist/ssr/charts/core/line-options.js.map +1 -0
  219. package/dist/ssr/charts/core/line-paths.js +60 -0
  220. package/dist/ssr/charts/core/line-paths.js.map +1 -0
  221. package/dist/ssr/charts/core/line.js +15 -0
  222. package/dist/ssr/charts/core/line.js.map +1 -0
  223. package/dist/ssr/charts/core/palette.js +11 -0
  224. package/dist/ssr/charts/core/palette.js.map +1 -0
  225. package/dist/ssr/charts/core/pareto.js +138 -0
  226. package/dist/ssr/charts/core/pareto.js.map +1 -0
  227. package/dist/ssr/charts/core/radar.js +101 -0
  228. package/dist/ssr/charts/core/radar.js.map +1 -0
  229. package/dist/ssr/charts/core/registry.js +14 -2
  230. package/dist/ssr/charts/core/registry.js.map +1 -1
  231. package/dist/ssr/charts/core/render-size.js +7 -2
  232. package/dist/ssr/charts/core/render-size.js.map +1 -1
  233. package/dist/ssr/charts/core/render.js +42 -7
  234. package/dist/ssr/charts/core/render.js.map +1 -1
  235. package/dist/ssr/charts/core/sankey-size.js +105 -0
  236. package/dist/ssr/charts/core/sankey-size.js.map +1 -0
  237. package/dist/ssr/charts/core/sankey.js +280 -0
  238. package/dist/ssr/charts/core/sankey.js.map +1 -0
  239. package/dist/ssr/charts/core/snapshot.js +5 -3
  240. package/dist/ssr/charts/core/snapshot.js.map +1 -1
  241. package/dist/ssr/charts/core/svg-barGauge.js +67 -0
  242. package/dist/ssr/charts/core/svg-barGauge.js.map +1 -0
  243. package/dist/ssr/charts/core/svg-boxplot.js +127 -0
  244. package/dist/ssr/charts/core/svg-boxplot.js.map +1 -0
  245. package/dist/ssr/charts/core/svg-common.js +1003 -0
  246. package/dist/ssr/charts/core/svg-common.js.map +1 -0
  247. package/dist/ssr/charts/core/svg-format.js +7 -0
  248. package/dist/ssr/charts/core/svg-format.js.map +1 -0
  249. package/dist/ssr/charts/core/svg-gauge.js +185 -0
  250. package/dist/ssr/charts/core/svg-gauge.js.map +1 -0
  251. package/dist/ssr/charts/core/svg-heatmap.js +80 -0
  252. package/dist/ssr/charts/core/svg-heatmap.js.map +1 -0
  253. package/dist/ssr/charts/core/svg-histogram.js +73 -0
  254. package/dist/ssr/charts/core/svg-histogram.js.map +1 -0
  255. package/dist/ssr/charts/core/svg-renderers.js +10 -1876
  256. package/dist/ssr/charts/core/svg-renderers.js.map +1 -1
  257. package/dist/ssr/charts/core/svg-scatter.js +114 -0
  258. package/dist/ssr/charts/core/svg-scatter.js.map +1 -0
  259. package/dist/ssr/charts/core/treemap.js +138 -0
  260. package/dist/ssr/charts/core/treemap.js.map +1 -0
  261. package/dist/ssr/charts/description.js.map +1 -1
  262. package/dist/ssr/charts.js +2 -1
  263. package/dist/ssr/charts.js.map +1 -1
  264. package/dist/ssr/content/ChartExplorer.js +16 -4
  265. package/dist/ssr/content/ChartExplorer.js.map +1 -1
  266. package/dist/ssr/content/ChartRoot.js +43 -17
  267. package/dist/ssr/content/ChartRoot.js.map +1 -1
  268. package/dist/ssr/content/ChartSnapshotView.js +7 -2
  269. package/dist/ssr/content/ChartSnapshotView.js.map +1 -1
  270. package/dist/ssr/content/DataTable.js +12 -16
  271. package/dist/ssr/content/DataTable.js.map +1 -1
  272. package/dist/ssr/content/Lightbox.js +32 -3
  273. package/dist/ssr/content/Lightbox.js.map +1 -1
  274. package/dist/ssr/content/ThumbnailStrip.js +103 -0
  275. package/dist/ssr/content/ThumbnailStrip.js.map +1 -0
  276. package/dist/ssr/content/chart-bar.js +139 -191
  277. package/dist/ssr/content/chart-bar.js.map +1 -1
  278. package/dist/ssr/content/chart-calendar.js +30 -14
  279. package/dist/ssr/content/chart-calendar.js.map +1 -1
  280. package/dist/ssr/content/chart-inspection-core.js +41 -14
  281. package/dist/ssr/content/chart-inspection-core.js.map +1 -1
  282. package/dist/ssr/content/chart-message-catalog.js +26 -0
  283. package/dist/ssr/content/chart-message-catalog.js.map +1 -1
  284. package/dist/ssr/content/chart-sankey.js +13 -0
  285. package/dist/ssr/content/chart-sankey.js.map +1 -0
  286. package/dist/ssr/content/chart-svg.js +1 -1
  287. package/dist/ssr/content/chart-svg.js.map +1 -1
  288. package/dist/ssr/content/chart-time-axis.js +10 -108
  289. package/dist/ssr/content/chart-time-axis.js.map +1 -1
  290. package/dist/ssr/content/chart-time-calendar.js +108 -0
  291. package/dist/ssr/content/chart-time-calendar.js.map +1 -0
  292. package/dist/ssr/content/index.js +1 -0
  293. package/dist/ssr/content/index.js.map +1 -1
  294. package/dist/ssr/content/thumbnail-strip-messages.js +24 -0
  295. package/dist/ssr/content/thumbnail-strip-messages.js.map +1 -0
  296. package/dist/ssr/inputs/ChoiceInputs.js +55 -40
  297. package/dist/ssr/inputs/ChoiceInputs.js.map +1 -1
  298. package/dist/ssr/inputs/DatePicker.js +30 -21
  299. package/dist/ssr/inputs/DatePicker.js.map +1 -1
  300. package/dist/ssr/inputs/NumberInput.js +33 -7
  301. package/dist/ssr/inputs/NumberInput.js.map +1 -1
  302. package/dist/ssr/inputs/Select.js +38 -7
  303. package/dist/ssr/inputs/Select.js.map +1 -1
  304. package/dist/ssr/inputs/Switch.js +79 -18
  305. package/dist/ssr/inputs/Switch.js.map +1 -1
  306. package/dist/ssr/inputs/TextInput.js +31 -7
  307. package/dist/ssr/inputs/TextInput.js.map +1 -1
  308. package/dist/ssr/inputs/field-contract.js.map +1 -1
  309. package/dist/ssr/inputs/field-suggestion-slot.js +21 -0
  310. package/dist/ssr/inputs/field-suggestion-slot.js.map +1 -0
  311. package/dist/ssr/inputs/field-suggestion-types.js +2 -0
  312. package/dist/ssr/inputs/field-suggestion-types.js.map +1 -0
  313. package/dist/ssr/inputs/field-suggestion.js +402 -0
  314. package/dist/ssr/inputs/field-suggestion.js.map +1 -0
  315. package/dist/ssr/inputs/index.js +2 -0
  316. package/dist/ssr/inputs/index.js.map +1 -1
  317. package/dist/ssr/inputs/markdown/MarkdownSelectionToolbar.js +293 -0
  318. package/dist/ssr/inputs/markdown/MarkdownSelectionToolbar.js.map +1 -0
  319. package/dist/ssr/inputs/suggestion-messages.js +160 -0
  320. package/dist/ssr/inputs/suggestion-messages.js.map +1 -0
  321. package/dist/ssr/internal/field.js +36 -24
  322. package/dist/ssr/internal/field.js.map +1 -1
  323. package/dist/ssr/layout/AppOverview.js +3 -3
  324. package/dist/ssr/layout/AppOverview.js.map +1 -1
  325. package/dist/ssr/layout/AppWorkspace.js +5 -1
  326. package/dist/ssr/layout/AppWorkspace.js.map +1 -1
  327. package/dist/ssr/layout/DetailPanel.js +24 -220
  328. package/dist/ssr/layout/DetailPanel.js.map +1 -1
  329. package/dist/ssr/layout/DetailSections.js +8 -7
  330. package/dist/ssr/layout/DetailSections.js.map +1 -1
  331. package/dist/ssr/layout/Discussion.js +56 -76
  332. package/dist/ssr/layout/Discussion.js.map +1 -1
  333. package/dist/ssr/layout/PanelDialog.js +40 -26
  334. package/dist/ssr/layout/PanelDialog.js.map +1 -1
  335. package/dist/ssr/layout/detail-panel-messages.js +1 -1
  336. package/dist/ssr/layout/detail-panel-messages.js.map +1 -1
  337. package/dist/ssr/layout/index.js.map +1 -1
  338. package/dist/ssr/surfaces/Field.js +58 -0
  339. package/dist/ssr/surfaces/Field.js.map +1 -0
  340. package/dist/ssr/surfaces/LinkCard.js +38 -5
  341. package/dist/ssr/surfaces/LinkCard.js.map +1 -1
  342. package/dist/ssr/surfaces/NoticeRow.js +39 -0
  343. package/dist/ssr/surfaces/NoticeRow.js.map +1 -0
  344. package/dist/ssr/surfaces/Section.js +295 -0
  345. package/dist/ssr/surfaces/Section.js.map +1 -0
  346. package/dist/ssr/surfaces/StatCell.js +29 -18
  347. package/dist/ssr/surfaces/StatCell.js.map +1 -1
  348. package/dist/ssr/surfaces/index.js +3 -0
  349. package/dist/ssr/surfaces/index.js.map +1 -1
  350. package/dist/ssr/surfaces/section-messages.js +25 -0
  351. package/dist/ssr/surfaces/section-messages.js.map +1 -0
  352. package/dist/ssr/surfaces/stat-cell-messages.js +4 -2
  353. package/dist/ssr/surfaces/stat-cell-messages.js.map +1 -1
  354. package/dist/ssr/widgets/DashboardFrame.js +6 -11
  355. package/dist/ssr/widgets/DashboardFrame.js.map +1 -1
  356. package/dist/styles.css +1 -1
  357. package/dist/tabler.css +2 -1
  358. package/dist/types/actions/SplitButton.d.ts +5 -1
  359. package/dist/types/actions/Toolbar.d.ts +20 -1
  360. package/dist/types/actions/index.d.ts +2 -2
  361. package/dist/types/charts/core/bar-base-render.d.ts +7 -0
  362. package/dist/types/charts/core/bar-common.d.ts +13 -0
  363. package/dist/types/charts/core/bar-labels.d.ts +2 -0
  364. package/dist/types/charts/core/bar-render.d.ts +7 -0
  365. package/dist/types/charts/core/bar-series.d.ts +7 -0
  366. package/dist/types/charts/core/bubble.d.ts +66 -0
  367. package/dist/types/charts/core/calendar.d.ts +9 -0
  368. package/dist/types/charts/core/default-styles.d.ts +1 -0
  369. package/dist/types/charts/core/dot-options.d.ts +27 -0
  370. package/dist/types/charts/core/dots.d.ts +7 -0
  371. package/dist/types/charts/core/funnel-layout.d.ts +43 -0
  372. package/dist/types/charts/core/funnel.d.ts +13 -0
  373. package/dist/types/charts/core/index.d.ts +19 -2
  374. package/dist/types/charts/core/line-base.d.ts +3 -0
  375. package/dist/types/charts/core/line-details.d.ts +30 -0
  376. package/dist/types/charts/core/line-options.d.ts +25 -0
  377. package/dist/types/charts/core/line-paths.d.ts +16 -0
  378. package/dist/types/charts/core/line.d.ts +2 -0
  379. package/dist/types/charts/core/palette.d.ts +5 -0
  380. package/dist/types/charts/core/pareto.d.ts +42 -0
  381. package/dist/types/charts/core/radar.d.ts +47 -0
  382. package/dist/types/charts/core/registry.d.ts +13 -1
  383. package/dist/types/charts/core/render-size.d.ts +1 -1
  384. package/dist/types/charts/core/render.d.ts +4 -1
  385. package/dist/types/charts/core/sankey-size.d.ts +38 -0
  386. package/dist/types/charts/core/sankey.d.ts +106 -0
  387. package/dist/types/charts/core/snapshot.d.ts +2 -0
  388. package/dist/types/charts/core/svg-barGauge.d.ts +3 -0
  389. package/dist/types/charts/core/svg-boxplot.d.ts +18 -0
  390. package/dist/types/charts/core/svg-common.d.ts +619 -0
  391. package/dist/types/charts/core/svg-format.d.ts +1 -0
  392. package/dist/types/charts/core/svg-gauge.d.ts +6 -0
  393. package/dist/types/charts/core/svg-heatmap.d.ts +6 -0
  394. package/dist/types/charts/core/svg-histogram.d.ts +16 -0
  395. package/dist/types/charts/core/svg-renderers.d.ts +9 -613
  396. package/dist/types/charts/core/svg-scatter.d.ts +23 -0
  397. package/dist/types/charts/core/treemap.d.ts +45 -0
  398. package/dist/types/charts/description.d.ts +102 -1
  399. package/dist/types/charts.d.ts +2 -1
  400. package/dist/types/content/ChartExplorer.d.ts +2 -0
  401. package/dist/types/content/ChartRoot.d.ts +1 -1
  402. package/dist/types/content/Lightbox.d.ts +2 -0
  403. package/dist/types/content/ThumbnailStrip.d.ts +29 -0
  404. package/dist/types/content/chart-bar.d.ts +62 -18
  405. package/dist/types/content/chart-inspection-core.d.ts +11 -1
  406. package/dist/types/content/chart-inspection.d.ts +1 -0
  407. package/dist/types/content/chart-message-catalog.d.ts +8 -0
  408. package/dist/types/content/chart-sankey.d.ts +3 -0
  409. package/dist/types/content/chart-svg.d.ts +1 -1
  410. package/dist/types/content/chart-time-axis.d.ts +3 -19
  411. package/dist/types/content/chart-time-calendar.d.ts +24 -0
  412. package/dist/types/content/index.d.ts +1 -0
  413. package/dist/types/content/thumbnail-strip-messages.d.ts +10 -0
  414. package/dist/types/inputs/ChoiceInputs.d.ts +2 -0
  415. package/dist/types/inputs/DatePicker.d.ts +4 -2
  416. package/dist/types/inputs/NumberInput.d.ts +2 -2
  417. package/dist/types/inputs/Select.d.ts +2 -2
  418. package/dist/types/inputs/Switch.d.ts +8 -2
  419. package/dist/types/inputs/TextInput.d.ts +4 -2
  420. package/dist/types/inputs/field-contract.d.ts +1 -0
  421. package/dist/types/inputs/field-suggestion-slot.d.ts +3 -0
  422. package/dist/types/inputs/field-suggestion-types.d.ts +103 -0
  423. package/dist/types/inputs/field-suggestion.d.ts +26 -0
  424. package/dist/types/inputs/index.d.ts +5 -1
  425. package/dist/types/inputs/markdown/MarkdownSelectionToolbar.d.ts +19 -0
  426. package/dist/types/inputs/suggestion-messages.d.ts +67 -0
  427. package/dist/types/internal/field.d.ts +2 -0
  428. package/dist/types/layout/AppOverview.d.ts +2 -0
  429. package/dist/types/layout/DetailPanel.d.ts +4 -37
  430. package/dist/types/layout/PanelDialog.d.ts +5 -0
  431. package/dist/types/layout/detail-panel-messages.d.ts +1 -1
  432. package/dist/types/layout/index.d.ts +1 -1
  433. package/dist/types/surfaces/Field.d.ts +20 -0
  434. package/dist/types/surfaces/LinkCard.d.ts +9 -1
  435. package/dist/types/surfaces/NoticeRow.d.ts +23 -0
  436. package/dist/types/surfaces/Section.d.ts +74 -0
  437. package/dist/types/surfaces/index.d.ts +6 -0
  438. package/dist/types/surfaces/section-messages.d.ts +10 -0
  439. package/dist/types/surfaces/stat-cell-messages.d.ts +1 -0
  440. package/dist/types/widgets/DashboardFrame.d.ts +4 -1
  441. package/package.json +3 -3
  442. /package/dist/{tabler-icons-15sezdfp.woff2 → tabler-icons-dafbdda4cb0cdcb2.woff2} +0 -0
@@ -0,0 +1,1003 @@
1
+ import { fmt } from "./svg-format";
2
+ // Ported from @k2b/stdlib 0.30.0 (ISC); retain SVG and numeric algorithms until parity proves changes.
3
+ // ==========================
4
+ // SVG Chart Generation
5
+ // ==========================
6
+ //
7
+ // Pure-native SVG generation for the four basic chart types: scatter, line,
8
+ // bar, and pie/donut. Returns SVG strings — inject directly into the DOM,
9
+ // write to disk, or send over the wire. No peer dependencies.
10
+ //
11
+ // Charts ship with embedded default CSS using semantic class names and CSS
12
+ // custom properties for colors. Consumers override styles via class selectors
13
+ // (their CSS wins on specificity) or CSS variables (`--stdlib-chart-c1` ...
14
+ // `--stdlib-chart-c8`). Axes and labels use `currentColor` so parent `color`
15
+ // drives theming (dark mode "just works").
16
+
17
+ import { DEFAULT_STYLES } from "./default-styles";
18
+
19
+ // ==========================
20
+ // PUBLIC TYPES
21
+ // ==========================
22
+
23
+ /** Marker shapes for `scatter` data points. Auto-cycles per series when
24
+ * `autoVariant` is enabled on the chart. */
25
+
26
+ /** Line dash patterns for `line` series. Auto-cycles per series when
27
+ * `autoVariant` is enabled. */
28
+
29
+ export const itemColorIndex = (item, fallback) => {
30
+ const index = item.colorIndex ?? fallback;
31
+ if (!Number.isInteger(index) || index < 0) throw new RangeError("Chart colorIndex must be a nonnegative integer");
32
+ return index % 8;
33
+ };
34
+ /** One selectable datum in an inspected SVG. Indices refer to the source arrays.
35
+ * `anchor` uses the containing SVG coordinate system, including nested map SVGs.
36
+ * Values are raw data; `formatted` contains the renderer's axis/value formatting.
37
+ */
38
+
39
+ /** Wrap renderer-owned geometry with escaped, inert inspection metadata. */
40
+ export const chartDatumSvg = (svg, datum, inspect, titleText) => {
41
+ if (!inspect || !datum.anchor.every(Number.isFinite)) return svg;
42
+ const title = titleText ?? [datum.label, ...datum.values.map(field => `${field.key}: ${field.formatted ?? field.value}`)].filter(Boolean).join(" · ");
43
+ return `<g data-chart-role="${escapeXml(datum.role)}" data-chart-datum="${escapeXml(JSON.stringify(datum))}"><title>${escapeXml(title)}</title>${svg}</g>`;
44
+ };
45
+ export const inspectionPoint = (datum, inspect) => inspect ? chartDatumSvg(`<circle class="stdlib-chart-inspection-point" cx="${fmt(datum.anchor[0])}" cy="${fmt(datum.anchor[1])}" r="3" fill="transparent" stroke="none"/>`, datum, true) : "";
46
+ export const pointValues = (p, xAxis, yAxis) => [{
47
+ key: "x",
48
+ value: p.x,
49
+ formatted: xAxis?.format?.(p.x)
50
+ }, {
51
+ key: "y",
52
+ value: p.y,
53
+ formatted: yAxis?.format?.(p.y)
54
+ }, ...Object.entries(p).filter(([key, value]) => key !== "x" && key !== "y" && typeof value === "number" && Number.isFinite(value)).map(([key, value]) => ({
55
+ key,
56
+ value
57
+ }))];
58
+
59
+ /**
60
+ * A horizontal or vertical reference line drawn on a cartesian chart, e.g.
61
+ * for thresholds, targets, or averages.
62
+ */
63
+
64
+ /** Internal shared attributes for raw cartesian charts and UI bar layouts. */
65
+ export const referenceLineAttributes = (ref, label = false) => {
66
+ const declarations = [];
67
+ if (!label && ref.style !== undefined) {
68
+ const styles = {
69
+ solid: "none",
70
+ dashed: "4 4",
71
+ dotted: "1 3"
72
+ };
73
+ const dash = styles[ref.style];
74
+ if (typeof dash !== "string") throw new RangeError("Invalid reference line style");
75
+ declarations.push(`stroke-dasharray:${dash}`);
76
+ if (ref.style === "dotted") declarations.push("stroke-linecap:round");
77
+ }
78
+ if (ref.tone !== undefined) {
79
+ const tones = {
80
+ neutral: "currentColor",
81
+ info: "var(--k2b-info-text,#1d4ed8)",
82
+ success: "var(--k2b-success-text,#047857)",
83
+ warning: "var(--k2b-warning-text,#92400e)",
84
+ danger: "var(--k2b-danger-text,#b91c1c)"
85
+ };
86
+ const color = tones[ref.tone];
87
+ if (typeof color !== "string") throw new RangeError("Invalid reference line tone");
88
+ declarations.push(`color:${color}`);
89
+ }
90
+ return declarations.length ? ` style="${declarations.join(";")}"` : "";
91
+ };
92
+
93
+ // ==========================
94
+ // CONSTANTS
95
+ // ==========================
96
+
97
+ export const DEFAULT_WIDTH = 400;
98
+ export const DEFAULT_HEIGHT = 240;
99
+ const DEFAULT_PADDING = {
100
+ top: 16,
101
+ right: 16,
102
+ bottom: 32,
103
+ left: 40
104
+ };
105
+ const DEFAULT_TICKS = 5;
106
+ export const DEFAULT_MARKERS = ["circle", "square", "triangle", "diamond", "plus", "cross"];
107
+ export { DEFAULT_LINE_STYLES, LINE_DASH_PATTERNS } from "./line-paths";
108
+
109
+ // ==========================
110
+ // HELPERS (pure)
111
+ // ==========================
112
+
113
+ /** XML-escape a string for safe inclusion in attribute values or text content. */
114
+ export const escapeXml = s => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
115
+
116
+ /** Normalize a `Padding` input (number or partial object) to a full `Padding`. */
117
+ export const normalizePadding = p => {
118
+ if (p === undefined) return {
119
+ ...DEFAULT_PADDING
120
+ };
121
+ if (typeof p === "number") return {
122
+ top: p,
123
+ right: p,
124
+ bottom: p,
125
+ left: p
126
+ };
127
+ return {
128
+ top: p.top ?? DEFAULT_PADDING.top,
129
+ right: p.right ?? DEFAULT_PADDING.right,
130
+ bottom: p.bottom ?? DEFAULT_PADDING.bottom,
131
+ left: p.left ?? DEFAULT_PADDING.left
132
+ };
133
+ };
134
+
135
+ /**
136
+ * Compute `[min, max]` from a list of numeric values, ignoring non-finite
137
+ * entries. Returns `[0, 1]` for an empty/all-non-finite list and pads ±1
138
+ * around a single finite value.
139
+ */
140
+ export const computeDomain = values => {
141
+ let min = Number.POSITIVE_INFINITY;
142
+ let max = Number.NEGATIVE_INFINITY;
143
+ for (const v of values) {
144
+ if (!Number.isFinite(v)) continue;
145
+ if (v < min) min = v;
146
+ if (v > max) max = v;
147
+ }
148
+ if (!Number.isFinite(min) || !Number.isFinite(max)) return [0, 1];
149
+ if (min === max) return [min - 1, max + 1];
150
+ return [min, max];
151
+ };
152
+
153
+ /**
154
+ * Pick a "nice" axis step (1, 2, 5, 10, 20, 50, ...) that splits `range`
155
+ * into roughly `target` intervals. Avoids ugly tick labels like 0.473.
156
+ */
157
+ export const niceStep = (range, target) => {
158
+ if (range <= 0 || target <= 0) return 1;
159
+ const rough = range / target;
160
+ const mag = Math.pow(10, Math.floor(Math.log10(rough)));
161
+ const norm = rough / mag;
162
+ const nice = norm < 1.5 ? 1 : norm < 3 ? 2 : norm < 7 ? 5 : 10;
163
+ return nice * mag;
164
+ };
165
+
166
+ /** The most ticks one linear axis counts, the same budget as a time axis; more never fit a readable axis. */
167
+ export const MAX_AXIS_TICKS = 1_000;
168
+
169
+ /**
170
+ * Round `min` down and `max` up to the nearest multiples of `step`, so the
171
+ * domain edges fall on tick boundaries. Returns the extended domain plus the
172
+ * tick values within it (inclusive of both ends).
173
+ */
174
+ export const extendDomainToNice = (min, max, step) => {
175
+ const lo = Math.floor(min / step) * step;
176
+ const hi = Math.ceil(max / step) * step;
177
+ const ticks = [];
178
+ // Use rounding to avoid floating-point drift at tick positions.
179
+ const decimals = Math.max(0, -Math.floor(Math.log10(step)));
180
+ const round = v => Number(v.toFixed(Math.min(decimals + 2, 12)));
181
+ // A step below the float spacing of large values never advances, and a tiny step counts without end: keep the ends.
182
+ const ends = {
183
+ domain: [lo, hi],
184
+ ticks: [...new Set([round(lo), round(hi)])]
185
+ };
186
+ if ((hi - lo) / step > MAX_AXIS_TICKS) return ends;
187
+ for (let v = lo; v <= hi + step / 2;) {
188
+ ticks.push(round(v));
189
+ const next = v + step;
190
+ if (next <= v) return ends;
191
+ v = next;
192
+ }
193
+ return {
194
+ domain: [lo, hi],
195
+ ticks
196
+ };
197
+ };
198
+
199
+ /** Linear map of `value` from input domain `[d0, d1]` to output range `[r0, r1]`. */
200
+ export const mapRange = (value, [d0, d1], [r0, r1]) => {
201
+ if (d1 === d0) return (r0 + r1) / 2;
202
+ return r0 + (value - d0) / (d1 - d0) * (r1 - r0);
203
+ };
204
+
205
+ /**
206
+ * Logarithmic (base-10) map of `value` from input domain `[d0, d1]` to
207
+ * output range `[r0, r1]`. Both domain endpoints must be strictly positive.
208
+ * Non-positive values are clamped to a small epsilon to avoid `-Infinity`.
209
+ */
210
+ export const mapLog = (value, [d0, d1], [r0, r1]) => {
211
+ if (d0 <= 0 || d1 <= 0) return (r0 + r1) / 2;
212
+ const v = Math.max(value, 1e-300);
213
+ const logD0 = Math.log10(d0);
214
+ const logD1 = Math.log10(d1);
215
+ if (logD0 === logD1) return (r0 + r1) / 2;
216
+ return r0 + (Math.log10(v) - logD0) / (logD1 - logD0) * (r1 - r0);
217
+ };
218
+
219
+ /**
220
+ * Compute logarithmic ticks (powers of 10) within `[min, max]`. The
221
+ * returned array always includes both decade boundaries enclosing the
222
+ * domain so the axis line spans the data.
223
+ */
224
+ export const niceLogTicks = (min, max) => {
225
+ const safeMin = Math.max(min, 1e-300);
226
+ const safeMax = Math.max(max, safeMin);
227
+ // Clamp the log-tick range to a finite, SVG-safe span so callers passing
228
+ // Number.MAX_VALUE (or non-finite extremes) don't trigger an infinite loop.
229
+ // 1e-30 .. 1e30 covers every real-world scientific magnitude.
230
+ const MIN_EXP = -30;
231
+ const MAX_EXP = 30;
232
+ const loExp = Math.max(MIN_EXP, Math.floor(Math.log10(safeMin)));
233
+ const hiExp = Math.min(MAX_EXP, Math.ceil(Math.log10(safeMax)));
234
+ const lo = Math.pow(10, loExp);
235
+ const hi = Math.pow(10, Math.max(loExp, hiExp));
236
+ const ticks = [];
237
+ // Iterate by exponent to avoid floating-point drift at extreme ranges.
238
+ for (let e = loExp; e <= Math.max(loExp, hiExp); e++) {
239
+ ticks.push(Math.pow(10, e));
240
+ }
241
+ return {
242
+ domain: [lo, hi],
243
+ ticks
244
+ };
245
+ };
246
+
247
+ /**
248
+ * Least-squares linear regression. Returns slope, intercept, and r² for the
249
+ * regression line `y = slope * x + intercept`. Returns null for fewer than
250
+ * two finite points or all-x-equal input.
251
+ */
252
+ export const linearRegression = points => {
253
+ const finite = points.filter(p => Number.isFinite(p.x) && Number.isFinite(p.y));
254
+ const n = finite.length;
255
+ if (n < 2) return null;
256
+ let sumX = 0;
257
+ let sumY = 0;
258
+ for (const p of finite) {
259
+ sumX += p.x;
260
+ sumY += p.y;
261
+ }
262
+ const meanX = sumX / n;
263
+ const meanY = sumY / n;
264
+ let num = 0;
265
+ let denom = 0;
266
+ let totalSS = 0;
267
+ for (const p of finite) {
268
+ const dx = p.x - meanX;
269
+ const dy = p.y - meanY;
270
+ num += dx * dy;
271
+ denom += dx * dx;
272
+ totalSS += dy * dy;
273
+ }
274
+ if (denom === 0) return null;
275
+ const slope = num / denom;
276
+ const intercept = meanY - slope * meanX;
277
+ // r² via 1 - SSres / SStot
278
+ let resSS = 0;
279
+ for (const p of finite) {
280
+ const predicted = slope * p.x + intercept;
281
+ const resid = p.y - predicted;
282
+ resSS += resid * resid;
283
+ }
284
+ const r2 = totalSS === 0 ? 1 : 1 - resSS / totalSS;
285
+ return {
286
+ slope,
287
+ intercept,
288
+ r2
289
+ };
290
+ };
291
+
292
+ /**
293
+ * Compute box-plot statistics for a set of observations:
294
+ * min/max, quartiles (q1/q2/q3 via R-7 linear interpolation), Tukey whiskers
295
+ * (1.5×IQR rule clamped to data extents), and outliers beyond the whiskers.
296
+ *
297
+ * Returns null for an empty/all-non-finite input.
298
+ */
299
+ export const computeBoxStats = values => {
300
+ const finite = values.filter(v => Number.isFinite(v));
301
+ if (finite.length === 0) return null;
302
+ const sorted = [...finite].sort((a, b) => a - b);
303
+ const quantile = q => {
304
+ // R-7 (linear interpolation between consecutive order statistics).
305
+ const pos = q * (sorted.length - 1);
306
+ const lo = Math.floor(pos);
307
+ const hi = Math.ceil(pos);
308
+ if (lo === hi) return sorted[lo];
309
+ return sorted[lo] + (pos - lo) * (sorted[hi] - sorted[lo]);
310
+ };
311
+ const q1 = quantile(0.25);
312
+ const q2 = quantile(0.5);
313
+ const q3 = quantile(0.75);
314
+ const iqr = q3 - q1;
315
+ const fenceLow = q1 - 1.5 * iqr;
316
+ const fenceHigh = q3 + 1.5 * iqr;
317
+ // Whiskers extend to the most-extreme data point still inside the fences.
318
+ let whiskerLow = q1;
319
+ let whiskerHigh = q3;
320
+ for (const v of sorted) {
321
+ if (v >= fenceLow && v < whiskerLow) whiskerLow = v;
322
+ if (v <= fenceHigh && v > whiskerHigh) whiskerHigh = v;
323
+ }
324
+ const outliers = sorted.filter(v => v < fenceLow || v > fenceHigh);
325
+ return {
326
+ min: sorted[0],
327
+ max: sorted[sorted.length - 1],
328
+ q1,
329
+ q2,
330
+ q3,
331
+ whiskerLow,
332
+ whiskerHigh,
333
+ outliers
334
+ };
335
+ };
336
+
337
+ /**
338
+ * Bin a numeric dataset into a histogram. `bins` may be:
339
+ * - undefined → Sturges' formula `ceil(log2(n)) + 1`
340
+ * - a number → that many equal-width bins
341
+ * - an array of edges (length k+1 → k bins)
342
+ *
343
+ * Non-finite input values are filtered. Returns bin edges and per-bin counts.
344
+ */
345
+ export const autoBin = (values, bins) => {
346
+ const finite = values.filter(v => Number.isFinite(v));
347
+ if (finite.length === 0) return {
348
+ edges: [0, 1],
349
+ counts: [0]
350
+ };
351
+
352
+ // Cap bin count so a malicious / mistyped `bins: 1e9` doesn't allocate
353
+ // gigabytes. 1024 is generous: 30 is Sturges' for 1e9 samples.
354
+ const MAX_BINS = 1024;
355
+ let edges;
356
+ if (Array.isArray(bins)) {
357
+ const sorted = [...bins].filter(e => Number.isFinite(e)).sort((a, b) => a - b);
358
+ if (sorted.length >= 2) {
359
+ edges = sorted;
360
+ } else {
361
+ // Empty or single-edge input → fall back to a single auto-bin span over
362
+ // the data so we never emit `[undefined, NaN]` edges.
363
+ const dmin = Math.min(...finite);
364
+ const dmax = Math.max(...finite);
365
+ edges = dmin === dmax ? [dmin - 0.5, dmin + 0.5] : [dmin, dmax];
366
+ }
367
+ } else {
368
+ // Single-loop min/max — `Math.min(...arr)` fails with RangeError on huge
369
+ // arrays (call-stack overflow) and is also O(n) anyway.
370
+ let min = Infinity;
371
+ let max = -Infinity;
372
+ for (const v of finite) {
373
+ if (v < min) min = v;
374
+ if (v > max) max = v;
375
+ }
376
+ const range = max - min;
377
+ let k;
378
+ if (typeof bins === "number" && bins > 0) {
379
+ k = Math.min(MAX_BINS, Math.floor(bins));
380
+ } else {
381
+ k = Math.max(1, Math.min(MAX_BINS, Math.ceil(Math.log2(finite.length)) + 1));
382
+ }
383
+ if (range === 0) {
384
+ edges = [min - 0.5, min + 0.5];
385
+ } else {
386
+ const step = range / k;
387
+ edges = Array.from({
388
+ length: k + 1
389
+ }, (_, i) => min + i * step);
390
+ }
391
+ }
392
+ const counts = new Array(edges.length - 1).fill(0);
393
+ for (const v of finite) {
394
+ // Right-open intervals [e_i, e_{i+1}); last bin closed-closed.
395
+ let bin = -1;
396
+ for (let i = 0; i < counts.length; i++) {
397
+ const isLast = i === counts.length - 1;
398
+ if (v >= edges[i] && (isLast ? v <= edges[i + 1] : v < edges[i + 1])) {
399
+ bin = i;
400
+ break;
401
+ }
402
+ }
403
+ if (bin >= 0) counts[bin] += 1;
404
+ }
405
+ return {
406
+ edges,
407
+ counts
408
+ };
409
+ };
410
+
411
+ // ==========================
412
+ // SVG SKELETON
413
+ // ==========================
414
+
415
+ export const computePlotArea = (width, height, padding, hasXAxisLabel, hasYAxisLabel, headerHeight = 0, legendHeight = 0) => {
416
+ // Reserve extra space when axis labels are present.
417
+ const extraBottom = hasXAxisLabel ? 14 : 0;
418
+ const extraLeft = hasYAxisLabel ? 14 : 0;
419
+ return {
420
+ x0: padding.left + extraLeft,
421
+ y0: padding.top + headerHeight,
422
+ x1: width - padding.right,
423
+ y1: height - padding.bottom - extraBottom - legendHeight
424
+ };
425
+ };
426
+
427
+ /**
428
+ * Render an optional centered header (title + subtitle) at the top of an
429
+ * SVG. Returns the SVG fragment plus the pixel height it consumed so the
430
+ * caller can shift the plot area down accordingly.
431
+ */
432
+ export const renderHeader = (width, title, subtitle) => {
433
+ if (!title && !subtitle) return {
434
+ svg: "",
435
+ height: 0
436
+ };
437
+ const cx = width / 2;
438
+ const parts = [];
439
+ let y = 16;
440
+ if (title) {
441
+ parts.push(`<text class="stdlib-chart-title" x="${fmt(cx)}" y="${fmt(y)}" text-anchor="middle">${escapeXml(title)}</text>`);
442
+ y += 14;
443
+ }
444
+ if (subtitle) {
445
+ parts.push(`<text class="stdlib-chart-subtitle" x="${fmt(cx)}" y="${fmt(y)}" text-anchor="middle">${escapeXml(subtitle)}</text>`);
446
+ y += 6;
447
+ }
448
+ return {
449
+ svg: parts.join(""),
450
+ height: y
451
+ };
452
+ };
453
+
454
+ /**
455
+ * Render reference lines (horizontal or vertical thresholds) within the plot
456
+ * area. Out-of-domain values are silently skipped. Honors per-axis scale
457
+ * (linear or log).
458
+ */
459
+ export const renderReferenceLines = (refs, xAxis, yAxis, area) => {
460
+ const xMap = pickMapper(xAxis.scale);
461
+ const yMap = pickMapper(yAxis.scale);
462
+ const parts = [];
463
+ for (const ref of refs) {
464
+ if (!Number.isFinite(ref.value)) continue;
465
+ const axis = ref.axis ?? "y";
466
+ if (axis === "y") {
467
+ if (ref.value < yAxis.domain[0] || ref.value > yAxis.domain[1]) continue;
468
+ const y = yMap(ref.value, yAxis.domain, [area.y1, area.y0]);
469
+ parts.push(`<line class="stdlib-chart-reference"${referenceLineAttributes(ref)} x1="${fmt(area.x0)}" y1="${fmt(y)}" x2="${fmt(area.x1)}" y2="${fmt(y)}"/>`);
470
+ if (ref.label) {
471
+ parts.push(`<text class="stdlib-chart-reference-label"${referenceLineAttributes(ref, true)} x="${fmt(area.x1 - 4)}" y="${fmt(y - 4)}" text-anchor="end">${escapeXml(ref.label)}</text>`);
472
+ }
473
+ } else {
474
+ if (ref.value < xAxis.domain[0] || ref.value > xAxis.domain[1]) continue;
475
+ const x = xMap(ref.value, xAxis.domain, [area.x0, area.x1]);
476
+ parts.push(`<line class="stdlib-chart-reference"${referenceLineAttributes(ref)} x1="${fmt(x)}" y1="${fmt(area.y0)}" x2="${fmt(x)}" y2="${fmt(area.y1)}"/>`);
477
+ if (ref.label) {
478
+ parts.push(`<text class="stdlib-chart-reference-label"${referenceLineAttributes(ref, true)} x="${fmt(x + 4)}" y="${fmt(area.y0 + 12)}">${escapeXml(ref.label)}</text>`);
479
+ }
480
+ }
481
+ }
482
+ return parts.join("");
483
+ };
484
+
485
+ /**
486
+ * Resolve a point's effective error extents into `[low, high]` magnitudes
487
+ * (relative deltas, both ≥ 0). Asymmetric `errYHigh`/`errYLow` take precedence
488
+ * over symmetric `errY`. Returns null when no error info is set.
489
+ */
490
+ export const resolveErrorY = p => {
491
+ const high = p.errYHigh ?? p.errY;
492
+ const low = p.errYLow ?? p.errY;
493
+ if (high === undefined && low === undefined) return null;
494
+ return [Number.isFinite(low) ? Math.abs(low) : 0, Number.isFinite(high) ? Math.abs(high) : 0];
495
+ };
496
+ const resolveErrorX = p => {
497
+ const high = p.errXHigh ?? p.errX;
498
+ const low = p.errXLow ?? p.errX;
499
+ if (high === undefined && low === undefined) return null;
500
+ return [Number.isFinite(low) ? Math.abs(low) : 0, Number.isFinite(high) ? Math.abs(high) : 0];
501
+ };
502
+
503
+ /** Build the SVG fragment for the per-point error bars across all series. */
504
+ export const renderErrorBars = (series, xAxis, yAxis, area) => {
505
+ const xMap = pickMapper(xAxis.scale);
506
+ const yMap = pickMapper(yAxis.scale);
507
+ const CAP = 4; // half-width of error bar caps in pixels
508
+ const parts = [];
509
+ for (const s of series) {
510
+ for (const p of s.data) {
511
+ if (!Number.isFinite(p.x) || !Number.isFinite(p.y)) continue;
512
+ const cx = xMap(p.x, xAxis.domain, [area.x0, area.x1]);
513
+ const cy = yMap(p.y, yAxis.domain, [area.y1, area.y0]);
514
+ const yErr = resolveErrorY(p);
515
+ if (yErr) {
516
+ const [low, high] = yErr;
517
+ const yHi = yMap(p.y + high, yAxis.domain, [area.y1, area.y0]);
518
+ const yLo = yMap(p.y - low, yAxis.domain, [area.y1, area.y0]);
519
+ parts.push(`<line class="stdlib-chart-errorbar" x1="${fmt(cx)}" y1="${fmt(yHi)}" x2="${fmt(cx)}" y2="${fmt(yLo)}"/>`);
520
+ parts.push(`<line class="stdlib-chart-errorbar" x1="${fmt(cx - CAP)}" y1="${fmt(yHi)}" x2="${fmt(cx + CAP)}" y2="${fmt(yHi)}"/>`);
521
+ parts.push(`<line class="stdlib-chart-errorbar" x1="${fmt(cx - CAP)}" y1="${fmt(yLo)}" x2="${fmt(cx + CAP)}" y2="${fmt(yLo)}"/>`);
522
+ // Mark we need cy to match data point — ensure we use it (silences unused warnings if any).
523
+ void cy;
524
+ }
525
+ const xErr = resolveErrorX(p);
526
+ if (xErr) {
527
+ const [low, high] = xErr;
528
+ const xHi = xMap(p.x + high, xAxis.domain, [area.x0, area.x1]);
529
+ const xLo = xMap(p.x - low, xAxis.domain, [area.x0, area.x1]);
530
+ parts.push(`<line class="stdlib-chart-errorbar" x1="${fmt(xLo)}" y1="${fmt(cy)}" x2="${fmt(xHi)}" y2="${fmt(cy)}"/>`);
531
+ parts.push(`<line class="stdlib-chart-errorbar" x1="${fmt(xLo)}" y1="${fmt(cy - CAP)}" x2="${fmt(xLo)}" y2="${fmt(cy + CAP)}"/>`);
532
+ parts.push(`<line class="stdlib-chart-errorbar" x1="${fmt(xHi)}" y1="${fmt(cy - CAP)}" x2="${fmt(xHi)}" y2="${fmt(cy + CAP)}"/>`);
533
+ }
534
+ }
535
+ }
536
+ return parts.join("");
537
+ };
538
+
539
+ /** Collect all values relevant for axis-domain computation, including error
540
+ * extents so error bars don't get clipped. */
541
+ export const collectAxisValues = (series, axis) => {
542
+ const out = [];
543
+ for (const s of series) {
544
+ for (const p of s.data) {
545
+ const v = axis === "x" ? p.x : p.y;
546
+ if (!Number.isFinite(v)) continue;
547
+ out.push(v);
548
+ const err = axis === "x" ? resolveErrorX(p) : resolveErrorY(p);
549
+ if (err) {
550
+ out.push(v - err[0]);
551
+ out.push(v + err[1]);
552
+ }
553
+ }
554
+ }
555
+ return out;
556
+ };
557
+
558
+ /**
559
+ * Render a single-row centered legend at the bottom of the SVG. Returns the
560
+ * SVG fragment plus the height it consumed so callers can shift the plot
561
+ * area up accordingly. Empty input yields height 0.
562
+ */
563
+ export const renderLegend = (items, width, yTop) => {
564
+ if (items.length === 0) return {
565
+ svg: "",
566
+ height: 0
567
+ };
568
+ const ROW_HEIGHT = 20;
569
+ const ITEM_GAP = 16;
570
+ const SWATCH = 8;
571
+ const SWATCH_GAP = 4;
572
+ const SIDE_PADDING = 4;
573
+ // Approximate text width per character at 11px — good enough for centering.
574
+ const charWidth = 6.5;
575
+ const itemWidths = items.map(it => SWATCH + SWATCH_GAP + Math.max(it.label.length, 1) * charWidth);
576
+
577
+ // Greedy line-break: pack items into rows so each row fits inside the
578
+ // available width. Single-row legends (≤ a few short labels) still render
579
+ // on one line — no visual change for the line/scatter/bar callers that
580
+ // typically have only 2-4 series. Pie/donut with long "Label (XX%)" entries
581
+ // and 5+ slices wrap to multiple rows instead of overflowing the viewBox.
582
+ const availableWidth = Math.max(40, width - 2 * SIDE_PADDING);
583
+ const rows = [];
584
+ let cur = [];
585
+ let curW = 0;
586
+ items.forEach((item, i) => {
587
+ const w = itemWidths[i];
588
+ const projected = cur.length === 0 ? w : curW + ITEM_GAP + w;
589
+ if (cur.length > 0 && projected > availableWidth) {
590
+ rows.push({
591
+ items: cur,
592
+ widths: cur.map((_, j) => itemWidths[i - cur.length + j]),
593
+ totalWidth: curW
594
+ });
595
+ cur = [item];
596
+ curW = w;
597
+ } else {
598
+ cur = [...cur, item];
599
+ curW = projected;
600
+ }
601
+ });
602
+ if (cur.length > 0) {
603
+ rows.push({
604
+ items: cur,
605
+ widths: cur.map((_, j) => itemWidths[items.length - cur.length + j]),
606
+ totalWidth: curW
607
+ });
608
+ }
609
+ const parts = [`<g class="stdlib-chart-legend">`];
610
+ rows.forEach((row, rowIdx) => {
611
+ let cursor = Math.max(SIDE_PADDING, (width - row.totalWidth) / 2);
612
+ const baseY = yTop + ROW_HEIGHT / 2 + rowIdx * ROW_HEIGHT;
613
+ row.items.forEach((item, i) => {
614
+ parts.push(`<g class="stdlib-chart-legend-item stdlib-chart-series-${item.seriesIndex % 8}">`);
615
+ parts.push(`<rect class="stdlib-chart-legend-swatch" x="${fmt(cursor)}" y="${fmt(baseY - SWATCH / 2)}" width="${SWATCH}" height="${SWATCH}" rx="1"/>`);
616
+ parts.push(`<text class="stdlib-chart-legend-label" x="${fmt(cursor + SWATCH + SWATCH_GAP)}" y="${fmt(baseY)}" dominant-baseline="middle">${escapeXml(item.label)}</text>`);
617
+ parts.push(`</g>`);
618
+ cursor += row.widths[i] + ITEM_GAP;
619
+ });
620
+ });
621
+ parts.push(`</g>`);
622
+ return {
623
+ svg: parts.join(""),
624
+ height: rows.length * ROW_HEIGHT
625
+ };
626
+ };
627
+
628
+ /** Measure the total height a legend with `items` will consume in `width`,
629
+ * without actually rendering. Used by chart functions to reserve vertical
630
+ * space before computing the plot area. */
631
+ export const measureLegendHeight = (items, width) => {
632
+ if (items.length === 0) return 0;
633
+ const ROW_HEIGHT = 20;
634
+ const ITEM_GAP = 16;
635
+ const SWATCH = 8;
636
+ const SWATCH_GAP = 4;
637
+ const charWidth = 6.5;
638
+ const availableWidth = Math.max(40, width - 8);
639
+ let curW = 0;
640
+ let rows = 1;
641
+ items.forEach((it, i) => {
642
+ const w = SWATCH + SWATCH_GAP + Math.max(it.label.length, 1) * charWidth;
643
+ const projected = i === 0 ? w : curW + ITEM_GAP + w;
644
+ if (i > 0 && projected > availableWidth) {
645
+ rows++;
646
+ curW = w;
647
+ } else {
648
+ curW = projected;
649
+ }
650
+ });
651
+ return rows * ROW_HEIGHT;
652
+ };
653
+
654
+ /** Wrap chart body in a root `<svg>` with embedded default styles. */
655
+ export const svgRoot = (opts, body) => {
656
+ const cls = opts.className ? `stdlib-chart ${escapeXml(opts.className)}` : "stdlib-chart";
657
+ return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${opts.width} ${opts.height}" class="${cls}"><style>${DEFAULT_STYLES}</style>${body}</svg>`;
658
+ };
659
+
660
+ // ==========================
661
+ // GEOMETRY HELPERS
662
+ // ==========================
663
+
664
+ /** Format an SVG path `d` attribute for a polyline through `points`. */
665
+ /**
666
+ * Format an SVG path `d` for a smooth curve through `points` using cubic
667
+ * Bezier segments with Catmull-Rom-derived vertical control points.
668
+ *
669
+ * Vertical control points use neighboring `points[i-1]` and `points[i+2]`
670
+ * (reflecting the end points at boundaries) with the standard Catmull-Rom
671
+ * tension factor of 1/6. Horizontal control points stay at the segment's
672
+ * thirds, so x progresses linearly and never doubles back when point spacing
673
+ * is uneven.
674
+ */
675
+ export { linePathD, smoothPathD } from "./line-paths";
676
+ /**
677
+ * Build an SVG path `d` attribute for a pie slice (or donut sector).
678
+ *
679
+ * Angles are in radians, measured from the +X axis. Slices grow clockwise,
680
+ * which in SVG's y-down coordinate space means `a1 > a0` produces a clockwise
681
+ * arc when drawn with the large-arc and sweep flags set appropriately.
682
+ *
683
+ * Full-circle (a1 - a0 ≈ 2π) is split into two 180° arcs because a single
684
+ * `A` command can't draw a complete circle unambiguously.
685
+ */
686
+ export const arcPathD = (cx, cy, r, a0, a1, innerR = 0) => {
687
+ const sweep = a1 - a0;
688
+ // Full circle: split into two halves to avoid degenerate `A` command.
689
+ if (sweep >= Math.PI * 2 - 1e-9) {
690
+ const aMid = a0 + Math.PI;
691
+ if (innerR <= 0) {
692
+ const ox0 = cx + r * Math.cos(a0),
693
+ oy0 = cy + r * Math.sin(a0);
694
+ const oxM = cx + r * Math.cos(aMid),
695
+ oyM = cy + r * Math.sin(aMid);
696
+ return `M ${fmt(ox0)} ${fmt(oy0)} A ${fmt(r)} ${fmt(r)} 0 0 1 ${fmt(oxM)} ${fmt(oyM)} A ${fmt(r)} ${fmt(r)} 0 0 1 ${fmt(ox0)} ${fmt(oy0)} Z`;
697
+ }
698
+ const ox0 = cx + r * Math.cos(a0),
699
+ oy0 = cy + r * Math.sin(a0);
700
+ const oxM = cx + r * Math.cos(aMid),
701
+ oyM = cy + r * Math.sin(aMid);
702
+ const ix0 = cx + innerR * Math.cos(a0),
703
+ iy0 = cy + innerR * Math.sin(a0);
704
+ const ixM = cx + innerR * Math.cos(aMid),
705
+ iyM = cy + innerR * Math.sin(aMid);
706
+ // Outer ring CW, inner ring CCW (using even-odd fill rule via SVG default).
707
+ return `M ${fmt(ox0)} ${fmt(oy0)} A ${fmt(r)} ${fmt(r)} 0 0 1 ${fmt(oxM)} ${fmt(oyM)} A ${fmt(r)} ${fmt(r)} 0 0 1 ${fmt(ox0)} ${fmt(oy0)} Z` + ` M ${fmt(ix0)} ${fmt(iy0)} A ${fmt(innerR)} ${fmt(innerR)} 0 0 0 ${fmt(ixM)} ${fmt(iyM)} A ${fmt(innerR)} ${fmt(innerR)} 0 0 0 ${fmt(ix0)} ${fmt(iy0)} Z`;
708
+ }
709
+ const large = sweep > Math.PI ? 1 : 0;
710
+ const ox0 = cx + r * Math.cos(a0),
711
+ oy0 = cy + r * Math.sin(a0);
712
+ const ox1 = cx + r * Math.cos(a1),
713
+ oy1 = cy + r * Math.sin(a1);
714
+ if (innerR <= 0) {
715
+ return `M ${fmt(cx)} ${fmt(cy)} L ${fmt(ox0)} ${fmt(oy0)} A ${fmt(r)} ${fmt(r)} 0 ${large} 1 ${fmt(ox1)} ${fmt(oy1)} Z`;
716
+ }
717
+ const ix0 = cx + innerR * Math.cos(a0),
718
+ iy0 = cy + innerR * Math.sin(a0);
719
+ const ix1 = cx + innerR * Math.cos(a1),
720
+ iy1 = cy + innerR * Math.sin(a1);
721
+ return `M ${fmt(ox0)} ${fmt(oy0)} A ${fmt(r)} ${fmt(r)} 0 ${large} 1 ${fmt(ox1)} ${fmt(oy1)} L ${fmt(ix1)} ${fmt(iy1)} A ${fmt(innerR)} ${fmt(innerR)} 0 ${large} 0 ${fmt(ix0)} ${fmt(iy0)} Z`;
722
+ };
723
+
724
+ /**
725
+ * SVG path `d` for a marker shape centered at `(cx, cy)` with circumradius `r`.
726
+ *
727
+ * The shapes are sized so a typical visual radius matches `r`:
728
+ * - circle: full radius
729
+ * - square: side = sqrt(2)·r so the diagonal equals 2·r (visually balanced
730
+ * next to a circle of the same r)
731
+ * - triangle: equilateral pointing up, circumradius r
732
+ * - diamond: square rotated 45°, half-diagonal = r
733
+ * - plus: cross-shape at thickness r·0.5
734
+ * - cross: X-shape at thickness r·0.4
735
+ */
736
+ export const markerPath = (shape, cx, cy, r) => {
737
+ switch (shape) {
738
+ case "circle":
739
+ // Single arc command pair to draw a closed circle.
740
+ return `M ${fmt(cx - r)} ${fmt(cy)} A ${fmt(r)} ${fmt(r)} 0 1 0 ${fmt(cx + r)} ${fmt(cy)} A ${fmt(r)} ${fmt(r)} 0 1 0 ${fmt(cx - r)} ${fmt(cy)} Z`;
741
+ case "square":
742
+ {
743
+ const s = r * Math.SQRT2 / 2; // half-side
744
+ return `M ${fmt(cx - s)} ${fmt(cy - s)} L ${fmt(cx + s)} ${fmt(cy - s)} L ${fmt(cx + s)} ${fmt(cy + s)} L ${fmt(cx - s)} ${fmt(cy + s)} Z`;
745
+ }
746
+ case "triangle":
747
+ {
748
+ // Equilateral pointing up. Circumradius r.
749
+ const h = r * Math.sin(Math.PI / 3) * 1.5; // altitude from base to apex
750
+ return `M ${fmt(cx)} ${fmt(cy - r)} L ${fmt(cx + h * Math.cos(Math.PI / 6))} ${fmt(cy + r * 0.5)} L ${fmt(cx - h * Math.cos(Math.PI / 6))} ${fmt(cy + r * 0.5)} Z`;
751
+ }
752
+ case "diamond":
753
+ return `M ${fmt(cx)} ${fmt(cy - r)} L ${fmt(cx + r)} ${fmt(cy)} L ${fmt(cx)} ${fmt(cy + r)} L ${fmt(cx - r)} ${fmt(cy)} Z`;
754
+ case "plus":
755
+ {
756
+ const t = r * 0.32; // half-thickness
757
+ return `M ${fmt(cx - r)} ${fmt(cy - t)} L ${fmt(cx - t)} ${fmt(cy - t)} L ${fmt(cx - t)} ${fmt(cy - r)} L ${fmt(cx + t)} ${fmt(cy - r)} L ${fmt(cx + t)} ${fmt(cy - t)} L ${fmt(cx + r)} ${fmt(cy - t)} L ${fmt(cx + r)} ${fmt(cy + t)} L ${fmt(cx + t)} ${fmt(cy + t)} L ${fmt(cx + t)} ${fmt(cy + r)} L ${fmt(cx - t)} ${fmt(cy + r)} L ${fmt(cx - t)} ${fmt(cy + t)} L ${fmt(cx - r)} ${fmt(cy + t)} Z`;
758
+ }
759
+ case "cross":
760
+ {
761
+ // X shape — same as plus rotated 45°. Build by composing two oriented bars.
762
+ const a = r * 0.7;
763
+ const t = r * 0.28;
764
+ return `M ${fmt(cx - a + t)} ${fmt(cy - a - t)} L ${fmt(cx - a - t)} ${fmt(cy - a + t)} L ${fmt(cx + a - t)} ${fmt(cy + a + t)} L ${fmt(cx + a + t)} ${fmt(cy + a - t)} Z` + ` M ${fmt(cx + a - t)} ${fmt(cy - a - t)} L ${fmt(cx + a + t)} ${fmt(cy - a + t)} L ${fmt(cx - a + t)} ${fmt(cy + a + t)} L ${fmt(cx - a - t)} ${fmt(cy + a - t)} Z`;
765
+ }
766
+ }
767
+ };
768
+
769
+ /**
770
+ * SVG path `d` for a step (stair) line. `mode` controls where the vertical
771
+ * step happens relative to the data points:
772
+ * - `before` — vertical step at the new x BEFORE the value updates (state
773
+ * machine "Mealy" style: change at input)
774
+ * - `after` — value updates at the data point's x and persists until next x
775
+ * - `middle` — vertical step at the midpoint between consecutive x-values
776
+ */
777
+ export { stepPathD } from "./line-paths";
778
+ /** Format a number for SVG attributes — short, no scientific notation. */
779
+ export { fmt } from "./svg-format";
780
+ export const clamp = (value, min, max) => Math.max(min, Math.min(max, value));
781
+ export const normalizeMinMax = (min, max) => {
782
+ const lo = Number.isFinite(min) ? min : 0;
783
+ const hi = Number.isFinite(max) ? max : 100;
784
+ return lo === hi ? [lo, lo + 1] : lo < hi ? [lo, hi] : [hi, lo];
785
+ };
786
+ export const formatNumberValue = (value, format, unit = "") => {
787
+ if (!Number.isFinite(value)) return "";
788
+ return `${format ? format(value) : fmt(value)}${unit}`;
789
+ };
790
+ export const thresholdFillAttr = color => color ? ` fill="${escapeXml(color)}"` : "";
791
+ export const thresholdStrokeAttr = color => color ? ` stroke="${escapeXml(color)}"` : "";
792
+
793
+ // ==========================
794
+ // AXIS RENDERERS
795
+ // ==========================
796
+
797
+ export const pickMapper = scale => scale === "log" ? mapLog : mapRange;
798
+
799
+ /**
800
+ * Whether a value is renderable on the given axis. Log axes reject zero and
801
+ * negative values (since `log(<=0)` is undefined). Used to filter data
802
+ * points before rendering so we don't emit huge off-plot SVG coordinates.
803
+ */
804
+ export const isOnAxis = (axis, v) => Number.isFinite(v) && (axis.scale !== "log" || v > 0);
805
+
806
+ /**
807
+ * Compute the domain, major ticks, and (optional) minor ticks for an axis,
808
+ * choosing linear or log scale per `axisOpts`. Filters non-positive values
809
+ * out under log scale and falls back to `[1, 10]` if none remain.
810
+ */
811
+ export const computeAxisScale = (values, axisOpts, fallbackTicks = DEFAULT_TICKS) => {
812
+ const scale = axisOpts?.scale === "log" ? "log" : "linear";
813
+ if (axisOpts?.domain) {
814
+ const [lo, hi] = axisOpts.domain;
815
+ if (!Number.isFinite(lo) || !Number.isFinite(hi) || lo >= hi || !Number.isFinite(hi - lo) || scale === "log" && lo <= 0) {
816
+ throw new RangeError("Chart axis domain must have finite increasing bounds (positive for log scales)");
817
+ }
818
+ if (values.some(v => Number.isFinite(v) && (scale !== "log" || v > 0) && (v < lo || v > hi))) {
819
+ throw new RangeError("Chart axis domain must contain all plotted values and bounds");
820
+ }
821
+ const ticks = [];
822
+ if (scale === "log") {
823
+ for (let exponent = Math.floor(Math.log10(lo)); exponent <= Math.ceil(Math.log10(hi)); exponent++) {
824
+ const value = 10 ** exponent;
825
+ if (value > lo && value < hi) ticks.push(value);
826
+ }
827
+ } else {
828
+ const step = niceStep(hi - lo, axisOpts.ticks ?? fallbackTicks);
829
+ // At extreme magnitudes the step may be smaller than one representable
830
+ // increment. Keep endpoint ticks instead of entering a non-advancing loop.
831
+ if (step > 0 && Number.isFinite(step) && (hi - lo) / step <= MAX_AXIS_TICKS) {
832
+ for (let value = Math.ceil(lo / step) * step; value < hi;) {
833
+ if (value > lo && (!axisOpts.insetEndpointLabels || value - lo >= step && hi - value >= step)) ticks.push(value);
834
+ const next = value + step;
835
+ if (next <= value) break;
836
+ value = next;
837
+ }
838
+ }
839
+ }
840
+ return {
841
+ domain: [lo, hi],
842
+ ticks: [...new Set([lo, ...ticks.filter(v => v > lo && v < hi), hi])],
843
+ minorTicks: [],
844
+ scale
845
+ };
846
+ }
847
+ if (scale === "log") {
848
+ const positive = values.filter(v => Number.isFinite(v) && v > 0);
849
+ if (positive.length === 0) {
850
+ return {
851
+ domain: [1, 10],
852
+ ticks: [1, 10],
853
+ minorTicks: [],
854
+ scale
855
+ };
856
+ }
857
+ const min = Math.min(...positive);
858
+ const max = Math.max(...positive);
859
+ const r = niceLogTicks(min, max);
860
+ const minorTicks = [];
861
+ if (axisOpts?.minorTicks) {
862
+ for (let i = 0; i < r.ticks.length - 1; i++) {
863
+ const decade = r.ticks[i];
864
+ for (let m = 2; m <= 9; m++) minorTicks.push(decade * m);
865
+ }
866
+ }
867
+ return {
868
+ domain: r.domain,
869
+ ticks: r.ticks,
870
+ minorTicks,
871
+ scale
872
+ };
873
+ }
874
+ const [minRaw, maxRaw] = computeDomain(values);
875
+ const step = niceStep(maxRaw - minRaw, axisOpts?.ticks ?? fallbackTicks);
876
+ const r = extendDomainToNice(minRaw, maxRaw, step);
877
+ const minorTicks = [];
878
+ if (axisOpts?.minorTicks && r.ticks.length > 1) {
879
+ const SUBDIVISIONS = 5;
880
+ for (let i = 0; i < r.ticks.length - 1; i++) {
881
+ const a = r.ticks[i];
882
+ const b = r.ticks[i + 1];
883
+ const sub = (b - a) / SUBDIVISIONS;
884
+ for (let m = 1; m < SUBDIVISIONS; m++) minorTicks.push(a + sub * m);
885
+ }
886
+ }
887
+ return {
888
+ domain: r.domain,
889
+ ticks: r.ticks,
890
+ minorTicks,
891
+ scale
892
+ };
893
+ };
894
+ export const renderYAxis = (axis, area, opts) => {
895
+ const format = opts?.format ?? (v => String(v));
896
+ const map = pickMapper(axis.scale);
897
+ const parts = [];
898
+ for (const t of axis.ticks) {
899
+ const y = map(t, axis.domain, [area.y1, area.y0]);
900
+ parts.push(`<line class="stdlib-chart-grid" x1="${fmt(area.x0)}" y1="${fmt(y)}" x2="${fmt(area.x1)}" y2="${fmt(y)}"/>`);
901
+ parts.push(`<text class="stdlib-chart-tick-label" x="${fmt(area.x0 - 6)}" y="${fmt(y + 3)}" text-anchor="end">${escapeXml(format(t))}</text>`);
902
+ }
903
+ for (const mt of axis.minorTicks) {
904
+ const y = map(mt, axis.domain, [area.y1, area.y0]);
905
+ parts.push(`<line class="stdlib-chart-minor-tick" x1="${fmt(area.x0 - 3)}" y1="${fmt(y)}" x2="${fmt(area.x0)}" y2="${fmt(y)}"/>`);
906
+ }
907
+ parts.push(`<line class="stdlib-chart-axis" x1="${fmt(area.x0)}" y1="${fmt(area.y0)}" x2="${fmt(area.x0)}" y2="${fmt(area.y1)}"/>`);
908
+ if (opts?.label) {
909
+ const cx = 12;
910
+ const cy = (area.y0 + area.y1) / 2;
911
+ parts.push(`<text class="stdlib-chart-axis-label" x="${fmt(cx)}" y="${fmt(cy)}" text-anchor="middle" transform="rotate(-90 ${fmt(cx)} ${fmt(cy)})">${escapeXml(opts.label)}</text>`);
912
+ }
913
+ return parts.join("");
914
+ };
915
+ export const renderXAxisNumeric = (axis, area, height, opts) => {
916
+ const format = opts?.format ?? (v => String(v));
917
+ const map = pickMapper(axis.scale);
918
+ const parts = [];
919
+ for (const t of axis.ticks) {
920
+ const x = map(t, axis.domain, [area.x0, area.x1]);
921
+ const anchor = opts?.domain && opts.insetEndpointLabels ? t === axis.domain[0] ? "start" : t === axis.domain[1] ? "end" : "middle" : "middle";
922
+ parts.push(`<text class="stdlib-chart-tick-label" x="${fmt(x)}" y="${fmt(area.y1 + 14)}" text-anchor="${anchor}">${escapeXml(format(t))}</text>`);
923
+ }
924
+ for (const mt of axis.minorTicks) {
925
+ const x = map(mt, axis.domain, [area.x0, area.x1]);
926
+ parts.push(`<line class="stdlib-chart-minor-tick" x1="${fmt(x)}" y1="${fmt(area.y1)}" x2="${fmt(x)}" y2="${fmt(area.y1 + 3)}"/>`);
927
+ }
928
+ parts.push(`<line class="stdlib-chart-axis" x1="${fmt(area.x0)}" y1="${fmt(area.y1)}" x2="${fmt(area.x1)}" y2="${fmt(area.y1)}"/>`);
929
+ if (opts?.label) {
930
+ parts.push(`<text class="stdlib-chart-axis-label" x="${fmt((area.x0 + area.x1) / 2)}" y="${fmt(height - 4)}" text-anchor="middle">${escapeXml(opts.label)}</text>`);
931
+ }
932
+ return parts.join("");
933
+ };
934
+ export const renderXAxisCategorical = (labels, area, height, axisLabel) => {
935
+ const parts = [];
936
+ if (labels.length > 0) {
937
+ const step = (area.x1 - area.x0) / labels.length;
938
+ for (let i = 0; i < labels.length; i++) {
939
+ const cx = area.x0 + step * (i + 0.5);
940
+ parts.push(`<text class="stdlib-chart-tick-label" x="${fmt(cx)}" y="${fmt(area.y1 + 14)}" text-anchor="middle">${escapeXml(labels[i])}</text>`);
941
+ }
942
+ }
943
+ parts.push(`<line class="stdlib-chart-axis" x1="${fmt(area.x0)}" y1="${fmt(area.y1)}" x2="${fmt(area.x1)}" y2="${fmt(area.y1)}"/>`);
944
+ if (axisLabel) {
945
+ parts.push(`<text class="stdlib-chart-axis-label" x="${fmt((area.x0 + area.x1) / 2)}" y="${fmt(height - 4)}" text-anchor="middle">${escapeXml(axisLabel)}</text>`);
946
+ }
947
+ return parts.join("");
948
+ };
949
+ export const emptyChart = (width, height, className, message = "no data") => svgRoot({
950
+ width,
951
+ height,
952
+ className
953
+ }, `<text class="stdlib-chart-empty-text" x="${fmt(width / 2)}" y="${fmt(height / 2)}" text-anchor="middle" dominant-baseline="middle">${escapeXml(message)}</text>`);
954
+
955
+ // ==========================
956
+ // CHART FUNCTIONS
957
+ // ==========================
958
+
959
+ export const collectSeriesLegend = opts => {
960
+ if (!opts.legend) return [];
961
+ return opts.series.map((s, i) => ({
962
+ label: s.label && s.label.length > 0 ? s.label : `Series ${i + 1}`,
963
+ seriesIndex: i
964
+ }));
965
+ };
966
+
967
+ // ==========================
968
+ // BAR
969
+ // ==========================
970
+
971
+ // ==========================
972
+ // PIE / DONUT
973
+ // ==========================
974
+
975
+ // ==========================
976
+ // HISTOGRAM
977
+ // ==========================
978
+
979
+ // ==========================
980
+ // BOX PLOT
981
+ // ==========================
982
+
983
+ // ==========================
984
+ // DASHBOARD PANELS
985
+ // ==========================
986
+
987
+ export const thresholdIndexForValue = (value, thresholds, min, max) => {
988
+ if (!thresholds || thresholds.length === 0) return 0;
989
+ const sorted = [...thresholds].filter(t => Number.isFinite(t.value)).sort((a, b) => a.value - b.value);
990
+ const clamped = clamp(value, min, max);
991
+ const idx = sorted.findIndex(t => clamped <= t.value);
992
+ return idx >= 0 ? idx : Math.max(0, sorted.length - 1);
993
+ };
994
+ export const thresholdForIndex = (thresholds, index) => {
995
+ if (!thresholds || thresholds.length === 0) return undefined;
996
+ const sorted = [...thresholds].filter(t => Number.isFinite(t.value)).sort((a, b) => a.value - b.value);
997
+ return sorted[index];
998
+ };
999
+
1000
+ // ==========================
1001
+ // SPARKLINE
1002
+ // ==========================
1003
+ //# sourceMappingURL=svg-common.js.map