@bino-bi/bn-template-engine 1.0.0-next.49 → 1.0.0-next.51

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 (107) hide show
  1. package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
  2. package/dist/bn-template-engine/p-0cad5598.entry.js +1 -0
  3. package/dist/bn-template-engine/{p-2de524d0.entry.js → p-150bdb68.entry.js} +1 -1
  4. package/dist/bn-template-engine/{p-Bxa4pX1M.js → p-Bvunba5p.js} +1 -1
  5. package/dist/bn-template-engine/p-NxJ6P79y.js +1 -0
  6. package/dist/bn-template-engine/{p-8fc90dc8.entry.js → p-b75a4b52.entry.js} +1 -1
  7. package/dist/bn-template-engine/{p-510d2ee6.entry.js → p-fdf42a77.entry.js} +1 -1
  8. package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +1045 -63
  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-pkdctrK9.js → withStyled-BISQLGLe.js} +9 -0
  15. package/dist/cjs/{withTranslation-BIzTNYZM.js → withTranslation-B7T30EVU.js} +1 -1
  16. package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +109 -11
  17. package/dist/collection/components/bn-annotation-layer/utils/marks.js +126 -4
  18. package/dist/collection/components/bn-annotation-layer/utils/matchPoint.js +2 -1
  19. package/dist/collection/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.js +133 -0
  20. package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +258 -2
  21. package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +507 -27
  22. package/dist/collection/components/bn-chart-structure/utils/elements/Bar.js +3 -1
  23. package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +12 -0
  24. package/dist/collection/components/bn-chart-structure/utils/elements/StackedBar.js +23 -8
  25. package/dist/collection/components/bn-chart-structure/utils/helper/ElementPositions.js +19 -3
  26. package/dist/collection/components/bn-chart-structure/utils/model/StructureChartComponentConfig.js +23 -0
  27. package/dist/collection/components/bn-context/bn-context.js +56 -1
  28. package/dist/collection/components/bn-layout-card/bn-layout-card.js +62 -2
  29. package/dist/collection/utils/formatter.js +13 -2
  30. package/dist/collection/utils/validate.js +9 -0
  31. package/dist/components/bn-annotation-layer.js +1 -1
  32. package/dist/components/bn-chart-bubble-renderer.js +1 -1
  33. package/dist/components/bn-chart-bubble.js +1 -1
  34. package/dist/components/bn-chart-bullet-renderer.js +1 -1
  35. package/dist/components/bn-chart-bullet.js +1 -1
  36. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  37. package/dist/components/bn-chart-scatter.js +1 -1
  38. package/dist/components/bn-chart-structure-renderer.js +1 -1
  39. package/dist/components/bn-chart-structure.js +1 -1
  40. package/dist/components/bn-chart-time-renderer.js +1 -1
  41. package/dist/components/bn-chart-time.js +1 -1
  42. package/dist/components/bn-context.js +1 -1
  43. package/dist/components/bn-grid.js +1 -1
  44. package/dist/components/bn-image.js +1 -1
  45. package/dist/components/bn-layout-card.js +1 -1
  46. package/dist/components/bn-layout-page.js +1 -1
  47. package/dist/components/bn-page.js +1 -1
  48. package/dist/components/bn-table-renderer.js +1 -1
  49. package/dist/components/bn-table.js +1 -1
  50. package/dist/components/bn-text.js +1 -1
  51. package/dist/components/bn-title-renderer.js +1 -1
  52. package/dist/components/bn-title.js +1 -1
  53. package/dist/components/bn-tree.js +1 -1
  54. package/dist/components/p-BOwmXBm-.js +1 -0
  55. package/dist/components/p-Bs5V6Ibu.js +1 -0
  56. package/dist/components/{p-CVfmhtEW.js → p-CU9CdEBF.js} +1 -1
  57. package/dist/components/{p-Cc0gaLwp.js → p-CZSp0rSS.js} +1 -1
  58. package/dist/components/p-CcfvGlBq.js +1 -0
  59. package/dist/components/p-CiljAoC5.js +1 -0
  60. package/dist/components/p-D0v9GMIf.js +1 -0
  61. package/dist/components/{p-DBj1Yd3M.js → p-D65TnLS9.js} +1 -1
  62. package/dist/components/p-DKcw-1ot.js +1 -0
  63. package/dist/components/{p-k7heRDPP.js → p-DLmQ_mi7.js} +1 -1
  64. package/dist/components/p-DOKqRsAu.js +1 -0
  65. package/dist/components/p-Dpc8_R-Y.js +1 -0
  66. package/dist/components/p-LHIKI9Dp.js +1 -0
  67. package/dist/components/{p-Blre9f28.js → p-NdDdfez6.js} +1 -1
  68. package/dist/components/p-Zz3fAPcH.js +1 -0
  69. package/dist/components/{p-y12CmIFS.js → p-dSUX43yf.js} +1 -1
  70. package/dist/components/p-jEqo8YD5.js +1 -0
  71. package/dist/esm/bn-annotation-layer_30.entry.js +1045 -63
  72. package/dist/esm/bn-grid.entry.js +1 -1
  73. package/dist/esm/bn-image.entry.js +1 -1
  74. package/dist/esm/bn-template-engine.js +1 -1
  75. package/dist/esm/bn-text.entry.js +2 -2
  76. package/dist/esm/loader.js +1 -1
  77. package/dist/esm/{withStyled-B62R20Zx.js → withStyled-CrTxIZ0Q.js} +9 -0
  78. package/dist/esm/{withTranslation-BEseMLQ6.js → withTranslation-BtSJmx1J.js} +1 -1
  79. package/dist/schemas/stack.schema.json +42 -0
  80. package/dist/types/components/bn-annotation-layer/utils/marks.d.ts +53 -0
  81. package/dist/types/components/bn-annotation-layer/utils/matchPoint.d.ts +2 -0
  82. package/dist/types/components/bn-chart-structure/bn-chart-structure-renderer/bn-chart-structure-renderer.d.ts +11 -1
  83. package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +49 -0
  84. package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +45 -0
  85. package/dist/types/components/bn-chart-structure/utils/elements/Label.d.ts +4 -0
  86. package/dist/types/components/bn-chart-structure/utils/elements/StackedBar.d.ts +13 -1
  87. package/dist/types/components/bn-chart-structure/utils/helper/ElementPositions.d.ts +13 -1
  88. package/dist/types/components/bn-chart-structure/utils/model/StructureChartComponentConfig.d.ts +23 -0
  89. package/dist/types/components/bn-context/bn-context.d.ts +11 -0
  90. package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +12 -0
  91. package/dist/types/components.d.ts +113 -2
  92. package/dist/types/schemas.d.ts +12 -0
  93. package/dist/types/utils/annotations.d.ts +1 -1
  94. package/dist/types/utils/formatter.d.ts +5 -0
  95. package/package.json +1 -1
  96. package/dist/bn-template-engine/p-BFl7OwcC.js +0 -1
  97. package/dist/bn-template-engine/p-c1d679af.entry.js +0 -1
  98. package/dist/components/p-B11cXOLy.js +0 -1
  99. package/dist/components/p-BVNOmHh4.js +0 -1
  100. package/dist/components/p-CHhxQoF9.js +0 -1
  101. package/dist/components/p-CO6bgquz.js +0 -1
  102. package/dist/components/p-CmvpJzLd.js +0 -1
  103. package/dist/components/p-CuUfiEu0.js +0 -1
  104. package/dist/components/p-DHloMyxV.js +0 -1
  105. package/dist/components/p-Dd1QOWDV.js +0 -1
  106. package/dist/components/p-HVN8BNWN.js +0 -1
  107. package/dist/components/p-x0W2_FAX.js +0 -1
@@ -171,9 +171,12 @@ export function buildMark(item, box, toBox, em, options = {}) {
171
171
  }
172
172
  if (item.mark === "frame") {
173
173
  // a text of its own stands in the upper part of the target, above a value label in its middle
174
- const caption = item.text != null && !whole
175
- ? { x: box.x + box.width / 2, y: box.y + Math.min(box.height / 2, Math.max(0.9 * em, 0.3 * box.height)) }
176
- : undefined;
174
+ const caption = item.text == null || whole
175
+ ? undefined
176
+ : options.label
177
+ ? // right of a value label, so both can be read
178
+ { x: box.x + box.width + 0.7 * em + textWidth(item.text, em) / 2, y: box.y + box.height / 2 }
179
+ : { x: box.x + box.width / 2, y: box.y + Math.min(box.height / 2, Math.max(0.9 * em, 0.3 * box.height)) };
177
180
  const captionBox = caption && {
178
181
  x: caption.x - textWidth(item.text, em) / 2,
179
182
  y: caption.y - 0.6 * em,
@@ -224,7 +227,20 @@ export function buildMark(item, box, toBox, em, options = {}) {
224
227
  const size = (label == null ? 0.4 : 0.75) * unit;
225
228
  const r = isRow ? Math.min(size, box.height / 2) : size;
226
229
  let at = whole ? { x: box.x + box.width - r, y: box.y + r } : centre(box);
227
- if (!whole && options.stacked && ((_c = item.point) === null || _c === void 0 ? void 0 : _c.part) !== "label" && ((_d = item.point) === null || _d === void 0 ? void 0 : _d.part) !== "total") {
230
+ if (!whole && options.label) {
231
+ // right of the label of a chart, not on it
232
+ at = { x: box.x + box.width + 0.25 * unit + r, y: box.y + box.height / 2 };
233
+ }
234
+ else if (!whole && options.stacked && options.horizontal) {
235
+ // in a wide segment right of its label, like in a table. Else on the upper edge at its end.
236
+ // The total behind the bar stays free in both cases.
237
+ const beside = 1.3 * unit + r;
238
+ at =
239
+ box.width / 2 >= beside + r
240
+ ? { x: box.x + box.width / 2 + beside, y: box.y + box.height / 2 }
241
+ : { x: box.x + box.width - Math.min(r, box.width / 2), y: box.y };
242
+ }
243
+ else if (!whole && options.stacked && ((_c = item.point) === null || _c === void 0 ? void 0 : _c.part) !== "label" && ((_d = item.point) === null || _d === void 0 ? void 0 : _d.part) !== "total") {
228
244
  // on the upper right corner: the label in the middle and a name beside the segment stay free
229
245
  at = { x: box.x + box.width, y: box.y + Math.min(0.5 * r, box.height / 2) };
230
246
  }
@@ -239,3 +255,109 @@ export function buildMark(item, box, toBox, em, options = {}) {
239
255
  }
240
256
  return { kind: "marker", color, badge: keepInside({ cx: at.x, cy: at.y, r, label }, area) };
241
257
  }
258
+ /**
259
+ * The difference of two bars that run from left to right. `levels` are the x of the
260
+ * two values. The bar of the difference lies in the gap below the second row, or above
261
+ * it when that row is the upper one. A thin line runs from each value to it, and the
262
+ * label stands right of it.
263
+ */
264
+ export function buildHorizontalDifference(item, box, toBox, fromValue, toValue, em, levels) {
265
+ var _a;
266
+ if (fromValue == null || toValue == null)
267
+ return undefined;
268
+ const difference = toValue - fromValue;
269
+ const digits = Number.isInteger(item.digits) && item.digits >= 0 ? item.digits : 1;
270
+ const good = item.sentiment === "good-down" ? difference <= 0 : difference >= 0;
271
+ const direction = toBox.y + toBox.height / 2 >= box.y + box.height / 2 ? 1 : -1;
272
+ const edge = (of) => (direction === 1 ? of.y + of.height : of.y);
273
+ const barHeight = 0.25 * em;
274
+ const barY = edge(toBox) + direction * 0.25 * em;
275
+ const left = Math.min(levels.from, levels.to);
276
+ const right = Math.max(levels.from, levels.to);
277
+ const percent = item.percent && fromValue !== 0 ? `(${signed((difference / Math.abs(fromValue)) * 100, 0)}%)` : undefined;
278
+ const value = signed(difference, digits);
279
+ const textX = right + 0.5 * em;
280
+ const valueWidth = value.length * 0.5 * em;
281
+ const percentWidth = percent ? textWidth(percent, 0.85 * em) : 0;
282
+ const percentX = textX + valueWidth + 0.35 * em;
283
+ return {
284
+ kind: "difference",
285
+ color: (_a = item.color) !== null && _a !== void 0 ? _a : (good ? "positive" : "negative"),
286
+ lines: [
287
+ { x1: levels.from, y1: edge(box), x2: levels.from, y2: barY },
288
+ { x1: levels.to, y1: edge(toBox), x2: levels.to, y2: barY },
289
+ ],
290
+ bar: { x: left, y: barY - barHeight / 2, width: Math.max(right - left, 1), height: barHeight },
291
+ text: { x: textX, y: barY, anchor: "start", value, percent },
292
+ frame: percent && item.highlight
293
+ ? {
294
+ x: percentX - 0.25 * em,
295
+ y: barY - 0.65 * em,
296
+ width: percentWidth + 0.5 * em,
297
+ height: 1.3 * em,
298
+ r: 0.65 * em,
299
+ }
300
+ : undefined,
301
+ badge: item.label != null ? { cx: left - 0.9 * em, cy: barY, r: 0.65 * em, label: item.label } : undefined,
302
+ };
303
+ }
304
+ /** A thick arrow that points down at `tip`: the value end of a bar, or the top of a column. */
305
+ export function buildPointer(item, at, em) {
306
+ const x = at.x;
307
+ const tip = at.y - 0.15 * em;
308
+ const neck = tip - 0.7 * em;
309
+ const top = tip - 1.9 * em;
310
+ const head = 0.55 * em;
311
+ const shaft = 0.22 * em;
312
+ const points = [
313
+ [x, tip],
314
+ [x - head, neck],
315
+ [x - shaft, neck],
316
+ [x - shaft, top],
317
+ [x + shaft, top],
318
+ [x + shaft, neck],
319
+ [x + head, neck],
320
+ ];
321
+ return {
322
+ kind: "pointer",
323
+ color: item.color,
324
+ shape: points.map(([px, py]) => `${px},${py}`).join(" "),
325
+ badge: item.label != null ? { cx: x + 1.1 * em, cy: top + 0.65 * em, r: 0.65 * em, label: item.label } : undefined,
326
+ };
327
+ }
328
+ /**
329
+ * A bracket around a range of rows of a chart with bars from left to right. A line
330
+ * runs below the last row from `left` to the end of its bar, and from there up to the
331
+ * end of the bar of the first row. `ends` are the x of the two values. `text` stands
332
+ * in a frame at the left, above the first row.
333
+ */
334
+ export function buildBracket(item, first, last, ends, left, text, em) {
335
+ const firstIsUpper = first.y <= last.y;
336
+ const [upper, lower] = firstIsUpper ? [first, last] : [last, first];
337
+ const [upperEnd, lowerEnd] = firstIsUpper ? [ends.first, ends.last] : [ends.last, ends.first];
338
+ const bottom = lower.y + lower.height + 0.2 * em;
339
+ const points = [
340
+ [left, bottom],
341
+ [lowerEnd, bottom],
342
+ [upperEnd, upper.y - 0.1 * em],
343
+ ];
344
+ const width = text ? textWidth(text, em) : 0;
345
+ const captionY = upper.y - 0.9 * em;
346
+ const caption = text ? { x: left + 0.5 * em + width / 2, y: captionY, text } : undefined;
347
+ // the number stands behind the text, or in its place
348
+ const badgeX = caption ? caption.x + width / 2 + 1.2 * em : left + 0.65 * em;
349
+ return {
350
+ kind: "bracket",
351
+ color: item.color,
352
+ path: points.map(([px, py]) => `${px},${py}`).join(" "),
353
+ caption,
354
+ frame: caption && {
355
+ x: caption.x - width / 2 - 0.45 * em,
356
+ y: caption.y - 0.7 * em,
357
+ width: width + 0.9 * em,
358
+ height: 1.4 * em,
359
+ r: 0.7 * em,
360
+ },
361
+ badge: item.label != null ? { cx: badgeX, cy: captionY, r: 0.65 * em, label: item.label } : undefined,
362
+ };
363
+ }
@@ -21,11 +21,12 @@ export function matchPoint(state, point) {
21
21
  const noThereof = state.table != null && point.subCategory == null;
22
22
  return candidates
23
23
  .filter((candidate) => matches(candidate.point, point) && !(noThereof && candidate.point.subCategory != null))
24
- .map(({ rect, content, contentSign, value, scenario }) => ({
24
+ .map(({ rect, content, contentSign, value, scenario, kind }) => ({
25
25
  rect,
26
26
  content,
27
27
  contentSign,
28
28
  value,
29
29
  stacked: typeof scenario === "string" && scenario.startsWith("stack:"),
30
+ label: kind === "label",
30
31
  }));
31
32
  }
@@ -76,6 +76,16 @@ export class BnChartStructureRenderer {
76
76
  /** @internal */
77
77
  this.stackConfig = null;
78
78
  /** @internal */
79
+ this.sums = "none";
80
+ /** @internal */
81
+ this.sumTitle = "";
82
+ /** @internal */
83
+ this.scenarioLabelTop = false;
84
+ /** @internal */
85
+ this.referenceLine = null;
86
+ /** @internal */
87
+ this.italicCategories = [];
88
+ /** @internal */
79
89
  this.parentDimensions = { width: 0, height: 0 };
80
90
  withComponentStatus(this);
81
91
  }
@@ -313,6 +323,11 @@ export class BnChartStructureRenderer {
313
323
  showMeasureScale: this.showMeasureScale,
314
324
  dataFormatDigits: this.dataFormatDigits,
315
325
  stackConfig: this.stackConfig,
326
+ sums: this.sums,
327
+ sumTitle: this.sumTitle,
328
+ scenarioLabelTop: this.scenarioLabelTop,
329
+ referenceLine: this.referenceLine,
330
+ italicCategories: this.italicCategories,
316
331
  });
317
332
  }
318
333
  prepareStyle() {
@@ -851,6 +866,124 @@ export class BnChartStructureRenderer {
851
866
  "setter": false,
852
867
  "defaultValue": "null"
853
868
  },
869
+ "sums": {
870
+ "type": "string",
871
+ "mutable": false,
872
+ "complexType": {
873
+ "original": "string",
874
+ "resolved": "string",
875
+ "references": {}
876
+ },
877
+ "required": false,
878
+ "optional": false,
879
+ "docs": {
880
+ "tags": [{
881
+ "name": "internal",
882
+ "text": undefined
883
+ }],
884
+ "text": ""
885
+ },
886
+ "getter": false,
887
+ "setter": false,
888
+ "reflect": false,
889
+ "attribute": "sums",
890
+ "defaultValue": "\"none\""
891
+ },
892
+ "sumTitle": {
893
+ "type": "string",
894
+ "mutable": false,
895
+ "complexType": {
896
+ "original": "string",
897
+ "resolved": "string",
898
+ "references": {}
899
+ },
900
+ "required": false,
901
+ "optional": false,
902
+ "docs": {
903
+ "tags": [{
904
+ "name": "internal",
905
+ "text": undefined
906
+ }],
907
+ "text": ""
908
+ },
909
+ "getter": false,
910
+ "setter": false,
911
+ "reflect": false,
912
+ "attribute": "sum-title",
913
+ "defaultValue": "\"\""
914
+ },
915
+ "scenarioLabelTop": {
916
+ "type": "boolean",
917
+ "mutable": false,
918
+ "complexType": {
919
+ "original": "boolean",
920
+ "resolved": "boolean",
921
+ "references": {}
922
+ },
923
+ "required": false,
924
+ "optional": false,
925
+ "docs": {
926
+ "tags": [{
927
+ "name": "internal",
928
+ "text": undefined
929
+ }],
930
+ "text": ""
931
+ },
932
+ "getter": false,
933
+ "setter": false,
934
+ "reflect": false,
935
+ "attribute": "scenario-label-top",
936
+ "defaultValue": "false"
937
+ },
938
+ "referenceLine": {
939
+ "type": "unknown",
940
+ "mutable": false,
941
+ "complexType": {
942
+ "original": "ReferenceLine | null",
943
+ "resolved": "ReferenceLine",
944
+ "references": {
945
+ "ReferenceLine": {
946
+ "location": "import",
947
+ "path": "../utils/model/StructureChartComponentConfig",
948
+ "id": "src/components/bn-chart-structure/utils/model/StructureChartComponentConfig.ts::ReferenceLine",
949
+ "referenceLocation": "ReferenceLine"
950
+ }
951
+ }
952
+ },
953
+ "required": false,
954
+ "optional": false,
955
+ "docs": {
956
+ "tags": [{
957
+ "name": "internal",
958
+ "text": undefined
959
+ }],
960
+ "text": ""
961
+ },
962
+ "getter": false,
963
+ "setter": false,
964
+ "defaultValue": "null"
965
+ },
966
+ "italicCategories": {
967
+ "type": "unknown",
968
+ "mutable": false,
969
+ "complexType": {
970
+ "original": "string[]",
971
+ "resolved": "string[]",
972
+ "references": {}
973
+ },
974
+ "required": false,
975
+ "optional": false,
976
+ "docs": {
977
+ "tags": [{
978
+ "name": "internal",
979
+ "text": undefined
980
+ }],
981
+ "text": ""
982
+ },
983
+ "getter": false,
984
+ "setter": false,
985
+ "defaultValue": "[]"
986
+ },
854
987
  "parentDimensions": {
855
988
  "type": "unknown",
856
989
  "mutable": false,
@@ -211,6 +211,55 @@ export class Chart {
211
211
  this.errors.remove(errId);
212
212
  }
213
213
  }
214
+ validateSums(newValue) {
215
+ this.warnUnless("sums", ["none", "groups", "total", "all"].includes(newValue), newValue);
216
+ }
217
+ validateScenarioLabelPosition(newValue) {
218
+ this.warnUnless("scenarioLabelPosition", ["bottom", "top"].includes(newValue), newValue);
219
+ }
220
+ validateReferenceLine(newValue) {
221
+ this.warnUnless("referenceLine", isBlankInput(newValue) || this.prepareReferenceLine() !== null, newValue);
222
+ }
223
+ validateItalicCategories(newValue) {
224
+ this.warnUnless("italicCategories", isBlankInput(newValue) || this.prepareItalicCategories() !== null, newValue);
225
+ }
226
+ warnUnless(name, valid, value) {
227
+ const errId = `WARN_${name}`;
228
+ if (valid) {
229
+ this.errors.remove(errId);
230
+ }
231
+ else {
232
+ this.errors.addOrReplace({
233
+ id: errId,
234
+ type: "warning",
235
+ message: name + ": invalid value '" + value + "' is not supported.",
236
+ });
237
+ }
238
+ }
239
+ prepareReferenceLine() {
240
+ if (isBlankInput(this.referenceLine))
241
+ return null;
242
+ try {
243
+ const parsed = JSON.parse(this.referenceLine);
244
+ if (typeof (parsed === null || parsed === void 0 ? void 0 : parsed.value) !== "number" || !Number.isFinite(parsed.value))
245
+ return null;
246
+ return { value: parsed.value, label: typeof parsed.label === "string" ? parsed.label : undefined };
247
+ }
248
+ catch (_a) {
249
+ return null;
250
+ }
251
+ }
252
+ prepareItalicCategories() {
253
+ if (isBlankInput(this.italicCategories))
254
+ return [];
255
+ try {
256
+ const parsed = JSON.parse(this.italicCategories);
257
+ return Array.isArray(parsed) && parsed.every((entry) => typeof entry === "string") ? parsed : null;
258
+ }
259
+ catch (_a) {
260
+ return null;
261
+ }
262
+ }
214
263
  validateStack(newValue) {
215
264
  const errId = "WARN_stack";
216
265
  const errors = validateStackConfig(newValue);
@@ -323,6 +372,48 @@ export class Chart {
323
372
  * Number of decimal digits of the percent labels (relative variances, shares of a 100 % stack)
324
373
  */
325
374
  this.dataFormatDigitsPercent = 2;
375
+ /**
376
+ * Sum rows. `groups` adds a row below the rows of each `rowGroup` (level
377
+ * `category`), `total` a row over all rows, `all` both. A sum row has no
378
+ * bar: it prints the sum in bold, in a stack one number per series with a
379
+ * small square in the colour of the series. In a 100 % stack it is a bar
380
+ * of shares. A sum row does not count for the scale.
381
+ *
382
+ * @default "none"
383
+ * @example sums="all"
384
+ */
385
+ this.sums = "none";
386
+ /**
387
+ * Label of the sum row over all rows.
388
+ *
389
+ * @default "" (the `SUM_TOTAL` text)
390
+ * @example sum-title="World"
391
+ */
392
+ this.sumTitle = "";
393
+ /**
394
+ * Where the name of the scenario of a chart with plain bars stands:
395
+ * `bottom` below the last bar, `top` above the first one.
396
+ *
397
+ * @default "bottom"
398
+ * @example scenario-label-position="top"
399
+ */
400
+ this.scenarioLabelPosition = "bottom";
401
+ /**
402
+ * A line across the bars at one value of the axis, as a JSON string:
403
+ * `value` and an optional `label`. In a 100 % stack the value is a percent.
404
+ *
405
+ * @default "" (no line)
406
+ * @example reference-line='{"value":50,"label":"50%"}'
407
+ */
408
+ this.referenceLine = "";
409
+ /**
410
+ * Rows that are printed in italics, as a JSON array of values of the
411
+ * level column, for example the rest rows.
412
+ *
413
+ * @default "" (none)
414
+ * @example italic-categories='["Rest of world"]'
415
+ */
416
+ this.italicCategories = "";
326
417
  /**
327
418
  * Stacking configuration as a JSON string. When set, bars are drawn as
328
419
  * stacked segments instead of side-by-side.
@@ -425,6 +516,10 @@ export class Chart {
425
516
  this.validateOrderList(this.order);
426
517
  this.validateMeasureScale(this.measureScale);
427
518
  this.validateStack(this.stack);
519
+ this.validateSums(this.sums);
520
+ this.validateScenarioLabelPosition(this.scenarioLabelPosition);
521
+ this.validateReferenceLine(this.referenceLine);
522
+ this.validateItalicCategories(this.italicCategories);
428
523
  this.validateScaling(this.scale);
429
524
  }
430
525
  componentDidRender() {
@@ -825,6 +920,7 @@ export class Chart {
825
920
  prepareStackConfig() {
826
921
  if (isBlankInput(this.stack)) {
827
922
  this.errors.remove("WARN_stack_dimensions_scenarios");
923
+ this.errors.remove("WARN_stack_thickness_variances");
828
924
  return null;
829
925
  }
830
926
  try {
@@ -847,10 +943,27 @@ export class Chart {
847
943
  else {
848
944
  this.errors.remove(errId);
849
945
  }
946
+ // rows of different height are for the base chart alone: a variance bar has one thickness
947
+ const byTotal = parsed.thickness === "total";
948
+ const withVariances = byTotal && this.prepareVariances().length > 0;
949
+ if (withVariances) {
950
+ this.errors.addOrReplace({
951
+ id: "WARN_stack_thickness_variances",
952
+ type: "warning",
953
+ message: "stack thickness total: not used together with variances, the rows keep one height.",
954
+ });
955
+ }
956
+ else {
957
+ this.errors.remove("WARN_stack_thickness_variances");
958
+ }
850
959
  return {
851
960
  by,
852
961
  mode: parsed.mode || StackMode.ABSOLUTE,
853
962
  order: parsed.order || StackOrder.DATASET,
963
+ percentMark: parsed.percentMark === true,
964
+ labels: parsed.labels === "value" ? "value" : "share",
965
+ thickness: byTotal && !withVariances ? "total" : "equal",
966
+ totalTitle: typeof parsed.totalTitle === "string" ? parsed.totalTitle : undefined,
854
967
  };
855
968
  }
856
969
  catch (_a) {
@@ -924,6 +1037,7 @@ export class Chart {
924
1037
  return this.measureUnit;
925
1038
  }
926
1039
  chartTemplate(localScenarioString, idx) {
1040
+ var _a;
927
1041
  const ppu = this.preparePixelPerUnit();
928
1042
  const ppp = this.preparePixelPerPercentage();
929
1043
  const stackConfig = this.prepareStackConfig();
@@ -931,7 +1045,7 @@ export class Chart {
931
1045
  const scenarios = this.hidesScenarios() ? variancesScenarios([localScenarioString]) : this.prepareScenarios();
932
1046
  // Dimension stacking uses only the first scenario. Only the base chart draws a stack, a variance needs both of its scenarios
933
1047
  const effectiveScenarios = isBase && (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
934
- return (h("bn-chart-structure-renderer", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, limit: this.prepareLimit(), styles: this.prepareStyle(), i18n: this.prepareI18n(), order: this.prepareOrder(), level: this.prepareLevel(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(idx), stackConfig: stackConfig, dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
1048
+ return (h("bn-chart-structure-renderer", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, limit: this.prepareLimit(), styles: this.prepareStyle(), i18n: this.prepareI18n(), order: this.prepareOrder(), level: this.prepareLevel(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(idx), stackConfig: stackConfig, sums: ["groups", "total", "all"].includes(this.sums) ? this.sums : "none", sumTitle: this.sumTitle, scenarioLabelTop: this.scenarioLabelPosition === "top", referenceLine: isBase ? this.prepareReferenceLine() : null, italicCategories: (_a = this.prepareItalicCategories()) !== null && _a !== void 0 ? _a : [], dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
935
1049
  }
936
1050
  /**
937
1051
  * The line this chart wants to be aligned on, in CSS px from the host's
@@ -1061,7 +1175,7 @@ export class Chart {
1061
1175
  this.errors.remove("WARN_scenarios_none");
1062
1176
  }
1063
1177
  const fontStyles = this.getFontStyles();
1064
- return (h(Host, { key: 'a9b487fd43e785b1f14d0599ad0145a248b35f5d', style: fontStyles }, h("div", { key: '950ab383346b288ab17c2a1bbdfcfcd240e0f4d8', class: "container" }, scenariosArray.map(this.chartTemplate))));
1178
+ return (h(Host, { key: 'eb0b081632a3d8e9475f280357c0b22b17b23df3', style: fontStyles }, h("div", { key: '8ecaea33bcd96b312e39868f008aa630e12077c2', class: "container" }, scenariosArray.map(this.chartTemplate))));
1065
1179
  }
1066
1180
  static get is() { return "bn-chart-structure"; }
1067
1181
  static get encapsulation() { return "shadow"; }
@@ -1538,6 +1652,136 @@ export class Chart {
1538
1652
  "attribute": "data-format-digits-percent",
1539
1653
  "defaultValue": "2"
1540
1654
  },
1655
+ "sums": {
1656
+ "type": "string",
1657
+ "mutable": false,
1658
+ "complexType": {
1659
+ "original": "\"none\" | \"groups\" | \"total\" | \"all\"",
1660
+ "resolved": "\"all\" | \"groups\" | \"none\" | \"total\"",
1661
+ "references": {}
1662
+ },
1663
+ "required": false,
1664
+ "optional": false,
1665
+ "docs": {
1666
+ "tags": [{
1667
+ "name": "default",
1668
+ "text": "\"none\""
1669
+ }, {
1670
+ "name": "example",
1671
+ "text": "sums=\"all\""
1672
+ }],
1673
+ "text": "Sum rows. `groups` adds a row below the rows of each `rowGroup` (level\n`category`), `total` a row over all rows, `all` both. A sum row has no\nbar: it prints the sum in bold, in a stack one number per series with a\nsmall square in the colour of the series. In a 100 % stack it is a bar\nof shares. A sum row does not count for the scale."
1674
+ },
1675
+ "getter": false,
1676
+ "setter": false,
1677
+ "reflect": false,
1678
+ "attribute": "sums",
1679
+ "defaultValue": "\"none\""
1680
+ },
1681
+ "sumTitle": {
1682
+ "type": "string",
1683
+ "mutable": false,
1684
+ "complexType": {
1685
+ "original": "string",
1686
+ "resolved": "string",
1687
+ "references": {}
1688
+ },
1689
+ "required": false,
1690
+ "optional": false,
1691
+ "docs": {
1692
+ "tags": [{
1693
+ "name": "default",
1694
+ "text": "\"\" (the `SUM_TOTAL` text)"
1695
+ }, {
1696
+ "name": "example",
1697
+ "text": "sum-title=\"World\""
1698
+ }],
1699
+ "text": "Label of the sum row over all rows."
1700
+ },
1701
+ "getter": false,
1702
+ "setter": false,
1703
+ "reflect": false,
1704
+ "attribute": "sum-title",
1705
+ "defaultValue": "\"\""
1706
+ },
1707
+ "scenarioLabelPosition": {
1708
+ "type": "string",
1709
+ "mutable": false,
1710
+ "complexType": {
1711
+ "original": "\"bottom\" | \"top\"",
1712
+ "resolved": "\"bottom\" | \"top\"",
1713
+ "references": {}
1714
+ },
1715
+ "required": false,
1716
+ "optional": false,
1717
+ "docs": {
1718
+ "tags": [{
1719
+ "name": "default",
1720
+ "text": "\"bottom\""
1721
+ }, {
1722
+ "name": "example",
1723
+ "text": "scenario-label-position=\"top\""
1724
+ }],
1725
+ "text": "Where the name of the scenario of a chart with plain bars stands:\n`bottom` below the last bar, `top` above the first one."
1726
+ },
1727
+ "getter": false,
1728
+ "setter": false,
1729
+ "reflect": false,
1730
+ "attribute": "scenario-label-position",
1731
+ "defaultValue": "\"bottom\""
1732
+ },
1733
+ "referenceLine": {
1734
+ "type": "string",
1735
+ "mutable": false,
1736
+ "complexType": {
1737
+ "original": "string",
1738
+ "resolved": "string",
1739
+ "references": {}
1740
+ },
1741
+ "required": false,
1742
+ "optional": false,
1743
+ "docs": {
1744
+ "tags": [{
1745
+ "name": "default",
1746
+ "text": "\"\" (no line)"
1747
+ }, {
1748
+ "name": "example",
1749
+ "text": "reference-line='{\"value\":50,\"label\":\"50%\"}'"
1750
+ }],
1751
+ "text": "A line across the bars at one value of the axis, as a JSON string:\n`value` and an optional `label`. In a 100 % stack the value is a percent."
1752
+ },
1753
+ "getter": false,
1754
+ "setter": false,
1755
+ "reflect": false,
1756
+ "attribute": "reference-line",
1757
+ "defaultValue": "\"\""
1758
+ },
1759
+ "italicCategories": {
1760
+ "type": "string",
1761
+ "mutable": false,
1762
+ "complexType": {
1763
+ "original": "string",
1764
+ "resolved": "string",
1765
+ "references": {}
1766
+ },
1767
+ "required": false,
1768
+ "optional": false,
1769
+ "docs": {
1770
+ "tags": [{
1771
+ "name": "default",
1772
+ "text": "\"\" (none)"
1773
+ }, {
1774
+ "name": "example",
1775
+ "text": "italic-categories='[\"Rest of world\"]'"
1776
+ }],
1777
+ "text": "Rows that are printed in italics, as a JSON array of values of the\nlevel column, for example the rest rows."
1778
+ },
1779
+ "getter": false,
1780
+ "setter": false,
1781
+ "reflect": false,
1782
+ "attribute": "italic-categories",
1783
+ "defaultValue": "\"\""
1784
+ },
1541
1785
  "stack": {
1542
1786
  "type": "string",
1543
1787
  "mutable": false,
@@ -1697,6 +1941,18 @@ export class Chart {
1697
1941
  }, {
1698
1942
  "propName": "dataFormatDigitsPercent",
1699
1943
  "methodName": "validateDataFormatDigitsPercent"
1944
+ }, {
1945
+ "propName": "sums",
1946
+ "methodName": "validateSums"
1947
+ }, {
1948
+ "propName": "scenarioLabelPosition",
1949
+ "methodName": "validateScenarioLabelPosition"
1950
+ }, {
1951
+ "propName": "referenceLine",
1952
+ "methodName": "validateReferenceLine"
1953
+ }, {
1954
+ "propName": "italicCategories",
1955
+ "methodName": "validateItalicCategories"
1700
1956
  }, {
1701
1957
  "propName": "stack",
1702
1958
  "methodName": "validateStack"