@bino-bi/bn-template-engine 1.0.0-alpha.3 → 1.0.0-alpha.5

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 (198) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-1265d8d3.entry.js +1 -0
  3. package/dist/bn-template-engine/p-15516dac.entry.js +1 -0
  4. package/dist/bn-template-engine/p-1c716641.entry.js +1 -0
  5. package/dist/bn-template-engine/p-27cc8dc0.entry.js +1 -0
  6. package/dist/bn-template-engine/p-3b4c7425.entry.js +1 -0
  7. package/dist/bn-template-engine/p-4426d484.entry.js +1 -0
  8. package/dist/bn-template-engine/p-51f8dc9e.entry.js +1 -0
  9. package/dist/bn-template-engine/p-53d4e690.entry.js +1 -0
  10. package/dist/bn-template-engine/p-5KQYRQLK.js +1 -0
  11. package/dist/bn-template-engine/p-7337e03d.entry.js +1 -0
  12. package/dist/bn-template-engine/{p-0f1504f3.entry.js → p-75e97c87.entry.js} +1 -1
  13. package/dist/bn-template-engine/p-7a560278.entry.js +1 -0
  14. package/dist/bn-template-engine/p-BYBpC0EO.js +1 -0
  15. package/dist/bn-template-engine/p-BfXY5dsy.js +1 -0
  16. package/dist/bn-template-engine/p-BgnHJQ9Q.js +1 -0
  17. package/dist/bn-template-engine/{p-B4ySv9KQ.js → p-Bhd_WSML.js} +1 -1
  18. package/dist/bn-template-engine/p-Bka-Z6jo.js +1 -0
  19. package/dist/bn-template-engine/p-Bnhh02CF.js +1 -0
  20. package/dist/bn-template-engine/p-C7dQL8CS.js +1 -0
  21. package/dist/bn-template-engine/p-CL1RYuNU.js +1 -0
  22. package/dist/bn-template-engine/p-CYwd_ZNM.js +1 -0
  23. package/dist/bn-template-engine/p-ChlK-T9I.js +1 -0
  24. package/dist/bn-template-engine/p-DHezf8pZ.js +1 -0
  25. package/dist/bn-template-engine/{p-DVMu6dEy.js → p-DlppAFq9.js} +1 -1
  26. package/dist/bn-template-engine/p-DvDDgmcV.js +1 -0
  27. package/dist/bn-template-engine/p-DvvwfRQG.js +1 -0
  28. package/dist/bn-template-engine/{p-DG-1MR_T.js → p-P7pGJBgc.js} +1 -1
  29. package/dist/bn-template-engine/p-abc0067c.entry.js +1 -0
  30. package/dist/bn-template-engine/p-b34eaf86.entry.js +1 -0
  31. package/dist/bn-template-engine/p-bdb8b44c.entry.js +1 -0
  32. package/dist/bn-template-engine/p-c44fcb8e.entry.js +1 -0
  33. package/dist/bn-template-engine/p-c7e1a49b.entry.js +1 -0
  34. package/dist/bn-template-engine/p-d9003041.entry.js +1 -0
  35. package/dist/bn-template-engine/p-daa7ffa3.entry.js +1 -0
  36. package/dist/bn-template-engine/p-e084f50a.entry.js +1 -0
  37. package/dist/bn-template-engine/p-eaba6658.entry.js +1 -0
  38. package/dist/bn-template-engine/{p-C0yAPzJz.js → p-u8igQLRZ.js} +1 -1
  39. package/dist/cjs/{DataFormatDigits-DAmZzqbD.js → DataFormatDigits-DKcOeLNK.js} +1 -1
  40. package/dist/cjs/{DateStringFactory-CcluhpGI.js → DateStringFactory-CSKvbS8K.js} +1 -1
  41. package/dist/cjs/{Order-BKoDS21t.js → Order-iG11HI4R.js} +8 -5
  42. package/dist/cjs/{SVGVariancesStyleGroup-DYYAU-81.js → SVGVariancesStyleGroup-K-Tw6lOD.js} +1 -14
  43. package/dist/cjs/bn-asset.cjs.entry.js +5 -4
  44. package/dist/cjs/bn-body_4.cjs.entry.js +15 -13
  45. package/dist/cjs/bn-card.cjs.entry.js +5 -4
  46. package/dist/cjs/{ibcs-chart-structure.cjs.entry.js → bn-chart-structure_5.cjs.entry.js} +1074 -30
  47. package/dist/cjs/bn-chart-time.cjs.entry.js +38 -12
  48. package/dist/cjs/bn-component-style.cjs.entry.js +5 -4
  49. package/dist/cjs/bn-dataset.cjs.entry.js +38 -9
  50. package/dist/cjs/bn-grid.cjs.entry.js +9 -7
  51. package/dist/cjs/bn-image.cjs.entry.js +9 -7
  52. package/dist/cjs/bn-internationalization.cjs.entry.js +5 -4
  53. package/dist/cjs/bn-layout-card.cjs.entry.js +3 -2
  54. package/dist/cjs/bn-layout-page.cjs.entry.js +2 -1
  55. package/dist/cjs/bn-message.cjs.entry.js +5 -4
  56. package/dist/cjs/bn-table.cjs.entry.js +981 -0
  57. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  58. package/dist/cjs/bn-template.cjs.entry.js +3 -2
  59. package/dist/cjs/bn-text.cjs.entry.js +11 -9
  60. package/dist/cjs/bn-tree.cjs.entry.js +9 -7
  61. package/dist/cjs/contentDecoder-JxOldq1e.js +419 -0
  62. package/dist/cjs/{context-protocol-CRPmux5D.js → context-protocol-DRQWrwsA.js} +2 -0
  63. package/dist/cjs/editor-companion.cjs.entry.js +1 -1
  64. package/dist/cjs/emotion-hash.esm-nbbEQ0Dn.js +57 -0
  65. package/dist/cjs/ibcs-chart-time.cjs.entry.js +22 -18
  66. package/dist/cjs/{bn-context_5.cjs.entry.js → ibcs-table.cjs.entry.js} +122 -1293
  67. package/dist/cjs/{StringAdapter-Bneo8T4k.js → ibcsRuleSet-DgUoXOfd.js} +10 -10
  68. package/dist/cjs/index-Dm85hG6t.js +65 -0
  69. package/dist/cjs/loader.cjs.js +1 -1
  70. package/dist/cjs/{scaling-D8sIIKft.js → scaling-9Tz595RQ.js} +7 -7
  71. package/dist/cjs/{withHasError-B8gHkfV2.js → utils-CwHIVbbL.js} +1 -69
  72. package/dist/cjs/{withBodyObserver-C6gLgq_e.js → withBodyObserver-CKpSD8UT.js} +3 -3
  73. package/dist/cjs/{withComponentStatus-_x4LQZ0N.js → withComponentStatus-Bw70BhO0.js} +5 -5
  74. package/dist/cjs/{withComponentStyle-DMtic_9Y.js → withComponentStyle-aIbTCtfj.js} +5 -5
  75. package/dist/cjs/withHasError-D7ue5vAv.js +72 -0
  76. package/dist/cjs/{withStyled-CW30Bh6c.js → withStyled-CS1Yp4sv.js} +8 -61
  77. package/dist/cjs/{withTranslation-CWPAIRjh.js → withTranslation-rwgyITqe.js} +5 -5
  78. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +226 -99
  79. package/dist/collection/components/bn-chart-structure/ibcs-chart-structure.js +13 -3
  80. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +94 -11
  81. package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +11 -0
  82. package/dist/collection/components/bn-chart-structure/utils/elements/StackedBar.js +8 -6
  83. package/dist/collection/components/bn-chart-structure/utils/model/styles/StructureChartStyle.js +4 -0
  84. package/dist/collection/components/bn-chart-time/bn-chart-time.js +28 -4
  85. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +3 -3
  86. package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +3 -4
  87. package/dist/collection/components/bn-chart-time/utils/model/styles/TimeChartStyle.js +4 -0
  88. package/dist/collection/components/bn-dataset/bn-dataset.js +49 -2
  89. package/dist/collection/components/bn-datasource/bn-datasource.js +46 -3
  90. package/dist/collection/components/bn-table/bn-table.js +20 -21
  91. package/dist/collection/components/bn-table/ibcs-table.js +2 -2
  92. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +58 -41
  93. package/dist/collection/stores/componentStyles.js +2 -0
  94. package/dist/collection/utils/constants.js +8 -5
  95. package/dist/collection/utils/contentDecoder.js +28 -0
  96. package/dist/collection/utils/stackColors.js +2 -2
  97. package/dist/collection/utils/validate.js +1 -1
  98. package/dist/components/DataFormatDigits.js +1 -1
  99. package/dist/components/Order.js +1 -1
  100. package/dist/components/SVGVariancesStyleGroup.js +1 -1
  101. package/dist/components/bn-chart-structure.js +1 -1
  102. package/dist/components/bn-chart-time.js +1 -1
  103. package/dist/components/bn-dataset.js +1 -1
  104. package/dist/components/bn-datasource.js +1 -1
  105. package/dist/components/bn-table.js +1 -1
  106. package/dist/components/contentDecoder.js +1 -0
  107. package/dist/components/context-protocol.js +1 -1
  108. package/dist/components/emotion-hash.esm.js +1 -0
  109. package/dist/components/ibcs-chart-structure2.js +1 -1
  110. package/dist/components/ibcs-chart-time2.js +1 -1
  111. package/dist/components/ibcs-table2.js +1 -1
  112. package/dist/components/ibcs-title2.js +1 -1
  113. package/dist/components/ibcsRuleSet.js +1 -1
  114. package/dist/components/validate.js +1 -1
  115. package/dist/components/withStyled.js +1 -1
  116. package/dist/esm/{DataFormatDigits--qIbKvXa.js → DataFormatDigits-oSZ1hBKE.js} +1 -1
  117. package/dist/esm/{DateStringFactory-XWdUjsn8.js → DateStringFactory-CSGz6TDk.js} +1 -1
  118. package/dist/esm/{Order-sqjrku2z.js → Order-Bnhh02CF.js} +9 -6
  119. package/dist/esm/{SVGVariancesStyleGroup-ibg3sLjM.js → SVGVariancesStyleGroup-CqTjrZYg.js} +2 -13
  120. package/dist/esm/bn-asset.entry.js +5 -4
  121. package/dist/esm/bn-body_4.entry.js +11 -9
  122. package/dist/esm/bn-card.entry.js +5 -4
  123. package/dist/esm/{ibcs-chart-structure.entry.js → bn-chart-structure_5.entry.js} +1064 -24
  124. package/dist/esm/bn-chart-time.entry.js +38 -12
  125. package/dist/esm/bn-component-style.entry.js +5 -4
  126. package/dist/esm/bn-dataset.entry.js +35 -6
  127. package/dist/esm/bn-grid.entry.js +9 -7
  128. package/dist/esm/bn-image.entry.js +9 -7
  129. package/dist/esm/bn-internationalization.entry.js +5 -4
  130. package/dist/esm/bn-layout-card.entry.js +3 -2
  131. package/dist/esm/bn-layout-page.entry.js +2 -1
  132. package/dist/esm/bn-message.entry.js +5 -4
  133. package/dist/esm/bn-table.entry.js +979 -0
  134. package/dist/esm/bn-template-engine.js +1 -1
  135. package/dist/esm/bn-template.entry.js +3 -2
  136. package/dist/esm/bn-text.entry.js +11 -9
  137. package/dist/esm/bn-tree.entry.js +9 -7
  138. package/dist/esm/contentDecoder-oMmxz6nJ.js +416 -0
  139. package/dist/esm/{context-protocol-Bz5klD-F.js → context-protocol-BHnQsVsr.js} +2 -0
  140. package/dist/esm/editor-companion.entry.js +1 -1
  141. package/dist/esm/emotion-hash.esm-BYBpC0EO.js +55 -0
  142. package/dist/esm/ibcs-chart-time.entry.js +15 -11
  143. package/dist/esm/{bn-context_5.entry.js → ibcs-table.entry.js} +69 -1236
  144. package/dist/esm/{StringAdapter-BCLJpQQ8.js → ibcsRuleSet-K4ytuA1f.js} +10 -10
  145. package/dist/esm/index-DHezf8pZ.js +65 -0
  146. package/dist/esm/loader.js +1 -1
  147. package/dist/esm/{scaling-C6K8FYSF.js → scaling-Cehc74IE.js} +2 -2
  148. package/dist/esm/{withHasError-B3QX2emi.js → utils-DvvwfRQG.js} +1 -69
  149. package/dist/esm/{withBodyObserver-DczL5ia8.js → withBodyObserver-FQ8NwCIz.js} +1 -1
  150. package/dist/esm/{withComponentStatus-DodoSXe-.js → withComponentStatus-DWjDYtZ7.js} +1 -1
  151. package/dist/esm/{withComponentStyle-BerJY64r.js → withComponentStyle-9uP_hcDq.js} +2 -2
  152. package/dist/esm/withHasError-FyY5mQ_3.js +70 -0
  153. package/dist/esm/{withStyled-D1fAWJ3g.js → withStyled--qQWquTH.js} +6 -59
  154. package/dist/esm/{withTranslation-mimbJdER.js → withTranslation-BqD0Kp7b.js} +2 -2
  155. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +155 -109
  156. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +7 -0
  157. package/dist/types/components/bn-chart-structure/utils/elements/Label.d.ts +2 -0
  158. package/dist/types/components/bn-chart-structure/utils/model/styles/StructureChartStyle.d.ts +1 -0
  159. package/dist/types/components/bn-chart-time/utils/model/styles/TimeChartStyle.d.ts +1 -0
  160. package/dist/types/components/bn-dataset/bn-dataset.d.ts +6 -0
  161. package/dist/types/components/bn-datasource/bn-datasource.d.ts +8 -0
  162. package/dist/types/components/bn-table/bn-table.d.ts +10 -8
  163. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +0 -2
  164. package/dist/types/components.d.ts +102 -38
  165. package/dist/types/stores/componentStyles.d.ts +2 -0
  166. package/dist/types/utils/constants.d.ts +8 -5
  167. package/dist/types/utils/contentDecoder.d.ts +12 -0
  168. package/package.json +2 -1
  169. package/dist/bn-template-engine/p-05a82a77.entry.js +0 -1
  170. package/dist/bn-template-engine/p-1970906d.entry.js +0 -1
  171. package/dist/bn-template-engine/p-1dbd339c.entry.js +0 -1
  172. package/dist/bn-template-engine/p-2e68cf09.entry.js +0 -1
  173. package/dist/bn-template-engine/p-31cc6a2d.entry.js +0 -1
  174. package/dist/bn-template-engine/p-37881d05.entry.js +0 -1
  175. package/dist/bn-template-engine/p-3b894997.entry.js +0 -1
  176. package/dist/bn-template-engine/p-50e49732.entry.js +0 -1
  177. package/dist/bn-template-engine/p-6c7c0455.entry.js +0 -1
  178. package/dist/bn-template-engine/p-6da93eae.entry.js +0 -1
  179. package/dist/bn-template-engine/p-701e1578.entry.js +0 -1
  180. package/dist/bn-template-engine/p-8tsCnxIz.js +0 -1
  181. package/dist/bn-template-engine/p-997b2fe4.entry.js +0 -1
  182. package/dist/bn-template-engine/p-BL8gyUwE.js +0 -1
  183. package/dist/bn-template-engine/p-BSfqOkN_.js +0 -1
  184. package/dist/bn-template-engine/p-CRLgp9-v.js +0 -1
  185. package/dist/bn-template-engine/p-CYjZRKdI.js +0 -1
  186. package/dist/bn-template-engine/p-DRikHQE-.js +0 -1
  187. package/dist/bn-template-engine/p-DtdQCMzj.js +0 -1
  188. package/dist/bn-template-engine/p-a90f1cbe.entry.js +0 -1
  189. package/dist/bn-template-engine/p-b7bec050.entry.js +0 -1
  190. package/dist/bn-template-engine/p-d7f0cbaf.entry.js +0 -1
  191. package/dist/bn-template-engine/p-dfb61aa5.entry.js +0 -1
  192. package/dist/bn-template-engine/p-ece17f84.entry.js +0 -1
  193. package/dist/bn-template-engine/p-f27995c9.entry.js +0 -1
  194. package/dist/bn-template-engine/p-fd427179.entry.js +0 -1
  195. package/dist/bn-template-engine/p-sqjrku2z.js +0 -1
  196. package/dist/bn-template-engine/p-tzFCK9qn.js +0 -1
  197. package/dist/cjs/bn-chart-structure.cjs.entry.js +0 -700
  198. package/dist/esm/bn-chart-structure.entry.js +0 -698
@@ -1,12 +1,941 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement } from './index-JNHhIe7t.js';
2
- import { S as Svg, g as getContrastTextColor, a as getStackFill, b as getStackStroke, c as getScenarioPrefix, I as IBCS_LAYER_ORDER, F as FontStyleAdapter, d as SVGStyleGroupAdapter, e as SVGStyleAdapter, f as SVGVariancesStyleGroupAdapter, P as PaddingAdapter } from './SVGVariancesStyleGroup-ibg3sLjM.js';
3
- import { d as AdapterUtils, e as CompareUtil, k as OrderAdapter, A as AggregationLevel, b as StackMode, l as StackBy, a as OrderColumn, O as OrderDirection } from './Order-sqjrku2z.js';
4
- import { D as DataAnalyzer, S as SiPrefix, b as DataFormatDigitsAdapter } from './DataFormatDigits--qIbKvXa.js';
2
+ import { v as validateScenarioList, a as validateVariancesList, i as isValidNumber, c as isValidLevel, d as validateOrderList, e as isValidDirection, b as isValidInteger, j as isValidBoolean, k as isValidMeasureScale, g as validateStackConfig, w as withStyled, l as isBlankInput } from './withStyled--qQWquTH.js';
3
+ import { w as withDataset, g as getParentDimensions, p as parseScaling } from './scaling-Cehc74IE.js';
4
+ import { w as withComponentStatus } from './withComponentStatus-DWjDYtZ7.js';
5
+ import { w as withTranslation } from './withTranslation-BqD0Kp7b.js';
6
+ import { a as globalLabelKeys, b as getOrCreateStores, g as getStores } from './context-protocol-BHnQsVsr.js';
7
+ import { w as withComponentStyle } from './withComponentStyle-9uP_hcDq.js';
8
+ import { w as withHasError } from './withHasError-FyY5mQ_3.js';
9
+ import { j as AggregationLevel, O as OrderDirection, a as OrderColumn, S as StackBy, b as StackOrder, c as StackMode, f as AdapterUtils, g as CompareUtil, l as OrderAdapter } from './Order-Bnhh02CF.js';
10
+ import { w as withBodyObserver } from './withBodyObserver-FQ8NwCIz.js';
11
+ import { c as computeContentHash, d as decodeCompressedContent } from './contentDecoder-oMmxz6nJ.js';
12
+ import { S as Svg, g as getContrastTextColor, a as getScenarioPrefix, I as IBCS_LAYER_ORDER, F as FontStyleAdapter, b as SVGStyleGroupAdapter, c as SVGStyleAdapter, d as SVGVariancesStyleGroupAdapter, P as PaddingAdapter } from './SVGVariancesStyleGroup-CqTjrZYg.js';
13
+ import { D as DataAnalyzer, S as SiPrefix, b as DataFormatDigitsAdapter } from './DataFormatDigits-oSZ1hBKE.js';
5
14
  import { F as Formatter, C as CalculateSize, V as VarianceScenario } from './formatter-DTMEZ6d8.js';
6
15
  import { a as alasql } from './alasql.min-CWu4NkIt.js';
7
- import { S as StringAdapter, I as IBCSRuleSet } from './StringAdapter-BCLJpQQ8.js';
16
+ import { S as StringAdapter, I as IBCSRuleSet } from './ibcsRuleSet-K4ytuA1f.js';
17
+ import './emotion-hash.esm-BYBpC0EO.js';
18
+ import './DateStringFactory-CSGz6TDk.js';
19
+ import './utils-DvvwfRQG.js';
8
20
  import './_commonjsHelpers-BFTU3MAI.js';
9
21
 
22
+ const bnChartStructureCss$1 = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
23
+
24
+ const Chart = class {
25
+ validateScenario(newValue) {
26
+ const invalidScenarios = validateScenarioList(newValue);
27
+ const errId = "ERR_scenarios";
28
+ if (invalidScenarios.length > 0) {
29
+ this.errors.addOrReplace({
30
+ id: errId,
31
+ type: "warning",
32
+ message: "scenarios: invalid value(s) '" + JSON.stringify(invalidScenarios) + "' are not supported.",
33
+ });
34
+ }
35
+ else {
36
+ this.errors.remove(errId);
37
+ }
38
+ }
39
+ validateVariances(newValue) {
40
+ const errIdVar = "ERR_variances";
41
+ const invalidVariances = validateVariancesList(newValue);
42
+ if (invalidVariances.length > 0) {
43
+ this.errors.addOrReplace({
44
+ id: errIdVar,
45
+ type: "warning",
46
+ message: "variances: invalid value(s) '" + JSON.stringify(invalidVariances) + "' are not supported.",
47
+ });
48
+ }
49
+ else {
50
+ this.errors.remove(errIdVar);
51
+ }
52
+ }
53
+ validateUnitScaling(newValue) {
54
+ const errId = "ERR_unitScaling";
55
+ if (!isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
56
+ this.errors.addOrReplace({
57
+ id: errId,
58
+ type: "warning",
59
+ message: "unitScaling: invalid value(s) '" + newValue + "' are not supported.",
60
+ });
61
+ }
62
+ else {
63
+ this.errors.remove(errId);
64
+ }
65
+ }
66
+ validatePercentageScaling(newValue) {
67
+ const errId = "ERR_percentageScaling";
68
+ if (!isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
69
+ this.errors.addOrReplace({
70
+ id: errId,
71
+ type: "warning",
72
+ message: "percentageScaling: invalid value(s) '" + newValue + "' are not supported.",
73
+ });
74
+ }
75
+ else {
76
+ this.errors.remove(errId);
77
+ }
78
+ }
79
+ validateLevel(newValue) {
80
+ const errId = "ERR_level";
81
+ if (!isValidLevel(newValue)) {
82
+ this.errors.addOrReplace({
83
+ id: errId,
84
+ type: "warning",
85
+ message: "level: invalid value(s) '" + newValue + "' are not supported.",
86
+ });
87
+ }
88
+ else {
89
+ this.errors.remove(errId);
90
+ }
91
+ }
92
+ validateOrderList(newValue) {
93
+ const invalidElements = validateOrderList(newValue);
94
+ const errId = "ERR_order";
95
+ if (invalidElements.length > 0) {
96
+ this.errors.addOrReplace({
97
+ id: errId,
98
+ type: "warning",
99
+ message: "order: invalid value(s) '" + JSON.stringify(invalidElements) + "' are not supported.",
100
+ });
101
+ }
102
+ else {
103
+ this.errors.remove(errId);
104
+ }
105
+ }
106
+ validateOrderDirection(newValue) {
107
+ const errId = "ERR_orderDirection";
108
+ if (!isValidDirection(newValue)) {
109
+ this.errors.addOrReplace({
110
+ id: errId,
111
+ type: "warning",
112
+ message: "orderDirection: invalid value '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' is not supported.",
113
+ });
114
+ }
115
+ else {
116
+ this.errors.remove(errId);
117
+ }
118
+ }
119
+ validateLimit(newValue) {
120
+ const errId = "ERR_limit";
121
+ if (!isValidInteger(newValue)) {
122
+ this.errors.addOrReplace({
123
+ id: errId,
124
+ type: "warning",
125
+ message: "limit: invalid value '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' is not supported.",
126
+ });
127
+ }
128
+ else {
129
+ this.errors.remove(errId);
130
+ }
131
+ }
132
+ validateShowCategories(newValue) {
133
+ const errId = "ERR_showCategories";
134
+ if (!isValidBoolean(newValue)) {
135
+ this.errors.addOrReplace({
136
+ id: errId,
137
+ type: "warning",
138
+ message: "showCategories: invalid value(s) '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' are not supported.",
139
+ });
140
+ }
141
+ else {
142
+ this.errors.remove(errId);
143
+ }
144
+ }
145
+ validateMeasureScale(newValue) {
146
+ const errId = "ERR_measureScale";
147
+ if (!isValidMeasureScale(newValue)) {
148
+ this.errors.addOrReplace({
149
+ id: errId,
150
+ type: "warning",
151
+ message: "measureScale: invalid value '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' is not supported.",
152
+ });
153
+ }
154
+ else {
155
+ this.errors.remove(errId);
156
+ }
157
+ }
158
+ validateShowMeasureScale(newValue) {
159
+ const errId = "ERR_grouped";
160
+ if (!isValidBoolean(newValue)) {
161
+ this.errors.addOrReplace({
162
+ id: errId,
163
+ type: "warning",
164
+ message: "showMeasureScale: invalid value(s) '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' are not supported.",
165
+ });
166
+ }
167
+ else {
168
+ this.errors.remove(errId);
169
+ }
170
+ }
171
+ validateStack(newValue) {
172
+ const errId = "ERR_stack";
173
+ const errors = validateStackConfig(newValue);
174
+ if (errors.length > 0) {
175
+ this.errors.addOrReplace({
176
+ id: errId,
177
+ type: "warning",
178
+ message: errors.join("; "),
179
+ });
180
+ }
181
+ else {
182
+ this.errors.remove(errId);
183
+ }
184
+ }
185
+ validateScaling(newValue) {
186
+ if (newValue == null || newValue === "" || newValue === "none" || newValue === "auto") {
187
+ this.errors.remove("ERR_scale");
188
+ return;
189
+ }
190
+ const num = Number(newValue);
191
+ if (isNaN(num) || num <= 0) {
192
+ this.errors.addOrReplace({
193
+ id: "ERR_scale",
194
+ type: "warning",
195
+ message: `Invalid scale value: "${newValue}". Use "none", "auto", or a positive number.`,
196
+ });
197
+ }
198
+ else {
199
+ this.errors.remove("ERR_scale");
200
+ }
201
+ }
202
+ constructor(hostRef) {
203
+ registerInstance(this, hostRef);
204
+ this.data = [];
205
+ this.datasetMeta = null;
206
+ this.appliedScaleFactor = 1;
207
+ /**
208
+ * Title displayed above the chart. When empty, the title is derived
209
+ * from the variance scenario labels (if variances are configured).
210
+ *
211
+ * @example chart-title="Revenue by Category"
212
+ */
213
+ this.chartTitle = "";
214
+ /**
215
+ * AlaSQL WHERE clause fragment injected into the data query to filter
216
+ * rows before rendering.
217
+ *
218
+ * @example filter="rowGroup = 'Revenue'"
219
+ */
220
+ this.filter = "";
221
+ /**
222
+ * Maximum number of bars to display. Excess rows are aggregated into
223
+ * a "REST" summary bar. `0` means no limit (all rows are shown).
224
+ *
225
+ * @default 0
226
+ * @example limit="5"
227
+ */
228
+ this.limit = 0;
229
+ /**
230
+ * Whether to display category labels on the left side of the chart.
231
+ *
232
+ * Values: `"true"` | `"false"`.
233
+ *
234
+ * @default "true"
235
+ * @example show-categories="false"
236
+ */
237
+ this.showCategories = "true";
238
+ /**
239
+ * SI prefix applied to data values, dividing them for display
240
+ * (e.g. `"k"` divides by 1 000, showing 14 000 as "14").
241
+ *
242
+ * Common prefixes: `"k"` (×10³), `"M"` (×10⁶), `"G"` (×10⁹), `"T"` (×10¹²).
243
+ * Use `"_"` for no prefix (raw values).
244
+ *
245
+ * | Special value | Behavior |
246
+ * |---------------|--------------------------------------------------------------|
247
+ * | `"GREATEST"` | Auto-select prefix based on the largest value in the dataset |
248
+ * | `"LEAST"` | Auto-select prefix based on the smallest value |
249
+ *
250
+ * The selected prefix is shown in the chart footer when `show-measure-scale` is enabled.
251
+ *
252
+ * @default "greatest"
253
+ * @example measure-scale="k"
254
+ */
255
+ this.measureScale = "greatest";
256
+ /**
257
+ * Toggles display of the SI prefix and unit label in the chart footer
258
+ * (e.g. "k EUR").
259
+ *
260
+ * Values: `"true"` | `"false"`.
261
+ *
262
+ * @default "false"
263
+ * @example show-measure-scale="true"
264
+ */
265
+ this.showMeasureScale = "false";
266
+ /**
267
+ * Unit label displayed alongside the SI prefix in the chart footer
268
+ * (e.g. "EUR", "USD", "pcs"). Only visible when `show-measure-scale` is `"true"`.
269
+ *
270
+ * @default ""
271
+ * @example measure-unit="EUR"
272
+ */
273
+ this.measureUnit = "";
274
+ /**
275
+ * Stacking configuration as a JSON string. When set, bars are drawn as
276
+ * stacked segments instead of side-by-side.
277
+ *
278
+ * **Properties:**
279
+ *
280
+ * | Key | Values | Description |
281
+ * |---------|-----------------------------------------------|----------------------------------------------------|
282
+ * | `by` | `"scenarios"` \| `"dimensions"` | **Required.** What to stack. |
283
+ * | `mode` | `"absolute"` \| `"relative"` \| `"absolute-relative"` | Stacking mode. Default: `"absolute"`. |
284
+ * | `order` | `"asc"` \| `"desc"` \| `"dataset"` | Segment sort order. Default: `"dataset"`. |
285
+ *
286
+ * - `by: "scenarios"` — stacks the scenarios listed in the `scenarios` prop end-to-end.
287
+ * - `by: "dimensions"` — stacks by the next-lower hierarchy level derived from `level`
288
+ * (e.g. level `"rowGroup"` stacks by category). Only the first scenario is used;
289
+ * extra scenarios trigger a `WARN_stack_dimensions_scenarios` warning.
290
+ * - `mode: "relative"` — normalizes each bar to 100%, showing proportions.
291
+ * - `mode: "absolute-relative"` — absolute bars with percentage labels.
292
+ *
293
+ * Segment colors are configurable via the `stackColors` array in component styles.
294
+ *
295
+ * @default "" (no stacking)
296
+ * @example stack='{"by":"scenarios","mode":"absolute"}'
297
+ * @example stack='{"by":"dimensions","mode":"relative"}'
298
+ */
299
+ this.stack = "";
300
+ this.scenariosArray = [""];
301
+ this.pixelPerUnitGroupMap = new Map();
302
+ this._autoScaleGuard = false;
303
+ withStyled(this);
304
+ withComponentStatus(this);
305
+ withDataset(this, (_name, data) => {
306
+ this.data = (data || []);
307
+ }, (_name, meta) => {
308
+ this.datasetMeta = meta;
309
+ });
310
+ this.chartTemplate = this.chartTemplate.bind(this);
311
+ this.errors = withHasError(this);
312
+ this.componentStyle = withComponentStyle(this);
313
+ this.t = withTranslation(this).t;
314
+ }
315
+ componentWillLoad() {
316
+ this.validateScenario(this.scenarios);
317
+ this.validateVariances(this.variances);
318
+ this.validateUnitScaling(this.unitScaling);
319
+ //this.validateSelectedStyle(this.selectedStyle);
320
+ this.validateLevel(this.level);
321
+ this.validateOrderDirection(this.orderDirection);
322
+ this.validateOrderList(this.order);
323
+ this.validateShowCategories(this.showCategories);
324
+ this.validateMeasureScale(this.measureScale);
325
+ this.validateShowMeasureScale(this.showMeasureScale);
326
+ this.validateStack(this.stack);
327
+ this.validateScaling(this.scale);
328
+ }
329
+ componentDidRender() {
330
+ var _a, _b;
331
+ const { mode } = parseScaling(this.scale);
332
+ if (mode !== "auto" && mode !== "empty") {
333
+ this._autoScaleGuard = false;
334
+ this.checkWidthOverflow();
335
+ return;
336
+ }
337
+ if (this._autoScaleGuard) {
338
+ this._autoScaleGuard = false;
339
+ this.checkWidthOverflow();
340
+ return;
341
+ }
342
+ const host = this.element;
343
+ const { height: parentHeight } = getParentDimensions(host);
344
+ if (parentHeight <= 0) {
345
+ this.checkWidthOverflow();
346
+ return;
347
+ }
348
+ // Measure at base (unscaled) font size to get true content height
349
+ const baseFontSize = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; });
350
+ host.style.setProperty("--bn-font-size", `${baseFontSize}px`);
351
+ // Reading scrollHeight forces a synchronous reflow at base size
352
+ const div = (_a = host.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(".container");
353
+ const unscaledHeight = (_b = div === null || div === void 0 ? void 0 : div.scrollHeight) !== null && _b !== void 0 ? _b : host.scrollHeight;
354
+ if (unscaledHeight <= parentHeight + 1) {
355
+ this.errors.remove("AUTO_scale");
356
+ if (this.appliedScaleFactor !== 1) {
357
+ this._autoScaleGuard = true;
358
+ this.appliedScaleFactor = 1;
359
+ }
360
+ this.checkWidthOverflow();
361
+ return;
362
+ }
363
+ const computedFactor = (parentHeight - 1) / unscaledHeight;
364
+ host.style.setProperty("--bn-font-size", `${baseFontSize * computedFactor}px`);
365
+ if (mode === "empty") {
366
+ this.errors.addOrReplace({
367
+ id: "AUTO_scale",
368
+ type: "warning",
369
+ message: `Auto-scaled chart by factor ${computedFactor.toFixed(3)}`,
370
+ });
371
+ }
372
+ else {
373
+ this.errors.remove("AUTO_scale");
374
+ }
375
+ if (Math.abs(computedFactor - this.appliedScaleFactor) > 0.001) {
376
+ this._autoScaleGuard = true;
377
+ this.appliedScaleFactor = computedFactor;
378
+ }
379
+ this.checkWidthOverflow();
380
+ }
381
+ /**
382
+ * Emits an error when a custom unit-scaling value causes the chart to exceed its container width.
383
+ * Skipped for auto/unset unit-scaling since auto-fit handles width.
384
+ */
385
+ checkWidthOverflow() {
386
+ var _a;
387
+ const errId = "WARN_overflow";
388
+ const us = String((_a = this.unitScaling) !== null && _a !== void 0 ? _a : "")
389
+ .trim()
390
+ .toLowerCase();
391
+ if (us === "" || us === "auto") {
392
+ this.errors.remove(errId);
393
+ return;
394
+ }
395
+ const parent = getParentDimensions(this.element);
396
+ if (parent.width > 0 && this.element.scrollWidth > parent.width + 1) {
397
+ this.errors.addOrReplace({
398
+ id: errId,
399
+ type: "error",
400
+ message: `Chart exceeds available width (${this.element.scrollWidth}px > ${Math.round(parent.width)}px). Reduce unit-scaling or set to "auto".`,
401
+ });
402
+ }
403
+ else {
404
+ this.errors.remove(errId);
405
+ }
406
+ }
407
+ prepareDimension() {
408
+ const parent = getParentDimensions(this.element);
409
+ this.canvasWidthSegmented = parent.width / this.scenariosArray.length;
410
+ return { width: this.canvasWidthSegmented, height: parent.height };
411
+ }
412
+ prepareScenarios() {
413
+ var _a, _b, _c, _d;
414
+ const isAuto = ((_a = this.scenarios) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
415
+ if (isBlankInput(this.scenarios) || isAuto) {
416
+ if (((_c = (_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.availableScenarios) === null || _c === void 0 ? void 0 : _c.length) > 0) {
417
+ if (!isAuto) {
418
+ this.errors.addOrReplace({
419
+ id: "AUTO_scenarios",
420
+ type: "warning",
421
+ message: `scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`,
422
+ });
423
+ }
424
+ else {
425
+ this.errors.remove("AUTO_scenarios");
426
+ }
427
+ return this.datasetMeta.availableScenarios;
428
+ }
429
+ return [];
430
+ }
431
+ this.errors.remove("AUTO_scenarios");
432
+ return (_d = this.scenarios) === null || _d === void 0 ? void 0 : _d.split(",").map((entry) => entry.trim());
433
+ }
434
+ prepareVariances() {
435
+ var _a;
436
+ if (isBlankInput(this.variances)) {
437
+ return [];
438
+ }
439
+ return (_a = this.variances) === null || _a === void 0 ? void 0 : _a.split(",").map((entry) => entry.trim());
440
+ }
441
+ prepareHideCategories(idx) {
442
+ return idx >= 1 || this.showCategories !== "true";
443
+ }
444
+ prepareI18n() {
445
+ const i18nMetaLabelsLocal = [];
446
+ const i18nMetaLabelsGlobal = globalLabelKeys;
447
+ const i18nMapLocal = new Map(i18nMetaLabelsLocal.map((key) => [key, this.t(".".concat(key))]));
448
+ const i18nMapGlobal = new Map(i18nMetaLabelsGlobal.map((key) => [key, this.t("global.".concat(key))]));
449
+ return new Map([...i18nMapGlobal.entries(), ...i18nMapLocal.entries()]);
450
+ }
451
+ preparePixelPerUnit() {
452
+ var _a;
453
+ if (this.pixelPerUnitGroupMap.has(this.unitScaling)) {
454
+ this.errors.remove("AUTO_unitScaling");
455
+ return this.pixelPerUnitGroupMap.get(this.unitScaling);
456
+ }
457
+ // Explicit 'auto' → auto-calculate silently
458
+ if (((_a = this.unitScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
459
+ this.errors.remove("AUTO_unitScaling");
460
+ return 0;
461
+ }
462
+ const numeric = Number(this.unitScaling);
463
+ if (!isNaN(numeric) && numeric > 0) {
464
+ this.errors.remove("AUTO_unitScaling");
465
+ return numeric;
466
+ }
467
+ // Not set / invalid → auto-calculate with warning
468
+ this.errors.addOrReplace({
469
+ id: "AUTO_unitScaling",
470
+ type: "warning",
471
+ message: `unit-scaling: not set, auto-calculated to fit available space.`,
472
+ });
473
+ return 0;
474
+ }
475
+ preparePixelPerPercentage() {
476
+ if (this.pixelPerUnitGroupMap.has(this.percentageScaling)) {
477
+ return this.pixelPerUnitGroupMap.get(this.percentageScaling);
478
+ }
479
+ return Number(this.percentageScaling) * 100;
480
+ }
481
+ prepareLevel() {
482
+ var _a, _b, _c;
483
+ const isAuto = ((_a = this.level) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
484
+ if (isBlankInput(this.level) || isAuto) {
485
+ if ((_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.suggestedLevel) {
486
+ if (!isAuto) {
487
+ this.errors.addOrReplace({
488
+ id: "AUTO_level",
489
+ type: "warning",
490
+ message: `level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`,
491
+ });
492
+ }
493
+ else {
494
+ this.errors.remove("AUTO_level");
495
+ }
496
+ return AggregationLevel[this.datasetMeta.suggestedLevel.toUpperCase()];
497
+ }
498
+ return undefined;
499
+ }
500
+ this.errors.remove("AUTO_level");
501
+ return AggregationLevel[(_c = this.level) === null || _c === void 0 ? void 0 : _c.toUpperCase()];
502
+ }
503
+ prepareOrder() {
504
+ var _a, _b, _c;
505
+ const isAuto = ((_a = this.order) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
506
+ let orderStr;
507
+ if (isBlankInput(this.order) || isAuto) {
508
+ if ((_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.suggestedOrder) {
509
+ if (!isAuto) {
510
+ this.errors.addOrReplace({
511
+ id: "AUTO_order",
512
+ type: "warning",
513
+ message: `order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`,
514
+ });
515
+ }
516
+ else {
517
+ this.errors.remove("AUTO_order");
518
+ }
519
+ orderStr = this.datasetMeta.suggestedOrder;
520
+ }
521
+ else {
522
+ orderStr = this.order;
523
+ }
524
+ }
525
+ else {
526
+ this.errors.remove("AUTO_order");
527
+ orderStr = this.order;
528
+ }
529
+ const tableOrder = {
530
+ hierarchy: orderStr === null || orderStr === void 0 ? void 0 : orderStr.split(",").map((entry) => OrderColumn[entry === null || entry === void 0 ? void 0 : entry.toUpperCase()]),
531
+ direction: OrderDirection[(_c = this.orderDirection) === null || _c === void 0 ? void 0 : _c.toUpperCase()],
532
+ };
533
+ return tableOrder;
534
+ }
535
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
536
+ prepareStyle() {
537
+ const effectiveFactor = this.getEffectiveScaleFactor();
538
+ return this.componentStyle(($) => {
539
+ const baseFontSize = $["global"]["fontSizePx"];
540
+ const scaledFontSize = baseFontSize * effectiveFactor;
541
+ return {
542
+ scaleFactors: {
543
+ scenarioOffset: $["bn-chart-structure"]["scaleFactors"]["scenarioOffset"],
544
+ scenarioLabelToBar: $["bn-chart-structure"]["scaleFactors"]["scenarioLabelToBar"],
545
+ labelToBar: $["bn-chart-structure"]["scaleFactors"]["labelToBar"],
546
+ labelToAxis: $["bn-chart-structure"]["scaleFactors"]["labelToAxis"],
547
+ needleWidth: $["bn-chart-structure"]["scaleFactors"]["needleWidth"],
548
+ needleHeadWidth: $["bn-chart-structure"]["scaleFactors"]["needleHeadWidth"],
549
+ barWidth: $["bn-chart-structure"]["scaleFactors"]["barWidth"],
550
+ varianceAxisLineWidth: $["bn-chart-structure"]["scaleFactors"]["varianceAxisLineWidth"],
551
+ axisLineWidth: $["bn-chart-structure"]["scaleFactors"]["axisLineWidth"],
552
+ auxiliaryLineWidth: $["bn-chart-structure"]["scaleFactors"]["auxiliaryLineWidth"],
553
+ scenarioLineWidth: $["bn-chart-structure"]["scaleFactors"]["scenarioLineWidth"],
554
+ markerWidth: $["bn-chart-structure"]["scaleFactors"]["markerWidth"],
555
+ markerOffset: $["bn-chart-structure"]["scaleFactors"]["markerOffset"],
556
+ categoryWidth: $["bn-chart-structure"]["scaleFactors"]["categoryWidth"],
557
+ axisTickLength: $["bn-chart-structure"]["scaleFactors"]["axisTickLength"],
558
+ },
559
+ fontStyles: {
560
+ font: `${scaledFontSize}px ${$["global"]["fontFamily"]}`,
561
+ size: scaledFontSize,
562
+ color: $["global"]["fontColor"],
563
+ background: $["global"]["fontBackgroundColor"],
564
+ leading: 1.8,
565
+ },
566
+ axisStyles: $["bn-chart-structure"]["axisStyles"],
567
+ barStyles: $["bn-chart-structure"]["barStyles"],
568
+ varianceStyles: $["bn-chart-structure"]["varianceStyles"],
569
+ padding: $["bn-chart-structure"]["padding"],
570
+ pattern: null,
571
+ };
572
+ });
573
+ }
574
+ prepareChartTitle(idx) {
575
+ if (idx >= 1) {
576
+ return "";
577
+ }
578
+ return this.chartTitle;
579
+ }
580
+ prepareStackConfig() {
581
+ if (isBlankInput(this.stack)) {
582
+ this.errors.remove("WARN_stack_dimensions_scenarios");
583
+ return null;
584
+ }
585
+ try {
586
+ const parsed = JSON.parse(this.stack);
587
+ const by = parsed.by;
588
+ const errId = "WARN_stack_dimensions_scenarios";
589
+ if (by === StackBy.DIMENSIONS) {
590
+ const scenarios = this.prepareScenarios();
591
+ if (scenarios.length > 1) {
592
+ this.errors.addOrReplace({
593
+ id: errId,
594
+ type: "warning",
595
+ message: `stack by dimensions: only the first scenario "${scenarios[0]}" is used, the rest (${scenarios.slice(1).join(", ")}) are discarded.`,
596
+ });
597
+ }
598
+ else {
599
+ this.errors.remove(errId);
600
+ }
601
+ }
602
+ else {
603
+ this.errors.remove(errId);
604
+ }
605
+ return {
606
+ by,
607
+ mode: parsed.mode || StackMode.ABSOLUTE,
608
+ order: parsed.order || StackOrder.DATASET,
609
+ };
610
+ }
611
+ catch (_a) {
612
+ this.errors.remove("WARN_stack_dimensions_scenarios");
613
+ return null;
614
+ }
615
+ }
616
+ prepareFilter() {
617
+ if (this.filter.length === 0) {
618
+ return "";
619
+ }
620
+ return this.filter;
621
+ }
622
+ prepareLimit() {
623
+ return Math.floor(Number(this.limit) || 0);
624
+ }
625
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
626
+ getDataStructure() {
627
+ const dataSetStructure = {
628
+ IStructureChartDataRow: {
629
+ operation: { type: "string", isOptional: false, description: "" },
630
+ rowGroup: { type: "string", isOptional: false, description: "" },
631
+ rowGroupIndex: { type: "number", isOptional: false, description: "" },
632
+ category: { type: "string", isOptional: false, description: "" },
633
+ categoryIndex: { type: "number", isOptional: false, description: "" },
634
+ subCategory: { type: "string", isOptional: false, description: "" },
635
+ subCategoryIndex: { type: "number", isOptional: false, description: "" },
636
+ columnGroup: { type: "string", isOptional: false, description: "" },
637
+ columnGroupIndex: { type: "number", isOptional: false, description: "" },
638
+ columnSubGroup: { type: "string", isOptional: false, description: "" },
639
+ columnSubGroupIndex: { type: "number", isOptional: false, description: "" },
640
+ ac1: { type: "number", isOptional: false, description: "" },
641
+ ac2: { type: "number", isOptional: false, description: "" },
642
+ ac3: { type: "number", isOptional: false, description: "" },
643
+ ac4: { type: "number", isOptional: false, description: "" },
644
+ pp1: { type: "number", isOptional: false, description: "" },
645
+ pp2: { type: "number", isOptional: false, description: "" },
646
+ pp3: { type: "number", isOptional: false, description: "" },
647
+ pp4: { type: "number", isOptional: false, description: "" },
648
+ fc1: { type: "number", isOptional: false, description: "" },
649
+ fc2: { type: "number", isOptional: false, description: "" },
650
+ fc3: { type: "number", isOptional: false, description: "" },
651
+ fc4: { type: "number", isOptional: false, description: "" },
652
+ pl1: { type: "number", isOptional: false, description: "" },
653
+ pl2: { type: "number", isOptional: false, description: "" },
654
+ pl3: { type: "number", isOptional: false, description: "" },
655
+ pl4: { type: "number", isOptional: false, description: "" },
656
+ },
657
+ };
658
+ return dataSetStructure;
659
+ }
660
+ prepareMeasureScale() {
661
+ if (isBlankInput(this.measureScale)) {
662
+ return "GREATEST";
663
+ }
664
+ if (["_", "k", "M", "G", "T", "P", "E", "Z", "Y", "m", "μ", "n", "p", "P", "f", "a", "z", "y"].includes(this.measureScale.trim())) {
665
+ return this.measureScale.trim();
666
+ }
667
+ if (this.measureScale.trim().toUpperCase() === "LEAST") {
668
+ return this.measureScale.trim();
669
+ }
670
+ return "GREATEST";
671
+ }
672
+ prepareShowMeasureScale(idx) {
673
+ return idx === 0 && this.showMeasureScale === "true";
674
+ }
675
+ prepareMeasureUnit() {
676
+ if (this.measureUnit === "" || this.measureUnit == null) {
677
+ return "";
678
+ }
679
+ return this.measureUnit;
680
+ }
681
+ chartTemplate(localScenarioString, idx) {
682
+ const effectiveFactor = this.getEffectiveScaleFactor();
683
+ const ppu = this.preparePixelPerUnit();
684
+ const ppp = this.preparePixelPerPercentage();
685
+ const stackConfig = this.prepareStackConfig();
686
+ const scenarios = this.prepareScenarios();
687
+ // Dimension stacking uses only the first scenario
688
+ const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
689
+ return (h("ibcs-chart-structure", { data: this.data, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu > 0 ? ppu * effectiveFactor : 0, pixelPerPercentage: ppp > 0 ? ppp * effectiveFactor : 0, limit: this.prepareLimit(), styles: this.prepareStyle(), i18n: this.prepareI18n(), order: this.prepareOrder(), level: this.prepareLevel(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(idx), stackConfig: stackConfig, parentDimensions: this.prepareDimension() }));
690
+ }
691
+ getEffectiveScaleFactor() {
692
+ const { mode, factor } = parseScaling(this.scale);
693
+ if (mode === "factor")
694
+ return factor;
695
+ if (mode === "auto" || mode === "empty")
696
+ return this.appliedScaleFactor;
697
+ return 1;
698
+ }
699
+ getFontStyles() {
700
+ const effectiveFactor = this.getEffectiveScaleFactor();
701
+ return this.componentStyle(($) => {
702
+ var _a, _b, _c, _d;
703
+ const baseFontSize = ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333;
704
+ return {
705
+ "--bn-font-family": ((_b = $["global"]) === null || _b === void 0 ? void 0 : _b["fontFamily"]) || "'Noto Sans', sans-serif",
706
+ "--bn-font-size": `${baseFontSize * effectiveFactor}px`,
707
+ "--bn-font-color": ((_c = $["global"]) === null || _c === void 0 ? void 0 : _c["fontColor"]) || "#000000",
708
+ "--bn-font-background": ((_d = $["global"]) === null || _d === void 0 ? void 0 : _d["fontBackgroundColor"]) || "#ffffff",
709
+ };
710
+ });
711
+ }
712
+ render() {
713
+ let scenariosArray = [""];
714
+ const variancesArray = this.prepareVariances();
715
+ if (variancesArray.length > 0) {
716
+ scenariosArray = [...scenariosArray, ...variancesArray];
717
+ }
718
+ const fontStyles = this.getFontStyles();
719
+ return (h(Host, { key: '570fb741ddf481be0f3055d346314ad39a455361', style: fontStyles }, h("div", { key: 'e84cfe2e00dd2f960f038844e00449431efa6ce0', class: "container" }, scenariosArray.map(this.chartTemplate))));
720
+ }
721
+ get element() { return getElement(this); }
722
+ static get watchers() { return {
723
+ "scenarios": [{
724
+ "validateScenario": 0
725
+ }],
726
+ "variances": [{
727
+ "validateVariances": 0
728
+ }],
729
+ "unitScaling": [{
730
+ "validateUnitScaling": 0
731
+ }],
732
+ "percentageScaling": [{
733
+ "validatePercentageScaling": 0
734
+ }],
735
+ "level": [{
736
+ "validateLevel": 0
737
+ }],
738
+ "order": [{
739
+ "validateOrderList": 0
740
+ }],
741
+ "orderDirection": [{
742
+ "validateOrderDirection": 0
743
+ }],
744
+ "limit": [{
745
+ "validateLimit": 0
746
+ }],
747
+ "showCategories": [{
748
+ "validateShowCategories": 0
749
+ }],
750
+ "measureScale": [{
751
+ "validateMeasureScale": 0
752
+ }],
753
+ "showMeasureScale": [{
754
+ "validateShowMeasureScale": 0
755
+ }],
756
+ "stack": [{
757
+ "validateStack": 0
758
+ }],
759
+ "scale": [{
760
+ "validateScaling": 0
761
+ }]
762
+ }; }
763
+ };
764
+ Chart.style = bnChartStructureCss$1();
765
+
766
+ const bnContextCss = () => `:host{display:block}`;
767
+
768
+ const Context = class {
769
+ constructor(hostRef) {
770
+ registerInstance(this, hostRef);
771
+ this.currentPageUpdate = undefined;
772
+ withComponentStatus(this);
773
+ this.errors = withHasError(this);
774
+ }
775
+ setLocale(newValue) {
776
+ this.stores.context.state.locale = newValue;
777
+ }
778
+ connectedCallback() {
779
+ // Retrieve (or create) the stores for this context element.
780
+ // A descendant component may have already triggered creation via
781
+ // getStores() if Stencil initialized it before this component.
782
+ this.stores = getOrCreateStores(this.element);
783
+ if (this.locale) {
784
+ this.stores.context.state.locale = this.locale;
785
+ }
786
+ this.currentPageUpdate = setTimeout(() => {
787
+ this.element.querySelectorAll("bn-page, bn-layout-page").forEach((page, index) => {
788
+ if (page.localName === "bn-layout-page") {
789
+ page.setAttribute("page-number", (index + 1).toString());
790
+ }
791
+ else {
792
+ const footer = page.querySelector("bn-footer");
793
+ if (footer) {
794
+ // @ts-ignore
795
+ footer.setAttribute("page-number", (index + 1).toString());
796
+ }
797
+ }
798
+ });
799
+ }, 250);
800
+ }
801
+ disconnectedCallback() {
802
+ if (this.currentPageUpdate) {
803
+ clearTimeout(this.currentPageUpdate);
804
+ }
805
+ }
806
+ componentWillLoad() {
807
+ // stencil needs one componenet implementing all lifecycle steps to get mixing working
808
+ }
809
+ componentDidLoad() { }
810
+ componentShouldUpdate() { }
811
+ componentWillRender() { }
812
+ componentDidRender() { }
813
+ componentWillUpdate() { }
814
+ componentDidUpdate() { }
815
+ render() {
816
+ return (h(Host, { key: 'b92019b909e271225baca2cf740c8301e324164e' }, h("slot", { key: '87bac4bb29bca32d961afe31355dc1bd48fff0f8' })));
817
+ }
818
+ get element() { return getElement(this); }
819
+ static get watchers() { return {
820
+ "locale": [{
821
+ "setLocale": 0
822
+ }]
823
+ }; }
824
+ };
825
+ Context.style = bnContextCss();
826
+
827
+ const bnDatasourceCss = () => `bn-datasource{display:none}`;
828
+
829
+ const Datasource = class {
830
+ constructor(hostRef) {
831
+ registerInstance(this, hostRef);
832
+ /**
833
+ * When true (default), body content is plain JSON text.
834
+ * When false, body content is a compressed payload (`<hash>:<base64_gzip>`).
835
+ */
836
+ this.raw = true;
837
+ this.lastHash = null;
838
+ withComponentStatus(this);
839
+ this.errors = withHasError(this);
840
+ withBodyObserver(this, (data) => {
841
+ if (!this.stores)
842
+ this.stores = getStores(this.element);
843
+ try {
844
+ let contentHash;
845
+ let jsonString;
846
+ if (this.raw) {
847
+ contentHash = computeContentHash(data);
848
+ jsonString = data;
849
+ }
850
+ else {
851
+ const decoded = decodeCompressedContent(data);
852
+ contentHash = decoded.hash;
853
+ jsonString = decoded.json;
854
+ }
855
+ if (contentHash === this.lastHash)
856
+ return;
857
+ this.lastHash = contentHash;
858
+ const json = JSON.parse(jsonString);
859
+ // @ts-ignore
860
+ this.stores.datasources.set(this.name, json);
861
+ }
862
+ catch (e) {
863
+ console.error("Error parsing datasource", e, String(data).slice(0, 200));
864
+ // @ts-ignore
865
+ this.stores.datasources.set(this.name, []);
866
+ }
867
+ });
868
+ }
869
+ render() {
870
+ return h(Host, { key: '43b691b07f63d12ad6c835dfb5d5bf6053b3bbf4' });
871
+ }
872
+ get element() { return getElement(this); }
873
+ };
874
+ Datasource.style = bnDatasourceCss();
875
+
876
+ const bnPageCss = () => `:host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);height:768px;width:1024px;display:flex;flex-direction:column;page-break-after:always;overflow:hidden}:host([format=xga]){height:768px;width:1024px}:host([format=xga][orientation=portrait]){height:1024px;width:768px}:host([format=xga][orientation=landscape]){height:768px;width:1024px}:host([format=hd]){height:720px;width:1280px}:host([format=hd][orientation=portrait]){height:1280px;width:720px}:host([format=hd][orientation=landscape]){height:720px;width:1280px}:host([format=full_hd]){height:1080px;width:1920px}:host([format=full_hd][orientation=portrait]){height:1920px;width:1080px}:host([format=full_hd][orientation=landscape]){height:1080px;width:1920px}:host([format="4k"]){height:2160px;width:3840px}:host([format="4k"][orientation=portrait]){height:3840px;width:2160px}:host([format="4k"][orientation=landscape]){height:2160px;width:3840px}:host([format="4k2k"]){height:2160px;width:4096px}:host([format="4k2k"][orientation=portrait]){height:4096px;width:2160px}:host([format="4k2k"][orientation=landscape]){height:2160px;width:4096px}:host([format=a6]){height:5.83in;width:4.13in}:host([format=a6][orientation=portrait]){height:5.83in;width:4.13in}:host([format=a6][orientation=landscape]){height:4.13in;width:5.83in}:host([format=a5]){height:8.27in;width:5.83in}:host([format=a5][orientation=portrait]){height:8.27in;width:5.83in}:host([format=a5][orientation=landscape]){height:5.83in;width:8.27in}:host([format=a4]){height:11.6in;width:8.17in}:host([format=a4][orientation=portrait]){height:11.6in;width:8.17in}:host([format=a4][orientation=landscape]){height:8.17in;width:11.6in}:host([format=a3]){height:16.54in;width:11.7in}:host([format=a3][orientation=portrait]){height:16.54in;width:11.7in}:host([format=a3][orientation=landscape]){height:11.7in;width:16.54in}:host([format=a2]){height:23.4in;width:16.54in}:host([format=a2][orientation=portrait]){height:23.4in;width:16.54in}:host([format=a2][orientation=landscape]){height:16.54in;width:23.4in}:host([format=a1]){height:33.1in;width:23.4in}:host([format=a1][orientation=portrait]){height:33.1in;width:23.4in}:host([format=a1][orientation=landscape]){height:23.4in;width:33.1in}:host([format=a0]){height:46.8in;width:33.1in}:host([format=a0][orientation=portrait]){height:46.8in;width:33.1in}:host([format=a0][orientation=landscape]){height:33.1in;width:46.8in}:host([format=letter]){height:11in;width:8.5in}:host([format=letter][orientation=portrait]){height:11in;width:8.5in}:host([format=letter][orientation=landscape]){height:8.5in;width:11in}:host([format=legal]){height:14in;width:8.5in}:host([format=legal][orientation=portrait]){height:14in;width:8.5in}:host([format=legal][orientation=landscape]){height:8.5in;width:14in}:host([format=tabloid]){height:17in;width:11in}:host([format=tabloid][orientation=portrait]){height:17in;width:11in}:host([format=tabloid][orientation=landscape]){height:11in;width:17in}:host([format=ledger]){height:11in;width:17in}:host([format=ledger][orientation=portrait]){height:17in;width:11in}:host([format=ledger][orientation=landscape]){height:11in;width:17in}`;
877
+
878
+ const VALID_FORMATS = ["xga", "hd", "full-hd", "4k", "4k2k", "a4", "a3", "a2", "a1", "a0", "letter", "legal"];
879
+ const VALID_ORIENTATIONS = ["landscape", "portrait"];
880
+ const Page = class {
881
+ constructor(hostRef) {
882
+ registerInstance(this, hostRef);
883
+ withComponentStatus(this);
884
+ this.errors = withHasError(this);
885
+ this.componentStyle = withComponentStyle(this);
886
+ }
887
+ validateFormat(newValue) {
888
+ const errId = "ERR_format";
889
+ if (!isBlankInput(newValue) && !VALID_FORMATS.includes(newValue)) {
890
+ this.errors.addOrReplace({
891
+ id: errId,
892
+ type: "warning",
893
+ message: `format: invalid value '${newValue}' is not supported. Valid values: ${VALID_FORMATS.join(", ")}`,
894
+ });
895
+ }
896
+ else {
897
+ this.errors.remove(errId);
898
+ }
899
+ }
900
+ validateOrientation(newValue) {
901
+ const errId = "ERR_orientation";
902
+ if (!isBlankInput(newValue) && !VALID_ORIENTATIONS.includes(newValue)) {
903
+ this.errors.addOrReplace({
904
+ id: errId,
905
+ type: "warning",
906
+ message: `orientation: invalid value '${newValue}' is not supported. Valid values: ${VALID_ORIENTATIONS.join(", ")}`,
907
+ });
908
+ }
909
+ else {
910
+ this.errors.remove(errId);
911
+ }
912
+ }
913
+ render() {
914
+ return (h(Host, { key: 'b4d682a8f6e83f77c58236265eaf9d1327809c6f', format: this.format, orientation: this.orientation, style: this.prepareStyle() }, h("slot", { key: 'ef49c43c1f8926c4c968b752608627adbe330d6c' })));
915
+ }
916
+ prepareStyle() {
917
+ const pageStyle = {
918
+ "font-family": this.componentStyle(($) => $.global["fontFamily"]),
919
+ "font-size": `${this.componentStyle(($) => $.global["fontSizePx"])}px`,
920
+ "--bn-font-family": this.componentStyle(($) => $.global["fontFamily"]) || "'Noto Sans', sans-serif",
921
+ "--bn-font-size": `${this.componentStyle(($) => $.global["fontSizePx"]) || 13.3333}px`,
922
+ "--bn-font-color": this.componentStyle(($) => $.global["fontColor"]) || "#000000",
923
+ "--bn-font-background": this.componentStyle(($) => $.global["fontBackgroundColor"]) || "#ffffff",
924
+ };
925
+ return pageStyle;
926
+ }
927
+ get element() { return getElement(this); }
928
+ static get watchers() { return {
929
+ "format": [{
930
+ "validateFormat": 0
931
+ }],
932
+ "orientation": [{
933
+ "validateOrientation": 0
934
+ }]
935
+ }; }
936
+ };
937
+ Page.style = bnPageCss();
938
+
10
939
  /**
11
940
  * Spatial layout engine for the structure chart (horizontal bars).
12
941
  *
@@ -679,6 +1608,7 @@ class StructureChartStyle {
679
1608
  this.varianceStyles = varianceStyles;
680
1609
  this.padding = padding;
681
1610
  this.pattern = new Map();
1611
+ this.stackColors = ["#000000", "#c0c0c0", "#808080"];
682
1612
  }
683
1613
  }
684
1614
  /** Adapts raw componentStyle JSON into a StructureChartStyle, falling back to defaults for missing properties. */
@@ -711,6 +1641,9 @@ class StructureChartStylesAdapter {
711
1641
  if (CompareUtil.isExisting(data.padding)) {
712
1642
  styles.padding = this.paddingadapter.adapt(data.padding);
713
1643
  }
1644
+ if (Array.isArray(data.stackColors) && data.stackColors.length > 0) {
1645
+ styles.stackColors = data.stackColors;
1646
+ }
714
1647
  styles.pattern = new MarkerPattern(styles.fontStyles.size).createPatternMapForStructureBar();
715
1648
  }
716
1649
  return styles;
@@ -888,6 +1821,7 @@ class Label {
888
1821
  constructor(parent, xPosition, yPosition, groupPrefix, value, styles, verticalHookLocation, horizontalHookLocation) {
889
1822
  this.group = null;
890
1823
  this.segmentFillColor = null;
1824
+ this.maxWidth = null;
891
1825
  this.ID_SCENARIOLABEL = "Label";
892
1826
  this.CSS_CATEGORIES = "categories";
893
1827
  this.x = xPosition;
@@ -915,6 +1849,10 @@ class Label {
915
1849
  this.segmentFillColor = color;
916
1850
  return this;
917
1851
  }
1852
+ setMaxWidth(width) {
1853
+ this.maxWidth = width;
1854
+ return this;
1855
+ }
918
1856
  updateGroup(newGroup) {
919
1857
  this.group = newGroup;
920
1858
  return this;
@@ -923,6 +1861,7 @@ class Label {
923
1861
  return prefix + "_" + groupPrefix + "_" + this.ID_SCENARIOLABEL;
924
1862
  }
925
1863
  draw(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
1864
+ var _a;
926
1865
  if (this.isEmpty()) {
927
1866
  return this;
928
1867
  }
@@ -960,6 +1899,11 @@ class Label {
960
1899
  text.move(this.x, this.y);
961
1900
  const boxWidth = text.bbox().w;
962
1901
  const boxHeight = text.bbox().h;
1902
+ if (this.maxWidth != null && boxWidth > this.maxWidth) {
1903
+ (_a = this.group) === null || _a === void 0 ? void 0 : _a.remove();
1904
+ this.group = null;
1905
+ return this;
1906
+ }
963
1907
  if (this.horizontalHookLocation === HookLocation.Right) {
964
1908
  labelAnchor = "end";
965
1909
  text.move(text.x() - text.length(), text.y());
@@ -1636,26 +2580,29 @@ class StackedBar {
1636
2580
  xPos = axisX + baselinePixels;
1637
2581
  }
1638
2582
  const yPos = this.position.getBarPositionY(this.index, true);
1639
- // Unified IBCS 3-color palette for all stacking modes
1640
- const fillColor = getStackFill(this.segmentIndex);
2583
+ const colors = this.styles.stackColors;
2584
+ const fillColor = colors[this.segmentIndex % colors.length];
1641
2585
  const fillStyle = { color: fillColor };
1642
- const strokeStyle = { color: getStackStroke(this.segmentIndex), width: 0.5 };
2586
+ const strokeStyle = { color: fillColor, width: 0.5 };
1643
2587
  this.barGroup.rect(Math.max(segmentLength, 0.5), barWidth).fill(fillStyle).stroke(strokeStyle).cy(yPos).x(xPos);
1644
2588
  // Draw segment value label centered on bar if wide enough
1645
- const MIN_SEGMENT_WIDTH_FOR_LABEL = 30;
1646
- if (segmentLength >= MIN_SEGMENT_WIDTH_FOR_LABEL) {
2589
+ const LABEL_PADDING = 6;
2590
+ const availableWidth = segmentLength - LABEL_PADDING;
2591
+ if (availableWidth > 0) {
1647
2592
  const labelX = xPos + segmentLength / 2;
1648
2593
  if (this.stackMode === StackMode.RELATIVE || this.stackMode === StackMode.ABSOLUTE_RELATIVE) {
1649
2594
  const pct = this.totalValue !== 0 ? (value / this.totalValue) * 100 : 0;
1650
2595
  const labelValue = pct.toFixed(dataFormatDigits.percent) + "%";
1651
2596
  new Label(this.group, labelX, yPos, "STACK_SEG", labelValue, this.styles, HookLocation.Center, HookLocation.Center)
1652
2597
  .setSegmentFill(fillColor)
2598
+ .setMaxWidth(availableWidth)
1653
2599
  .draw();
1654
2600
  }
1655
2601
  else {
1656
2602
  // Pass raw numeric value — Label.draw() formats with measureScale
1657
2603
  new Label(this.group, labelX, yPos, "STACK_SEG", value, this.styles, HookLocation.Center, HookLocation.Center)
1658
2604
  .setSegmentFill(fillColor)
2605
+ .setMaxWidth(availableWidth)
1659
2606
  .draw(dataFormatDigits, measureScale);
1660
2607
  }
1661
2608
  }
@@ -1835,6 +2782,7 @@ class StructureChart {
1835
2782
  this.dataFormatDigits = { percent: 2, decimal: 1 };
1836
2783
  this.stackConfig = null;
1837
2784
  this.overflowConfig = null;
2785
+ this.highestStackedTotal = 0;
1838
2786
  this.initSQLFunctions();
1839
2787
  this.ruleSet = ruleSet || new IBCSRuleSet();
1840
2788
  this.i18n = this.createI18n(new Map());
@@ -1873,7 +2821,7 @@ class StructureChart {
1873
2821
  this.setData([...config.data], config.filter);
1874
2822
  this.dataModel = this.populateModel(config.scenarios, config.level, config.sortOrder);
1875
2823
  // Populate per-dimension stack segments when stacking by a data dimension
1876
- if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIO) {
2824
+ if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIOS) {
1877
2825
  this.populateDimensionStackSegments(config.scenarios, config.stackConfig, config.level);
1878
2826
  }
1879
2827
  this.variancesDataModel = this.populateVarianceModel(config.variances, this.dataModel);
@@ -1887,6 +2835,7 @@ class StructureChart {
1887
2835
  this.measureUnit = config.measureUnit;
1888
2836
  this.dataFormatDigits = config.dataFormatDigits;
1889
2837
  this.stackConfig = config.stackConfig;
2838
+ this.highestStackedTotal = this.findHighestStackedRowTotal(this.dataModel);
1890
2839
  this.updatePosition();
1891
2840
  }
1892
2841
  sortScenariosbyVisualisationRules(config) {
@@ -1976,6 +2925,30 @@ class StructureChart {
1976
2925
  this.preparedDataSet = data;
1977
2926
  }
1978
2927
  }
2928
+ /**
2929
+ * Returns the data value whose bar extent is proportional to pixelPerUnit.
2930
+ * Used by autoFitScaling to separate fixed vs variable width components.
2931
+ */
2932
+ getMaxBarValue() {
2933
+ var _a, _b;
2934
+ // Stacked: bar extent = highestStackedTotal * ppu (or just ppu for relative)
2935
+ if (this.stackConfig != null && this.highestStackedTotal > 0) {
2936
+ if (this.stackConfig.mode === StackMode.RELATIVE) {
2937
+ return 1;
2938
+ }
2939
+ return this.highestStackedTotal;
2940
+ }
2941
+ // Non-stacked: bar extent = highestDataPointValue * ppu
2942
+ const vt = this.getVarianceType();
2943
+ if (vt === VarianceType.NONE && ((_a = this.highestDataPointValue) === null || _a === void 0 ? void 0 : _a.value) != null) {
2944
+ return Math.abs(this.highestDataPointValue.value);
2945
+ }
2946
+ if (vt === VarianceType.ABSOLUTE && ((_b = this.highestVarianceDataPointValue) === null || _b === void 0 ? void 0 : _b.value) != null) {
2947
+ return Math.abs(this.highestVarianceDataPointValue.value);
2948
+ }
2949
+ // RELATIVE variance depends on pixelPerPercentage, not pixelPerUnit
2950
+ return 0;
2951
+ }
1979
2952
  getAllocatedCanvasWidth() {
1980
2953
  //let columnLabelWidth = this.calculateCategoryWidth();
1981
2954
  const leftSideWidth = this.position.getAxisPositionX(); //this.calculateLeftSideWidth(this.getVarianceType());
@@ -2226,6 +3199,48 @@ class StructureChart {
2226
3199
  }
2227
3200
  return highestDataPoint;
2228
3201
  }
3202
+ findHighestStackedRowTotal(dataModel) {
3203
+ if (!this.stackConfig || dataModel.length === 0)
3204
+ return 0;
3205
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
3206
+ let maxTotal = 0;
3207
+ for (const row of dataModel) {
3208
+ let rowTotal = 0;
3209
+ if (isScenarioStack) {
3210
+ const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
3211
+ const segments = [];
3212
+ for (const key of scenarioKeys) {
3213
+ const dp = row[key];
3214
+ if (dp && !dp.isEmpty() && dp.value != null) {
3215
+ segments.push({ value: dp.value, scenario: dp.scenario });
3216
+ }
3217
+ }
3218
+ const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
3219
+ if (prefixes.size > 1) {
3220
+ // Overlay: groups overlap from baseline, width = max group total
3221
+ const groupMap = new Map();
3222
+ for (const seg of segments) {
3223
+ const prefix = getScenarioPrefix(seg.scenario);
3224
+ groupMap.set(prefix, (groupMap.get(prefix) || 0) + Math.abs(seg.value));
3225
+ }
3226
+ rowTotal = Math.max(...groupMap.values());
3227
+ }
3228
+ else {
3229
+ // Single group: segments stack end-to-end, width = sum
3230
+ rowTotal = segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
3231
+ }
3232
+ }
3233
+ else {
3234
+ // Dimension stacking: use stackSegments
3235
+ if (row.stackSegments && row.stackSegments.length > 0) {
3236
+ rowTotal = row.stackSegments.reduce((sum, s) => sum + Math.abs(s.value), 0);
3237
+ }
3238
+ }
3239
+ if (rowTotal > maxTotal)
3240
+ maxTotal = rowTotal;
3241
+ }
3242
+ return maxTotal;
3243
+ }
2229
3244
  populateVarianceModel(variancesConfig, dataModel) {
2230
3245
  const varianceModel = [];
2231
3246
  if (variancesConfig.length === 0) {
@@ -2373,7 +3388,7 @@ class StructureChart {
2373
3388
  if (!this.stackConfig)
2374
3389
  return;
2375
3390
  const stackGroup = svgContainer.group().id("StackedScenarios");
2376
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIO;
3391
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
2377
3392
  dataModel.forEach((elements, index) => {
2378
3393
  const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
2379
3394
  const segments = [];
@@ -2474,7 +3489,7 @@ class StructureChart {
2474
3489
  drawStackedHeaders(dataModel, svgContainer) {
2475
3490
  if (!this.stackConfig || dataModel.length === 0)
2476
3491
  return;
2477
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIO;
3492
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
2478
3493
  const headerGroup = svgContainer.group().id("StackedHeaders");
2479
3494
  const firstRow = dataModel[0];
2480
3495
  // Dimension stacking: use stackSegments from first row for headers
@@ -2609,6 +3624,20 @@ class StructureChart {
2609
3624
  }
2610
3625
  calculateRightSideWidth(varianceType) {
2611
3626
  var _a, _b, _c;
3627
+ // Stacked charts: width based on max row total, not individual max
3628
+ if (this.stackConfig != null && this.highestStackedTotal > 0) {
3629
+ const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
3630
+ let barExtent;
3631
+ if (this.stackConfig.mode === StackMode.RELATIVE) {
3632
+ barExtent = this.pixelPerUnit;
3633
+ }
3634
+ else {
3635
+ barExtent = this.highestStackedTotal * this.pixelPerUnit;
3636
+ }
3637
+ const sizeTotalLabel = this.calculateTextBoxWidth(this.highestStackedTotal);
3638
+ const width = barExtent + labelToBar + sizeTotalLabel;
3639
+ return Math.max(width, this.titleLength);
3640
+ }
2612
3641
  let width = 0;
2613
3642
  const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
2614
3643
  if (VarianceType.NONE === varianceType &&
@@ -2638,19 +3667,20 @@ class StructureChart {
2638
3667
  * For dimension stacking (by category, subcategory, or rowgroup), query the raw data
2639
3668
  * at the stack dimension level and attach stackSegments to each dataModel row.
2640
3669
  */
2641
- populateDimensionStackSegments(scenarios, stackConfig, level) {
3670
+ populateDimensionStackSegments(scenarios, _stackConfig, level) {
2642
3671
  var _a;
2643
3672
  if (((_a = this.preparedDataSet) === null || _a === void 0 ? void 0 : _a.length) === 0 || scenarios.length === 0)
2644
3673
  return;
2645
- // Map StackBy value to the actual data column name
2646
- const stackColumnMap = {
2647
- [StackBy.CATEGORY]: "category",
2648
- [StackBy.SUBCATEGORY]: "subCategory",
2649
- [StackBy.ROWGROUP]: "rowGroup",
3674
+ // Derive stack column from level: stack by the next-lower hierarchy dimension
3675
+ const nextLowerDimension = {
3676
+ [AggregationLevel.ROWGROUP]: "category",
3677
+ [AggregationLevel.ROWGROUPINDEX]: "category",
3678
+ [AggregationLevel.CATEGORY]: "subCategory",
3679
+ [AggregationLevel.CATEGORYINDEX]: "subCategory",
2650
3680
  };
2651
- const stackColumn = stackColumnMap[stackConfig.by];
3681
+ const stackColumn = nextLowerDimension[level];
2652
3682
  if (!stackColumn)
2653
- return;
3683
+ return; // subCategory has no lower dimension
2654
3684
  // The display level column (what each bar represents)
2655
3685
  const displayColumn = level.toString(); // e.g. 'rowGroup', 'category', 'subCategory'
2656
3686
  const scenario = scenarios[0]; // dimension stacking uses first scenario
@@ -2837,7 +3867,7 @@ const IbcsChartStructure = class {
2837
3867
  this.chart.setI18n(this.i18n);
2838
3868
  return;
2839
3869
  }
2840
- // First pass with pixelPerUnit=1 to measure the real SVG width
3870
+ // First pass with pixelPerUnit=1 to measure total width and bar extent
2841
3871
  config.pixelPerUnit = 1;
2842
3872
  this.chart = new StructureChart(new IBCSRuleSet(), config, styles);
2843
3873
  this.chart.setI18n(this.i18n);
@@ -2846,8 +3876,18 @@ const IbcsChartStructure = class {
2846
3876
  if (svgWidth <= 0) {
2847
3877
  return;
2848
3878
  }
2849
- // Scale so the chart fits in ~90% of the available width
2850
- config.pixelPerUnit = (targetWidth * 0.9) / svgWidth;
3879
+ // Separate fixed parts (labels, padding, spacing) from variable part (bar extent).
3880
+ // totalWidth(ppu) = fixedWidth + maxBarValue * ppu
3881
+ // Solving for ppu: ppu = (targetWidth - fixedWidth) / maxBarValue
3882
+ const maxBarValue = this.chart.getMaxBarValue();
3883
+ if (maxBarValue > 0) {
3884
+ const fixedWidth = svgWidth - maxBarValue; // at ppu=1, barExtent = maxBarValue * 1
3885
+ config.pixelPerUnit = Math.max(0.001, (targetWidth - fixedWidth) / maxBarValue);
3886
+ }
3887
+ else {
3888
+ // Fallback (e.g. relative variance charts)
3889
+ config.pixelPerUnit = (targetWidth * 0.9) / svgWidth;
3890
+ }
2851
3891
  // Second pass with the corrected scaling
2852
3892
  this.chart = new StructureChart(new IBCSRuleSet(), config, styles);
2853
3893
  this.chart.setI18n(this.i18n);
@@ -2899,4 +3939,4 @@ const IbcsChartStructure = class {
2899
3939
  };
2900
3940
  IbcsChartStructure.style = bnChartStructureCss();
2901
3941
 
2902
- export { IbcsChartStructure as ibcs_chart_structure };
3942
+ export { Chart as bn_chart_structure, Context as bn_context, Datasource as bn_datasource, Page as bn_page, IbcsChartStructure as ibcs_chart_structure };