@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,620 @@
1
+ import { r as registerInstance, h, H as Host, g as getElement } from './index-B_d-jp99.js';
2
+ import { r as resolveSeriesColor, m as markTreatment, s as shade, g as getStores, b as buildFromExpr } from './context-protocol-BNHTlllP.js';
3
+ import { C as CalculateSize, S as Svg, F as Formatter, g as getContrastTextColor, I as IBCSRuleSet, a as FontStyleAdapter, b as SVGStyleGroupAdapter, c as SVGStyleAdapter, P as PaddingAdapter } from './LabelCollisionManager-DZP5Vl8T.js';
4
+ import { X as XYChartDataRowAdapter, r as resolveXYData, a as XYLegend, N as NumericScale, b as XYFrame, P as PointLabeler, F as FacetGrid, c as XYChartStylesAdapter, S as ScaleFactorsXYChartAdapter } from './XYChartDataRow-FF_VxRnF.js';
5
+ import { r as resolveMeasure } from './VarianceMeasure-Cxshx01h.js';
6
+
7
+ /**
8
+ * Area-true bubble sizing: bubble **area** is proportional to the data
9
+ * value (IBCS), so radius grows with the square root.
10
+ *
11
+ * Two modes:
12
+ * - **Local** (default): radii are normalized to the chart's own maximum
13
+ * value — `r = rMax · √(v / vMax)` with a minimum visible radius.
14
+ * `vMax` must be the max across all panels and both scenario sets of the
15
+ * chart instance (shared size scale, mandatory for comparability).
16
+ * - **Grouped** (`bn-scaling-group`): the group value is interpreted as
17
+ * **area px² per data unit** — `r = √(area · v / π)` with no
18
+ * normalization and no radius caps, so identical values render at
19
+ * identical sizes across every chart referencing the group.
20
+ */
21
+ class RadiusScale {
22
+ constructor(mode, vMax, rMaxPx, rMinPx, areaPerUnitPx2) {
23
+ this.mode = mode;
24
+ this.vMax = vMax;
25
+ this.rMaxPx = rMaxPx;
26
+ this.rMinPx = rMinPx;
27
+ this.areaPerUnitPx2 = areaPerUnitPx2;
28
+ }
29
+ static local(vMax, rMaxPx, rMinPx) {
30
+ return new RadiusScale("local", vMax, rMaxPx, rMinPx, 0);
31
+ }
32
+ static grouped(areaPerUnitPx2) {
33
+ return new RadiusScale("grouped", 0, 0, 0, areaPerUnitPx2);
34
+ }
35
+ /** Radius in pixels for a size value (values must be >= 0). */
36
+ radius(value) {
37
+ if (this.mode === "grouped") {
38
+ if (value <= 0) {
39
+ return 0;
40
+ }
41
+ return Math.sqrt((this.areaPerUnitPx2 * value) / Math.PI);
42
+ }
43
+ if (this.vMax <= 0 || value <= 0) {
44
+ return this.rMinPx;
45
+ }
46
+ return Math.max(this.rMinPx, this.rMaxPx * Math.sqrt(value / this.vMax));
47
+ }
48
+ }
49
+
50
+ /**
51
+ * SVG orchestrator for `bn-chart-bubble` (IBCS template C10).
52
+ *
53
+ * Bubble **area** is proportional to the size measure. Marks compose the
54
+ * series hue with the scenario treatment from the rule set; an optional
55
+ * comparison scenario renders behind the primary set (10D), `share` draws
56
+ * a pie sector from 12 o'clock (10E). The SVG is built on a detached
57
+ * `Svg` root and emitted via `toString()`.
58
+ */
59
+ class BubbleChart {
60
+ constructor(ruleSet, db, fromExpr, config, styles, availableWidth) {
61
+ var _a, _b, _c, _d;
62
+ this.ruleSet = ruleSet;
63
+ this.config = config;
64
+ this.styles = styles;
65
+ this.availableWidth = availableWidth;
66
+ this.warnings = [];
67
+ this.canvasHeight = 0;
68
+ this.i18nMap = new Map();
69
+ this.hatchPatterns = new Set();
70
+ this.scaleOverflowCount = 0;
71
+ this.svgRoot = null;
72
+ const adapter = new XYChartDataRowAdapter();
73
+ const rawRows = fromExpr !== "" ? db.exec(`SELECT * FROM ${fromExpr}`) : [];
74
+ const rows = (rawRows !== null && rawRows !== void 0 ? rawRows : []).map((row) => adapter.adapt(row));
75
+ this.data = resolveXYData(rows, {
76
+ pointLevel: config.pointLevel,
77
+ seriesLevel: config.seriesLevel,
78
+ facetLevel: config.facet !== null ? (config.facet.level === "rowgroup" ? "rowGroup" : "category") : null,
79
+ measures: {
80
+ x: (_a = resolveMeasure(config.x.measure)) !== null && _a !== void 0 ? _a : { kind: "scenario", slot: "ac1" },
81
+ y: (_b = resolveMeasure(config.y.measure)) !== null && _b !== void 0 ? _b : { kind: "scenario", slot: "ac2" },
82
+ size: (_c = resolveMeasure(config.size.measure)) !== null && _c !== void 0 ? _c : { kind: "scenario", slot: "ac3" },
83
+ share: config.share !== null ? ((_d = resolveMeasure(config.share.measure)) !== null && _d !== void 0 ? _d : undefined) : undefined,
84
+ },
85
+ compareFamily: config.compareFamily,
86
+ domains: {
87
+ x: { min: config.x.min, max: config.x.max },
88
+ y: { min: config.y.min, max: config.y.max },
89
+ },
90
+ limit: config.limit,
91
+ limitBy: "size",
92
+ });
93
+ this.warnings.push(...this.data.warnings);
94
+ }
95
+ get em() {
96
+ return this.styles.fontStyles.size;
97
+ }
98
+ fontFamily() {
99
+ return this.styles.fontStyles.font.replace(/^[\d.]+px\s*/, "");
100
+ }
101
+ textWidth(text, bold = false) {
102
+ const width = CalculateSize(text, {
103
+ font: this.styles.fontStyles.font,
104
+ fontSize: this.styles.fontStyles.size + "px",
105
+ fontWeight: bold ? "bold" : "normal",
106
+ }).width;
107
+ // calculate-size needs a live DOM; fall back to an estimate in test environments.
108
+ return Number.isFinite(width) && width > 0 ? width : text.length * 0.6 * this.em;
109
+ }
110
+ drawText(group, text, x, y, options = {}) {
111
+ var _a, _b;
112
+ group
113
+ .text(text)
114
+ .font({
115
+ size: this.styles.fontStyles.size,
116
+ weight: options.bold ? "bold" : "normal",
117
+ anchor: (_a = options.anchor) !== null && _a !== void 0 ? _a : "start",
118
+ })
119
+ .fill((_b = options.color) !== null && _b !== void 0 ? _b : this.styles.fontStyles.color)
120
+ .attr({ x, y, "font-family": this.fontFamily() });
121
+ }
122
+ hasNoData() {
123
+ return this.data.totalPoints === 0;
124
+ }
125
+ /** Warnings collected during data resolution and drawing (§8 codes). */
126
+ getWarnings() {
127
+ return this.warnings;
128
+ }
129
+ getAllocatedCanvasWidth() {
130
+ return this.availableWidth;
131
+ }
132
+ getAllocatedCanvasHeight() {
133
+ return this.canvasHeight;
134
+ }
135
+ setI18n(i18n) {
136
+ this.i18nMap = i18n;
137
+ }
138
+ addWarningOnce(code, data) {
139
+ if (!this.warnings.some((w) => w.code === code)) {
140
+ this.warnings.push({ code, data });
141
+ }
142
+ }
143
+ /** ColorIndex of the primary scenario family (variance axes → 10). */
144
+ primaryColorIndex() {
145
+ const ref = resolveMeasure(this.config.size.measure);
146
+ if (ref === null || ref.kind === "variance") {
147
+ return 10;
148
+ }
149
+ return this.ruleSet.getScenarioColorIndex(ref.slot);
150
+ }
151
+ compareColorIndex() {
152
+ return this.ruleSet.getScenarioColorIndex(`${this.config.compareFamily}1`);
153
+ }
154
+ seriesHue(seriesIndex) {
155
+ const { color, overflowed } = resolveSeriesColor(seriesIndex, this.styles.seriesColors);
156
+ if (overflowed) {
157
+ this.addWarningOnce("xy-series-overflow", {});
158
+ }
159
+ return color;
160
+ }
161
+ /** Scenario display name of a family (e.g. "PY"), from the merged rule set. */
162
+ familyDisplayName(family) {
163
+ return this.ruleSet.getScenario(`${family}1`).group;
164
+ }
165
+ legendModel() {
166
+ var _a, _b;
167
+ const sizeCaption = [];
168
+ const sizeLabel = (_b = (_a = this.config.size.label) !== null && _a !== void 0 ? _a : this.i18nMap.get("legend.size")) !== null && _b !== void 0 ? _b : "";
169
+ if (sizeLabel !== "") {
170
+ sizeCaption.push(sizeLabel);
171
+ if (this.config.size.unit !== undefined && this.config.size.unit !== "") {
172
+ sizeCaption.push(`${this.i18nMap.get("axis.in") || "in"} ${this.config.size.unit}`);
173
+ }
174
+ }
175
+ const firstHue = this.seriesHue(0);
176
+ const compareEntries = [];
177
+ if (this.config.compareFamily !== null) {
178
+ const primaryRef = resolveMeasure(this.config.size.measure);
179
+ const primaryFamily = primaryRef !== null && primaryRef.kind === "scenario" ? primaryRef.slot.replace(/\d+$/, "") : "ac";
180
+ compareEntries.push({
181
+ label: this.familyDisplayName(this.config.compareFamily),
182
+ treatment: markTreatment(this.compareColorIndex(), firstHue, "bubble"),
183
+ });
184
+ compareEntries.push({
185
+ label: this.familyDisplayName(primaryFamily),
186
+ treatment: markTreatment(this.primaryColorIndex(), firstHue, "bubble"),
187
+ });
188
+ }
189
+ const entries = this.data.series.map((series) => {
190
+ var _a;
191
+ return ({
192
+ label: series.key === "" ? ((_a = this.ruleSet.getScenario("").name) !== null && _a !== void 0 ? _a : "Series") : series.key,
193
+ treatment: markTreatment(this.primaryColorIndex(), this.seriesHue(series.index), "bubble"),
194
+ });
195
+ });
196
+ return {
197
+ sizeCaption,
198
+ title: this.i18nMap.get("legend.title") || null,
199
+ compareEntries,
200
+ entries,
201
+ };
202
+ }
203
+ toString() {
204
+ const container = new Svg();
205
+ this.draw(container);
206
+ container.id("drawCanvas");
207
+ container.width(this.getAllocatedCanvasWidth());
208
+ container.height(this.getAllocatedCanvasHeight());
209
+ container.attr("overflow", "visible");
210
+ return container.svg();
211
+ }
212
+ /** Axis title in the IBCS "Label in Unit" form. */
213
+ axisTitle(axis, inWord) {
214
+ var _a;
215
+ const label = (_a = axis.label) !== null && _a !== void 0 ? _a : "";
216
+ if (label === "") {
217
+ return "";
218
+ }
219
+ if (axis.unit === undefined || axis.unit === "") {
220
+ return label;
221
+ }
222
+ return `${label} ${inWord} ${axis.unit}`;
223
+ }
224
+ draw(container) {
225
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
226
+ this.warnings = this.data.warnings.slice();
227
+ this.hatchPatterns.clear();
228
+ this.scaleOverflowCount = 0;
229
+ this.svgRoot = container;
230
+ const em = this.em;
231
+ const padding = this.styles.padding;
232
+ const inWord = this.i18nMap.get("axis.in") || "in";
233
+ const root = container.group();
234
+ const legend = new XYLegend(this.styles);
235
+ const legendModel = this.legendModel();
236
+ const showLegend = this.config.legend.show && (legendModel.entries.length > 0 || legendModel.sizeCaption.length > 0);
237
+ const legendSize = showLegend ? legend.measure(legendModel, this.config.legend.position) : { width: 0, height: 0 };
238
+ const rightReserve = this.config.legend.position === "right" && showLegend ? legendSize.width + em : 0;
239
+ const titleH = this.config.chartTitle !== "" ? 1.6 * em : 0;
240
+ const yTitleText = this.axisTitle(this.config.y, inWord);
241
+ const xTitleText = this.axisTitle(this.config.x, inWord);
242
+ const yTitleH = yTitleText !== "" ? 1.4 * em : 0.4 * em;
243
+ const xAxisH = 1.4 * em + (xTitleText !== "" ? 1.3 * em : 0);
244
+ let axisLeftW = 3 * em;
245
+ let drawing = { x: 0, y: 0, width: 0, height: 0 };
246
+ let grid;
247
+ let ticksY = [];
248
+ const facetCount = Math.max(1, this.data.facets.length);
249
+ const columns = (_a = this.config.facet) === null || _a === void 0 ? void 0 : _a.columns;
250
+ const xDomain = NumericScale.domain((_c = (_b = this.data.extents) === null || _b === void 0 ? void 0 : _b.xMin) !== null && _c !== void 0 ? _c : 0, (_e = (_d = this.data.extents) === null || _d === void 0 ? void 0 : _d.xMax) !== null && _e !== void 0 ? _e : 1, {
251
+ min: this.config.x.min,
252
+ max: this.config.x.max,
253
+ });
254
+ const yDomain = NumericScale.domain((_g = (_f = this.data.extents) === null || _f === void 0 ? void 0 : _f.yMin) !== null && _g !== void 0 ? _g : 0, (_j = (_h = this.data.extents) === null || _h === void 0 ? void 0 : _h.yMax) !== null && _j !== void 0 ? _j : 1, {
255
+ min: this.config.y.min,
256
+ max: this.config.y.max,
257
+ });
258
+ for (let pass = 0; pass < 2; pass++) {
259
+ const drawingW = Math.max(10, this.availableWidth - padding.left - padding.right - axisLeftW - rightReserve);
260
+ const drawingH = drawingW / this.config.aspect;
261
+ drawing = {
262
+ x: padding.left + axisLeftW,
263
+ y: padding.top + titleH + yTitleH,
264
+ width: drawingW,
265
+ height: drawingH,
266
+ };
267
+ grid = new FacetGrid(facetCount, columns, drawing, this.styles.scaleFactors.panelGap * em);
268
+ const panelH = grid.panelRect(0).height;
269
+ const targetY = Math.max(4, Math.min(8, Math.round(panelH / (4 * em))));
270
+ const yScale = new NumericScale(yDomain[0], yDomain[1], panelH, 0);
271
+ ticksY = yScale.ticks(targetY);
272
+ const yDecimals = NumericScale.tickDecimals(ticksY);
273
+ const maxTickW = Math.max(...ticksY.map((tick) => this.textWidth(this.formatTick(tick, yDecimals))), em);
274
+ axisLeftW = maxTickW + this.styles.scaleFactors.axisTickLength * em + 0.4 * em;
275
+ }
276
+ this.canvasHeight =
277
+ drawing.y +
278
+ drawing.height +
279
+ xAxisH +
280
+ (this.config.legend.position === "bottom" && showLegend ? legendSize.height + em : 0) +
281
+ padding.bottom;
282
+ if (this.config.chartTitle !== "") {
283
+ this.drawText(root, this.config.chartTitle, padding.left, padding.top + em, { bold: true });
284
+ }
285
+ if (yTitleText !== "") {
286
+ this.drawAxisTitleText(root, this.config.y, inWord, padding.left, drawing.y - 0.6 * em, "start");
287
+ }
288
+ const panels = this.buildPanels(grid, xDomain, yDomain);
289
+ const ticksX = panels[0].xScale.ticks(Math.max(3, Math.min(8, Math.round(panels[0].rect.width / (7 * em)))));
290
+ const xDecimals = NumericScale.tickDecimals(ticksX);
291
+ const yDecimals = NumericScale.tickDecimals(ticksY);
292
+ const radiusScale = this.config.sizeAreaPerUnit > 0
293
+ ? RadiusScale.grouped(this.config.sizeAreaPerUnit)
294
+ : RadiusScale.local((_l = (_k = this.data.extents) === null || _k === void 0 ? void 0 : _k.sizeMax) !== null && _l !== void 0 ? _l : 0, this.styles.scaleFactors.bubbleMaxRadius * em, this.styles.scaleFactors.bubbleMinRadius * em);
295
+ if (this.data.facets.length === 0) {
296
+ this.drawPanel(root, panels[0], { key: "", points: [] }, radiusScale, ticksX, ticksY, xDecimals, yDecimals, true, true);
297
+ }
298
+ else {
299
+ this.data.facets.forEach((facet, index) => {
300
+ this.drawPanel(root, panels[index], facet, radiusScale, ticksX, ticksY, xDecimals, yDecimals, grid.isOuterLeft(index), grid.isOuterBottom(index), this.data.facets.length > 1 ? facet.key : "");
301
+ });
302
+ }
303
+ if (xTitleText !== "") {
304
+ this.drawAxisTitleText(root, this.config.x, inWord, drawing.x + drawing.width, drawing.y + drawing.height + 2.6 * em, "end");
305
+ }
306
+ if (showLegend) {
307
+ if (this.config.legend.position === "right") {
308
+ legend.draw(root, legendModel, drawing.x + drawing.width + em, drawing.y, "right");
309
+ }
310
+ else {
311
+ legend.draw(root, legendModel, drawing.x, drawing.y + drawing.height + xAxisH, "bottom");
312
+ }
313
+ }
314
+ if (this.scaleOverflowCount > 0) {
315
+ this.addWarningOnce("bubble-scale-overflow", { count: String(this.scaleOverflowCount) });
316
+ }
317
+ // Stable, empty hook for a future annotation layer (spec §12).
318
+ container.group().addClass("annotations");
319
+ }
320
+ /** Axis title with the label bold and the "in Unit" part regular. */
321
+ drawAxisTitleText(group, axis, inWord, x, y, anchor) {
322
+ var _a;
323
+ const label = (_a = axis.label) !== null && _a !== void 0 ? _a : "";
324
+ const suffix = axis.unit !== undefined && axis.unit !== "" ? `${inWord} ${axis.unit}` : "";
325
+ // SVG collapses leading whitespace in text nodes — position the suffix
326
+ // with an explicit gap instead.
327
+ const gap = 0.3 * this.em;
328
+ if (anchor === "start") {
329
+ this.drawText(group, label, x, y, { bold: true });
330
+ if (suffix !== "") {
331
+ this.drawText(group, suffix, x + this.textWidth(label, true) + gap, y, {});
332
+ }
333
+ }
334
+ else if (suffix !== "") {
335
+ this.drawText(group, suffix, x, y, { anchor: "end" });
336
+ this.drawText(group, label, x - this.textWidth(suffix) - gap, y, { anchor: "end", bold: true });
337
+ }
338
+ else {
339
+ this.drawText(group, label, x, y, { anchor: "end", bold: true });
340
+ }
341
+ }
342
+ buildPanels(grid, xDomain, yDomain) {
343
+ const panels = [];
344
+ for (let i = 0; i < grid.count; i++) {
345
+ const rect = grid.panelRect(i);
346
+ const xScale = new NumericScale(xDomain[0], xDomain[1], rect.x, rect.x + rect.width);
347
+ const yScale = new NumericScale(yDomain[0], yDomain[1], rect.y + rect.height, rect.y);
348
+ panels.push({ rect, xScale, yScale, frame: new XYFrame(xScale, yScale, rect, this.styles) });
349
+ }
350
+ return panels;
351
+ }
352
+ /** Fill value for a treatment; FC bubbles fill with a per-series hatch pattern. */
353
+ treatmentFill(treatment, seriesIndex, hue) {
354
+ if (treatment.hatch !== true) {
355
+ return treatment.fill;
356
+ }
357
+ this.ensureHatchPattern(seriesIndex, hue);
358
+ return `url(#xy-fc-${seriesIndex})`;
359
+ }
360
+ /** 45° series-hue hatch tile in the chart's own defs (shadow DOM scopes the id). */
361
+ ensureHatchPattern(seriesIndex, hue) {
362
+ if (this.hatchPatterns.has(seriesIndex) || this.svgRoot === null) {
363
+ return;
364
+ }
365
+ this.hatchPatterns.add(seriesIndex);
366
+ const defs = this.svgRoot.defs();
367
+ defs
368
+ .pattern(10, 10, (add) => {
369
+ add.rect(10, 10).fill("#ffffff");
370
+ add.line(0, 10, 10, 0).stroke({ color: hue, width: 2 });
371
+ add.line(-2.5, 2.5, 2.5, -2.5).stroke({ color: hue, width: 2 });
372
+ add.line(7.5, 12.5, 12.5, 7.5).stroke({ color: hue, width: 2 });
373
+ })
374
+ .id(`xy-fc-${seriesIndex}`);
375
+ }
376
+ drawPanel(root, panel, facet, radiusScale, ticksX, ticksY, xDecimals, yDecimals, isOuterLeft, isOuterBottom, panelTitle = "") {
377
+ var _a, _b, _c, _d;
378
+ const group = root.group();
379
+ const em = this.em;
380
+ panel.frame.drawBands(group, this.config.x.highlight, this.config.y.highlight);
381
+ const hasRefLines = this.config.x.refLine !== undefined || this.config.y.refLine !== undefined;
382
+ const wide = panel.rect.width > 30 * em;
383
+ panel.frame.drawGrid(group, ticksY, !hasRefLines && wide ? ticksX : undefined);
384
+ panel.frame.drawRefLines(group, this.config.x.refLine, this.config.y.refLine);
385
+ panel.frame.drawFrame(group);
386
+ // Comparison set renders in its own group BEHIND the primary set (10D) —
387
+ // the z-order is structural, independent of rule-set sort indices.
388
+ const compareGroup = group.group().id("compare");
389
+ const primaryGroup = group.group().id("primary");
390
+ const labeler = new PointLabeler(panel.rect, this.styles.scaleFactors.labelToMark * em);
391
+ // Draw order: descending size, so small bubbles stay visible on top.
392
+ const ordered = [...facet.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); });
393
+ const marks = [];
394
+ for (const point of ordered) {
395
+ const seriesIndex = (_b = (_a = this.data.series.find((s) => s.key === point.seriesKey)) === null || _a === void 0 ? void 0 : _a.index) !== null && _b !== void 0 ? _b : 0;
396
+ const hue = this.seriesHue(seriesIndex);
397
+ const treatment = markTreatment(this.primaryColorIndex(), hue, "bubble");
398
+ const cx = panel.xScale.scale(point.x);
399
+ const cy = panel.yScale.scale(point.y);
400
+ const r = radiusScale.radius((_c = point.size) !== null && _c !== void 0 ? _c : 0);
401
+ if (this.config.sizeAreaPerUnit > 0 && this.bubbleExceedsPanel(panel.rect, cx, cy, r)) {
402
+ this.scaleOverflowCount++;
403
+ }
404
+ if (point.compare != null) {
405
+ const compareTreatment = markTreatment(this.compareColorIndex(), hue, "bubble");
406
+ const ccx = panel.xScale.scale(point.compare.x);
407
+ const ccy = panel.yScale.scale(point.compare.y);
408
+ const cr = radiusScale.radius((_d = point.compare.size) !== null && _d !== void 0 ? _d : 0);
409
+ this.drawBubble(compareGroup, ccx, ccy, cr, compareTreatment, seriesIndex, hue);
410
+ labeler.registerMark(ccx, ccy, cr);
411
+ // Comparison bubbles carry a value label only when large enough — never a share slice.
412
+ if (this.config.labels.values && point.compare.size !== undefined && cr >= 1.2 * em) {
413
+ this.drawValueLabel(compareGroup, ccx, ccy, cr, point.compare.size, compareTreatment.fill);
414
+ }
415
+ }
416
+ this.drawBubble(primaryGroup, cx, cy, r, treatment, seriesIndex, hue);
417
+ labeler.registerMark(cx, cy, r);
418
+ if (point.share !== undefined && r > 0) {
419
+ this.drawShareSlice(primaryGroup, cx, cy, r, point.share, shade(hue));
420
+ }
421
+ if (this.config.labels.values && point.size !== undefined) {
422
+ this.drawValueLabel(primaryGroup, cx, cy, r, point.size, treatment.hatch === true ? "#ffffff" : treatment.fill);
423
+ }
424
+ marks.push({ point, cx, cy, r, seriesIndex, hue, treatment });
425
+ }
426
+ this.drawNameLabels(group, labeler, marks);
427
+ panel.frame.drawTickLabels(group, {
428
+ ticksX,
429
+ ticksY,
430
+ xDecimals,
431
+ yDecimals,
432
+ showXLabels: isOuterBottom,
433
+ showYLabels: isOuterLeft,
434
+ });
435
+ if (panelTitle !== "") {
436
+ panel.frame.drawPanelTitle(group, panelTitle);
437
+ }
438
+ }
439
+ bubbleExceedsPanel(rect, cx, cy, r) {
440
+ return cx - r < rect.x || cx + r > rect.x + rect.width || cy - r < rect.y || cy + r > rect.y + rect.height;
441
+ }
442
+ drawBubble(group, cx, cy, r, treatment, seriesIndex, hue) {
443
+ if (r <= 0) {
444
+ return;
445
+ }
446
+ group
447
+ .circle(r * 2)
448
+ .center(cx, cy)
449
+ .fill(this.treatmentFill(treatment, seriesIndex, hue))
450
+ .stroke({ color: treatment.stroke, width: treatment.strokeWidth });
451
+ }
452
+ /** Pie sector from 12 o'clock, clockwise, angle = share·360° (10E). */
453
+ drawShareSlice(group, cx, cy, r, share, fill) {
454
+ if (share <= 0) {
455
+ return;
456
+ }
457
+ if (share >= 1) {
458
+ group
459
+ .circle(r * 2)
460
+ .center(cx, cy)
461
+ .fill(fill);
462
+ return;
463
+ }
464
+ const angle = share * 2 * Math.PI;
465
+ const endX = cx + r * Math.sin(angle);
466
+ const endY = cy - r * Math.cos(angle);
467
+ const largeArc = angle > Math.PI ? 1 : 0;
468
+ group
469
+ .path(`M ${cx} ${cy} L ${cx} ${cy - r} A ${r} ${r} 0 ${largeArc} 1 ${endX} ${endY} Z`)
470
+ .fill(fill)
471
+ .stroke("none");
472
+ }
473
+ /** Value inside the bubble, contrast-colored; hidden when it doesn't fit. */
474
+ drawValueLabel(group, cx, cy, r, value, fill) {
475
+ const text = Formatter.number(value, "decimal", 1, 1);
476
+ const width = this.textWidth(text);
477
+ if (width + 0.4 * this.em > 2 * r) {
478
+ return;
479
+ }
480
+ this.drawText(group, text, cx, cy + 0.35 * this.em, {
481
+ anchor: "middle",
482
+ color: getContrastTextColor(fill.startsWith("#") ? fill : "#ffffff"),
483
+ });
484
+ }
485
+ /** Name labels — bubbles are few, named entities; labels prefer the spot above (10A). */
486
+ drawNameLabels(group, labeler, marks) {
487
+ // Rank by size descending: big bubbles claim their labels first.
488
+ const ranked = [...marks].sort((a, b) => { var _a, _b; return ((_a = b.point.size) !== null && _a !== void 0 ? _a : 0) - ((_b = a.point.size) !== null && _b !== void 0 ? _b : 0); });
489
+ const { selected, unknownNames } = labeler.selectCandidates(ranked, this.config.labels.points, this.config.labels.max, (mark) => mark.point.name);
490
+ if (unknownNames.length > 0) {
491
+ this.addWarningOnce("xy-label-unknown", { names: unknownNames.join(", ") });
492
+ }
493
+ const candidates = selected.map((mark) => ({
494
+ name: mark.point.name,
495
+ cx: mark.cx,
496
+ cy: mark.cy,
497
+ r: mark.r,
498
+ width: this.textWidth(mark.point.name),
499
+ height: 1.1 * this.em,
500
+ }));
501
+ for (const placed of labeler.place(candidates)) {
502
+ this.drawText(group, placed.candidate.name, placed.x, placed.y + 0.9 * placed.candidate.height, {});
503
+ }
504
+ }
505
+ formatTick(value, decimals) {
506
+ return Formatter.number(value, "decimal", decimals, decimals);
507
+ }
508
+ }
509
+
510
+ const ibcsChartBubbleCss = () => `:host{position:relative;display:inline-block}.warning{font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}`;
511
+
512
+ /** The §8 codes this chart can raise from data resolution / drawing. */
513
+ const BUBBLE_DATA_WARNING_CODES = [
514
+ "xy-duplicate-point",
515
+ "xy-point-clipped",
516
+ "xy-variance-nodata",
517
+ "xy-label-unknown",
518
+ "xy-series-overflow",
519
+ "xy-point-budget",
520
+ "bubble-size-negative",
521
+ "bubble-share-range",
522
+ "bubble-scale-overflow",
523
+ ];
524
+ const IbcsChartBubble = class {
525
+ constructor(hostRef) {
526
+ registerInstance(this, hostRef);
527
+ /** Name of the dataset (table or view in the scoped alasql database). */
528
+ this.tableName = "";
529
+ /** Bumped by the facade when the dataset changes; triggers re-render. */
530
+ this.dataVersion = 0;
531
+ this.chartTitle = "";
532
+ this.share = null;
533
+ /** Comparison scenario family, or `null` (10D overlay). */
534
+ this.compareFamily = null;
535
+ this.facet = null;
536
+ this.pointLevel = "category";
537
+ this.seriesLevel = null;
538
+ /** Plot aspect ratio, width/height. */
539
+ this.aspect = 16 / 9;
540
+ this.limit = 0;
541
+ this.filter = "";
542
+ /** Scaling-group mode: area px² per data unit (0 = local sizing). */
543
+ this.sizeAreaPerUnit = 0;
544
+ this.i18n = new Map();
545
+ this.containerWidth = 0;
546
+ this.svgMarkup = "";
547
+ }
548
+ getDb() {
549
+ if (!this.stores)
550
+ this.stores = getStores(this.element);
551
+ return this.stores.db.db;
552
+ }
553
+ componentWillLoad() {
554
+ this.rebuild();
555
+ }
556
+ componentWillUpdate() {
557
+ this.rebuild();
558
+ }
559
+ rebuild() {
560
+ const styles = this.prepareStyle();
561
+ const fromExpr = this.tableName ? buildFromExpr(this.tableName, this.filter) : "";
562
+ this.chart = new BubbleChart(new IBCSRuleSet(this.ruleSetConfig), this.getDb(), fromExpr, {
563
+ chartTitle: this.chartTitle,
564
+ x: this.x,
565
+ y: this.y,
566
+ size: this.size,
567
+ share: this.share,
568
+ compareFamily: this.compareFamily,
569
+ labels: this.labels,
570
+ legend: this.legend,
571
+ facet: this.facet,
572
+ pointLevel: this.pointLevel,
573
+ seriesLevel: this.seriesLevel,
574
+ aspect: this.aspect,
575
+ limit: this.limit,
576
+ sizeAreaPerUnit: this.sizeAreaPerUnit,
577
+ }, styles, this.containerWidth || 0);
578
+ this.chart.setI18n(this.i18n);
579
+ this.svgMarkup = this.chart.hasNoData() ? "" : this.chart.toString();
580
+ this.syncWarnings(this.chart.getWarnings());
581
+ }
582
+ /**
583
+ * Syncs the orchestrator's data warnings to the facade's dispatcher.
584
+ * Walks the full fixed code list so cleared warnings are removed again
585
+ * (addOrReplace/remove discipline, stable ids).
586
+ */
587
+ syncWarnings(warnings) {
588
+ if (this.errors === undefined) {
589
+ return;
590
+ }
591
+ const present = new Map(warnings.map((warning) => [warning.code, warning.data]));
592
+ for (const code of BUBBLE_DATA_WARNING_CODES) {
593
+ const id = `WARN_${code}`;
594
+ if (present.has(code)) {
595
+ const message = this.translate !== undefined ? this.translate(`.${code}`, present.get(code)) : code;
596
+ this.errors.addOrReplace({ id, type: "warning", message });
597
+ }
598
+ else {
599
+ this.errors.remove(id);
600
+ }
601
+ }
602
+ }
603
+ prepareStyle() {
604
+ return new XYChartStylesAdapter(new ScaleFactorsXYChartAdapter(), new FontStyleAdapter(), new SVGStyleGroupAdapter(new SVGStyleAdapter()), new PaddingAdapter()).adapt(this.styles);
605
+ }
606
+ render() {
607
+ if (this.chart === undefined) {
608
+ return h(Host, null);
609
+ }
610
+ if (this.chart.hasNoData()) {
611
+ const errorMsg = this.i18n.get("no-data") || "==No Data==";
612
+ return (h(Host, null, h("p", { class: "warning" }, errorMsg)));
613
+ }
614
+ return (h(Host, null, h("div", { innerHTML: this.svgMarkup })));
615
+ }
616
+ get element() { return getElement(this); }
617
+ };
618
+ IbcsChartBubble.style = ibcsChartBubbleCss();
619
+
620
+ export { IbcsChartBubble as ibcs_chart_bubble };