@bino-bi/bn-template-engine 1.0.0-next.39 → 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 (93) 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 +785 -378
  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 +156 -11
  21. package/dist/collection/components/bn-table/bn-table.js +134 -5
  22. package/dist/collection/components/bn-table/utils/elements/Cell.js +10 -1
  23. package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +25 -10
  24. package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +50 -12
  25. package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +44 -14
  26. package/dist/collection/components/bn-table/utils/helper/DataQuery.js +63 -2
  27. package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +123 -11
  28. package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +57 -9
  29. package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +16 -1
  30. package/dist/collection/components/bn-table/utils/model/index.js +6 -0
  31. package/dist/collection/utils/validate.js +4 -0
  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.js +1 -1
  35. package/dist/components/bn-chart-scatter-renderer.js +1 -1
  36. package/dist/components/bn-chart-scatter.js +1 -1
  37. package/dist/components/bn-chart-structure-renderer.js +1 -1
  38. package/dist/components/bn-chart-structure.js +1 -1
  39. package/dist/components/bn-chart-time-renderer.js +1 -1
  40. package/dist/components/bn-chart-time.js +1 -1
  41. package/dist/components/bn-grid.js +1 -1
  42. package/dist/components/bn-image.js +1 -1
  43. package/dist/components/bn-layout-card.js +1 -1
  44. package/dist/components/bn-layout-page.js +1 -1
  45. package/dist/components/bn-page.js +1 -1
  46. package/dist/components/bn-table-renderer.js +1 -1
  47. package/dist/components/bn-table.js +1 -1
  48. package/dist/components/bn-text.js +1 -1
  49. package/dist/components/bn-title.js +1 -1
  50. package/dist/components/bn-tree.js +1 -1
  51. package/dist/components/p-1B_s8oPY.js +1 -0
  52. package/dist/components/{p-BqUB56k1.js → p-B4L069XF.js} +1 -1
  53. package/dist/components/p-BC4MwlnX.js +1 -0
  54. package/dist/components/p-BZXiWkDS.js +1 -0
  55. package/dist/components/p-BiSytXUy.js +1 -0
  56. package/dist/components/p-Bn7J1pgl.js +1 -0
  57. package/dist/components/{p-BmOWXYHF.js → p-CEf5X8MZ.js} +1 -1
  58. package/dist/components/{p-Cyf5ZEXs.js → p-CUSAlS2o.js} +1 -1
  59. package/dist/components/p-CvEdUq8i.js +1 -0
  60. package/dist/components/{p-OquycEMA.js → p-D40Am1Ap.js} +1 -1
  61. package/dist/components/{p-B4Cf0cVi.js → p-DM4Up10X.js} +1 -1
  62. package/dist/components/{p-Bo_R7f_T.js → p-DwuXVo2h.js} +1 -1
  63. package/dist/components/{p-DTmqMQpw.js → p-Y9bth2Y_.js} +1 -1
  64. package/dist/components/{p-BU_53KVT.js → p-xIWChKGS.js} +1 -1
  65. package/dist/esm/bn-annotation-layer_30.entry.js +903 -496
  66. package/dist/esm/bn-grid.entry.js +1 -1
  67. package/dist/esm/bn-image.entry.js +1 -1
  68. package/dist/esm/bn-template-engine.js +1 -1
  69. package/dist/esm/bn-text.entry.js +2 -2
  70. package/dist/esm/loader.js +1 -1
  71. package/dist/esm/{withStyled-CIoJ86RM.js → withStyled-CzzXg64f.js} +77 -4
  72. package/dist/esm/{withTranslation-BX9T3dfm.js → withTranslation-Daq2JXkv.js} +1 -1
  73. package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +20 -1
  74. package/dist/types/components/bn-table/bn-table.d.ts +49 -1
  75. package/dist/types/components/bn-table/utils/elements/Cell.d.ts +3 -0
  76. package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +26 -0
  77. package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +22 -2
  78. package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +13 -0
  79. package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +30 -2
  80. package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +24 -4
  81. package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +7 -1
  82. package/dist/types/components/bn-table/utils/model/index.d.ts +5 -0
  83. package/dist/types/components.d.ts +49 -4
  84. package/dist/types/utils/validate.d.ts +1 -0
  85. package/package.json +1 -1
  86. package/dist/bn-template-engine/p-8c84d57e.entry.js +0 -1
  87. package/dist/bn-template-engine/p-BVU4bIsi.js +0 -1
  88. package/dist/components/p-BsJOvfIg.js +0 -1
  89. package/dist/components/p-DCPLGEs_.js +0 -1
  90. package/dist/components/p-DT04Cka0.js +0 -1
  91. package/dist/components/p-Dm6EAaJ9.js +0 -1
  92. package/dist/components/p-dRPJiQB6.js +0 -1
  93. package/dist/components/p-tkB96Ena.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { forceUpdate, h, Host } from "@stencil/core";
2
- import { OrderDirection, TableRowType, TableType } from "../utils/model";
2
+ import { OrderDirection, TableRowType, TableType, ThereofPosition } from "../utils/model";
3
3
  import { dataPointAttributes, measure, measureContent, measureSign, readLayoutPoint, } from "../../../utils/layoutState";
4
4
  import { Table } from "../utils/Table";
5
5
  import { TableComponentConfigAdapter } from "../utils/model/TableComponentConfig";
@@ -10,12 +10,12 @@ import { IBCSRuleSet, stylesBySlot } from "../../../utils/ibcsRuleSet";
10
10
  import { DataFormatDigits, DataFormatDigitsAdapter } from "../../../utils/model/DataFormatDigits";
11
11
  import { OrderAdapter } from "../../../utils/model/Order";
12
12
  import { CellBarChart, formatValue, zeroOnPositiveSide, } from "../utils/elements/CellBarChart";
13
- import { WaterfallBar } from "../utils/elements/WaterfallBar";
13
+ import { WaterfallBar, waterfallLabelText } from "../utils/elements/WaterfallBar";
14
14
  import withComponentStatus from "../../../utils/withComponentStatus";
15
15
  import withComponentStyle from "../../../utils/withComponentStyle";
16
16
  import { getStores } from "../../../context/context-protocol";
17
17
  import { sourceExpr } from "../../../context/scopedDb";
18
- import { absoluteBarGeometry, BAR_LABEL_FONT_RATIO, labelWidth, PIN_HEAD_SIZE, pinLabelsFit, relativePinGeometry, } from "../utils/helper/barColumnGeometry";
18
+ import { absoluteBarGeometry, BAR_LABEL_FONT_RATIO, labelWidth, PIN_HEAD_SIZE, pinLabelsFit, relativePinGeometry, waterfallGeometry, } from "../utils/helper/barColumnGeometry";
19
19
  import { NOT_AVAILABLE } from "../../../utils/relativeVariance";
20
20
  import { normalizeFillPattern } from "../../../utils/model/styles/SVGStyle";
21
21
  /**
@@ -59,8 +59,14 @@ export class BnTableRenderer {
59
59
  /** @internal */
60
60
  this.showGroupTitle = true;
61
61
  /** @internal */
62
+ this.runningSum = false;
63
+ /** @internal */
64
+ this.varianceWaterfall = false;
65
+ /** @internal */
62
66
  this.thereof = [];
63
67
  /** @internal */
68
+ this.thereofPosition = ThereofPosition.BELOW;
69
+ /** @internal */
64
70
  this.partof = [];
65
71
  /** @internal */
66
72
  this.order = {
@@ -111,9 +117,10 @@ export class BnTableRenderer {
111
117
  this.scaleFactor = 1;
112
118
  this.componentDataFormatDigits = new DataFormatDigits();
113
119
  this.barColumnLayouts = new Map();
120
+ this.waterfallGeometries = new Map();
114
121
  // labels measured in the fallback font are too narrow or too wide once the web font is there: lay out again
115
122
  this.relayout = () => {
116
- if (this.barColumnLayouts.size > 0)
123
+ if (this.barColumnLayouts.size > 0 || this.waterfallGeometries.size > 0)
117
124
  forceUpdate(this);
118
125
  };
119
126
  withComponentStatus(this);
@@ -246,14 +253,16 @@ export class BnTableRenderer {
246
253
  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;
247
254
  return (h("table", null, h("thead", null, this.table.getHeader().map((row) => (h("tr", { class: row.cssStyle }, row.getCells().map((cell) => (h("th", { colSpan: cell.colSpan, class: cell.cssStyle }, cell.getAsHeaderList().map((line, i, arr) => (h("span", null, i === arr.length - 1 ? (h("span", { class: line === " " ? "table-footer" : "" }, line, cell.drawPrefix(), " ")) : (h("span", null, line, cell.drawPrefix(), h("br", null))))))))))))), h("tbody", null, this.table.getBody().map((row) => (h("tr", Object.assign({ class: row.cssStyle }, dataPointAttributes(row.key, "element")), row === null || row === void 0 ? void 0 : row.getCells().map((cell) => {
248
255
  var _a, _b, _c, _d, _e;
249
- return (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 !== "-"
256
+ return (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 !== "-"
250
257
  ? dataPointAttributes(Object.assign(Object.assign({}, row.key), { date: cell.date, scenario: cell.key }), "element")
251
- : {})), cell.prefix != null ? (h("span", { class: cell.cssStyle + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
258
+ : {})), cell.prefix != null ? (h("span", { class: this.cellClass(cell, locale) + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
252
259
  cell.columnStats &&
253
260
  cell.value !== NOT_AVAILABLE &&
254
261
  // an untitled group head is only a gap between list groups, a bar cell would print "-" in it
255
262
  (this.showGroupTitle || row.type !== TableRowType.HEADER) &&
256
- (cell.waterfall !== undefined || row.type !== TableRowType.SUM) ? (cell.waterfall !== undefined ? (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 })) : (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))));
263
+ (cell.waterfall !== undefined || row.type !== TableRowType.SUM) &&
264
+ // a variance walk where every step is zero has no extent: the rows print their zero
265
+ !(cell.direction !== undefined && cell.waterfall && cell.waterfall.max === cell.waterfall.min) ? (cell.waterfall !== undefined ? (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) })) : (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))));
257
266
  })))))));
258
267
  };
259
268
  return h(Host, { class: { "no-data": ((_a = this.table) === null || _a === void 0 ? void 0 : _a.hasNoData()) === true } }, helper());
@@ -309,8 +318,16 @@ export class BnTableRenderer {
309
318
  }
310
319
  }
311
320
  this.barColumnLayouts = this.collectBarColumnLayouts();
321
+ this.waterfallGeometries = this.collectWaterfallGeometries();
312
322
  this.barChartStyles = this.prepareBarChartStyles();
313
323
  }
324
+ /** The classes of a number cell. A variance that prints as zero loses its sign and its sentiment color. */
325
+ cellClass(cell, locale) {
326
+ if (cell.direction === undefined || !cell.roundsToZero(this.componentDataFormatDigits, locale)) {
327
+ return cell.cssStyle;
328
+ }
329
+ return cell.cssStyle.replace(/^(pos|neg)_\w+/, "zero");
330
+ }
314
331
  prepareConfig(db) {
315
332
  var _a, _b, _c;
316
333
  const fromExpr = sourceExpr(db, this.tableName, this.filter);
@@ -324,7 +341,10 @@ export class BnTableRenderer {
324
341
  scenariosUnitType: this.scenariosDataFormat,
325
342
  grouped: this.grouped,
326
343
  showGroupTitle: this.showGroupTitle,
344
+ runningSum: this.runningSum,
345
+ varianceWaterfall: this.varianceWaterfall,
327
346
  thereOf: this.thereof,
347
+ thereOfPosition: this.thereofPosition,
328
348
  partOf: this.partof,
329
349
  categoryThereOf: this.categorythereof,
330
350
  attributes: this.attributeColumns,
@@ -487,6 +507,7 @@ export class BnTableRenderer {
487
507
  const layouts = new Map();
488
508
  if (!this.table || this.table.hasNoData())
489
509
  return layouts;
510
+ // a cell with the weight its row prints in
490
511
  const cellsByKey = new Map();
491
512
  for (const row of this.table.getBody()) {
492
513
  if (row.type === TableRowType.SUM)
@@ -497,7 +518,7 @@ export class BnTableRenderer {
497
518
  continue;
498
519
  if (typeof cell.value !== "number" || isNaN(cell.value))
499
520
  continue;
500
- cellsByKey.set(cell.key, [...((_a = cellsByKey.get(cell.key)) !== null && _a !== void 0 ? _a : []), cell]);
521
+ cellsByKey.set(cell.key, [...((_a = cellsByKey.get(cell.key)) !== null && _a !== void 0 ? _a : []), { cell, bold: isBoldRow(row) }]);
501
522
  }
502
523
  }
503
524
  const emPx = this.emPx();
@@ -507,7 +528,7 @@ export class BnTableRenderer {
507
528
  const fontFamily = this.labelFontFamily();
508
529
  for (const [key, cells] of cellsByKey) {
509
530
  const isRelative = key.startsWith("dr");
510
- const values = cells.map((cell) => cell.value);
531
+ const values = cells.map(({ cell }) => cell.value);
511
532
  const measure = (percentDigits, percentSign) => {
512
533
  var _a;
513
534
  const labels = {
@@ -515,11 +536,11 @@ export class BnTableRenderer {
515
536
  pos: values.some((value) => value > 0) ? 0 : undefined,
516
537
  };
517
538
  const zeroPositive = zeroOnPositiveSide(labels);
518
- for (const cell of cells) {
539
+ for (const { cell, bold } of cells) {
519
540
  const value = cell.value;
520
541
  const side = value > 0 || (value === 0 && zeroPositive) ? "pos" : "neg";
521
542
  const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign, barLabelDigits(cell, this.componentDataFormatDigits));
522
- labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative));
543
+ labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative, bold));
523
544
  }
524
545
  return labels;
525
546
  };
@@ -545,6 +566,50 @@ export class BnTableRenderer {
545
566
  }
546
567
  return layouts;
547
568
  }
569
+ /**
570
+ * What a variance waterfall connector crosses outside the bar svg: the border of its own
571
+ * row above, the padding of a sum row below.
572
+ */
573
+ connectorReach(row) {
574
+ const emPx = this.emPx();
575
+ return { top: 0.1 * emPx, bottom: row.type === TableRowType.SUM ? 0.5 * emPx : 0 };
576
+ }
577
+ /**
578
+ * Geometry of every waterfall column from the measured labels of all cells that draw a
579
+ * bar, sum rows included: each side gets the room its labels need.
580
+ */
581
+ collectWaterfallGeometries() {
582
+ var _a, _b, _c, _d;
583
+ const geometries = new Map();
584
+ if (!this.table || this.table.hasNoData())
585
+ return geometries;
586
+ const emPx = this.emPx();
587
+ const fs = emPx * BAR_LABEL_FONT_RATIO;
588
+ 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;
589
+ const fontFamily = this.labelFontFamily();
590
+ const columns = new Map();
591
+ for (const row of this.table.getBody()) {
592
+ for (const cell of row.getCells()) {
593
+ if (!cell.isBarChart || !cell.columnStats || cell.waterfall === undefined)
594
+ continue;
595
+ if (typeof cell.value !== "number" || isNaN(cell.value))
596
+ continue;
597
+ const { start, end, min, max, kind } = cell.waterfall;
598
+ const text = waterfallLabelText(cell.value, kind, barLabelMeasureScale(cell), locale, barLabelDigits(cell, this.componentDataFormatDigits), cell.direction !== undefined);
599
+ const column = (_d = columns.get(cell.key)) !== null && _d !== void 0 ? _d : { min, max, labels: [] };
600
+ column.labels.push({
601
+ end,
602
+ pointsLeft: end < start,
603
+ width: labelWidth(text, fs, fontFamily, false, isBoldRow(row)),
604
+ });
605
+ columns.set(cell.key, column);
606
+ }
607
+ }
608
+ for (const [key, column] of columns) {
609
+ geometries.set(key, waterfallGeometry(this.barColumnMaxWidth, emPx, column));
610
+ }
611
+ return geometries;
612
+ }
548
613
  static get is() { return "bn-table-renderer"; }
549
614
  static get encapsulation() { return "shadow"; }
550
615
  static get originalStyleUrls() {
@@ -770,6 +835,52 @@ export class BnTableRenderer {
770
835
  "attribute": "show-group-title",
771
836
  "defaultValue": "true"
772
837
  },
838
+ "runningSum": {
839
+ "type": "boolean",
840
+ "mutable": false,
841
+ "complexType": {
842
+ "original": "boolean",
843
+ "resolved": "boolean",
844
+ "references": {}
845
+ },
846
+ "required": false,
847
+ "optional": false,
848
+ "docs": {
849
+ "tags": [{
850
+ "name": "internal",
851
+ "text": undefined
852
+ }],
853
+ "text": ""
854
+ },
855
+ "getter": false,
856
+ "setter": false,
857
+ "reflect": false,
858
+ "attribute": "running-sum",
859
+ "defaultValue": "false"
860
+ },
861
+ "varianceWaterfall": {
862
+ "type": "boolean",
863
+ "mutable": false,
864
+ "complexType": {
865
+ "original": "boolean",
866
+ "resolved": "boolean",
867
+ "references": {}
868
+ },
869
+ "required": false,
870
+ "optional": false,
871
+ "docs": {
872
+ "tags": [{
873
+ "name": "internal",
874
+ "text": undefined
875
+ }],
876
+ "text": ""
877
+ },
878
+ "getter": false,
879
+ "setter": false,
880
+ "reflect": false,
881
+ "attribute": "variance-waterfall",
882
+ "defaultValue": "false"
883
+ },
773
884
  "thereof": {
774
885
  "type": "unknown",
775
886
  "mutable": false,
@@ -798,6 +909,36 @@ export class BnTableRenderer {
798
909
  "setter": false,
799
910
  "defaultValue": "[]"
800
911
  },
912
+ "thereofPosition": {
913
+ "type": "string",
914
+ "mutable": false,
915
+ "complexType": {
916
+ "original": "ThereofPosition",
917
+ "resolved": "ThereofPosition.ABOVE | ThereofPosition.BELOW",
918
+ "references": {
919
+ "ThereofPosition": {
920
+ "location": "import",
921
+ "path": "../utils/model",
922
+ "id": "src/components/bn-table/utils/model/index.ts::ThereofPosition",
923
+ "referenceLocation": "ThereofPosition"
924
+ }
925
+ }
926
+ },
927
+ "required": false,
928
+ "optional": false,
929
+ "docs": {
930
+ "tags": [{
931
+ "name": "internal",
932
+ "text": undefined
933
+ }],
934
+ "text": ""
935
+ },
936
+ "getter": false,
937
+ "setter": false,
938
+ "reflect": false,
939
+ "attribute": "thereof-position",
940
+ "defaultValue": "ThereofPosition.BELOW"
941
+ },
801
942
  "partof": {
802
943
  "type": "unknown",
803
944
  "mutable": false,
@@ -1495,6 +1636,10 @@ export class BnTableRenderer {
1495
1636
  }
1496
1637
  static get elementRef() { return "element"; }
1497
1638
  }
1639
+ /** Sum rows and the parent of thereof rows printed above it are bold. */
1640
+ function isBoldRow(row) {
1641
+ return row.type === TableRowType.SUM || row.cssStyle === "ofit-sum";
1642
+ }
1498
1643
  /** Percentage points: the fraction times 100, no measure scale. */
1499
1644
  function barLabelMeasureScale(cell) {
1500
1645
  return cell.type === "percentpoint" ? 0.01 : cell.measureScale;
@@ -1,6 +1,6 @@
1
1
  import { forceUpdate, h, Host, writeTask } from "@stencil/core";
2
2
  import { hasInlineJs } from "../../context/scopedDb";
3
- import { isBlankInput, isTableBarColumnWidth, isTableCategoryWidth, isValidDataFormat, isValidDateFormat, isValidDirection, isValidInteger, isValidMeasureScale, isValidMeasureType, isValidTableType, validateAttributesJsonStr, validateBarColumnsList, validateColumnThereOfJsonStr, validateTableOrderList, validatePartOfJsonStr, validateScenarioList, validateThereOfJsonStr, validateVariancesList, } from "../../utils/validate";
3
+ import { isBlankInput, isTableBarColumnWidth, isTableCategoryWidth, isValidDataFormat, isValidDateFormat, isValidDirection, isValidInteger, isValidMeasureScale, isValidMeasureType, isValidTableType, isValidThereofPosition, validateAttributesJsonStr, validateBarColumnsList, validateColumnThereOfJsonStr, validateTableOrderList, validatePartOfJsonStr, validateScenarioList, validateThereOfJsonStr, validateVariancesList, } from "../../utils/validate";
4
4
  import withDataset from "../../utils/withDataset";
5
5
  import withComponentStatus from "../../utils/withComponentStatus";
6
6
  import withScalingGroup from "../../utils/withScalingGroup";
@@ -16,7 +16,7 @@ import { getParentDimensions } from "../../utils/parentDimensions";
16
16
  import { formatScalingValue, parseScaling, resolveScalingValue } from "../../utils/scaling";
17
17
  import { observeParentResize } from "../../utils/layoutObserver";
18
18
  import { BAR_COLUMN_WIDTH_EM, DataFormat, I18nMode, MeasureType, TableBarColumnWidth, TableCategoryWidth, } from "../../utils/constants";
19
- import { TableType } from "./utils/model";
19
+ import { TableType, ThereofPosition } from "./utils/model";
20
20
  import { coerceSetnameIndex, INTERVAL_NONE, INTERVAL_SETNAME } from "./utils/helper/IntervalColumns";
21
21
  import { parseTableAttributeExpression } from "./utils/model/TableAttribute";
22
22
  import { normalizeOrderToken, OrderDirection } from "../../utils/model/Order";
@@ -91,7 +91,7 @@ export class Table {
91
91
  /**
92
92
  * Data units displayed per 1 em of bar length for absolute variance bar
93
93
  * charts (ΔPY) - map-scale semantics: a larger value means smaller bars.
94
- * Bars exceeding barColumnWidth are shown with an arrow indicator.
94
+ * Bars exceeding barColumnWidth are cut with a zigzag break.
95
95
  *
96
96
  * | Value | Behavior |
97
97
  * |------------------|----------------------------------------------------------------|
@@ -159,6 +159,37 @@ export class Table {
159
159
  *
160
160
  */
161
161
  this.showGroupTitle = true;
162
+ /**
163
+ * Turns the sum row of each (row-)group into a running result: the sum of all
164
+ * rows from the first group down to its own group, with the matching absolute
165
+ * and relative variances. Use it for a calculation scheme such as an income
166
+ * statement, where each `rowGroup` ends in a result.
167
+ * <br /><br />
168
+ * Needs `grouped` and a type with group sums (```sum // opt // sumnototal // optnototal```).
169
+ * The total row of ```sum``` and ```opt``` stays and repeats the last running
170
+ * result, so ```sumnototal``` or ```optnototal``` is the usual choice.
171
+ * `partof` shares still refer to the sum of their own group.
172
+ * Not supported together with `columnthereof`: there it has no effect.
173
+ * <br /><br />
174
+ * values: <br />
175
+ * ```true // false```
176
+ */
177
+ this.runningSum = false;
178
+ /**
179
+ * Draws every absolute variance column (d_*) listed in ```barColumns``` as a
180
+ * variance waterfall down the rows instead of single bars from the axis.
181
+ * A row starts where the row above ended; on ```opt``` and ```optnototal```
182
+ * tables a "-" row with a positive variance moves to the left. Sum rows are
183
+ * bars from the axis. Thin lines join the bars. Each row group starts at the
184
+ * axis again, with ```runningSum``` the walk goes on from the sum row.
185
+ * The column scales to fit the whole walk (unit-scaling does not apply).
186
+ * Relative variance columns (dr_*) stay pins.
187
+ * Has no effect together with ```interval``` or ```columnthereof```.
188
+ * <br /><br />
189
+ * values: <br />
190
+ * ```true // false```
191
+ */
192
+ this.varianceWaterfall = false;
162
193
  /**
163
194
  * Set the table type
164
195
  * <br /><br />
@@ -186,6 +217,21 @@ export class Table {
186
217
  * ```[{"rowGroup": "Umsatz", "category": "Applications", "subCategory": "Applications-A"}]```
187
218
  */
188
219
  this.thereof = "[]";
220
+ /**
221
+ * Position of the `thereof` rows relative to their parent row.
222
+ * <br /><br />
223
+ * ```below``` (default) prints them below the parent, small and italic, with
224
+ * the thereof label. ```above``` prints them before the parent in normal
225
+ * size with an indented label, and the parent row looks like a subtotal
226
+ * (bold, with a line above it). The parent keeps its operation sign and its
227
+ * value, so a parent of `-` rows reads like "- Operating expenses".
228
+ * With ```above``` list all subcategories of the parent (`"subCategory": ""`):
229
+ * with only some of them the parent looks like a subtotal that does not add up.
230
+ * <br /><br />
231
+ * values: <br />
232
+ * ```below // above```
233
+ */
234
+ this.thereofPosition = "below";
189
235
  /**
190
236
  * JSON array of part-of objects with the keys `rowGroup` and `category`
191
237
  * (both strings, both required).
@@ -574,6 +620,19 @@ export class Table {
574
620
  this.errors.remove(errId);
575
621
  }
576
622
  }
623
+ validateThereofPosition(newValue) {
624
+ const errId = "WARN_thereofPosition";
625
+ if (isBlankInput(newValue) || isValidThereofPosition(newValue)) {
626
+ this.errors.remove(errId);
627
+ }
628
+ else {
629
+ this.errors.addOrReplace({
630
+ id: errId,
631
+ type: "warning",
632
+ message: "thereofPosition: invalid value '" + newValue + "' is not supported.",
633
+ });
634
+ }
635
+ }
577
636
  validatePartOf(newValue) {
578
637
  const errId = "WARN_partof";
579
638
  const invalidElements = validatePartOfJsonStr(newValue);
@@ -751,6 +810,7 @@ export class Table {
751
810
  this.validateType(this.type);
752
811
  this.validateLimit(this.limit);
753
812
  this.validateThereOf(this.thereof);
813
+ this.validateThereofPosition(this.thereofPosition);
754
814
  this.validatePartOf(this.partof);
755
815
  this.validateOrderDirection(this.orderDirection);
756
816
  this.validateOrderList(this.order);
@@ -894,6 +954,12 @@ export class Table {
894
954
  prepareShowGroupTitle() {
895
955
  return this.showGroupTitle;
896
956
  }
957
+ prepareThereofPosition() {
958
+ var _a;
959
+ return ((_a = this.thereofPosition) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ThereofPosition.ABOVE
960
+ ? ThereofPosition.ABOVE
961
+ : ThereofPosition.BELOW;
962
+ }
897
963
  prepareTableType() {
898
964
  var _a;
899
965
  return TableType[(_a = this.type) === null || _a === void 0 ? void 0 : _a.toUpperCase()];
@@ -1403,7 +1469,7 @@ export class Table {
1403
1469
  render() {
1404
1470
  const fontStyles = this.getFontStyles();
1405
1471
  const effectiveFactor = this.getEffectiveScaleFactor();
1406
- return (h(Host, { key: '9c4b7d3df45c425ab5d6f1443a3a067220d3a451', style: fontStyles }, h("div", { key: 'b0332096da43ca9d5c139da7f18abdcb89356c37' }, h("bn-table-renderer", { key: 'f9ae1288c299bf3e5a5d1da5161fd9c663472e76', 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(), 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 }))));
1472
+ return (h(Host, { key: '2af1b7f31952cd0ba32e0a069ce143d3402b4a77', style: fontStyles }, h("div", { key: 'b78ad13abb48a43c1da0aec4727372a482c39701' }, 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 }))));
1407
1473
  }
1408
1474
  static get is() { return "bn-table"; }
1409
1475
  static get encapsulation() { return "shadow"; }
@@ -1672,7 +1738,7 @@ export class Table {
1672
1738
  "name": "example",
1673
1739
  "text": "unit-scaling=\"revenue-scale\""
1674
1740
  }],
1675
- "text": "Data units displayed per 1 em of bar length for absolute variance bar\ncharts (\u0394PY) - map-scale semantics: a larger value means smaller bars.\nBars exceeding barColumnWidth are shown with an arrow indicator.\n\n| Value | Behavior |\n|------------------|----------------------------------------------------------------|\n| `\"auto\"` | Auto-fit the largest bar to the bar column width |\n| `\"250000\"`, `\"1M\"` | Units per em; optional SI suffix `k`/`K`/`M`/`G`/`T` |\n| group name | References a `<bn-scaling-group>` for synchronized scaling |\n| invalid / unknown | Auto-fit + `AUTO_unitScaling` warning |\n\nDefault: `\"100\"` (1 em of bar represents 100 units)"
1741
+ "text": "Data units displayed per 1 em of bar length for absolute variance bar\ncharts (\u0394PY) - map-scale semantics: a larger value means smaller bars.\nBars exceeding barColumnWidth are cut with a zigzag break.\n\n| Value | Behavior |\n|------------------|----------------------------------------------------------------|\n| `\"auto\"` | Auto-fit the largest bar to the bar column width |\n| `\"250000\"`, `\"1M\"` | Units per em; optional SI suffix `k`/`K`/`M`/`G`/`T` |\n| group name | References a `<bn-scaling-group>` for synchronized scaling |\n| invalid / unknown | Auto-fit + `AUTO_unitScaling` warning |\n\nDefault: `\"100\"` (1 em of bar represents 100 units)"
1676
1742
  },
1677
1743
  "getter": false,
1678
1744
  "setter": false,
@@ -1786,6 +1852,46 @@ export class Table {
1786
1852
  "attribute": "show-group-title",
1787
1853
  "defaultValue": "true"
1788
1854
  },
1855
+ "runningSum": {
1856
+ "type": "boolean",
1857
+ "mutable": false,
1858
+ "complexType": {
1859
+ "original": "boolean",
1860
+ "resolved": "boolean",
1861
+ "references": {}
1862
+ },
1863
+ "required": false,
1864
+ "optional": false,
1865
+ "docs": {
1866
+ "tags": [],
1867
+ "text": "Turns the sum row of each (row-)group into a running result: the sum of all\nrows from the first group down to its own group, with the matching absolute\nand relative variances. Use it for a calculation scheme such as an income\nstatement, where each `rowGroup` ends in a result.\n<br /><br />\nNeeds `grouped` and a type with group sums (```sum // opt // sumnototal // optnototal```).\nThe total row of ```sum``` and ```opt``` stays and repeats the last running\nresult, so ```sumnototal``` or ```optnototal``` is the usual choice.\n`partof` shares still refer to the sum of their own group.\nNot supported together with `columnthereof`: there it has no effect.\n<br /><br />\nvalues: <br />\n```true // false```"
1868
+ },
1869
+ "getter": false,
1870
+ "setter": false,
1871
+ "reflect": false,
1872
+ "attribute": "running-sum",
1873
+ "defaultValue": "false"
1874
+ },
1875
+ "varianceWaterfall": {
1876
+ "type": "boolean",
1877
+ "mutable": false,
1878
+ "complexType": {
1879
+ "original": "boolean",
1880
+ "resolved": "boolean",
1881
+ "references": {}
1882
+ },
1883
+ "required": false,
1884
+ "optional": false,
1885
+ "docs": {
1886
+ "tags": [],
1887
+ "text": "Draws every absolute variance column (d_*) listed in ```barColumns``` as a\nvariance waterfall down the rows instead of single bars from the axis.\nA row starts where the row above ended; on ```opt``` and ```optnototal```\ntables a \"-\" row with a positive variance moves to the left. Sum rows are\nbars from the axis. Thin lines join the bars. Each row group starts at the\naxis again, with ```runningSum``` the walk goes on from the sum row.\nThe column scales to fit the whole walk (unit-scaling does not apply).\nRelative variance columns (dr_*) stay pins.\nHas no effect together with ```interval``` or ```columnthereof```.\n<br /><br />\nvalues: <br />\n```true // false```"
1888
+ },
1889
+ "getter": false,
1890
+ "setter": false,
1891
+ "reflect": false,
1892
+ "attribute": "variance-waterfall",
1893
+ "defaultValue": "false"
1894
+ },
1789
1895
  "type": {
1790
1896
  "type": "string",
1791
1897
  "mutable": false,
@@ -1846,6 +1952,26 @@ export class Table {
1846
1952
  "attribute": "thereof",
1847
1953
  "defaultValue": "\"[]\""
1848
1954
  },
1955
+ "thereofPosition": {
1956
+ "type": "string",
1957
+ "mutable": false,
1958
+ "complexType": {
1959
+ "original": "string",
1960
+ "resolved": "string",
1961
+ "references": {}
1962
+ },
1963
+ "required": false,
1964
+ "optional": false,
1965
+ "docs": {
1966
+ "tags": [],
1967
+ "text": "Position of the `thereof` rows relative to their parent row.\n<br /><br />\n```below``` (default) prints them below the parent, small and italic, with\nthe thereof label. ```above``` prints them before the parent in normal\nsize with an indented label, and the parent row looks like a subtotal\n(bold, with a line above it). The parent keeps its operation sign and its\nvalue, so a parent of `-` rows reads like \"- Operating expenses\".\nWith ```above``` list all subcategories of the parent (`\"subCategory\": \"\"`):\nwith only some of them the parent looks like a subtotal that does not add up.\n<br /><br />\nvalues: <br />\n```below // above```"
1968
+ },
1969
+ "getter": false,
1970
+ "setter": false,
1971
+ "reflect": false,
1972
+ "attribute": "thereof-position",
1973
+ "defaultValue": "\"below\""
1974
+ },
1849
1975
  "partof": {
1850
1976
  "type": "string",
1851
1977
  "mutable": false,
@@ -2205,6 +2331,9 @@ export class Table {
2205
2331
  }, {
2206
2332
  "propName": "thereof",
2207
2333
  "methodName": "validateThereOf"
2334
+ }, {
2335
+ "propName": "thereofPosition",
2336
+ "methodName": "validateThereofPosition"
2208
2337
  }, {
2209
2338
  "propName": "partof",
2210
2339
  "methodName": "validatePartOf"
@@ -40,7 +40,16 @@ export class Cell {
40
40
  return result;
41
41
  }
42
42
  draw(dataFormatDigits, locale) {
43
- let cellValue = this.value;
43
+ return this.format(this.value, dataFormatDigits, locale);
44
+ }
45
+ /** True when the cell prints a number that is zero at the displayed digits. */
46
+ roundsToZero(dataFormatDigits, locale) {
47
+ return (typeof this.value === "number" &&
48
+ !!this.type &&
49
+ this.draw(dataFormatDigits, locale) === this.format(0, dataFormatDigits, locale));
50
+ }
51
+ format(value, dataFormatDigits, locale) {
52
+ let cellValue = value;
44
53
  if (cellValue === "undefined" || cellValue === undefined || cellValue == null) {
45
54
  return "";
46
55
  }
@@ -26,6 +26,10 @@ export const DEFAULT_STYLES = {
26
26
  export const AXIS_COLOR = "#666666";
27
27
  /** Width of the pin line, in px before scaleFactor. */
28
28
  const PIN_LINE_WIDTH = 3;
29
+ /** Arrow head of a cut pin, in sides of the square pin head: IBCS draws it a bit larger. */
30
+ const PIN_ARROW_RATIO = 1.2;
31
+ /** Padding of the light band under the label on a cut pin, in label font sizes. */
32
+ const PIN_BAND_PAD = 0.2;
29
33
  /**
30
34
  * Creates a unique pattern ID for the SVG defs
31
35
  */
@@ -124,7 +128,7 @@ function getScenarioStyle(scenario, styles) {
124
128
  const type = getScenarioType(scenario);
125
129
  return styles.scenarios[type];
126
130
  }
127
- function getVarianceLook(scenario, styles) {
131
+ export function getVarianceLook(scenario, styles) {
128
132
  if (isScenarioColumn(scenario))
129
133
  return null;
130
134
  const variance = new VarianceScenario(scenario);
@@ -144,7 +148,7 @@ function getVarianceLook(scenario, styles) {
144
148
  * a double line (PL, outlined) or dashed (FC, hatched). Lines only, so the bar stays the
145
149
  * one direct-child rect of the svg.
146
150
  */
147
- const VarianceAxis = ({ x, height, look, styles }) => {
151
+ export const VarianceAxis = ({ x, height, look, styles }) => {
148
152
  const s = styles.scaleFactor;
149
153
  const width = VARIANCE_AXIS_EM * styles.emPx;
150
154
  const { reference, referenceSlot } = look;
@@ -260,11 +264,11 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
260
264
  * exactly `columnWidthEm` em - see barColumnGeometry.ts.
261
265
  */
262
266
  const AbsoluteVarianceBar = (props) => {
263
- const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
267
+ const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, bold, styles = DEFAULT_STYLES, } = props;
264
268
  const s = styles.scaleFactor;
265
269
  const fs = styles.fontSize;
266
270
  const displayValue = formattedValue || formatValue(value, false, measureScale, locale, 0, true, decimalDigits);
267
- const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false));
271
+ const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false, bold));
268
272
  const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
269
273
  const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
270
274
  const geometry = absoluteBarGeometry(columnWidthEm, styles.emPx, sides, { neg, pos });
@@ -317,7 +321,8 @@ const AbsoluteVarianceBar = (props) => {
317
321
  * Renders a relative variance pin chart (dr_ prefix).
318
322
  * Line from the axis in the sentiment colour, ending in a square head in the look of the
319
323
  * minuend, with the value label beside the head like an absolute bar label. A pin beyond
320
- * the pin area is cut and ends in an arrow, its label after the arrow tip.
324
+ * the pin area is cut and ends in an arrow. Its label stands on the line behind the arrow
325
+ * head, on a light band, or after the arrow tip when the line is too short for it.
321
326
  *
322
327
  * Layout: [left label area][pin area with axis][right label area], summing to exactly
323
328
  * `columnWidthEm` em - see barColumnGeometry.ts.
@@ -325,13 +330,14 @@ const AbsoluteVarianceBar = (props) => {
325
330
  */
326
331
  const RelativeVariancePin = (props) => {
327
332
  var _a, _b;
328
- const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, percentDigits, percentSign, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
333
+ const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, percentDigits, percentSign, columnWidthEm = 10, labelWidths, sideMax, bold, styles = DEFAULT_STYLES, } = props;
329
334
  const s = styles.scaleFactor;
330
335
  const fs = styles.fontSize;
331
336
  const headSize = PIN_HEAD_SIZE * s;
332
337
  const pinPx = 100 * styles.percentageScaling * fs;
333
338
  const displayValue = formattedValue || formatValue(value, true, measureScale, locale, percentDigits, percentSign);
334
- const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, true));
339
+ const ownWidth = labelWidth(displayValue, fs, styles.fontFamily, true, bold);
340
+ const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, ownWidth);
335
341
  const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
336
342
  const { totalWidth, negPinLength, posPinLength, axisX, labelGap } = relativePinGeometry(columnWidthEm, styles.emPx, sides, headSize, { neg: neg * pinPx, pos: pos * pinPx });
337
343
  const centerY = height / 2;
@@ -350,9 +356,18 @@ const RelativeVariancePin = (props) => {
350
356
  const headStyle = (_a = look === null || look === void 0 ? void 0 : look.minuend) !== null && _a !== void 0 ? _a : styles.scenarios.ac;
351
357
  // the arrow tip lands on the outer edge of a full-length head, so the label after it stays in the cell
352
358
  const tipX = axisX + direction * (maxPinLength + headSize / 2);
353
- const arrowBaseX = tipX - direction * headSize;
354
- const labelX = (isExtreme ? tipX : pinEndX + direction * (headSize / 2)) + direction * labelGap;
355
- return (h("svg", { width: totalWidth, height: height, class: "cell-bar-chart relative-variance", style: { overflow: "visible" } }, h(PatternDefs, { styles: styles }), look ? (h(VarianceAxis, { x: axisX, height: height, look: look, styles: styles })) : (h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s })), h("line", { x1: axisX, y1: centerY, x2: isExtreme ? arrowBaseX : pinEndX, y2: centerY, stroke: barStyle.fill, "stroke-width": PIN_LINE_WIDTH * s }), isExtreme ? (h("polygon", { points: `${tipX},${centerY} ${arrowBaseX},${centerY - headSize / 2} ${arrowBaseX},${centerY + headSize / 2}`, fill: barStyle.fill })) : (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 })), 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)));
359
+ const arrowSize = PIN_ARROW_RATIO * headSize;
360
+ const arrowBaseX = tipX - direction * arrowSize;
361
+ // the band keeps a pad of full line to the arrow head and to the axis, else the label goes after the tip
362
+ const bandPad = PIN_BAND_PAD * fs;
363
+ const bandWidth = ownWidth + 2 * bandPad;
364
+ const shaftLength = Math.abs(arrowBaseX - axisX) - (VARIANCE_AXIS_EM * styles.emPx) / 2;
365
+ const labelOnShaft = isExtreme && shaftLength >= bandWidth + 2 * bandPad;
366
+ const bandX = arrowBaseX - direction * (bandPad + bandWidth / 2) - bandWidth / 2;
367
+ const labelX = labelOnShaft
368
+ ? bandX + bandWidth / 2
369
+ : (isExtreme ? tipX : pinEndX + direction * (headSize / 2)) + direction * labelGap;
370
+ return (h("svg", { width: totalWidth, height: height, class: "cell-bar-chart relative-variance", style: { overflow: "visible" } }, h(PatternDefs, { styles: styles }), look ? (h(VarianceAxis, { x: axisX, height: height, look: look, styles: styles })) : (h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s })), h("line", { x1: axisX, y1: centerY, x2: isExtreme ? arrowBaseX : pinEndX, y2: centerY, stroke: barStyle.fill, "stroke-width": PIN_LINE_WIDTH * s }), isExtreme ? (h("polygon", { points: `${tipX},${centerY} ${arrowBaseX},${centerY - arrowSize / 2} ${arrowBaseX},${centerY + arrowSize / 2}`, fill: barStyle.fill })) : (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 && (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" })), 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)));
356
371
  };
357
372
  /**
358
373
  * CellBarChart - Renders IBCS-compliant variance bar charts.