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

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 (195) 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-4426d484.entry.js +1 -0
  7. package/dist/bn-template-engine/p-51f8dc9e.entry.js +1 -0
  8. package/dist/bn-template-engine/p-53d4e690.entry.js +1 -0
  9. package/dist/bn-template-engine/p-5KQYRQLK.js +1 -0
  10. package/dist/bn-template-engine/p-745f4596.entry.js +1 -0
  11. package/dist/bn-template-engine/{p-0f1504f3.entry.js → p-75e97c87.entry.js} +1 -1
  12. package/dist/bn-template-engine/p-7a560278.entry.js +1 -0
  13. package/dist/bn-template-engine/p-7ea7c325.entry.js +1 -0
  14. package/dist/bn-template-engine/p-945cc95d.entry.js +1 -0
  15. package/dist/bn-template-engine/p-BYBpC0EO.js +1 -0
  16. package/dist/bn-template-engine/p-BfXY5dsy.js +1 -0
  17. package/dist/bn-template-engine/p-BgnHJQ9Q.js +1 -0
  18. package/dist/bn-template-engine/{p-B4ySv9KQ.js → p-Bhd_WSML.js} +1 -1
  19. package/dist/bn-template-engine/p-Bka-Z6jo.js +1 -0
  20. package/dist/bn-template-engine/p-Bnhh02CF.js +1 -0
  21. package/dist/bn-template-engine/p-C7dQL8CS.js +1 -0
  22. package/dist/bn-template-engine/p-CL1RYuNU.js +1 -0
  23. package/dist/bn-template-engine/p-CYwd_ZNM.js +1 -0
  24. package/dist/bn-template-engine/p-ChlK-T9I.js +1 -0
  25. package/dist/bn-template-engine/p-DHezf8pZ.js +1 -0
  26. package/dist/bn-template-engine/{p-DVMu6dEy.js → p-DlppAFq9.js} +1 -1
  27. package/dist/bn-template-engine/p-DvDDgmcV.js +1 -0
  28. package/dist/bn-template-engine/p-DvvwfRQG.js +1 -0
  29. package/dist/bn-template-engine/{p-DG-1MR_T.js → p-P7pGJBgc.js} +1 -1
  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} +1058 -28
  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 +979 -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/StackedBar.js +3 -4
  82. package/dist/collection/components/bn-chart-structure/utils/model/styles/StructureChartStyle.js +4 -0
  83. package/dist/collection/components/bn-chart-time/bn-chart-time.js +28 -4
  84. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +3 -3
  85. package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +3 -4
  86. package/dist/collection/components/bn-chart-time/utils/model/styles/TimeChartStyle.js +4 -0
  87. package/dist/collection/components/bn-dataset/bn-dataset.js +49 -2
  88. package/dist/collection/components/bn-datasource/bn-datasource.js +46 -3
  89. package/dist/collection/components/bn-table/bn-table.js +9 -12
  90. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +58 -41
  91. package/dist/collection/stores/componentStyles.js +2 -0
  92. package/dist/collection/utils/constants.js +8 -5
  93. package/dist/collection/utils/contentDecoder.js +28 -0
  94. package/dist/collection/utils/stackColors.js +2 -2
  95. package/dist/collection/utils/validate.js +1 -1
  96. package/dist/components/DataFormatDigits.js +1 -1
  97. package/dist/components/Order.js +1 -1
  98. package/dist/components/SVGVariancesStyleGroup.js +1 -1
  99. package/dist/components/bn-chart-structure.js +1 -1
  100. package/dist/components/bn-chart-time.js +1 -1
  101. package/dist/components/bn-dataset.js +1 -1
  102. package/dist/components/bn-datasource.js +1 -1
  103. package/dist/components/bn-table.js +1 -1
  104. package/dist/components/contentDecoder.js +1 -0
  105. package/dist/components/context-protocol.js +1 -1
  106. package/dist/components/emotion-hash.esm.js +1 -0
  107. package/dist/components/ibcs-chart-structure2.js +1 -1
  108. package/dist/components/ibcs-chart-time2.js +1 -1
  109. package/dist/components/ibcs-table2.js +1 -1
  110. package/dist/components/ibcs-title2.js +1 -1
  111. package/dist/components/ibcsRuleSet.js +1 -1
  112. package/dist/components/validate.js +1 -1
  113. package/dist/components/withStyled.js +1 -1
  114. package/dist/esm/{DataFormatDigits--qIbKvXa.js → DataFormatDigits-oSZ1hBKE.js} +1 -1
  115. package/dist/esm/{DateStringFactory-XWdUjsn8.js → DateStringFactory-CSGz6TDk.js} +1 -1
  116. package/dist/esm/{Order-sqjrku2z.js → Order-Bnhh02CF.js} +9 -6
  117. package/dist/esm/{SVGVariancesStyleGroup-ibg3sLjM.js → SVGVariancesStyleGroup-CqTjrZYg.js} +2 -13
  118. package/dist/esm/bn-asset.entry.js +5 -4
  119. package/dist/esm/bn-body_4.entry.js +11 -9
  120. package/dist/esm/bn-card.entry.js +5 -4
  121. package/dist/esm/{ibcs-chart-structure.entry.js → bn-chart-structure_5.entry.js} +1048 -22
  122. package/dist/esm/bn-chart-time.entry.js +38 -12
  123. package/dist/esm/bn-component-style.entry.js +5 -4
  124. package/dist/esm/bn-dataset.entry.js +35 -6
  125. package/dist/esm/bn-grid.entry.js +9 -7
  126. package/dist/esm/bn-image.entry.js +9 -7
  127. package/dist/esm/bn-internationalization.entry.js +5 -4
  128. package/dist/esm/bn-layout-card.entry.js +3 -2
  129. package/dist/esm/bn-layout-page.entry.js +2 -1
  130. package/dist/esm/bn-message.entry.js +5 -4
  131. package/dist/esm/bn-table.entry.js +977 -0
  132. package/dist/esm/bn-template-engine.js +1 -1
  133. package/dist/esm/bn-template.entry.js +3 -2
  134. package/dist/esm/bn-text.entry.js +11 -9
  135. package/dist/esm/bn-tree.entry.js +9 -7
  136. package/dist/esm/contentDecoder-oMmxz6nJ.js +416 -0
  137. package/dist/esm/{context-protocol-Bz5klD-F.js → context-protocol-BHnQsVsr.js} +2 -0
  138. package/dist/esm/editor-companion.entry.js +1 -1
  139. package/dist/esm/emotion-hash.esm-BYBpC0EO.js +55 -0
  140. package/dist/esm/ibcs-chart-time.entry.js +15 -11
  141. package/dist/esm/{bn-context_5.entry.js → ibcs-table.entry.js} +68 -1235
  142. package/dist/esm/{StringAdapter-BCLJpQQ8.js → ibcsRuleSet-K4ytuA1f.js} +10 -10
  143. package/dist/esm/index-DHezf8pZ.js +65 -0
  144. package/dist/esm/loader.js +1 -1
  145. package/dist/esm/{scaling-C6K8FYSF.js → scaling-Cehc74IE.js} +2 -2
  146. package/dist/esm/{withHasError-B3QX2emi.js → utils-DvvwfRQG.js} +1 -69
  147. package/dist/esm/{withBodyObserver-DczL5ia8.js → withBodyObserver-FQ8NwCIz.js} +1 -1
  148. package/dist/esm/{withComponentStatus-DodoSXe-.js → withComponentStatus-DWjDYtZ7.js} +1 -1
  149. package/dist/esm/{withComponentStyle-BerJY64r.js → withComponentStyle-9uP_hcDq.js} +2 -2
  150. package/dist/esm/withHasError-FyY5mQ_3.js +70 -0
  151. package/dist/esm/{withStyled-D1fAWJ3g.js → withStyled--qQWquTH.js} +6 -59
  152. package/dist/esm/{withTranslation-mimbJdER.js → withTranslation-BqD0Kp7b.js} +2 -2
  153. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +155 -109
  154. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +7 -0
  155. package/dist/types/components/bn-chart-structure/utils/model/styles/StructureChartStyle.d.ts +1 -0
  156. package/dist/types/components/bn-chart-time/utils/model/styles/TimeChartStyle.d.ts +1 -0
  157. package/dist/types/components/bn-dataset/bn-dataset.d.ts +6 -0
  158. package/dist/types/components/bn-datasource/bn-datasource.d.ts +8 -0
  159. package/dist/types/components/bn-table/bn-table.d.ts +3 -3
  160. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +0 -2
  161. package/dist/types/components.d.ts +100 -36
  162. package/dist/types/stores/componentStyles.d.ts +2 -0
  163. package/dist/types/utils/constants.d.ts +8 -5
  164. package/dist/types/utils/contentDecoder.d.ts +12 -0
  165. package/package.json +2 -1
  166. package/dist/bn-template-engine/p-05a82a77.entry.js +0 -1
  167. package/dist/bn-template-engine/p-1970906d.entry.js +0 -1
  168. package/dist/bn-template-engine/p-1dbd339c.entry.js +0 -1
  169. package/dist/bn-template-engine/p-2e68cf09.entry.js +0 -1
  170. package/dist/bn-template-engine/p-31cc6a2d.entry.js +0 -1
  171. package/dist/bn-template-engine/p-37881d05.entry.js +0 -1
  172. package/dist/bn-template-engine/p-3b894997.entry.js +0 -1
  173. package/dist/bn-template-engine/p-50e49732.entry.js +0 -1
  174. package/dist/bn-template-engine/p-6c7c0455.entry.js +0 -1
  175. package/dist/bn-template-engine/p-6da93eae.entry.js +0 -1
  176. package/dist/bn-template-engine/p-701e1578.entry.js +0 -1
  177. package/dist/bn-template-engine/p-8tsCnxIz.js +0 -1
  178. package/dist/bn-template-engine/p-997b2fe4.entry.js +0 -1
  179. package/dist/bn-template-engine/p-BL8gyUwE.js +0 -1
  180. package/dist/bn-template-engine/p-BSfqOkN_.js +0 -1
  181. package/dist/bn-template-engine/p-CRLgp9-v.js +0 -1
  182. package/dist/bn-template-engine/p-CYjZRKdI.js +0 -1
  183. package/dist/bn-template-engine/p-DRikHQE-.js +0 -1
  184. package/dist/bn-template-engine/p-DtdQCMzj.js +0 -1
  185. package/dist/bn-template-engine/p-a90f1cbe.entry.js +0 -1
  186. package/dist/bn-template-engine/p-b7bec050.entry.js +0 -1
  187. package/dist/bn-template-engine/p-d7f0cbaf.entry.js +0 -1
  188. package/dist/bn-template-engine/p-dfb61aa5.entry.js +0 -1
  189. package/dist/bn-template-engine/p-ece17f84.entry.js +0 -1
  190. package/dist/bn-template-engine/p-f27995c9.entry.js +0 -1
  191. package/dist/bn-template-engine/p-fd427179.entry.js +0 -1
  192. package/dist/bn-template-engine/p-sqjrku2z.js +0 -1
  193. package/dist/bn-template-engine/p-tzFCK9qn.js +0 -1
  194. package/dist/cjs/bn-chart-structure.cjs.entry.js +0 -700
  195. 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;
@@ -1636,10 +2569,10 @@ class StackedBar {
1636
2569
  xPos = axisX + baselinePixels;
1637
2570
  }
1638
2571
  const yPos = this.position.getBarPositionY(this.index, true);
1639
- // Unified IBCS 3-color palette for all stacking modes
1640
- const fillColor = getStackFill(this.segmentIndex);
2572
+ const colors = this.styles.stackColors;
2573
+ const fillColor = colors[this.segmentIndex % colors.length];
1641
2574
  const fillStyle = { color: fillColor };
1642
- const strokeStyle = { color: getStackStroke(this.segmentIndex), width: 0.5 };
2575
+ const strokeStyle = { color: fillColor, width: 0.5 };
1643
2576
  this.barGroup.rect(Math.max(segmentLength, 0.5), barWidth).fill(fillStyle).stroke(strokeStyle).cy(yPos).x(xPos);
1644
2577
  // Draw segment value label centered on bar if wide enough
1645
2578
  const MIN_SEGMENT_WIDTH_FOR_LABEL = 30;
@@ -1835,6 +2768,7 @@ class StructureChart {
1835
2768
  this.dataFormatDigits = { percent: 2, decimal: 1 };
1836
2769
  this.stackConfig = null;
1837
2770
  this.overflowConfig = null;
2771
+ this.highestStackedTotal = 0;
1838
2772
  this.initSQLFunctions();
1839
2773
  this.ruleSet = ruleSet || new IBCSRuleSet();
1840
2774
  this.i18n = this.createI18n(new Map());
@@ -1873,7 +2807,7 @@ class StructureChart {
1873
2807
  this.setData([...config.data], config.filter);
1874
2808
  this.dataModel = this.populateModel(config.scenarios, config.level, config.sortOrder);
1875
2809
  // Populate per-dimension stack segments when stacking by a data dimension
1876
- if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIO) {
2810
+ if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIOS) {
1877
2811
  this.populateDimensionStackSegments(config.scenarios, config.stackConfig, config.level);
1878
2812
  }
1879
2813
  this.variancesDataModel = this.populateVarianceModel(config.variances, this.dataModel);
@@ -1887,6 +2821,7 @@ class StructureChart {
1887
2821
  this.measureUnit = config.measureUnit;
1888
2822
  this.dataFormatDigits = config.dataFormatDigits;
1889
2823
  this.stackConfig = config.stackConfig;
2824
+ this.highestStackedTotal = this.findHighestStackedRowTotal(this.dataModel);
1890
2825
  this.updatePosition();
1891
2826
  }
1892
2827
  sortScenariosbyVisualisationRules(config) {
@@ -1976,6 +2911,30 @@ class StructureChart {
1976
2911
  this.preparedDataSet = data;
1977
2912
  }
1978
2913
  }
2914
+ /**
2915
+ * Returns the data value whose bar extent is proportional to pixelPerUnit.
2916
+ * Used by autoFitScaling to separate fixed vs variable width components.
2917
+ */
2918
+ getMaxBarValue() {
2919
+ var _a, _b;
2920
+ // Stacked: bar extent = highestStackedTotal * ppu (or just ppu for relative)
2921
+ if (this.stackConfig != null && this.highestStackedTotal > 0) {
2922
+ if (this.stackConfig.mode === StackMode.RELATIVE) {
2923
+ return 1;
2924
+ }
2925
+ return this.highestStackedTotal;
2926
+ }
2927
+ // Non-stacked: bar extent = highestDataPointValue * ppu
2928
+ const vt = this.getVarianceType();
2929
+ if (vt === VarianceType.NONE && ((_a = this.highestDataPointValue) === null || _a === void 0 ? void 0 : _a.value) != null) {
2930
+ return Math.abs(this.highestDataPointValue.value);
2931
+ }
2932
+ if (vt === VarianceType.ABSOLUTE && ((_b = this.highestVarianceDataPointValue) === null || _b === void 0 ? void 0 : _b.value) != null) {
2933
+ return Math.abs(this.highestVarianceDataPointValue.value);
2934
+ }
2935
+ // RELATIVE variance depends on pixelPerPercentage, not pixelPerUnit
2936
+ return 0;
2937
+ }
1979
2938
  getAllocatedCanvasWidth() {
1980
2939
  //let columnLabelWidth = this.calculateCategoryWidth();
1981
2940
  const leftSideWidth = this.position.getAxisPositionX(); //this.calculateLeftSideWidth(this.getVarianceType());
@@ -2226,6 +3185,48 @@ class StructureChart {
2226
3185
  }
2227
3186
  return highestDataPoint;
2228
3187
  }
3188
+ findHighestStackedRowTotal(dataModel) {
3189
+ if (!this.stackConfig || dataModel.length === 0)
3190
+ return 0;
3191
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
3192
+ let maxTotal = 0;
3193
+ for (const row of dataModel) {
3194
+ let rowTotal = 0;
3195
+ if (isScenarioStack) {
3196
+ const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
3197
+ const segments = [];
3198
+ for (const key of scenarioKeys) {
3199
+ const dp = row[key];
3200
+ if (dp && !dp.isEmpty() && dp.value != null) {
3201
+ segments.push({ value: dp.value, scenario: dp.scenario });
3202
+ }
3203
+ }
3204
+ const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
3205
+ if (prefixes.size > 1) {
3206
+ // Overlay: groups overlap from baseline, width = max group total
3207
+ const groupMap = new Map();
3208
+ for (const seg of segments) {
3209
+ const prefix = getScenarioPrefix(seg.scenario);
3210
+ groupMap.set(prefix, (groupMap.get(prefix) || 0) + Math.abs(seg.value));
3211
+ }
3212
+ rowTotal = Math.max(...groupMap.values());
3213
+ }
3214
+ else {
3215
+ // Single group: segments stack end-to-end, width = sum
3216
+ rowTotal = segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
3217
+ }
3218
+ }
3219
+ else {
3220
+ // Dimension stacking: use stackSegments
3221
+ if (row.stackSegments && row.stackSegments.length > 0) {
3222
+ rowTotal = row.stackSegments.reduce((sum, s) => sum + Math.abs(s.value), 0);
3223
+ }
3224
+ }
3225
+ if (rowTotal > maxTotal)
3226
+ maxTotal = rowTotal;
3227
+ }
3228
+ return maxTotal;
3229
+ }
2229
3230
  populateVarianceModel(variancesConfig, dataModel) {
2230
3231
  const varianceModel = [];
2231
3232
  if (variancesConfig.length === 0) {
@@ -2373,7 +3374,7 @@ class StructureChart {
2373
3374
  if (!this.stackConfig)
2374
3375
  return;
2375
3376
  const stackGroup = svgContainer.group().id("StackedScenarios");
2376
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIO;
3377
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
2377
3378
  dataModel.forEach((elements, index) => {
2378
3379
  const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
2379
3380
  const segments = [];
@@ -2474,7 +3475,7 @@ class StructureChart {
2474
3475
  drawStackedHeaders(dataModel, svgContainer) {
2475
3476
  if (!this.stackConfig || dataModel.length === 0)
2476
3477
  return;
2477
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIO;
3478
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
2478
3479
  const headerGroup = svgContainer.group().id("StackedHeaders");
2479
3480
  const firstRow = dataModel[0];
2480
3481
  // Dimension stacking: use stackSegments from first row for headers
@@ -2609,6 +3610,20 @@ class StructureChart {
2609
3610
  }
2610
3611
  calculateRightSideWidth(varianceType) {
2611
3612
  var _a, _b, _c;
3613
+ // Stacked charts: width based on max row total, not individual max
3614
+ if (this.stackConfig != null && this.highestStackedTotal > 0) {
3615
+ const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
3616
+ let barExtent;
3617
+ if (this.stackConfig.mode === StackMode.RELATIVE) {
3618
+ barExtent = this.pixelPerUnit;
3619
+ }
3620
+ else {
3621
+ barExtent = this.highestStackedTotal * this.pixelPerUnit;
3622
+ }
3623
+ const sizeTotalLabel = this.calculateTextBoxWidth(this.highestStackedTotal);
3624
+ const width = barExtent + labelToBar + sizeTotalLabel;
3625
+ return Math.max(width, this.titleLength);
3626
+ }
2612
3627
  let width = 0;
2613
3628
  const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
2614
3629
  if (VarianceType.NONE === varianceType &&
@@ -2638,19 +3653,20 @@ class StructureChart {
2638
3653
  * For dimension stacking (by category, subcategory, or rowgroup), query the raw data
2639
3654
  * at the stack dimension level and attach stackSegments to each dataModel row.
2640
3655
  */
2641
- populateDimensionStackSegments(scenarios, stackConfig, level) {
3656
+ populateDimensionStackSegments(scenarios, _stackConfig, level) {
2642
3657
  var _a;
2643
3658
  if (((_a = this.preparedDataSet) === null || _a === void 0 ? void 0 : _a.length) === 0 || scenarios.length === 0)
2644
3659
  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",
3660
+ // Derive stack column from level: stack by the next-lower hierarchy dimension
3661
+ const nextLowerDimension = {
3662
+ [AggregationLevel.ROWGROUP]: "category",
3663
+ [AggregationLevel.ROWGROUPINDEX]: "category",
3664
+ [AggregationLevel.CATEGORY]: "subCategory",
3665
+ [AggregationLevel.CATEGORYINDEX]: "subCategory",
2650
3666
  };
2651
- const stackColumn = stackColumnMap[stackConfig.by];
3667
+ const stackColumn = nextLowerDimension[level];
2652
3668
  if (!stackColumn)
2653
- return;
3669
+ return; // subCategory has no lower dimension
2654
3670
  // The display level column (what each bar represents)
2655
3671
  const displayColumn = level.toString(); // e.g. 'rowGroup', 'category', 'subCategory'
2656
3672
  const scenario = scenarios[0]; // dimension stacking uses first scenario
@@ -2837,7 +3853,7 @@ const IbcsChartStructure = class {
2837
3853
  this.chart.setI18n(this.i18n);
2838
3854
  return;
2839
3855
  }
2840
- // First pass with pixelPerUnit=1 to measure the real SVG width
3856
+ // First pass with pixelPerUnit=1 to measure total width and bar extent
2841
3857
  config.pixelPerUnit = 1;
2842
3858
  this.chart = new StructureChart(new IBCSRuleSet(), config, styles);
2843
3859
  this.chart.setI18n(this.i18n);
@@ -2846,8 +3862,18 @@ const IbcsChartStructure = class {
2846
3862
  if (svgWidth <= 0) {
2847
3863
  return;
2848
3864
  }
2849
- // Scale so the chart fits in ~90% of the available width
2850
- config.pixelPerUnit = (targetWidth * 0.9) / svgWidth;
3865
+ // Separate fixed parts (labels, padding, spacing) from variable part (bar extent).
3866
+ // totalWidth(ppu) = fixedWidth + maxBarValue * ppu
3867
+ // Solving for ppu: ppu = (targetWidth - fixedWidth) / maxBarValue
3868
+ const maxBarValue = this.chart.getMaxBarValue();
3869
+ if (maxBarValue > 0) {
3870
+ const fixedWidth = svgWidth - maxBarValue; // at ppu=1, barExtent = maxBarValue * 1
3871
+ config.pixelPerUnit = Math.max(0.001, (targetWidth - fixedWidth) / maxBarValue);
3872
+ }
3873
+ else {
3874
+ // Fallback (e.g. relative variance charts)
3875
+ config.pixelPerUnit = (targetWidth * 0.9) / svgWidth;
3876
+ }
2851
3877
  // Second pass with the corrected scaling
2852
3878
  this.chart = new StructureChart(new IBCSRuleSet(), config, styles);
2853
3879
  this.chart.setI18n(this.i18n);
@@ -2899,4 +3925,4 @@ const IbcsChartStructure = class {
2899
3925
  };
2900
3926
  IbcsChartStructure.style = bnChartStructureCss();
2901
3927
 
2902
- export { IbcsChartStructure as ibcs_chart_structure };
3928
+ export { Chart as bn_chart_structure, Context as bn_context, Datasource as bn_datasource, Page as bn_page, IbcsChartStructure as ibcs_chart_structure };