@bino-bi/bn-template-engine 1.0.0-next.38 → 1.0.0-next.40

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 (105) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-9a61f59d.entry.js → p-8b28c9bd.entry.js} +1 -1
  3. package/dist/bn-template-engine/{p-DyupX-Z-.js → p-BjozxTTW.js} +1 -1
  4. package/dist/bn-template-engine/p-EcC0qLtU.js +1 -0
  5. package/dist/bn-template-engine/{p-eea538f1.entry.js → p-a4b76176.entry.js} +1 -1
  6. package/dist/bn-template-engine/p-aa0fd797.entry.js +1 -0
  7. package/dist/bn-template-engine/{p-93b8387f.entry.js → p-ce764078.entry.js} +1 -1
  8. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +1067 -515
  9. package/dist/cjs/bn-grid.cjs.entry.js +1 -1
  10. package/dist/cjs/bn-image.cjs.entry.js +1 -1
  11. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  12. package/dist/cjs/bn-text.cjs.entry.js +2 -2
  13. package/dist/cjs/loader.cjs.js +1 -1
  14. package/dist/cjs/{withStyled-DfE0aW7D.js → withStyled-BZb6snOx.js} +74 -0
  15. package/dist/cjs/{withTranslation-0gkn9xoC.js → withTranslation-FxXGUB3H.js} +1 -1
  16. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +4 -1
  17. package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +3 -1
  18. package/dist/collection/components/bn-chart-time/utils/elements/Label.js +3 -1
  19. package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.css +22 -1
  20. package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +192 -12
  21. package/dist/collection/components/bn-table/bn-table.js +222 -8
  22. package/dist/collection/components/bn-table/utils/Table.js +33 -2
  23. package/dist/collection/components/bn-table/utils/elements/Cell.js +10 -1
  24. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +25 -10
  25. package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +50 -12
  26. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +59 -21
  27. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +63 -2
  28. package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +30 -6
  29. package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +123 -11
  30. package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +57 -9
  31. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +21 -1
  32. package/dist/collection/components/bn-table/utils/model/index.js +6 -0
  33. package/dist/collection/utils/layoutState/baseline.js +6 -5
  34. package/dist/collection/utils/validate.js +4 -0
  35. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  36. package/dist/components/bn-chart-bubble.js +1 -1
  37. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  38. package/dist/components/bn-chart-bullet.js +1 -1
  39. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  40. package/dist/components/bn-chart-scatter.js +1 -1
  41. package/dist/components/bn-chart-structure-renderer.js +1 -1
  42. package/dist/components/bn-chart-structure.js +1 -1
  43. package/dist/components/bn-chart-time-renderer.js +1 -1
  44. package/dist/components/bn-chart-time.js +1 -1
  45. package/dist/components/bn-grid.js +1 -1
  46. package/dist/components/bn-image.js +1 -1
  47. package/dist/components/bn-layout-card.js +1 -1
  48. package/dist/components/bn-layout-page.js +1 -1
  49. package/dist/components/bn-page.js +1 -1
  50. package/dist/components/bn-table-renderer.js +1 -1
  51. package/dist/components/bn-table.js +1 -1
  52. package/dist/components/bn-text.js +1 -1
  53. package/dist/components/bn-title.js +1 -1
  54. package/dist/components/bn-tree.js +1 -1
  55. package/dist/components/p-1B_s8oPY.js +1 -0
  56. package/dist/components/{p-BqUB56k1.js → p-B4L069XF.js} +1 -1
  57. package/dist/components/p-BC4MwlnX.js +1 -0
  58. package/dist/components/p-BZXiWkDS.js +1 -0
  59. package/dist/components/p-BiSytXUy.js +1 -0
  60. package/dist/components/p-Bn7J1pgl.js +1 -0
  61. package/dist/components/{p-BmOWXYHF.js → p-CEf5X8MZ.js} +1 -1
  62. package/dist/components/{p-BhEdmPjm.js → p-CUSAlS2o.js} +1 -1
  63. package/dist/components/p-ChaSU4fh.js +1 -0
  64. package/dist/components/p-CvEdUq8i.js +1 -0
  65. package/dist/components/{p-OquycEMA.js → p-D40Am1Ap.js} +1 -1
  66. package/dist/components/{p-CQVAHG6w.js → p-DM4Up10X.js} +1 -1
  67. package/dist/components/{p-Bo_R7f_T.js → p-DwuXVo2h.js} +1 -1
  68. package/dist/components/{p-t4xPltK2.js → p-XFZYX7DZ.js} +1 -1
  69. package/dist/components/{p-DTmqMQpw.js → p-Y9bth2Y_.js} +1 -1
  70. package/dist/components/{p-C_6KHDYv.js → p-chnyMHJT.js} +1 -1
  71. package/dist/components/{p-BU_53KVT.js → p-xIWChKGS.js} +1 -1
  72. package/dist/esm/bn-annotation-layer_30.entry.js +1037 -485
  73. package/dist/esm/bn-grid.entry.js +1 -1
  74. package/dist/esm/bn-image.entry.js +1 -1
  75. package/dist/esm/bn-template-engine.js +1 -1
  76. package/dist/esm/bn-text.entry.js +2 -2
  77. package/dist/esm/loader.js +1 -1
  78. package/dist/esm/{withStyled-CIoJ86RM.js → withStyled-CzzXg64f.js} +77 -4
  79. package/dist/esm/{withTranslation-BX9T3dfm.js → withTranslation-Daq2JXkv.js} +1 -1
  80. package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +22 -1
  81. package/dist/types/components/bn-table/bn-table.d.ts +72 -1
  82. package/dist/types/components/bn-table/utils/Table.d.ts +11 -1
  83. package/dist/types/components/bn-table/utils/elements/Cell.d.ts +3 -0
  84. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +26 -0
  85. package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +22 -2
  86. package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +7 -4
  87. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +13 -0
  88. package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +7 -0
  89. package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +30 -2
  90. package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +24 -4
  91. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +9 -1
  92. package/dist/types/components/bn-table/utils/model/index.d.ts +5 -0
  93. package/dist/types/components.d.ts +66 -6
  94. package/dist/types/utils/layoutState/baseline.d.ts +4 -2
  95. package/dist/types/utils/validate.d.ts +1 -0
  96. package/package.json +1 -1
  97. package/dist/bn-template-engine/p-BVU4bIsi.js +0 -1
  98. package/dist/bn-template-engine/p-e15ccc4a.entry.js +0 -1
  99. package/dist/components/p--HIZm_2v.js +0 -1
  100. package/dist/components/p-C-KX1_tw.js +0 -1
  101. package/dist/components/p-DCPLGEs_.js +0 -1
  102. package/dist/components/p-DT04Cka0.js +0 -1
  103. package/dist/components/p-Dm6EAaJ9.js +0 -1
  104. package/dist/components/p-sar8m7th.js +0 -1
  105. package/dist/components/p-tkB96Ena.js +0 -1
@@ -2,8 +2,8 @@
2
2
 
3
3
  var index = require('./index-DGis1BzT.js');
4
4
  var withHasError = require('./withHasError-BkBrsCpI.js');
5
- var withStyled = require('./withStyled-DfE0aW7D.js');
6
- var withTranslation = require('./withTranslation-0gkn9xoC.js');
5
+ var withStyled = require('./withStyled-BZb6snOx.js');
6
+ var withTranslation = require('./withTranslation-FxXGUB3H.js');
7
7
  var withBodyObserver = require('./withBodyObserver-S-FGHpAX.js');
8
8
  var localFrame = require('./localFrame-U3Qs0psw.js');
9
9
  var index$1 = require('./index.cjs.js');
@@ -810,8 +810,10 @@ function readChartBaseline(host, innerTag) {
810
810
  }
811
811
  /**
812
812
  * Baseline of a rendered `<table>`, in the layout px of `host`: y is the
813
- * bottom of the header, x the left edge of the first value column (the cell
814
- * after the category column of the last header row, else of the first body row).
813
+ * bottom of the header, x the left edge of the first value column of the last
814
+ * header row, else of the first body row. That is the first cell that is not
815
+ * the operation or the category column. Interval groups can stand left of the
816
+ * category column, then it is the first cell of the row.
815
817
  */
816
818
  function readTableBaseline(table, host) {
817
819
  var _a;
@@ -827,10 +829,9 @@ function readTableBaseline(table, host) {
827
829
  const rows = (section) => section ? Array.from(section.children).filter((child) => child.localName === "tr") : [];
828
830
  const headerRows = rows(thead);
829
831
  const row = (_a = headerRows[headerRows.length - 1]) !== null && _a !== void 0 ? _a : rows(table.querySelector("tbody"))[0];
830
- // an operation column can come before the category column (table type opt)
831
832
  const cells = row ? Array.from(row.children) : [];
832
- const category = cells.findIndex((cell) => cell.classList.contains("category"));
833
- const valueCell = cells[category >= 0 ? category + 1 : 1];
833
+ const isRowHeader = (cell) => cell.classList.contains("category") || cell.classList.contains("operation");
834
+ const valueCell = cells.some(isRowHeader) ? cells.find((cell) => !isRowHeader(cell)) : cells[1];
834
835
  if (valueCell) {
835
836
  baseline.x = round2(frame.toLocal(valueCell.getBoundingClientRect()).x);
836
837
  }
@@ -9569,7 +9570,9 @@ let Label$1 = class Label {
9569
9570
  type = "decimal";
9570
9571
  }
9571
9572
  valueStr = Formatter.number(Number(value), type, digits, digitsMin, scale, this.styles.locale);
9572
- if (this.isVarianceLabel && Number(this.value) >= 0) {
9573
+ // a value that rounds to zero prints without a sign
9574
+ const zeroStr = Formatter.number(0, type, digits, digitsMin, scale, this.styles.locale);
9575
+ if (this.isVarianceLabel && Number(this.value) > 0 && valueStr !== zeroStr) {
9573
9576
  prefix = "+";
9574
9577
  }
9575
9578
  }
@@ -15599,11 +15602,11 @@ let CustomPattern$1 = class CustomPattern {
15599
15602
  }
15600
15603
  };
15601
15604
 
15602
- var FactoryState$3;
15605
+ var FactoryState$2;
15603
15606
  (function (FactoryState) {
15604
15607
  FactoryState[FactoryState["UP_TO_DATE"] = 0] = "UP_TO_DATE";
15605
15608
  FactoryState[FactoryState["DIRTY"] = 1] = "DIRTY";
15606
- })(FactoryState$3 || (FactoryState$3 = {}));
15609
+ })(FactoryState$2 || (FactoryState$2 = {}));
15607
15610
  var VarianceType$1;
15608
15611
  (function (VarianceType) {
15609
15612
  VarianceType["RELATIVE"] = "dr";
@@ -16261,12 +16264,12 @@ var Scenario$1;
16261
16264
  Scenario["NEU"] = "neu";
16262
16265
  })(Scenario$1 || (Scenario$1 = {}));
16263
16266
  /** Chart-internal table aggregation modes. */
16264
- var TableType$2;
16267
+ var TableType$1;
16265
16268
  (function (TableType) {
16266
16269
  TableType["LIST"] = "LIST";
16267
16270
  TableType["SUM"] = "SUM";
16268
16271
  TableType["OPT"] = "OPT";
16269
- })(TableType$2 || (TableType$2 = {}));
16272
+ })(TableType$1 || (TableType$1 = {}));
16270
16273
 
16271
16274
  // import {Formatter} from "../../../../utils";
16272
16275
  // import {StructureChartStyle} from "../model";
@@ -16369,7 +16372,9 @@ class Label {
16369
16372
  if (Number(this.value) < 0) {
16370
16373
  labelAnchor = "end";
16371
16374
  }
16372
- if (this.isVarianceLabel && Number(this.value) >= 0) {
16375
+ // a value that rounds to zero prints without a sign
16376
+ const zeroStr = Formatter.number(0, type, digits, digitsMin, scale, this.styles.locale);
16377
+ if (this.isVarianceLabel && Number(this.value) > 0 && valueStr !== zeroStr) {
16373
16378
  prefix = "+";
16374
16379
  }
16375
16380
  }
@@ -17409,7 +17414,7 @@ class StructureChart {
17409
17414
  this.hideCategories = false;
17410
17415
  this.axisScenario = Scenario$1.AC1;
17411
17416
  this.CSS_CATEGORIES = "categories";
17412
- this.state = FactoryState$3.DIRTY;
17417
+ this.state = FactoryState$2.DIRTY;
17413
17418
  this.titleLength = 0;
17414
17419
  this.leftSideOffsetForHorizontalSync = 0;
17415
17420
  this.limit = 0;
@@ -17453,7 +17458,7 @@ class StructureChart {
17453
17458
  }
17454
17459
  setConfig(config) {
17455
17460
  var _a, _b;
17456
- this.state = FactoryState$3.DIRTY;
17461
+ this.state = FactoryState$2.DIRTY;
17457
17462
  this.scenarioPropOrder = [...config.scenarios];
17458
17463
  const scenarios = this.sortScenariosbyVisualisationRules(config.scenarios);
17459
17464
  this.hideCategories = config.hideCategories || false;
@@ -17526,7 +17531,7 @@ class StructureChart {
17526
17531
  this.title = this.configTitle || Formatter.translateScenarioLabel((_a = this.configVariances) === null || _a === void 0 ? void 0 : _a.toString(), this.i18n);
17527
17532
  }
17528
17533
  createI18n(i18n) {
17529
- this.state = FactoryState$3.DIRTY;
17534
+ this.state = FactoryState$2.DIRTY;
17530
17535
  const defaultI18n = new Map([
17531
17536
  ["SEPARATOR_WS", ", "],
17532
17537
  ["in", "in"],
@@ -17567,7 +17572,7 @@ class StructureChart {
17567
17572
  */
17568
17573
  setSource(filter) {
17569
17574
  var _a, _b;
17570
- this.state = FactoryState$3.DIRTY;
17575
+ this.state = FactoryState$2.DIRTY;
17571
17576
  this.queryError = undefined;
17572
17577
  // "" while the source is not registered yet: no data, and no error
17573
17578
  this.fromExpr = withHasError.sourceExpr(this.db, this.tableName, filter);
@@ -17693,8 +17698,8 @@ class StructureChart {
17693
17698
  draw(svgContainer) {
17694
17699
  this.cleanSVGforRedraw(svgContainer);
17695
17700
  this.applyFontToContainer(svgContainer);
17696
- if (this.state === FactoryState$3.DIRTY) {
17697
- this.state = FactoryState$3.UP_TO_DATE;
17701
+ if (this.state === FactoryState$2.DIRTY) {
17702
+ this.state = FactoryState$2.UP_TO_DATE;
17698
17703
  }
17699
17704
  if (this.variancesDataModel && this.variancesDataModel.length > 0) {
17700
17705
  this.drawVarianceScenario(this.variancesDataModel, svgContainer);
@@ -18111,7 +18116,10 @@ class StructureChart {
18111
18116
  }
18112
18117
  calculatePercentageTextBoxWidth(value) {
18113
18118
  let signWidth = 0;
18114
- if (value >= 0) {
18119
+ // like the label: no sign for a value that rounds to zero
18120
+ const digits = this.dataFormatDigits.percent;
18121
+ const percent = (v) => Formatter.number(v, "percent", digits, digits, 1, this.styles.locale);
18122
+ if (value > 0 && percent(value) !== percent(0)) {
18115
18123
  signWidth += CalculateSize("+", {
18116
18124
  font: this.styles.fontStyles.font,
18117
18125
  fontSize: this.styles.fontStyles.size + "px",
@@ -20732,12 +20740,12 @@ var Scenario;
20732
20740
  Scenario["NEU"] = "neu";
20733
20741
  })(Scenario || (Scenario = {}));
20734
20742
  /** Chart-internal table aggregation modes. */
20735
- var TableType$1;
20743
+ var TableType;
20736
20744
  (function (TableType) {
20737
20745
  TableType["LIST"] = "LIST";
20738
20746
  TableType["SUM"] = "SUM";
20739
20747
  TableType["OPT"] = "OPT";
20740
- })(TableType$1 || (TableType$1 = {}));
20748
+ })(TableType || (TableType = {}));
20741
20749
 
20742
20750
  /**
20743
20751
  * Renders the horizontal baseline axis for a time chart.
@@ -22132,11 +22140,11 @@ function drawAttached(container, drawFn) {
22132
22140
  /** Above this many periods between the first and the last date, gaps are not filled with empty periods. */
22133
22141
  const MAX_GAP_FILLED_PERIODS = 10000;
22134
22142
  /** Tracks whether the internal data model needs to be regenerated. */
22135
- var FactoryState$2;
22143
+ var FactoryState$1;
22136
22144
  (function (FactoryState) {
22137
22145
  FactoryState[FactoryState["UP_TO_DATE"] = 0] = "UP_TO_DATE";
22138
22146
  FactoryState[FactoryState["DIRTY"] = 1] = "DIRTY";
22139
- })(FactoryState$2 || (FactoryState$2 = {}));
22147
+ })(FactoryState$1 || (FactoryState$1 = {}));
22140
22148
  /** Classifies how a data model entry should be rendered: as an absolute or relative variance, or as a regular scenario. */
22141
22149
  var VarianceType;
22142
22150
  (function (VarianceType) {
@@ -22186,7 +22194,7 @@ class TimeChart {
22186
22194
  this.rowCount = 0;
22187
22195
  this.axisCategoryArea = { width: 0, height: 0 };
22188
22196
  this.scenariosArea = { width: 0, height: 0 };
22189
- this.state = FactoryState$2.DIRTY;
22197
+ this.state = FactoryState$1.DIRTY;
22190
22198
  this.i18n = new Map();
22191
22199
  this.leftSideOffsetForHorizontalSync = -1;
22192
22200
  this.dateInterval = withStyled.DateDistance.DAY;
@@ -22285,7 +22293,7 @@ class TimeChart {
22285
22293
  }
22286
22294
  setConfig(config) {
22287
22295
  var _a;
22288
- this.state = FactoryState$2.DIRTY;
22296
+ this.state = FactoryState$1.DIRTY;
22289
22297
  // Must precede setSource/populateModel: the locale is baked into the
22290
22298
  // normalizeDate() SQL as well as into the axis date labels.
22291
22299
  this.locale = config.locale;
@@ -22379,7 +22387,7 @@ class TimeChart {
22379
22387
  */
22380
22388
  setSource(filter) {
22381
22389
  var _a, _b;
22382
- this.state = FactoryState$2.DIRTY;
22390
+ this.state = FactoryState$1.DIRTY;
22383
22391
  this.queryError = undefined;
22384
22392
  // "" while the source is not registered yet: no data, and no error
22385
22393
  this.fromExpr = withHasError.sourceExpr(this.db, this.tableName, filter);
@@ -22523,8 +22531,8 @@ class TimeChart {
22523
22531
  draw(svgContainer) {
22524
22532
  this.cleanSVGforRedraw(svgContainer);
22525
22533
  this.applyFontToContainer(svgContainer);
22526
- if (this.state === FactoryState$2.DIRTY) {
22527
- this.state = FactoryState$2.UP_TO_DATE;
22534
+ if (this.state === FactoryState$1.DIRTY) {
22535
+ this.state = FactoryState$1.UP_TO_DATE;
22528
22536
  }
22529
22537
  if (this.isVarianceChart()) {
22530
22538
  this.drawVarianceScenario(this.variancesDataModel, svgContainer);
@@ -22590,7 +22598,7 @@ class TimeChart {
22590
22598
  }
22591
22599
  }
22592
22600
  createI18n(i18n) {
22593
- this.state = FactoryState$2.DIRTY;
22601
+ this.state = FactoryState$1.DIRTY;
22594
22602
  const defaultI18n = new Map([
22595
22603
  ["SEPARATOR_WS", ", "],
22596
22604
  ["in", "in"],
@@ -26548,70 +26556,6 @@ const ScalingGroup = class {
26548
26556
  };
26549
26557
  ScalingGroup.style = bnScalingGroupCss();
26550
26558
 
26551
- /** Sentinel value indicating all groups should be included. */
26552
- var GroupSelection;
26553
- (function (GroupSelection) {
26554
- GroupSelection[GroupSelection["ALL"] = -1] = "ALL";
26555
- })(GroupSelection || (GroupSelection = {}));
26556
- /**
26557
- * Tracks whether a factory's output is current or needs recalculation.
26558
- * Used to avoid redundant re-rendering when underlying data has not changed.
26559
- */
26560
- var FactoryState$1;
26561
- (function (FactoryState) {
26562
- /** Output matches the current input data. */
26563
- FactoryState[FactoryState["UP_TO_DATE"] = 0] = "UP_TO_DATE";
26564
- /** Input data has changed; output needs to be regenerated. */
26565
- FactoryState[FactoryState["DIRTY"] = 1] = "DIRTY";
26566
- })(FactoryState$1 || (FactoryState$1 = {}));
26567
- /**
26568
- * Table aggregation modes controlling how rows are grouped and totalled.
26569
- *
26570
- * - `LIST` -- Flat list with no aggregation.
26571
- * - `SUM` -- Grouped rows with sum totals per group and a grand total.
26572
- * - `SUMNOTOTAL` -- Grouped rows with group sums but no grand total row.
26573
- * - `OPT` -- Operation-aware aggregation (respects the +/- operation field).
26574
- * - `OPTNOTOTAL` -- Operation-aware aggregation without a grand total row.
26575
- */
26576
- var TableType;
26577
- (function (TableType) {
26578
- TableType["LIST"] = "list";
26579
- TableType["SUM"] = "sum";
26580
- TableType["SUMNOTOTAL"] = "sumnototal";
26581
- TableType["OPT"] = "opt";
26582
- TableType["OPTNOTOTAL"] = "optnototal";
26583
- })(TableType || (TableType = {}));
26584
- var OrderDirection;
26585
- (function (OrderDirection) {
26586
- OrderDirection["ASC"] = "asc";
26587
- OrderDirection["DESC"] = "desc";
26588
- })(OrderDirection || (OrderDirection = {}));
26589
- /**
26590
- * Discriminator for rendered table rows, controlling visual styling and behavior.
26591
- *
26592
- * - `HEADER` -- Column header row.
26593
- * - `GROUPHEAD` -- Group title row (rendered when `grouped` is true).
26594
- * - `SEPERATORLINE` -- Visual divider between groups.
26595
- * - `SUM` -- Grand total row.
26596
- * - `GROUPSUM` -- Sub-total row for a single group.
26597
- * - `DRILLELEMENT` -- "Thereof" drill-down sub-row.
26598
- * - `STANDARD` -- Normal data row.
26599
- * - `PARTELEMENT` -- "Part of" percentage row.
26600
- * - `ENTRY` -- Generic entry row.
26601
- */
26602
- var TableRowType;
26603
- (function (TableRowType) {
26604
- TableRowType["HEADER"] = "HEADER";
26605
- TableRowType["GROUPHEAD"] = "GROUPHEAD";
26606
- TableRowType["SEPERATORLINE"] = "SEPERATORLINE";
26607
- TableRowType["SUM"] = "SUM";
26608
- TableRowType["GROUPSUM"] = "GROUP_SUM";
26609
- TableRowType["DRILLELEMENT"] = "DRILLELEMENT";
26610
- TableRowType["STANDARD"] = "STANDARD";
26611
- TableRowType["PARTELEMENT"] = "PARTELEMENT";
26612
- TableRowType["ENTRY"] = "ENTRY";
26613
- })(TableRowType || (TableRowType = {}));
26614
-
26615
26559
  /** `interval` value deactivating the feature. */
26616
26560
  const INTERVAL_NONE = "none";
26617
26561
  /** `interval` value grouping by the dataset's `setname` column. */
@@ -26634,6 +26578,16 @@ function intervalBucketSQL(interval) {
26634
26578
  }
26635
26579
  return `normalizeDate([date], '${interval}')`;
26636
26580
  }
26581
+ /** SQL expression reading the optional `setnameIndex` column, tolerant like `setname`. */
26582
+ const SETNAME_INDEX_SQL = "COALESCE([setnameIndex],[setNameIndex])";
26583
+ /** A raw `setnameIndex` value as a number; undefined when it is blank or not numeric. */
26584
+ function coerceSetnameIndex(value) {
26585
+ if (typeof value === "string" ? value.trim() === "" : typeof value !== "number") {
26586
+ return undefined;
26587
+ }
26588
+ const index = Number(value);
26589
+ return Number.isFinite(index) ? index : undefined;
26590
+ }
26637
26591
  /** Coerces a raw bucket value (luxon DateTime, string, millis) to a stable string key. */
26638
26592
  function coerceBucketKey(value) {
26639
26593
  if (value == null) {
@@ -26680,22 +26634,36 @@ function resolveIntervalGranularity(db, fromExpr, interval) {
26680
26634
  * Date buckets are sorted chronologically ascending and labeled locale-aware;
26681
26635
  * setname buckets keep their order of first appearance in the data, blank
26682
26636
  * setnames are collected in a trailing-position "-" bucket where they occur.
26637
+ * When rows carry a numeric `setnameIndex`, the setname buckets are sorted
26638
+ * ascending by the smallest index of each setname. Buckets without an index
26639
+ * follow, and ties keep the order of first appearance.
26683
26640
  */
26684
26641
  function queryIntervalBuckets(db, fromExpr, interval, locale) {
26685
- const rows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval FROM ${fromExpr}`);
26686
26642
  if (interval === INTERVAL_SETNAME) {
26643
+ const setRows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval, ${SETNAME_INDEX_SQL} as __index FROM ${fromExpr}`);
26687
26644
  const seen = new Set();
26645
+ const indexes = new Map();
26688
26646
  const buckets = [];
26689
- for (const row of rows) {
26647
+ for (const row of setRows) {
26690
26648
  const key = coerceBucketKey(row.__interval);
26691
- if (seen.has(key)) {
26692
- continue;
26649
+ if (!seen.has(key)) {
26650
+ seen.add(key);
26651
+ buckets.push({ key, label: key.length === 0 ? BLANK_BUCKET_LABEL : key });
26693
26652
  }
26694
- seen.add(key);
26695
- buckets.push({ key, label: key.length === 0 ? BLANK_BUCKET_LABEL : key });
26653
+ const index = coerceSetnameIndex(row.__index);
26654
+ const known = indexes.get(key);
26655
+ if (index !== undefined && (known === undefined || index < known)) {
26656
+ indexes.set(key, index);
26657
+ }
26658
+ }
26659
+ // without any index the order of first appearance stays as it is
26660
+ if (indexes.size > 0) {
26661
+ const rank = (bucket) => { var _a; return (_a = indexes.get(bucket.key)) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY; };
26662
+ buckets.sort((a, b) => (rank(a) === rank(b) ? 0 : rank(a) < rank(b) ? -1 : 1));
26696
26663
  }
26697
26664
  return buckets;
26698
26665
  }
26666
+ const rows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval FROM ${fromExpr}`);
26699
26667
  const seen = new Set();
26700
26668
  const dates = [];
26701
26669
  for (const row of rows) {
@@ -26770,6 +26738,8 @@ const Table$1 = class Table {
26770
26738
  this.appliedScaleFactor = 1;
26771
26739
  /** True when the active dataset contains rows with a blank `setname` (relevant for `interval='setname'`). */
26772
26740
  this.hasBlankSetnames = false;
26741
+ /** True when the active dataset contains rows with a `setnameIndex` but a blank `setname`. */
26742
+ this.hasSetnameIndexWithoutSetname = false;
26773
26743
  /**
26774
26744
  * Label of the grand-total row at the bottom of the table. Only rendered for
26775
26745
  * `type="sum"` and `type="opt"`; the other table types have no total row.
@@ -26798,7 +26768,7 @@ const Table$1 = class Table {
26798
26768
  /**
26799
26769
  * Data units displayed per 1 em of bar length for absolute variance bar
26800
26770
  * charts (ΔPY) - map-scale semantics: a larger value means smaller bars.
26801
- * Bars exceeding barColumnWidth are shown with an arrow indicator.
26771
+ * Bars exceeding barColumnWidth are cut with a zigzag break.
26802
26772
  *
26803
26773
  * | Value | Behavior |
26804
26774
  * |------------------|----------------------------------------------------------------|
@@ -26866,6 +26836,37 @@ const Table$1 = class Table {
26866
26836
  *
26867
26837
  */
26868
26838
  this.showGroupTitle = true;
26839
+ /**
26840
+ * Turns the sum row of each (row-)group into a running result: the sum of all
26841
+ * rows from the first group down to its own group, with the matching absolute
26842
+ * and relative variances. Use it for a calculation scheme such as an income
26843
+ * statement, where each `rowGroup` ends in a result.
26844
+ * <br /><br />
26845
+ * Needs `grouped` and a type with group sums (```sum // opt // sumnototal // optnototal```).
26846
+ * The total row of ```sum``` and ```opt``` stays and repeats the last running
26847
+ * result, so ```sumnototal``` or ```optnototal``` is the usual choice.
26848
+ * `partof` shares still refer to the sum of their own group.
26849
+ * Not supported together with `columnthereof`: there it has no effect.
26850
+ * <br /><br />
26851
+ * values: <br />
26852
+ * ```true // false```
26853
+ */
26854
+ this.runningSum = false;
26855
+ /**
26856
+ * Draws every absolute variance column (d_*) listed in ```barColumns``` as a
26857
+ * variance waterfall down the rows instead of single bars from the axis.
26858
+ * A row starts where the row above ended; on ```opt``` and ```optnototal```
26859
+ * tables a "-" row with a positive variance moves to the left. Sum rows are
26860
+ * bars from the axis. Thin lines join the bars. Each row group starts at the
26861
+ * axis again, with ```runningSum``` the walk goes on from the sum row.
26862
+ * The column scales to fit the whole walk (unit-scaling does not apply).
26863
+ * Relative variance columns (dr_*) stay pins.
26864
+ * Has no effect together with ```interval``` or ```columnthereof```.
26865
+ * <br /><br />
26866
+ * values: <br />
26867
+ * ```true // false```
26868
+ */
26869
+ this.varianceWaterfall = false;
26869
26870
  /**
26870
26871
  * Set the table type
26871
26872
  * <br /><br />
@@ -26893,6 +26894,21 @@ const Table$1 = class Table {
26893
26894
  * ```[{"rowGroup": "Umsatz", "category": "Applications", "subCategory": "Applications-A"}]```
26894
26895
  */
26895
26896
  this.thereof = "[]";
26897
+ /**
26898
+ * Position of the `thereof` rows relative to their parent row.
26899
+ * <br /><br />
26900
+ * ```below``` (default) prints them below the parent, small and italic, with
26901
+ * the thereof label. ```above``` prints them before the parent in normal
26902
+ * size with an indented label, and the parent row looks like a subtotal
26903
+ * (bold, with a line above it). The parent keeps its operation sign and its
26904
+ * value, so a parent of `-` rows reads like "- Operating expenses".
26905
+ * With ```above``` list all subcategories of the parent (`"subCategory": ""`):
26906
+ * with only some of them the parent looks like a subtotal that does not add up.
26907
+ * <br /><br />
26908
+ * values: <br />
26909
+ * ```below // above```
26910
+ */
26911
+ this.thereofPosition = "below";
26896
26912
  /**
26897
26913
  * JSON array of part-of objects with the keys `rowGroup` and `category`
26898
26914
  * (both strings, both required).
@@ -27018,8 +27034,27 @@ const Table$1 = class Table {
27018
27034
  * raise a warning and are grouped under `-`. Date values bucket rows by the
27019
27035
  * `date` column; ```auto``` detects the granularity from the date span.
27020
27036
  * Cannot be combined with `columnthereof`.
27037
+ * <br /><br />
27038
+ * Date groups are shown in chronological order. Setname groups are shown in
27039
+ * order of first appearance in the dataset. When the rows carry the optional
27040
+ * numeric column `setnameIndex`, the setname groups are sorted ascending by
27041
+ * it: the smallest index of a setname counts, groups without an index come
27042
+ * last.
27021
27043
  */
27022
27044
  this.interval = "none";
27045
+ /**
27046
+ * Number of interval groups that stand left of the category column. Needs
27047
+ * an active `interval`.
27048
+ * <br /><br />
27049
+ * ```0``` (default) keeps the category column first. ```1``` puts one
27050
+ * interval group left of it and the rest right. The number of interval
27051
+ * groups puts the category column last. A greater value raises a warning
27052
+ * and is used as the number of groups.
27053
+ * <br /><br />
27054
+ * The operation column and the `attributes` columns move with the category
27055
+ * column.
27056
+ */
27057
+ this.categoryIntervalPosition = 0;
27023
27058
  /**
27024
27059
  * Stringified JSON object defining custom columns computed from dataset fields.<br />
27025
27060
  * Keys are column labels, values are aggregate expressions over the rows that
@@ -27085,6 +27120,13 @@ const Table$1 = class Table {
27085
27120
  this.dataVersion = this.dataVersion + 1;
27086
27121
  this.hasBlankSetnames =
27087
27122
  Array.isArray(data) && data.some((row) => { var _a; return withStyled.isBlankInput(((_a = row === null || row === void 0 ? void 0 : row.setname) !== null && _a !== void 0 ? _a : row === null || row === void 0 ? void 0 : row.setName)); });
27123
+ this.hasSetnameIndexWithoutSetname =
27124
+ Array.isArray(data) &&
27125
+ data.some((row) => {
27126
+ var _a, _b;
27127
+ return coerceSetnameIndex((_a = row === null || row === void 0 ? void 0 : row.setnameIndex) !== null && _a !== void 0 ? _a : row === null || row === void 0 ? void 0 : row.setNameIndex) !== undefined &&
27128
+ withStyled.isBlankInput(((_b = row === null || row === void 0 ? void 0 : row.setname) !== null && _b !== void 0 ? _b : row === null || row === void 0 ? void 0 : row.setName));
27129
+ });
27088
27130
  }, (_name, meta) => {
27089
27131
  this.datasetMeta = meta;
27090
27132
  });
@@ -27255,6 +27297,19 @@ const Table$1 = class Table {
27255
27297
  this.errors.remove(errId);
27256
27298
  }
27257
27299
  }
27300
+ validateThereofPosition(newValue) {
27301
+ const errId = "WARN_thereofPosition";
27302
+ if (withStyled.isBlankInput(newValue) || withStyled.isValidThereofPosition(newValue)) {
27303
+ this.errors.remove(errId);
27304
+ }
27305
+ else {
27306
+ this.errors.addOrReplace({
27307
+ id: errId,
27308
+ type: "warning",
27309
+ message: "thereofPosition: invalid value '" + newValue + "' is not supported.",
27310
+ });
27311
+ }
27312
+ }
27258
27313
  validatePartOf(newValue) {
27259
27314
  const errId = "WARN_partof";
27260
27315
  const invalidElements = withStyled.validatePartOfJsonStr(newValue);
@@ -27397,6 +27452,19 @@ const Table$1 = class Table {
27397
27452
  });
27398
27453
  }
27399
27454
  }
27455
+ validateCategoryIntervalPosition(newValue) {
27456
+ const errId = "WARN_categoryIntervalPosition";
27457
+ if (withStyled.isBlankInput(newValue) || (withStyled.isValidInteger(newValue) && Number(newValue) >= 0)) {
27458
+ this.errors.remove(errId);
27459
+ }
27460
+ else {
27461
+ this.errors.addOrReplace({
27462
+ id: errId,
27463
+ type: "warning",
27464
+ message: "categoryIntervalPosition: invalid value '" + newValue + "' is not supported.",
27465
+ });
27466
+ }
27467
+ }
27400
27468
  validateTableAttributes(newValue) {
27401
27469
  const errId = "WARN_attributes";
27402
27470
  const invalidElements = withStyled.validateAttributesJsonStr(newValue);
@@ -27419,6 +27487,7 @@ const Table$1 = class Table {
27419
27487
  this.validateType(this.type);
27420
27488
  this.validateLimit(this.limit);
27421
27489
  this.validateThereOf(this.thereof);
27490
+ this.validateThereofPosition(this.thereofPosition);
27422
27491
  this.validatePartOf(this.partof);
27423
27492
  this.validateOrderDirection(this.orderDirection);
27424
27493
  this.validateOrderList(this.order);
@@ -27429,6 +27498,7 @@ const Table$1 = class Table {
27429
27498
  this.validateMeasureScale(this.measureScale);
27430
27499
  this.validateColumnThereOf(this.columnthereof);
27431
27500
  this.validateInterval(this.interval);
27501
+ this.validateCategoryIntervalPosition(this.categoryIntervalPosition);
27432
27502
  this.validateTableAttributes(this.tableAttributes);
27433
27503
  this.validateBarColumns(this.barColumns);
27434
27504
  this.validateBarColumnWidth(this.barColumnWidth);
@@ -27561,9 +27631,15 @@ const Table$1 = class Table {
27561
27631
  prepareShowGroupTitle() {
27562
27632
  return this.showGroupTitle;
27563
27633
  }
27634
+ prepareThereofPosition() {
27635
+ var _a;
27636
+ return ((_a = this.thereofPosition) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === withStyled.ThereofPosition.ABOVE
27637
+ ? withStyled.ThereofPosition.ABOVE
27638
+ : withStyled.ThereofPosition.BELOW;
27639
+ }
27564
27640
  prepareTableType() {
27565
27641
  var _a;
27566
- return TableType[(_a = this.type) === null || _a === void 0 ? void 0 : _a.toUpperCase()];
27642
+ return withStyled.TableType[(_a = this.type) === null || _a === void 0 ? void 0 : _a.toUpperCase()];
27567
27643
  }
27568
27644
  prepareLimit() {
27569
27645
  return Math.floor(Number(this.limit) || 0);
@@ -27745,6 +27821,7 @@ const Table$1 = class Table {
27745
27821
  const conflictErrId = "WARN_intervalConflict";
27746
27822
  const noDateErrId = "WARN_intervalNoDate";
27747
27823
  const setnameErrId = "WARN_intervalSetname";
27824
+ const setnameIndexErrId = "WARN_intervalSetnameIndex";
27748
27825
  const interval = withStyled.isBlankInput(this.interval) ? INTERVAL_NONE : this.interval.trim().toLowerCase();
27749
27826
  const isValid = interval === INTERVAL_NONE || interval === INTERVAL_SETNAME || withStyled.isValidDateFormat(interval);
27750
27827
  // invalid values are already reported by validateInterval
@@ -27752,6 +27829,7 @@ const Table$1 = class Table {
27752
27829
  this.errors.remove(conflictErrId);
27753
27830
  this.errors.remove(noDateErrId);
27754
27831
  this.errors.remove(setnameErrId);
27832
+ this.errors.remove(setnameIndexErrId);
27755
27833
  return INTERVAL_NONE;
27756
27834
  }
27757
27835
  if (this.columnthereof != null && this.columnthereof.trim() !== "") {
@@ -27762,6 +27840,7 @@ const Table$1 = class Table {
27762
27840
  });
27763
27841
  this.errors.remove(noDateErrId);
27764
27842
  this.errors.remove(setnameErrId);
27843
+ this.errors.remove(setnameIndexErrId);
27765
27844
  return INTERVAL_NONE;
27766
27845
  }
27767
27846
  this.errors.remove(conflictErrId);
@@ -27776,10 +27855,21 @@ const Table$1 = class Table {
27776
27855
  else {
27777
27856
  this.errors.remove(setnameErrId);
27778
27857
  }
27858
+ if (this.hasSetnameIndexWithoutSetname) {
27859
+ this.errors.addOrReplace({
27860
+ id: setnameIndexErrId,
27861
+ type: "warning",
27862
+ message: "interval: rows with setnameIndex but blank setname found, setnameIndex needs setname.",
27863
+ });
27864
+ }
27865
+ else {
27866
+ this.errors.remove(setnameIndexErrId);
27867
+ }
27779
27868
  this.errors.remove(noDateErrId);
27780
27869
  return INTERVAL_SETNAME;
27781
27870
  }
27782
27871
  this.errors.remove(setnameErrId);
27872
+ this.errors.remove(setnameIndexErrId);
27783
27873
  if (this.datasetMeta && !((_a = this.datasetMeta.dateRange) === null || _a === void 0 ? void 0 : _a.hasData)) {
27784
27874
  this.errors.addOrReplace({
27785
27875
  id: noDateErrId,
@@ -27791,6 +27881,10 @@ const Table$1 = class Table {
27791
27881
  this.errors.remove(noDateErrId);
27792
27882
  return interval;
27793
27883
  }
27884
+ prepareCategoryIntervalPosition() {
27885
+ const position = Number(this.categoryIntervalPosition);
27886
+ return Number.isInteger(position) && position > 0 ? position : 0;
27887
+ }
27794
27888
  prepareAttributes() {
27795
27889
  if (this.tableAttributes == null || this.tableAttributes.trim() === "") {
27796
27890
  return [];
@@ -27896,6 +27990,7 @@ const Table$1 = class Table {
27896
27990
  const dataSetStructure = {
27897
27991
  ITableDataRow: {
27898
27992
  setName: { type: "string", isOptional: false, description: "" },
27993
+ setNameIndex: { type: "number", isOptional: true, description: "" },
27899
27994
  date: { type: "string", isOptional: false, description: "" },
27900
27995
  operation: { type: "string", isOptional: false, description: "" },
27901
27996
  rowGroup: { type: "string", isOptional: false, description: "" },
@@ -28051,7 +28146,7 @@ const Table$1 = class Table {
28051
28146
  render() {
28052
28147
  const fontStyles = this.getFontStyles();
28053
28148
  const effectiveFactor = this.getEffectiveScaleFactor();
28054
- return (index.h(index.Host, { key: '42974a4931f678c35e5c740bf6d630966368fb4b', style: fontStyles }, index.h("div", { key: '2c8f99a8bd155e2c93e55e9542090d04afe22a31' }, index.h("bn-table-renderer", { key: 'cae9e83bf297e730f12a8a390cbf279413c40b54', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
28149
+ return (index.h(index.Host, { key: '2af1b7f31952cd0ba32e0a069ce143d3402b4a77', style: fontStyles }, index.h("div", { key: 'b78ad13abb48a43c1da0aec4727372a482c39701' }, index.h("bn-table-renderer", { key: 'ab0132a3b57953379f6d8f5f19a18f95a14cc326', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), runningSum: this.runningSum, varianceWaterfall: this.varianceWaterfall, thereof: this.prepareThereOf(), thereofPosition: this.prepareThereofPosition(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), categoryIntervalPosition: this.prepareCategoryIntervalPosition(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
28055
28150
  }
28056
28151
  get element() { return index.getElement(this); }
28057
28152
  static get watchers() { return {
@@ -28091,6 +28186,9 @@ const Table$1 = class Table {
28091
28186
  "thereof": [{
28092
28187
  "validateThereOf": 0
28093
28188
  }],
28189
+ "thereofPosition": [{
28190
+ "validateThereofPosition": 0
28191
+ }],
28094
28192
  "partof": [{
28095
28193
  "validatePartOf": 0
28096
28194
  }],
@@ -28121,6 +28219,9 @@ const Table$1 = class Table {
28121
28219
  "interval": [{
28122
28220
  "validateInterval": 0
28123
28221
  }],
28222
+ "categoryIntervalPosition": [{
28223
+ "validateCategoryIntervalPosition": 0
28224
+ }],
28124
28225
  "tableAttributes": [{
28125
28226
  "validateTableAttributes": 0
28126
28227
  }]
@@ -28169,7 +28270,16 @@ class Cell {
28169
28270
  return result;
28170
28271
  }
28171
28272
  draw(dataFormatDigits, locale) {
28172
- let cellValue = this.value;
28273
+ return this.format(this.value, dataFormatDigits, locale);
28274
+ }
28275
+ /** True when the cell prints a number that is zero at the displayed digits. */
28276
+ roundsToZero(dataFormatDigits, locale) {
28277
+ return (typeof this.value === "number" &&
28278
+ !!this.type &&
28279
+ this.draw(dataFormatDigits, locale) === this.format(0, dataFormatDigits, locale));
28280
+ }
28281
+ format(value, dataFormatDigits, locale) {
28282
+ let cellValue = value;
28173
28283
  if (cellValue === "undefined" || cellValue === undefined || cellValue == null) {
28174
28284
  return "";
28175
28285
  }
@@ -28226,22 +28336,22 @@ class TableRow {
28226
28336
  }
28227
28337
  initCssStyle() {
28228
28338
  switch (this.type) {
28229
- case TableRowType.HEADER: {
28339
+ case withStyled.TableRowType.HEADER: {
28230
28340
  return "groupheader";
28231
28341
  }
28232
- case TableRowType.SEPERATORLINE: {
28342
+ case withStyled.TableRowType.SEPERATORLINE: {
28233
28343
  return "";
28234
28344
  }
28235
- case TableRowType.DRILLELEMENT: {
28345
+ case withStyled.TableRowType.DRILLELEMENT: {
28236
28346
  return "ofit";
28237
28347
  }
28238
- case TableRowType.PARTELEMENT: {
28348
+ case withStyled.TableRowType.PARTELEMENT: {
28239
28349
  return "partof";
28240
28350
  }
28241
- case TableRowType.STANDARD: {
28351
+ case withStyled.TableRowType.STANDARD: {
28242
28352
  return "";
28243
28353
  }
28244
- case TableRowType.SUM: {
28354
+ case withStyled.TableRowType.SUM: {
28245
28355
  return "sum";
28246
28356
  }
28247
28357
  default: {
@@ -28257,13 +28367,13 @@ class TableRow {
28257
28367
  if (scenario === "category" && categoryWidth != null) {
28258
28368
  cssStyle = `category-${categoryWidth.toString()}`;
28259
28369
  }
28260
- if (this.type === TableRowType.HEADER) {
28370
+ if (this.type === withStyled.TableRowType.HEADER) {
28261
28371
  cssStyle = "headerlabel";
28262
28372
  }
28263
- else if (this.type === TableRowType.SEPERATORLINE) {
28373
+ else if (this.type === withStyled.TableRowType.SEPERATORLINE) {
28264
28374
  cssStyle = cellStyle !== null && cellStyle !== void 0 ? cellStyle : scenario;
28265
28375
  }
28266
- if (this.type === TableRowType.PARTELEMENT) {
28376
+ if (this.type === withStyled.TableRowType.PARTELEMENT) {
28267
28377
  if (cellType === "percent") {
28268
28378
  value = "-";
28269
28379
  }
@@ -28374,24 +28484,27 @@ function labelMeasureContext() {
28374
28484
  }
28375
28485
  return measureContext;
28376
28486
  }
28487
+ /** Bold digits of a font can be wider than the regular ones the glyph table lists. */
28488
+ const BOLD_WIDTH_MARGIN = 1.08;
28377
28489
  /**
28378
28490
  * Rendered width of a value label in px, measured with the font the SVG text uses. Falls
28379
28491
  * back to estimateLabelWidth where no canvas can measure.
28380
28492
  */
28381
- function labelWidth(text, fontSize, fontFamily, italic) {
28493
+ function labelWidth(text, fontSize, fontFamily, italic, bold = false) {
28494
+ const estimate = () => estimateLabelWidth(text, fontSize) * (bold ? BOLD_WIDTH_MARGIN : 1);
28382
28495
  const ctx = labelMeasureContext();
28383
28496
  if (ctx) {
28384
28497
  // the canvas ignores a font it cannot parse and keeps the last one: the sentinel shows that
28385
28498
  ctx.font = FONT_SENTINEL;
28386
28499
  const sentinel = ctx.font;
28387
- ctx.font = `${italic ? "italic " : ""}${fontSize}px ${fontFamily}`;
28500
+ ctx.font = `${italic ? "italic " : ""}${bold ? "bold " : ""}${fontSize}px ${fontFamily}`;
28388
28501
  if (ctx.font === sentinel)
28389
- return estimateLabelWidth(text, fontSize);
28502
+ return estimate();
28390
28503
  const width = ctx.measureText(text).width;
28391
28504
  if (Number.isFinite(width) && (width > 0 || text === ""))
28392
28505
  return width + MEASURE_PAD * fontSize;
28393
28506
  }
28394
- return estimateLabelWidth(text, fontSize);
28507
+ return estimate();
28395
28508
  }
28396
28509
  /** The SVG fills the cell's content box: the requested column width minus the cell padding. */
28397
28510
  function contentWidth(widthEm, emPx) {
@@ -28507,14 +28620,59 @@ function relativePinGeometry(widthEm, emPx, labels, headSize, reach) {
28507
28620
  labelGap,
28508
28621
  };
28509
28622
  }
28510
- function waterfallGeometry(widthEm, emPx) {
28623
+ /**
28624
+ * Without `column` both sides get the fixed gutter. With it each side gets the room its
28625
+ * labels need beyond the bar area at the scale of the bars. The bar area keeps at least
28626
+ * half the width: only gutters that need more shrink, and a side that fits the fixed
28627
+ * gutter keeps its room then.
28628
+ */
28629
+ function waterfallGeometry(widthEm, emPx, column) {
28511
28630
  const totalWidth = contentWidth(widthEm, emPx);
28512
- const labelAreaWidth = Math.min(BAR_LABEL_EM * emPx, totalWidth / 4);
28631
+ const labelGap = LABEL_GAP_EM * emPx;
28632
+ const fixed = Math.min(BAR_LABEL_EM * emPx, totalWidth / 4);
28633
+ let left = fixed;
28634
+ let right = fixed;
28635
+ const range = column ? column.max - column.min : 0;
28636
+ if (column && range > 0) {
28637
+ // what the labels of one side stick out of the bar area at the given scale
28638
+ const room = (pointsLeft, pxPerUnit) => Math.max(0, ...column.labels
28639
+ .filter((label) => label.pointsLeft === pointsLeft)
28640
+ .map((label) => label.width + labelGap - (pointsLeft ? label.end - column.min : column.max - label.end) * pxPerUnit));
28641
+ left = room(true, 0);
28642
+ right = room(false, 0);
28643
+ const budget = totalWidth / 2;
28644
+ // a label needs less room the further its bar ends from the edge; a smaller gutter only widens the scale.
28645
+ // One pass is enough for gutters that fit; more passes only while they take more than half the width.
28646
+ for (let pass = 0; pass < 8; pass++) {
28647
+ const pxPerUnit = Math.max(0, totalWidth - left - right) / range;
28648
+ const nextLeft = Math.min(left, room(true, pxPerUnit));
28649
+ const nextRight = Math.min(right, room(false, pxPerUnit));
28650
+ const settled = nextLeft + nextRight <= budget || (nextLeft === left && nextRight === right);
28651
+ left = nextLeft;
28652
+ right = nextRight;
28653
+ if (settled)
28654
+ break;
28655
+ }
28656
+ if (left + right > budget) {
28657
+ if (Math.min(left, right) > fixed) {
28658
+ const shrink = budget / (left + right);
28659
+ left *= shrink;
28660
+ right *= shrink;
28661
+ }
28662
+ else if (left <= right) {
28663
+ right = budget - left;
28664
+ }
28665
+ else {
28666
+ left = budget - right;
28667
+ }
28668
+ }
28669
+ }
28513
28670
  return {
28514
28671
  totalWidth,
28515
- labelAreaWidth,
28516
- barAreaWidth: totalWidth - labelAreaWidth * 2,
28517
- labelGap: LABEL_GAP_EM * emPx,
28672
+ labelAreaLeft: left,
28673
+ labelAreaRight: right,
28674
+ barAreaWidth: totalWidth - left - right,
28675
+ labelGap,
28518
28676
  };
28519
28677
  }
28520
28678
 
@@ -28542,6 +28700,10 @@ const DEFAULT_STYLES = {
28542
28700
  const AXIS_COLOR = "#666666";
28543
28701
  /** Width of the pin line, in px before scaleFactor. */
28544
28702
  const PIN_LINE_WIDTH = 3;
28703
+ /** Arrow head of a cut pin, in sides of the square pin head: IBCS draws it a bit larger. */
28704
+ const PIN_ARROW_RATIO = 1.2;
28705
+ /** Padding of the light band under the label on a cut pin, in label font sizes. */
28706
+ const PIN_BAND_PAD = 0.2;
28545
28707
  /**
28546
28708
  * Creates a unique pattern ID for the SVG defs
28547
28709
  */
@@ -28776,11 +28938,11 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
28776
28938
  * exactly `columnWidthEm` em - see barColumnGeometry.ts.
28777
28939
  */
28778
28940
  const AbsoluteVarianceBar = (props) => {
28779
- const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
28941
+ const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, bold, styles = DEFAULT_STYLES, } = props;
28780
28942
  const s = styles.scaleFactor;
28781
28943
  const fs = styles.fontSize;
28782
28944
  const displayValue = formattedValue || formatValue(value, false, measureScale, locale, 0, true, decimalDigits);
28783
- const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false));
28945
+ const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false, bold));
28784
28946
  const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
28785
28947
  const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
28786
28948
  const geometry = absoluteBarGeometry(columnWidthEm, styles.emPx, sides, { neg, pos });
@@ -28833,7 +28995,8 @@ const AbsoluteVarianceBar = (props) => {
28833
28995
  * Renders a relative variance pin chart (dr_ prefix).
28834
28996
  * Line from the axis in the sentiment colour, ending in a square head in the look of the
28835
28997
  * minuend, with the value label beside the head like an absolute bar label. A pin beyond
28836
- * the pin area is cut and ends in an arrow, its label after the arrow tip.
28998
+ * the pin area is cut and ends in an arrow. Its label stands on the line behind the arrow
28999
+ * head, on a light band, or after the arrow tip when the line is too short for it.
28837
29000
  *
28838
29001
  * Layout: [left label area][pin area with axis][right label area], summing to exactly
28839
29002
  * `columnWidthEm` em - see barColumnGeometry.ts.
@@ -28841,13 +29004,14 @@ const AbsoluteVarianceBar = (props) => {
28841
29004
  */
28842
29005
  const RelativeVariancePin = (props) => {
28843
29006
  var _a, _b;
28844
- const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, percentDigits, percentSign, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
29007
+ const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, percentDigits, percentSign, columnWidthEm = 10, labelWidths, sideMax, bold, styles = DEFAULT_STYLES, } = props;
28845
29008
  const s = styles.scaleFactor;
28846
29009
  const fs = styles.fontSize;
28847
29010
  const headSize = PIN_HEAD_SIZE * s;
28848
29011
  const pinPx = 100 * styles.percentageScaling * fs;
28849
29012
  const displayValue = formattedValue || formatValue(value, true, measureScale, locale, percentDigits, percentSign);
28850
- const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, true));
29013
+ const ownWidth = labelWidth(displayValue, fs, styles.fontFamily, true, bold);
29014
+ const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, ownWidth);
28851
29015
  const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
28852
29016
  const { totalWidth, negPinLength, posPinLength, axisX, labelGap } = relativePinGeometry(columnWidthEm, styles.emPx, sides, headSize, { neg: neg * pinPx, pos: pos * pinPx });
28853
29017
  const centerY = height / 2;
@@ -28866,9 +29030,18 @@ const RelativeVariancePin = (props) => {
28866
29030
  const headStyle = (_a = look === null || look === void 0 ? void 0 : look.minuend) !== null && _a !== void 0 ? _a : styles.scenarios.ac;
28867
29031
  // the arrow tip lands on the outer edge of a full-length head, so the label after it stays in the cell
28868
29032
  const tipX = axisX + direction * (maxPinLength + headSize / 2);
28869
- const arrowBaseX = tipX - direction * headSize;
28870
- const labelX = (isExtreme ? tipX : pinEndX + direction * (headSize / 2)) + direction * labelGap;
28871
- return (index.h("svg", { width: totalWidth, height: height, class: "cell-bar-chart relative-variance", style: { overflow: "visible" } }, index.h(PatternDefs, { styles: styles }), look ? (index.h(VarianceAxis, { x: axisX, height: height, look: look, styles: styles })) : (index.h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s })), index.h("line", { x1: axisX, y1: centerY, x2: isExtreme ? arrowBaseX : pinEndX, y2: centerY, stroke: barStyle.fill, "stroke-width": PIN_LINE_WIDTH * s }), isExtreme ? (index.h("polygon", { points: `${tipX},${centerY} ${arrowBaseX},${centerY - headSize / 2} ${arrowBaseX},${centerY + headSize / 2}`, fill: barStyle.fill })) : (index.h("rect", { x: pinEndX - headSize / 2, y: centerY - headSize / 2, width: headSize, height: headSize, fill: headStyle.fillpattern === "outlined" ? "#ffffff" : getBarFill(headStyle, (_b = look === null || look === void 0 ? void 0 : look.minuendSlot) !== null && _b !== void 0 ? _b : "ac"), stroke: headStyle.stroke, "stroke-width": 1 * s })), index.h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": isPositive ? "start" : "end", fill: styles.fontColor, "font-size": fs, "font-style": "italic", "font-family": styles.fontFamily }, displayValue)));
29033
+ const arrowSize = PIN_ARROW_RATIO * headSize;
29034
+ const arrowBaseX = tipX - direction * arrowSize;
29035
+ // the band keeps a pad of full line to the arrow head and to the axis, else the label goes after the tip
29036
+ const bandPad = PIN_BAND_PAD * fs;
29037
+ const bandWidth = ownWidth + 2 * bandPad;
29038
+ const shaftLength = Math.abs(arrowBaseX - axisX) - (VARIANCE_AXIS_EM * styles.emPx) / 2;
29039
+ const labelOnShaft = isExtreme && shaftLength >= bandWidth + 2 * bandPad;
29040
+ const bandX = arrowBaseX - direction * (bandPad + bandWidth / 2) - bandWidth / 2;
29041
+ const labelX = labelOnShaft
29042
+ ? bandX + bandWidth / 2
29043
+ : (isExtreme ? tipX : pinEndX + direction * (headSize / 2)) + direction * labelGap;
29044
+ return (index.h("svg", { width: totalWidth, height: height, class: "cell-bar-chart relative-variance", style: { overflow: "visible" } }, index.h(PatternDefs, { styles: styles }), look ? (index.h(VarianceAxis, { x: axisX, height: height, look: look, styles: styles })) : (index.h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s })), index.h("line", { x1: axisX, y1: centerY, x2: isExtreme ? arrowBaseX : pinEndX, y2: centerY, stroke: barStyle.fill, "stroke-width": PIN_LINE_WIDTH * s }), isExtreme ? (index.h("polygon", { points: `${tipX},${centerY} ${arrowBaseX},${centerY - arrowSize / 2} ${arrowBaseX},${centerY + arrowSize / 2}`, fill: barStyle.fill })) : (index.h("rect", { x: pinEndX - headSize / 2, y: centerY - headSize / 2, width: headSize, height: headSize, fill: headStyle.fillpattern === "outlined" ? "#ffffff" : getBarFill(headStyle, (_b = look === null || look === void 0 ? void 0 : look.minuendSlot) !== null && _b !== void 0 ? _b : "ac"), stroke: headStyle.stroke, "stroke-width": 1 * s })), labelOnShaft && (index.h("rect", { class: "pin-label-band", x: bandX, y: centerY - (PIN_LINE_WIDTH * s) / 2, width: bandWidth, height: PIN_LINE_WIDTH * s, fill: "#ffffff", "fill-opacity": "0.5" })), index.h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": labelOnShaft ? "middle" : isPositive ? "start" : "end", fill: styles.fontColor, "font-size": fs, "font-style": "italic", "font-family": styles.fontFamily }, displayValue)));
28872
29045
  };
28873
29046
  /**
28874
29047
  * CellBarChart - Renders IBCS-compliant variance bar charts.
@@ -28890,6 +29063,14 @@ const CellBarChart = (props) => {
28890
29063
  return index.h(AbsoluteVarianceBar, Object.assign({}, props));
28891
29064
  };
28892
29065
 
29066
+ /**
29067
+ * Label text of a waterfall bar. Scenario values carry no variance sentiment: unsigned per
29068
+ * IBCS. A variance keeps its sign (`signed`).
29069
+ */
29070
+ function waterfallLabelText(value, kind, measureScale, locale, decimalDigits, signed = false) {
29071
+ const text = formatValue(value, kind === "partof", measureScale, locale, 0, true, decimalDigits);
29072
+ return signed ? text : text.replace(/^\+/, "");
29073
+ }
28893
29074
  /**
28894
29075
  * Renders one row of an IBCS waterfall for a scenario bar column.
28895
29076
  *
@@ -28902,19 +29083,27 @@ const CellBarChart = (props) => {
28902
29083
  * Layout: [left label area][bar area][right label area]
28903
29084
  * The value label sits at the bar's free end (right of rightward bars,
28904
29085
  * left of leftward bars). thereof/partof rows additionally get dashed
28905
- * guides marking their parent bar's extent.
29086
+ * guides marking their parent bar's extent. A guide or axis line that would
29087
+ * run through the label is left out in that row.
29088
+ *
29089
+ * An absolute variance column is drawn as a variance waterfall: the bar in the color of
29090
+ * the sentiment and the pattern of the minuend, the axis in the look of the reference
29091
+ * scenario in every row, a signed label, and thin connectors to the rows above and below
29092
+ * in place of the dashed guides. The axis and the connectors join the rows, so where one
29093
+ * meets the label it is only interrupted over the height of the text.
28906
29094
  */
28907
29095
  const WaterfallBar = (props) => {
28908
- const { value, scenario, height, measureScale, locale, decimalDigits, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, } = props;
29096
+ var _a;
29097
+ const { value, scenario, height, isPositiveGood, measureScale, locale, decimalDigits, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, geometry, bold, connectorReach = { top: 0, bottom: 0 }, } = props;
28909
29098
  const s = styles.scaleFactor;
28910
29099
  const fs = styles.fontSize;
28911
29100
  const range = waterfall.max - waterfall.min;
28912
29101
  if (value === null || value === undefined || isNaN(value) || range <= 0) {
28913
29102
  return (index.h("span", { class: "bar-chart-empty", style: { color: styles.fontColor, fontStyle: "italic" } }, "-"));
28914
29103
  }
28915
- const { totalWidth, labelAreaWidth, barAreaWidth, labelGap } = waterfallGeometry(columnWidthEm, styles.emPx);
29104
+ const { totalWidth, labelAreaLeft, barAreaWidth, labelGap } = geometry !== null && geometry !== void 0 ? geometry : waterfallGeometry(columnWidthEm, styles.emPx);
28916
29105
  const pxPerUnit = barAreaWidth / range;
28917
- const xOf = (coordinate) => labelAreaWidth + (coordinate - waterfall.min) * pxPerUnit;
29106
+ const xOf = (coordinate) => labelAreaLeft + (coordinate - waterfall.min) * pxPerUnit;
28918
29107
  const padding = 2 * s;
28919
29108
  const barHeight = height - padding * 2;
28920
29109
  const barY = padding;
@@ -28923,15 +29112,37 @@ const WaterfallBar = (props) => {
28923
29112
  const endX = xOf(waterfall.end);
28924
29113
  const barX = Math.min(startX, endX);
28925
29114
  const barWidth = Math.abs(endX - startX);
28926
- const barStyle = getBarStyle(scenario, value, false, styles);
28927
- const fillValue = getBarFill(barStyle, getScenarioType(scenario));
28928
- const { stroke: barStroke, strokeWidth: barStrokeWidth } = getBarStroke(barStyle);
28929
- // Scenario values carry no variance sentiment - labels are unsigned per IBCS
28930
- const displayValue = formatValue(value, waterfall.kind === "partof", measureScale, locale, 0, true, decimalDigits).replace(/^\+/, "");
29115
+ // null for a scenario column, which ignores the sentiment
29116
+ const look = getVarianceLook(scenario, styles);
29117
+ const sentimentStyle = getBarStyle(scenario, value, isPositiveGood, styles);
29118
+ const minuendPattern = look === null || look === void 0 ? void 0 : look.minuend.fillpattern;
29119
+ const barStyle = minuendPattern === "hatched" || minuendPattern === "outlined"
29120
+ ? Object.assign(Object.assign({}, sentimentStyle), { fillpattern: minuendPattern }) : sentimentStyle;
29121
+ const patternPrefix = look ? (sentimentStyle === styles.positive ? "pos" : "neg") : getScenarioType(scenario);
29122
+ const fillValue = getBarFill(barStyle, patternPrefix);
29123
+ const { stroke: barStroke, strokeWidth: barStrokeWidth } = look && barStyle.fillpattern === "hatched" ? { stroke: barStyle.stroke, strokeWidth: 1 } : getBarStroke(barStyle);
29124
+ const displayValue = waterfallLabelText(value, waterfall.kind, measureScale, locale, decimalDigits, look !== null);
28931
29125
  const pointsLeft = endX < startX;
28932
29126
  const labelX = pointsLeft ? barX - labelGap : barX + barWidth + labelGap;
28933
29127
  const labelAnchor = pointsLeft ? "end" : "start";
28934
- return (index.h("svg", { width: totalWidth, height: height, class: "cell-bar-chart waterfall-bar", style: { overflow: "visible" } }, index.h(PatternDefs, { styles: styles }), index.h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s }), waterfall.parentStart !== undefined && waterfall.parentEnd !== undefined && (index.h("line", { x1: xOf(waterfall.parentStart), y1: 0, x2: xOf(waterfall.parentStart), y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s, "stroke-dasharray": `${2 * s},${2 * s}` })), waterfall.parentStart !== undefined && waterfall.parentEnd !== undefined && (index.h("line", { x1: xOf(waterfall.parentEnd), y1: 0, x2: xOf(waterfall.parentEnd), y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s, "stroke-dasharray": `${2 * s},${2 * s}` })), barWidth > 0 && (index.h("rect", { x: barX, y: barY, width: barWidth, height: barHeight, fill: fillValue, stroke: barStroke, "stroke-width": barStrokeWidth * s })), index.h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": labelAnchor, fill: styles.fontColor, "font-size": fs, "font-family": styles.fontFamily }, displayValue)));
29128
+ // a line through the label makes it unreadable, so the row drops it
29129
+ const labelSize = labelWidth(displayValue, fs, styles.fontFamily, false, bold);
29130
+ const labelPad = labelGap / 2;
29131
+ const labelFrom = (pointsLeft ? labelX - labelSize : labelX) - labelPad;
29132
+ const labelTo = (pointsLeft ? labelX : labelX + labelSize) + labelPad;
29133
+ const meetsLabel = (x) => x > labelFrom && x < labelTo;
29134
+ const parentEndX = waterfall.parentEnd !== undefined ? xOf(waterfall.parentEnd) : undefined;
29135
+ // the parts of a vertical line of a variance waterfall that stay clear of the label text
29136
+ const labelTop = height / 2 - fs / 2;
29137
+ const labelBottom = height / 2 + fs / 2;
29138
+ const clearOfLabel = (x, y1, y2, halfWidth = 0) => x + halfWidth > labelFrom && x - halfWidth < labelTo
29139
+ ? [[y1, Math.min(y2, labelTop)], [Math.max(y1, labelBottom), y2]].filter(([from, to]) => to > from)
29140
+ : [[y1, y2]];
29141
+ const axisTop = -connectorReach.top;
29142
+ const axisBottom = height + connectorReach.bottom;
29143
+ return (index.h("svg", { width: totalWidth, height: height, class: `cell-bar-chart waterfall-bar${look ? " variance-waterfall" : ""}`, style: { overflow: "visible" } }, index.h(PatternDefs, { styles: styles }), !look && !meetsLabel(axisX) && (index.h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s })), waterfall.parentStart !== undefined && waterfall.parentEnd !== undefined && (index.h("line", { x1: xOf(waterfall.parentStart), y1: 0, x2: xOf(waterfall.parentStart), y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s, "stroke-dasharray": `${2 * s},${2 * s}` })), waterfall.parentStart !== undefined && parentEndX !== undefined && !meetsLabel(parentEndX) && (index.h("line", { x1: parentEndX, y1: 0, x2: parentEndX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s, "stroke-dasharray": `${2 * s},${2 * s}` })), (_a = waterfall.connectors) === null || _a === void 0 ? void 0 :
29144
+ _a.map(({ at, part }) => clearOfLabel(xOf(at), part === "bottom" ? barY + barHeight : axisTop, part === "top" ? barY : axisBottom).map(([y1, y2]) => (index.h("line", { class: "waterfall-connector", x1: xOf(at), y1: y1, x2: xOf(at), y2: y2, stroke: AXIS_COLOR, "stroke-width": 1 * s })))), barWidth > 0 && (index.h("rect", { x: barX, y: barY, width: barWidth, height: barHeight, fill: fillValue, stroke: barStroke, "stroke-width": barStrokeWidth * s })), look &&
29145
+ clearOfLabel(axisX, axisTop, axisBottom, (VARIANCE_AXIS_EM * styles.emPx) / 2).map(([y1, y2]) => (index.h("g", { transform: `translate(0,${y1})` }, index.h(VarianceAxis, { x: axisX, height: y2 - y1, look: look, styles: styles })))), index.h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": labelAnchor, fill: styles.fontColor, "font-size": fs, "font-family": styles.fontFamily }, displayValue)));
28935
29146
  };
28936
29147
 
28937
29148
  /** '', null and a missing rowGroup are one group. */
@@ -28949,7 +29160,7 @@ const BLANK_SAFE_ROWGROUP = `IFNULL(${QueryColumnNames.ROWGROUP}, '')`;
28949
29160
  class QueryGroups {
28950
29161
  constructor(config) {
28951
29162
  this.groups = [QueryColumnNames.CATEGORY, QueryColumnNames.CATEGORYINDEX];
28952
- if (TableType.OPT === config.type || TableType.OPTNOTOTAL === config.type) {
29163
+ if (withStyled.TableType.OPT === config.type || withStyled.TableType.OPTNOTOTAL === config.type) {
28953
29164
  this.groups.unshift(QueryColumnNames.OPERATION);
28954
29165
  }
28955
29166
  if (config.grouped) {
@@ -28973,129 +29184,418 @@ class QueryGroups {
28973
29184
  }
28974
29185
  }
28975
29186
 
29187
+ function sameCoordinate(a, b) {
29188
+ return Math.abs(a - b) <= 1e-9 * Math.max(1, Math.abs(a), Math.abs(b));
29189
+ }
28976
29190
  /**
28977
- * AlaSQL-based query builder that produces the complete table result set for bn-table.
28978
- *
28979
- * Translates a {@link TableComponentConfig} into a series of SQL statements executed
28980
- * against in-memory data rows. The pipeline handles scenario aggregation, row/column
28981
- * grouping, drill-down expansion (thereof / partof), REST rows, sum rows, NaN detection,
28982
- * column-level drill columns, and relative variance calculation.
29191
+ * Sets the connectors of a variance walk in print order. A null unit is a printed row
29192
+ * without a bar. Two rows are joined only where the walk goes on: a group that restarts
29193
+ * at zero gets no line from the sum row above it.
28983
29194
  */
28984
- class DataQuery {
28985
- constructor(config, i18n) {
28986
- this.hasPartOf = false;
28987
- /** Values bound as AlaSQL parameters ($0, $1, ...): row values and free-text config never become SQL text. */
28988
- this.params = [];
28989
- /** Select fragment (leading comma) of the sort keys for variance and bucketed order tokens. */
28990
- this.sortSelect = "";
28991
- /** Set by execute: the grouped table has rows with a blank rowGroup (null, '' or missing). */
28992
- this.hasBlankRowGroup = false;
28993
- this.config = config;
28994
- this.i18n = i18n;
28995
- }
28996
- /**
28997
- * Executes the full query pipeline and returns a segmented result set.
28998
- *
28999
- * Pipeline steps:
29000
- * 1. Translate scenario columns into SQL aggregation expressions
29001
- * 2. Run a meta query to discover row groups and their category counts
29002
- * 3. For each group: generate header row, data rows, REST overflow row, and group sum row
29003
- * 4. Append a total sum row (if table type requires it)
29004
- * 5. Execute all accumulated SQL statements against the input data
29005
- * 6. Detect NaN cells (aggregated cells with zero contributing rows)
29006
- * 7. Inject thereof/partof drill rows and column-level drill columns
29007
- * 8. Calculate REST columns (parent minus drilled children)
29008
- * 9. Divide absolute variances by their denominator to produce relative variances
29009
- *
29010
- * @param db - The shared alasql database.
29011
- * @param fromExpr - SQL FROM-clause expression naming the source table or filtered view.
29012
- * @returns Array of row-group segments; each segment is an array of result rows.
29013
- */
29014
- execute(db, fromExpr) {
29195
+ function connectWalk(units, thereofAbove) {
29196
+ const add = (bar, at, part) => {
29015
29197
  var _a;
29016
- this.db = db;
29017
- this.fromExpr = fromExpr;
29018
- // these names are written into the SQL text as column names
29019
- for (const name of [...this.config.scenarios, ...this.config.categoryThereOf.keys()]) {
29020
- if (!withStyled.FIELD_IDENTIFIER_REGEX.test(name)) {
29021
- throw new Error(`invalid identifier "${name}"`);
29022
- }
29023
- }
29024
- const queries = [];
29025
- const sumGroupQueries = [];
29026
- const res = [];
29027
- const scenarios = this.config.scenarios
29028
- .map((s) => this.translateScenarioSQL(s, false, this.config.type))
29029
- .toString();
29030
- const scenariosSUMQuery = this.config.scenarios
29031
- .map((s) => this.translateScenarioSQL(s, true, this.config.type))
29032
- .toString();
29033
- const relativeScenarios = this.getRelativeScenarios();
29034
- const attributesSQL = this.config.attributes.map((attribute) => this.translateAttributeSQL(attribute)).toString();
29035
- const groups = new QueryGroups(this.config);
29036
- // a bucket only applies under interval setname, else the token sorts like its bare column
29037
- const sortOrder = this.config.interval === INTERVAL_SETNAME
29038
- ? this.config.sortOrder
29039
- : {
29040
- hierarchy: this.config.sortOrder.hierarchy.map((column) => { var _a, _b; return (_b = (_a = withStyled.parseOrderToken(column)) === null || _a === void 0 ? void 0 : _a.column) !== null && _b !== void 0 ? _b : column; }),
29041
- direction: this.config.sortOrder.direction,
29042
- };
29043
- let order = ["", ""];
29044
- if (sortOrder.hierarchy.length > 0) {
29045
- order = this.createOrderString(sortOrder);
29198
+ bar.connectors = [...((_a = bar.connectors) !== null && _a !== void 0 ? _a : []), { at, part }];
29199
+ };
29200
+ const link = (from, between, to, at) => {
29201
+ add(from, at, "bottom");
29202
+ between.forEach((bar) => add(bar, at, "through"));
29203
+ add(to, at, "top");
29204
+ };
29205
+ let previous = null;
29206
+ for (const unit of units) {
29207
+ if (unit === null) {
29208
+ previous = null;
29209
+ continue;
29046
29210
  }
29047
- this.hasPartOf = this.checkConfigForPartOf();
29048
- // meta defines groups and the number detail rows in each group
29049
- // Bsp: 0: Object { totalrowcnt: 7, rowgroup: "Umsatz" }
29050
- // groups follow the order entries that exist per group (rowGroup, rowGroupIndex, scenario sum), else rowGroupIndex
29051
- const { hierarchy, direction } = sortOrder;
29052
- const groupOrderColumns = hierarchy.filter((column) => column === QueryColumnNames.ROWGROUP ||
29053
- column === QueryColumnNames.ROWGROUPINDEX ||
29054
- column.toUpperCase() in withStyled.Scenarios);
29055
- const groupSums = groupOrderColumns
29056
- .filter((column) => column.toUpperCase() in withStyled.Scenarios)
29057
- .map((column) => `, SUM(${column} * transformOperator(operation)) as ${column}`)
29058
- .join("");
29059
- const groupOrder = groupOrderColumns.length > 0
29060
- ? groupOrderColumns.map((column) => `${column} ${direction}`).toString()
29061
- : `${QueryColumnNames.ROWGROUPINDEX} asc`;
29062
- const meta = db.exec(`SELECT COUNT(DISTINCT ${QueryColumnNames.CATEGORY}) as ${QueryColumnNames.TOTALROWCOUNT} ${this.config.grouped ? `, ${BLANK_SAFE_ROWGROUP} as ${QueryColumnNames.ROWGROUP}, FIRST(${QueryColumnNames.ROWGROUPINDEX}) as ${QueryColumnNames.ROWGROUPINDEX}${groupSums}` : ""}
29063
- FROM ${fromExpr} ${this.config.grouped ? `GROUP BY ${BLANK_SAFE_ROWGROUP} ORDER BY ${groupOrder}` : ""}`);
29064
- if (meta.length === 0 ||
29065
- (meta.length === 1 && ((_a = meta[0][QueryColumnNames.TOTALROWCOUNT]) !== null && _a !== void 0 ? _a : 0) === 0 && !this.config.grouped)) {
29066
- return [];
29211
+ const { main, children } = unit;
29212
+ const entry = main.kind === "anchor" ? main.end : main.start;
29213
+ if (previous && !unit.gapAbove && sameCoordinate(previous.main.end, entry)) {
29214
+ // the line runs beside the thereof rows printed between the two rows
29215
+ link(previous.main, thereofAbove ? children : previous.children, main, entry);
29067
29216
  }
29068
- this.hasBlankRowGroup = this.config.grouped && meta.some((row) => row.rowGroup === "");
29069
- // Creates DataSelection for LIST
29070
- meta.forEach((rowGroupEntry) => {
29071
- // the following variables are 'helper sections' which are used to constuct dynamicly the sql statement depending of the given config
29072
- // is grouping active?
29073
- const queryWhereSection = !this.config.grouped
29074
- ? ``
29075
- : rowGroupEntry.rowGroup === ""
29076
- ? `WHERE (${QueryColumnNames.ROWGROUP} IS NULL OR ${QueryColumnNames.ROWGROUP} = '')`
29077
- : `WHERE ${QueryColumnNames.ROWGROUP} = ${this.bind(rowGroupEntry.rowGroup)}`;
29078
- // is limit active?
29079
- let queryLimitSection = "";
29080
- if (this.config.limit) {
29081
- queryLimitSection = `LIMIT ${this.config.limit}`;
29217
+ if (!unit.gapAbove && !unit.gapBelow) {
29218
+ children.forEach((child, index) => {
29219
+ if (index > 0)
29220
+ link(children[index - 1], [], child, child.start);
29221
+ });
29222
+ if (children.length > 0) {
29223
+ const last = children[children.length - 1];
29224
+ if (!thereofAbove) {
29225
+ link(main, [], children[0], main.start);
29226
+ }
29227
+ else if (sameCoordinate(last.end, main.end)) {
29228
+ link(last, [], main, main.end);
29229
+ }
29082
29230
  }
29083
- this.createGroupHeaderRow(rowGroupEntry, queries);
29084
- this.createDataRow(queries, rowGroupEntry, groups, scenarios, attributesSQL, queryWhereSection, order, queryLimitSection);
29085
- this.createRestRow(rowGroupEntry, queries, groups, scenarios, queryWhereSection, order);
29086
- this.createGroupSumRow(queries, sumGroupQueries, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order);
29087
- });
29088
- this.createTotalSumRow(queries, sumGroupQueries, scenariosSUMQuery);
29089
- // executes main queries
29090
- queries.forEach((query) => res.push(this.exec(query)));
29091
- this.detectNaNCells(this.config.scenarios, res);
29092
- this.createThereOfDrillRows(scenarios, attributesSQL, order, res);
29093
- this.createPartOfDrillRows(scenarios, order, sumGroupQueries, res);
29094
- this.createIntervalColumns(res);
29095
- this.createThereOfDrillColumns(this.config.categoryThereOf, res);
29096
- this.calculateColumnGroupRest(res, this.config.categoryThereOf);
29097
- this.calculateRelativeVariances(res, relativeScenarios);
29098
- return res;
29231
+ }
29232
+ previous = unit.gapBelow ? null : unit;
29233
+ }
29234
+ }
29235
+ /**
29236
+ * Waterfall geometry per raw result row and column, keyed by row identity
29237
+ * (the factory iterates the same row objects the calculator walked).
29238
+ */
29239
+ class WaterfallResult {
29240
+ constructor() {
29241
+ this.geometry = new Map();
29242
+ this.columns = new Set();
29243
+ }
29244
+ set(row, column, data) {
29245
+ let columns = this.geometry.get(row);
29246
+ if (!columns) {
29247
+ columns = new Map();
29248
+ this.geometry.set(row, columns);
29249
+ }
29250
+ columns.set(column, data);
29251
+ this.columns.add(column);
29252
+ }
29253
+ get(row, column) {
29254
+ var _a;
29255
+ return (_a = this.geometry.get(row)) === null || _a === void 0 ? void 0 : _a.get(column);
29256
+ }
29257
+ /** True when the column has waterfall bars, also for a row of it that got none. */
29258
+ has(column) {
29259
+ return this.columns.has(column);
29260
+ }
29261
+ }
29262
+ /** True when the result contains grouping structure (sum, subtotal, or drill rows). */
29263
+ function hasGroupingStructure(queryData) {
29264
+ for (const groupData of queryData) {
29265
+ for (const row of groupData) {
29266
+ const type = row[QueryColumnNames.TYPE];
29267
+ if (type === withStyled.TableRowType.SUM ||
29268
+ type === withStyled.TableRowType.GROUPSUM ||
29269
+ type === withStyled.TableRowType.DRILLELEMENT ||
29270
+ type === withStyled.TableRowType.PARTELEMENT) {
29271
+ return true;
29272
+ }
29273
+ }
29274
+ }
29275
+ return false;
29276
+ }
29277
+ /**
29278
+ * Alias of the signed sum of a bar column on the generated REST row of an OPT table. The
29279
+ * row prints the unsigned sum of the rows it folds, the walk needs the signed one.
29280
+ */
29281
+ function restSignedAlias(column) {
29282
+ return `${column}__signed`;
29283
+ }
29284
+ /** Sign of an OPT entry row; the generated REST row has `restOperation` in place of `operation`. */
29285
+ function operationSign(row) {
29286
+ var _a;
29287
+ return ((_a = row[QueryColumnNames.OPERATION]) !== null && _a !== void 0 ? _a : row.restOperation) === "-" ? -1 : 1;
29288
+ }
29289
+ /**
29290
+ * Signed waterfall contribution of a row for one column.
29291
+ *
29292
+ * Non-OPT table types aggregate `SUM(scn * transformOperator(operation))`, so ENTRY
29293
+ * values arrive already signed. OPT types aggregate plain `SUM(scn)` with the sign
29294
+ * carried in the visible operation column, so the sign is applied here. A REST row that
29295
+ * folds "+" and "-" rows has no single sign, it brings its signed sum. Sum rows are
29296
+ * fully signed in both modes.
29297
+ */
29298
+ function signedValue(row, column, tableType) {
29299
+ const raw = row[column];
29300
+ if (raw === null || raw === undefined) {
29301
+ return null;
29302
+ }
29303
+ const value = Number(raw);
29304
+ if (isNaN(value)) {
29305
+ return null;
29306
+ }
29307
+ const isOpt = tableType === withStyled.TableType.OPT || tableType === withStyled.TableType.OPTNOTOTAL;
29308
+ if (isOpt && row[QueryColumnNames.TYPE] === withStyled.TableRowType.ENTRY) {
29309
+ const signed = row[restSignedAlias(column)];
29310
+ return typeof signed === "number" ? signed : operationSign(row) * value;
29311
+ }
29312
+ return value;
29313
+ }
29314
+ /**
29315
+ * Computes waterfall bar geometry for the given scenario columns by walking the
29316
+ * segmented query result once per column in display order.
29317
+ *
29318
+ * - ENTRY rows (incl. REST) cascade from the running total by their signed value.
29319
+ * The REST row of an OPT table takes the sign of `restOperation`, or its signed sum.
29320
+ * - SUM / GROUP_SUM rows anchor at zero. A SUM row resets the running total to its
29321
+ * value, a GROUP_SUM row resets it to zero.
29322
+ * - DRILLELEMENT (thereof) rows form a sub-cascade from their parent bar's start in
29323
+ * the parent's direction; the running total is untouched.
29324
+ * - PARTELEMENT (partof) rows cascade a `share * parent width` segment the same way.
29325
+ * Note: the share denominator is the group sum (or SUM_TOTAL when ungrouped) per
29326
+ * `createPartOfDrillRows`, not literally the parent row's value.
29327
+ * - GROUPHEAD rows get no bar and restart the running total at zero: every row group
29328
+ * is its own cascade that ends at its GROUP_SUM.
29329
+ * - With `runningSum` a GROUP_SUM row holds the result of all groups so far, so the
29330
+ * cascade goes on from its value and no GROUPHEAD restarts it.
29331
+ * - NaN rows get no bar; a NaN parent orphans its drill children.
29332
+ *
29333
+ * An absolute variance column walks the same way with three differences: a thereof row
29334
+ * steps by its signed value times the operation sign of its parent, so its siblings can
29335
+ * go both ways and leave the parent bar; a partof row gets no bar; and the bars carry
29336
+ * connectors to the rows printed above and below.
29337
+ *
29338
+ * @param queryData - Segmented result rows from DataQuery.execute().
29339
+ * @param columns - Plain scenario (ac1..pl4) or absolute variance column keys; no `##` composite keys.
29340
+ * @param tableType - Table aggregation mode, needed for OPT sign handling.
29341
+ * @param runningSum - True when the GROUP_SUM rows are running results.
29342
+ * @param thereofAbove - True when thereof rows are printed above their parent; only the connectors depend on it.
29343
+ */
29344
+ function computeWaterfall(queryData, columns, tableType, runningSum = false, thereofAbove = false) {
29345
+ const result = new WaterfallResult();
29346
+ const isOpt = tableType === withStyled.TableType.OPT || tableType === withStyled.TableType.OPTNOTOTAL;
29347
+ for (const column of columns) {
29348
+ const variance = new VarianceScenario(column).isValid;
29349
+ let running = 0;
29350
+ let lastParent;
29351
+ let subCursor = 0;
29352
+ const emitted = [];
29353
+ const units = [];
29354
+ let unit = null;
29355
+ const emit = (row, data) => {
29356
+ emitted.push(data);
29357
+ result.set(row, column, data);
29358
+ return data;
29359
+ };
29360
+ const startUnit = (main) => {
29361
+ unit = main && { main, children: [], gapAbove: false, gapBelow: false };
29362
+ units.push(unit);
29363
+ };
29364
+ for (const groupData of queryData) {
29365
+ for (const row of groupData) {
29366
+ const type = row[QueryColumnNames.TYPE];
29367
+ if (type === withStyled.TableRowType.GROUPHEAD) {
29368
+ // a group sum only totals its own rows, so the cascade must not carry over
29369
+ if (!runningSum) {
29370
+ running = 0;
29371
+ }
29372
+ lastParent = undefined;
29373
+ startUnit(null);
29374
+ continue;
29375
+ }
29376
+ const value = signedValue(row, column, tableType);
29377
+ if (type === withStyled.TableRowType.ENTRY) {
29378
+ if (value === null) {
29379
+ lastParent = undefined;
29380
+ startUnit(null);
29381
+ continue;
29382
+ }
29383
+ startUnit(emit(row, { start: running, end: running + value, min: 0, max: 0, kind: "cascade" }));
29384
+ // thereof values of an OPT table are unsigned like the entries, so they take the sign of the parent
29385
+ const sign = isOpt ? operationSign(row) : 1;
29386
+ lastParent = { start: running, end: running + value, sign };
29387
+ subCursor = lastParent.start;
29388
+ running += value;
29389
+ }
29390
+ else if (type === withStyled.TableRowType.SUM || type === withStyled.TableRowType.GROUPSUM) {
29391
+ if (value === null) {
29392
+ lastParent = undefined;
29393
+ startUnit(null);
29394
+ continue;
29395
+ }
29396
+ startUnit(emit(row, { start: 0, end: value, min: 0, max: 0, kind: "anchor" }));
29397
+ lastParent = { start: 0, end: value, sign: 1 };
29398
+ subCursor = 0;
29399
+ // a group sum closes its group (there may be no GROUPHEAD row when the title is hidden)
29400
+ running = type === withStyled.TableRowType.GROUPSUM && !runningSum ? 0 : value;
29401
+ }
29402
+ else if (variance && (type === withStyled.TableRowType.DRILLELEMENT || type === withStyled.TableRowType.PARTELEMENT)) {
29403
+ if (type === withStyled.TableRowType.DRILLELEMENT && value !== null && lastParent !== undefined && unit) {
29404
+ const end = subCursor + lastParent.sign * value;
29405
+ unit.children.push(emit(row, { start: subCursor, end, min: 0, max: 0, kind: "thereof" }));
29406
+ subCursor = end;
29407
+ }
29408
+ else if (unit) {
29409
+ // only thereof rows move above the parent
29410
+ if (thereofAbove && type === withStyled.TableRowType.DRILLELEMENT)
29411
+ unit.gapAbove = true;
29412
+ else
29413
+ unit.gapBelow = true;
29414
+ }
29415
+ }
29416
+ else if (type === withStyled.TableRowType.DRILLELEMENT) {
29417
+ if (value === null || lastParent === undefined) {
29418
+ continue;
29419
+ }
29420
+ const direction = Math.sign(lastParent.end - lastParent.start) || 1;
29421
+ const end = subCursor + direction * Math.abs(value);
29422
+ emit(row, {
29423
+ start: subCursor,
29424
+ end,
29425
+ min: 0,
29426
+ max: 0,
29427
+ kind: "thereof",
29428
+ parentStart: lastParent.start,
29429
+ parentEnd: lastParent.end,
29430
+ });
29431
+ subCursor = end;
29432
+ }
29433
+ else if (type === withStyled.TableRowType.PARTELEMENT) {
29434
+ if (value === null || lastParent === undefined) {
29435
+ continue;
29436
+ }
29437
+ const end = subCursor + value * (lastParent.end - lastParent.start);
29438
+ emit(row, {
29439
+ start: subCursor,
29440
+ end,
29441
+ min: 0,
29442
+ max: 0,
29443
+ kind: "partof",
29444
+ parentStart: lastParent.start,
29445
+ parentEnd: lastParent.end,
29446
+ });
29447
+ subCursor = end;
29448
+ }
29449
+ }
29450
+ }
29451
+ if (variance) {
29452
+ connectWalk(units, thereofAbove);
29453
+ }
29454
+ // All rows of a column share one coordinate system including zero
29455
+ let min = 0;
29456
+ let max = 0;
29457
+ for (const data of emitted) {
29458
+ min = Math.min(min, data.start, data.end);
29459
+ max = Math.max(max, data.start, data.end);
29460
+ }
29461
+ for (const data of emitted) {
29462
+ data.min = min;
29463
+ data.max = max;
29464
+ }
29465
+ }
29466
+ return result;
29467
+ }
29468
+
29469
+ /** Adds a group sum to a running result; it stays missing as long as no group had a value. */
29470
+ function addGroupSum(running, value) {
29471
+ return running == null && value == null ? value : (running !== null && running !== void 0 ? running : 0) + (value !== null && value !== void 0 ? value : 0);
29472
+ }
29473
+ /**
29474
+ * AlaSQL-based query builder that produces the complete table result set for bn-table.
29475
+ *
29476
+ * Translates a {@link TableComponentConfig} into a series of SQL statements executed
29477
+ * against in-memory data rows. The pipeline handles scenario aggregation, row/column
29478
+ * grouping, drill-down expansion (thereof / partof), REST rows, sum rows, NaN detection,
29479
+ * column-level drill columns, and relative variance calculation.
29480
+ */
29481
+ class DataQuery {
29482
+ constructor(config, i18n) {
29483
+ this.hasPartOf = false;
29484
+ /** Values bound as AlaSQL parameters ($0, $1, ...): row values and free-text config never become SQL text. */
29485
+ this.params = [];
29486
+ /** Select fragment (leading comma) of the sort keys for variance and bucketed order tokens. */
29487
+ this.sortSelect = "";
29488
+ /** Set by execute: the grouped table has rows with a blank rowGroup (null, '' or missing). */
29489
+ this.hasBlankRowGroup = false;
29490
+ this.config = config;
29491
+ this.i18n = i18n;
29492
+ }
29493
+ /**
29494
+ * Executes the full query pipeline and returns a segmented result set.
29495
+ *
29496
+ * Pipeline steps:
29497
+ * 1. Translate scenario columns into SQL aggregation expressions
29498
+ * 2. Run a meta query to discover row groups and their category counts
29499
+ * 3. For each group: generate header row, data rows, REST overflow row, and group sum row
29500
+ * 4. Append a total sum row (if table type requires it)
29501
+ * 5. Execute all accumulated SQL statements against the input data
29502
+ * 6. Detect NaN cells (aggregated cells with zero contributing rows)
29503
+ * 7. Inject thereof/partof drill rows and column-level drill columns
29504
+ * 8. Calculate REST columns (parent minus drilled children)
29505
+ * 9. Divide absolute variances by their denominator to produce relative variances
29506
+ *
29507
+ * @param db - The shared alasql database.
29508
+ * @param fromExpr - SQL FROM-clause expression naming the source table or filtered view.
29509
+ * @returns Array of row-group segments; each segment is an array of result rows.
29510
+ */
29511
+ execute(db, fromExpr) {
29512
+ var _a;
29513
+ this.db = db;
29514
+ this.fromExpr = fromExpr;
29515
+ // these names are written into the SQL text as column names
29516
+ for (const name of [...this.config.scenarios, ...this.config.categoryThereOf.keys()]) {
29517
+ if (!withStyled.FIELD_IDENTIFIER_REGEX.test(name)) {
29518
+ throw new Error(`invalid identifier "${name}"`);
29519
+ }
29520
+ }
29521
+ const queries = [];
29522
+ const sumGroupQueries = [];
29523
+ const res = [];
29524
+ const scenarios = this.config.scenarios
29525
+ .map((s) => this.translateScenarioSQL(s, false, this.config.type))
29526
+ .toString();
29527
+ const scenariosSUMQuery = this.config.scenarios
29528
+ .map((s) => this.translateScenarioSQL(s, true, this.config.type))
29529
+ .toString();
29530
+ const relativeScenarios = this.getRelativeScenarios();
29531
+ const attributesSQL = this.config.attributes.map((attribute) => this.translateAttributeSQL(attribute)).toString();
29532
+ const groups = new QueryGroups(this.config);
29533
+ // a bucket only applies under interval setname, else the token sorts like its bare column
29534
+ const sortOrder = this.config.interval === INTERVAL_SETNAME
29535
+ ? this.config.sortOrder
29536
+ : {
29537
+ hierarchy: this.config.sortOrder.hierarchy.map((column) => { var _a, _b; return (_b = (_a = withStyled.parseOrderToken(column)) === null || _a === void 0 ? void 0 : _a.column) !== null && _b !== void 0 ? _b : column; }),
29538
+ direction: this.config.sortOrder.direction,
29539
+ };
29540
+ let order = ["", ""];
29541
+ if (sortOrder.hierarchy.length > 0) {
29542
+ order = this.createOrderString(sortOrder);
29543
+ }
29544
+ this.hasPartOf = this.checkConfigForPartOf();
29545
+ // meta defines groups and the number detail rows in each group
29546
+ // Bsp: 0: Object { totalrowcnt: 7, rowgroup: "Umsatz" }
29547
+ // groups follow the order entries that exist per group (rowGroup, rowGroupIndex, scenario sum), else rowGroupIndex
29548
+ const { hierarchy, direction } = sortOrder;
29549
+ const groupOrderColumns = hierarchy.filter((column) => column === QueryColumnNames.ROWGROUP ||
29550
+ column === QueryColumnNames.ROWGROUPINDEX ||
29551
+ column.toUpperCase() in withStyled.Scenarios);
29552
+ const groupSums = groupOrderColumns
29553
+ .filter((column) => column.toUpperCase() in withStyled.Scenarios)
29554
+ .map((column) => `, SUM(${column} * transformOperator(operation)) as ${column}`)
29555
+ .join("");
29556
+ const groupOrder = groupOrderColumns.length > 0
29557
+ ? groupOrderColumns.map((column) => `${column} ${direction}`).toString()
29558
+ : `${QueryColumnNames.ROWGROUPINDEX} asc`;
29559
+ const meta = db.exec(`SELECT COUNT(DISTINCT ${QueryColumnNames.CATEGORY}) as ${QueryColumnNames.TOTALROWCOUNT} ${this.config.grouped ? `, ${BLANK_SAFE_ROWGROUP} as ${QueryColumnNames.ROWGROUP}, FIRST(${QueryColumnNames.ROWGROUPINDEX}) as ${QueryColumnNames.ROWGROUPINDEX}${groupSums}` : ""}
29560
+ FROM ${fromExpr} ${this.config.grouped ? `GROUP BY ${BLANK_SAFE_ROWGROUP} ORDER BY ${groupOrder}` : ""}`);
29561
+ if (meta.length === 0 ||
29562
+ (meta.length === 1 && ((_a = meta[0][QueryColumnNames.TOTALROWCOUNT]) !== null && _a !== void 0 ? _a : 0) === 0 && !this.config.grouped)) {
29563
+ return [];
29564
+ }
29565
+ this.hasBlankRowGroup = this.config.grouped && meta.some((row) => row.rowGroup === "");
29566
+ // Creates DataSelection for LIST
29567
+ meta.forEach((rowGroupEntry) => {
29568
+ // the following variables are 'helper sections' which are used to constuct dynamicly the sql statement depending of the given config
29569
+ // is grouping active?
29570
+ const queryWhereSection = !this.config.grouped
29571
+ ? ``
29572
+ : rowGroupEntry.rowGroup === ""
29573
+ ? `WHERE (${QueryColumnNames.ROWGROUP} IS NULL OR ${QueryColumnNames.ROWGROUP} = '')`
29574
+ : `WHERE ${QueryColumnNames.ROWGROUP} = ${this.bind(rowGroupEntry.rowGroup)}`;
29575
+ // is limit active?
29576
+ let queryLimitSection = "";
29577
+ if (this.config.limit) {
29578
+ queryLimitSection = `LIMIT ${this.config.limit}`;
29579
+ }
29580
+ this.createGroupHeaderRow(rowGroupEntry, queries);
29581
+ this.createDataRow(queries, rowGroupEntry, groups, scenarios, attributesSQL, queryWhereSection, order, queryLimitSection);
29582
+ this.createRestRow(rowGroupEntry, queries, groups, scenarios, queryWhereSection, order);
29583
+ this.createGroupSumRow(queries, sumGroupQueries, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order);
29584
+ });
29585
+ this.createTotalSumRow(queries, sumGroupQueries, scenariosSUMQuery);
29586
+ // executes main queries
29587
+ queries.forEach((query) => res.push(this.exec(query)));
29588
+ if (this.hasRunningSum()) {
29589
+ this.accumulateGroupSums(res, [...new Set(this.exctractScenarioNames(scenariosSUMQuery))]);
29590
+ }
29591
+ this.detectNaNCells(this.config.scenarios, res);
29592
+ this.createThereOfDrillRows(scenarios, attributesSQL, order, res);
29593
+ this.createPartOfDrillRows(scenarios, order, sumGroupQueries, res);
29594
+ this.createIntervalColumns(res);
29595
+ this.createThereOfDrillColumns(this.config.categoryThereOf, res);
29596
+ this.calculateColumnGroupRest(res, this.config.categoryThereOf);
29597
+ this.calculateRelativeVariances(res, relativeScenarios);
29598
+ return res;
29099
29599
  }
29100
29600
  /**
29101
29601
  * Marks aggregated cells as NaN when no source rows contributed to the sum.
@@ -29132,7 +29632,7 @@ class DataQuery {
29132
29632
  * value by the corresponding group sum to produce a percentage.
29133
29633
  */
29134
29634
  createPartOfDrillRows(scenarios, order, sumGroupQueries, res) {
29135
- if (this.config.partOf == null || this.config.partOf.length === 0 || this.config.type === TableType.LIST) {
29635
+ if (this.config.partOf == null || this.config.partOf.length === 0 || this.config.type === withStyled.TableType.LIST) {
29136
29636
  return;
29137
29637
  }
29138
29638
  const drillQueries = this.createPartOfQuery(scenarios, order);
@@ -29178,8 +29678,13 @@ class DataQuery {
29178
29678
  .map((name) => `SUM(${name}) as ${name}`)
29179
29679
  .join(", ");
29180
29680
  // a REST row of only "-" rows counts as "-" for the op sentiment; not named operation, so it stays hidden
29181
- const restOperation = TableType.OPT === this.config.type || TableType.OPTNOTOTAL === this.config.type
29182
- ? `, CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation`
29681
+ // the row prints the unsigned sum; the walk of a waterfall needs the signed sum of its bar columns
29682
+ const restSigned = this.exctractScenarioNames(scenarios)
29683
+ .filter((name) => { var _a; return (_a = this.config.barColumns) === null || _a === void 0 ? void 0 : _a.includes(name); })
29684
+ .map((name) => `, SUM(${name} * transformOperator(operation)) as ${restSignedAlias(name)}`)
29685
+ .join("");
29686
+ const restOperation = withStyled.TableType.OPT === this.config.type || withStyled.TableType.OPTNOTOTAL === this.config.type
29687
+ ? `, CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation${restSigned}`
29183
29688
  : "";
29184
29689
  querys.push(`SELECT ${QueryColumnNames.ROWNR}, 1 as ${QueryColumnNames.ROWGROUPINDEX} , 'ENTRY' as ${QueryColumnNames.TYPE}, 'NO_GROUP' as ${QueryColumnNames.ROWGROUP}, ${this.bind(String((_a = rowGroupEntry.rowGroup) !== null && _a !== void 0 ? _a : ""))} as restRowGroup, 'REST' as ${QueryColumnNames.CATEGORY}${restOperation} ${restScenarios.length > 0 ? ", " + restScenarios : ""} FROM` +
29185
29690
  ` (SELECT ROWNUM() AS ${QueryColumnNames.ROWNR}, ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX} , 'ENTRY' as ${QueryColumnNames.TYPE}, ${this.bind(String(rowGroupEntry.rowGroup || "NO_GROUP"))} as ${QueryColumnNames.ROWGROUP}, ${groups.select()} ${scenarios.length > 0 ? ",".concat(scenarios) : ""}${this.sortSelect} FROM ${this.fromExpr} ${queryWhereSection} GROUP BY ${groups} ORDER BY ${order[0]})` +
@@ -29216,10 +29721,38 @@ class DataQuery {
29216
29721
  }
29217
29722
  }
29218
29723
  hasGroupSum() {
29219
- return (TableType.SUM === this.config.type ||
29220
- TableType.SUMNOTOTAL === this.config.type ||
29221
- TableType.OPT === this.config.type ||
29222
- TableType.OPTNOTOTAL === this.config.type);
29724
+ return (withStyled.TableType.SUM === this.config.type ||
29725
+ withStyled.TableType.SUMNOTOTAL === this.config.type ||
29726
+ withStyled.TableType.OPT === this.config.type ||
29727
+ withStyled.TableType.OPTNOTOTAL === this.config.type);
29728
+ }
29729
+ /**
29730
+ * True when the group sum rows are running results: only a grouped table with group sum
29731
+ * rows has them. Column drill values of the group sum rows are not accumulated, so
29732
+ * `runningSum` is off with columnthereof.
29733
+ */
29734
+ hasRunningSum() {
29735
+ return (this.config.runningSum && this.config.grouped && this.hasGroupSum() && this.config.categoryThereOf.size === 0);
29736
+ }
29737
+ /**
29738
+ * Turns the GROUP_SUM rows into running results: each one gets the raw aliases of all
29739
+ * group sums before it added (scenarios, `_cnt`, variances and `dr_*` denominators).
29740
+ * Runs before the NaN step and the relative variance division, where all of them are sums.
29741
+ * A missing value stays missing until a group brings a real one.
29742
+ */
29743
+ accumulateGroupSums(res, aliases) {
29744
+ const running = {};
29745
+ for (const segment of res) {
29746
+ for (const row of segment) {
29747
+ if (row[QueryColumnNames.TYPE] !== "GROUP_SUM") {
29748
+ continue;
29749
+ }
29750
+ for (const alias of aliases) {
29751
+ running[alias] = addGroupSum(running[alias], row[alias]);
29752
+ row[alias] = running[alias];
29753
+ }
29754
+ }
29755
+ }
29223
29756
  }
29224
29757
  /** Generates a GROUP_SUM row that aggregates all entries within a single row group. */
29225
29758
  createGroupSumRow(querys, groupSumQuery, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order) {
@@ -29245,7 +29778,7 @@ class DataQuery {
29245
29778
  /** Generates a total SUM row across all groups (only for SUM / OPT table types). */
29246
29779
  createTotalSumRow(querys, sumGroupQueries, scenariosSUMQuery) {
29247
29780
  var _a;
29248
- if (TableType.SUM === this.config.type || TableType.OPT === this.config.type) {
29781
+ if (withStyled.TableType.SUM === this.config.type || withStyled.TableType.OPT === this.config.type) {
29249
29782
  // An empty label falls back to the SUM_TOTAL key, which tableDataSetFactory
29250
29783
  // resolves to the IBCS total symbol (❖).
29251
29784
  const label = ((_a = this.config.title) === null || _a === void 0 ? void 0 : _a.trim()) || "SUM_TOTAL";
@@ -29497,13 +30030,13 @@ class DataQuery {
29497
30030
  const entryAliases = [...new Set(this.exctractScenarioNames(scenarios))];
29498
30031
  const relativeScenarios = this.getRelativeScenarios();
29499
30032
  const groups = new QueryGroups(this.config);
29500
- const isOpt = TableType.OPT === this.config.type || TableType.OPTNOTOTAL === this.config.type;
30033
+ const isOpt = withStyled.TableType.OPT === this.config.type || withStyled.TableType.OPTNOTOTAL === this.config.type;
29501
30034
  const isSumTypeGrouped = this.config.grouped &&
29502
- (TableType.SUM === this.config.type ||
29503
- TableType.SUMNOTOTAL === this.config.type ||
29504
- TableType.OPT === this.config.type ||
29505
- TableType.OPTNOTOTAL === this.config.type);
29506
- const hasPartOfActive = this.checkConfigForPartOf() && this.config.type !== TableType.LIST;
30035
+ (withStyled.TableType.SUM === this.config.type ||
30036
+ withStyled.TableType.SUMNOTOTAL === this.config.type ||
30037
+ withStyled.TableType.OPT === this.config.type ||
30038
+ withStyled.TableType.OPTNOTOTAL === this.config.type);
30039
+ const hasPartOfActive = this.checkConfigForPartOf() && this.config.type !== withStyled.TableType.LIST;
29507
30040
  const exec = (query) => this.exec(query);
29508
30041
  // mirrors detectNaNCells + calculateRelativeVariances for a single bucket row
29509
30042
  const finalizeBucketRow = (row) => {
@@ -29602,7 +30135,27 @@ class DataQuery {
29602
30135
  : [];
29603
30136
  const groupTotalsByKey = new Map();
29604
30137
  groupTotalRowsRaw.forEach((row) => groupTotalsByKey.set(`${row.rowGroup}${separator}${coerceBucketKey(row.__interval)}`, row));
29605
- if (isSumTypeGrouped) {
30138
+ if (isSumTypeGrouped && this.hasRunningSum()) {
30139
+ // per bucket, each group sum row gets the totals of all groups up to its own
30140
+ const sumAliases = [...new Set(this.exctractScenarioNames(scenariosSUMQuery))];
30141
+ const groupSumRows = res.flat().filter((row) => row.type === "GROUP_SUM");
30142
+ for (const bucketKey of new Set(groupTotalRowsRaw.map((row) => coerceBucketKey(row.__interval)))) {
30143
+ let running;
30144
+ for (const row of groupSumRows) {
30145
+ const totalRow = groupTotalsByKey.get(`${row.rowGroup}${separator}${bucketKey}`);
30146
+ if (totalRow) {
30147
+ running !== null && running !== void 0 ? running : (running = {});
30148
+ for (const alias of sumAliases) {
30149
+ running[alias] = addGroupSum(running[alias], totalRow[alias]);
30150
+ }
30151
+ }
30152
+ if (running) {
30153
+ writeBucketValues(row, finalizeBucketRow(Object.assign({}, running)), bucketKey);
30154
+ }
30155
+ }
30156
+ }
30157
+ }
30158
+ else if (isSumTypeGrouped) {
29606
30159
  for (const totalRow of groupTotalRowsRaw) {
29607
30160
  const bucketKey = coerceBucketKey(totalRow.__interval);
29608
30161
  const finalized = finalizeBucketRow(Object.assign({}, totalRow));
@@ -29615,7 +30168,7 @@ class DataQuery {
29615
30168
  }
29616
30169
  }
29617
30170
  }
29618
- const hasTotalSumRow = TableType.SUM === this.config.type || TableType.OPT === this.config.type;
30171
+ const hasTotalSumRow = withStyled.TableType.SUM === this.config.type || withStyled.TableType.OPT === this.config.type;
29619
30172
  const sumTotalRowsRaw = hasTotalSumRow || (hasPartOfActive && !this.config.grouped)
29620
30173
  ? exec(`SELECT __interval ${scenariosSUMQuery.length > 0 ? ",".concat(scenariosSUMQuery) : ""}
29621
30174
  FROM ${bucketSource}
@@ -29755,7 +30308,7 @@ class DataQuery {
29755
30308
  */
29756
30309
  translateScenarioSQL(scenario, isSumRow, type) {
29757
30310
  const scenarios = new VarianceScenario(scenario);
29758
- if (TableType.OPT === type || TableType.OPTNOTOTAL === type) {
30311
+ if (withStyled.TableType.OPT === type || withStyled.TableType.OPTNOTOTAL === type) {
29759
30312
  if (scenarios.isValid) {
29760
30313
  // sum rows show signed scenario values, so their variances must be signed too
29761
30314
  const sign = isSumRow ? " * transformOperator(operation)" : "";
@@ -29795,7 +30348,7 @@ class DataQuery {
29795
30348
  translateAttributeSQL(attribute) {
29796
30349
  const field = `[${attribute.arg}]`;
29797
30350
  const isScenarioField = /^(ac|pp|fc|pl)[1-4]$/.test(attribute.arg);
29798
- const useOperator = isScenarioField && this.config.type !== TableType.OPT && this.config.type !== TableType.OPTNOTOTAL;
30351
+ const useOperator = isScenarioField && this.config.type !== withStyled.TableType.OPT && this.config.type !== withStyled.TableType.OPTNOTOTAL;
29799
30352
  switch (attribute.fn) {
29800
30353
  case "set":
29801
30354
  return `SETAGG(${field}) as ${attribute.alias}`;
@@ -29846,7 +30399,7 @@ class DataQuery {
29846
30399
  * @param orderComponent
29847
30400
  */
29848
30401
  createOrderString(orderComponent) {
29849
- const inverse = OrderDirection.ASC === orderComponent.direction ? OrderDirection.DESC : OrderDirection.ASC;
30402
+ const inverse = withStyled.OrderDirection$1.ASC === orderComponent.direction ? withStyled.OrderDirection$1.DESC : withStyled.OrderDirection$1.ASC;
29850
30403
  const sortKeys = new Map();
29851
30404
  orderComponent.hierarchy.forEach((column, i) => {
29852
30405
  const token = withStyled.parseOrderToken(column);
@@ -29877,7 +30430,7 @@ class DataQuery {
29877
30430
  * `__sortnull<i>` is 1 when the cell has no value: no data, or a relative variance with a zero reference.
29878
30431
  */
29879
30432
  translateSortKeySQL(token, bucket, i) {
29880
- const isOpt = TableType.OPT === this.config.type || TableType.OPTNOTOTAL === this.config.type;
30433
+ const isOpt = withStyled.TableType.OPT === this.config.type || withStyled.TableType.OPTNOTOTAL === this.config.type;
29881
30434
  const sign = isOpt ? "" : " * transformOperator(operation)";
29882
30435
  const inBucket = bucket === undefined ? "" : `TRIM(CAST(${intervalBucketSQL(INTERVAL_SETNAME)} AS STRING)) = ${this.bind(bucket)}`;
29883
30436
  const value = (x) => `SUM(${inBucket ? `(CASE WHEN ${inBucket} THEN ${x} ELSE 0 END)` : x}${sign})`;
@@ -30148,181 +30701,10 @@ class DataQuery {
30148
30701
  }
30149
30702
  }
30150
30703
 
30151
- /**
30152
- * Waterfall geometry per raw result row and column, keyed by row identity
30153
- * (the factory iterates the same row objects the calculator walked).
30154
- */
30155
- class WaterfallResult {
30156
- constructor() {
30157
- this.geometry = new Map();
30158
- }
30159
- set(row, column, data) {
30160
- let columns = this.geometry.get(row);
30161
- if (!columns) {
30162
- columns = new Map();
30163
- this.geometry.set(row, columns);
30164
- }
30165
- columns.set(column, data);
30166
- }
30167
- get(row, column) {
30168
- var _a;
30169
- return (_a = this.geometry.get(row)) === null || _a === void 0 ? void 0 : _a.get(column);
30170
- }
30171
- }
30172
- /** True when the result contains grouping structure (sum, subtotal, or drill rows). */
30173
- function hasGroupingStructure(queryData) {
30174
- for (const groupData of queryData) {
30175
- for (const row of groupData) {
30176
- const type = row[QueryColumnNames.TYPE];
30177
- if (type === TableRowType.SUM ||
30178
- type === TableRowType.GROUPSUM ||
30179
- type === TableRowType.DRILLELEMENT ||
30180
- type === TableRowType.PARTELEMENT) {
30181
- return true;
30182
- }
30183
- }
30184
- }
30185
- return false;
30186
- }
30187
- /**
30188
- * Signed waterfall contribution of a row for one column.
30189
- *
30190
- * Non-OPT table types aggregate `SUM(scn * transformOperator(operation))`, so ENTRY
30191
- * values arrive already signed. OPT types aggregate plain `SUM(scn)` with the sign
30192
- * carried in the visible operation column, so the sign is applied here. Sum rows are
30193
- * fully signed in both modes.
30194
- */
30195
- function signedValue(row, column, tableType) {
30196
- const raw = row[column];
30197
- if (raw === null || raw === undefined) {
30198
- return null;
30199
- }
30200
- const value = Number(raw);
30201
- if (isNaN(value)) {
30202
- return null;
30203
- }
30204
- const isOpt = tableType === TableType.OPT || tableType === TableType.OPTNOTOTAL;
30205
- if (isOpt && row[QueryColumnNames.TYPE] === TableRowType.ENTRY && row[QueryColumnNames.OPERATION] === "-") {
30206
- return -value;
30207
- }
30208
- return value;
30209
- }
30210
- /**
30211
- * Computes waterfall bar geometry for the given scenario columns by walking the
30212
- * segmented query result once per column in display order.
30213
- *
30214
- * - ENTRY rows (incl. REST) cascade from the running total by their signed value.
30215
- * - SUM / GROUP_SUM rows anchor at zero. A SUM row resets the running total to its
30216
- * value, a GROUP_SUM row resets it to zero.
30217
- * - DRILLELEMENT (thereof) rows form a sub-cascade from their parent bar's start in
30218
- * the parent's direction; the running total is untouched.
30219
- * - PARTELEMENT (partof) rows cascade a `share * parent width` segment the same way.
30220
- * Note: the share denominator is the group sum (or SUM_TOTAL when ungrouped) per
30221
- * `createPartOfDrillRows`, not literally the parent row's value.
30222
- * - GROUPHEAD rows get no bar and restart the running total at zero: every row group
30223
- * is its own cascade that ends at its GROUP_SUM.
30224
- * - NaN rows get no bar; a NaN parent orphans its drill children.
30225
- *
30226
- * @param queryData - Segmented result rows from DataQuery.execute().
30227
- * @param columns - Plain scenario column keys (ac1..pl4); no `##` composite keys.
30228
- * @param tableType - Table aggregation mode, needed for OPT sign handling.
30229
- */
30230
- function computeWaterfall(queryData, columns, tableType) {
30231
- const result = new WaterfallResult();
30232
- for (const column of columns) {
30233
- let running = 0;
30234
- let lastParent;
30235
- let subCursor = 0;
30236
- const emitted = [];
30237
- const emit = (row, data) => {
30238
- emitted.push(data);
30239
- result.set(row, column, data);
30240
- };
30241
- for (const groupData of queryData) {
30242
- for (const row of groupData) {
30243
- const type = row[QueryColumnNames.TYPE];
30244
- if (type === TableRowType.GROUPHEAD) {
30245
- // a group sum only totals its own rows, so the cascade must not carry over
30246
- running = 0;
30247
- lastParent = undefined;
30248
- continue;
30249
- }
30250
- const value = signedValue(row, column, tableType);
30251
- if (type === TableRowType.ENTRY) {
30252
- if (value === null) {
30253
- lastParent = undefined;
30254
- continue;
30255
- }
30256
- emit(row, { start: running, end: running + value, min: 0, max: 0, kind: "cascade" });
30257
- lastParent = { start: running, end: running + value };
30258
- subCursor = lastParent.start;
30259
- running += value;
30260
- }
30261
- else if (type === TableRowType.SUM || type === TableRowType.GROUPSUM) {
30262
- if (value === null) {
30263
- lastParent = undefined;
30264
- continue;
30265
- }
30266
- emit(row, { start: 0, end: value, min: 0, max: 0, kind: "anchor" });
30267
- lastParent = { start: 0, end: value };
30268
- subCursor = 0;
30269
- // a group sum closes its group (there may be no GROUPHEAD row when the title is hidden)
30270
- running = type === TableRowType.GROUPSUM ? 0 : value;
30271
- }
30272
- else if (type === TableRowType.DRILLELEMENT) {
30273
- if (value === null || lastParent === undefined) {
30274
- continue;
30275
- }
30276
- const direction = Math.sign(lastParent.end - lastParent.start) || 1;
30277
- const end = subCursor + direction * Math.abs(value);
30278
- emit(row, {
30279
- start: subCursor,
30280
- end,
30281
- min: 0,
30282
- max: 0,
30283
- kind: "thereof",
30284
- parentStart: lastParent.start,
30285
- parentEnd: lastParent.end,
30286
- });
30287
- subCursor = end;
30288
- }
30289
- else if (type === TableRowType.PARTELEMENT) {
30290
- if (value === null || lastParent === undefined) {
30291
- continue;
30292
- }
30293
- const end = subCursor + value * (lastParent.end - lastParent.start);
30294
- emit(row, {
30295
- start: subCursor,
30296
- end,
30297
- min: 0,
30298
- max: 0,
30299
- kind: "partof",
30300
- parentStart: lastParent.start,
30301
- parentEnd: lastParent.end,
30302
- });
30303
- subCursor = end;
30304
- }
30305
- }
30306
- }
30307
- // All rows of a column share one coordinate system including zero
30308
- let min = 0;
30309
- let max = 0;
30310
- for (const data of emitted) {
30311
- min = Math.min(min, data.start, data.end);
30312
- max = Math.max(max, data.start, data.end);
30313
- }
30314
- for (const data of emitted) {
30315
- data.min = min;
30316
- data.max = max;
30317
- }
30318
- }
30319
- return result;
30320
- }
30321
-
30322
30704
  /**
30323
30705
  * Transforms raw query results into structured TableRow collections for header and body.
30324
30706
  *
30325
- * Header normalization: prepends fixed columns (operation, category) to the configured
30707
+ * Header normalization: adds the fixed columns (operation, category) to the configured
30326
30708
  * scenarios, then translates labels via i18n and adds separator rows for IBCS-style borders.
30327
30709
  *
30328
30710
  * Body row creation: iterates DataQuery results grouped by rowGroup, creates detail rows
@@ -30349,7 +30731,7 @@ class TableDataSetFactory {
30349
30731
  }
30350
30732
  return styleSlot(this.ruleSet.getScenarioColorIndex(type)) + type.slice(2);
30351
30733
  }
30352
- /** Effective column list (category/operation + attributes + scenarios × buckets), set by createHeader(). */
30734
+ /** Effective column list (category/operation + attributes + scenarios × buckets) in render order, set by createHeader(). */
30353
30735
  getNormalizedHeader() {
30354
30736
  return this.normalizedHeader;
30355
30737
  }
@@ -30361,16 +30743,16 @@ class TableDataSetFactory {
30361
30743
  * visualise grouping.
30362
30744
  * finally a seperator header row is created for the header underlining (border)
30363
30745
  */
30364
- createHeader(type, scenarios, i18n, measureScale, measureUnit, showMeasureScale, attributes = []) {
30746
+ createHeader(type, scenarios, i18n, measureScale, measureUnit, showMeasureScale, attributes = [], leadingScenarioColumns = 0) {
30365
30747
  const header = [];
30366
30748
  this.attributesByAlias = new Map(attributes.map((attribute) => [attribute.alias, attribute]));
30367
- this.normalizedHeader = this.normalizeHeader(type, scenarios, attributes);
30749
+ this.normalizedHeader = this.normalizeHeader(type, scenarios, attributes, leadingScenarioColumns);
30368
30750
  const hasIntervalColumns = this.normalizedHeader.some((column) => column.bucket !== undefined);
30369
30751
  if (hasIntervalColumns) {
30370
30752
  header.push(this.createIntervalBandRow());
30371
30753
  }
30372
- const headerRow = new TableRow(hasIntervalColumns ? 1 : 0, 0, TableRowType.HEADER);
30373
- const separatorRow = new TableRow(hasIntervalColumns ? 2 : 1, 0, TableRowType.SEPERATORLINE);
30754
+ const headerRow = new TableRow(hasIntervalColumns ? 1 : 0, 0, withStyled.TableRowType.HEADER);
30755
+ const separatorRow = new TableRow(hasIntervalColumns ? 2 : 1, 0, withStyled.TableRowType.SEPERATORLINE);
30374
30756
  for (const scenario of this.normalizedHeader) {
30375
30757
  const attribute = this.attributesByAlias.get(scenario.name);
30376
30758
  headerRow.createElement(attribute
@@ -30384,12 +30766,12 @@ class TableDataSetFactory {
30384
30766
  }
30385
30767
  /**
30386
30768
  * Creates the spanning interval band row (e.g. `2023 | 2024 | 2025`) rendered
30387
- * above the scenario label row. Leading non-interval columns (category,
30769
+ * above the scenario label row. Non-interval columns (category,
30388
30770
  * operation, attributes) receive borderless filler cells; each run of
30389
30771
  * consecutive columns of the same bucket is spanned by one label cell.
30390
30772
  */
30391
30773
  createIntervalBandRow() {
30392
- const bandRow = new TableRow(0, 0, TableRowType.HEADER);
30774
+ const bandRow = new TableRow(0, 0, withStyled.TableRowType.HEADER);
30393
30775
  let index = 0;
30394
30776
  while (index < this.normalizedHeader.length) {
30395
30777
  const column = this.normalizedHeader[index];
@@ -30425,8 +30807,11 @@ class TableDataSetFactory {
30425
30807
  * configured scenarios.
30426
30808
  * depending of table type operation column is used (OPT) or not (SUM | LIST)
30427
30809
  * in addition the headers are sorted based on the ruleset and duplicates are removed
30810
+ *
30811
+ * operation, category and the attribute columns are the row header block. It moves
30812
+ * as one unit: `leadingScenarioColumns` scenario columns stand left of it.
30428
30813
  */
30429
- normalizeHeader(type, scenarios, attributes) {
30814
+ normalizeHeader(type, scenarios, attributes, leadingScenarioColumns = 0) {
30430
30815
  let header = [
30431
30816
  {
30432
30817
  name: QueryColumnNames.CATEGORY,
@@ -30435,7 +30820,7 @@ class TableDataSetFactory {
30435
30820
  order: undefined,
30436
30821
  },
30437
30822
  ];
30438
- if (TableType.OPT === type || TableType.OPTNOTOTAL === type) {
30823
+ if (withStyled.TableType.OPT === type || withStyled.TableType.OPTNOTOTAL === type) {
30439
30824
  header = [
30440
30825
  {
30441
30826
  name: QueryColumnNames.OPERATION,
@@ -30459,7 +30844,12 @@ class TableDataSetFactory {
30459
30844
  order: undefined,
30460
30845
  }));
30461
30846
  // NOTE: scenarios are already sorted in setConfig
30462
- return [...header, ...attributeColumns, ...scenarios];
30847
+ return [
30848
+ ...scenarios.slice(0, leadingScenarioColumns),
30849
+ ...header,
30850
+ ...attributeColumns,
30851
+ ...scenarios.slice(leadingScenarioColumns),
30852
+ ];
30463
30853
  }
30464
30854
  /**
30465
30855
  * Creates table data colelction,
@@ -30472,25 +30862,29 @@ class TableDataSetFactory {
30472
30862
  let iGroupIndex = -1; // index used in detailRow JSON to count the current group
30473
30863
  const dataQuery = new DataQuery(config, i18n);
30474
30864
  this.dateBuckets = isDateInterval(config.interval);
30475
- this.unsignedEntries = TableType.OPT === config.type || TableType.OPTNOTOTAL === config.type;
30865
+ this.unsignedEntries = withStyled.TableType.OPT === config.type || withStyled.TableType.OPTNOTOTAL === config.type;
30476
30866
  const queryData = dataQuery.execute(db, fromExpr); // collection of all query results
30477
30867
  this.hasBlankRowGroup = dataQuery.hasBlankRowGroup;
30478
30868
  // Calculate column statistics for bar columns
30479
30869
  const columnStatsMap = this.calculateColumnStatistics(queryData, config.barColumns, config.interval !== INTERVAL_NONE);
30480
- // Scenario bar columns render as a waterfall when grouping structure is present;
30870
+ // Scenario bar columns render as a waterfall when grouping structure is present,
30871
+ // absolute variance bar columns when varianceWaterfall is set;
30481
30872
  // interval/columnthereof composite columns are excluded and render as today
30482
- const waterfallColumns = ((_a = config.barColumns) !== null && _a !== void 0 ? _a : []).filter((column) => column.toUpperCase().trim() in withStyled.Scenarios);
30483
- const waterfallResult = waterfallColumns.length > 0 &&
30484
- config.interval === INTERVAL_NONE &&
30485
- config.categoryThereOf.size === 0 &&
30486
- hasGroupingStructure(queryData)
30487
- ? computeWaterfall(queryData, waterfallColumns, config.type)
30873
+ const thereOfAbove = config.thereOfPosition === withStyled.ThereofPosition.ABOVE;
30874
+ const barColumns = (_a = config.barColumns) !== null && _a !== void 0 ? _a : [];
30875
+ const scenarioColumns = barColumns.filter((column) => column.toUpperCase().trim() in withStyled.Scenarios);
30876
+ const waterfallColumns = [
30877
+ ...(scenarioColumns.length > 0 && hasGroupingStructure(queryData) ? scenarioColumns : []),
30878
+ ...(config.varianceWaterfall ? barColumns.filter((column) => new VarianceScenario(column).type === "d") : []),
30879
+ ];
30880
+ const waterfallResult = waterfallColumns.length > 0 && config.interval === INTERVAL_NONE && config.categoryThereOf.size === 0
30881
+ ? computeWaterfall(queryData, waterfallColumns, config.type, dataQuery.hasRunningSum(), thereOfAbove)
30488
30882
  : undefined;
30489
30883
  for (const groupData of queryData) {
30490
30884
  // groupData is a collection of dataRows, each group base on a query and represents a 'row' group
30491
30885
  iGroupIndex += 1;
30492
30886
  const iRowIndex = -1;
30493
- bodyRows.push(...this.createRow(config.i18n, i18n, config.scenariosUnitType, groupData, iGroupIndex, iRowIndex, config.categoryWidth, config.measureScale, config.barColumns, columnStatsMap, waterfallResult));
30887
+ bodyRows.push(...this.createRow(config.i18n, i18n, config.scenariosUnitType, groupData, iGroupIndex, iRowIndex, config.categoryWidth, config.measureScale, config.barColumns, columnStatsMap, waterfallResult, thereOfAbove));
30494
30888
  }
30495
30889
  return bodyRows;
30496
30890
  }
@@ -30513,7 +30907,7 @@ class TableDataSetFactory {
30513
30907
  for (const row of groupData) {
30514
30908
  // sum rows draw no bar (a waterfall takes its extent from WaterfallBarData), so they must not stretch the scale
30515
30909
  const type = row[QueryColumnNames.TYPE];
30516
- if (type === TableRowType.SUM || type === TableRowType.GROUPSUM)
30910
+ if (type === withStyled.TableRowType.SUM || type === withStyled.TableRowType.GROUPSUM)
30517
30911
  continue;
30518
30912
  for (const column of barColumns) {
30519
30913
  // with an active interval the rendered values live under the
@@ -30601,9 +30995,12 @@ class TableDataSetFactory {
30601
30995
  * @param barColumns
30602
30996
  * @param columnStatsMap
30603
30997
  */
30604
- createRow(i18nMode, i18n, scenariosUnitType, groupData, iGroupIndex, iRowIndex, categoryWidth, measureScale, barColumns, columnStatsMap, waterfallResult) {
30998
+ createRow(i18nMode, i18n, scenariosUnitType, groupData, iGroupIndex, iRowIndex, categoryWidth, measureScale, barColumns, columnStatsMap, waterfallResult, thereOfAbove = false) {
30605
30999
  var _a, _b, _c;
30606
31000
  const result = [];
31001
+ // the last entry row and its index in result: the parent of the thereof rows that follow it
31002
+ let parentIndex = -1;
31003
+ let parent;
30607
31004
  // thereof and partof rows have no operation, they take the one of the row above
30608
31005
  let operation;
30609
31006
  for (const rawDataRow of groupData) {
@@ -30615,20 +31012,31 @@ class TableDataSetFactory {
30615
31012
  const type = rawDataRow[QueryColumnNames.TYPE];
30616
31013
  const isSecondElement = rawDataRow[QueryColumnNames.ROWNR] >= 2;
30617
31014
  operation = ((_b = (_a = rawDataRow.operation) !== null && _a !== void 0 ? _a : rawDataRow.restOperation) !== null && _b !== void 0 ? _b : operation);
31015
+ // a thereof row moves above the entry row before it only when that row is its parent
31016
+ const moved = thereOfAbove &&
31017
+ type === withStyled.TableRowType.DRILLELEMENT &&
31018
+ parent !== undefined &&
31019
+ parent[QueryColumnNames.CATEGORY] === rawDataRow[QueryColumnNames.CATEGORY] &&
31020
+ (parent[QueryColumnNames.ROWGROUP] === "NO_GROUP" || parent[QueryColumnNames.ROWGROUP] === rowGroup);
30618
31021
  const detailsRow = this.createDetailRow(type, iRowIndex, iGroupIndex, groupData.length);
30619
31022
  detailsRow.key = this.rowKey(rawDataRow);
30620
31023
  for (const scenario of this.normalizedHeader) {
30621
31024
  const value = this.getRawDataRowElement(rawDataRow, scenario);
30622
- const isBarChart = (_c = barColumns === null || barColumns === void 0 ? void 0 : barColumns.includes(scenario.type)) !== null && _c !== void 0 ? _c : false;
30623
- const columnStats = isBarChart ? columnStatsMap === null || columnStatsMap === void 0 ? void 0 : columnStatsMap.get(scenario.type) : undefined;
31025
+ const isBarColumn = (_c = barColumns === null || barColumns === void 0 ? void 0 : barColumns.includes(scenario.type)) !== null && _c !== void 0 ? _c : false;
30624
31026
  // waterfall geometry only exists for plain scenario columns (no ## composites)
30625
- const waterfall = isBarChart &&
31027
+ const waterfall = isBarColumn &&
30626
31028
  scenario.bucket === undefined &&
30627
31029
  scenario.name === scenario.group &&
30628
31030
  scenario.name === scenario.type
30629
31031
  ? waterfallResult === null || waterfallResult === void 0 ? void 0 : waterfallResult.get(rawDataRow, scenario.type)
30630
31032
  : undefined;
30631
- detailsRow.createElement(this.translateSumCellLabel(i18nMode, i18n, value, groupName, subCategory, type, scenario.type), scenario.type, this.createColumnType(scenario), this.setCellType(scenario.type, scenariosUnitType), this.translateCellPrefix(i18n, type, scenario.type), this.translateScenarioCSS(scenario.type, value, operation), isSecondElement, categoryWidth, measureScale === null || measureScale === void 0 ? void 0 : measureScale.value, isBarChart, columnStats, 1, waterfall);
31033
+ // a share of a variance has no place in the walk of a variance waterfall: the row prints the number
31034
+ const isBarChart = isBarColumn &&
31035
+ !(type === withStyled.TableRowType.PARTELEMENT &&
31036
+ new VarianceScenario(scenario.type).isValid &&
31037
+ (waterfallResult === null || waterfallResult === void 0 ? void 0 : waterfallResult.has(scenario.type)));
31038
+ const columnStats = isBarChart ? columnStatsMap === null || columnStatsMap === void 0 ? void 0 : columnStatsMap.get(scenario.type) : undefined;
31039
+ detailsRow.createElement(this.translateSumCellLabel(i18nMode, i18n, value, groupName, subCategory, type, scenario.type), scenario.type, this.createColumnType(scenario), this.setCellType(scenario.type, scenariosUnitType), moved ? null : this.translateCellPrefix(i18n, type, scenario.type), this.translateScenarioCSS(scenario.type, value, operation), isSecondElement, categoryWidth, measureScale === null || measureScale === void 0 ? void 0 : measureScale.value, isBarChart, columnStats, 1, waterfall);
30632
31040
  const cell = detailsRow.elements[detailsRow.elements.length - 1];
30633
31041
  if (this.dateBuckets && scenario.bucket !== undefined) {
30634
31042
  cell.date = pointDate(scenario.bucket);
@@ -30638,6 +31046,18 @@ class TableDataSetFactory {
30638
31046
  cell.direction = this.resolveDirection(varianceScenario, operation);
30639
31047
  }
30640
31048
  }
31049
+ // moved only here: the operation above and the waterfall geometry both rely on the parent coming first
31050
+ if (moved) {
31051
+ detailsRow.cssStyle = "ofit-above";
31052
+ result[parentIndex].cssStyle = "ofit-sum";
31053
+ result.splice(parentIndex, 0, detailsRow);
31054
+ parentIndex += 1;
31055
+ continue;
31056
+ }
31057
+ if (type === withStyled.TableRowType.ENTRY) {
31058
+ parentIndex = result.length;
31059
+ parent = rawDataRow;
31060
+ }
30641
31061
  result.push(detailsRow);
30642
31062
  }
30643
31063
  return result;
@@ -30647,13 +31067,13 @@ class TableDataSetFactory {
30647
31067
  var _a;
30648
31068
  const rowGroup = row.restRowGroup != null ? row.restRowGroup : row.rowGroup === "NO_GROUP" ? undefined : row.rowGroup;
30649
31069
  switch (row.type) {
30650
- case TableRowType.ENTRY:
31070
+ case withStyled.TableRowType.ENTRY:
30651
31071
  return { rowGroup, category: row.category, subCategory: row.subCategory };
30652
- case TableRowType.DRILLELEMENT:
31072
+ case withStyled.TableRowType.DRILLELEMENT:
30653
31073
  return { rowGroup, category: row.category, subCategory: (_a = row.rawSubCategory) !== null && _a !== void 0 ? _a : row.subCategory };
30654
- case TableRowType.GROUPSUM:
31074
+ case withStyled.TableRowType.GROUPSUM:
30655
31075
  return { rowGroup, row: "subtotal" };
30656
- case TableRowType.SUM:
31076
+ case withStyled.TableRowType.SUM:
30657
31077
  return { row: "total" };
30658
31078
  default:
30659
31079
  return undefined;
@@ -30684,18 +31104,18 @@ class TableDataSetFactory {
30684
31104
  */
30685
31105
  createDetailRow(type, rowIndex, groupIndex, maxIndex) {
30686
31106
  switch (type) {
30687
- case TableRowType.GROUPHEAD:
30688
- return new TableRow(rowIndex, groupIndex, TableRowType.HEADER);
30689
- case TableRowType.SUM:
30690
- return new TableRow(maxIndex + 2, groupIndex, TableRowType.SUM);
30691
- case TableRowType.GROUPSUM:
30692
- return new TableRow(maxIndex + 2, groupIndex, TableRowType.SUM);
30693
- case TableRowType.DRILLELEMENT:
30694
- return new TableRow(maxIndex + 2, groupIndex, TableRowType.DRILLELEMENT);
30695
- case TableRowType.PARTELEMENT:
30696
- return new TableRow(maxIndex + 2, groupIndex, TableRowType.PARTELEMENT);
31107
+ case withStyled.TableRowType.GROUPHEAD:
31108
+ return new TableRow(rowIndex, groupIndex, withStyled.TableRowType.HEADER);
31109
+ case withStyled.TableRowType.SUM:
31110
+ return new TableRow(maxIndex + 2, groupIndex, withStyled.TableRowType.SUM);
31111
+ case withStyled.TableRowType.GROUPSUM:
31112
+ return new TableRow(maxIndex + 2, groupIndex, withStyled.TableRowType.SUM);
31113
+ case withStyled.TableRowType.DRILLELEMENT:
31114
+ return new TableRow(maxIndex + 2, groupIndex, withStyled.TableRowType.DRILLELEMENT);
31115
+ case withStyled.TableRowType.PARTELEMENT:
31116
+ return new TableRow(maxIndex + 2, groupIndex, withStyled.TableRowType.PARTELEMENT);
30697
31117
  default:
30698
- return new TableRow(rowIndex, groupIndex, TableRowType.STANDARD);
31118
+ return new TableRow(rowIndex, groupIndex, withStyled.TableRowType.STANDARD);
30699
31119
  }
30700
31120
  }
30701
31121
  /**
@@ -30942,11 +31362,11 @@ class Table {
30942
31362
  ["ibcssymbol_delta_generic_relative", "Δ({%})%"],
30943
31363
  ["SUM_TOTAL", "❖"],
30944
31364
  ]);
30945
- this.state = FactoryState$1.DIRTY; // mark dataSet for update
31365
+ this.state = withStyled.FactoryState.DIRTY; // mark dataSet for update
30946
31366
  return new Map([...defaultI18n, ...(i18n || new Map())]);
30947
31367
  }
30948
31368
  initConfig(config) {
30949
- this.state = FactoryState$1.DIRTY; // mark dataSet for update
31369
+ this.state = withStyled.FactoryState.DIRTY; // mark dataSet for update
30950
31370
  const tmpConfig = config;
30951
31371
  // sorting scenario order based on Ruleset
30952
31372
  const self = this;
@@ -30981,7 +31401,7 @@ class Table {
30981
31401
  */
30982
31402
  setSource(tableName, filter) {
30983
31403
  var _a, _b;
30984
- this.state = FactoryState$1.DIRTY;
31404
+ this.state = withStyled.FactoryState.DIRTY;
30985
31405
  // "" while the source is not registered (e.g. the datasource has not loaded yet): treated as empty
30986
31406
  this.fromExpr = withHasError.sourceExpr(this.db, tableName, filter);
30987
31407
  if (!this.fromExpr) {
@@ -30995,28 +31415,33 @@ class Table {
30995
31415
  update() {
30996
31416
  this.prepareIntervalBuckets();
30997
31417
  const normalizedScenarios = this.normalizeScenarios(this.config.scenarios, this.config.categoryThereOf, this.config.sortOrder, this.intervalBuckets);
30998
- this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes);
31418
+ this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes,
31419
+ // every interval group has one column per scenario
31420
+ Math.min(this.categoryIntervalPosition(), this.intervalBuckets.length) * this.config.scenarios.length);
30999
31421
  this.bodyRows =
31000
31422
  this.rowCount === 0 || !this.fromExpr
31001
31423
  ? []
31002
31424
  : this.dataSetFactory.createBodyRows(this.config, this.i18n, this.db, this.fromExpr);
31003
- this.state = FactoryState$1.UP_TO_DATE;
31425
+ this.state = withStyled.FactoryState.UP_TO_DATE;
31004
31426
  }
31005
31427
  getHeader() {
31006
- if (this.state === FactoryState$1.DIRTY) {
31428
+ if (this.state === withStyled.FactoryState.DIRTY) {
31007
31429
  this.update();
31008
31430
  }
31009
31431
  return this.headerRows;
31010
31432
  }
31011
31433
  getBody() {
31012
- if (this.state === FactoryState$1.DIRTY) {
31434
+ if (this.state === withStyled.FactoryState.DIRTY) {
31013
31435
  this.update();
31014
31436
  }
31015
31437
  return this.bodyRows;
31016
31438
  }
31017
- /** Effective column definitions: category/operation + attributes + scenarios × interval buckets. */
31439
+ /**
31440
+ * Effective column definitions in render order: category/operation + attributes + scenarios × interval buckets.
31441
+ * With `categoryIntervalPosition` the first interval buckets come before the category/operation column.
31442
+ */
31018
31443
  getColumns() {
31019
- if (this.state === FactoryState$1.DIRTY) {
31444
+ if (this.state === withStyled.FactoryState.DIRTY) {
31020
31445
  this.update();
31021
31446
  }
31022
31447
  return this.dataSetFactory.getNormalizedHeader();
@@ -31100,7 +31525,7 @@ class Table {
31100
31525
  /** Warning for an order `@bucket` that cannot apply, once the body was built; undefined when all apply. */
31101
31526
  orderBucketWarning() {
31102
31527
  var _a, _b;
31103
- if (this.hasNoData() || this.state !== FactoryState$1.UP_TO_DATE) {
31528
+ if (this.hasNoData() || this.state !== withStyled.FactoryState.UP_TO_DATE) {
31104
31529
  return undefined;
31105
31530
  }
31106
31531
  const buckets = ((_b = (_a = this.config.sortOrder) === null || _a === void 0 ? void 0 : _a.hierarchy) !== null && _b !== void 0 ? _b : [])
@@ -31115,6 +31540,32 @@ class Table {
31115
31540
  const unknown = buckets.find((bucket) => !this.intervalBuckets.some((b) => b.key === bucket));
31116
31541
  return unknown === undefined ? undefined : `order: setname '${unknown}' not found, the rows are not sorted by it.`;
31117
31542
  }
31543
+ /** The configured `categoryIntervalPosition`; anything but a positive integer counts as 0. */
31544
+ categoryIntervalPosition() {
31545
+ const position = this.config.categoryIntervalPosition;
31546
+ return Number.isInteger(position) && position > 0 ? position : 0;
31547
+ }
31548
+ /** Warning for a `categoryIntervalPosition` that cannot apply, once the body was built; undefined when it applies. */
31549
+ categoryIntervalPositionWarning() {
31550
+ const position = this.categoryIntervalPosition();
31551
+ if (position <= 0 || this.hasNoData() || this.state !== withStyled.FactoryState.UP_TO_DATE) {
31552
+ return undefined;
31553
+ }
31554
+ const groups = this.intervalBuckets.length;
31555
+ if (groups === 0) {
31556
+ return {
31557
+ id: "WARN_categoryIntervalPositionNoInterval",
31558
+ message: "categoryIntervalPosition: needs an active interval, the value is ignored.",
31559
+ };
31560
+ }
31561
+ if (position > groups) {
31562
+ return {
31563
+ id: "WARN_categoryIntervalPositionRange",
31564
+ message: `categoryIntervalPosition: '${position}' is greater than the number of interval groups, ${groups} is used.`,
31565
+ };
31566
+ }
31567
+ return undefined;
31568
+ }
31118
31569
  /** True once the body was built and the grouped table has rows with a blank rowGroup. */
31119
31570
  hasBlankRowGroup() {
31120
31571
  return this.dataSetFactory.hasBlankRowGroup;
@@ -31145,8 +31596,14 @@ class TableComponentConfig {
31145
31596
  /** When true, rows are visually grouped by rowGroup. */
31146
31597
  this.grouped = false;
31147
31598
  this.showGroupTitle = true;
31599
+ /** When true, each group sum row holds the running result of all groups up to its own (see bn-table `runningSum` prop). */
31600
+ this.runningSum = false;
31601
+ /** When true, absolute variance bar columns are drawn as a waterfall (see bn-table `varianceWaterfall` prop). */
31602
+ this.varianceWaterfall = false;
31148
31603
  /** Drill-down sub-row definitions -- "thereof" breakdowns within a category. */
31149
31604
  this.thereOf = [];
31605
+ /** Thereof rows below or above their parent row (see bn-table `thereofPosition` prop). */
31606
+ this.thereOfPosition = withStyled.ThereofPosition.BELOW;
31150
31607
  /** Column-level drill-down using `##` separator in category names. */
31151
31608
  this.categoryThereOf = new Map();
31152
31609
  /** Percentage-of-total sub-row definitions. */
@@ -31155,7 +31612,7 @@ class TableComponentConfig {
31155
31612
  this.attributes = [];
31156
31613
  this.sortOrder = new withStyled.OrderAdapter(new StringAdapter()).default();
31157
31614
  /** Table aggregation mode: LIST (flat), SUM (with totals), OPT (with optional totals), etc. */
31158
- this.type = TableType.LIST;
31615
+ this.type = withStyled.TableType.LIST;
31159
31616
  /** Maximum rows to display; 0 means unlimited. */
31160
31617
  this.limit = 0;
31161
31618
  this.i18n = withStyled.I18nMode.ALL;
@@ -31174,6 +31631,8 @@ class TableComponentConfig {
31174
31631
  this.barColumns = [];
31175
31632
  /** Interval column grouping: "none", "setname" or a DateDistance value (see bn-table `interval` prop). */
31176
31633
  this.interval = "none";
31634
+ /** Number of interval groups left of the row header block (see bn-table `categoryIntervalPosition` prop). */
31635
+ this.categoryIntervalPosition = 0;
31177
31636
  /** Locale used for interval bucket labels. */
31178
31637
  this.locale = "de";
31179
31638
  }
@@ -31209,6 +31668,15 @@ class TableComponentConfigAdapter {
31209
31668
  if (withStyled.CompareUtil.isBoolean(data.showGroupTitle)) {
31210
31669
  config.showGroupTitle = data.showGroupTitle;
31211
31670
  }
31671
+ if (withStyled.CompareUtil.isBoolean(data.runningSum)) {
31672
+ config.runningSum = data.runningSum;
31673
+ }
31674
+ if (withStyled.CompareUtil.isBoolean(data.varianceWaterfall)) {
31675
+ config.varianceWaterfall = data.varianceWaterfall;
31676
+ }
31677
+ if (data.thereOfPosition === withStyled.ThereofPosition.ABOVE) {
31678
+ config.thereOfPosition = withStyled.ThereofPosition.ABOVE;
31679
+ }
31212
31680
  if (withStyled.CompareUtil.isBoolean(data.showMeasureScale)) {
31213
31681
  config.showMeasureScale = data.showMeasureScale;
31214
31682
  }
@@ -31257,6 +31725,9 @@ class TableComponentConfigAdapter {
31257
31725
  if (withStyled.CompareUtil.isString(data.interval)) {
31258
31726
  config.interval = data.interval;
31259
31727
  }
31728
+ if (withStyled.CompareUtil.isNumber(data.categoryIntervalPosition)) {
31729
+ config.categoryIntervalPosition = data.categoryIntervalPosition;
31730
+ }
31260
31731
  if (withStyled.CompareUtil.isString(data.locale)) {
31261
31732
  config.locale = data.locale;
31262
31733
  }
@@ -31309,7 +31780,7 @@ class TableDrillGroupAdapter {
31309
31780
  }
31310
31781
  }
31311
31782
 
31312
- const bnTableRendererCss = () => `:host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}`;
31783
+ const bnTableRendererCss = () => `:host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral,td.zero{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.ofit-above td[class^=category]{padding-left:1em}tr.ofit-sum td{border-top:0.1em solid black;font-weight:bold}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.variance-waterfall){overflow:visible}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}tr.ofit td:has(.variance-waterfall){padding:0 0.4166666667em}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}`;
31313
31784
 
31314
31785
  const BnTableRenderer = class {
31315
31786
  constructor(hostRef) {
@@ -31343,20 +31814,26 @@ const BnTableRenderer = class {
31343
31814
  /** @internal */
31344
31815
  this.showGroupTitle = true;
31345
31816
  /** @internal */
31817
+ this.runningSum = false;
31818
+ /** @internal */
31819
+ this.varianceWaterfall = false;
31820
+ /** @internal */
31346
31821
  this.thereof = [];
31347
31822
  /** @internal */
31823
+ this.thereofPosition = withStyled.ThereofPosition.BELOW;
31824
+ /** @internal */
31348
31825
  this.partof = [];
31349
31826
  /** @internal */
31350
31827
  this.order = {
31351
31828
  hierarchy: [],
31352
- direction: OrderDirection.ASC,
31829
+ direction: withStyled.OrderDirection$1.ASC,
31353
31830
  };
31354
31831
  /** @internal */
31355
31832
  this.categorythereof = new Map();
31356
31833
  /** @internal */
31357
31834
  this.attributeColumns = [];
31358
31835
  /** @internal */
31359
- this.type = TableType.LIST;
31836
+ this.type = withStyled.TableType.LIST;
31360
31837
  /** @internal */
31361
31838
  this.categoryWidth = withStyled.TableCategoryWidth.INF;
31362
31839
  /** @internal */
@@ -31379,6 +31856,8 @@ const BnTableRenderer = class {
31379
31856
  this.barColumns = [];
31380
31857
  /** @internal */
31381
31858
  this.interval = "none";
31859
+ /** @internal */
31860
+ this.categoryIntervalPosition = 0;
31382
31861
  /**
31383
31862
  * Total width of a bar chart column, in em of the table font - the same unit
31384
31863
  * `categoryWidth` uses, so the two render at the same width for the same value.
@@ -31393,9 +31872,10 @@ const BnTableRenderer = class {
31393
31872
  this.scaleFactor = 1;
31394
31873
  this.componentDataFormatDigits = new DataFormatDigits();
31395
31874
  this.barColumnLayouts = new Map();
31875
+ this.waterfallGeometries = new Map();
31396
31876
  // labels measured in the fallback font are too narrow or too wide once the web font is there: lay out again
31397
31877
  this.relayout = () => {
31398
- if (this.barColumnLayouts.size > 0)
31878
+ if (this.barColumnLayouts.size > 0 || this.waterfallGeometries.size > 0)
31399
31879
  index.forceUpdate(this);
31400
31880
  };
31401
31881
  withHasError.withComponentStatus(this);
@@ -31528,20 +32008,22 @@ const BnTableRenderer = class {
31528
32008
  const locale = (_d = (_c = (_b = this.stores) === null || _b === void 0 ? void 0 : _b.context) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.locale;
31529
32009
  return (index.h("table", null, index.h("thead", null, this.table.getHeader().map((row) => (index.h("tr", { class: row.cssStyle }, row.getCells().map((cell) => (index.h("th", { colSpan: cell.colSpan, class: cell.cssStyle }, cell.getAsHeaderList().map((line, i, arr) => (index.h("span", null, i === arr.length - 1 ? (index.h("span", { class: line === " " ? "table-footer" : "" }, line, cell.drawPrefix(), " ")) : (index.h("span", null, line, cell.drawPrefix(), index.h("br", null))))))))))))), index.h("tbody", null, this.table.getBody().map((row) => (index.h("tr", Object.assign({ class: row.cssStyle }, dataPointAttributes(row.key, "element")), row === null || row === void 0 ? void 0 : row.getCells().map((cell) => {
31530
32010
  var _a, _b, _c, _d, _e;
31531
- return (index.h("td", Object.assign({ colSpan: cell.colSpan, class: cell.type ? `${cell.cssStyle} ${cell.type}` : cell.cssStyle }, (row.key && cell.value != null && cell.value !== "" && cell.value !== "-"
32011
+ return (index.h("td", Object.assign({ colSpan: cell.colSpan, class: cell.type ? `${this.cellClass(cell, locale)} ${cell.type}` : cell.cssStyle }, (row.key && cell.value != null && cell.value !== "" && cell.value !== "-"
31532
32012
  ? dataPointAttributes(Object.assign(Object.assign({}, row.key), { date: cell.date, scenario: cell.key }), "element")
31533
- : {})), cell.prefix != null ? (index.h("span", { class: cell.cssStyle + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
32013
+ : {})), cell.prefix != null ? (index.h("span", { class: this.cellClass(cell, locale) + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
31534
32014
  cell.columnStats &&
31535
32015
  cell.value !== withStyled.NOT_AVAILABLE &&
31536
32016
  // an untitled group head is only a gap between list groups, a bar cell would print "-" in it
31537
- (this.showGroupTitle || row.type !== TableRowType.HEADER) &&
31538
- (cell.waterfall !== undefined || row.type !== TableRowType.SUM) ? (cell.waterfall !== undefined ? (index.h(WaterfallBar, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: false, isPositiveGood: cell.direction === "pos", measureScale: cell.measureScale, locale: locale, decimalDigits: barLabelDigits(cell, this.componentDataFormatDigits), columnWidthEm: this.barColumnMaxWidth, styles: this.barChartStyles, waterfall: cell.waterfall })) : (index.h(CellBarChart, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: cell.key.startsWith("dr"), isPositiveGood: cell.direction === "pos", measureScale: barLabelMeasureScale(cell), locale: locale, decimalDigits: barLabelDigits(cell, this.componentDataFormatDigits), percentDigits: (_b = (_a = this.barColumnLayouts.get(cell.key)) === null || _a === void 0 ? void 0 : _a.percentDigits) !== null && _b !== void 0 ? _b : this.componentDataFormatDigits.percent, percentSign: (_c = this.barColumnLayouts.get(cell.key)) === null || _c === void 0 ? void 0 : _c.percentSign, columnWidthEm: this.barColumnMaxWidth, labelWidths: (_d = this.barColumnLayouts.get(cell.key)) === null || _d === void 0 ? void 0 : _d.labels, sideMax: (_e = this.barColumnLayouts.get(cell.key)) === null || _e === void 0 ? void 0 : _e.sideMax, styles: this.barChartStyles }))) : (cell.draw(this.componentDataFormatDigits, locale))));
32017
+ (this.showGroupTitle || row.type !== withStyled.TableRowType.HEADER) &&
32018
+ (cell.waterfall !== undefined || row.type !== withStyled.TableRowType.SUM) &&
32019
+ // a variance walk where every step is zero has no extent: the rows print their zero
32020
+ !(cell.direction !== undefined && cell.waterfall && cell.waterfall.max === cell.waterfall.min) ? (cell.waterfall !== undefined ? (index.h(WaterfallBar, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: false, isPositiveGood: cell.direction === "pos", measureScale: barLabelMeasureScale(cell), locale: locale, decimalDigits: barLabelDigits(cell, this.componentDataFormatDigits), columnWidthEm: this.barColumnMaxWidth, styles: this.barChartStyles, waterfall: cell.waterfall, geometry: this.waterfallGeometries.get(cell.key), bold: isBoldRow(row), connectorReach: this.connectorReach(row) })) : (index.h(CellBarChart, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: cell.key.startsWith("dr"), isPositiveGood: cell.direction === "pos", measureScale: barLabelMeasureScale(cell), locale: locale, decimalDigits: barLabelDigits(cell, this.componentDataFormatDigits), percentDigits: (_b = (_a = this.barColumnLayouts.get(cell.key)) === null || _a === void 0 ? void 0 : _a.percentDigits) !== null && _b !== void 0 ? _b : this.componentDataFormatDigits.percent, percentSign: (_c = this.barColumnLayouts.get(cell.key)) === null || _c === void 0 ? void 0 : _c.percentSign, columnWidthEm: this.barColumnMaxWidth, labelWidths: (_d = this.barColumnLayouts.get(cell.key)) === null || _d === void 0 ? void 0 : _d.labels, sideMax: (_e = this.barColumnLayouts.get(cell.key)) === null || _e === void 0 ? void 0 : _e.sideMax, bold: isBoldRow(row), styles: this.barChartStyles }))) : (cell.draw(this.componentDataFormatDigits, locale))));
31539
32021
  })))))));
31540
32022
  };
31541
32023
  return index.h(index.Host, { class: { "no-data": ((_a = this.table) === null || _a === void 0 ? void 0 : _a.hasNoData()) === true } }, helper());
31542
32024
  }
31543
32025
  componentWillRender() {
31544
- var _a, _b, _c, _d, _e, _f, _g, _h;
32026
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
31545
32027
  if (!this.stores)
31546
32028
  this.stores = withHasError.getStores(this.element);
31547
32029
  const db = this.stores.db.db;
@@ -31581,9 +32063,26 @@ const BnTableRenderer = class {
31581
32063
  else {
31582
32064
  (_h = this.errors) === null || _h === void 0 ? void 0 : _h.remove("WARN_orderBucket");
31583
32065
  }
32066
+ const positionWarning = (_j = this.table) === null || _j === void 0 ? void 0 : _j.categoryIntervalPositionWarning();
32067
+ for (const id of ["WARN_categoryIntervalPositionNoInterval", "WARN_categoryIntervalPositionRange"]) {
32068
+ if ((positionWarning === null || positionWarning === void 0 ? void 0 : positionWarning.id) === id) {
32069
+ (_k = this.errors) === null || _k === void 0 ? void 0 : _k.addOrReplace({ id, type: "warning", message: positionWarning.message });
32070
+ }
32071
+ else {
32072
+ (_l = this.errors) === null || _l === void 0 ? void 0 : _l.remove(id);
32073
+ }
32074
+ }
31584
32075
  this.barColumnLayouts = this.collectBarColumnLayouts();
32076
+ this.waterfallGeometries = this.collectWaterfallGeometries();
31585
32077
  this.barChartStyles = this.prepareBarChartStyles();
31586
32078
  }
32079
+ /** The classes of a number cell. A variance that prints as zero loses its sign and its sentiment color. */
32080
+ cellClass(cell, locale) {
32081
+ if (cell.direction === undefined || !cell.roundsToZero(this.componentDataFormatDigits, locale)) {
32082
+ return cell.cssStyle;
32083
+ }
32084
+ return cell.cssStyle.replace(/^(pos|neg)_\w+/, "zero");
32085
+ }
31587
32086
  prepareConfig(db) {
31588
32087
  var _a, _b, _c;
31589
32088
  const fromExpr = withHasError.sourceExpr(db, this.tableName, this.filter);
@@ -31597,7 +32096,10 @@ const BnTableRenderer = class {
31597
32096
  scenariosUnitType: this.scenariosDataFormat,
31598
32097
  grouped: this.grouped,
31599
32098
  showGroupTitle: this.showGroupTitle,
32099
+ runningSum: this.runningSum,
32100
+ varianceWaterfall: this.varianceWaterfall,
31600
32101
  thereOf: this.thereof,
32102
+ thereOfPosition: this.thereofPosition,
31601
32103
  partOf: this.partof,
31602
32104
  categoryThereOf: this.categorythereof,
31603
32105
  attributes: this.attributeColumns,
@@ -31613,6 +32115,7 @@ const BnTableRenderer = class {
31613
32115
  filter: this.filter,
31614
32116
  barColumns: this.barColumns,
31615
32117
  interval: this.interval,
32118
+ categoryIntervalPosition: this.categoryIntervalPosition,
31616
32119
  locale: ((_c = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.locale) || "de",
31617
32120
  });
31618
32121
  return config;
@@ -31759,9 +32262,10 @@ const BnTableRenderer = class {
31759
32262
  const layouts = new Map();
31760
32263
  if (!this.table || this.table.hasNoData())
31761
32264
  return layouts;
32265
+ // a cell with the weight its row prints in
31762
32266
  const cellsByKey = new Map();
31763
32267
  for (const row of this.table.getBody()) {
31764
- if (row.type === TableRowType.SUM)
32268
+ if (row.type === withStyled.TableRowType.SUM)
31765
32269
  continue;
31766
32270
  for (const cell of row.getCells()) {
31767
32271
  // waterfall cells scale independently
@@ -31769,7 +32273,7 @@ const BnTableRenderer = class {
31769
32273
  continue;
31770
32274
  if (typeof cell.value !== "number" || isNaN(cell.value))
31771
32275
  continue;
31772
- cellsByKey.set(cell.key, [...((_a = cellsByKey.get(cell.key)) !== null && _a !== void 0 ? _a : []), cell]);
32276
+ cellsByKey.set(cell.key, [...((_a = cellsByKey.get(cell.key)) !== null && _a !== void 0 ? _a : []), { cell, bold: isBoldRow(row) }]);
31773
32277
  }
31774
32278
  }
31775
32279
  const emPx = this.emPx();
@@ -31779,7 +32283,7 @@ const BnTableRenderer = class {
31779
32283
  const fontFamily = this.labelFontFamily();
31780
32284
  for (const [key, cells] of cellsByKey) {
31781
32285
  const isRelative = key.startsWith("dr");
31782
- const values = cells.map((cell) => cell.value);
32286
+ const values = cells.map(({ cell }) => cell.value);
31783
32287
  const measure = (percentDigits, percentSign) => {
31784
32288
  var _a;
31785
32289
  const labels = {
@@ -31787,11 +32291,11 @@ const BnTableRenderer = class {
31787
32291
  pos: values.some((value) => value > 0) ? 0 : undefined,
31788
32292
  };
31789
32293
  const zeroPositive = zeroOnPositiveSide(labels);
31790
- for (const cell of cells) {
32294
+ for (const { cell, bold } of cells) {
31791
32295
  const value = cell.value;
31792
32296
  const side = value > 0 || (value === 0 && zeroPositive) ? "pos" : "neg";
31793
32297
  const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign, barLabelDigits(cell, this.componentDataFormatDigits));
31794
- labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative));
32298
+ labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative, bold));
31795
32299
  }
31796
32300
  return labels;
31797
32301
  };
@@ -31817,8 +32321,56 @@ const BnTableRenderer = class {
31817
32321
  }
31818
32322
  return layouts;
31819
32323
  }
32324
+ /**
32325
+ * What a variance waterfall connector crosses outside the bar svg: the border of its own
32326
+ * row above, the padding of a sum row below.
32327
+ */
32328
+ connectorReach(row) {
32329
+ const emPx = this.emPx();
32330
+ return { top: 0.1 * emPx, bottom: row.type === withStyled.TableRowType.SUM ? 0.5 * emPx : 0 };
32331
+ }
32332
+ /**
32333
+ * Geometry of every waterfall column from the measured labels of all cells that draw a
32334
+ * bar, sum rows included: each side gets the room its labels need.
32335
+ */
32336
+ collectWaterfallGeometries() {
32337
+ var _a, _b, _c, _d;
32338
+ const geometries = new Map();
32339
+ if (!this.table || this.table.hasNoData())
32340
+ return geometries;
32341
+ const emPx = this.emPx();
32342
+ const fs = emPx * BAR_LABEL_FONT_RATIO;
32343
+ const locale = (_c = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.locale;
32344
+ const fontFamily = this.labelFontFamily();
32345
+ const columns = new Map();
32346
+ for (const row of this.table.getBody()) {
32347
+ for (const cell of row.getCells()) {
32348
+ if (!cell.isBarChart || !cell.columnStats || cell.waterfall === undefined)
32349
+ continue;
32350
+ if (typeof cell.value !== "number" || isNaN(cell.value))
32351
+ continue;
32352
+ const { start, end, min, max, kind } = cell.waterfall;
32353
+ const text = waterfallLabelText(cell.value, kind, barLabelMeasureScale(cell), locale, barLabelDigits(cell, this.componentDataFormatDigits), cell.direction !== undefined);
32354
+ const column = (_d = columns.get(cell.key)) !== null && _d !== void 0 ? _d : { min, max, labels: [] };
32355
+ column.labels.push({
32356
+ end,
32357
+ pointsLeft: end < start,
32358
+ width: labelWidth(text, fs, fontFamily, false, isBoldRow(row)),
32359
+ });
32360
+ columns.set(cell.key, column);
32361
+ }
32362
+ }
32363
+ for (const [key, column] of columns) {
32364
+ geometries.set(key, waterfallGeometry(this.barColumnMaxWidth, emPx, column));
32365
+ }
32366
+ return geometries;
32367
+ }
31820
32368
  get element() { return index.getElement(this); }
31821
32369
  };
32370
+ /** Sum rows and the parent of thereof rows printed above it are bold. */
32371
+ function isBoldRow(row) {
32372
+ return row.type === withStyled.TableRowType.SUM || row.cssStyle === "ofit-sum";
32373
+ }
31822
32374
  /** Percentage points: the fraction times 100, no measure scale. */
31823
32375
  function barLabelMeasureScale(cell) {
31824
32376
  return cell.type === "percentpoint" ? 0.01 : cell.measureScale;