@bino-bi/bn-template-engine 1.0.0-next.45 → 1.0.0-next.46

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 (169) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/{p-8b28c9bd.entry.js → p-16623e0f.entry.js} +1 -1
  3. package/dist/bn-template-engine/p-17970e07.entry.js +1 -0
  4. package/dist/bn-template-engine/{p-48871742.entry.js → p-21930d0a.entry.js} +1 -1
  5. package/dist/bn-template-engine/{p-5a64f90f.entry.js → p-46c46067.entry.js} +1 -1
  6. package/dist/bn-template-engine/p-9caa7f46.entry.js +1 -0
  7. package/dist/bn-template-engine/p-B0MEAsAS.js +1 -0
  8. package/dist/bn-template-engine/{p-qpZjVnX5.js → p-BA-fydUt.js} +1 -1
  9. package/dist/bn-template-engine/p-BEGt_7Hr.js +1 -0
  10. package/dist/bn-template-engine/p-BRO1oW7m.js +1 -0
  11. package/dist/bn-template-engine/{p-DVE0-sOv.js → p-BnzIfgCq.js} +1 -1
  12. package/dist/bn-template-engine/{p-b0dfc113.entry.js → p-b0d528f2.entry.js} +1 -1
  13. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +608 -83
  14. package/dist/cjs/bn-grid.cjs.entry.js +161 -34
  15. package/dist/cjs/bn-image.cjs.entry.js +2 -2
  16. package/dist/cjs/bn-internationalization.cjs.entry.js +2 -2
  17. package/dist/cjs/bn-ruleset.cjs.entry.js +2 -2
  18. package/dist/cjs/bn-template-engine.cjs.js +1 -1
  19. package/dist/cjs/bn-text.cjs.entry.js +3 -3
  20. package/dist/cjs/loader.cjs.js +1 -1
  21. package/dist/cjs/{localFrame-U3Qs0psw.js → localFrame-C27GGom1.js} +1 -1
  22. package/dist/cjs/{withBodyObserver-S-FGHpAX.js → withBodyObserver-B78wzw3f.js} +1 -1
  23. package/dist/cjs/{withHasError-BkBrsCpI.js → withHasError-0hW3-4mr.js} +11 -5
  24. package/dist/cjs/{withStyled-BZb6snOx.js → withStyled-D0hrcfE_.js} +25 -1
  25. package/dist/cjs/{withTranslation-1qTs5Fi7.js → withTranslation-B4WipL_5.js} +2 -2
  26. package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +33 -2
  27. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +112 -16
  28. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +1 -1
  29. package/dist/collection/components/bn-chart-structure/utils/elements/Needle.js +3 -3
  30. package/dist/collection/components/bn-chart-time/bn-chart-time-renderer/bn-chart-time-renderer.js +113 -3
  31. package/dist/collection/components/bn-chart-time/bn-chart-time.js +261 -22
  32. package/dist/collection/components/bn-chart-time/utils/TimeChart.js +221 -12
  33. package/dist/collection/components/bn-chart-time/utils/elements/Axis.js +9 -1
  34. package/dist/collection/components/bn-chart-time/utils/elements/Column.js +10 -4
  35. package/dist/collection/components/bn-chart-time/utils/elements/Needle.js +9 -3
  36. package/dist/collection/components/bn-chart-time/utils/factories/ScenarioFactory.js +2 -2
  37. package/dist/collection/components/bn-chart-time/utils/model/DataPoint.js +9 -6
  38. package/dist/collection/components/bn-chart-time/utils/model/TimeChartComponentConfig.js +15 -0
  39. package/dist/collection/components/bn-grid/bn-grid.js +118 -24
  40. package/dist/collection/components/bn-grid/utils/cellLayout.js +55 -9
  41. package/dist/collection/components/bn-layout-card/bn-layout-card.js +4 -2
  42. package/dist/collection/components/bn-layout-page/bn-layout-page.js +23 -1
  43. package/dist/collection/components/bn-title/bn-title-renderer/bn-title-renderer.css +10 -0
  44. package/dist/collection/components/bn-title/bn-title-renderer/bn-title-renderer.js +23 -1
  45. package/dist/collection/components/bn-title/bn-title.js +40 -2
  46. package/dist/collection/stores/componentStyles.js +9 -3
  47. package/dist/collection/stores/internationalization.js +2 -2
  48. package/dist/collection/utils/DateStringFactory.js +19 -0
  49. package/dist/collection/utils/model/DataFormatDigits.js +4 -2
  50. package/dist/collection/utils/model/VarianceScenario.js +13 -0
  51. package/dist/collection/utils/validate.js +4 -0
  52. package/dist/components/bn-annotation-layer.js +1 -1
  53. package/dist/components/bn-annotation-list.js +1 -1
  54. package/dist/components/bn-asset.js +1 -1
  55. package/dist/components/bn-body.js +1 -1
  56. package/dist/components/bn-card.js +1 -1
  57. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  58. package/dist/components/bn-chart-bubble.js +1 -1
  59. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  60. package/dist/components/bn-chart-bullet.js +1 -1
  61. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  62. package/dist/components/bn-chart-scatter.js +1 -1
  63. package/dist/components/bn-chart-structure-renderer.js +1 -1
  64. package/dist/components/bn-chart-structure.js +1 -1
  65. package/dist/components/bn-chart-time-renderer.js +1 -1
  66. package/dist/components/bn-chart-time.js +1 -1
  67. package/dist/components/bn-component-style.js +1 -1
  68. package/dist/components/bn-context.js +1 -1
  69. package/dist/components/bn-dataset.js +1 -1
  70. package/dist/components/bn-datasource.js +1 -1
  71. package/dist/components/bn-footer.js +1 -1
  72. package/dist/components/bn-grid.js +1 -1
  73. package/dist/components/bn-image.js +1 -1
  74. package/dist/components/bn-internationalization.js +1 -1
  75. package/dist/components/bn-layout-card.js +1 -1
  76. package/dist/components/bn-layout-page.js +1 -1
  77. package/dist/components/bn-message.js +1 -1
  78. package/dist/components/bn-page.js +1 -1
  79. package/dist/components/bn-ruleset.js +1 -1
  80. package/dist/components/bn-scaling-group.js +1 -1
  81. package/dist/components/bn-table-renderer.js +1 -1
  82. package/dist/components/bn-table.js +1 -1
  83. package/dist/components/bn-text.js +1 -1
  84. package/dist/components/bn-title-renderer.js +1 -1
  85. package/dist/components/bn-title.js +1 -1
  86. package/dist/components/bn-tree.js +1 -1
  87. package/dist/components/p-9X5fVJqR.js +1 -0
  88. package/dist/components/p-B5GRtTLX.js +1 -0
  89. package/dist/components/{p-DJUffGeB.js → p-BKA15uoz.js} +1 -1
  90. package/dist/components/p-BKLq0Pbv.js +1 -0
  91. package/dist/components/p-BKTBdrEA.js +1 -0
  92. package/dist/components/p-Bd8cQiLx.js +1 -0
  93. package/dist/components/{p-CvEdUq8i.js → p-Be0Q3bvf.js} +1 -1
  94. package/dist/components/{p-xIWChKGS.js → p-Bj3RWsEx.js} +1 -1
  95. package/dist/components/{p-B4L069XF.js → p-BoBamuPt.js} +1 -1
  96. package/dist/components/{p-DaOm9YwQ.js → p-BrJZUp-K.js} +1 -1
  97. package/dist/components/{p-CyfGkLMh.js → p-BuWNCnvR.js} +1 -1
  98. package/dist/components/{p-M2k_I8lv.js → p-CFVoK5Rb.js} +1 -1
  99. package/dist/components/{p-fKJx8WtW.js → p-CgJB5mCu.js} +1 -1
  100. package/dist/components/p-Cxx0YNnl.js +1 -0
  101. package/dist/components/p-D9F5IBFT.js +1 -0
  102. package/dist/components/{p-BfUdaxZ9.js → p-DQFahsnV.js} +1 -1
  103. package/dist/components/p-DROj8gke.js +1 -0
  104. package/dist/components/p-D_Sbhd0L.js +1 -0
  105. package/dist/components/{p-Cel0a6ma.js → p-DbWh9W5D.js} +1 -1
  106. package/dist/components/{p-2eicD9rF.js → p-DkCeSWKR.js} +1 -1
  107. package/dist/components/{p-7ieJFBUk.js → p-DoOSXntC.js} +1 -1
  108. package/dist/components/p-Dxj_pf8s.js +1 -0
  109. package/dist/components/{p-DQl2K2Xl.js → p-DzYhS_9s.js} +1 -1
  110. package/dist/components/{p-B2bvM2Ig.js → p-EQNS13GN.js} +1 -1
  111. package/dist/components/{p-Y9bth2Y_.js → p-G56USTsQ.js} +1 -1
  112. package/dist/components/p-OgFFKehL.js +1 -0
  113. package/dist/components/{p-C2ycO60j.js → p-kvYRImZT.js} +1 -1
  114. package/dist/components/{p-Chuj-LpI.js → p-rEdNIgD8.js} +1 -1
  115. package/dist/components/{p-DwuXVo2h.js → p-uCpFBDF5.js} +1 -1
  116. package/dist/esm/bn-annotation-layer_30.entry.js +608 -83
  117. package/dist/esm/bn-grid.entry.js +161 -34
  118. package/dist/esm/bn-image.entry.js +2 -2
  119. package/dist/esm/bn-internationalization.entry.js +2 -2
  120. package/dist/esm/bn-ruleset.entry.js +2 -2
  121. package/dist/esm/bn-template-engine.js +1 -1
  122. package/dist/esm/bn-text.entry.js +3 -3
  123. package/dist/esm/loader.js +1 -1
  124. package/dist/esm/{localFrame-BNWPPaQa.js → localFrame-CEZ7-hBs.js} +1 -1
  125. package/dist/esm/{withBodyObserver-AHQAUV85.js → withBodyObserver-D9yIMxdr.js} +1 -1
  126. package/dist/esm/{withHasError-B6Lvj9Cq.js → withHasError-UGtkLrYT.js} +11 -5
  127. package/dist/esm/{withStyled-CzzXg64f.js → withStyled-BlMqEIfr.js} +25 -2
  128. package/dist/esm/{withTranslation-C1gL7wSU.js → withTranslation-Bc3bjHTb.js} +2 -2
  129. package/dist/schemas/theme.schema.json +18 -0
  130. package/dist/types/components/bn-annotation-layer/bn-annotation-layer.d.ts +11 -0
  131. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +16 -0
  132. package/dist/types/components/bn-chart-structure/utils/elements/Needle.d.ts +2 -1
  133. package/dist/types/components/bn-chart-time/bn-chart-time-renderer/bn-chart-time-renderer.d.ts +8 -0
  134. package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +46 -1
  135. package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +37 -0
  136. package/dist/types/components/bn-chart-time/utils/elements/Axis.d.ts +2 -0
  137. package/dist/types/components/bn-chart-time/utils/elements/Needle.d.ts +2 -1
  138. package/dist/types/components/bn-chart-time/utils/factories/ScenarioFactory.d.ts +1 -1
  139. package/dist/types/components/bn-chart-time/utils/model/DataPoint.d.ts +6 -1
  140. package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +6 -0
  141. package/dist/types/components/bn-grid/bn-grid.d.ts +23 -0
  142. package/dist/types/components/bn-grid/utils/cellLayout.d.ts +39 -3
  143. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +3 -1
  144. package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +9 -0
  145. package/dist/types/components/bn-title/bn-title-renderer/bn-title-renderer.d.ts +2 -0
  146. package/dist/types/components/bn-title/bn-title.d.ts +10 -0
  147. package/dist/types/components.d.ts +173 -6
  148. package/dist/types/stores/componentStyles.d.ts +8 -0
  149. package/dist/types/utils/DateStringFactory.d.ts +4 -0
  150. package/dist/types/utils/layoutState/types.d.ts +3 -0
  151. package/dist/types/utils/model/VarianceScenario.d.ts +2 -0
  152. package/dist/types/utils/validate.d.ts +2 -0
  153. package/package.json +1 -1
  154. package/dist/bn-template-engine/p-1b002bd5.entry.js +0 -1
  155. package/dist/bn-template-engine/p-750b2c82.entry.js +0 -1
  156. package/dist/bn-template-engine/p-D0tNATZq.js +0 -1
  157. package/dist/bn-template-engine/p-DF9sfwBN.js +0 -1
  158. package/dist/bn-template-engine/p-EcC0qLtU.js +0 -1
  159. package/dist/components/p-1B_s8oPY.js +0 -1
  160. package/dist/components/p-AwH1w8Mu.js +0 -1
  161. package/dist/components/p-BiSytXUy.js +0 -1
  162. package/dist/components/p-C3gYq-HU.js +0 -1
  163. package/dist/components/p-CEf5X8MZ.js +0 -1
  164. package/dist/components/p-CniN8ALm.js +0 -1
  165. package/dist/components/p-D40Am1Ap.js +0 -1
  166. package/dist/components/p-DDvWTgk1.js +0 -1
  167. package/dist/components/p-DjPWZfry.js +0 -1
  168. package/dist/components/p-DnDL1pPc.js +0 -1
  169. package/dist/components/p-sLbQ7yZ1.js +0 -1
@@ -57,11 +57,11 @@ export class Needle {
57
57
  (_a = this.label) === null || _a === void 0 ? void 0 : _a.updateGroup(newGroup);
58
58
  return this;
59
59
  }
60
- draw() {
60
+ draw(dataFormatDigits = { percent: 2, decimal: 1 }) {
61
61
  var _a, _b, _c;
62
62
  if (((_a = this.dataPoint) === null || _a === void 0 ? void 0 : _a.value) === undefined) {
63
63
  // reference 0: the label says "n/a", there is no pin
64
- (_b = this.label) === null || _b === void 0 ? void 0 : _b.draw();
64
+ (_b = this.label) === null || _b === void 0 ? void 0 : _b.draw(dataFormatDigits);
65
65
  return this;
66
66
  }
67
67
  if (this.isEmpty()) {
@@ -91,7 +91,7 @@ export class Needle {
91
91
  .stroke(strokeStyle)
92
92
  .cy(this.dimensions.yPos)
93
93
  .x(this.dimensions.xPos);
94
- (_c = this.label) === null || _c === void 0 ? void 0 : _c.draw();
94
+ (_c = this.label) === null || _c === void 0 ? void 0 : _c.draw(dataFormatDigits);
95
95
  }
96
96
  createDimensions(position, dataPoint, index) {
97
97
  if (dataPoint.getScaledPercentUnit() < 0) {
@@ -22,6 +22,13 @@ import { SVGStyleGroupAdapter } from "../../../utils/model/styles/SVGStyleGroup"
22
22
  import { SVGVariancesStyleGroupAdapter } from "../../../utils/model/styles/SVGVariancesStyleGroup";
23
23
  /** @internal */
24
24
  export class BnChartTimeRenderer {
25
+ disconnectedCallback() {
26
+ var _a;
27
+ if (this.overlapErrId) {
28
+ (_a = this.errors) === null || _a === void 0 ? void 0 : _a.remove(this.overlapErrId);
29
+ this.overlapErrId = undefined;
30
+ }
31
+ }
25
32
  constructor() {
26
33
  /**
27
34
  * Name of the dataset (table or view in the shared alasql database).
@@ -78,6 +85,12 @@ export class BnChartTimeRenderer {
78
85
  /** @internal */
79
86
  this.dataFormatDigits = { percent: 2, decimal: 1 };
80
87
  /** @internal */
88
+ this.axisLabelsStep = 1;
89
+ /** @internal */
90
+ this.scenarioSwitch = false;
91
+ /** @internal */
92
+ this.axisTitlePosition = "left";
93
+ /** @internal */
81
94
  this.parentDimensions = { width: 0, height: 0 };
82
95
  withComponentStatus(this);
83
96
  }
@@ -99,12 +112,29 @@ export class BnChartTimeRenderer {
99
112
  }
100
113
  /** Reports a failed query as the wrapper's `ERR_sql` item. Without it the chart would only show "No Data". */
101
114
  syncQueryError() {
102
- var _a, _b;
115
+ var _a, _b, _c, _d, _e, _f, _g;
103
116
  this.queryError = (_a = this.measureScaleError) !== null && _a !== void 0 ? _a : (_b = this.chart) === null || _b === void 0 ? void 0 : _b.getQueryError();
104
117
  reportQueryError(this.errors, this.queryError);
118
+ const errId = `WARN_variances_overlap_${this.variances.join("_")}`;
119
+ const overlaps = (_d = (_c = this.chart) === null || _c === void 0 ? void 0 : _c.getVarianceOverlaps()) !== null && _d !== void 0 ? _d : 0;
120
+ // the row can get other variances: the warning of the old list has to go
121
+ if (this.overlapErrId && this.overlapErrId !== errId) {
122
+ (_e = this.errors) === null || _e === void 0 ? void 0 : _e.remove(this.overlapErrId);
123
+ }
124
+ this.overlapErrId = overlaps > 0 ? errId : undefined;
125
+ if (overlaps > 0) {
126
+ (_f = this.errors) === null || _f === void 0 ? void 0 : _f.addOrReplace({
127
+ id: errId,
128
+ type: "warning",
129
+ message: `scenarioSwitch: the variances ${this.variances.join(", ")} share a row, but ${overlaps} period(s) have more than one value. The first variance wins there.`,
130
+ });
131
+ }
132
+ else {
133
+ (_g = this.errors) === null || _g === void 0 ? void 0 : _g.remove(errId);
134
+ }
105
135
  }
106
136
  async componentWillLoad() {
107
- var _a;
137
+ var _a, _b;
108
138
  const config = this.prepareConfig();
109
139
  const styles = this.prepareStyle();
110
140
  const availableWidth = this.containerWidth || 0;
@@ -116,14 +146,18 @@ export class BnChartTimeRenderer {
116
146
  // fitted chart fits by construction, and the overdrive's rough overhead
117
147
  // estimate would falsely re-engage on it.
118
148
  const unitWasAuto = config.pixelPerUnit <= 0;
149
+ const percentWasAuto = config.pixelPerPercentage <= 0;
119
150
  this.autoFitScaling(config, styles);
120
151
  this.chart.setAvailableHeight(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
152
+ if (!percentWasAuto) {
153
+ this.chart.fitRelativeVariances(((_b = this.parentDimensions) === null || _b === void 0 ? void 0 : _b.height) || 0);
154
+ }
121
155
  this.pattern = new CustomPattern(this.chart.styles);
122
156
  this.chart.setPattern("hatched", this.pattern.getFCPolygonPattern());
123
157
  this.syncQueryError();
124
158
  }
125
159
  async componentWillUpdate() {
126
- var _a;
160
+ var _a, _b;
127
161
  if (this.chart == null) {
128
162
  return;
129
163
  }
@@ -136,8 +170,12 @@ export class BnChartTimeRenderer {
136
170
  this.chart.setConfig(config);
137
171
  // See componentWillLoad: no broken-bar overdrive for auto-fitted scaling
138
172
  const unitWasAuto = config.pixelPerUnit <= 0;
173
+ const percentWasAuto = config.pixelPerPercentage <= 0;
139
174
  this.autoFitScaling(config, styles);
140
175
  this.chart.setAvailableHeight(unitWasAuto ? 0 : ((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.height) || 0);
176
+ if (!percentWasAuto) {
177
+ this.chart.fitRelativeVariances(((_b = this.parentDimensions) === null || _b === void 0 ? void 0 : _b.height) || 0);
178
+ }
141
179
  this.pattern = new CustomPattern(this.chart.styles);
142
180
  this.chart.setPattern("hatched", this.pattern.getFCPolygonPattern());
143
181
  this.syncQueryError();
@@ -323,6 +361,9 @@ export class BnChartTimeRenderer {
323
361
  maxBars: this.maxBars,
324
362
  stackConfig: this.stackConfig,
325
363
  lineFullWidth: this.lineFullWidth,
364
+ axisLabelsStep: this.axisLabelsStep,
365
+ scenarioSwitch: this.scenarioSwitch,
366
+ axisTitlePosition: this.axisTitlePosition,
326
367
  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",
327
368
  });
328
369
  }
@@ -1031,6 +1072,75 @@ export class BnChartTimeRenderer {
1031
1072
  "setter": false,
1032
1073
  "defaultValue": "{ percent: 2, decimal: 1 }"
1033
1074
  },
1075
+ "axisLabelsStep": {
1076
+ "type": "number",
1077
+ "mutable": false,
1078
+ "complexType": {
1079
+ "original": "number",
1080
+ "resolved": "number",
1081
+ "references": {}
1082
+ },
1083
+ "required": false,
1084
+ "optional": false,
1085
+ "docs": {
1086
+ "tags": [{
1087
+ "name": "internal",
1088
+ "text": undefined
1089
+ }],
1090
+ "text": ""
1091
+ },
1092
+ "getter": false,
1093
+ "setter": false,
1094
+ "reflect": false,
1095
+ "attribute": "axis-labels-step",
1096
+ "defaultValue": "1"
1097
+ },
1098
+ "scenarioSwitch": {
1099
+ "type": "boolean",
1100
+ "mutable": false,
1101
+ "complexType": {
1102
+ "original": "boolean",
1103
+ "resolved": "boolean",
1104
+ "references": {}
1105
+ },
1106
+ "required": false,
1107
+ "optional": false,
1108
+ "docs": {
1109
+ "tags": [{
1110
+ "name": "internal",
1111
+ "text": undefined
1112
+ }],
1113
+ "text": ""
1114
+ },
1115
+ "getter": false,
1116
+ "setter": false,
1117
+ "reflect": false,
1118
+ "attribute": "scenario-switch",
1119
+ "defaultValue": "false"
1120
+ },
1121
+ "axisTitlePosition": {
1122
+ "type": "string",
1123
+ "mutable": false,
1124
+ "complexType": {
1125
+ "original": "string",
1126
+ "resolved": "string",
1127
+ "references": {}
1128
+ },
1129
+ "required": false,
1130
+ "optional": false,
1131
+ "docs": {
1132
+ "tags": [{
1133
+ "name": "internal",
1134
+ "text": undefined
1135
+ }],
1136
+ "text": ""
1137
+ },
1138
+ "getter": false,
1139
+ "setter": false,
1140
+ "reflect": false,
1141
+ "attribute": "axis-title-position",
1142
+ "defaultValue": "\"left\""
1143
+ },
1034
1144
  "parentDimensions": {
1035
1145
  "type": "unknown",
1036
1146
  "mutable": false,
@@ -1,6 +1,6 @@
1
1
  import { forceUpdate, h, Host, writeTask } from "@stencil/core";
2
2
  import { hasInlineJs } from "../../context/scopedDb";
3
- import { isBlankInput, isValidAxisLabelsMode, isValidDateFormat, isValidInteger, isValidMeasureScale, isValidNumber, validateScenarioList, validateStackConfig, validateVariancesList, } from "../../utils/validate";
3
+ import { isBlankInput, isValidAxisLabelsMode, isValidDateFormat, isValidInteger, isValidMeasureScale, isNoScenarios, isValidNumber, validateScenarioList, validateStackConfig, validateVariancesList, } from "../../utils/validate";
4
4
  import withDataset from "../../utils/withDataset";
5
5
  import withComponentStatus from "../../utils/withComponentStatus";
6
6
  import withTranslation from "../../utils/withTranslation";
@@ -15,7 +15,7 @@ import withInheritedProps, { isInheritedValue } from "../../utils/withInheritedP
15
15
  import { getParentDimensions } from "../../utils/parentDimensions";
16
16
  import { formatScalingValue, parseScaling, resolveScalingValue } from "../../utils/scaling";
17
17
  import { observeParentResize } from "../../utils/layoutObserver";
18
- import { VarianceScenario } from "../../utils/model/VarianceScenario";
18
+ import { VarianceScenario, variancesScenarios } from "../../utils/model/VarianceScenario";
19
19
  import { Formatter } from "../../utils/formatter";
20
20
  import { AxisLabelsMode, ChartMode, StackBy, StackMode, StackOrder } from "../../utils/constants";
21
21
  import { DateDistance } from "../../utils/DateStringFactory";
@@ -47,7 +47,7 @@ export class Chart {
47
47
  }
48
48
  validateScenario(newValue) {
49
49
  const errId = "WARN_scenarios";
50
- if (isInheritedValue(newValue)) {
50
+ if (isInheritedValue(newValue) || isNoScenarios(newValue)) {
51
51
  this.errors.remove(errId);
52
52
  return;
53
53
  }
@@ -235,6 +235,51 @@ export class Chart {
235
235
  this.errors.remove(errId);
236
236
  }
237
237
  }
238
+ validateDataFormatDigitsDecimal(newValue) {
239
+ this.validateDigits("dataFormatDigitsDecimal", newValue);
240
+ }
241
+ validateDataFormatDigitsPercent(newValue) {
242
+ this.validateDigits("dataFormatDigitsPercent", newValue);
243
+ }
244
+ validateDigits(name, value) {
245
+ const errId = `WARN_${name}`;
246
+ if (!isValidInteger(value) || Number(value) < 0 || Number(value) > 100) {
247
+ this.errors.addOrReplace({
248
+ id: errId,
249
+ type: "warning",
250
+ message: name + ": invalid value '" + value + "' is not supported.",
251
+ });
252
+ }
253
+ else {
254
+ this.errors.remove(errId);
255
+ }
256
+ }
257
+ validateAxisLabelsStep(newValue) {
258
+ const errId = "WARN_axisLabelsStep";
259
+ if (!isValidInteger(newValue) || Number(newValue) < 1) {
260
+ this.errors.addOrReplace({
261
+ id: errId,
262
+ type: "warning",
263
+ message: "axisLabelsStep: invalid value '" + newValue + "' is not supported.",
264
+ });
265
+ }
266
+ else {
267
+ this.errors.remove(errId);
268
+ }
269
+ }
270
+ validateAxisTitlePosition(newValue) {
271
+ const errId = "WARN_axisTitlePosition";
272
+ if (!isBlankInput(newValue) && !["left", "right", "none"].includes(newValue.trim().toLowerCase())) {
273
+ this.errors.addOrReplace({
274
+ id: errId,
275
+ type: "warning",
276
+ message: "axisTitlePosition: invalid value '" + newValue + "' is not supported.",
277
+ });
278
+ }
279
+ else {
280
+ this.errors.remove(errId);
281
+ }
282
+ }
238
283
  constructor() {
239
284
  /** Active dataset name (the last subscribed dataset to fire `onUpdate`). */
240
285
  this.datasetName = "";
@@ -372,6 +417,35 @@ export class Chart {
372
417
  * measureUnit displayed in table.
373
418
  */
374
419
  this.measureUnit = "";
420
+ /**
421
+ * Number of decimal digits of the value labels
422
+ */
423
+ this.dataFormatDigitsDecimal = 1;
424
+ /**
425
+ * Number of decimal digits of the percent labels (relative variances)
426
+ */
427
+ this.dataFormatDigitsPercent = 2;
428
+ /**
429
+ * Prints only every n-th category label, starting with the first period.
430
+ * 2 labels every second period. Bar mode only.
431
+ */
432
+ this.axisLabelsStep = 1;
433
+ /**
434
+ * For a series that changes its scenario along the time axis, for example
435
+ * AC up to this year and PL after it. In a period where the first scenario
436
+ * has no value, the next scenario with a value is drawn in its place with
437
+ * its value label. A vertical line marks the change, and the scenario names
438
+ * stand under the axis. Variances with the same reference and type share
439
+ * one row. Bar mode without stack only.
440
+ */
441
+ this.scenarioSwitch = false;
442
+ /**
443
+ * Where the axis title stands (the chart title, or the name of a variance).
444
+ * <br /><br />
445
+ * values:<br />
446
+ * ```left // right // none```
447
+ */
448
+ this.axisTitlePosition = "left";
375
449
  this.pixelPerUnitGroupMap = new Map();
376
450
  this._autoScaleGuard = false;
377
451
  this._lastObservedWidth = 0;
@@ -450,6 +524,10 @@ export class Chart {
450
524
  this.validateMaxBars(this.maxBars);
451
525
  this.validateStack(this.stack);
452
526
  this.validateScaling(this.scale);
527
+ this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal);
528
+ this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent);
529
+ this.validateAxisLabelsStep(this.axisLabelsStep);
530
+ this.validateAxisTitlePosition(this.axisTitlePosition);
453
531
  }
454
532
  /**
455
533
  * Content width from the rendered SVG width attributes (segments stack
@@ -663,14 +741,14 @@ export class Chart {
663
741
  prepareDimension() {
664
742
  const parent = getParentDimensions(this.element);
665
743
  const scenariosList = this.prepareScenarios();
666
- const variancesList = this.prepareVariances();
667
- this.canvasWidthSegmented = parent.width / (scenariosList.length + variancesList.length || 1);
744
+ const segments = this.prepareSegments();
745
+ this.canvasWidthSegmented = parent.width / (scenariosList.length + this.prepareVariances().length || 1);
668
746
  this._lastAppliedHeight = parent.height;
669
747
  // The base chart and each variance render as vertically stacked segments
670
748
  // (see render()), so each one may only claim its share of the height.
671
749
  // The measure-scale footer (first segment only) renders below its SVG:
672
750
  // reserve roughly one em for it so the fitted charts leave it room.
673
- const segmentCount = 1 + variancesList.length;
751
+ const segmentCount = Math.max(1, segments.length);
674
752
  const footerAllowance = this.showMeasureScale ? this.getEffectiveFontPx() : 0;
675
753
  return { width: this.canvasWidthSegmented, height: Math.max(0, parent.height - footerAllowance) / segmentCount };
676
754
  }
@@ -681,6 +759,10 @@ export class Chart {
681
759
  this.errors.remove("AUTO_scenarios");
682
760
  return scenarios.value.split(",").map((entry) => entry.trim());
683
761
  }
762
+ if (isNoScenarios(scenarios.value)) {
763
+ this.errors.remove("AUTO_scenarios");
764
+ return [];
765
+ }
684
766
  const isAuto = ((_a = scenarios.value) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
685
767
  if (isBlankInput(scenarios.value) || isAuto) {
686
768
  if (((_c = (_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.availableScenarios) === null || _c === void 0 ? void 0 : _c.length) > 0) {
@@ -702,6 +784,40 @@ export class Chart {
702
784
  this.errors.remove("AUTO_scenarios");
703
785
  return (_d = scenarios.value) === null || _d === void 0 ? void 0 : _d.split(",").map((entry) => entry.trim());
704
786
  }
787
+ /** `scenarios="none"`: the chart draws its variances only. */
788
+ hidesScenarios() {
789
+ const scenarios = this.resolveInherited("scenarios", this.scenarios);
790
+ return !scenarios.inherited && isNoScenarios(scenarios.value);
791
+ }
792
+ /**
793
+ * The stacked segments, bottom to top: `[]` is the base chart, else the
794
+ * variances of one row. With `scenarioSwitch`, variances of one type over
795
+ * the same reference share a row.
796
+ */
797
+ prepareSegments() {
798
+ const rows = this.hidesScenarios() ? [] : [[]];
799
+ const rowByKey = new Map();
800
+ for (const variance of this.prepareVariances()) {
801
+ const parsed = new VarianceScenario(variance);
802
+ const key = `${parsed.type}:${parsed.delta}`;
803
+ const row = this.scenarioSwitch && parsed.isValid ? rowByKey.get(key) : undefined;
804
+ if (row) {
805
+ row.push(variance);
806
+ continue;
807
+ }
808
+ const created = [variance];
809
+ rows.push(created);
810
+ if (parsed.isValid) {
811
+ rowByKey.set(key, created);
812
+ }
813
+ }
814
+ return rows;
815
+ }
816
+ prepareAxisTitlePosition() {
817
+ var _a;
818
+ const position = (_a = this.axisTitlePosition) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase();
819
+ return position === "right" || position === "none" ? position : "left";
820
+ }
705
821
  prepareAvg() {
706
822
  return this.showOverlayAvg;
707
823
  }
@@ -732,7 +848,7 @@ export class Chart {
732
848
  }
733
849
  }
734
850
  }
735
- if (scenarios.length > 0 && missing.length > 0) {
851
+ if (!this.hidesScenarios() && scenarios.length > 0 && missing.length > 0) {
736
852
  this.errors.addOrReplace({
737
853
  id: errId,
738
854
  type: "warning",
@@ -747,7 +863,7 @@ export class Chart {
747
863
  return idx >= 1 || !this.showCategories;
748
864
  }
749
865
  prepareI18n() {
750
- const i18nMetaLabelsLocal = ["no-data"];
866
+ const i18nMetaLabelsLocal = ["no-data", "date-format-short-year"];
751
867
  const i18nMetaLabelsGlobal = globalLabelKeys;
752
868
  const i18nMapLocal = new Map(i18nMetaLabelsLocal.map((key) => [key, this.t(".".concat(key))]));
753
869
  const i18nMapGlobal = new Map(i18nMetaLabelsGlobal.map((key) => [key, this.t("global.".concat(key))]));
@@ -857,14 +973,17 @@ export class Chart {
857
973
  if (this.syncSpaceLeft > -1) {
858
974
  return this.syncSpaceLeft;
859
975
  }
860
- const leftSideOffset = Formatter.getMaxWidthOfArrayItems([...this.prepareVariances(), ...this.prepareScenarios(), this.chartTitle], preparedI18n, preparedStyle);
976
+ // without a title on the left only the scenario names stand there
977
+ const titles = this.prepareAxisTitlePosition() === "left" ? [...this.prepareVariances(), this.chartTitle] : [];
978
+ const leftSideOffset = Formatter.getMaxWidthOfArrayItems([...titles, ...this.prepareScenarios()], preparedI18n, preparedStyle);
861
979
  //if(leftSideOffset < this.syncSpaceLeft) {
862
980
  // return this.syncSpaceLeft;
863
981
  //}
864
982
  return leftSideOffset;
865
983
  }
866
984
  prepareChartTitle(idx) {
867
- if (idx >= 1) {
985
+ // a variance keeps its own name as title
986
+ if (idx >= 1 || this.hidesScenarios()) {
868
987
  return "";
869
988
  }
870
989
  return this.chartTitle;
@@ -1016,16 +1135,18 @@ export class Chart {
1016
1135
  prepareMaxBars() {
1017
1136
  return Math.floor(Number(this.maxBars) || 28);
1018
1137
  }
1019
- chartTemplate(localScenarioString, idx) {
1138
+ chartTemplate(segmentVariances, idx) {
1020
1139
  const preparedI18n = this.prepareI18n();
1021
1140
  const preparedStyle = this.prepareStyle();
1022
1141
  const fullParentWidth = getParentDimensions(this.element).width;
1023
1142
  const ppu = this.preparePixelPerUnit();
1024
1143
  const ppp = this.preparePixelPerPercentage();
1025
1144
  const stackConfig = this.prepareStackConfig();
1026
- const scenarios = this.prepareScenarios();
1027
- const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
1028
- return (h("bn-chart-time-renderer", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideAxisLabels: this.prepareHideAxisLabels(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, leftSideOffsetForHorizontalSync: this.prepareLeftSideOffset(preparedI18n, preparedStyle), styles: preparedStyle, i18n: preparedI18n, dateInterval: this.prepareDateInterval(), intervalSpanLimit: this.prepareIntervalSpanLimit(), axisLabelsMode: this.prepareAxisLabelsMode(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showOverlayAvg: this.prepareAvg(), showOverlayMedian: this.prepareMedian(), showMeasureScale: this.prepareShowMeasureScale(idx), chartMode: this.prepareChartMode(), maxBars: this.prepareMaxBars(), stackConfig: stackConfig, lineFullWidth: this.prepareLineFullWidth(), containerWidth: fullParentWidth, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
1145
+ const isBase = segmentVariances.length === 0;
1146
+ const scenarios = this.hidesScenarios() ? variancesScenarios(segmentVariances) : this.prepareScenarios();
1147
+ // only the base chart draws a stack, a variance needs both of its scenarios
1148
+ const effectiveScenarios = isBase && (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
1149
+ return (h("bn-chart-time-renderer", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: segmentVariances.length > 0 ? segmentVariances : [""], hideAxisLabels: this.prepareHideAxisLabels(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, leftSideOffsetForHorizontalSync: this.prepareLeftSideOffset(preparedI18n, preparedStyle), styles: preparedStyle, i18n: preparedI18n, dateInterval: this.prepareDateInterval(), intervalSpanLimit: this.prepareIntervalSpanLimit(), axisLabelsMode: this.prepareAxisLabelsMode(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showOverlayAvg: this.prepareAvg(), showOverlayMedian: this.prepareMedian(), showMeasureScale: this.prepareShowMeasureScale(idx), chartMode: this.prepareChartMode(), maxBars: this.prepareMaxBars(), stackConfig: stackConfig, lineFullWidth: this.prepareLineFullWidth(), dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, axisLabelsStep: Math.max(1, Math.floor(Number(this.axisLabelsStep) || 1)), scenarioSwitch: this.scenarioSwitch, axisTitlePosition: this.prepareAxisTitlePosition(), containerWidth: fullParentWidth, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
1029
1150
  }
1030
1151
  /**
1031
1152
  * The line this chart wants to be aligned on, in CSS px from the host's
@@ -1052,7 +1173,7 @@ export class Chart {
1052
1173
  const factor = Number.isFinite(rawFactor) && rawFactor > 0 ? rawFactor : 1;
1053
1174
  const fontSizePx = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; }) * factor;
1054
1175
  const variances = this.prepareVariances();
1055
- const layout = collectChartFacadeLayout(this.element, "bn-chart-time-renderer", ["base", ...variances], origins, detail);
1176
+ const layout = collectChartFacadeLayout(this.element, "bn-chart-time-renderer", this.prepareSegments().map((segment) => (segment.length > 0 ? segment.join(",") : "base")), origins, detail);
1056
1177
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1057
1178
  const firstInner = (_b = this.element.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("bn-chart-time-renderer");
1058
1179
  const state = {
@@ -1144,14 +1265,20 @@ export class Chart {
1144
1265
  });
1145
1266
  }
1146
1267
  render() {
1147
- let scenariosArray = [""];
1148
- const variancesArray = this.prepareVariances();
1149
- this.checkVarianceScenarios(variancesArray);
1150
- if (variancesArray.length > 0) {
1151
- scenariosArray = [...scenariosArray, ...variancesArray];
1268
+ this.checkVarianceScenarios(this.prepareVariances());
1269
+ const segments = this.prepareSegments();
1270
+ if (segments.length === 0) {
1271
+ this.errors.addOrReplace({
1272
+ id: "WARN_scenarios_none",
1273
+ type: "warning",
1274
+ message: "scenarios: none needs at least one variance, the chart is empty.",
1275
+ });
1276
+ }
1277
+ else {
1278
+ this.errors.remove("WARN_scenarios_none");
1152
1279
  }
1153
1280
  const fontStyles = this.getFontStyles();
1154
- return (h(Host, { key: '37085b275bb92d716a31f79f15b9f2517f1c596b', style: fontStyles }, h("div", { key: '93e9eacc22334da1deed871db640d6fd4aafb153', class: "container" }, scenariosArray.map(this.chartTemplate))));
1281
+ return (h(Host, { key: '530c7c27c23afc339ca03506f2cb608774e8a7ed', style: fontStyles }, h("div", { key: '99bbe8fa9d17ef14bbb6a3b5e2dce21025cdc40c', class: "container" }, segments.map(this.chartTemplate))));
1155
1282
  }
1156
1283
  static get is() { return "bn-chart-time"; }
1157
1284
  static get encapsulation() { return "shadow"; }
@@ -1295,7 +1422,7 @@ export class Chart {
1295
1422
  "optional": false,
1296
1423
  "docs": {
1297
1424
  "tags": [],
1298
- "text": "List of Scenarios Map.\n<br /> <br />\nper chart there are up to 4 different scenarios supported.\nThe first 4 scenarios in the list are used, the rest ignored.\n\n<br /> <br />\n values:<br /> ```ac // fc // pp // pl [1-4] // auto```\n example:<br /> ```ac1,ac2,ac3,ac4```\n<br /> <br />\n When set to ```auto```, scenarios are detected from the dataset silently.\n When left blank, scenarios are detected from the dataset with a warning."
1425
+ "text": "List of Scenarios Map.\n<br /> <br />\nper chart there are up to 4 different scenarios supported.\nThe first 4 scenarios in the list are used, the rest ignored.\n\n<br /> <br />\n values:<br /> ```ac // fc // pp // pl [1-4] // auto```\n example:<br /> ```ac1,ac2,ac3,ac4```\n<br /> <br />\n When set to ```auto```, scenarios are detected from the dataset silently.\n When left blank, scenarios are detected from the dataset with a warning.\n When set to ```none```, no scenario is drawn: the chart shows only its variances,\n and the lowest variance carries the category labels."
1299
1426
  },
1300
1427
  "getter": false,
1301
1428
  "setter": false,
@@ -1679,6 +1806,106 @@ export class Chart {
1679
1806
  "reflect": false,
1680
1807
  "attribute": "measure-unit",
1681
1808
  "defaultValue": "\"\""
1809
+ },
1810
+ "dataFormatDigitsDecimal": {
1811
+ "type": "number",
1812
+ "mutable": false,
1813
+ "complexType": {
1814
+ "original": "number",
1815
+ "resolved": "number",
1816
+ "references": {}
1817
+ },
1818
+ "required": false,
1819
+ "optional": false,
1820
+ "docs": {
1821
+ "tags": [],
1822
+ "text": "Number of decimal digits of the value labels"
1823
+ },
1824
+ "getter": false,
1825
+ "setter": false,
1826
+ "reflect": false,
1827
+ "attribute": "data-format-digits-decimal",
1828
+ "defaultValue": "1"
1829
+ },
1830
+ "dataFormatDigitsPercent": {
1831
+ "type": "number",
1832
+ "mutable": false,
1833
+ "complexType": {
1834
+ "original": "number",
1835
+ "resolved": "number",
1836
+ "references": {}
1837
+ },
1838
+ "required": false,
1839
+ "optional": false,
1840
+ "docs": {
1841
+ "tags": [],
1842
+ "text": "Number of decimal digits of the percent labels (relative variances)"
1843
+ },
1844
+ "getter": false,
1845
+ "setter": false,
1846
+ "reflect": false,
1847
+ "attribute": "data-format-digits-percent",
1848
+ "defaultValue": "2"
1849
+ },
1850
+ "axisLabelsStep": {
1851
+ "type": "number",
1852
+ "mutable": false,
1853
+ "complexType": {
1854
+ "original": "number",
1855
+ "resolved": "number",
1856
+ "references": {}
1857
+ },
1858
+ "required": false,
1859
+ "optional": false,
1860
+ "docs": {
1861
+ "tags": [],
1862
+ "text": "Prints only every n-th category label, starting with the first period.\n2 labels every second period. Bar mode only."
1863
+ },
1864
+ "getter": false,
1865
+ "setter": false,
1866
+ "reflect": false,
1867
+ "attribute": "axis-labels-step",
1868
+ "defaultValue": "1"
1869
+ },
1870
+ "scenarioSwitch": {
1871
+ "type": "boolean",
1872
+ "mutable": false,
1873
+ "complexType": {
1874
+ "original": "boolean",
1875
+ "resolved": "boolean",
1876
+ "references": {}
1877
+ },
1878
+ "required": false,
1879
+ "optional": false,
1880
+ "docs": {
1881
+ "tags": [],
1882
+ "text": "For a series that changes its scenario along the time axis, for example\nAC up to this year and PL after it. In a period where the first scenario\nhas no value, the next scenario with a value is drawn in its place with\nits value label. A vertical line marks the change, and the scenario names\nstand under the axis. Variances with the same reference and type share\none row. Bar mode without stack only."
1883
+ },
1884
+ "getter": false,
1885
+ "setter": false,
1886
+ "reflect": false,
1887
+ "attribute": "scenario-switch",
1888
+ "defaultValue": "false"
1889
+ },
1890
+ "axisTitlePosition": {
1891
+ "type": "string",
1892
+ "mutable": false,
1893
+ "complexType": {
1894
+ "original": "string",
1895
+ "resolved": "string",
1896
+ "references": {}
1897
+ },
1898
+ "required": false,
1899
+ "optional": false,
1900
+ "docs": {
1901
+ "tags": [],
1902
+ "text": "Where the axis title stands (the chart title, or the name of a variance).\n<br /><br />\nvalues:<br />\n```left // right // none```"
1903
+ },
1904
+ "getter": false,
1905
+ "setter": false,
1906
+ "reflect": false,
1907
+ "attribute": "axis-title-position",
1908
+ "defaultValue": "\"left\""
1682
1909
  }
1683
1910
  };
1684
1911
  }
@@ -1794,6 +2021,18 @@ export class Chart {
1794
2021
  }, {
1795
2022
  "propName": "measureScale",
1796
2023
  "methodName": "validateMeasureScale"
2024
+ }, {
2025
+ "propName": "dataFormatDigitsDecimal",
2026
+ "methodName": "validateDataFormatDigitsDecimal"
2027
+ }, {
2028
+ "propName": "dataFormatDigitsPercent",
2029
+ "methodName": "validateDataFormatDigitsPercent"
2030
+ }, {
2031
+ "propName": "axisLabelsStep",
2032
+ "methodName": "validateAxisLabelsStep"
2033
+ }, {
2034
+ "propName": "axisTitlePosition",
2035
+ "methodName": "validateAxisTitlePosition"
1797
2036
  }];
1798
2037
  }
1799
2038
  }