@bino-bi/bn-template-engine 1.0.0-alpha.16 → 1.0.0-alpha.17

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 (287) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-172499ac.entry.js +1 -0
  3. package/dist/bn-template-engine/p-19e65c04.entry.js +1 -0
  4. package/dist/bn-template-engine/{p-ff659485.entry.js → p-1a1fd8eb.entry.js} +1 -1
  5. package/dist/bn-template-engine/p-2849c367.entry.js +1 -0
  6. package/dist/bn-template-engine/p-44L8rZSd.js +1 -0
  7. package/dist/bn-template-engine/p-5dd11fcc.entry.js +1 -0
  8. package/dist/bn-template-engine/p-63f891d9.entry.js +1 -0
  9. package/dist/bn-template-engine/p-72f63181.entry.js +1 -0
  10. package/dist/bn-template-engine/p-836ad6f3.entry.js +1 -0
  11. package/dist/bn-template-engine/p-B2KOyHRY.js +1 -0
  12. package/dist/bn-template-engine/p-BA48JiHe.js +1 -0
  13. package/dist/bn-template-engine/p-BnOTt2YD.js +1 -0
  14. package/dist/bn-template-engine/p-CDPTCKVx.js +1 -0
  15. package/dist/bn-template-engine/p-CIXlJoMr.js +1 -0
  16. package/dist/bn-template-engine/{p-BPDZcex5.js → p-COXiPUfj.js} +1 -1
  17. package/dist/bn-template-engine/p-CPZIJpxn.js +1 -0
  18. package/dist/bn-template-engine/p-DHibUOw5.js +1 -0
  19. package/dist/bn-template-engine/p-a50da0f0.entry.js +1 -0
  20. package/dist/bn-template-engine/p-a9a34fb2.entry.js +1 -0
  21. package/dist/bn-template-engine/p-b0369558.entry.js +1 -0
  22. package/dist/bn-template-engine/p-d3fc17ee.entry.js +1 -0
  23. package/dist/bn-template-engine/p-f8c46905.entry.js +1 -0
  24. package/dist/bn-template-engine/p-lIy3SJs2.js +1 -0
  25. package/dist/cjs/AxisConfig-B_GMRfX_.js +233 -0
  26. package/dist/cjs/LabelCollisionManager-8HGn9W0V.js +8616 -0
  27. package/dist/cjs/VarianceMeasure-DEOzP-XZ.js +372 -0
  28. package/dist/cjs/XYChartDataRow-CDl1Ofnv.js +933 -0
  29. package/dist/cjs/bn-asset_21.cjs.entry.js +1586 -9600
  30. package/dist/cjs/bn-chart-bubble.cjs.entry.js +761 -0
  31. package/dist/cjs/bn-chart-scatter.cjs.entry.js +657 -0
  32. package/dist/cjs/bn-grid.cjs.entry.js +4 -3
  33. package/dist/cjs/bn-image.cjs.entry.js +4 -3
  34. package/dist/cjs/bn-internationalization.cjs.entry.js +2 -2
  35. package/dist/cjs/bn-ruleset.cjs.entry.js +41 -0
  36. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  37. package/dist/cjs/bn-template.cjs.entry.js +1 -1
  38. package/dist/cjs/bn-text.cjs.entry.js +7 -79
  39. package/dist/cjs/bn-tree.cjs.entry.js +3 -2
  40. package/dist/cjs/{context-protocol-Cn5PL928.js → context-protocol-CIuyJKkK.js} +206 -1
  41. package/dist/cjs/editor-companion.cjs.entry.js +2 -2
  42. package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +622 -0
  43. package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +665 -0
  44. package/dist/cjs/layoutObserver-CJWRV_y6.js +350 -0
  45. package/dist/cjs/loader.cjs.js +1 -1
  46. package/dist/cjs/sanitizeHtml-LuZr1IMd.js +85 -0
  47. package/dist/cjs/{scaling-DM2UILdF.js → scaling-B4UPXivZ.js} +1 -1
  48. package/dist/cjs/withScalingGroup-D832DQKp.js +73 -0
  49. package/dist/cjs/{withStyled-Dx3uRw9g.js → withStyled-COxuhL-N.js} +43 -301
  50. package/dist/collection/collection-manifest.json +5 -0
  51. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.css +10 -0
  52. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +1110 -0
  53. package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.css +9 -0
  54. package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.js +653 -0
  55. package/dist/collection/components/bn-chart-bubble/utils/BubbleChart.js +472 -0
  56. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.css +10 -0
  57. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +965 -0
  58. package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.css +9 -0
  59. package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.js +580 -0
  60. package/dist/collection/components/bn-chart-scatter/utils/ScatterChart.js +409 -0
  61. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +23 -2
  62. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +29 -4
  63. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +3 -0
  64. package/dist/collection/components/bn-chart-time/bn-chart-time.js +27 -4
  65. package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +29 -4
  66. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +16 -4
  67. package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +3 -3
  68. package/dist/collection/components/bn-component-style/bn-component-style.js +1 -1
  69. package/dist/collection/components/bn-context/bn-context.js +1 -1
  70. package/dist/collection/components/bn-dataset/bn-dataset.js +1 -1
  71. package/dist/collection/components/bn-datasource/bn-datasource.js +1 -1
  72. package/dist/collection/components/bn-footer/bn-footer.js +1 -1
  73. package/dist/collection/components/bn-grid/bn-grid.js +1 -1
  74. package/dist/collection/components/bn-image/bn-image.js +1 -1
  75. package/dist/collection/components/bn-internationalization/bn-internationalization.js +1 -1
  76. package/dist/collection/components/bn-layout-card/bn-layout-card.js +26 -3
  77. package/dist/collection/components/bn-layout-page/bn-layout-page.js +33 -4
  78. package/dist/collection/components/bn-message/bn-message.css +6 -2
  79. package/dist/collection/components/bn-message/bn-message.js +3 -2
  80. package/dist/collection/components/bn-page/bn-page.js +1 -1
  81. package/dist/collection/components/bn-ruleset/bn-ruleset.css +3 -0
  82. package/dist/collection/components/bn-ruleset/bn-ruleset.js +68 -0
  83. package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +1 -1
  84. package/dist/collection/components/bn-table/bn-table.js +146 -14
  85. package/dist/collection/components/bn-table/ibcs-table.css +8 -0
  86. package/dist/collection/components/bn-table/ibcs-table.js +64 -8
  87. package/dist/collection/components/bn-table/utils/Table.js +43 -5
  88. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +13 -8
  89. package/dist/collection/components/bn-table/utils/elements/TableRow.js +3 -2
  90. package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +47 -0
  91. package/dist/collection/components/bn-table/utils/elements/index.js +1 -0
  92. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +87 -15
  93. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +284 -3
  94. package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +140 -0
  95. package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +166 -0
  96. package/dist/collection/components/bn-table/utils/helper/index.js +2 -0
  97. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +10 -0
  98. package/dist/collection/components/bn-template/bn-template.js +1 -1
  99. package/dist/collection/components/bn-text/bn-text.js +2 -75
  100. package/dist/collection/components/bn-title/bn-title.js +27 -3
  101. package/dist/collection/components/bn-title/ibcs-title/ibcs-title.css +4 -0
  102. package/dist/collection/components/bn-title/ibcs-title/ibcs-title.js +29 -3
  103. package/dist/collection/components/bn-title/ibcs-title/utils/Title.js +3 -0
  104. package/dist/collection/components/editor-companion/editor-companion.js +1 -1
  105. package/dist/collection/stores/componentStyles.js +29 -0
  106. package/dist/collection/stores/createScopedStores.js +6 -1
  107. package/dist/collection/stores/internationalization.js +40 -0
  108. package/dist/collection/stores/ruleSets.js +46 -0
  109. package/dist/collection/utils/constants.js +5 -0
  110. package/dist/collection/utils/ibcsRuleSet.js +14 -26
  111. package/dist/collection/utils/sanitizeHtml.js +81 -0
  112. package/dist/collection/utils/validate.js +24 -0
  113. package/dist/collection/utils/withComponentStyle.js +3 -5
  114. package/dist/collection/utils/withInheritedProps.js +1 -1
  115. package/dist/collection/utils/withRuleSet.js +105 -0
  116. package/dist/collection/utils/withScalingGroup.js +3 -0
  117. package/dist/collection/utils/xy/FacetGrid.js +36 -0
  118. package/dist/collection/utils/xy/IsoCurves.js +156 -0
  119. package/dist/collection/utils/xy/NumericScale.js +103 -0
  120. package/dist/collection/utils/xy/PointLabeler.js +96 -0
  121. package/dist/collection/utils/xy/RadiusScale.js +42 -0
  122. package/dist/collection/utils/xy/SeriesPalette.js +80 -0
  123. package/dist/collection/utils/xy/VarianceMeasure.js +76 -0
  124. package/dist/collection/utils/xy/XYFrame.js +120 -0
  125. package/dist/collection/utils/xy/XYLegend.js +107 -0
  126. package/dist/collection/utils/xy/model/AxisConfig.js +221 -0
  127. package/dist/collection/utils/xy/model/ScaleFactorsXYChart.js +69 -0
  128. package/dist/collection/utils/xy/model/XYChartDataRow.js +0 -0
  129. package/dist/collection/utils/xy/model/XYChartStyle.js +52 -0
  130. package/dist/components/AxisConfig.js +1 -0
  131. package/dist/components/CompareUtil.js +1 -0
  132. package/dist/components/DataFormatDigits.js +1 -1
  133. package/dist/components/LabelCollisionManager.js +1 -0
  134. package/dist/components/Order.js +1 -1
  135. package/dist/components/SVGVariancesStyleGroup.js +1 -1
  136. package/dist/components/SiPrefix.js +1 -0
  137. package/dist/components/StringAdapter.js +1 -0
  138. package/dist/components/VarianceMeasure.js +1 -0
  139. package/dist/components/XYChartDataRow.js +1 -0
  140. package/dist/components/bn-chart-bubble.d.ts +11 -0
  141. package/dist/components/bn-chart-bubble.js +1 -0
  142. package/dist/components/bn-chart-scatter.d.ts +11 -0
  143. package/dist/components/bn-chart-scatter.js +1 -0
  144. package/dist/components/bn-chart-structure.js +1 -1
  145. package/dist/components/bn-chart-time.js +1 -1
  146. package/dist/components/bn-component-style.js +1 -1
  147. package/dist/components/bn-context.js +1 -1
  148. package/dist/components/bn-dataset.js +1 -1
  149. package/dist/components/bn-datasource.js +1 -1
  150. package/dist/components/bn-footer2.js +1 -1
  151. package/dist/components/bn-grid.js +1 -1
  152. package/dist/components/bn-image.js +1 -1
  153. package/dist/components/bn-internationalization.js +1 -1
  154. package/dist/components/bn-layout-card.js +1 -1
  155. package/dist/components/bn-layout-page.js +1 -1
  156. package/dist/components/bn-message2.js +1 -1
  157. package/dist/components/bn-page2.js +1 -1
  158. package/dist/components/bn-ruleset.d.ts +11 -0
  159. package/dist/components/bn-ruleset.js +1 -0
  160. package/dist/components/bn-scaling-group.js +1 -1
  161. package/dist/components/bn-table.js +1 -1
  162. package/dist/components/bn-template.js +1 -1
  163. package/dist/components/bn-text.js +1 -1
  164. package/dist/components/bn-title2.js +1 -1
  165. package/dist/components/bn-tree.js +1 -1
  166. package/dist/components/context-protocol.js +1 -1
  167. package/dist/components/editor-companion.js +1 -1
  168. package/dist/components/formatter.js +1 -0
  169. package/dist/components/ibcs-chart-bubble.d.ts +11 -0
  170. package/dist/components/ibcs-chart-bubble.js +1 -0
  171. package/dist/components/ibcs-chart-bubble2.js +1 -0
  172. package/dist/components/ibcs-chart-scatter.d.ts +11 -0
  173. package/dist/components/ibcs-chart-scatter.js +1 -0
  174. package/dist/components/ibcs-chart-scatter2.js +1 -0
  175. package/dist/components/ibcs-chart-structure2.js +1 -1
  176. package/dist/components/ibcs-chart-time2.js +1 -1
  177. package/dist/components/ibcs-table2.js +1 -1
  178. package/dist/components/ibcs-title2.js +1 -1
  179. package/dist/components/layoutObserver.js +1 -1
  180. package/dist/components/luxon.js +1 -1
  181. package/dist/components/merge.js +1 -0
  182. package/dist/components/sanitizeHtml.js +1 -0
  183. package/dist/components/stackColors.js +1 -0
  184. package/dist/components/validate.js +1 -1
  185. package/dist/components/withComponentStyle.js +1 -1
  186. package/dist/components/withDataset.js +1 -0
  187. package/dist/components/withRuleSet.js +1 -0
  188. package/dist/components/withScalingGroup.js +1 -0
  189. package/dist/components/withStyled.js +1 -1
  190. package/dist/esm/AxisConfig-BwUQrme0.js +224 -0
  191. package/dist/esm/LabelCollisionManager-DZP5Vl8T.js +8599 -0
  192. package/dist/esm/VarianceMeasure-Cxshx01h.js +364 -0
  193. package/dist/esm/XYChartDataRow-FF_VxRnF.js +923 -0
  194. package/dist/esm/bn-asset_21.entry.js +1124 -9138
  195. package/dist/esm/bn-chart-bubble.entry.js +759 -0
  196. package/dist/esm/bn-chart-scatter.entry.js +655 -0
  197. package/dist/esm/bn-grid.entry.js +4 -3
  198. package/dist/esm/bn-image.entry.js +4 -3
  199. package/dist/esm/bn-internationalization.entry.js +2 -2
  200. package/dist/esm/bn-ruleset.entry.js +39 -0
  201. package/dist/esm/bn-template-engine.js +1 -1
  202. package/dist/esm/bn-template.entry.js +1 -1
  203. package/dist/esm/bn-text.entry.js +6 -78
  204. package/dist/esm/bn-tree.entry.js +3 -2
  205. package/dist/esm/{context-protocol-BB-4Onmw.js → context-protocol-BNHTlllP.js} +202 -2
  206. package/dist/esm/editor-companion.entry.js +2 -2
  207. package/dist/esm/ibcs-chart-bubble.entry.js +620 -0
  208. package/dist/esm/ibcs-chart-scatter.entry.js +663 -0
  209. package/dist/esm/layoutObserver-D5FY_lQa.js +345 -0
  210. package/dist/esm/loader.js +1 -1
  211. package/dist/esm/sanitizeHtml-BA48JiHe.js +83 -0
  212. package/dist/esm/{scaling-h4KcBet3.js → scaling-B7Pa0d_s.js} +2 -2
  213. package/dist/esm/withScalingGroup-DBheBsP4.js +71 -0
  214. package/dist/esm/{withStyled-BBvU2f-A.js → withStyled-DTvj2nar.js} +29 -287
  215. package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +193 -0
  216. package/dist/types/components/bn-chart-bubble/ibcs-chart-bubble.d.ts +58 -0
  217. package/dist/types/components/bn-chart-bubble/utils/BubbleChart.d.ts +91 -0
  218. package/dist/types/components/bn-chart-scatter/bn-chart-scatter.d.ts +172 -0
  219. package/dist/types/components/bn-chart-scatter/ibcs-chart-scatter.d.ts +53 -0
  220. package/dist/types/components/bn-chart-scatter/utils/ScatterChart.d.ts +66 -0
  221. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +7 -0
  222. package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +2 -0
  223. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +1 -0
  224. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +10 -1
  225. package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +2 -0
  226. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +1 -0
  227. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +10 -0
  228. package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +14 -0
  229. package/dist/types/components/bn-message/bn-message.d.ts +5 -2
  230. package/dist/types/components/bn-ruleset/bn-ruleset.d.ts +8 -0
  231. package/dist/types/components/bn-table/bn-table.d.ts +38 -5
  232. package/dist/types/components/bn-table/ibcs-table.d.ts +8 -1
  233. package/dist/types/components/bn-table/utils/Table.d.ts +8 -0
  234. package/dist/types/components/bn-table/utils/elements/Cell.d.ts +2 -0
  235. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +33 -0
  236. package/dist/types/components/bn-table/utils/elements/TableRow.d.ts +2 -1
  237. package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +21 -0
  238. package/dist/types/components/bn-table/utils/elements/index.d.ts +1 -0
  239. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +13 -7
  240. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +17 -0
  241. package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +37 -0
  242. package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +55 -0
  243. package/dist/types/components/bn-table/utils/helper/index.d.ts +2 -0
  244. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +4 -0
  245. package/dist/types/components/bn-table/utils/model/index.d.ts +21 -0
  246. package/dist/types/components/bn-title/bn-title.d.ts +11 -1
  247. package/dist/types/components/bn-title/ibcs-title/ibcs-title.d.ts +2 -0
  248. package/dist/types/components/bn-title/ibcs-title/utils/Title.d.ts +1 -0
  249. package/dist/types/components.d.ts +943 -37
  250. package/dist/types/context/context-protocol.d.ts +2 -0
  251. package/dist/types/stores/componentStyles.d.ts +21 -0
  252. package/dist/types/stores/createScopedStores.d.ts +2 -0
  253. package/dist/types/stores/ruleSets.d.ts +40 -0
  254. package/dist/types/utils/constants.d.ts +5 -0
  255. package/dist/types/utils/ibcsRuleSet.d.ts +6 -1
  256. package/dist/types/utils/model/ChartStyles.d.ts +2 -1
  257. package/dist/types/utils/sanitizeHtml.d.ts +6 -0
  258. package/dist/types/utils/validate.d.ts +12 -0
  259. package/dist/types/utils/withInheritedProps.d.ts +11 -0
  260. package/dist/types/utils/withRuleSet.d.ts +24 -0
  261. package/dist/types/utils/xy/FacetGrid.d.ts +27 -0
  262. package/dist/types/utils/xy/IsoCurves.d.ts +46 -0
  263. package/dist/types/utils/xy/NumericScale.d.ts +41 -0
  264. package/dist/types/utils/xy/PointLabeler.d.ts +58 -0
  265. package/dist/types/utils/xy/RadiusScale.d.ts +26 -0
  266. package/dist/types/utils/xy/SeriesPalette.d.ts +59 -0
  267. package/dist/types/utils/xy/VarianceMeasure.d.ts +37 -0
  268. package/dist/types/utils/xy/XYFrame.d.ts +44 -0
  269. package/dist/types/utils/xy/XYLegend.d.ts +43 -0
  270. package/dist/types/utils/xy/model/AxisConfig.d.ts +96 -0
  271. package/dist/types/utils/xy/model/ScaleFactorsXYChart.d.ts +36 -0
  272. package/dist/types/utils/xy/model/XYChartDataRow.d.ts +157 -0
  273. package/dist/types/utils/xy/model/XYChartStyle.d.ts +31 -0
  274. package/package.json +1 -1
  275. package/readme.md +7 -3
  276. package/dist/bn-template-engine/p-19f49fbc.entry.js +0 -1
  277. package/dist/bn-template-engine/p-3465fcdc.entry.js +0 -1
  278. package/dist/bn-template-engine/p-67746414.entry.js +0 -1
  279. package/dist/bn-template-engine/p-6b469808.entry.js +0 -1
  280. package/dist/bn-template-engine/p-86ca2d5e.entry.js +0 -1
  281. package/dist/bn-template-engine/p-Tx6omDWp.js +0 -1
  282. package/dist/bn-template-engine/p-d724ab88.entry.js +0 -1
  283. package/dist/bn-template-engine/p-efd3b67a.entry.js +0 -1
  284. package/dist/bn-template-engine/p-z9bPNFYF.js +0 -1
  285. package/dist/components/ibcsRuleSet.js +0 -1
  286. package/dist/components/scaling.js +0 -1
  287. package/dist/components/withInheritedProps.js +0 -1
@@ -0,0 +1,933 @@
1
+ 'use strict';
2
+
3
+ var VarianceMeasure = require('./VarianceMeasure-DEOzP-XZ.js');
4
+ var contextProtocol = require('./context-protocol-CIuyJKkK.js');
5
+ var LabelCollisionManager = require('./LabelCollisionManager-8HGn9W0V.js');
6
+
7
+ /**
8
+ * Aggregates all style configuration for an XY chart (scatter/bubble):
9
+ * scale factors, fonts, axis styles, the series color palette, and padding.
10
+ *
11
+ * The analog of {@link TimeChartStyle} with `seriesColors` in place of
12
+ * `stackColors` and no variance styles (variance measures position points,
13
+ * they don't color them).
14
+ */
15
+ class XYChartStyle {
16
+ constructor(scaleFactors, fontStyles, axisStyles, padding) {
17
+ this.scaleFactors = scaleFactors;
18
+ this.fontStyles = fontStyles;
19
+ this.axisStyles = axisStyles;
20
+ this.padding = padding;
21
+ this.seriesColors = [...contextProtocol.XY_SERIES_PALETTE];
22
+ }
23
+ }
24
+ /** Adapts raw componentStyle JSON into an XYChartStyle, falling back to defaults for missing properties. */
25
+ class XYChartStylesAdapter {
26
+ constructor(scaleFactorsXYChartAdapter, fontStyleAdapter, svgStyleGroupAdapter, paddingAdapter) {
27
+ this.scaleFactorsXYChartAdapter = scaleFactorsXYChartAdapter;
28
+ this.fontStyleAdapter = fontStyleAdapter;
29
+ this.svgStyleGroupAdapter = svgStyleGroupAdapter;
30
+ this.paddingAdapter = paddingAdapter;
31
+ }
32
+ adapt(data) {
33
+ const styles = this.default();
34
+ if (VarianceMeasure.CompareUtil.isExisting(data)) {
35
+ if (VarianceMeasure.CompareUtil.isExisting(data.scaleFactors)) {
36
+ styles.scaleFactors = this.scaleFactorsXYChartAdapter.adapt(data.scaleFactors);
37
+ }
38
+ if (VarianceMeasure.CompareUtil.isExisting(data.fontStyles)) {
39
+ styles.fontStyles = this.fontStyleAdapter.adapt(data.fontStyles);
40
+ }
41
+ if (VarianceMeasure.CompareUtil.isExisting(data.axisStyles)) {
42
+ styles.axisStyles = this.svgStyleGroupAdapter.adapt(data.axisStyles);
43
+ }
44
+ if (VarianceMeasure.CompareUtil.isExisting(data.padding)) {
45
+ styles.padding = this.paddingAdapter.adapt(data.padding);
46
+ }
47
+ if (Array.isArray(data.seriesColors) && data.seriesColors.length > 0) {
48
+ styles.seriesColors = data.seriesColors;
49
+ }
50
+ }
51
+ return styles;
52
+ }
53
+ default() {
54
+ return new XYChartStyle(this.scaleFactorsXYChartAdapter.default(), this.fontStyleAdapter.default(), this.svgStyleGroupAdapter.default(), this.paddingAdapter.default());
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Proportional scale factors for XY chart elements (scatter and bubble).
60
+ *
61
+ * All values except the `*LineWidth` entries are expressed in **font-size
62
+ * multiples** (em-like units), so the chart scales uniformly when the base
63
+ * font size changes. The chart renderer multiplies each factor by the
64
+ * computed font size to get pixel dimensions. Line widths are absolute
65
+ * pixel values (hairlines must not scale with the font).
66
+ */
67
+ class ScaleFactorsXYChart {
68
+ constructor() {
69
+ /** Radius of a scatter point. */
70
+ this.pointRadius = 0.4;
71
+ /** Maximum bubble radius in local (vMax-normalized) sizing mode. */
72
+ this.bubbleMaxRadius = 3.2;
73
+ /** Minimum visible bubble radius in local sizing mode. */
74
+ this.bubbleMinRadius = 0.35;
75
+ /** Length of axis tick marks. */
76
+ this.axisTickLength = 0.35;
77
+ /** Gap between a mark (dot/bubble) and its name label. */
78
+ this.labelToMark = 0.3;
79
+ /** Diameter of a legend color swatch. */
80
+ this.legendSwatch = 0.9;
81
+ /** Gap between facet panels. */
82
+ this.panelGap = 1.6;
83
+ /** Stroke width of reference lines, in pixels. */
84
+ this.refLineWidth = 1;
85
+ /** Stroke width of gridlines and the plot frame, in pixels. */
86
+ this.gridLineWidth = 1;
87
+ }
88
+ }
89
+ /** Converts untyped JSON into a validated {@link ScaleFactorsXYChart}. */
90
+ class ScaleFactorsXYChartAdapter {
91
+ adapt(data) {
92
+ const scaleFactors = new ScaleFactorsXYChart();
93
+ if (VarianceMeasure.CompareUtil.isNumber(data.pointRadius)) {
94
+ scaleFactors.pointRadius = data.pointRadius;
95
+ }
96
+ if (VarianceMeasure.CompareUtil.isNumber(data.bubbleMaxRadius)) {
97
+ scaleFactors.bubbleMaxRadius = data.bubbleMaxRadius;
98
+ }
99
+ if (VarianceMeasure.CompareUtil.isNumber(data.bubbleMinRadius)) {
100
+ scaleFactors.bubbleMinRadius = data.bubbleMinRadius;
101
+ }
102
+ if (VarianceMeasure.CompareUtil.isNumber(data.axisTickLength)) {
103
+ scaleFactors.axisTickLength = data.axisTickLength;
104
+ }
105
+ if (VarianceMeasure.CompareUtil.isNumber(data.labelToMark)) {
106
+ scaleFactors.labelToMark = data.labelToMark;
107
+ }
108
+ if (VarianceMeasure.CompareUtil.isNumber(data.legendSwatch)) {
109
+ scaleFactors.legendSwatch = data.legendSwatch;
110
+ }
111
+ if (VarianceMeasure.CompareUtil.isNumber(data.panelGap)) {
112
+ scaleFactors.panelGap = data.panelGap;
113
+ }
114
+ if (VarianceMeasure.CompareUtil.isNumber(data.refLineWidth)) {
115
+ scaleFactors.refLineWidth = data.refLineWidth;
116
+ }
117
+ if (VarianceMeasure.CompareUtil.isNumber(data.gridLineWidth)) {
118
+ scaleFactors.gridLineWidth = data.gridLineWidth;
119
+ }
120
+ return scaleFactors;
121
+ }
122
+ default() {
123
+ return new ScaleFactorsXYChart();
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Small-multiple panel layout: divides a drawing area into equal panels,
129
+ * wrapping row-major at `columns`. Axis tick labels render on the outer
130
+ * edges only (IBCS 10F/10G style) — the `isOuterLeft`/`isOuterBottom`
131
+ * flags tell the renderer which panels carry them.
132
+ */
133
+ class FacetGrid {
134
+ constructor(count, columns, drawingRect, panelGapPx) {
135
+ this.count = count;
136
+ this.drawingRect = drawingRect;
137
+ this.panelGapPx = panelGapPx;
138
+ this.columns = Math.max(1, Math.min(columns !== null && columns !== void 0 ? columns : count, count));
139
+ this.rows = Math.max(1, Math.ceil(count / this.columns));
140
+ }
141
+ /** Rectangle of the i-th panel (row-major order). */
142
+ panelRect(index) {
143
+ const col = index % this.columns;
144
+ const row = Math.floor(index / this.columns);
145
+ const width = (this.drawingRect.width - (this.columns - 1) * this.panelGapPx) / this.columns;
146
+ const height = (this.drawingRect.height - (this.rows - 1) * this.panelGapPx) / this.rows;
147
+ return {
148
+ x: this.drawingRect.x + col * (width + this.panelGapPx),
149
+ y: this.drawingRect.y + row * (height + this.panelGapPx),
150
+ width,
151
+ height,
152
+ };
153
+ }
154
+ /** True when the panel sits in the leftmost column (carries y tick labels). */
155
+ isOuterLeft(index) {
156
+ return index % this.columns === 0;
157
+ }
158
+ /** True when no panel renders below this one (carries x tick labels). */
159
+ isOuterBottom(index) {
160
+ return index + this.columns >= this.count;
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Linear numeric scale with nice-tick generation for the XY charts.
166
+ *
167
+ * Domains default to the data extent padded 4% on each side; zero-inclusion
168
+ * is NOT forced — points encode by position, not length, so IBCS's
169
+ * zero-baseline rule for bars does not apply. Explicit `min`/`max`
170
+ * overrides disable the padding on that side.
171
+ */
172
+ class NumericScale {
173
+ constructor(domainMin, domainMax, rangeMin, rangeMax) {
174
+ this.domainMin = domainMin;
175
+ this.domainMax = domainMax;
176
+ this.rangeMin = rangeMin;
177
+ this.rangeMax = rangeMax;
178
+ }
179
+ /** Maps a domain value to range (pixel) coordinates. */
180
+ scale(value) {
181
+ const span = this.domainMax - this.domainMin;
182
+ if (span === 0) {
183
+ return (this.rangeMin + this.rangeMax) / 2;
184
+ }
185
+ return this.rangeMin + ((value - this.domainMin) / span) * (this.rangeMax - this.rangeMin);
186
+ }
187
+ /**
188
+ * Computes the domain from a data extent: 4% padding on each side,
189
+ * overridden per side by explicit `min`/`max`. Degenerate extents
190
+ * (single value) are widened symmetrically.
191
+ */
192
+ static domain(dataMin, dataMax, override, pad = 0.04) {
193
+ let span = dataMax - dataMin;
194
+ if (span === 0) {
195
+ const widen = dataMin === 0 ? 1 : Math.abs(dataMin) * 0.1;
196
+ dataMin -= widen;
197
+ dataMax += widen;
198
+ span = dataMax - dataMin;
199
+ }
200
+ const min = (override === null || override === void 0 ? void 0 : override.min) !== undefined ? override.min : dataMin - span * pad;
201
+ const max = (override === null || override === void 0 ? void 0 : override.max) !== undefined ? override.max : dataMax + span * pad;
202
+ return [min, max];
203
+ }
204
+ /**
205
+ * Picks a nice step size from the 1-2-2.5-5 ladder so that the span
206
+ * yields close to `targetCount` ticks.
207
+ */
208
+ static niceStep(span, targetCount) {
209
+ if (span <= 0 || targetCount <= 0) {
210
+ return 1;
211
+ }
212
+ const rawStep = span / targetCount;
213
+ const magnitude = Math.pow(10, Math.floor(Math.log10(rawStep)));
214
+ const normalized = rawStep / magnitude;
215
+ let mantissa;
216
+ if (normalized <= 1) {
217
+ mantissa = 1;
218
+ }
219
+ else if (normalized <= 2) {
220
+ mantissa = 2;
221
+ }
222
+ else if (normalized <= 2.5) {
223
+ mantissa = 2.5;
224
+ }
225
+ else if (normalized <= 5) {
226
+ mantissa = 5;
227
+ }
228
+ else {
229
+ mantissa = 10;
230
+ }
231
+ return mantissa * magnitude;
232
+ }
233
+ /**
234
+ * Nice tick values inside the domain, aiming for `targetCount` ticks
235
+ * (the renderer picks 4–8 depending on panel size).
236
+ */
237
+ ticks(targetCount) {
238
+ const span = this.domainMax - this.domainMin;
239
+ if (span <= 0) {
240
+ return [this.domainMin];
241
+ }
242
+ const step = NumericScale.niceStep(span, targetCount);
243
+ const first = Math.ceil(this.domainMin / step) * step;
244
+ const ticks = [];
245
+ // Guard against floating-point drift at the domain edge.
246
+ for (let tick = first; tick <= this.domainMax + step * 1e-9; tick += step) {
247
+ ticks.push(Math.abs(tick) < step * 1e-9 ? 0 : tick);
248
+ }
249
+ return ticks;
250
+ }
251
+ /**
252
+ * Decimal places (0–2) needed to render the given ticks without
253
+ * ambiguity between adjacent values.
254
+ */
255
+ static tickDecimals(ticks) {
256
+ let decimals = 0;
257
+ for (const tick of ticks) {
258
+ const text = String(tick);
259
+ const dot = text.indexOf(".");
260
+ if (dot >= 0) {
261
+ decimals = Math.max(decimals, Math.min(2, text.length - dot - 1));
262
+ }
263
+ }
264
+ return decimals;
265
+ }
266
+ }
267
+
268
+ const ANCHORS = ["n", "ne", "e", "se", "s", "sw", "w", "nw"];
269
+ const DIAGONAL = Math.SQRT1_2;
270
+ /**
271
+ * Selective point labeling with greedy collision-free placement for the XY
272
+ * charts. Composes the existing {@link LabelCollisionManager} (AABB
273
+ * register/hasCollision core); marks are pre-registered as bounding
274
+ * squares — conservative for circles, acceptable for label proximity.
275
+ *
276
+ * Placement tries eight anchors clockwise from north and rejects positions
277
+ * that leave the frame or collide with marks or other labels; unplaceable
278
+ * labels are dropped (IBCS wants proximate labels — no leader lines).
279
+ */
280
+ class PointLabeler {
281
+ constructor(frame, gapPx, manager = new LabelCollisionManager.LabelCollisionManager()) {
282
+ this.frame = frame;
283
+ this.gapPx = gapPx;
284
+ this.manager = manager;
285
+ }
286
+ /** Registers a mark so labels avoid it (bounding-square approximation). */
287
+ registerMark(cx, cy, r) {
288
+ this.manager.register(this.bounds(cx - r, cy - r, 2 * r, 2 * r));
289
+ }
290
+ /**
291
+ * Selects which points receive labels. `items` must be pre-ranked for
292
+ * `"auto"` mode (extremity for scatter, size descending for bubble).
293
+ */
294
+ selectCandidates(items, mode, max, nameOf) {
295
+ if (mode === "none") {
296
+ return { selected: [], unknownNames: [] };
297
+ }
298
+ if (mode === "all") {
299
+ return { selected: [...items], unknownNames: [] };
300
+ }
301
+ if (mode === "auto") {
302
+ return { selected: items.slice(0, max), unknownNames: [] };
303
+ }
304
+ const wanted = new Set(mode);
305
+ const selected = items.filter((item) => wanted.has(nameOf(item)));
306
+ const found = new Set(selected.map((item) => nameOf(item)));
307
+ const unknownNames = mode.filter((name) => !found.has(name));
308
+ return { selected, unknownNames };
309
+ }
310
+ /** Greedy placement in candidate order; returns only the labels that fit. */
311
+ place(candidates) {
312
+ const placed = [];
313
+ for (const candidate of candidates) {
314
+ for (const anchor of ANCHORS) {
315
+ const box = this.anchorBox(candidate, anchor);
316
+ if (!this.insideFrame(box.x, box.y, candidate.width, candidate.height)) {
317
+ continue;
318
+ }
319
+ const bounds = this.bounds(box.x, box.y, candidate.width, candidate.height);
320
+ if (this.manager.hasCollision(bounds)) {
321
+ continue;
322
+ }
323
+ this.manager.register(bounds);
324
+ placed.push({ candidate, x: box.x, y: box.y, anchor });
325
+ break;
326
+ }
327
+ }
328
+ return placed;
329
+ }
330
+ anchorBox(c, anchor) {
331
+ const offset = c.r + this.gapPx;
332
+ const diagonal = c.r * DIAGONAL + this.gapPx * 0.5;
333
+ switch (anchor) {
334
+ case "n":
335
+ return { x: c.cx - c.width / 2, y: c.cy - offset - c.height };
336
+ case "ne":
337
+ return { x: c.cx + diagonal, y: c.cy - diagonal - c.height };
338
+ case "e":
339
+ return { x: c.cx + offset, y: c.cy - c.height / 2 };
340
+ case "se":
341
+ return { x: c.cx + diagonal, y: c.cy + diagonal };
342
+ case "s":
343
+ return { x: c.cx - c.width / 2, y: c.cy + offset };
344
+ case "sw":
345
+ return { x: c.cx - diagonal - c.width, y: c.cy + diagonal };
346
+ case "w":
347
+ return { x: c.cx - offset - c.width, y: c.cy - c.height / 2 };
348
+ case "nw":
349
+ return { x: c.cx - diagonal - c.width, y: c.cy - diagonal - c.height };
350
+ }
351
+ }
352
+ insideFrame(x, y, width, height) {
353
+ return (x >= this.frame.x &&
354
+ y >= this.frame.y &&
355
+ x + width <= this.frame.x + this.frame.width &&
356
+ y + height <= this.frame.y + this.frame.height);
357
+ }
358
+ bounds(x, y, width, height) {
359
+ return { x, y, width, height, pointIndex: 0, preferredHook: LabelCollisionManager.HookLocation.Center };
360
+ }
361
+ }
362
+
363
+ /**
364
+ * Per-panel plot frame for the XY charts: highlight bands, gridlines,
365
+ * reference lines, the frame rectangle, tick labels, and the panel title.
366
+ *
367
+ * Style roles are taken from the `axisStyles` scenario group:
368
+ * `ac` = frame + tick labels, `pp` = gridlines, `fc` = reference lines
369
+ * and iso-curves, `pl` = highlight band fill.
370
+ */
371
+ class XYFrame {
372
+ constructor(xScale, yScale, rect, styles) {
373
+ this.xScale = xScale;
374
+ this.yScale = yScale;
375
+ this.rect = rect;
376
+ this.styles = styles;
377
+ }
378
+ get em() {
379
+ return this.styles.fontStyles.size;
380
+ }
381
+ fontFamily() {
382
+ return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/, "");
383
+ }
384
+ /** Shaded bands behind everything; open ends run to the domain edge. */
385
+ drawBands(group, xHighlight, yHighlight) {
386
+ var _a, _b, _c, _d;
387
+ const fill = this.styles.axisStyles.pl.fill;
388
+ if (xHighlight !== undefined && (xHighlight.from !== undefined || xHighlight.to !== undefined)) {
389
+ const from = this.xScale.scale((_a = xHighlight.from) !== null && _a !== void 0 ? _a : this.xScale.domainMin);
390
+ const to = this.xScale.scale((_b = xHighlight.to) !== null && _b !== void 0 ? _b : this.xScale.domainMax);
391
+ group
392
+ .rect(Math.abs(to - from), this.rect.height)
393
+ .move(Math.min(from, to), this.rect.y)
394
+ .fill(fill);
395
+ }
396
+ if (yHighlight !== undefined && (yHighlight.from !== undefined || yHighlight.to !== undefined)) {
397
+ const from = this.yScale.scale((_c = yHighlight.from) !== null && _c !== void 0 ? _c : this.yScale.domainMin);
398
+ const to = this.yScale.scale((_d = yHighlight.to) !== null && _d !== void 0 ? _d : this.yScale.domainMax);
399
+ group
400
+ .rect(this.rect.width, Math.abs(from - to))
401
+ .move(this.rect.x, Math.min(from, to))
402
+ .fill(fill);
403
+ }
404
+ }
405
+ /** Horizontal gridlines at the y ticks; vertical ones only when `ticksX` is given. */
406
+ drawGrid(group, ticksY, ticksX) {
407
+ const stroke = { color: this.styles.axisStyles.pp.stroke, width: this.styles.scaleFactors.gridLineWidth };
408
+ for (const tick of ticksY) {
409
+ const y = this.yScale.scale(tick);
410
+ group.line(this.rect.x, y, this.rect.x + this.rect.width, y).stroke(stroke);
411
+ }
412
+ if (ticksX !== undefined) {
413
+ for (const tick of ticksX) {
414
+ const x = this.xScale.scale(tick);
415
+ group.line(x, this.rect.y, x, this.rect.y + this.rect.height).stroke(stroke);
416
+ }
417
+ }
418
+ }
419
+ /** Thin reference lines at the given axis values (10A quadrant crosshair). */
420
+ drawRefLines(group, xRef, yRef) {
421
+ const stroke = { color: this.styles.axisStyles.fc.stroke, width: this.styles.scaleFactors.refLineWidth };
422
+ if (xRef !== undefined) {
423
+ const x = this.xScale.scale(xRef);
424
+ group.line(x, this.rect.y, x, this.rect.y + this.rect.height).stroke(stroke);
425
+ }
426
+ if (yRef !== undefined) {
427
+ const y = this.yScale.scale(yRef);
428
+ group.line(this.rect.x, y, this.rect.x + this.rect.width, y).stroke(stroke);
429
+ }
430
+ }
431
+ /** The four-sided thin plot frame (as in the IBCS template images). */
432
+ drawFrame(group) {
433
+ group
434
+ .rect(this.rect.width, this.rect.height)
435
+ .move(this.rect.x, this.rect.y)
436
+ .fill("none")
437
+ .stroke({ color: this.styles.axisStyles.ac.stroke, width: this.styles.scaleFactors.gridLineWidth });
438
+ }
439
+ /** Tick labels along the outer edges (no tick marks — template style). */
440
+ drawTickLabels(group, config) {
441
+ const gap = this.styles.scaleFactors.axisTickLength * this.em;
442
+ const font = { size: this.styles.fontStyles.size, anchor: "start" };
443
+ const family = this.fontFamily();
444
+ const color = this.styles.fontStyles.color;
445
+ if (config.showXLabels) {
446
+ for (const tick of config.ticksX) {
447
+ const x = this.xScale.scale(tick);
448
+ group
449
+ .text(LabelCollisionManager.Formatter.number(tick, "decimal", config.xDecimals, config.xDecimals))
450
+ .font(Object.assign(Object.assign({}, font), { anchor: "middle" }))
451
+ .fill(color)
452
+ .attr({ x, y: this.rect.y + this.rect.height + gap + this.em * 0.8, "font-family": family });
453
+ }
454
+ }
455
+ if (config.showYLabels) {
456
+ for (const tick of config.ticksY) {
457
+ const y = this.yScale.scale(tick);
458
+ group
459
+ .text(LabelCollisionManager.Formatter.number(tick, "decimal", config.yDecimals, config.yDecimals))
460
+ .font(Object.assign(Object.assign({}, font), { anchor: "end" }))
461
+ .fill(color)
462
+ .attr({ x: this.rect.x - gap, y: y + this.em * 0.35, "font-family": family });
463
+ }
464
+ }
465
+ }
466
+ /** Facet panel title, top-left inside the panel, bold (10F "Europe"/"RoW"). */
467
+ drawPanelTitle(group, title) {
468
+ if (title === "") {
469
+ return;
470
+ }
471
+ group
472
+ .text(title)
473
+ .font({ size: this.styles.fontStyles.size, weight: "bold", anchor: "start" })
474
+ .fill(this.styles.fontStyles.color)
475
+ .attr({
476
+ x: this.rect.x + 0.5 * this.em,
477
+ y: this.rect.y + 1.2 * this.em,
478
+ "font-family": this.fontFamily(),
479
+ });
480
+ }
481
+ }
482
+
483
+ /**
484
+ * Series-color legend + bubble-size caption for the XY charts
485
+ * (IBCS requires a legend explaining colors — and, for bubbles, size).
486
+ * Positioned by the orchestrator: right column (default) or bottom row.
487
+ */
488
+ class XYLegend {
489
+ constructor(styles) {
490
+ this.styles = styles;
491
+ }
492
+ get em() {
493
+ return this.styles.fontStyles.size;
494
+ }
495
+ get rowHeight() {
496
+ return this.em * 1.5;
497
+ }
498
+ get swatchSize() {
499
+ return this.styles.scaleFactors.legendSwatch * this.em;
500
+ }
501
+ textWidth(text, bold = false) {
502
+ const width = LabelCollisionManager.CalculateSize(text, {
503
+ font: this.styles.fontStyles.font,
504
+ fontSize: this.styles.fontStyles.size + "px",
505
+ fontWeight: bold ? "bold" : "normal",
506
+ }).width;
507
+ // calculate-size needs a live DOM; fall back to an estimate in test environments.
508
+ return Number.isFinite(width) && width > 0 ? width : text.length * 0.6 * this.em;
509
+ }
510
+ rows(model) {
511
+ const rows = [];
512
+ model.sizeCaption.forEach((line, index) => {
513
+ rows.push({ text: line, bold: index === 0, treatment: null });
514
+ });
515
+ if (model.title !== null && model.title !== "") {
516
+ rows.push({ text: model.title, bold: true, treatment: null });
517
+ }
518
+ for (const entry of model.compareEntries) {
519
+ rows.push({ text: entry.label, bold: false, treatment: entry.treatment });
520
+ }
521
+ for (const entry of model.entries) {
522
+ rows.push({ text: entry.label, bold: false, treatment: entry.treatment });
523
+ }
524
+ return rows;
525
+ }
526
+ /** Footprint of the legend for layout reservation. */
527
+ measure(model, position) {
528
+ const rows = this.rows(model);
529
+ if (rows.length === 0) {
530
+ return { width: 0, height: 0 };
531
+ }
532
+ const swatchSpan = this.swatchSize + 0.4 * this.em;
533
+ if (position === "bottom") {
534
+ let width = 0;
535
+ for (const row of rows) {
536
+ width += (row.treatment !== null ? swatchSpan : 0) + this.textWidth(row.text, row.bold) + 1.5 * this.em;
537
+ }
538
+ return { width, height: this.rowHeight };
539
+ }
540
+ let width = 0;
541
+ for (const row of rows) {
542
+ width = Math.max(width, (row.treatment !== null ? swatchSpan : 0) + this.textWidth(row.text, row.bold));
543
+ }
544
+ return { width, height: rows.length * this.rowHeight };
545
+ }
546
+ /** Draws the legend with its top-left corner at `x`/`y`. */
547
+ draw(group, model, x, y, position) {
548
+ const rows = this.rows(model);
549
+ const swatchSpan = this.swatchSize + 0.4 * this.em;
550
+ let cursorX = x;
551
+ let cursorY = y;
552
+ for (const row of rows) {
553
+ let textX = cursorX;
554
+ if (row.treatment !== null) {
555
+ const swatch = group
556
+ .circle(this.swatchSize)
557
+ .move(cursorX, cursorY + (this.rowHeight - this.swatchSize) / 2)
558
+ .fill(row.treatment.hatch ? "#ffffff" : row.treatment.fill)
559
+ .stroke({
560
+ color: row.treatment.stroke === "#ffffff" ? row.treatment.fill : row.treatment.stroke,
561
+ width: row.treatment.strokeWidth,
562
+ });
563
+ if (row.treatment.dasharray !== undefined) {
564
+ swatch.attr("stroke-dasharray", row.treatment.dasharray);
565
+ }
566
+ textX += swatchSpan;
567
+ }
568
+ group
569
+ .text(row.text)
570
+ .font({
571
+ size: this.styles.fontStyles.size,
572
+ weight: row.bold ? "bold" : "normal",
573
+ anchor: "start",
574
+ })
575
+ .fill(this.styles.fontStyles.color)
576
+ .attr({ x: textX, y: cursorY + this.rowHeight / 2 + this.em * 0.35, "font-family": this.fontFamily() });
577
+ if (position === "bottom") {
578
+ cursorX = textX + this.textWidth(row.text, row.bold) + 1.5 * this.em;
579
+ }
580
+ else {
581
+ cursorY += this.rowHeight;
582
+ }
583
+ }
584
+ }
585
+ fontFamily() {
586
+ return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/, "");
587
+ }
588
+ }
589
+
590
+ /**
591
+ * IBCS-compliant data row for XY (scatter/bubble) chart visualizations.
592
+ *
593
+ * Same schema as {@link StructureChartDataRow}: the full dimension hierarchy
594
+ * plus the 16 scenario value slots. `date` is parsed but unused (reserved),
595
+ * there are no `setName` semantics. `_`-prefixed passthrough columns are
596
+ * retained on the row (engine convention) but unused by v1 rendering;
597
+ * `<slot>_cnt` columns feed the variance no-data rule.
598
+ */
599
+ class XYChartDataRow {
600
+ constructor() {
601
+ this.operation = "+";
602
+ /** `_`-prefixed passthrough columns, retained but unused by v1 rendering. */
603
+ this.custom = {};
604
+ /** `<slot>_cnt` columns: non-null value counts used by the variance no-data rule. */
605
+ this.counts = {};
606
+ }
607
+ /** Value of a scenario slot, `null`-normalized. */
608
+ slotValue(slot) {
609
+ const value = this[slot];
610
+ return VarianceMeasure.CompareUtil.isNumber(value) ? value : null;
611
+ }
612
+ /** True when the slot's `_cnt` column reports zero non-null source values. */
613
+ slotHasNoData(slot) {
614
+ return this.counts[slot] === 0;
615
+ }
616
+ }
617
+ const SCENARIO_SLOTS = [
618
+ "ac1",
619
+ "ac2",
620
+ "ac3",
621
+ "ac4",
622
+ "pp1",
623
+ "pp2",
624
+ "pp3",
625
+ "pp4",
626
+ "fc1",
627
+ "fc2",
628
+ "fc3",
629
+ "fc4",
630
+ "pl1",
631
+ "pl2",
632
+ "pl3",
633
+ "pl4",
634
+ ];
635
+ /**
636
+ * Converts untyped JSON records into validated {@link XYChartDataRow}
637
+ * instances. Only assigns fields that pass {@link CompareUtil} type guards,
638
+ * so malformed input data is silently dropped and defaults are preserved.
639
+ */
640
+ class XYChartDataRowAdapter {
641
+ adapt(data) {
642
+ const row = new XYChartDataRow();
643
+ if (VarianceMeasure.CompareUtil.isOperator(data.operation)) {
644
+ row.operation = data.operation;
645
+ }
646
+ if (VarianceMeasure.CompareUtil.isString(data.date)) {
647
+ const parsed = contextProtocol.DateTime.fromISO(data.date);
648
+ row.date = parsed.isValid ? parsed : undefined;
649
+ }
650
+ if (VarianceMeasure.CompareUtil.isString(data.rowGroup) && VarianceMeasure.CompareUtil.isNumber(data.rowGroupIndex)) {
651
+ row.rowGroup = data.rowGroup;
652
+ row.rowGroupIndex = data.rowGroupIndex;
653
+ }
654
+ if (VarianceMeasure.CompareUtil.isString(data.category) && VarianceMeasure.CompareUtil.isNumber(data.categoryIndex)) {
655
+ row.category = data.category;
656
+ row.categoryIndex = data.categoryIndex;
657
+ }
658
+ if (VarianceMeasure.CompareUtil.isString(data.subCategory) && VarianceMeasure.CompareUtil.isNumber(data.subCategoryIndex)) {
659
+ row.subCategory = data.subCategory;
660
+ row.subCategoryIndex = data.subCategoryIndex;
661
+ }
662
+ if (VarianceMeasure.CompareUtil.isString(data.columnGroup) && VarianceMeasure.CompareUtil.isNumber(data.columnGroupIndex)) {
663
+ row.columnGroup = data.columnGroup;
664
+ row.columnGroupIndex = data.columnGroupIndex;
665
+ }
666
+ if (VarianceMeasure.CompareUtil.isString(data.columnSubGroup) && VarianceMeasure.CompareUtil.isNumber(data.columnSubGroupIndex)) {
667
+ row.columnSubGroup = data.columnSubGroup;
668
+ row.columnSubGroupIndex = data.columnSubGroupIndex;
669
+ }
670
+ for (const slot of SCENARIO_SLOTS) {
671
+ if (VarianceMeasure.CompareUtil.isNumber(data[slot])) {
672
+ row[slot] = data[slot];
673
+ }
674
+ const cnt = data[`${slot}_cnt`];
675
+ if (VarianceMeasure.CompareUtil.isNumber(cnt)) {
676
+ row.counts[slot] = cnt;
677
+ }
678
+ }
679
+ for (const key of Object.keys(data)) {
680
+ if (key.startsWith("_")) {
681
+ row.custom[key] = data[key];
682
+ }
683
+ }
684
+ return row;
685
+ }
686
+ default() {
687
+ return new XYChartDataRow();
688
+ }
689
+ }
690
+ /** Points above this budget raise the `xy-point-budget` warning (spec §10). */
691
+ const XY_POINT_BUDGET = 5000;
692
+ const INDEX_FIELD = {
693
+ rowGroup: "rowGroupIndex",
694
+ category: "categoryIndex",
695
+ subCategory: "subCategoryIndex",
696
+ };
697
+ function evaluateMeasure(row, ref) {
698
+ if (ref.kind === "scenario") {
699
+ return { value: row.slotValue(ref.slot), varianceNoData: false };
700
+ }
701
+ if (row.slotHasNoData(ref.measure.base) || row.slotHasNoData(ref.measure.delta)) {
702
+ return { value: null, varianceNoData: true };
703
+ }
704
+ const value = ref.measure.compute(row.slotValue(ref.measure.base), row.slotValue(ref.measure.delta));
705
+ return { value, varianceNoData: value === null };
706
+ }
707
+ function outsideDomain(value, domain) {
708
+ if (domain === undefined) {
709
+ return false;
710
+ }
711
+ if (domain.min !== undefined && value < domain.min) {
712
+ return true;
713
+ }
714
+ if (domain.max !== undefined && value > domain.max) {
715
+ return true;
716
+ }
717
+ return false;
718
+ }
719
+ function compareSlot(ref, family) {
720
+ if (ref.kind !== "scenario") {
721
+ return null;
722
+ }
723
+ return family + VarianceMeasure.scenarioSlotNumber(ref.slot);
724
+ }
725
+ /**
726
+ * Resolves adapted rows into facets, series, and renderable points —
727
+ * the shared data pipeline of both XY orchestrators.
728
+ *
729
+ * One row = one point. Duplicate identities (same facet + point name) keep
730
+ * the first row (deterministic) and raise `xy-duplicate-point`. There is no
731
+ * implicit aggregation — axes are frequently ratios where SUM is wrong; the
732
+ * DataSet SQL is the aggregation surface.
733
+ */
734
+ function resolveXYData(rows, opts) {
735
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
736
+ const warnings = [];
737
+ const seenKeys = new Set();
738
+ const duplicateNames = [];
739
+ let duplicateCount = 0;
740
+ let varianceNoDataCount = 0;
741
+ let clippedCount = 0;
742
+ let sizeNegativeCount = 0;
743
+ let shareClampCount = 0;
744
+ const facetOrder = new Map();
745
+ const seriesOrder = new Map();
746
+ const facetPoints = new Map();
747
+ const compareFamily = (_a = opts.compareFamily) !== null && _a !== void 0 ? _a : null;
748
+ const compareX = compareFamily !== null ? compareSlot(opts.measures.x, compareFamily) : null;
749
+ const compareY = compareFamily !== null ? compareSlot(opts.measures.y, compareFamily) : null;
750
+ const compareSize = compareFamily !== null && opts.measures.size !== undefined ? compareSlot(opts.measures.size, compareFamily) : null;
751
+ for (const row of rows) {
752
+ const name = row[opts.pointLevel];
753
+ if (name == null || name === "") {
754
+ continue;
755
+ }
756
+ const facetKey = (_b = (opts.facetLevel !== null ? row[opts.facetLevel] : "")) !== null && _b !== void 0 ? _b : "";
757
+ const seriesKey = (_c = (opts.seriesLevel !== null ? row[opts.seriesLevel] : "")) !== null && _c !== void 0 ? _c : "";
758
+ const identity = `${facetKey}${name}`;
759
+ if (seenKeys.has(identity)) {
760
+ duplicateCount++;
761
+ if (duplicateNames.length < 5 && !duplicateNames.includes(name)) {
762
+ duplicateNames.push(name);
763
+ }
764
+ continue;
765
+ }
766
+ const xEval = evaluateMeasure(row, opts.measures.x);
767
+ const yEval = evaluateMeasure(row, opts.measures.y);
768
+ if (xEval.value === null || yEval.value === null) {
769
+ if (xEval.varianceNoData || yEval.varianceNoData) {
770
+ varianceNoDataCount++;
771
+ }
772
+ continue;
773
+ }
774
+ if (outsideDomain(xEval.value, (_d = opts.domains) === null || _d === void 0 ? void 0 : _d.x) || outsideDomain(yEval.value, (_e = opts.domains) === null || _e === void 0 ? void 0 : _e.y)) {
775
+ clippedCount++;
776
+ continue;
777
+ }
778
+ const point = {
779
+ name,
780
+ seriesKey,
781
+ facetKey,
782
+ x: xEval.value,
783
+ y: yEval.value,
784
+ row,
785
+ };
786
+ if (opts.measures.size !== undefined) {
787
+ const sizeValue = evaluateMeasure(row, opts.measures.size).value;
788
+ if (sizeValue === null) {
789
+ continue;
790
+ }
791
+ if (sizeValue < 0) {
792
+ sizeNegativeCount++;
793
+ continue;
794
+ }
795
+ point.size = sizeValue;
796
+ }
797
+ if (opts.measures.share !== undefined) {
798
+ const shareValue = evaluateMeasure(row, opts.measures.share).value;
799
+ if (shareValue !== null) {
800
+ if (shareValue < 0 || shareValue > 1) {
801
+ shareClampCount++;
802
+ point.share = Math.min(1, Math.max(0, shareValue));
803
+ }
804
+ else {
805
+ point.share = shareValue;
806
+ }
807
+ }
808
+ }
809
+ if (compareX !== null && compareY !== null) {
810
+ const cx = row.slotValue(compareX);
811
+ const cy = row.slotValue(compareY);
812
+ const cSize = compareSize !== null ? row.slotValue(compareSize) : null;
813
+ const sizeMissing = compareSize !== null && cSize === null;
814
+ if (cx !== null && cy !== null && !sizeMissing) {
815
+ if (outsideDomain(cx, (_f = opts.domains) === null || _f === void 0 ? void 0 : _f.x) || outsideDomain(cy, (_g = opts.domains) === null || _g === void 0 ? void 0 : _g.y)) {
816
+ clippedCount++;
817
+ point.compare = null;
818
+ }
819
+ else {
820
+ point.compare = { x: cx, y: cy };
821
+ if (cSize !== null) {
822
+ point.compare.size = cSize;
823
+ }
824
+ }
825
+ }
826
+ else {
827
+ point.compare = null;
828
+ }
829
+ }
830
+ seenKeys.add(identity);
831
+ if (!facetPoints.has(facetKey)) {
832
+ facetPoints.set(facetKey, []);
833
+ }
834
+ facetPoints.get(facetKey).push(point);
835
+ if (opts.facetLevel !== null) {
836
+ const facetIndex = row[INDEX_FIELD[opts.facetLevel]];
837
+ if (facetIndex != null && facetIndex < ((_h = facetOrder.get(facetKey)) !== null && _h !== void 0 ? _h : Number.POSITIVE_INFINITY)) {
838
+ facetOrder.set(facetKey, facetIndex);
839
+ }
840
+ }
841
+ if (opts.seriesLevel !== null) {
842
+ const seriesIndex = row[INDEX_FIELD[opts.seriesLevel]];
843
+ if (seriesIndex != null && seriesIndex < ((_j = seriesOrder.get(seriesKey)) !== null && _j !== void 0 ? _j : Number.POSITIVE_INFINITY)) {
844
+ seriesOrder.set(seriesKey, seriesIndex);
845
+ }
846
+ }
847
+ }
848
+ const facetKeys = [...facetPoints.keys()].sort((a, b) => { var _a, _b; return ((_a = facetOrder.get(a)) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER) - ((_b = facetOrder.get(b)) !== null && _b !== void 0 ? _b : Number.MAX_SAFE_INTEGER); });
849
+ const facets = facetKeys.map((key) => {
850
+ let points = facetPoints.get(key);
851
+ if (opts.limit > 0 && points.length > opts.limit) {
852
+ if (opts.limitBy === "size") {
853
+ points = [...points].sort((a, b) => { var _a, _b; return ((_a = b.size) !== null && _a !== void 0 ? _a : 0) - ((_b = a.size) !== null && _b !== void 0 ? _b : 0); }).slice(0, opts.limit);
854
+ }
855
+ else {
856
+ points = points.slice(0, opts.limit);
857
+ }
858
+ }
859
+ return { key, points };
860
+ });
861
+ const seriesKeys = new Set();
862
+ for (const facet of facets) {
863
+ for (const point of facet.points) {
864
+ seriesKeys.add(point.seriesKey);
865
+ }
866
+ }
867
+ const series = [...seriesKeys]
868
+ .sort((a, b) => { var _a, _b; return ((_a = seriesOrder.get(a)) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER) - ((_b = seriesOrder.get(b)) !== null && _b !== void 0 ? _b : Number.MAX_SAFE_INTEGER); })
869
+ .map((key, index) => ({ key, index }));
870
+ let extents = null;
871
+ let totalPoints = 0;
872
+ for (const facet of facets) {
873
+ for (const point of facet.points) {
874
+ totalPoints++;
875
+ const xs = [point.x];
876
+ const ys = [point.y];
877
+ const sizes = point.size !== undefined ? [point.size] : [];
878
+ if (point.compare != null) {
879
+ xs.push(point.compare.x);
880
+ ys.push(point.compare.y);
881
+ if (point.compare.size !== undefined) {
882
+ sizes.push(point.compare.size);
883
+ }
884
+ }
885
+ if (extents === null) {
886
+ extents = { xMin: xs[0], xMax: xs[0], yMin: ys[0], yMax: ys[0], sizeMax: 0 };
887
+ }
888
+ for (const x of xs) {
889
+ extents.xMin = Math.min(extents.xMin, x);
890
+ extents.xMax = Math.max(extents.xMax, x);
891
+ }
892
+ for (const y of ys) {
893
+ extents.yMin = Math.min(extents.yMin, y);
894
+ extents.yMax = Math.max(extents.yMax, y);
895
+ }
896
+ for (const size of sizes) {
897
+ extents.sizeMax = Math.max(extents.sizeMax, size);
898
+ }
899
+ }
900
+ }
901
+ if (duplicateCount > 0) {
902
+ warnings.push({
903
+ code: "xy-duplicate-point",
904
+ data: { count: String(duplicateCount), names: duplicateNames.join(", ") },
905
+ });
906
+ }
907
+ if (varianceNoDataCount > 0) {
908
+ warnings.push({ code: "xy-variance-nodata", data: { count: String(varianceNoDataCount) } });
909
+ }
910
+ if (clippedCount > 0) {
911
+ warnings.push({ code: "xy-point-clipped", data: { count: String(clippedCount) } });
912
+ }
913
+ if (sizeNegativeCount > 0) {
914
+ warnings.push({ code: "bubble-size-negative", data: { count: String(sizeNegativeCount) } });
915
+ }
916
+ if (shareClampCount > 0) {
917
+ warnings.push({ code: "bubble-share-range", data: { count: String(shareClampCount) } });
918
+ }
919
+ if (totalPoints > XY_POINT_BUDGET) {
920
+ warnings.push({ code: "xy-point-budget", data: { count: String(totalPoints) } });
921
+ }
922
+ return { facets, series, extents, warnings, totalPoints };
923
+ }
924
+
925
+ exports.FacetGrid = FacetGrid;
926
+ exports.NumericScale = NumericScale;
927
+ exports.PointLabeler = PointLabeler;
928
+ exports.ScaleFactorsXYChartAdapter = ScaleFactorsXYChartAdapter;
929
+ exports.XYChartDataRowAdapter = XYChartDataRowAdapter;
930
+ exports.XYChartStylesAdapter = XYChartStylesAdapter;
931
+ exports.XYFrame = XYFrame;
932
+ exports.XYLegend = XYLegend;
933
+ exports.resolveXYData = resolveXYData;