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

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.
@@ -26919,6 +26919,9 @@ const Table$1 = class Table {
26919
26919
  * inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data
26920
26920
  * (and a relative variance with a zero reference) sort last.
26921
26921
  * <br /><br />
26922
+ * A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays
26923
+ * the last row of the group. Its label comes from the `REST` translation.
26924
+ * <br /><br />
26922
26925
  * When set to ```auto```, order is detected from the dataset silently.
26923
26926
  */
26924
26927
  this.order = "category";
@@ -28048,7 +28051,7 @@ const Table$1 = class Table {
28048
28051
  render() {
28049
28052
  const fontStyles = this.getFontStyles();
28050
28053
  const effectiveFactor = this.getEffectiveScaleFactor();
28051
- return (index.h(index.Host, { key: '2f24deddc4e58f57ef27443a27b4706b5f1b90db', style: fontStyles }, index.h("div", { key: 'b6368e143f868d9c2a7ad8ec753a14813b60e197' }, index.h("bn-table-renderer", { key: '399b2dc8d5cf3e7a8093a9a486635ea4d1bb74b9', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
28054
+ return (index.h(index.Host, { key: '42974a4931f678c35e5c740bf6d630966368fb4b', style: fontStyles }, index.h("div", { key: '2c8f99a8bd155e2c93e55e9542090d04afe22a31' }, index.h("bn-table-renderer", { key: 'cae9e83bf297e730f12a8a390cbf279413c40b54', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
28052
28055
  }
28053
28056
  get element() { return index.getElement(this); }
28054
28057
  static get watchers() { return {
@@ -28423,20 +28426,43 @@ function pinLabelsFit(widthEm, emPx, labels, headSize) {
28423
28426
  const { sides, neg, pos } = sideNeeds(labels, headSize / 2, LABEL_GAP_EM * emPx);
28424
28427
  return neg + pos + sides * minExtent(totalWidth, emPx, sides) <= totalWidth + 1e-6;
28425
28428
  }
28426
- function absoluteBarGeometry(widthEm, emPx, labels) {
28427
- const totalWidth = contentWidth(widthEm, emPx);
28428
- const labelGap = LABEL_GAP_EM * emPx;
28429
- // a variance bar starts at the outer edge of the thick axis
28430
- const { extent: maxBarWidth, axisX } = splitSides(totalWidth, labels, (VARIANCE_AXIS_EM * emPx) / 2, labelGap);
28431
- const breakGap = Math.min(BREAK_GAP_EM * emPx, maxBarWidth * 0.2);
28429
+ function barSide(maxBarWidth, breakGap) {
28432
28430
  const overdriveZoneWidth = maxBarWidth * OVERDRIVE_FRACTION;
28433
28431
  return {
28434
- totalWidth,
28435
28432
  maxBarWidth,
28436
- axisX,
28437
28433
  breakGap,
28438
28434
  overdriveZoneWidth,
28439
28435
  cutWidth: Math.max(0, maxBarWidth - breakGap - overdriveZoneWidth),
28436
+ };
28437
+ }
28438
+ /**
28439
+ * `sideMax` is the largest absolute value per side of the axis. With it, the bar room is
28440
+ * split so the uncut bar length of each side is in that ratio: the axis sits where the
28441
+ * values need it, at any scale. Without it, both sides get the same extent.
28442
+ */
28443
+ function absoluteBarGeometry(widthEm, emPx, labels, sideMax) {
28444
+ var _a, _b;
28445
+ const totalWidth = contentWidth(widthEm, emPx);
28446
+ const labelGap = LABEL_GAP_EM * emPx;
28447
+ // a variance bar starts at the outer edge of the thick axis
28448
+ const { extent, axisX } = splitSides(totalWidth, labels, (VARIANCE_AXIS_EM * emPx) / 2, labelGap);
28449
+ const breakGap = Math.min(BREAK_GAP_EM * emPx, extent * 0.2);
28450
+ const hasNeg = labels.neg !== undefined;
28451
+ const hasPos = labels.pos !== undefined || !hasNeg;
28452
+ let neg = hasNeg ? extent : 0;
28453
+ const maxNeg = Math.max(0, (_a = sideMax === null || sideMax === void 0 ? void 0 : sideMax.neg) !== null && _a !== void 0 ? _a : 0);
28454
+ const maxPos = Math.max(0, (_b = sideMax === null || sideMax === void 0 ? void 0 : sideMax.pos) !== null && _b !== void 0 ? _b : 0);
28455
+ if (hasNeg && hasPos && maxNeg + maxPos > 0) {
28456
+ // every side keeps its break gap and overdrive stub, only the uncut length follows the values
28457
+ const uncut = 2 * extent * (1 - OVERDRIVE_FRACTION) - 2 * breakGap;
28458
+ neg = (breakGap + (uncut * maxNeg) / (maxNeg + maxPos)) / (1 - OVERDRIVE_FRACTION);
28459
+ }
28460
+ const pos = hasPos ? (hasNeg ? 2 * extent - neg : extent) : 0;
28461
+ return {
28462
+ totalWidth,
28463
+ neg: barSide(neg, breakGap),
28464
+ pos: barSide(pos, breakGap),
28465
+ axisX: hasNeg ? axisX - extent + neg : 0,
28440
28466
  labelGap,
28441
28467
  };
28442
28468
  }
@@ -28543,9 +28569,10 @@ const PatternDefs = ({ styles }) => {
28543
28569
  /** Longest relative label that keeps all percent digits; a longer one drops digits so its gutter does not eat the pins. */
28544
28570
  const PIN_LABEL_CHARS = 7;
28545
28571
  /**
28546
- * Formats a number for display with appropriate SI prefix.
28572
+ * Formats a bar or pin label. An absolute value with `decimalDigits` prints like a number
28573
+ * cell, without them it takes an SI suffix.
28547
28574
  */
28548
- function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0, percentSign = true) {
28575
+ function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0, percentSign = true, decimalDigits) {
28549
28576
  // IBCS prints a value that rounds to zero without a sign
28550
28577
  const signed = (text, zero) => (value > 0 && text !== zero ? "+" : "") + text;
28551
28578
  if (isRelative) {
@@ -28563,6 +28590,10 @@ function formatValue(value, isRelative, measureScale = 1, locale, percentDigits
28563
28590
  }
28564
28591
  // Absolute variance - apply measure scale and use SI prefixes
28565
28592
  const scaledValue = value / measureScale;
28593
+ if (decimalDigits !== undefined) {
28594
+ const number = (v) => Formatter.number(v, "decimal", decimalDigits, decimalDigits, 1, locale);
28595
+ return signed(number(scaledValue), number(0));
28596
+ }
28566
28597
  const absValue = Math.abs(scaledValue);
28567
28598
  let unit = 1;
28568
28599
  let suffix = "";
@@ -28745,25 +28776,28 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
28745
28776
  * exactly `columnWidthEm` em - see barColumnGeometry.ts.
28746
28777
  */
28747
28778
  const AbsoluteVarianceBar = (props) => {
28748
- const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, columnWidthEm = 10, labelWidths, styles = DEFAULT_STYLES, } = props;
28779
+ const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
28749
28780
  const s = styles.scaleFactor;
28750
28781
  const fs = styles.fontSize;
28751
- const displayValue = formattedValue || formatValue(value, false, measureScale, locale);
28782
+ const displayValue = formattedValue || formatValue(value, false, measureScale, locale, 0, true, decimalDigits);
28752
28783
  const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false));
28753
- const { totalWidth, axisX, breakGap, overdriveZoneWidth, cutWidth, labelGap } = absoluteBarGeometry(columnWidthEm, styles.emPx, sides);
28784
+ const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
28785
+ const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
28786
+ const geometry = absoluteBarGeometry(columnWidthEm, styles.emPx, sides, { neg, pos });
28787
+ const { totalWidth, axisX, labelGap } = geometry;
28788
+ const { breakGap, overdriveZoneWidth, cutWidth } = isPositive ? geometry.pos : geometry.neg;
28754
28789
  // Direct unit scaling via fontSize
28755
28790
  const scaledWidth = Math.abs(value) * styles.unitScaling * fs;
28756
28791
  // auto scaling puts the largest bar on the cut, float rounding must not turn it into an overdrive bar
28757
28792
  const isExtreme = scaledWidth - cutWidth > 1e-6;
28758
28793
  // Compute proportional overdrive width across the column
28759
- const maxScaledWidth = columnStats.absMax * styles.unitScaling * fs;
28794
+ const maxScaledWidth = (isPositive ? pos : neg) * styles.unitScaling * fs;
28760
28795
  const maxOverflow = Math.max(0, maxScaledWidth - cutWidth);
28761
28796
  const overflowAmount = Math.max(0, scaledWidth - cutWidth);
28762
28797
  const overdriveWidth = maxOverflow > 0 ? (overflowAmount / maxOverflow) * overdriveZoneWidth : 0;
28763
28798
  const padding = 2 * s;
28764
28799
  const barHeight = height - padding * 2;
28765
28800
  const barY = padding;
28766
- const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
28767
28801
  // Get style based on column type (scenario vs variance)
28768
28802
  const look = getVarianceLook(scenario, styles);
28769
28803
  const sentimentStyle = getBarStyle(scenario, value, isPositiveGood, styles);
@@ -28871,7 +28905,7 @@ const CellBarChart = (props) => {
28871
28905
  * guides marking their parent bar's extent.
28872
28906
  */
28873
28907
  const WaterfallBar = (props) => {
28874
- const { value, scenario, height, measureScale, locale, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, } = props;
28908
+ const { value, scenario, height, measureScale, locale, decimalDigits, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, } = props;
28875
28909
  const s = styles.scaleFactor;
28876
28910
  const fs = styles.fontSize;
28877
28911
  const range = waterfall.max - waterfall.min;
@@ -28893,7 +28927,7 @@ const WaterfallBar = (props) => {
28893
28927
  const fillValue = getBarFill(barStyle, getScenarioType(scenario));
28894
28928
  const { stroke: barStroke, strokeWidth: barStrokeWidth } = getBarStroke(barStyle);
28895
28929
  // Scenario values carry no variance sentiment - labels are unsigned per IBCS
28896
- const displayValue = formatValue(value, waterfall.kind === "partof", measureScale, locale).replace(/^\+/, "");
28930
+ const displayValue = formatValue(value, waterfall.kind === "partof", measureScale, locale, 0, true, decimalDigits).replace(/^\+/, "");
28897
28931
  const pointsLeft = endX < startX;
28898
28932
  const labelX = pointsLeft ? barX - labelGap : barX + barWidth + labelGap;
28899
28933
  const labelAnchor = pointsLeft ? "end" : "start";
@@ -29168,7 +29202,8 @@ class DataQuery {
29168
29202
  /** Generates a GROUPHEAD row used as a visual header when row grouping is active. */
29169
29203
  createGroupHeaderRow(rowGroupEntry, querys) {
29170
29204
  // Generates GroupHeader Row
29171
- if (true === this.config.grouped) {
29205
+ // Without a title the group sum row alone closes the group; only a list has no sum row and keeps the head as gap
29206
+ if (true === this.config.grouped && (this.config.showGroupTitle || !this.hasGroupSum())) {
29172
29207
  const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
29173
29208
  const title = rowGroupEntry.rowGroup === "" ? this.bind(BLANK_BUCKET_LABEL) : rowGroup;
29174
29209
  const groupTitle = this.config.showGroupTitle ? `,${title} as ${QueryColumnNames.CATEGORY}` : "";
@@ -29180,14 +29215,16 @@ class DataQuery {
29180
29215
  GROUP BY '1'`);
29181
29216
  }
29182
29217
  }
29218
+ hasGroupSum() {
29219
+ return (TableType.SUM === this.config.type ||
29220
+ TableType.SUMNOTOTAL === this.config.type ||
29221
+ TableType.OPT === this.config.type ||
29222
+ TableType.OPTNOTOTAL === this.config.type);
29223
+ }
29183
29224
  /** Generates a GROUP_SUM row that aggregates all entries within a single row group. */
29184
29225
  createGroupSumRow(querys, groupSumQuery, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order) {
29185
29226
  // Generates SUM Row; sumsup all rows of group
29186
- if (true === this.config.grouped &&
29187
- (TableType.SUM === this.config.type ||
29188
- TableType.SUMNOTOTAL === this.config.type ||
29189
- TableType.OPT === this.config.type ||
29190
- TableType.OPTNOTOTAL === this.config.type)) {
29227
+ if (true === this.config.grouped && this.hasGroupSum()) {
29191
29228
  const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
29192
29229
  querys.push(`SELECT ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
29193
29230
  '=' as ${QueryColumnNames.OPERATION},
@@ -29495,17 +29532,19 @@ class DataQuery {
29495
29532
  const entryRowsRaw = exec(`SELECT ${groups.select()}, __interval ${scenarios.length > 0 ? ",".concat(scenarios) : ""}
29496
29533
  FROM ${bucketSource}
29497
29534
  GROUP BY ${groups}, __interval`);
29535
+ // only the generated REST row has restRowGroup; a data row with the category REST keeps its own values
29536
+ const isGeneratedRest = (row) => row.type === "ENTRY" && row.restRowGroup != null;
29498
29537
  // REST rows first: the math needs the raw (not yet finalized) entry aliases
29499
29538
  if (this.config.limit > 0) {
29500
29539
  for (let segmentIndex = 0; segmentIndex < res.length; segmentIndex++) {
29501
- const restRow = res[segmentIndex].find((row) => row.type === "ENTRY" && row.category === "REST");
29540
+ const restRow = res[segmentIndex].find(isGeneratedRest);
29502
29541
  if (!restRow) {
29503
29542
  continue;
29504
29543
  }
29505
29544
  // nearest preceding segment holding the displayed ENTRY rows
29506
29545
  let entrySegment;
29507
29546
  for (let i = segmentIndex - 1; i >= 0 && !entrySegment; i--) {
29508
- const candidate = res[i].filter((row) => row.type === "ENTRY" && row.category !== "REST");
29547
+ const candidate = res[i].filter((row) => row.type === "ENTRY" && !isGeneratedRest(row));
29509
29548
  if (candidate.length > 0) {
29510
29549
  entrySegment = candidate;
29511
29550
  }
@@ -29543,7 +29582,7 @@ class DataQuery {
29543
29582
  finalizeBucketRow(entryRow);
29544
29583
  for (const segment of res) {
29545
29584
  for (const row of segment) {
29546
- if (row.type !== "ENTRY" || row.category === "REST" || row.category !== entryRow.category) {
29585
+ if (row.type !== "ENTRY" || isGeneratedRest(row) || row.category !== entryRow.category) {
29547
29586
  continue;
29548
29587
  }
29549
29588
  if (this.config.grouped && row.rowGroup !== entryRow.rowGroup) {
@@ -29817,11 +29856,20 @@ class DataQuery {
29817
29856
  }
29818
29857
  });
29819
29858
  this.sortSelect = [...sortKeys.values()].map((key) => `, ${key}`).join("");
29859
+ // a data row with the reserved category REST stays last in its group when the rows are sorted by value
29860
+ const sortsByValue = orderComponent.hierarchy.some((column) => {
29861
+ var _a;
29862
+ const kind = (_a = withStyled.parseOrderToken(column)) === null || _a === void 0 ? void 0 : _a.kind;
29863
+ return kind === "scenario" || kind === "variance";
29864
+ });
29865
+ if (sortsByValue) {
29866
+ this.sortSelect += `, CASE WHEN ${QueryColumnNames.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`;
29867
+ }
29820
29868
  // rows without a value sort last in both directions
29821
29869
  const orderBy = (column, i, direction) => sortKeys.has(i) ? `__sortnull${i} asc, __sort${i} ${direction}` : `${column} ${direction}`;
29822
29870
  const base = orderComponent.hierarchy.map((column, i) => orderBy(column, i, orderComponent.direction)).toString();
29823
29871
  const inverted = orderComponent.hierarchy.map((column, i) => orderBy(column, i, inverse)).toString();
29824
- return [base, inverted];
29872
+ return sortsByValue ? [`__sortrest asc, ${base}`, `__sortrest desc, ${inverted}`] : [base, inverted];
29825
29873
  }
29826
29874
  /**
29827
29875
  * Sort key `__sort<i>` of a scenario or variance order token, as printed in an entry cell
@@ -30164,13 +30212,16 @@ function signedValue(row, column, tableType) {
30164
30212
  * segmented query result once per column in display order.
30165
30213
  *
30166
30214
  * - ENTRY rows (incl. REST) cascade from the running total by their signed value.
30167
- * - SUM / GROUP_SUM rows anchor at zero and reset the running total to their value.
30215
+ * - SUM / GROUP_SUM rows anchor at zero. A SUM row resets the running total to its
30216
+ * value, a GROUP_SUM row resets it to zero.
30168
30217
  * - DRILLELEMENT (thereof) rows form a sub-cascade from their parent bar's start in
30169
30218
  * the parent's direction; the running total is untouched.
30170
30219
  * - PARTELEMENT (partof) rows cascade a `share * parent width` segment the same way.
30171
30220
  * Note: the share denominator is the group sum (or SUM_TOTAL when ungrouped) per
30172
30221
  * `createPartOfDrillRows`, not literally the parent row's value.
30173
- * - GROUPHEAD and NaN rows get no bar; a NaN parent orphans its drill children.
30222
+ * - GROUPHEAD rows get no bar and restart the running total at zero: every row group
30223
+ * is its own cascade that ends at its GROUP_SUM.
30224
+ * - NaN rows get no bar; a NaN parent orphans its drill children.
30174
30225
  *
30175
30226
  * @param queryData - Segmented result rows from DataQuery.execute().
30176
30227
  * @param columns - Plain scenario column keys (ac1..pl4); no `##` composite keys.
@@ -30191,6 +30242,8 @@ function computeWaterfall(queryData, columns, tableType) {
30191
30242
  for (const row of groupData) {
30192
30243
  const type = row[QueryColumnNames.TYPE];
30193
30244
  if (type === TableRowType.GROUPHEAD) {
30245
+ // a group sum only totals its own rows, so the cascade must not carry over
30246
+ running = 0;
30194
30247
  lastParent = undefined;
30195
30248
  continue;
30196
30249
  }
@@ -30213,7 +30266,8 @@ function computeWaterfall(queryData, columns, tableType) {
30213
30266
  emit(row, { start: 0, end: value, min: 0, max: 0, kind: "anchor" });
30214
30267
  lastParent = { start: 0, end: value };
30215
30268
  subCursor = 0;
30216
- running = value;
30269
+ // a group sum closes its group (there may be no GROUPHEAD row when the title is hidden)
30270
+ running = type === TableRowType.GROUPSUM ? 0 : value;
30217
30271
  }
30218
30272
  else if (type === TableRowType.DRILLELEMENT) {
30219
30273
  if (value === null || lastParent === undefined) {
@@ -31479,7 +31533,9 @@ const BnTableRenderer = class {
31479
31533
  : {})), cell.prefix != null ? (index.h("span", { class: cell.cssStyle + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
31480
31534
  cell.columnStats &&
31481
31535
  cell.value !== withStyled.NOT_AVAILABLE &&
31482
- (cell.waterfall !== undefined || row.type !== TableRowType.SUM) ? (cell.waterfall !== undefined ? (index.h(WaterfallBar, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: false, isPositiveGood: cell.direction === "pos", measureScale: cell.measureScale, locale: locale, columnWidthEm: this.barColumnMaxWidth, styles: this.barChartStyles, waterfall: cell.waterfall })) : (index.h(CellBarChart, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: cell.key.startsWith("dr"), isPositiveGood: cell.direction === "pos", measureScale: barLabelMeasureScale(cell), locale: locale, 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))));
31536
+ // an untitled group head is only a gap between list groups, a bar cell would print "-" in it
31537
+ (this.showGroupTitle || row.type !== TableRowType.HEADER) &&
31538
+ (cell.waterfall !== undefined || row.type !== TableRowType.SUM) ? (cell.waterfall !== undefined ? (index.h(WaterfallBar, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: false, isPositiveGood: cell.direction === "pos", measureScale: cell.measureScale, locale: locale, decimalDigits: barLabelDigits(cell, this.componentDataFormatDigits), columnWidthEm: this.barColumnMaxWidth, styles: this.barChartStyles, waterfall: cell.waterfall })) : (index.h(CellBarChart, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: cell.key.startsWith("dr"), isPositiveGood: cell.direction === "pos", measureScale: barLabelMeasureScale(cell), locale: locale, decimalDigits: barLabelDigits(cell, this.componentDataFormatDigits), percentDigits: (_b = (_a = this.barColumnLayouts.get(cell.key)) === null || _a === void 0 ? void 0 : _a.percentDigits) !== null && _b !== void 0 ? _b : this.componentDataFormatDigits.percent, percentSign: (_c = this.barColumnLayouts.get(cell.key)) === null || _c === void 0 ? void 0 : _c.percentSign, columnWidthEm: this.barColumnMaxWidth, labelWidths: (_d = this.barColumnLayouts.get(cell.key)) === null || _d === void 0 ? void 0 : _d.labels, sideMax: (_e = this.barColumnLayouts.get(cell.key)) === null || _e === void 0 ? void 0 : _e.sideMax, styles: this.barChartStyles }))) : (cell.draw(this.componentDataFormatDigits, locale))));
31483
31539
  })))))));
31484
31540
  };
31485
31541
  return index.h(index.Host, { class: { "no-data": ((_a = this.table) === null || _a === void 0 ? void 0 : _a.hasNoData()) === true } }, helper());
@@ -31655,14 +31711,21 @@ const BnTableRenderer = class {
31655
31711
  * One scaling for all columns, so it is the smallest that fits every column.
31656
31712
  */
31657
31713
  autoUnitScaling() {
31714
+ var _a;
31658
31715
  const emPx = this.emPx();
31659
31716
  const fs = emPx * BAR_LABEL_FONT_RATIO;
31660
31717
  let scaling = Infinity;
31661
- for (const { isRelative, absMax, labels } of this.barColumnLayouts.values()) {
31718
+ for (const { isRelative, absMax, labels, sideMax } of this.barColumnLayouts.values()) {
31662
31719
  if (isRelative || absMax <= 0)
31663
31720
  continue;
31664
- const { maxBarWidth, cutWidth } = absoluteBarGeometry(this.barColumnMaxWidth, emPx, labels);
31665
- scaling = Math.min(scaling, Math.min(maxBarWidth * 0.8, cutWidth) / (absMax * fs));
31721
+ const geometry = absoluteBarGeometry(this.barColumnMaxWidth, emPx, labels, sideMax);
31722
+ for (const side of ["neg", "pos"]) {
31723
+ const max = (_a = sideMax[side]) !== null && _a !== void 0 ? _a : 0;
31724
+ if (max <= 0)
31725
+ continue;
31726
+ const { maxBarWidth, cutWidth } = geometry[side];
31727
+ scaling = Math.min(scaling, Math.min(maxBarWidth * 0.8, cutWidth) / (max * fs));
31728
+ }
31666
31729
  }
31667
31730
  return Number.isFinite(scaling) && fs > 0 ? scaling : 0.01;
31668
31731
  }
@@ -31727,7 +31790,7 @@ const BnTableRenderer = class {
31727
31790
  for (const cell of cells) {
31728
31791
  const value = cell.value;
31729
31792
  const side = value > 0 || (value === 0 && zeroPositive) ? "pos" : "neg";
31730
- const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign);
31793
+ const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign, barLabelDigits(cell, this.componentDataFormatDigits));
31731
31794
  labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative));
31732
31795
  }
31733
31796
  return labels;
@@ -31760,6 +31823,12 @@ const BnTableRenderer = class {
31760
31823
  function barLabelMeasureScale(cell) {
31761
31824
  return cell.type === "percentpoint" ? 0.01 : cell.measureScale;
31762
31825
  }
31826
+ /** Fraction digits of the number cells of the column, so an absolute bar label prints like them. */
31827
+ function barLabelDigits(cell, digits) {
31828
+ if (cell.type === "percentpoint")
31829
+ return digits.percent;
31830
+ return cell.type === "decimal" ? digits.decimal : undefined;
31831
+ }
31763
31832
  BnTableRenderer.style = bnTableRendererCss();
31764
31833
 
31765
31834
  const bnTitleCss = () => `:host{padding:0.5em;margin-bottom:0.5em;box-sizing:border-box;-webkit-box-sizing:border-box;width:100%;display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}`;
@@ -249,7 +249,9 @@ export class BnTableRenderer {
249
249
  : {})), cell.prefix != null ? (h("span", { class: cell.cssStyle + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
250
250
  cell.columnStats &&
251
251
  cell.value !== NOT_AVAILABLE &&
252
- (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, 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, 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))));
252
+ // an untitled group head is only a gap between list groups, a bar cell would print "-" in it
253
+ (this.showGroupTitle || row.type !== TableRowType.HEADER) &&
254
+ (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))));
253
255
  })))))));
254
256
  };
255
257
  return h(Host, { class: { "no-data": ((_a = this.table) === null || _a === void 0 ? void 0 : _a.hasNoData()) === true } }, helper());
@@ -425,14 +427,21 @@ export class BnTableRenderer {
425
427
  * One scaling for all columns, so it is the smallest that fits every column.
426
428
  */
427
429
  autoUnitScaling() {
430
+ var _a;
428
431
  const emPx = this.emPx();
429
432
  const fs = emPx * BAR_LABEL_FONT_RATIO;
430
433
  let scaling = Infinity;
431
- for (const { isRelative, absMax, labels } of this.barColumnLayouts.values()) {
434
+ for (const { isRelative, absMax, labels, sideMax } of this.barColumnLayouts.values()) {
432
435
  if (isRelative || absMax <= 0)
433
436
  continue;
434
- const { maxBarWidth, cutWidth } = absoluteBarGeometry(this.barColumnMaxWidth, emPx, labels);
435
- scaling = Math.min(scaling, Math.min(maxBarWidth * 0.8, cutWidth) / (absMax * fs));
437
+ const geometry = absoluteBarGeometry(this.barColumnMaxWidth, emPx, labels, sideMax);
438
+ for (const side of ["neg", "pos"]) {
439
+ const max = (_a = sideMax[side]) !== null && _a !== void 0 ? _a : 0;
440
+ if (max <= 0)
441
+ continue;
442
+ const { maxBarWidth, cutWidth } = geometry[side];
443
+ scaling = Math.min(scaling, Math.min(maxBarWidth * 0.8, cutWidth) / (max * fs));
444
+ }
436
445
  }
437
446
  return Number.isFinite(scaling) && fs > 0 ? scaling : 0.01;
438
447
  }
@@ -497,7 +506,7 @@ export class BnTableRenderer {
497
506
  for (const cell of cells) {
498
507
  const value = cell.value;
499
508
  const side = value > 0 || (value === 0 && zeroPositive) ? "pos" : "neg";
500
- const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign);
509
+ const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign, barLabelDigits(cell, this.componentDataFormatDigits));
501
510
  labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative));
502
511
  }
503
512
  return labels;
@@ -1455,3 +1464,9 @@ export class BnTableRenderer {
1455
1464
  function barLabelMeasureScale(cell) {
1456
1465
  return cell.type === "percentpoint" ? 0.01 : cell.measureScale;
1457
1466
  }
1467
+ /** Fraction digits of the number cells of the column, so an absolute bar label prints like them. */
1468
+ function barLabelDigits(cell, digits) {
1469
+ if (cell.type === "percentpoint")
1470
+ return digits.percent;
1471
+ return cell.type === "decimal" ? digits.decimal : undefined;
1472
+ }
@@ -210,6 +210,9 @@ export class Table {
210
210
  * inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data
211
211
  * (and a relative variance with a zero reference) sort last.
212
212
  * <br /><br />
213
+ * A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays
214
+ * the last row of the group. Its label comes from the `REST` translation.
215
+ * <br /><br />
213
216
  * When set to ```auto```, order is detected from the dataset silently.
214
217
  */
215
218
  this.order = "category";
@@ -1339,7 +1342,7 @@ export class Table {
1339
1342
  render() {
1340
1343
  const fontStyles = this.getFontStyles();
1341
1344
  const effectiveFactor = this.getEffectiveScaleFactor();
1342
- return (h(Host, { key: '2f24deddc4e58f57ef27443a27b4706b5f1b90db', style: fontStyles }, h("div", { key: 'b6368e143f868d9c2a7ad8ec753a14813b60e197' }, h("bn-table-renderer", { key: '399b2dc8d5cf3e7a8093a9a486635ea4d1bb74b9', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
1345
+ return (h(Host, { key: '42974a4931f678c35e5c740bf6d630966368fb4b', style: fontStyles }, h("div", { key: '2c8f99a8bd155e2c93e55e9542090d04afe22a31' }, h("bn-table-renderer", { key: 'cae9e83bf297e730f12a8a390cbf279413c40b54', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
1343
1346
  }
1344
1347
  static get is() { return "bn-table"; }
1345
1348
  static get encapsulation() { return "shadow"; }
@@ -1814,7 +1817,7 @@ export class Table {
1814
1817
  "optional": false,
1815
1818
  "docs": {
1816
1819
  "tags": [],
1817
- "text": "Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them.\n<br /><br />\nvalues: <br />\n```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto```\n<br />\nor a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos```\n<br /><br />\nWith `interval=\"setname\"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts\nby that block only. Without a bucket the sum over all buckets is used.\n<br /><br />\nThe scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one.\nA plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows\ninside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data\n(and a relative variance with a zero reference) sort last.\n<br /><br />\nWhen set to ```auto```, order is detected from the dataset silently."
1820
+ "text": "Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them.\n<br /><br />\nvalues: <br />\n```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto```\n<br />\nor a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos```\n<br /><br />\nWith `interval=\"setname\"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts\nby that block only. Without a bucket the sum over all buckets is used.\n<br /><br />\nThe scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one.\nA plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows\ninside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data\n(and a relative variance with a zero reference) sort last.\n<br /><br />\nA data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays\nthe last row of the group. Its label comes from the `REST` translation.\n<br /><br />\nWhen set to ```auto```, order is detected from the dataset silently."
1818
1821
  },
1819
1822
  "getter": false,
1820
1823
  "setter": false,
@@ -53,9 +53,10 @@ export const PatternDefs = ({ styles }) => {
53
53
  /** Longest relative label that keeps all percent digits; a longer one drops digits so its gutter does not eat the pins. */
54
54
  const PIN_LABEL_CHARS = 7;
55
55
  /**
56
- * Formats a number for display with appropriate SI prefix.
56
+ * Formats a bar or pin label. An absolute value with `decimalDigits` prints like a number
57
+ * cell, without them it takes an SI suffix.
57
58
  */
58
- export function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0, percentSign = true) {
59
+ export function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0, percentSign = true, decimalDigits) {
59
60
  // IBCS prints a value that rounds to zero without a sign
60
61
  const signed = (text, zero) => (value > 0 && text !== zero ? "+" : "") + text;
61
62
  if (isRelative) {
@@ -73,6 +74,10 @@ export function formatValue(value, isRelative, measureScale = 1, locale, percent
73
74
  }
74
75
  // Absolute variance - apply measure scale and use SI prefixes
75
76
  const scaledValue = value / measureScale;
77
+ if (decimalDigits !== undefined) {
78
+ const number = (v) => Formatter.number(v, "decimal", decimalDigits, decimalDigits, 1, locale);
79
+ return signed(number(scaledValue), number(0));
80
+ }
76
81
  const absValue = Math.abs(scaledValue);
77
82
  let unit = 1;
78
83
  let suffix = "";
@@ -255,25 +260,28 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
255
260
  * exactly `columnWidthEm` em - see barColumnGeometry.ts.
256
261
  */
257
262
  const AbsoluteVarianceBar = (props) => {
258
- const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, columnWidthEm = 10, labelWidths, styles = DEFAULT_STYLES, } = props;
263
+ const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
259
264
  const s = styles.scaleFactor;
260
265
  const fs = styles.fontSize;
261
- const displayValue = formattedValue || formatValue(value, false, measureScale, locale);
266
+ const displayValue = formattedValue || formatValue(value, false, measureScale, locale, 0, true, decimalDigits);
262
267
  const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false));
263
- const { totalWidth, axisX, breakGap, overdriveZoneWidth, cutWidth, labelGap } = absoluteBarGeometry(columnWidthEm, styles.emPx, sides);
268
+ const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
269
+ const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
270
+ const geometry = absoluteBarGeometry(columnWidthEm, styles.emPx, sides, { neg, pos });
271
+ const { totalWidth, axisX, labelGap } = geometry;
272
+ const { breakGap, overdriveZoneWidth, cutWidth } = isPositive ? geometry.pos : geometry.neg;
264
273
  // Direct unit scaling via fontSize
265
274
  const scaledWidth = Math.abs(value) * styles.unitScaling * fs;
266
275
  // auto scaling puts the largest bar on the cut, float rounding must not turn it into an overdrive bar
267
276
  const isExtreme = scaledWidth - cutWidth > 1e-6;
268
277
  // Compute proportional overdrive width across the column
269
- const maxScaledWidth = columnStats.absMax * styles.unitScaling * fs;
278
+ const maxScaledWidth = (isPositive ? pos : neg) * styles.unitScaling * fs;
270
279
  const maxOverflow = Math.max(0, maxScaledWidth - cutWidth);
271
280
  const overflowAmount = Math.max(0, scaledWidth - cutWidth);
272
281
  const overdriveWidth = maxOverflow > 0 ? (overflowAmount / maxOverflow) * overdriveZoneWidth : 0;
273
282
  const padding = 2 * s;
274
283
  const barHeight = height - padding * 2;
275
284
  const barY = padding;
276
- const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
277
285
  // Get style based on column type (scenario vs variance)
278
286
  const look = getVarianceLook(scenario, styles);
279
287
  const sentimentStyle = getBarStyle(scenario, value, isPositiveGood, styles);
@@ -16,7 +16,7 @@ import { waterfallGeometry } from "../helper/barColumnGeometry";
16
16
  * guides marking their parent bar's extent.
17
17
  */
18
18
  export const WaterfallBar = (props) => {
19
- const { value, scenario, height, measureScale, locale, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, } = props;
19
+ const { value, scenario, height, measureScale, locale, decimalDigits, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, } = props;
20
20
  const s = styles.scaleFactor;
21
21
  const fs = styles.fontSize;
22
22
  const range = waterfall.max - waterfall.min;
@@ -38,7 +38,7 @@ export const WaterfallBar = (props) => {
38
38
  const fillValue = getBarFill(barStyle, getScenarioType(scenario));
39
39
  const { stroke: barStroke, strokeWidth: barStrokeWidth } = getBarStroke(barStyle);
40
40
  // Scenario values carry no variance sentiment - labels are unsigned per IBCS
41
- const displayValue = formatValue(value, waterfall.kind === "partof", measureScale, locale).replace(/^\+/, "");
41
+ const displayValue = formatValue(value, waterfall.kind === "partof", measureScale, locale, 0, true, decimalDigits).replace(/^\+/, "");
42
42
  const pointsLeft = endX < startX;
43
43
  const labelX = pointsLeft ? barX - labelGap : barX + barWidth + labelGap;
44
44
  const labelAnchor = pointsLeft ? "end" : "start";
@@ -235,7 +235,8 @@ export class DataQuery {
235
235
  /** Generates a GROUPHEAD row used as a visual header when row grouping is active. */
236
236
  createGroupHeaderRow(rowGroupEntry, querys) {
237
237
  // Generates GroupHeader Row
238
- if (true === this.config.grouped) {
238
+ // Without a title the group sum row alone closes the group; only a list has no sum row and keeps the head as gap
239
+ if (true === this.config.grouped && (this.config.showGroupTitle || !this.hasGroupSum())) {
239
240
  const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
240
241
  const title = rowGroupEntry.rowGroup === "" ? this.bind(BLANK_BUCKET_LABEL) : rowGroup;
241
242
  const groupTitle = this.config.showGroupTitle ? `,${title} as ${QueryColumnNames.CATEGORY}` : "";
@@ -247,14 +248,16 @@ export class DataQuery {
247
248
  GROUP BY '1'`);
248
249
  }
249
250
  }
251
+ hasGroupSum() {
252
+ return (TableType.SUM === this.config.type ||
253
+ TableType.SUMNOTOTAL === this.config.type ||
254
+ TableType.OPT === this.config.type ||
255
+ TableType.OPTNOTOTAL === this.config.type);
256
+ }
250
257
  /** Generates a GROUP_SUM row that aggregates all entries within a single row group. */
251
258
  createGroupSumRow(querys, groupSumQuery, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order) {
252
259
  // Generates SUM Row; sumsup all rows of group
253
- if (true === this.config.grouped &&
254
- (TableType.SUM === this.config.type ||
255
- TableType.SUMNOTOTAL === this.config.type ||
256
- TableType.OPT === this.config.type ||
257
- TableType.OPTNOTOTAL === this.config.type)) {
260
+ if (true === this.config.grouped && this.hasGroupSum()) {
258
261
  const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
259
262
  querys.push(`SELECT ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
260
263
  '=' as ${QueryColumnNames.OPERATION},
@@ -562,17 +565,19 @@ export class DataQuery {
562
565
  const entryRowsRaw = exec(`SELECT ${groups.select()}, __interval ${scenarios.length > 0 ? ",".concat(scenarios) : ""}
563
566
  FROM ${bucketSource}
564
567
  GROUP BY ${groups}, __interval`);
568
+ // only the generated REST row has restRowGroup; a data row with the category REST keeps its own values
569
+ const isGeneratedRest = (row) => row.type === "ENTRY" && row.restRowGroup != null;
565
570
  // REST rows first: the math needs the raw (not yet finalized) entry aliases
566
571
  if (this.config.limit > 0) {
567
572
  for (let segmentIndex = 0; segmentIndex < res.length; segmentIndex++) {
568
- const restRow = res[segmentIndex].find((row) => row.type === "ENTRY" && row.category === "REST");
573
+ const restRow = res[segmentIndex].find(isGeneratedRest);
569
574
  if (!restRow) {
570
575
  continue;
571
576
  }
572
577
  // nearest preceding segment holding the displayed ENTRY rows
573
578
  let entrySegment;
574
579
  for (let i = segmentIndex - 1; i >= 0 && !entrySegment; i--) {
575
- const candidate = res[i].filter((row) => row.type === "ENTRY" && row.category !== "REST");
580
+ const candidate = res[i].filter((row) => row.type === "ENTRY" && !isGeneratedRest(row));
576
581
  if (candidate.length > 0) {
577
582
  entrySegment = candidate;
578
583
  }
@@ -610,7 +615,7 @@ export class DataQuery {
610
615
  finalizeBucketRow(entryRow);
611
616
  for (const segment of res) {
612
617
  for (const row of segment) {
613
- if (row.type !== "ENTRY" || row.category === "REST" || row.category !== entryRow.category) {
618
+ if (row.type !== "ENTRY" || isGeneratedRest(row) || row.category !== entryRow.category) {
614
619
  continue;
615
620
  }
616
621
  if (this.config.grouped && row.rowGroup !== entryRow.rowGroup) {
@@ -884,11 +889,20 @@ export class DataQuery {
884
889
  }
885
890
  });
886
891
  this.sortSelect = [...sortKeys.values()].map((key) => `, ${key}`).join("");
892
+ // a data row with the reserved category REST stays last in its group when the rows are sorted by value
893
+ const sortsByValue = orderComponent.hierarchy.some((column) => {
894
+ var _a;
895
+ const kind = (_a = parseOrderToken(column)) === null || _a === void 0 ? void 0 : _a.kind;
896
+ return kind === "scenario" || kind === "variance";
897
+ });
898
+ if (sortsByValue) {
899
+ this.sortSelect += `, CASE WHEN ${QueryColumnNames.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`;
900
+ }
887
901
  // rows without a value sort last in both directions
888
902
  const orderBy = (column, i, direction) => sortKeys.has(i) ? `__sortnull${i} asc, __sort${i} ${direction}` : `${column} ${direction}`;
889
903
  const base = orderComponent.hierarchy.map((column, i) => orderBy(column, i, orderComponent.direction)).toString();
890
904
  const inverted = orderComponent.hierarchy.map((column, i) => orderBy(column, i, inverse)).toString();
891
- return [base, inverted];
905
+ return sortsByValue ? [`__sortrest asc, ${base}`, `__sortrest desc, ${inverted}`] : [base, inverted];
892
906
  }
893
907
  /**
894
908
  * Sort key `__sort<i>` of a scenario or variance order token, as printed in an entry cell