@bino-bi/bn-template-engine 1.0.0-next.26 → 1.0.0-next.28

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 (420) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-5075771a.entry.js +1 -0
  3. package/dist/bn-template-engine/p-5d516435.entry.js +1 -0
  4. package/dist/bn-template-engine/p-5e90e728.entry.js +1 -0
  5. package/dist/bn-template-engine/p-9ef7e132.entry.js +1 -0
  6. package/dist/bn-template-engine/{p-f06c3703.entry.js → p-9f7a1980.entry.js} +1 -1
  7. package/dist/bn-template-engine/p-BeXgxHkW.js +1 -0
  8. package/dist/bn-template-engine/p-CH0bpt_k.js +1 -0
  9. package/dist/bn-template-engine/p-ClruFZD_.js +1 -0
  10. package/dist/bn-template-engine/{p-CTrNbSXN.js → p-DFmSrSnf.js} +1 -1
  11. package/dist/bn-template-engine/{p-BcLsoDrW.js → p-DI3efDSV.js} +1 -1
  12. package/dist/bn-template-engine/p-DXLTTILG.js +1 -0
  13. package/dist/bn-template-engine/p-DtP4jqG5.js +1 -0
  14. package/dist/bn-template-engine/p-a8281b71.entry.js +1 -0
  15. package/dist/bn-template-engine/p-b31277e7.entry.js +1 -0
  16. package/dist/bn-template-engine/p-b396ac84.entry.js +1 -0
  17. package/dist/cjs/{bn-asset_21.cjs.entry.js → bn-asset_28.cjs.entry.js} +21358 -6528
  18. package/dist/cjs/bn-grid.cjs.entry.js +4 -6
  19. package/dist/cjs/bn-image.cjs.entry.js +3 -5
  20. package/dist/cjs/bn-internationalization.cjs.entry.js +17 -6
  21. package/dist/cjs/bn-ruleset.cjs.entry.js +5 -5
  22. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  23. package/dist/cjs/bn-template.cjs.entry.js +2 -2
  24. package/dist/cjs/bn-text.cjs.entry.js +115 -43
  25. package/dist/cjs/{context-protocol-DcTEh1rq.js → context-protocol-C0rKepqu.js} +108 -22
  26. package/dist/cjs/{diagnostics-CTgbq_Gc.js → diagnostics-Cq-qDtXq.js} +1 -1
  27. package/dist/cjs/editor-companion.cjs.entry.js +2 -2
  28. package/dist/cjs/loader.cjs.js +1 -1
  29. package/dist/cjs/queryError-BZjnIW_w.js +16 -0
  30. package/dist/cjs/{scaling-Dsb5_NXy.js → sanitizeHtml-Yx1xn6i_.js} +467 -287
  31. package/dist/cjs/{withBodyObserver-DJO98AJ-.js → withBodyObserver-CaPUjuC5.js} +1 -1
  32. package/dist/cjs/withHasError-qGW_yqIv.js +426 -0
  33. package/dist/cjs/{withStyled-D0jLwCib.js → withStyled-vSfogp9J.js} +543 -42
  34. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.css +37 -0
  35. package/dist/collection/components/bn-chart-bubble/bn-chart-bubble.js +53 -28
  36. package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.css +37 -5
  37. package/dist/collection/components/bn-chart-bubble/ibcs-chart-bubble.js +16 -7
  38. package/dist/collection/components/bn-chart-bubble/utils/BubbleChart.js +67 -30
  39. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.css +37 -0
  40. package/dist/collection/components/bn-chart-bullet/bn-chart-bullet.js +49 -29
  41. package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.css +37 -5
  42. package/dist/collection/components/bn-chart-bullet/ibcs-chart-bullet.js +17 -7
  43. package/dist/collection/components/bn-chart-bullet/utils/BulletChart.js +34 -18
  44. package/dist/collection/components/bn-chart-bullet/utils/model/BulletChartStyle.js +2 -0
  45. package/dist/collection/components/bn-chart-bullet/utils/model/BulletConfig.js +1 -1
  46. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.css +37 -0
  47. package/dist/collection/components/bn-chart-scatter/bn-chart-scatter.js +52 -27
  48. package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.css +37 -5
  49. package/dist/collection/components/bn-chart-scatter/ibcs-chart-scatter.js +16 -7
  50. package/dist/collection/components/bn-chart-scatter/utils/ScatterChart.js +52 -18
  51. package/dist/collection/components/bn-chart-structure/bn-chart-structure.css +37 -5
  52. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +74 -44
  53. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +60 -19
  54. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +218 -262
  55. package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +1 -1
  56. package/dist/collection/components/bn-chart-structure/utils/elements/Needle.js +11 -4
  57. package/dist/collection/components/bn-chart-structure/utils/elements/StackedBar.js +16 -25
  58. package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +3 -2
  59. package/dist/collection/components/bn-chart-structure/utils/model/styles/StructureChartStyle.js +2 -0
  60. package/dist/collection/components/bn-chart-time/bn-chart-time.css +37 -0
  61. package/dist/collection/components/bn-chart-time/bn-chart-time.js +122 -52
  62. package/dist/collection/components/bn-chart-time/ibcs-chart-time.css +37 -0
  63. package/dist/collection/components/bn-chart-time/ibcs-chart-time.js +60 -19
  64. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +245 -250
  65. package/dist/collection/components/bn-chart-time/utils/elements/AreaFill.js +1 -1
  66. package/dist/collection/components/bn-chart-time/utils/elements/Label.js +1 -1
  67. package/dist/collection/components/bn-chart-time/utils/elements/LineSeries.js +1 -1
  68. package/dist/collection/components/bn-chart-time/utils/elements/Needle.js +11 -4
  69. package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +22 -34
  70. package/dist/collection/components/bn-chart-time/utils/helper/LabelCollisionManager.js +3 -3
  71. package/dist/collection/components/bn-chart-time/utils/model/TimeChartComponentConfig.js +4 -3
  72. package/dist/collection/components/bn-chart-time/utils/model/TimeChartDataRow.js +2 -2
  73. package/dist/collection/components/bn-chart-time/utils/model/styles/TimeChartStyle.js +2 -0
  74. package/dist/collection/components/bn-component-style/bn-component-style.js +14 -2
  75. package/dist/collection/components/bn-context/bn-context.js +92 -22
  76. package/dist/collection/components/bn-dataset/bn-dataset.js +246 -90
  77. package/dist/collection/components/bn-datasource/bn-datasource.js +169 -77
  78. package/dist/collection/components/bn-footer/bn-footer.js +6 -6
  79. package/dist/collection/components/bn-internationalization/bn-internationalization.js +14 -3
  80. package/dist/collection/components/bn-layout-card/bn-layout-card.js +25 -74
  81. package/dist/collection/components/bn-layout-page/bn-layout-page.js +59 -71
  82. package/dist/collection/components/bn-message/bn-message.js +2 -2
  83. package/dist/collection/components/bn-page/bn-page.css +0 -240
  84. package/dist/collection/components/bn-page/bn-page.js +14 -4
  85. package/dist/collection/components/bn-page/pageFormats.js +69 -0
  86. package/dist/collection/components/bn-ruleset/bn-ruleset.js +2 -2
  87. package/dist/collection/components/bn-scaling-group/bn-scaling-group.js +7 -7
  88. package/dist/collection/components/bn-table/bn-table.css +38 -1
  89. package/dist/collection/components/bn-table/bn-table.js +96 -59
  90. package/dist/collection/components/bn-table/ibcs-table.css +39 -1
  91. package/dist/collection/components/bn-table/ibcs-table.js +89 -30
  92. package/dist/collection/components/bn-table/utils/Table.js +12 -13
  93. package/dist/collection/components/bn-table/utils/elements/Cell.js +9 -3
  94. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +38 -34
  95. package/dist/collection/components/bn-table/utils/elements/TableRow.js +2 -1
  96. package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +4 -4
  97. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +17 -4
  98. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +128 -98
  99. package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +6 -20
  100. package/dist/collection/components/bn-table/utils/helper/QueryGroup.js +9 -2
  101. package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +2 -2
  102. package/dist/collection/components/bn-table/utils/model/TableAttribute.js +2 -2
  103. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +3 -2
  104. package/dist/collection/components/bn-template/bn-template.js +1 -1
  105. package/dist/collection/components/bn-text/bn-text.js +36 -39
  106. package/dist/collection/components/bn-text/utils/template.js +79 -0
  107. package/dist/collection/components/bn-title/bn-title.js +10 -4
  108. package/dist/collection/components/bn-title/ibcs-title/ibcs-title.js +3 -1
  109. package/dist/collection/components/bn-tree/bn-tree.js +119 -23
  110. package/dist/collection/components/bn-tree/utils/EdgeRenderer.js +59 -51
  111. package/dist/collection/components/bn-tree/utils/TreeLayout.js +30 -5
  112. package/dist/collection/components/bn-tree/utils/TreeParser.js +35 -0
  113. package/dist/collection/components/editor-companion/editor-companion.js +1 -1
  114. package/dist/collection/context/context-protocol.js +1 -1
  115. package/dist/collection/context/scopedDb.js +47 -4
  116. package/dist/collection/stores/componentStyles.js +39 -0
  117. package/dist/collection/stores/internationalization.js +15 -13
  118. package/dist/collection/utils/DateStringFactory.js +17 -15
  119. package/dist/collection/utils/autoFit.js +2 -2
  120. package/dist/collection/utils/componentRegister.js +60 -16
  121. package/dist/collection/utils/constants.js +2 -2
  122. package/dist/collection/utils/dataAnalyzer.js +9 -12
  123. package/dist/collection/utils/emptyState.js +21 -0
  124. package/dist/collection/utils/formatter.js +29 -20
  125. package/dist/collection/utils/layoutObserver.js +1 -1
  126. package/dist/collection/utils/layoutState/generic.js +1 -1
  127. package/dist/collection/utils/layoutState/svgChartElements.js +2 -2
  128. package/dist/collection/utils/layoutTemplate.js +81 -0
  129. package/dist/collection/utils/measurementHost.js +2 -2
  130. package/dist/collection/utils/model/Order.js +1 -1
  131. package/dist/collection/utils/model/styles/SVGStyle.js +12 -4
  132. package/dist/collection/utils/parentDimensions.js +35 -3
  133. package/dist/collection/utils/queryError.js +11 -0
  134. package/dist/collection/utils/relativeVariance.js +14 -0
  135. package/dist/collection/utils/sanitizeHtml.js +30 -16
  136. package/dist/collection/utils/scaling.js +2 -2
  137. package/dist/collection/utils/stackColors.js +27 -5
  138. package/dist/collection/utils/stackLayout.js +71 -0
  139. package/dist/collection/utils/styled/attributes.js +16 -3
  140. package/dist/collection/utils/styled/style-sheet.js +1 -1
  141. package/dist/collection/utils/styled/withStyled.js +1 -1
  142. package/dist/collection/utils/testing/fakeGroup.js +21 -0
  143. package/dist/collection/utils/testing/mutationObserver.js +44 -0
  144. package/dist/collection/utils/testing/structureChart.js +26 -0
  145. package/dist/collection/utils/testing/timeChart.js +28 -0
  146. package/dist/collection/utils/validate.js +1 -1
  147. package/dist/collection/utils/withComponentStatus.js +137 -12
  148. package/dist/collection/utils/withInheritedProps.js +113 -64
  149. package/dist/collection/utils/withRuleSet.js +10 -7
  150. package/dist/collection/utils/withTranslation.js +3 -3
  151. package/dist/collection/utils/xy/FacetGrid.js +1 -1
  152. package/dist/collection/utils/xy/IsoCurves.js +1 -1
  153. package/dist/collection/utils/xy/NumericScale.js +46 -15
  154. package/dist/collection/utils/xy/PointLabeler.js +2 -2
  155. package/dist/collection/utils/xy/RadiusScale.js +2 -2
  156. package/dist/collection/utils/xy/SeriesPalette.js +3 -3
  157. package/dist/collection/utils/xy/VarianceMeasure.js +22 -4
  158. package/dist/collection/utils/xy/XYFrame.js +4 -4
  159. package/dist/collection/utils/xy/XYLegend.js +5 -7
  160. package/dist/collection/utils/xy/checkXYOverflow.js +32 -0
  161. package/dist/collection/utils/xy/formatXYValue.js +13 -0
  162. package/dist/collection/utils/xy/model/XYChartDataRow.js +0 -0
  163. package/dist/collection/utils/xy/model/XYChartStyle.js +2 -0
  164. package/dist/components/DataFormatDigits.js +1 -1
  165. package/dist/components/DateStringFactory.js +1 -1
  166. package/dist/components/LabelCollisionManager.js +1 -1
  167. package/dist/components/NumericScale.js +1 -1
  168. package/dist/components/Order.js +1 -1
  169. package/dist/components/SVGStyle.js +1 -0
  170. package/dist/components/TableAttribute.js +1 -0
  171. package/dist/components/VarianceMeasure.js +1 -1
  172. package/dist/components/XYChartDataRow.js +1 -1
  173. package/dist/components/bn-asset.js +1 -1
  174. package/dist/components/bn-body2.js +1 -1
  175. package/dist/components/bn-card2.js +1 -1
  176. package/dist/components/bn-chart-bubble.js +1 -1
  177. package/dist/components/bn-chart-bullet.js +1 -1
  178. package/dist/components/bn-chart-scatter.js +1 -1
  179. package/dist/components/bn-chart-structure.js +1 -1
  180. package/dist/components/bn-chart-time.js +1 -1
  181. package/dist/components/bn-component-style.js +1 -1
  182. package/dist/components/bn-context.js +1 -1
  183. package/dist/components/bn-dataset.js +1 -1
  184. package/dist/components/bn-datasource.js +1 -1
  185. package/dist/components/bn-footer2.js +1 -1
  186. package/dist/components/bn-grid.js +1 -1
  187. package/dist/components/bn-image.js +1 -1
  188. package/dist/components/bn-internationalization.js +1 -1
  189. package/dist/components/bn-layout-card.js +1 -1
  190. package/dist/components/bn-layout-page.js +1 -1
  191. package/dist/components/bn-message2.js +1 -1
  192. package/dist/components/bn-page2.js +1 -1
  193. package/dist/components/bn-ruleset.js +1 -1
  194. package/dist/components/bn-scaling-group.js +1 -1
  195. package/dist/components/bn-table.js +1 -1
  196. package/dist/components/bn-template.js +1 -1
  197. package/dist/components/bn-text.js +1 -1
  198. package/dist/components/bn-title2.js +1 -1
  199. package/dist/components/bn-tree.js +1 -1
  200. package/dist/components/checkXYOverflow.js +1 -0
  201. package/dist/components/context-protocol.js +1 -1
  202. package/dist/components/editor-companion.js +1 -1
  203. package/dist/components/emptyState.js +1 -0
  204. package/dist/components/formatter.js +1 -1
  205. package/dist/components/ibcs-chart-bubble2.js +1 -1
  206. package/dist/components/ibcs-chart-bullet2.js +1 -1
  207. package/dist/components/ibcs-chart-scatter2.js +1 -1
  208. package/dist/components/ibcs-chart-structure2.js +1 -1
  209. package/dist/components/ibcs-chart-time2.js +1 -1
  210. package/dist/components/ibcs-table2.js +1 -1
  211. package/dist/components/ibcs-title2.js +1 -1
  212. package/dist/components/layoutTemplate.js +1 -0
  213. package/dist/components/pageFormats.js +1 -0
  214. package/dist/components/parentDimensions.js +1 -0
  215. package/dist/components/queryError.js +1 -0
  216. package/dist/components/relativeVariance.js +1 -0
  217. package/dist/components/sanitizeHtml.js +1 -1
  218. package/dist/components/stackColors.js +1 -1
  219. package/dist/components/stackLayout.js +1 -0
  220. package/dist/components/svg.esm.js +1 -0
  221. package/dist/components/validate.js +1 -1
  222. package/dist/components/withBodyObserver.js +1 -1
  223. package/dist/components/withComponentStatus.js +1 -0
  224. package/dist/components/withComponentStyle.js +1 -1
  225. package/dist/components/withDataset.js +1 -1
  226. package/dist/components/withHasError.js +1 -1
  227. package/dist/components/withRuleSet.js +1 -1
  228. package/dist/components/withScalingGroup.js +1 -1
  229. package/dist/components/withStyled.js +1 -1
  230. package/dist/components/withTranslation.js +1 -1
  231. package/dist/esm/{bn-asset_21.entry.js → bn-asset_28.entry.js} +20948 -6125
  232. package/dist/esm/bn-grid.entry.js +4 -6
  233. package/dist/esm/bn-image.entry.js +3 -5
  234. package/dist/esm/bn-internationalization.entry.js +17 -6
  235. package/dist/esm/bn-ruleset.entry.js +5 -5
  236. package/dist/esm/bn-template-engine.js +1 -1
  237. package/dist/esm/bn-template.entry.js +2 -2
  238. package/dist/esm/bn-text.entry.js +111 -39
  239. package/dist/esm/{context-protocol-B-vdGKeG.js → context-protocol-CdTp19uA.js} +106 -22
  240. package/dist/esm/{diagnostics-CiquIw8B.js → diagnostics-vw6TKMiT.js} +1 -1
  241. package/dist/esm/editor-companion.entry.js +2 -2
  242. package/dist/esm/loader.js +1 -1
  243. package/dist/esm/queryError-ClruFZD_.js +13 -0
  244. package/dist/esm/{scaling-Dggyeqts.js → sanitizeHtml-C5bFtARM.js} +464 -287
  245. package/dist/esm/{withBodyObserver-Cb9ZC5_J.js → withBodyObserver-DD_-r04o.js} +1 -1
  246. package/dist/esm/withHasError-73WV2SP5.js +422 -0
  247. package/dist/esm/{withStyled-DoNsbwS3.js → withStyled-BDEyKd_H.js} +513 -27
  248. package/dist/types/components/bn-chart-bubble/bn-chart-bubble.d.ts +8 -4
  249. package/dist/types/components/bn-chart-bubble/ibcs-chart-bubble.d.ts +2 -1
  250. package/dist/types/components/bn-chart-bubble/utils/BubbleChart.d.ts +14 -2
  251. package/dist/types/components/bn-chart-bullet/bn-chart-bullet.d.ts +12 -11
  252. package/dist/types/components/bn-chart-bullet/ibcs-chart-bullet.d.ts +2 -1
  253. package/dist/types/components/bn-chart-bullet/utils/BulletChart.d.ts +8 -5
  254. package/dist/types/components/bn-chart-bullet/utils/model/BulletChartStyle.d.ts +2 -0
  255. package/dist/types/components/bn-chart-bullet/utils/model/BulletConfig.d.ts +1 -1
  256. package/dist/types/components/bn-chart-scatter/bn-chart-scatter.d.ts +8 -4
  257. package/dist/types/components/bn-chart-scatter/ibcs-chart-scatter.d.ts +2 -1
  258. package/dist/types/components/bn-chart-scatter/utils/ScatterChart.d.ts +11 -1
  259. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +13 -12
  260. package/dist/types/components/bn-chart-structure/ibcs-chart-structure.d.ts +8 -1
  261. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +29 -6
  262. package/dist/types/components/bn-chart-structure/utils/elements/StackedBar.d.ts +4 -3
  263. package/dist/types/components/bn-chart-structure/utils/model/DataPoint.d.ts +3 -2
  264. package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +2 -1
  265. package/dist/types/components/bn-chart-structure/utils/model/styles/StructureChartStyle.d.ts +2 -0
  266. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +19 -15
  267. package/dist/types/components/bn-chart-time/ibcs-chart-time.d.ts +8 -1
  268. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +63 -5
  269. package/dist/types/components/bn-chart-time/utils/elements/AreaFill.d.ts +1 -1
  270. package/dist/types/components/bn-chart-time/utils/elements/StackedColumn.d.ts +9 -8
  271. package/dist/types/components/bn-chart-time/utils/model/DataPoint.d.ts +3 -2
  272. package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +3 -2
  273. package/dist/types/components/bn-chart-time/utils/model/styles/TimeChartStyle.d.ts +2 -0
  274. package/dist/types/components/bn-context/bn-context.d.ts +15 -3
  275. package/dist/types/components/bn-dataset/bn-dataset.d.ts +41 -20
  276. package/dist/types/components/bn-datasource/bn-datasource.d.ts +34 -18
  277. package/dist/types/components/bn-footer/bn-footer.d.ts +2 -2
  278. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +3 -10
  279. package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +13 -6
  280. package/dist/types/components/bn-message/bn-message.d.ts +2 -1
  281. package/dist/types/components/bn-page/bn-page.d.ts +2 -1
  282. package/dist/types/components/bn-page/pageFormats.d.ts +40 -0
  283. package/dist/types/components/bn-scaling-group/bn-scaling-group.d.ts +2 -2
  284. package/dist/types/components/bn-table/bn-table.d.ts +11 -10
  285. package/dist/types/components/bn-table/ibcs-table.d.ts +8 -5
  286. package/dist/types/components/bn-table/utils/Table.d.ts +3 -1
  287. package/dist/types/components/bn-table/utils/elements/Cell.d.ts +2 -2
  288. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +6 -4
  289. package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +1 -1
  290. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +2 -0
  291. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +14 -5
  292. package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +2 -2
  293. package/dist/types/components/bn-table/utils/helper/QueryGroup.d.ts +6 -1
  294. package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +2 -2
  295. package/dist/types/components/bn-table/utils/model/TableAttribute.d.ts +2 -0
  296. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +2 -1
  297. package/dist/types/components/bn-text/bn-text.d.ts +20 -13
  298. package/dist/types/components/bn-text/utils/template.d.ts +10 -0
  299. package/dist/types/components/bn-title/ibcs-title/ibcs-title.d.ts +1 -0
  300. package/dist/types/components/bn-tree/bn-tree.d.ts +8 -1
  301. package/dist/types/components/bn-tree/utils/EdgeRenderer.d.ts +18 -5
  302. package/dist/types/components/bn-tree/utils/TreeLayout.d.ts +5 -0
  303. package/dist/types/components.d.ts +226 -184
  304. package/dist/types/context/scopedDb.d.ts +20 -0
  305. package/dist/types/stores/componentStyles.d.ts +6 -0
  306. package/dist/types/utils/DateStringFactory.d.ts +3 -2
  307. package/dist/types/utils/autoFit.d.ts +2 -2
  308. package/dist/types/utils/componentRegister.d.ts +21 -5
  309. package/dist/types/utils/constants.d.ts +2 -2
  310. package/dist/types/utils/dataAnalyzer.d.ts +1 -1
  311. package/dist/types/utils/emptyState.d.ts +10 -0
  312. package/dist/types/utils/formatter.d.ts +7 -9
  313. package/dist/types/utils/layoutState/generic.d.ts +1 -1
  314. package/dist/types/utils/layoutState/svgChartElements.d.ts +2 -2
  315. package/dist/types/utils/layoutTemplate.d.ts +16 -0
  316. package/dist/types/utils/model/ChartStyles.d.ts +1 -1
  317. package/dist/types/utils/model/DataQueryResultRow.d.ts +2 -2
  318. package/dist/types/utils/model/Order.d.ts +1 -1
  319. package/dist/types/utils/model/styles/SVGStyle.d.ts +5 -1
  320. package/dist/types/utils/parentDimensions.d.ts +9 -0
  321. package/dist/types/utils/queryError.d.ts +5 -0
  322. package/dist/types/utils/relativeVariance.d.ts +9 -0
  323. package/dist/types/utils/sanitizeHtml.d.ts +2 -2
  324. package/dist/types/utils/scaling.d.ts +1 -1
  325. package/dist/types/utils/stackColors.d.ts +3 -2
  326. package/dist/types/utils/stackLayout.d.ts +49 -0
  327. package/dist/types/utils/testing/fakeGroup.d.ts +8 -0
  328. package/dist/types/utils/testing/mutationObserver.d.ts +5 -0
  329. package/dist/types/utils/testing/structureChart.d.ts +5 -0
  330. package/dist/types/utils/testing/timeChart.d.ts +5 -0
  331. package/dist/types/utils/validate.d.ts +1 -1
  332. package/dist/types/utils/withComponentStatus.d.ts +11 -3
  333. package/dist/types/utils/withInheritedProps.d.ts +42 -15
  334. package/dist/types/utils/withRuleSet.d.ts +2 -1
  335. package/dist/types/utils/withTranslation.d.ts +2 -2
  336. package/dist/types/utils/xy/FacetGrid.d.ts +1 -1
  337. package/dist/types/utils/xy/IsoCurves.d.ts +1 -1
  338. package/dist/types/utils/xy/NumericScale.d.ts +9 -4
  339. package/dist/types/utils/xy/PointLabeler.d.ts +2 -2
  340. package/dist/types/utils/xy/RadiusScale.d.ts +2 -2
  341. package/dist/types/utils/xy/SeriesPalette.d.ts +3 -3
  342. package/dist/types/utils/xy/VarianceMeasure.d.ts +10 -2
  343. package/dist/types/utils/xy/XYFrame.d.ts +4 -1
  344. package/dist/types/utils/xy/XYLegend.d.ts +3 -1
  345. package/dist/types/utils/xy/checkXYOverflow.d.ts +8 -0
  346. package/dist/types/utils/xy/formatXYValue.d.ts +7 -0
  347. package/dist/types/utils/xy/model/AxisConfig.d.ts +1 -1
  348. package/dist/types/utils/xy/model/XYChartStyle.d.ts +2 -0
  349. package/package.json +4 -2
  350. package/readme.md +11 -11
  351. package/dist/bn-template-engine/p-03304284.entry.js +0 -1
  352. package/dist/bn-template-engine/p-0fb02c57.entry.js +0 -1
  353. package/dist/bn-template-engine/p-4419db8f.entry.js +0 -1
  354. package/dist/bn-template-engine/p-45508f1b.entry.js +0 -1
  355. package/dist/bn-template-engine/p-461fdffa.entry.js +0 -1
  356. package/dist/bn-template-engine/p-5d7a3a77.entry.js +0 -1
  357. package/dist/bn-template-engine/p-62cc95b7.entry.js +0 -1
  358. package/dist/bn-template-engine/p-686d8e44.entry.js +0 -1
  359. package/dist/bn-template-engine/p-829212c3.entry.js +0 -1
  360. package/dist/bn-template-engine/p-B5Jd_eCX.js +0 -1
  361. package/dist/bn-template-engine/p-BA48JiHe.js +0 -1
  362. package/dist/bn-template-engine/p-BbmobTg0.js +0 -1
  363. package/dist/bn-template-engine/p-BcaI745G.js +0 -1
  364. package/dist/bn-template-engine/p-CG_Bcm6V.js +0 -1
  365. package/dist/bn-template-engine/p-CWWWM-XC.js +0 -1
  366. package/dist/bn-template-engine/p-CsJ84YRk.js +0 -1
  367. package/dist/bn-template-engine/p-D5e8I9Qe.js +0 -1
  368. package/dist/bn-template-engine/p-DVrDYxlh.js +0 -1
  369. package/dist/bn-template-engine/p-DjPXefnq.js +0 -1
  370. package/dist/bn-template-engine/p-DsTzlzxQ.js +0 -1
  371. package/dist/bn-template-engine/p-DtLI_CzV.js +0 -1
  372. package/dist/bn-template-engine/p-EtT29btN.js +0 -1
  373. package/dist/bn-template-engine/p-TuLpbB5O.js +0 -1
  374. package/dist/bn-template-engine/p-a5867a4c.entry.js +0 -1
  375. package/dist/bn-template-engine/p-b27009eb.entry.js +0 -1
  376. package/dist/bn-template-engine/p-bfa87b07.entry.js +0 -1
  377. package/dist/bn-template-engine/p-ceb80db3.entry.js +0 -1
  378. package/dist/bn-template-engine/p-fcfbb329.entry.js +0 -1
  379. package/dist/bn-template-engine/p-qRZrT-U3.js +0 -1
  380. package/dist/cjs/AxisConfig-DwiNUyYG.js +0 -233
  381. package/dist/cjs/LabelCollisionManager-Bv-xkeXw.js +0 -415
  382. package/dist/cjs/NumericScale-BAyYXpKL.js +0 -107
  383. package/dist/cjs/Order-2wRydarc.js +0 -87
  384. package/dist/cjs/SVGStyle-DoxylrEQ.js +0 -8219
  385. package/dist/cjs/SVGVariancesStyleGroup-CiI4GeWe.js +0 -50
  386. package/dist/cjs/VarianceMeasure-CQlSRzlp.js +0 -372
  387. package/dist/cjs/XYChartDataRow-C2FdL58s.js +0 -829
  388. package/dist/cjs/bn-chart-bubble.cjs.entry.js +0 -792
  389. package/dist/cjs/bn-chart-bullet.cjs.entry.js +0 -805
  390. package/dist/cjs/bn-chart-scatter.cjs.entry.js +0 -678
  391. package/dist/cjs/bn-tree.cjs.entry.js +0 -1042
  392. package/dist/cjs/ibcs-chart-bubble.cjs.entry.js +0 -624
  393. package/dist/cjs/ibcs-chart-bullet.cjs.entry.js +0 -673
  394. package/dist/cjs/ibcs-chart-scatter.cjs.entry.js +0 -667
  395. package/dist/cjs/sanitizeHtml-LuZr1IMd.js +0 -85
  396. package/dist/cjs/svgChartElements-tDA43aYj.js +0 -400
  397. package/dist/cjs/withHasError-BdDmiOXM.js +0 -258
  398. package/dist/cjs/withScalingGroup-CFIc5-6s.js +0 -73
  399. package/dist/components/autoFit.js +0 -1
  400. package/dist/components/main.js +0 -1
  401. package/dist/components/utils.js +0 -1
  402. package/dist/esm/AxisConfig-KqzWQbML.js +0 -224
  403. package/dist/esm/LabelCollisionManager-585bQMtP.js +0 -407
  404. package/dist/esm/NumericScale-DsTzlzxQ.js +0 -105
  405. package/dist/esm/Order-DZVWjEL_.js +0 -83
  406. package/dist/esm/SVGStyle-OrPkzjcb.js +0 -8209
  407. package/dist/esm/SVGVariancesStyleGroup-DO5QJfRQ.js +0 -48
  408. package/dist/esm/VarianceMeasure-DDjChp8C.js +0 -364
  409. package/dist/esm/XYChartDataRow-Dn83Tqh9.js +0 -820
  410. package/dist/esm/bn-chart-bubble.entry.js +0 -790
  411. package/dist/esm/bn-chart-bullet.entry.js +0 -803
  412. package/dist/esm/bn-chart-scatter.entry.js +0 -676
  413. package/dist/esm/bn-tree.entry.js +0 -1040
  414. package/dist/esm/ibcs-chart-bubble.entry.js +0 -622
  415. package/dist/esm/ibcs-chart-bullet.entry.js +0 -671
  416. package/dist/esm/ibcs-chart-scatter.entry.js +0 -665
  417. package/dist/esm/sanitizeHtml-BA48JiHe.js +0 -83
  418. package/dist/esm/svgChartElements-B3YClivG.js +0 -395
  419. package/dist/esm/withHasError-Bh1Viz52.js +0 -254
  420. package/dist/esm/withScalingGroup-DNBSqRC0.js +0 -71
@@ -9,11 +9,14 @@ import { Formatter } from "../../../utils";
9
9
  import { AggregationLevel, StackBy, StackMode } from "../../../utils/constants";
10
10
  import { computePercentBarExtent, computeUnitBarExtent } from "../../../utils/autoFit";
11
11
  import { getScenarioPrefix, IBCS_LAYER_ORDER } from "../../../utils/stackColors";
12
+ import { layoutStack, stackExtent, stackLabelSide } from "../../../utils/stackLayout";
12
13
  import { IBCSRuleSet } from "../../../utils/ibcsRuleSet";
14
+ import { relativeVariance } from "../../../utils/relativeVariance";
13
15
  import { VarianceScenario } from "../../../utils/model";
14
16
  import { OrderColumn } from "../../../utils/model/Order";
15
17
  import { SiPrefix } from "../../../utils/model/SiPrefix";
16
- import { buildFromExpr } from "../../../context/scopedDb";
18
+ import { sourceExpr } from "../../../context/scopedDb";
19
+ import { errorText } from "../../../utils/queryError";
17
20
  /**
18
21
  * Orchestrates the full rendering pipeline for an IBCS structure (categorical) chart.
19
22
  *
@@ -62,7 +65,10 @@ export class StructureChart {
62
65
  this.stackConfig = null;
63
66
  this.scenarioPropOrder = [];
64
67
  this.overflowConfig = null;
65
- this.highestStackedTotal = 0;
68
+ /** Largest positive and negative side of all stacks, in the units the stacks are laid out in. */
69
+ this.stackSides = stackExtent([]);
70
+ /** Largest distance a category label keeps from the axis to clear the stack segments, per side. */
71
+ this.stackLabelClearance = { left: 0, right: 0 };
66
72
  this.fromExpr = "";
67
73
  this.rowCount = 0;
68
74
  this.db = db;
@@ -119,7 +125,7 @@ export class StructureChart {
119
125
  this.measureUnit = config.measureUnit;
120
126
  this.dataFormatDigits = config.dataFormatDigits;
121
127
  this.stackConfig = config.stackConfig;
122
- this.highestStackedTotal = this.findHighestStackedRowTotal(this.dataModel);
128
+ this.measureStacks();
123
129
  this.updatePosition();
124
130
  }
125
131
  /** Returns a new array; the input keeps the `scenarios` prop order (the config is reused across rebuilds). */
@@ -147,7 +153,7 @@ export class StructureChart {
147
153
  setI18n(i18n) {
148
154
  this.i18n = this.createI18n(i18n);
149
155
  // The variance title bakes translated scenario labels in, and setI18n
150
- // arrives after the constructor's setConfig — recompute it here so the
156
+ // arrives after the constructor's setConfig - recompute it here so the
151
157
  // first render doesn't keep the built-in labels (e.g. ΔPY vs ΔVorjahr).
152
158
  this.updateTitle();
153
159
  }
@@ -199,20 +205,29 @@ export class StructureChart {
199
205
  setSource(filter) {
200
206
  var _a, _b;
201
207
  this.state = FactoryState.DIRTY;
202
- if (!this.tableName) {
203
- this.fromExpr = "";
208
+ this.queryError = undefined;
209
+ // "" while the source is not registered yet: no data, and no error
210
+ this.fromExpr = sourceExpr(this.db, this.tableName, filter);
211
+ if (!this.fromExpr) {
204
212
  this.rowCount = 0;
205
213
  return;
206
214
  }
207
- this.fromExpr = buildFromExpr(this.tableName, filter);
208
215
  try {
209
216
  const r = this.db.exec(`SELECT COUNT(*) AS cnt FROM ${this.fromExpr}`);
210
217
  this.rowCount = ((_b = (_a = r[0]) === null || _a === void 0 ? void 0 : _a.cnt) !== null && _b !== void 0 ? _b : 0);
211
218
  }
212
- catch (_e) {
219
+ catch (e) {
213
220
  this.rowCount = 0;
221
+ this.failQuery(e);
214
222
  }
215
223
  }
224
+ getQueryError() {
225
+ return this.queryError;
226
+ }
227
+ failQuery(e) {
228
+ var _a;
229
+ (_a = this.queryError) !== null && _a !== void 0 ? _a : (this.queryError = errorText(e));
230
+ }
216
231
  /**
217
232
  * Total bar extent (data units) proportional to pixelPerUnit, covering
218
233
  * BOTH sides of the axis (left side scales with negative values, right
@@ -221,14 +236,14 @@ export class StructureChart {
221
236
  */
222
237
  getUnitBarExtent() {
223
238
  var _a, _b;
224
- const stacked = this.stackConfig != null && this.highestStackedTotal > 0;
239
+ const stacked = this.isStacked();
225
240
  const vt = this.getVarianceType();
226
241
  const isVariance = vt !== VarianceType.NONE;
227
242
  const highest = isVariance ? this.highestVarianceDataPointValue : this.highestDataPointValue;
228
243
  const smallest = isVariance ? this.smallestVarianceDataPointValue : this.smallestDataPointValue;
229
244
  return computeUnitBarExtent({
230
- // Relative stacks span exactly 1 * ppu; absolute stacks the max row total
231
- fixedDomain: stacked ? (this.stackConfig.mode === StackMode.RELATIVE ? 1 : this.highestStackedTotal) : undefined,
245
+ // both sides of the axis; a relative stack is laid out on a span of 1, so its sides add up to 1 * ppu
246
+ fixedDomain: stacked ? this.stackSides.positive + this.stackSides.negative : undefined,
232
247
  relativeVariance: vt === VarianceType.RELATIVE,
233
248
  maxPositive: (_a = highest === null || highest === void 0 ? void 0 : highest.value) !== null && _a !== void 0 ? _a : 0,
234
249
  minNegative: (_b = smallest === null || smallest === void 0 ? void 0 : smallest.value) !== null && _b !== void 0 ? _b : 0,
@@ -271,7 +286,7 @@ export class StructureChart {
271
286
  return "<svg></svg>";
272
287
  }
273
288
  /**
274
- * Runs `draw()` purely for its side effects — it is what finalizes the
289
+ * Runs `draw()` purely for its side effects - it is what finalizes the
275
290
  * positions that `getAllocatedCanvas*()` read.
276
291
  *
277
292
  * The auto-fit solver measures the chart once per iteration and only needs
@@ -296,14 +311,14 @@ export class StructureChart {
296
311
  * its own takes whatever its ancestor chain supplies. That chain is not stable
297
312
  * across the places this SVG gets measured: drawn detached, svg.js's `bbox()`
298
313
  * clones the element into a sandbox under `document.body`, where it inherits
299
- * the document default — 16px Times — instead of the chart's real font. Every
314
+ * the document default - 16px Times - instead of the chart's real font. Every
300
315
  * label was measured ~9% too wide as a result, which over-allocated label
301
316
  * space and pushed labels past the `maxWidth` threshold in {@link Label} that
302
317
  * drops them entirely.
303
318
  *
304
319
  * Setting the font here makes a measurement independent of where it happens.
305
320
  * Stylesheet rules still win over presentation attributes, so this changes
306
- * nothing about how the chart renders in place — the CSS and this attribute
321
+ * nothing about how the chart renders in place - the CSS and this attribute
307
322
  * resolve to the same value, both being `fontSizePx * effectiveScaleFactor`.
308
323
  */
309
324
  applyFontToContainer(svgContainer) {
@@ -325,7 +340,7 @@ export class StructureChart {
325
340
  else if (this.stackConfig != null) {
326
341
  this.drawStackedScenarios(this.dataModel, svgContainer);
327
342
  this.drawStackedHeaders(this.dataModel, svgContainer);
328
- this.drawAxisAndLabels(this.dataModel, svgContainer);
343
+ this.drawAxisAndLabels(this.dataModel, svgContainer, true);
329
344
  }
330
345
  else {
331
346
  this.drawScenarios(this.dataModel, svgContainer);
@@ -389,11 +404,11 @@ export class StructureChart {
389
404
  ORDER BY ${orderStr}`);
390
405
  }
391
406
  catch (e) {
392
- console.error("StructureChart: populateModel query failed", e);
407
+ this.failQuery(e);
393
408
  return [];
394
409
  }
395
410
  this.detectNaNCells(selectedScenarios, result);
396
- this.createDataRows(result, dataModel, selectedScenarios);
411
+ this.createDataRows(this.limit > 0 ? result.slice(0, this.limit) : result, dataModel, selectedScenarios);
397
412
  this.crateRESTRow(result, selectedScenarios, dataModel);
398
413
  return dataModel;
399
414
  }
@@ -416,40 +431,37 @@ export class StructureChart {
416
431
  });
417
432
  }
418
433
  crateRESTRow(result, selectedScenarios, dataModel) {
419
- if (this.limit === 0 || this.limit > result.length) {
434
+ if (this.limit <= 0 || this.limit >= result.length) {
420
435
  return;
421
436
  }
422
437
  const restDataModel = [];
423
- const restResult = result.slice(this.limit, result.length);
424
- this.createDataRows(restResult, restDataModel, selectedScenarios);
438
+ this.createDataRows(result.slice(this.limit), restDataModel, selectedScenarios);
439
+ // a cell without a value is NaN: it is left out, and a sum over no value stays NaN (no bar)
440
+ const add = (sum, value) => Number.isFinite(value) ? (Number.isFinite(sum) ? sum : 0) + value : sum;
425
441
  const reducedRestRow = restDataModel.reduce(function (sum, current) {
426
442
  const obj = {
427
443
  id: sum.id,
428
444
  category: sum.category,
429
445
  type: sum.type,
430
- scenario1: new DataPoint(sum.scenario1.value + current.scenario1.value, selectedScenarios[0], sum.scenario1.pixelPerUnit, Scenario.NEU),
431
- scenario2: new DataPoint(sum.scenario2.value + current.scenario2.value, selectedScenarios[1], sum.scenario2.pixelPerUnit, Scenario.NEU),
432
- scenario3: new DataPoint(sum.scenario3.value + current.scenario3.value, selectedScenarios[2], sum.scenario3.pixelPerUnit, Scenario.NEU),
433
- scenario4: new DataPoint(sum.scenario4.value + current.scenario4.value, selectedScenarios[3], sum.scenario4.pixelPerUnit, Scenario.NEU),
446
+ scenario1: new DataPoint(add(sum.scenario1.value, current.scenario1.value), selectedScenarios[0], sum.scenario1.pixelPerUnit, Scenario.NEU),
447
+ scenario2: new DataPoint(add(sum.scenario2.value, current.scenario2.value), selectedScenarios[1], sum.scenario2.pixelPerUnit, Scenario.NEU),
448
+ scenario3: new DataPoint(add(sum.scenario3.value, current.scenario3.value), selectedScenarios[2], sum.scenario3.pixelPerUnit, Scenario.NEU),
449
+ scenario4: new DataPoint(add(sum.scenario4.value, current.scenario4.value), selectedScenarios[3], sum.scenario4.pixelPerUnit, Scenario.NEU),
434
450
  };
435
451
  return obj;
436
452
  }, {
437
453
  id: 9999,
438
454
  category: "REST",
439
455
  type: VarianceType.NONE,
440
- scenario1: new DataPoint(0, selectedScenarios[0], this.pixelPerUnit, Scenario.NEU),
441
- scenario2: new DataPoint(0, selectedScenarios[1], this.pixelPerUnit, Scenario.NEU),
442
- scenario3: new DataPoint(0, selectedScenarios[2], this.pixelPerUnit, Scenario.NEU),
443
- scenario4: new DataPoint(0, selectedScenarios[3], this.pixelPerUnit, Scenario.NEU),
456
+ scenario1: new DataPoint(NaN, selectedScenarios[0], this.pixelPerUnit, Scenario.NEU),
457
+ scenario2: new DataPoint(NaN, selectedScenarios[1], this.pixelPerUnit, Scenario.NEU),
458
+ scenario3: new DataPoint(NaN, selectedScenarios[2], this.pixelPerUnit, Scenario.NEU),
459
+ scenario4: new DataPoint(NaN, selectedScenarios[3], this.pixelPerUnit, Scenario.NEU),
444
460
  });
445
461
  dataModel.push(reducedRestRow);
446
462
  }
447
463
  createDataRows(result, dataModel, selectedScenarios) {
448
- let primaryResult = result;
449
- if (this.limit > 0) {
450
- primaryResult = result.slice(0, this.limit);
451
- }
452
- primaryResult.forEach((element, index) => {
464
+ result.forEach((element, index) => {
453
465
  dataModel.push({
454
466
  id: index,
455
467
  category: element.category,
@@ -464,7 +476,7 @@ export class StructureChart {
464
476
  createOrderStr(level, sortOrder) {
465
477
  let orderStr = `${level.toLowerCase()}`;
466
478
  if (sortOrder.hierarchy.length >= 1) {
467
- orderStr = `${sortOrder.hierarchy.toString()} ${sortOrder === null || sortOrder === void 0 ? void 0 : sortOrder.direction}`;
479
+ orderStr = sortOrder.hierarchy.map((column) => `${column} ${sortOrder.direction}`).toString();
468
480
  }
469
481
  return orderStr;
470
482
  }
@@ -540,47 +552,114 @@ export class StructureChart {
540
552
  }
541
553
  return highestDataPoint;
542
554
  }
543
- findHighestStackedRowTotal(dataModel) {
544
- if (!this.stackConfig || dataModel.length === 0)
545
- return 0;
555
+ /**
556
+ * The stacks of one row as they are drawn: one per scenario family when the row
557
+ * mixes several (overlay, back to front per IBCS layer order), else a single one.
558
+ */
559
+ stackGroups(row) {
560
+ if (!this.stackConfig)
561
+ return [];
546
562
  const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
547
- let maxTotal = 0;
548
- for (const row of dataModel) {
549
- let rowTotal = 0;
550
- if (isScenarioStack) {
551
- const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
552
- const segments = [];
553
- for (const key of scenarioKeys) {
554
- const dp = row[key];
555
- if (dp && !dp.isEmpty() && dp.value != null) {
556
- segments.push({ value: dp.value, scenario: dp.scenario });
557
- }
558
- }
559
- const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
560
- if (prefixes.size > 1) {
561
- // Overlay: groups overlap from baseline, width = max group total
562
- const groupMap = new Map();
563
- for (const seg of segments) {
564
- const prefix = getScenarioPrefix(seg.scenario);
565
- groupMap.set(prefix, (groupMap.get(prefix) || 0) + Math.abs(seg.value));
563
+ let segments = [];
564
+ for (const key of isScenarioStack ? ["scenario1", "scenario2", "scenario3", "scenario4"] : ["scenario1"]) {
565
+ const dp = row[key];
566
+ if (dp && !dp.isEmpty() && dp.value != null) {
567
+ segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
568
+ }
569
+ }
570
+ if (segments.length === 0)
571
+ return [];
572
+ const relativeSpan = this.stackConfig.mode === StackMode.RELATIVE ? 1 : 0;
573
+ const toGroup = (prefix, groupSegments) => ({
574
+ prefix,
575
+ segments: groupSegments,
576
+ layout: layoutStack(groupSegments.map((segment) => segment.value), relativeSpan),
577
+ hasValue: groupSegments.some((segment) => Number.isFinite(segment.value)),
578
+ });
579
+ if (isScenarioStack) {
580
+ this.sortSegmentsByPropOrder(segments);
581
+ const groupMap = new Map();
582
+ for (const seg of segments) {
583
+ const prefix = getScenarioPrefix(seg.scenario);
584
+ if (!groupMap.has(prefix))
585
+ groupMap.set(prefix, []);
586
+ groupMap.get(prefix).push(seg);
587
+ }
588
+ if (groupMap.size > 1) {
589
+ // Sort groups by IBCS layer order (back-to-front: pl, fc, pp, ac)
590
+ const groups = [];
591
+ for (const prefix of IBCS_LAYER_ORDER) {
592
+ if (groupMap.has(prefix)) {
593
+ groups.push(toGroup(prefix, groupMap.get(prefix)));
594
+ groupMap.delete(prefix);
566
595
  }
567
- rowTotal = Math.max(...groupMap.values());
568
- }
569
- else {
570
- // Single group: segments stack end-to-end, width = sum
571
- rowTotal = segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
572
596
  }
573
- }
574
- else {
575
- // Dimension stacking: use stackSegments
576
- if (row.stackSegments && row.stackSegments.length > 0) {
577
- rowTotal = row.stackSegments.reduce((sum, s) => sum + Math.abs(s.value), 0);
597
+ for (const [prefix, segs] of groupMap) {
598
+ groups.push(toGroup(prefix, segs));
578
599
  }
600
+ return groups;
579
601
  }
580
- if (rowTotal > maxTotal)
581
- maxTotal = rowTotal;
582
602
  }
583
- return maxTotal;
603
+ else if (row.stackSegments && row.stackSegments.length > 0) {
604
+ // Dimension stacking: one segment per value of the stack dimension
605
+ segments = row.stackSegments.map((seg) => ({
606
+ value: seg.value,
607
+ scenario: seg.label,
608
+ dataPoint: seg.dataPoint,
609
+ }));
610
+ }
611
+ // a segment without a value sorts like 0: NaN in the comparison would leave the stack unsorted
612
+ const sortValue = (segment) => (Number.isFinite(segment.value) ? segment.value : 0);
613
+ if (this.stackConfig.order === "asc") {
614
+ segments.sort((a, b) => sortValue(a) - sortValue(b));
615
+ }
616
+ else if (this.stackConfig.order === "desc") {
617
+ segments.sort((a, b) => sortValue(b) - sortValue(a));
618
+ }
619
+ return [toGroup("", segments)];
620
+ }
621
+ /** Extent of all stacks and the room their category labels need, taken from exactly what is drawn. */
622
+ measureStacks() {
623
+ const layouts = [];
624
+ this.stackLabelClearance = { left: 0, right: 0 };
625
+ for (const row of this.dataModel) {
626
+ const { flipped, clearance } = this.stackLabelPlace(row);
627
+ const rowLayouts = this.drawnStackLayouts(row);
628
+ const side = flipped ? "right" : "left";
629
+ this.stackLabelClearance[side] = Math.max(this.stackLabelClearance[side], clearance);
630
+ layouts.push(...rowLayouts);
631
+ }
632
+ this.stackSides = stackExtent(layouts);
633
+ }
634
+ /** Side of the axis and distance from it (in layout units) for the category label of a stacked row. */
635
+ stackLabelPlace(row) {
636
+ const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
637
+ // a 100 % stack prints no total
638
+ const totalLabelRoom = (layout) => {
639
+ var _a;
640
+ return ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === StackMode.RELATIVE
641
+ ? 0
642
+ : (labelToBar + this.calculateTotalLabelWidth(layout.total)) / this.pixelPerUnit;
643
+ };
644
+ return stackLabelSide(this.drawnStackLayouts(row), totalLabelRoom);
645
+ }
646
+ /** Layouts of the stacks of a row that are drawn, back to front. */
647
+ drawnStackLayouts(row) {
648
+ return this.stackGroups(row)
649
+ .filter((group) => group.hasValue)
650
+ .map((group) => group.layout);
651
+ }
652
+ /** Width of a stack total as its label prints it: with the fixed decimals and the measure scale of the chart. */
653
+ calculateTotalLabelWidth(total) {
654
+ const digits = this.dataFormatDigits.decimal;
655
+ return CalculateSize(Formatter.number(total, "decimal", digits, digits, this.measureScale.value, this.styles.locale), {
656
+ font: this.styles.fontStyles.font,
657
+ fontSize: this.styles.fontStyles.size + "px",
658
+ }).width;
659
+ }
660
+ /** True when the chart draws stacks that have a length. */
661
+ isStacked() {
662
+ return this.stackConfig != null && this.stackSides.positive + this.stackSides.negative > 0;
584
663
  }
585
664
  populateVarianceModel(variancesConfig, dataModel) {
586
665
  const varianceModel = [];
@@ -623,7 +702,8 @@ export class StructureChart {
623
702
  }
624
703
  const isRelativeVarianze = scenarios.type === VarianceType.RELATIVE;
625
704
  if (isRelativeVarianze) {
626
- return (element[scenarioBase].value - element[scenarioDelta].value) / element[scenarioDelta].value;
705
+ // NaN marks a category without data and stays empty; undefined is a reference of 0 and is shown as "n/a"
706
+ return relativeVariance(element[scenarioBase].value - element[scenarioDelta].value, element[scenarioDelta].value);
627
707
  }
628
708
  else {
629
709
  return element[scenarioBase].value - element[scenarioDelta].value;
@@ -645,7 +725,7 @@ export class StructureChart {
645
725
  return varianceMap;
646
726
  }
647
727
  calculateTextBoxWidth(value) {
648
- return CalculateSize(Formatter.number(value, "decimal", 1, 0), {
728
+ return CalculateSize(Formatter.number(value, "decimal", 1, 0, 1, this.styles.locale), {
649
729
  font: this.styles.fontStyles.font,
650
730
  fontSize: this.styles.fontStyles.size + "px",
651
731
  }).width;
@@ -662,7 +742,7 @@ export class StructureChart {
662
742
  font: this.styles.fontStyles.font,
663
743
  fontSize: this.styles.fontStyles.size + "px",
664
744
  }).width;
665
- const labelWidth = CalculateSize(Formatter.number(value, "decimal", 1, 1), {
745
+ const labelWidth = CalculateSize(Formatter.number(value, "decimal", 1, 1, 1, this.styles.locale), {
666
746
  font: this.styles.fontStyles.font,
667
747
  fontSize: this.styles.fontStyles.size + "px",
668
748
  }).width + signWidth;
@@ -671,7 +751,7 @@ export class StructureChart {
671
751
  cleanSVGforRedraw(svgContainer) {
672
752
  svgContainer.clear();
673
753
  }
674
- drawAxisAndLabels(dataModel, svgContainer) {
754
+ drawAxisAndLabels(dataModel, svgContainer, stacked = false) {
675
755
  const axisLabelGroup = svgContainer.group().id("AxisAndDateLables");
676
756
  let isRelative = false;
677
757
  if (!this.hideCategories) {
@@ -681,11 +761,20 @@ export class StructureChart {
681
761
  }
682
762
  let textHook = HookLocation.Right;
683
763
  let isPositive = true;
684
- if (elements["scenario1"].value < 0) {
685
- textHook = HookLocation.Left;
764
+ let clearance = 0;
765
+ if (stacked) {
766
+ // opposite the stack total, behind the segments on that side
767
+ const side = this.stackLabelPlace(elements);
768
+ isPositive = !side.flipped;
769
+ clearance = side.clearance * this.pixelPerUnit * (side.flipped ? 1 : -1);
770
+ }
771
+ else if (elements["scenario1"].value < 0) {
686
772
  isPositive = false;
687
773
  }
688
- new Label(axisLabelGroup, this.position.getCategoryPositionX(isPositive), this.position.getBarCenterPositionY(index), "",
774
+ if (!isPositive) {
775
+ textHook = HookLocation.Left;
776
+ }
777
+ new Label(axisLabelGroup, this.position.getCategoryPositionX(isPositive) + clearance, this.position.getBarCenterPositionY(index), "",
689
778
  // Category labels come from the data, but the synthetic "REST"
690
779
  // overflow bucket is engine-generated and translatable, as in bn-table.
691
780
  this.i18n.get(elements.category) || elements.category, this.styles, HookLocation.Center, textHook).draw();
@@ -738,6 +827,7 @@ export class StructureChart {
738
827
  * When stacking by scenario with multiple scenario types (e.g. ac+pl),
739
828
  * uses overlay mode: each type group is drawn from the same baseline,
740
829
  * back-to-front per IBCS convention (PL behind, AC on top).
830
+ * Positive segments stack right of the axis, negative segments left of it.
741
831
  */
742
832
  drawStackedScenarios(dataModel, svgContainer) {
743
833
  if (!this.stackConfig)
@@ -745,206 +835,60 @@ export class StructureChart {
745
835
  const stackGroup = svgContainer.group().id("StackedScenarios");
746
836
  const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
747
837
  dataModel.forEach((elements, index) => {
748
- const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
749
- const segments = [];
750
- if (isScenarioStack) {
751
- for (const key of scenarioKeys) {
752
- const dp = elements[key];
753
- if (dp && !dp.isEmpty() && dp.value != null) {
754
- segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
755
- }
756
- }
757
- this.sortSegmentsByPropOrder(segments);
758
- }
759
- else {
760
- const dp = elements["scenario1"];
761
- if (dp && !dp.isEmpty() && dp.value != null) {
762
- segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
763
- }
764
- }
765
- if (segments.length === 0)
766
- return;
767
- // Check if we have multiple scenario type groups for overlay mode
768
- const prefixes = isScenarioStack
769
- ? new Set(segments.map((s) => getScenarioPrefix(s.scenario)))
770
- : new Set();
771
- if (prefixes.size > 1) {
772
- // Overlay mode: group by scenario prefix, draw each group from same baseline
773
- const groupMap = new Map();
774
- for (const seg of segments) {
775
- const prefix = getScenarioPrefix(seg.scenario);
776
- if (!groupMap.has(prefix))
777
- groupMap.set(prefix, []);
778
- groupMap.get(prefix).push(seg);
779
- }
780
- // Sort groups by IBCS layer order (back-to-front: pl, fc, pp, ac)
781
- const groups = [];
782
- for (const prefix of IBCS_LAYER_ORDER) {
783
- if (groupMap.has(prefix)) {
784
- groups.push({ prefix, segments: groupMap.get(prefix) });
785
- groupMap.delete(prefix);
786
- }
787
- }
788
- for (const [prefix, segs] of groupMap) {
789
- groups.push({ prefix, segments: segs });
790
- }
791
- // Draw each group from baseline=0 (overlapping)
792
- groups.forEach((group, groupIdx) => {
793
- const groupTotal = group.segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
794
- const colorIndex = groups.length - 1 - groupIdx; // back=lighter, front=darker
795
- let cumulativeValue = 0;
796
- let lastBar = null;
797
- group.segments.forEach((seg) => {
798
- const bar = new StackedBar(this.position, this.styles, seg.dataPoint, index, cumulativeValue, seg.scenario, colorIndex, this.stackConfig.mode, groupTotal, true, stackGroup);
799
- bar.draw(this.dataFormatDigits, this.measureScale);
800
- cumulativeValue += Math.abs(seg.value);
801
- lastBar = bar;
802
- });
803
- if (lastBar) {
804
- lastBar.drawTotalLabel(this.dataFormatDigits, this.measureScale);
805
- }
806
- });
807
- }
808
- else {
809
- // Single group, scenario or dimension stacking
810
- // For dimension stacking, use stackSegments if available
811
- let finalSegments = segments;
812
- if (!isScenarioStack && elements.stackSegments && elements.stackSegments.length > 0) {
813
- finalSegments = elements.stackSegments.map((seg) => ({
814
- value: seg.value,
815
- scenario: seg.label,
816
- dataPoint: seg.dataPoint,
817
- }));
818
- }
819
- if (this.stackConfig.order === "asc") {
820
- finalSegments.sort((a, b) => a.value - b.value);
821
- }
822
- else if (this.stackConfig.order === "desc") {
823
- finalSegments.sort((a, b) => b.value - a.value);
824
- }
825
- const total = finalSegments.reduce((sum, s) => sum + Math.abs(s.value), 0);
826
- let cumulativeValue = 0;
838
+ const groups = this.stackGroups(elements);
839
+ groups.forEach((group, groupIdx) => {
827
840
  let lastBar = null;
828
- finalSegments.forEach((seg, segIdx) => {
829
- const bar = new StackedBar(this.position, this.styles, seg.dataPoint, index, cumulativeValue, seg.scenario, segIdx, this.stackConfig.mode, total, isScenarioStack, stackGroup);
841
+ group.segments.forEach((seg, segIdx) => {
842
+ const bar = new StackedBar(this.position, this.styles, seg.dataPoint, index, group.layout.segments[segIdx], seg.scenario,
843
+ // overlay: one colour per group, back=lighter, front=darker
844
+ groups.length > 1 ? groups.length - 1 - groupIdx : segIdx, this.stackConfig.mode, group.layout, isScenarioStack, stackGroup);
830
845
  bar.draw(this.dataFormatDigits, this.measureScale);
831
- cumulativeValue += Math.abs(seg.value);
832
846
  lastBar = bar;
833
847
  });
834
- if (lastBar) {
848
+ if (lastBar && group.hasValue) {
835
849
  lastBar.drawTotalLabel(this.dataFormatDigits, this.measureScale);
836
850
  }
837
- }
851
+ });
838
852
  });
839
853
  }
840
854
  /**
841
855
  * Draw column headers above stacked bars showing what each segment/group represents.
842
856
  * For overlay mode (multiple scenario types): shows one header per group.
843
- * For single-group scenario stacking: shows individual segment headers.
857
+ * For single-group stacking: shows individual segment headers.
858
+ * The headers take their place from the first row.
844
859
  */
845
860
  drawStackedHeaders(dataModel, svgContainer) {
846
861
  if (!this.stackConfig || dataModel.length === 0)
847
862
  return;
848
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
849
- const headerGroup = svgContainer.group().id("StackedHeaders");
850
863
  const firstRow = dataModel[0];
851
- // Dimension stacking: use stackSegments from first row for headers
852
- if (!isScenarioStack) {
853
- const stackSegs = firstRow.stackSegments;
854
- if (!stackSegs || stackSegs.length === 0)
855
- return;
856
- const orderedSegs = [...stackSegs];
857
- if (this.stackConfig.order === "asc")
858
- orderedSegs.sort((a, b) => a.value - b.value);
859
- else if (this.stackConfig.order === "desc")
860
- orderedSegs.sort((a, b) => b.value - a.value);
861
- const total = orderedSegs.reduce((sum, s) => sum + Math.abs(s.value), 0);
862
- const axisX = this.position.getBarPositionX();
863
- const headerY = this.position.getStackedHeaderPositionY();
864
- let cumulativePixels = 0;
865
- orderedSegs.forEach((seg) => {
866
- const pixelPerUnit = seg.dataPoint.pixelPerUnit;
867
- let segmentLength;
868
- if (this.stackConfig.mode === StackMode.RELATIVE) {
869
- const proportion = total !== 0 ? Math.abs(seg.value) / total : 0;
870
- segmentLength = proportion * pixelPerUnit;
871
- }
872
- else {
873
- segmentLength = Math.abs(seg.value * pixelPerUnit);
874
- }
875
- const centerX = axisX + cumulativePixels + segmentLength / 2;
876
- const labelText = this.i18n.get(seg.label) || seg.label;
877
- new Label(headerGroup, centerX, headerY, "STACK_HEADER", labelText, this.styles, HookLocation.Bottom, HookLocation.Center).draw();
878
- cumulativePixels += segmentLength;
879
- });
864
+ // Dimension stacking without segments draws one plain bar: nothing to name
865
+ if (this.stackConfig.by !== StackBy.SCENARIOS && (!firstRow.stackSegments || firstRow.stackSegments.length === 0)) {
880
866
  return;
881
867
  }
882
- const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
883
- const segments = [];
884
- for (const key of scenarioKeys) {
885
- const dp = firstRow[key];
886
- if (dp && !dp.isEmpty() && dp.value != null) {
887
- segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
888
- }
889
- }
890
- if (segments.length === 0)
868
+ const groups = this.stackGroups(firstRow);
869
+ if (groups.length === 0)
891
870
  return;
892
- this.sortSegmentsByPropOrder(segments);
893
- const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
871
+ const headerGroup = svgContainer.group().id("StackedHeaders");
894
872
  const axisX = this.position.getBarPositionX();
895
873
  const headerY = this.position.getStackedHeaderPositionY();
896
- if (prefixes.size > 1) {
874
+ const drawHeader = (centerX, labelText) => {
875
+ new Label(headerGroup, centerX, headerY, "STACK_HEADER", labelText, this.styles, HookLocation.Bottom, HookLocation.Center).draw();
876
+ };
877
+ if (groups.length > 1) {
897
878
  // Overlay mode: one header per group, centered on group's bar extent
898
- const groupMap = new Map();
899
- for (const seg of segments) {
900
- const prefix = getScenarioPrefix(seg.scenario);
901
- if (!groupMap.has(prefix))
902
- groupMap.set(prefix, []);
903
- groupMap.get(prefix).push(seg);
904
- }
905
- const groups = [];
906
- for (const prefix of IBCS_LAYER_ORDER) {
907
- if (groupMap.has(prefix)) {
908
- groups.push({ prefix, segments: groupMap.get(prefix) });
909
- groupMap.delete(prefix);
910
- }
911
- }
912
- for (const [prefix, segs] of groupMap) {
913
- groups.push({ prefix, segments: segs });
914
- }
915
879
  groups.forEach((group) => {
916
- const groupTotal = group.segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
917
880
  const pixelPerUnit = group.segments[0].dataPoint.pixelPerUnit;
918
- const groupPixelLength = this.stackConfig.mode === StackMode.RELATIVE ? pixelPerUnit : groupTotal * pixelPerUnit;
919
- const centerX = axisX + groupPixelLength / 2;
920
- const labelText = this.i18n.get(group.prefix + "1") || group.prefix.toUpperCase();
921
- new Label(headerGroup, centerX, headerY, "STACK_HEADER", labelText, this.styles, HookLocation.Bottom, HookLocation.Center).draw();
922
- });
923
- }
924
- else {
925
- // Single group: show individual segment headers
926
- if (this.stackConfig.order === "asc")
927
- segments.sort((a, b) => a.value - b.value);
928
- else if (this.stackConfig.order === "desc")
929
- segments.sort((a, b) => b.value - a.value);
930
- const total = segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
931
- let cumulativePixels = 0;
932
- segments.forEach((seg) => {
933
- const pixelPerUnit = seg.dataPoint.pixelPerUnit;
934
- let segmentLength;
935
- if (this.stackConfig.mode === StackMode.RELATIVE) {
936
- const proportion = total !== 0 ? Math.abs(seg.value) / total : 0;
937
- segmentLength = proportion * pixelPerUnit;
938
- }
939
- else {
940
- segmentLength = Math.abs(seg.value * pixelPerUnit);
941
- }
942
- const centerX = axisX + cumulativePixels + segmentLength / 2;
943
- const labelText = this.i18n.get(seg.scenario) || seg.scenario;
944
- new Label(headerGroup, centerX, headerY, "STACK_HEADER", labelText, this.styles, HookLocation.Bottom, HookLocation.Center).draw();
945
- cumulativePixels += segmentLength;
881
+ const centerX = axisX + ((group.layout.positive - group.layout.negative) / 2) * pixelPerUnit;
882
+ drawHeader(centerX, this.i18n.get(group.prefix + "1") || group.prefix.toUpperCase());
946
883
  });
884
+ return;
947
885
  }
886
+ // Single group: one header per segment, centered on the segment
887
+ const [group] = groups;
888
+ group.segments.forEach((seg, segIdx) => {
889
+ const { start, end } = group.layout.segments[segIdx];
890
+ drawHeader(axisX + ((start + end) / 2) * seg.dataPoint.pixelPerUnit, this.i18n.get(seg.scenario) || seg.scenario);
891
+ });
948
892
  }
949
893
  getVarianceType() {
950
894
  if (this.variancesDataModel.length > 0) {
@@ -956,7 +900,20 @@ export class StructureChart {
956
900
  var _a, _b, _c;
957
901
  let width = 0;
958
902
  const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
959
- if (VarianceType.NONE === varianceType &&
903
+ if (VarianceType.NONE === varianceType && this.isStacked()) {
904
+ // the negative side with the label of a negative total behind it
905
+ if (this.stackSides.negative > 0) {
906
+ width = this.stackSides.negative * this.pixelPerUnit;
907
+ if (this.stackSides.minTotal < 0) {
908
+ width += labelToBar + this.calculateTotalLabelWidth(this.stackSides.minTotal);
909
+ }
910
+ }
911
+ // a category label that sits behind negative segments
912
+ if (this.stackLabelClearance.left > 0) {
913
+ width = Math.max(width, this.stackLabelClearance.left * this.pixelPerUnit + this.calculateCategoryWidth());
914
+ }
915
+ }
916
+ else if (VarianceType.NONE === varianceType &&
960
917
  ((_a = this.smallestDataPointValue) === null || _a === void 0 ? void 0 : _a.value) != null &&
961
918
  this.smallestDataPointValue.value < 0) {
962
919
  const sizeLabelValue = this.calculateTextBoxWidth(this.smallestDataPointValue.value);
@@ -981,18 +938,17 @@ export class StructureChart {
981
938
  }
982
939
  calculateRightSideWidth(varianceType) {
983
940
  var _a, _b, _c;
984
- // Stacked charts: width based on max row total, not individual max
985
- if (this.stackConfig != null && this.highestStackedTotal > 0) {
941
+ // Stacked charts: width based on the positive side of the stacks, not individual max
942
+ if (this.isStacked()) {
986
943
  const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
987
- let barExtent;
988
- if (this.stackConfig.mode === StackMode.RELATIVE) {
989
- barExtent = this.pixelPerUnit;
990
- }
991
- else {
992
- barExtent = this.highestStackedTotal * this.pixelPerUnit;
944
+ const sizeTotalLabel = this.calculateTextBoxWidth(this.stackSides.maxTotal);
945
+ let width = this.stackSides.positive * this.pixelPerUnit + labelToBar + sizeTotalLabel;
946
+ // the category label of a row with a negative total sits right of the axis, behind its positive segments
947
+ if (this.stackSides.minTotal < 0) {
948
+ width = Math.max(width, this.stackLabelClearance.right * this.pixelPerUnit +
949
+ this.position.getCategoryToAxisSpaceing() +
950
+ this.calculateCategoryWidth());
993
951
  }
994
- const sizeTotalLabel = this.calculateTextBoxWidth(this.highestStackedTotal);
995
- const width = barExtent + labelToBar + sizeTotalLabel;
996
952
  return Math.max(width, this.titleLength);
997
953
  }
998
954
  let width = 0;
@@ -1047,7 +1003,7 @@ export class StructureChart {
1047
1003
  `FROM ${this.fromExpr} GROUP BY [${displayColumn}], [${stackColumn}]`);
1048
1004
  }
1049
1005
  catch (e) {
1050
- console.error("StructureChart: dimension-stack query failed", e);
1006
+ this.failQuery(e);
1051
1007
  return;
1052
1008
  }
1053
1009
  // Group results by displayGroup