@bino-bi/bn-template-engine 1.0.0-alpha.2 → 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 (205) 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-DgfL-ffj.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-CvXqez4D.js → p-u8igQLRZ.js} +1 -1
  39. package/dist/cjs/{DataFormatDigits-CbIVfGEH.js → DataFormatDigits-DKcOeLNK.js} +1 -1
  40. package/dist/cjs/{DateStringFactory-CfkXYAMN.js → DateStringFactory-CSKvbS8K.js} +1 -1
  41. package/dist/cjs/{Order-DtpbD8mQ.js → Order-iG11HI4R.js} +36 -5
  42. package/dist/cjs/{SVGVariancesStyleGroup-D-rTWlDo.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} +159 -1259
  67. package/dist/cjs/{StringAdapter-ByCHdlDO.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-BBtMesx3.js → withStyled-CS1Yp4sv.js} +12 -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 +60 -12
  90. package/dist/collection/components/bn-table/ibcs-table.css +7 -5
  91. package/dist/collection/components/bn-table/ibcs-table.js +22 -1
  92. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +79 -31
  93. package/dist/collection/components/bn-table/utils/elements/TableRow.js +3 -1
  94. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +12 -3
  95. package/dist/collection/components/bn-table/utils/helper/ColumnStatistics.js +9 -1
  96. package/dist/collection/stores/componentStyles.js +2 -0
  97. package/dist/collection/utils/constants.js +35 -5
  98. package/dist/collection/utils/contentDecoder.js +28 -0
  99. package/dist/collection/utils/stackColors.js +2 -2
  100. package/dist/collection/utils/validate.js +5 -2
  101. package/dist/components/DataFormatDigits.js +1 -1
  102. package/dist/components/DateStringFactory.js +1 -1
  103. package/dist/components/Order.js +1 -1
  104. package/dist/components/SVGVariancesStyleGroup.js +1 -1
  105. package/dist/components/bn-chart-structure.js +1 -1
  106. package/dist/components/bn-chart-time.js +1 -1
  107. package/dist/components/bn-dataset.js +1 -1
  108. package/dist/components/bn-datasource.js +1 -1
  109. package/dist/components/bn-table.js +1 -1
  110. package/dist/components/bn-title2.js +1 -1
  111. package/dist/components/contentDecoder.js +1 -0
  112. package/dist/components/context-protocol.js +1 -1
  113. package/dist/components/emotion-hash.esm.js +1 -0
  114. package/dist/components/ibcs-chart-structure2.js +1 -1
  115. package/dist/components/ibcs-chart-time2.js +1 -1
  116. package/dist/components/ibcs-table2.js +1 -1
  117. package/dist/components/ibcs-title2.js +1 -1
  118. package/dist/components/ibcsRuleSet.js +1 -1
  119. package/dist/components/validate.js +1 -1
  120. package/dist/components/withStyled.js +1 -1
  121. package/dist/esm/{DataFormatDigits-DYdbRX-1.js → DataFormatDigits-oSZ1hBKE.js} +1 -1
  122. package/dist/esm/{DateStringFactory-DRcbojUT.js → DateStringFactory-CSGz6TDk.js} +1 -1
  123. package/dist/esm/{Order-DdexOqTs.js → Order-Bnhh02CF.js} +36 -6
  124. package/dist/esm/{SVGVariancesStyleGroup-D0Cwprv1.js → SVGVariancesStyleGroup-CqTjrZYg.js} +2 -13
  125. package/dist/esm/bn-asset.entry.js +5 -4
  126. package/dist/esm/bn-body_4.entry.js +11 -9
  127. package/dist/esm/bn-card.entry.js +5 -4
  128. package/dist/esm/{ibcs-chart-structure.entry.js → bn-chart-structure_5.entry.js} +1048 -22
  129. package/dist/esm/bn-chart-time.entry.js +38 -12
  130. package/dist/esm/bn-component-style.entry.js +5 -4
  131. package/dist/esm/bn-dataset.entry.js +35 -6
  132. package/dist/esm/bn-grid.entry.js +9 -7
  133. package/dist/esm/bn-image.entry.js +9 -7
  134. package/dist/esm/bn-internationalization.entry.js +5 -4
  135. package/dist/esm/bn-layout-card.entry.js +3 -2
  136. package/dist/esm/bn-layout-page.entry.js +2 -1
  137. package/dist/esm/bn-message.entry.js +5 -4
  138. package/dist/esm/bn-table.entry.js +977 -0
  139. package/dist/esm/bn-template-engine.js +1 -1
  140. package/dist/esm/bn-template.entry.js +3 -2
  141. package/dist/esm/bn-text.entry.js +11 -9
  142. package/dist/esm/bn-tree.entry.js +9 -7
  143. package/dist/esm/contentDecoder-oMmxz6nJ.js +416 -0
  144. package/dist/esm/{context-protocol-Bz5klD-F.js → context-protocol-BHnQsVsr.js} +2 -0
  145. package/dist/esm/editor-companion.entry.js +1 -1
  146. package/dist/esm/emotion-hash.esm-BYBpC0EO.js +55 -0
  147. package/dist/esm/ibcs-chart-time.entry.js +15 -11
  148. package/dist/esm/{bn-context_5.entry.js → ibcs-table.entry.js} +106 -1202
  149. package/dist/esm/{StringAdapter-CTL-Dvzp.js → ibcsRuleSet-K4ytuA1f.js} +10 -10
  150. package/dist/esm/index-DHezf8pZ.js +65 -0
  151. package/dist/esm/loader.js +1 -1
  152. package/dist/esm/{scaling-C6K8FYSF.js → scaling-Cehc74IE.js} +2 -2
  153. package/dist/esm/{withHasError-B3QX2emi.js → utils-DvvwfRQG.js} +1 -69
  154. package/dist/esm/{withBodyObserver-DczL5ia8.js → withBodyObserver-FQ8NwCIz.js} +1 -1
  155. package/dist/esm/{withComponentStatus-DodoSXe-.js → withComponentStatus-DWjDYtZ7.js} +1 -1
  156. package/dist/esm/{withComponentStyle-BerJY64r.js → withComponentStyle-9uP_hcDq.js} +2 -2
  157. package/dist/esm/withHasError-FyY5mQ_3.js +70 -0
  158. package/dist/esm/{withStyled-DCipbf2O.js → withStyled--qQWquTH.js} +9 -59
  159. package/dist/esm/{withTranslation-mimbJdER.js → withTranslation-BqD0Kp7b.js} +2 -2
  160. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +155 -109
  161. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +7 -0
  162. package/dist/types/components/bn-chart-structure/utils/model/styles/StructureChartStyle.d.ts +1 -0
  163. package/dist/types/components/bn-chart-time/utils/model/styles/TimeChartStyle.d.ts +1 -0
  164. package/dist/types/components/bn-dataset/bn-dataset.d.ts +6 -0
  165. package/dist/types/components/bn-datasource/bn-datasource.d.ts +8 -0
  166. package/dist/types/components/bn-table/bn-table.d.ts +12 -8
  167. package/dist/types/components/bn-table/ibcs-table.d.ts +1 -0
  168. package/dist/types/components/bn-table/utils/elements/Cell.d.ts +1 -0
  169. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +1 -0
  170. package/dist/types/components.d.ts +118 -34
  171. package/dist/types/stores/componentStyles.d.ts +2 -0
  172. package/dist/types/utils/constants.d.ts +23 -5
  173. package/dist/types/utils/contentDecoder.d.ts +12 -0
  174. package/dist/types/utils/validate.d.ts +1 -0
  175. package/package.json +2 -1
  176. package/dist/bn-template-engine/p--PSoPbDM.js +0 -1
  177. package/dist/bn-template-engine/p-05a82a77.entry.js +0 -1
  178. package/dist/bn-template-engine/p-0ca8dc17.entry.js +0 -1
  179. package/dist/bn-template-engine/p-1d9a3be9.entry.js +0 -1
  180. package/dist/bn-template-engine/p-35638ad0.entry.js +0 -1
  181. package/dist/bn-template-engine/p-37881d05.entry.js +0 -1
  182. package/dist/bn-template-engine/p-3b894997.entry.js +0 -1
  183. package/dist/bn-template-engine/p-50e49732.entry.js +0 -1
  184. package/dist/bn-template-engine/p-60a7fc59.entry.js +0 -1
  185. package/dist/bn-template-engine/p-6c7c0455.entry.js +0 -1
  186. package/dist/bn-template-engine/p-6da93eae.entry.js +0 -1
  187. package/dist/bn-template-engine/p-701e1578.entry.js +0 -1
  188. package/dist/bn-template-engine/p-BSfqOkN_.js +0 -1
  189. package/dist/bn-template-engine/p-CRLgp9-v.js +0 -1
  190. package/dist/bn-template-engine/p-CYjZRKdI.js +0 -1
  191. package/dist/bn-template-engine/p-DRikHQE-.js +0 -1
  192. package/dist/bn-template-engine/p-DVo6aZUE.js +0 -1
  193. package/dist/bn-template-engine/p-DdexOqTs.js +0 -1
  194. package/dist/bn-template-engine/p-DyRaC0MB.js +0 -1
  195. package/dist/bn-template-engine/p-a95ccc16.entry.js +0 -1
  196. package/dist/bn-template-engine/p-b7bec050.entry.js +0 -1
  197. package/dist/bn-template-engine/p-bc59ea5c.entry.js +0 -1
  198. package/dist/bn-template-engine/p-d279b578.entry.js +0 -1
  199. package/dist/bn-template-engine/p-dd9dd407.entry.js +0 -1
  200. package/dist/bn-template-engine/p-e102a490.entry.js +0 -1
  201. package/dist/bn-template-engine/p-f27995c9.entry.js +0 -1
  202. package/dist/bn-template-engine/p-f89e55c6.entry.js +0 -1
  203. package/dist/bn-template-engine/p-tzFCK9qn.js +0 -1
  204. package/dist/cjs/bn-chart-structure.cjs.entry.js +0 -700
  205. package/dist/esm/bn-chart-structure.entry.js +0 -698
@@ -58,6 +58,7 @@ export class StructureChart {
58
58
  this.dataFormatDigits = { percent: 2, decimal: 1 };
59
59
  this.stackConfig = null;
60
60
  this.overflowConfig = null;
61
+ this.highestStackedTotal = 0;
61
62
  this.initSQLFunctions();
62
63
  this.ruleSet = ruleSet || new IBCSRuleSet();
63
64
  this.i18n = this.createI18n(new Map());
@@ -96,7 +97,7 @@ export class StructureChart {
96
97
  this.setData([...config.data], config.filter);
97
98
  this.dataModel = this.populateModel(config.scenarios, config.level, config.sortOrder);
98
99
  // Populate per-dimension stack segments when stacking by a data dimension
99
- if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIO) {
100
+ if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIOS) {
100
101
  this.populateDimensionStackSegments(config.scenarios, config.stackConfig, config.level);
101
102
  }
102
103
  this.variancesDataModel = this.populateVarianceModel(config.variances, this.dataModel);
@@ -110,6 +111,7 @@ export class StructureChart {
110
111
  this.measureUnit = config.measureUnit;
111
112
  this.dataFormatDigits = config.dataFormatDigits;
112
113
  this.stackConfig = config.stackConfig;
114
+ this.highestStackedTotal = this.findHighestStackedRowTotal(this.dataModel);
113
115
  this.updatePosition();
114
116
  }
115
117
  sortScenariosbyVisualisationRules(config) {
@@ -199,6 +201,30 @@ export class StructureChart {
199
201
  this.preparedDataSet = data;
200
202
  }
201
203
  }
204
+ /**
205
+ * Returns the data value whose bar extent is proportional to pixelPerUnit.
206
+ * Used by autoFitScaling to separate fixed vs variable width components.
207
+ */
208
+ getMaxBarValue() {
209
+ var _a, _b;
210
+ // Stacked: bar extent = highestStackedTotal * ppu (or just ppu for relative)
211
+ if (this.stackConfig != null && this.highestStackedTotal > 0) {
212
+ if (this.stackConfig.mode === StackMode.RELATIVE) {
213
+ return 1;
214
+ }
215
+ return this.highestStackedTotal;
216
+ }
217
+ // Non-stacked: bar extent = highestDataPointValue * ppu
218
+ const vt = this.getVarianceType();
219
+ if (vt === VarianceType.NONE && ((_a = this.highestDataPointValue) === null || _a === void 0 ? void 0 : _a.value) != null) {
220
+ return Math.abs(this.highestDataPointValue.value);
221
+ }
222
+ if (vt === VarianceType.ABSOLUTE && ((_b = this.highestVarianceDataPointValue) === null || _b === void 0 ? void 0 : _b.value) != null) {
223
+ return Math.abs(this.highestVarianceDataPointValue.value);
224
+ }
225
+ // RELATIVE variance depends on pixelPerPercentage, not pixelPerUnit
226
+ return 0;
227
+ }
202
228
  getAllocatedCanvasWidth() {
203
229
  //let columnLabelWidth = this.calculateCategoryWidth();
204
230
  const leftSideWidth = this.position.getAxisPositionX(); //this.calculateLeftSideWidth(this.getVarianceType());
@@ -449,6 +475,48 @@ export class StructureChart {
449
475
  }
450
476
  return highestDataPoint;
451
477
  }
478
+ findHighestStackedRowTotal(dataModel) {
479
+ if (!this.stackConfig || dataModel.length === 0)
480
+ return 0;
481
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
482
+ let maxTotal = 0;
483
+ for (const row of dataModel) {
484
+ let rowTotal = 0;
485
+ if (isScenarioStack) {
486
+ const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
487
+ const segments = [];
488
+ for (const key of scenarioKeys) {
489
+ const dp = row[key];
490
+ if (dp && !dp.isEmpty() && dp.value != null) {
491
+ segments.push({ value: dp.value, scenario: dp.scenario });
492
+ }
493
+ }
494
+ const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
495
+ if (prefixes.size > 1) {
496
+ // Overlay: groups overlap from baseline, width = max group total
497
+ const groupMap = new Map();
498
+ for (const seg of segments) {
499
+ const prefix = getScenarioPrefix(seg.scenario);
500
+ groupMap.set(prefix, (groupMap.get(prefix) || 0) + Math.abs(seg.value));
501
+ }
502
+ rowTotal = Math.max(...groupMap.values());
503
+ }
504
+ else {
505
+ // Single group: segments stack end-to-end, width = sum
506
+ rowTotal = segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
507
+ }
508
+ }
509
+ else {
510
+ // Dimension stacking: use stackSegments
511
+ if (row.stackSegments && row.stackSegments.length > 0) {
512
+ rowTotal = row.stackSegments.reduce((sum, s) => sum + Math.abs(s.value), 0);
513
+ }
514
+ }
515
+ if (rowTotal > maxTotal)
516
+ maxTotal = rowTotal;
517
+ }
518
+ return maxTotal;
519
+ }
452
520
  populateVarianceModel(variancesConfig, dataModel) {
453
521
  const varianceModel = [];
454
522
  if (variancesConfig.length === 0) {
@@ -596,7 +664,7 @@ export class StructureChart {
596
664
  if (!this.stackConfig)
597
665
  return;
598
666
  const stackGroup = svgContainer.group().id("StackedScenarios");
599
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIO;
667
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
600
668
  dataModel.forEach((elements, index) => {
601
669
  const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
602
670
  const segments = [];
@@ -697,7 +765,7 @@ export class StructureChart {
697
765
  drawStackedHeaders(dataModel, svgContainer) {
698
766
  if (!this.stackConfig || dataModel.length === 0)
699
767
  return;
700
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIO;
768
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
701
769
  const headerGroup = svgContainer.group().id("StackedHeaders");
702
770
  const firstRow = dataModel[0];
703
771
  // Dimension stacking: use stackSegments from first row for headers
@@ -832,6 +900,20 @@ export class StructureChart {
832
900
  }
833
901
  calculateRightSideWidth(varianceType) {
834
902
  var _a, _b, _c;
903
+ // Stacked charts: width based on max row total, not individual max
904
+ if (this.stackConfig != null && this.highestStackedTotal > 0) {
905
+ const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
906
+ let barExtent;
907
+ if (this.stackConfig.mode === StackMode.RELATIVE) {
908
+ barExtent = this.pixelPerUnit;
909
+ }
910
+ else {
911
+ barExtent = this.highestStackedTotal * this.pixelPerUnit;
912
+ }
913
+ const sizeTotalLabel = this.calculateTextBoxWidth(this.highestStackedTotal);
914
+ const width = barExtent + labelToBar + sizeTotalLabel;
915
+ return Math.max(width, this.titleLength);
916
+ }
835
917
  let width = 0;
836
918
  const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
837
919
  if (VarianceType.NONE === varianceType &&
@@ -861,19 +943,20 @@ export class StructureChart {
861
943
  * For dimension stacking (by category, subcategory, or rowgroup), query the raw data
862
944
  * at the stack dimension level and attach stackSegments to each dataModel row.
863
945
  */
864
- populateDimensionStackSegments(scenarios, stackConfig, level) {
946
+ populateDimensionStackSegments(scenarios, _stackConfig, level) {
865
947
  var _a;
866
948
  if (((_a = this.preparedDataSet) === null || _a === void 0 ? void 0 : _a.length) === 0 || scenarios.length === 0)
867
949
  return;
868
- // Map StackBy value to the actual data column name
869
- const stackColumnMap = {
870
- [StackBy.CATEGORY]: "category",
871
- [StackBy.SUBCATEGORY]: "subCategory",
872
- [StackBy.ROWGROUP]: "rowGroup",
950
+ // Derive stack column from level: stack by the next-lower hierarchy dimension
951
+ const nextLowerDimension = {
952
+ [AggregationLevel.ROWGROUP]: "category",
953
+ [AggregationLevel.ROWGROUPINDEX]: "category",
954
+ [AggregationLevel.CATEGORY]: "subCategory",
955
+ [AggregationLevel.CATEGORYINDEX]: "subCategory",
873
956
  };
874
- const stackColumn = stackColumnMap[stackConfig.by];
957
+ const stackColumn = nextLowerDimension[level];
875
958
  if (!stackColumn)
876
- return;
959
+ return; // subCategory has no lower dimension
877
960
  // The display level column (what each bar represents)
878
961
  const displayColumn = level.toString(); // e.g. 'rowGroup', 'category', 'subCategory'
879
962
  const scenario = scenarios[0]; // dimension stacking uses first scenario
@@ -1,7 +1,6 @@
1
1
  import { HookLocation, Label } from "./Label";
2
2
  import { SiPrefix } from "../../../../utils/model/SiPrefix";
3
3
  import { StackMode } from "../../../../utils/constants";
4
- import { getStackFill, getStackStroke } from "../../../../utils/stackColors";
5
4
  /**
6
5
  * Renders a single horizontal stacked bar segment for the structure chart.
7
6
  */
@@ -45,10 +44,10 @@ export class StackedBar {
45
44
  xPos = axisX + baselinePixels;
46
45
  }
47
46
  const yPos = this.position.getBarPositionY(this.index, true);
48
- // Unified IBCS 3-color palette for all stacking modes
49
- const fillColor = getStackFill(this.segmentIndex);
47
+ const colors = this.styles.stackColors;
48
+ const fillColor = colors[this.segmentIndex % colors.length];
50
49
  const fillStyle = { color: fillColor };
51
- const strokeStyle = { color: getStackStroke(this.segmentIndex), width: 0.5 };
50
+ const strokeStyle = { color: fillColor, width: 0.5 };
52
51
  this.barGroup.rect(Math.max(segmentLength, 0.5), barWidth).fill(fillStyle).stroke(strokeStyle).cy(yPos).x(xPos);
53
52
  // Draw segment value label centered on bar if wide enough
54
53
  const MIN_SEGMENT_WIDTH_FOR_LABEL = 30;
@@ -16,6 +16,7 @@ export class StructureChartStyle {
16
16
  this.varianceStyles = varianceStyles;
17
17
  this.padding = padding;
18
18
  this.pattern = new Map();
19
+ this.stackColors = ["#000000", "#c0c0c0", "#808080"];
19
20
  }
20
21
  }
21
22
  /** Adapts raw componentStyle JSON into a StructureChartStyle, falling back to defaults for missing properties. */
@@ -48,6 +49,9 @@ export class StructureChartStylesAdapter {
48
49
  if (CompareUtil.isExisting(data.padding)) {
49
50
  styles.padding = this.paddingadapter.adapt(data.padding);
50
51
  }
52
+ if (Array.isArray(data.stackColors) && data.stackColors.length > 0) {
53
+ styles.stackColors = data.stackColors;
54
+ }
51
55
  styles.pattern = new MarkerPattern(styles.fontStyles.size).createPatternMapForStructureBar();
52
56
  }
53
57
  return styles;
@@ -11,7 +11,7 @@ import { getParentDimensions } from "../../utils/parentDimensions";
11
11
  import { parseScaling } from "../../utils/scaling";
12
12
  import { OrderColumn, OrderDirection } from "../../utils/model/Order";
13
13
  import { Formatter } from "../../utils/formatter";
14
- import { AxisLabelsMode, ChartMode, StackMode, StackOrder } from "../../utils/constants";
14
+ import { AxisLabelsMode, ChartMode, StackBy, StackMode, StackOrder } from "../../utils/constants";
15
15
  import { DateDistance } from "../../utils/DateStringFactory";
16
16
  var AggregationLevel;
17
17
  (function (AggregationLevel) {
@@ -720,6 +720,7 @@ export class Chart {
720
720
  axisStyles: $["bn-chart-time"]["axisStyles"],
721
721
  barStyles: $["bn-chart-time"]["barStyles"],
722
722
  varianceStyles: $["bn-chart-time"]["varianceStyles"],
723
+ stackColors: $["bn-chart-time"]["stackColors"],
723
724
  padding: $["bn-chart-time"]["padding"],
724
725
  pattern: null,
725
726
  };
@@ -839,17 +840,37 @@ export class Chart {
839
840
  }
840
841
  prepareStackConfig() {
841
842
  if (isBlankInput(this.stack)) {
843
+ this.errors.remove("WARN_stack_dimensions_scenarios");
842
844
  return null;
843
845
  }
844
846
  try {
845
847
  const parsed = JSON.parse(this.stack);
848
+ const by = parsed.by;
849
+ const errId = "WARN_stack_dimensions_scenarios";
850
+ if (by === StackBy.DIMENSIONS) {
851
+ const scenarios = this.prepareScenarios();
852
+ if (scenarios.length > 1) {
853
+ this.errors.addOrReplace({
854
+ id: errId,
855
+ type: "warning",
856
+ message: `stack by dimensions: only the first scenario "${scenarios[0]}" is used, the rest (${scenarios.slice(1).join(", ")}) are discarded.`,
857
+ });
858
+ }
859
+ else {
860
+ this.errors.remove(errId);
861
+ }
862
+ }
863
+ else {
864
+ this.errors.remove(errId);
865
+ }
846
866
  return {
847
- by: parsed.by,
867
+ by,
848
868
  mode: parsed.mode || StackMode.ABSOLUTE,
849
869
  order: parsed.order || StackOrder.DATASET,
850
870
  };
851
871
  }
852
872
  catch (_a) {
873
+ this.errors.remove("WARN_stack_dimensions_scenarios");
853
874
  return null;
854
875
  }
855
876
  }
@@ -877,7 +898,10 @@ export class Chart {
877
898
  const effectiveFactor = this.getEffectiveScaleFactor();
878
899
  const ppu = this.preparePixelPerUnit();
879
900
  const ppp = this.preparePixelPerPercentage();
880
- return (h("ibcs-chart-time", { data: this.data, chartTitle: this.prepareChartTitle(idx), scenarios: this.prepareScenarios(), variances: [localScenarioString], hideAxisLabels: this.prepareHideAxisLabels(idx), pixelPerUnit: ppu > 0 ? ppu * effectiveFactor : 0, pixelPerPercentage: ppp > 0 ? ppp * effectiveFactor : 0, limit: this.prepareLimit(), leftSideOffsetForHorizontalSync: this.prepareLeftSideOffset(preparedI18n, preparedStyle), styles: preparedStyle, i18n: preparedI18n, order: this.prepareOrder(), level: this.prepareLevel(), dateInterval: this.prepareDateInterval(), intervalSpanLimit: this.prepareIntervalSpanLimit(), axisLabelsMode: this.prepareAxisLabelsMode(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showOverlayAvg: this.prepareAvg(), showOverlayMedian: this.prepareMedian(), showMeasureScale: this.prepareShowMeasureScale(idx), chartMode: this.prepareChartMode(), maxBars: this.prepareMaxBars(), stackConfig: this.prepareStackConfig(), lineFullWidth: this.prepareLineFullWidth(), containerWidth: fullParentWidth, parentDimensions: this.prepareDimension() }));
901
+ const stackConfig = this.prepareStackConfig();
902
+ const scenarios = this.prepareScenarios();
903
+ const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
904
+ return (h("ibcs-chart-time", { data: this.data, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideAxisLabels: this.prepareHideAxisLabels(idx), pixelPerUnit: ppu > 0 ? ppu * effectiveFactor : 0, pixelPerPercentage: ppp > 0 ? ppp * effectiveFactor : 0, limit: this.prepareLimit(), leftSideOffsetForHorizontalSync: this.prepareLeftSideOffset(preparedI18n, preparedStyle), styles: preparedStyle, i18n: preparedI18n, order: this.prepareOrder(), level: this.prepareLevel(), dateInterval: this.prepareDateInterval(), intervalSpanLimit: this.prepareIntervalSpanLimit(), axisLabelsMode: this.prepareAxisLabelsMode(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showOverlayAvg: this.prepareAvg(), showOverlayMedian: this.prepareMedian(), showMeasureScale: this.prepareShowMeasureScale(idx), chartMode: this.prepareChartMode(), maxBars: this.prepareMaxBars(), stackConfig: stackConfig, lineFullWidth: this.prepareLineFullWidth(), containerWidth: fullParentWidth, parentDimensions: this.prepareDimension() }));
881
905
  }
882
906
  getEffectiveScaleFactor() {
883
907
  const { mode, factor } = parseScaling(this.scale);
@@ -907,7 +931,7 @@ export class Chart {
907
931
  scenariosArray = [...scenariosArray, ...variancesArray];
908
932
  }
909
933
  const fontStyles = this.getFontStyles();
910
- return (h(Host, { key: 'ed9bf10764443d9b4be0bf05dbbcd858d271993a', style: fontStyles }, h("div", { key: 'c2bda702b470a4ddba2da84d81908d96ce893c8e', class: "container" }, scenariosArray.map(this.chartTemplate))));
934
+ return (h(Host, { key: 'ecbf96e2d037a7dad9b3380bcc28b6e010ac867c', style: fontStyles }, h("div", { key: 'c556b86aac629e59c601986650d1a4857a2ee068', class: "container" }, scenariosArray.map(this.chartTemplate))));
911
935
  }
912
936
  static get is() { return "bn-chart-time"; }
913
937
  static get encapsulation() { return "shadow"; }
@@ -1000,7 +1000,7 @@ export class TimeChart {
1000
1000
  if (!this.stackConfig)
1001
1001
  return;
1002
1002
  const stackGroup = svgContainer.group().id("StackedScenarios");
1003
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIO;
1003
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
1004
1004
  dataModel.forEach((elements, index) => {
1005
1005
  const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
1006
1006
  const segments = [];
@@ -1095,7 +1095,7 @@ export class TimeChart {
1095
1095
  drawStackedHeaders(dataModel, svgContainer) {
1096
1096
  if (!this.stackConfig || dataModel.length === 0)
1097
1097
  return;
1098
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIO;
1098
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
1099
1099
  if (!isScenarioStack)
1100
1100
  return;
1101
1101
  const headerGroup = svgContainer.group().id("StackedHeaders");
@@ -1175,7 +1175,7 @@ export class TimeChart {
1175
1175
  if (!this.stackConfig)
1176
1176
  return;
1177
1177
  const areaGroup = svgContainer.group().id("StackedAreaScenarios");
1178
- const isScenarioStack = this.stackConfig.by === StackBy.SCENARIO;
1178
+ const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
1179
1179
  const stackMode = this.stackConfig.mode;
1180
1180
  const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
1181
1181
  // Determine how many layers we have
@@ -1,7 +1,6 @@
1
1
  import { HookLocation, Label } from "./Label";
2
2
  import { SiPrefix } from "../../../../utils/model/SiPrefix";
3
3
  import { StackMode } from "../../../../utils/constants";
4
- import { getStackFill, getStackStroke } from "../../../../utils/stackColors";
5
4
  /**
6
5
  * Renders a single segment within a stacked bar column in a time chart.
7
6
  *
@@ -59,10 +58,10 @@ export class StackedColumn {
59
58
  }
60
59
  const xPos = this.position.getColumnCenterPositionX(this.index);
61
60
  const columnWidth = this.position.getColumnWidth();
62
- // Unified IBCS 3-color palette for all stacking modes
63
- const fillColor = getStackFill(this.segmentIndex);
61
+ const colors = this.styles.stackColors;
62
+ const fillColor = colors[this.segmentIndex % colors.length];
64
63
  const fillStyle = { color: fillColor };
65
- const strokeStyle = { color: getStackStroke(this.segmentIndex), width: 0.5 };
64
+ const strokeStyle = { color: fillColor, width: 0.5 };
66
65
  // Draw rectangle
67
66
  this.columnGroup
68
67
  .rect(columnWidth, Math.max(segmentHeight, 0.5))
@@ -12,6 +12,7 @@ export class TimeChartStyle {
12
12
  this.varianceStyles = varianceStyles;
13
13
  this.padding = padding;
14
14
  this.pattern = new Map();
15
+ this.stackColors = ["#000000", "#c0c0c0", "#808080"];
15
16
  }
16
17
  }
17
18
  /** Adapts raw componentStyle JSON into a TimeChartStyle, falling back to defaults for missing properties. */
@@ -44,6 +45,9 @@ export class TimeChartStylesAdapter {
44
45
  if (CompareUtil.isExisting(data.padding)) {
45
46
  styles.padding = this.paddingadapter.adapt(data.padding);
46
47
  }
48
+ if (Array.isArray(data.stackColors) && data.stackColors.length > 0) {
49
+ styles.stackColors = data.stackColors;
50
+ }
47
51
  styles.pattern = new MarkerPattern(styles.fontStyles.size).createPatternMapForStructureBar();
48
52
  }
49
53
  return styles;
@@ -6,6 +6,7 @@ import { calculateDatasetMeta } from "../../utils/datasetMetaCalculator";
6
6
  import alasql from "alasql";
7
7
  import withComponentStatus from "../../utils/withComponentStatus";
8
8
  import withHasError from "../../utils/withHasError";
9
+ import { computeContentHash, decodeCompressedContent } from "../../utils/contentDecoder";
9
10
  /**
10
11
  * Queries data from one or more `bn-datasource` entries via AlaSQL and
11
12
  * writes the result to the `datasets` store (+ computed `DatasetMeta`).
@@ -30,6 +31,12 @@ export class Dataset {
30
31
  * content as raw JSON, writing it directly to the datasets store.
31
32
  */
32
33
  this.static = false;
34
+ /**
35
+ * When true (default), body content is plain text (SQL or JSON).
36
+ * When false, body content is a compressed payload (`<hash>:<base64_gzip>`).
37
+ */
38
+ this.raw = true;
39
+ this.lastBodyHash = null;
33
40
  withComponentStatus(this);
34
41
  this.errors = withHasError(this);
35
42
  // @ts-ignore
@@ -39,7 +46,27 @@ export class Dataset {
39
46
  this.executeQuery();
40
47
  });
41
48
  withBodyObserver(this, (data) => {
42
- this.query = data;
49
+ let contentHash;
50
+ let body;
51
+ if (!this.raw && this.static) {
52
+ try {
53
+ const decoded = decodeCompressedContent(data);
54
+ contentHash = decoded.hash;
55
+ body = decoded.json;
56
+ }
57
+ catch (e) {
58
+ console.error("Error decoding compressed dataset", e, String(data).slice(0, 200));
59
+ return;
60
+ }
61
+ }
62
+ else {
63
+ contentHash = computeContentHash(data);
64
+ body = data;
65
+ }
66
+ if (contentHash === this.lastBodyHash)
67
+ return;
68
+ this.lastBodyHash = contentHash;
69
+ this.query = body;
43
70
  this.executeQuery();
44
71
  });
45
72
  }
@@ -73,7 +100,7 @@ export class Dataset {
73
100
  this.executeQuery();
74
101
  }
75
102
  render() {
76
- return h(Host, { key: '0aecc50d8aa488f49d6630fec9f0755d306f213e' });
103
+ return h(Host, { key: '3e8b6fbc52b5b5cbe0ae88d7aa1d259f86d63e1b' });
77
104
  }
78
105
  static get is() { return "bn-dataset"; }
79
106
  static get originalStyleUrls() {
@@ -146,6 +173,26 @@ export class Dataset {
146
173
  "reflect": false,
147
174
  "attribute": "static",
148
175
  "defaultValue": "false"
176
+ },
177
+ "raw": {
178
+ "type": "boolean",
179
+ "mutable": false,
180
+ "complexType": {
181
+ "original": "boolean",
182
+ "resolved": "boolean",
183
+ "references": {}
184
+ },
185
+ "required": false,
186
+ "optional": false,
187
+ "docs": {
188
+ "tags": [],
189
+ "text": "When true (default), body content is plain text (SQL or JSON).\nWhen false, body content is a compressed payload (`<hash>:<base64_gzip>`)."
190
+ },
191
+ "getter": false,
192
+ "setter": false,
193
+ "reflect": false,
194
+ "attribute": "raw",
195
+ "defaultValue": "true"
149
196
  }
150
197
  };
151
198
  }
@@ -3,34 +3,57 @@ import withBodyObserver from "../../utils/withBodyObserver";
3
3
  import { getStores } from "../../context/context-protocol";
4
4
  import withComponentStatus from "../../utils/withComponentStatus";
5
5
  import withHasError from "../../utils/withHasError";
6
+ import { computeContentHash, decodeCompressedContent } from "../../utils/contentDecoder";
6
7
  /**
7
8
  * Ingests raw JSON data and writes it to the scoped `datasources` store.
8
9
  *
9
10
  * Data is provided as JSON text inside the element body (observed via
10
11
  * `withBodyObserver`). Other components (e.g. `bn-dataset`) reference
11
12
  * the stored data by the `name` prop to run queries against it.
13
+ *
14
+ * Set `raw="false"` to accept pre-compressed payloads in `<hash>:<base64_gzip>` format.
12
15
  */
13
16
  export class Datasource {
14
17
  constructor() {
18
+ /**
19
+ * When true (default), body content is plain JSON text.
20
+ * When false, body content is a compressed payload (`<hash>:<base64_gzip>`).
21
+ */
22
+ this.raw = true;
23
+ this.lastHash = null;
15
24
  withComponentStatus(this);
16
25
  this.errors = withHasError(this);
17
26
  withBodyObserver(this, (data) => {
18
27
  if (!this.stores)
19
28
  this.stores = getStores(this.element);
20
29
  try {
21
- const json = JSON.parse(data);
30
+ let contentHash;
31
+ let jsonString;
32
+ if (this.raw) {
33
+ contentHash = computeContentHash(data);
34
+ jsonString = data;
35
+ }
36
+ else {
37
+ const decoded = decodeCompressedContent(data);
38
+ contentHash = decoded.hash;
39
+ jsonString = decoded.json;
40
+ }
41
+ if (contentHash === this.lastHash)
42
+ return;
43
+ this.lastHash = contentHash;
44
+ const json = JSON.parse(jsonString);
22
45
  // @ts-ignore
23
46
  this.stores.datasources.set(this.name, json);
24
47
  }
25
48
  catch (e) {
26
- console.error("Error parsing datasource", e, data);
49
+ console.error("Error parsing datasource", e, String(data).slice(0, 200));
27
50
  // @ts-ignore
28
51
  this.stores.datasources.set(this.name, []);
29
52
  }
30
53
  });
31
54
  }
32
55
  render() {
33
- return h(Host, { key: 'e47e62c941bb7954cabe331cb500a7d2fdd7c487' });
56
+ return h(Host, { key: '43b691b07f63d12ad6c835dfb5d5bf6053b3bbf4' });
34
57
  }
35
58
  static get is() { return "bn-datasource"; }
36
59
  static get originalStyleUrls() {
@@ -63,6 +86,26 @@ export class Datasource {
63
86
  "setter": false,
64
87
  "reflect": false,
65
88
  "attribute": "name"
89
+ },
90
+ "raw": {
91
+ "type": "boolean",
92
+ "mutable": false,
93
+ "complexType": {
94
+ "original": "boolean",
95
+ "resolved": "boolean",
96
+ "references": {}
97
+ },
98
+ "required": false,
99
+ "optional": false,
100
+ "docs": {
101
+ "tags": [],
102
+ "text": "When true (default), body content is plain JSON text.\nWhen false, body content is a compressed payload (`<hash>:<base64_gzip>`)."
103
+ },
104
+ "getter": false,
105
+ "setter": false,
106
+ "reflect": false,
107
+ "attribute": "raw",
108
+ "defaultValue": "true"
66
109
  }
67
110
  };
68
111
  }