@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.
- package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/{p-f74760d7.entry.js → p-e15ccc4a.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +105 -36
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +20 -5
- package/dist/collection/components/bn-table/bn-table.js +5 -2
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +15 -7
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +2 -2
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +24 -10
- package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +9 -3
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +31 -8
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/p--HIZm_2v.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +105 -36
- package/dist/types/components/bn-table/bn-table.d.ts +3 -0
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +5 -2
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +1 -0
- package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +5 -2
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +15 -6
- package/dist/types/components.d.ts +2 -2
- package/package.json +1 -1
- package/dist/components/p-CHQ67u2G.js +0 -1
|
@@ -26917,6 +26917,9 @@ const Table$1 = class Table {
|
|
|
26917
26917
|
* inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data
|
|
26918
26918
|
* (and a relative variance with a zero reference) sort last.
|
|
26919
26919
|
* <br /><br />
|
|
26920
|
+
* A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays
|
|
26921
|
+
* the last row of the group. Its label comes from the `REST` translation.
|
|
26922
|
+
* <br /><br />
|
|
26920
26923
|
* When set to ```auto```, order is detected from the dataset silently.
|
|
26921
26924
|
*/
|
|
26922
26925
|
this.order = "category";
|
|
@@ -28046,7 +28049,7 @@ const Table$1 = class Table {
|
|
|
28046
28049
|
render() {
|
|
28047
28050
|
const fontStyles = this.getFontStyles();
|
|
28048
28051
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
28049
|
-
return (h(Host, { key: '
|
|
28052
|
+
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 }))));
|
|
28050
28053
|
}
|
|
28051
28054
|
get element() { return getElement(this); }
|
|
28052
28055
|
static get watchers() { return {
|
|
@@ -28421,20 +28424,43 @@ function pinLabelsFit(widthEm, emPx, labels, headSize) {
|
|
|
28421
28424
|
const { sides, neg, pos } = sideNeeds(labels, headSize / 2, LABEL_GAP_EM * emPx);
|
|
28422
28425
|
return neg + pos + sides * minExtent(totalWidth, emPx, sides) <= totalWidth + 1e-6;
|
|
28423
28426
|
}
|
|
28424
|
-
function
|
|
28425
|
-
const totalWidth = contentWidth(widthEm, emPx);
|
|
28426
|
-
const labelGap = LABEL_GAP_EM * emPx;
|
|
28427
|
-
// a variance bar starts at the outer edge of the thick axis
|
|
28428
|
-
const { extent: maxBarWidth, axisX } = splitSides(totalWidth, labels, (VARIANCE_AXIS_EM * emPx) / 2, labelGap);
|
|
28429
|
-
const breakGap = Math.min(BREAK_GAP_EM * emPx, maxBarWidth * 0.2);
|
|
28427
|
+
function barSide(maxBarWidth, breakGap) {
|
|
28430
28428
|
const overdriveZoneWidth = maxBarWidth * OVERDRIVE_FRACTION;
|
|
28431
28429
|
return {
|
|
28432
|
-
totalWidth,
|
|
28433
28430
|
maxBarWidth,
|
|
28434
|
-
axisX,
|
|
28435
28431
|
breakGap,
|
|
28436
28432
|
overdriveZoneWidth,
|
|
28437
28433
|
cutWidth: Math.max(0, maxBarWidth - breakGap - overdriveZoneWidth),
|
|
28434
|
+
};
|
|
28435
|
+
}
|
|
28436
|
+
/**
|
|
28437
|
+
* `sideMax` is the largest absolute value per side of the axis. With it, the bar room is
|
|
28438
|
+
* split so the uncut bar length of each side is in that ratio: the axis sits where the
|
|
28439
|
+
* values need it, at any scale. Without it, both sides get the same extent.
|
|
28440
|
+
*/
|
|
28441
|
+
function absoluteBarGeometry(widthEm, emPx, labels, sideMax) {
|
|
28442
|
+
var _a, _b;
|
|
28443
|
+
const totalWidth = contentWidth(widthEm, emPx);
|
|
28444
|
+
const labelGap = LABEL_GAP_EM * emPx;
|
|
28445
|
+
// a variance bar starts at the outer edge of the thick axis
|
|
28446
|
+
const { extent, axisX } = splitSides(totalWidth, labels, (VARIANCE_AXIS_EM * emPx) / 2, labelGap);
|
|
28447
|
+
const breakGap = Math.min(BREAK_GAP_EM * emPx, extent * 0.2);
|
|
28448
|
+
const hasNeg = labels.neg !== undefined;
|
|
28449
|
+
const hasPos = labels.pos !== undefined || !hasNeg;
|
|
28450
|
+
let neg = hasNeg ? extent : 0;
|
|
28451
|
+
const maxNeg = Math.max(0, (_a = sideMax === null || sideMax === void 0 ? void 0 : sideMax.neg) !== null && _a !== void 0 ? _a : 0);
|
|
28452
|
+
const maxPos = Math.max(0, (_b = sideMax === null || sideMax === void 0 ? void 0 : sideMax.pos) !== null && _b !== void 0 ? _b : 0);
|
|
28453
|
+
if (hasNeg && hasPos && maxNeg + maxPos > 0) {
|
|
28454
|
+
// every side keeps its break gap and overdrive stub, only the uncut length follows the values
|
|
28455
|
+
const uncut = 2 * extent * (1 - OVERDRIVE_FRACTION) - 2 * breakGap;
|
|
28456
|
+
neg = (breakGap + (uncut * maxNeg) / (maxNeg + maxPos)) / (1 - OVERDRIVE_FRACTION);
|
|
28457
|
+
}
|
|
28458
|
+
const pos = hasPos ? (hasNeg ? 2 * extent - neg : extent) : 0;
|
|
28459
|
+
return {
|
|
28460
|
+
totalWidth,
|
|
28461
|
+
neg: barSide(neg, breakGap),
|
|
28462
|
+
pos: barSide(pos, breakGap),
|
|
28463
|
+
axisX: hasNeg ? axisX - extent + neg : 0,
|
|
28438
28464
|
labelGap,
|
|
28439
28465
|
};
|
|
28440
28466
|
}
|
|
@@ -28541,9 +28567,10 @@ const PatternDefs = ({ styles }) => {
|
|
|
28541
28567
|
/** Longest relative label that keeps all percent digits; a longer one drops digits so its gutter does not eat the pins. */
|
|
28542
28568
|
const PIN_LABEL_CHARS = 7;
|
|
28543
28569
|
/**
|
|
28544
|
-
* Formats a
|
|
28570
|
+
* Formats a bar or pin label. An absolute value with `decimalDigits` prints like a number
|
|
28571
|
+
* cell, without them it takes an SI suffix.
|
|
28545
28572
|
*/
|
|
28546
|
-
function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0, percentSign = true) {
|
|
28573
|
+
function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0, percentSign = true, decimalDigits) {
|
|
28547
28574
|
// IBCS prints a value that rounds to zero without a sign
|
|
28548
28575
|
const signed = (text, zero) => (value > 0 && text !== zero ? "+" : "") + text;
|
|
28549
28576
|
if (isRelative) {
|
|
@@ -28561,6 +28588,10 @@ function formatValue(value, isRelative, measureScale = 1, locale, percentDigits
|
|
|
28561
28588
|
}
|
|
28562
28589
|
// Absolute variance - apply measure scale and use SI prefixes
|
|
28563
28590
|
const scaledValue = value / measureScale;
|
|
28591
|
+
if (decimalDigits !== undefined) {
|
|
28592
|
+
const number = (v) => Formatter.number(v, "decimal", decimalDigits, decimalDigits, 1, locale);
|
|
28593
|
+
return signed(number(scaledValue), number(0));
|
|
28594
|
+
}
|
|
28564
28595
|
const absValue = Math.abs(scaledValue);
|
|
28565
28596
|
let unit = 1;
|
|
28566
28597
|
let suffix = "";
|
|
@@ -28743,25 +28774,28 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
|
|
|
28743
28774
|
* exactly `columnWidthEm` em - see barColumnGeometry.ts.
|
|
28744
28775
|
*/
|
|
28745
28776
|
const AbsoluteVarianceBar = (props) => {
|
|
28746
|
-
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, columnWidthEm = 10, labelWidths, styles = DEFAULT_STYLES, } = props;
|
|
28777
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
|
|
28747
28778
|
const s = styles.scaleFactor;
|
|
28748
28779
|
const fs = styles.fontSize;
|
|
28749
|
-
const displayValue = formattedValue || formatValue(value, false, measureScale, locale);
|
|
28780
|
+
const displayValue = formattedValue || formatValue(value, false, measureScale, locale, 0, true, decimalDigits);
|
|
28750
28781
|
const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false));
|
|
28751
|
-
const
|
|
28782
|
+
const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
|
|
28783
|
+
const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
|
|
28784
|
+
const geometry = absoluteBarGeometry(columnWidthEm, styles.emPx, sides, { neg, pos });
|
|
28785
|
+
const { totalWidth, axisX, labelGap } = geometry;
|
|
28786
|
+
const { breakGap, overdriveZoneWidth, cutWidth } = isPositive ? geometry.pos : geometry.neg;
|
|
28752
28787
|
// Direct unit scaling via fontSize
|
|
28753
28788
|
const scaledWidth = Math.abs(value) * styles.unitScaling * fs;
|
|
28754
28789
|
// auto scaling puts the largest bar on the cut, float rounding must not turn it into an overdrive bar
|
|
28755
28790
|
const isExtreme = scaledWidth - cutWidth > 1e-6;
|
|
28756
28791
|
// Compute proportional overdrive width across the column
|
|
28757
|
-
const maxScaledWidth =
|
|
28792
|
+
const maxScaledWidth = (isPositive ? pos : neg) * styles.unitScaling * fs;
|
|
28758
28793
|
const maxOverflow = Math.max(0, maxScaledWidth - cutWidth);
|
|
28759
28794
|
const overflowAmount = Math.max(0, scaledWidth - cutWidth);
|
|
28760
28795
|
const overdriveWidth = maxOverflow > 0 ? (overflowAmount / maxOverflow) * overdriveZoneWidth : 0;
|
|
28761
28796
|
const padding = 2 * s;
|
|
28762
28797
|
const barHeight = height - padding * 2;
|
|
28763
28798
|
const barY = padding;
|
|
28764
|
-
const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
|
|
28765
28799
|
// Get style based on column type (scenario vs variance)
|
|
28766
28800
|
const look = getVarianceLook(scenario, styles);
|
|
28767
28801
|
const sentimentStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
@@ -28869,7 +28903,7 @@ const CellBarChart = (props) => {
|
|
|
28869
28903
|
* guides marking their parent bar's extent.
|
|
28870
28904
|
*/
|
|
28871
28905
|
const WaterfallBar = (props) => {
|
|
28872
|
-
const { value, scenario, height, measureScale, locale, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, } = props;
|
|
28906
|
+
const { value, scenario, height, measureScale, locale, decimalDigits, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, } = props;
|
|
28873
28907
|
const s = styles.scaleFactor;
|
|
28874
28908
|
const fs = styles.fontSize;
|
|
28875
28909
|
const range = waterfall.max - waterfall.min;
|
|
@@ -28891,7 +28925,7 @@ const WaterfallBar = (props) => {
|
|
|
28891
28925
|
const fillValue = getBarFill(barStyle, getScenarioType(scenario));
|
|
28892
28926
|
const { stroke: barStroke, strokeWidth: barStrokeWidth } = getBarStroke(barStyle);
|
|
28893
28927
|
// Scenario values carry no variance sentiment - labels are unsigned per IBCS
|
|
28894
|
-
const displayValue = formatValue(value, waterfall.kind === "partof", measureScale, locale).replace(/^\+/, "");
|
|
28928
|
+
const displayValue = formatValue(value, waterfall.kind === "partof", measureScale, locale, 0, true, decimalDigits).replace(/^\+/, "");
|
|
28895
28929
|
const pointsLeft = endX < startX;
|
|
28896
28930
|
const labelX = pointsLeft ? barX - labelGap : barX + barWidth + labelGap;
|
|
28897
28931
|
const labelAnchor = pointsLeft ? "end" : "start";
|
|
@@ -29166,7 +29200,8 @@ class DataQuery {
|
|
|
29166
29200
|
/** Generates a GROUPHEAD row used as a visual header when row grouping is active. */
|
|
29167
29201
|
createGroupHeaderRow(rowGroupEntry, querys) {
|
|
29168
29202
|
// Generates GroupHeader Row
|
|
29169
|
-
|
|
29203
|
+
// Without a title the group sum row alone closes the group; only a list has no sum row and keeps the head as gap
|
|
29204
|
+
if (true === this.config.grouped && (this.config.showGroupTitle || !this.hasGroupSum())) {
|
|
29170
29205
|
const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
|
|
29171
29206
|
const title = rowGroupEntry.rowGroup === "" ? this.bind(BLANK_BUCKET_LABEL) : rowGroup;
|
|
29172
29207
|
const groupTitle = this.config.showGroupTitle ? `,${title} as ${QueryColumnNames.CATEGORY}` : "";
|
|
@@ -29178,14 +29213,16 @@ class DataQuery {
|
|
|
29178
29213
|
GROUP BY '1'`);
|
|
29179
29214
|
}
|
|
29180
29215
|
}
|
|
29216
|
+
hasGroupSum() {
|
|
29217
|
+
return (TableType.SUM === this.config.type ||
|
|
29218
|
+
TableType.SUMNOTOTAL === this.config.type ||
|
|
29219
|
+
TableType.OPT === this.config.type ||
|
|
29220
|
+
TableType.OPTNOTOTAL === this.config.type);
|
|
29221
|
+
}
|
|
29181
29222
|
/** Generates a GROUP_SUM row that aggregates all entries within a single row group. */
|
|
29182
29223
|
createGroupSumRow(querys, groupSumQuery, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order) {
|
|
29183
29224
|
// Generates SUM Row; sumsup all rows of group
|
|
29184
|
-
if (true === this.config.grouped &&
|
|
29185
|
-
(TableType.SUM === this.config.type ||
|
|
29186
|
-
TableType.SUMNOTOTAL === this.config.type ||
|
|
29187
|
-
TableType.OPT === this.config.type ||
|
|
29188
|
-
TableType.OPTNOTOTAL === this.config.type)) {
|
|
29225
|
+
if (true === this.config.grouped && this.hasGroupSum()) {
|
|
29189
29226
|
const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
|
|
29190
29227
|
querys.push(`SELECT ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
|
|
29191
29228
|
'=' as ${QueryColumnNames.OPERATION},
|
|
@@ -29493,17 +29530,19 @@ class DataQuery {
|
|
|
29493
29530
|
const entryRowsRaw = exec(`SELECT ${groups.select()}, __interval ${scenarios.length > 0 ? ",".concat(scenarios) : ""}
|
|
29494
29531
|
FROM ${bucketSource}
|
|
29495
29532
|
GROUP BY ${groups}, __interval`);
|
|
29533
|
+
// only the generated REST row has restRowGroup; a data row with the category REST keeps its own values
|
|
29534
|
+
const isGeneratedRest = (row) => row.type === "ENTRY" && row.restRowGroup != null;
|
|
29496
29535
|
// REST rows first: the math needs the raw (not yet finalized) entry aliases
|
|
29497
29536
|
if (this.config.limit > 0) {
|
|
29498
29537
|
for (let segmentIndex = 0; segmentIndex < res.length; segmentIndex++) {
|
|
29499
|
-
const restRow = res[segmentIndex].find(
|
|
29538
|
+
const restRow = res[segmentIndex].find(isGeneratedRest);
|
|
29500
29539
|
if (!restRow) {
|
|
29501
29540
|
continue;
|
|
29502
29541
|
}
|
|
29503
29542
|
// nearest preceding segment holding the displayed ENTRY rows
|
|
29504
29543
|
let entrySegment;
|
|
29505
29544
|
for (let i = segmentIndex - 1; i >= 0 && !entrySegment; i--) {
|
|
29506
|
-
const candidate = res[i].filter((row) => row.type === "ENTRY" && row
|
|
29545
|
+
const candidate = res[i].filter((row) => row.type === "ENTRY" && !isGeneratedRest(row));
|
|
29507
29546
|
if (candidate.length > 0) {
|
|
29508
29547
|
entrySegment = candidate;
|
|
29509
29548
|
}
|
|
@@ -29541,7 +29580,7 @@ class DataQuery {
|
|
|
29541
29580
|
finalizeBucketRow(entryRow);
|
|
29542
29581
|
for (const segment of res) {
|
|
29543
29582
|
for (const row of segment) {
|
|
29544
|
-
if (row.type !== "ENTRY" || row
|
|
29583
|
+
if (row.type !== "ENTRY" || isGeneratedRest(row) || row.category !== entryRow.category) {
|
|
29545
29584
|
continue;
|
|
29546
29585
|
}
|
|
29547
29586
|
if (this.config.grouped && row.rowGroup !== entryRow.rowGroup) {
|
|
@@ -29815,11 +29854,20 @@ class DataQuery {
|
|
|
29815
29854
|
}
|
|
29816
29855
|
});
|
|
29817
29856
|
this.sortSelect = [...sortKeys.values()].map((key) => `, ${key}`).join("");
|
|
29857
|
+
// a data row with the reserved category REST stays last in its group when the rows are sorted by value
|
|
29858
|
+
const sortsByValue = orderComponent.hierarchy.some((column) => {
|
|
29859
|
+
var _a;
|
|
29860
|
+
const kind = (_a = parseOrderToken(column)) === null || _a === void 0 ? void 0 : _a.kind;
|
|
29861
|
+
return kind === "scenario" || kind === "variance";
|
|
29862
|
+
});
|
|
29863
|
+
if (sortsByValue) {
|
|
29864
|
+
this.sortSelect += `, CASE WHEN ${QueryColumnNames.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`;
|
|
29865
|
+
}
|
|
29818
29866
|
// rows without a value sort last in both directions
|
|
29819
29867
|
const orderBy = (column, i, direction) => sortKeys.has(i) ? `__sortnull${i} asc, __sort${i} ${direction}` : `${column} ${direction}`;
|
|
29820
29868
|
const base = orderComponent.hierarchy.map((column, i) => orderBy(column, i, orderComponent.direction)).toString();
|
|
29821
29869
|
const inverted = orderComponent.hierarchy.map((column, i) => orderBy(column, i, inverse)).toString();
|
|
29822
|
-
return [base, inverted];
|
|
29870
|
+
return sortsByValue ? [`__sortrest asc, ${base}`, `__sortrest desc, ${inverted}`] : [base, inverted];
|
|
29823
29871
|
}
|
|
29824
29872
|
/**
|
|
29825
29873
|
* Sort key `__sort<i>` of a scenario or variance order token, as printed in an entry cell
|
|
@@ -30162,13 +30210,16 @@ function signedValue(row, column, tableType) {
|
|
|
30162
30210
|
* segmented query result once per column in display order.
|
|
30163
30211
|
*
|
|
30164
30212
|
* - ENTRY rows (incl. REST) cascade from the running total by their signed value.
|
|
30165
|
-
* - SUM / GROUP_SUM rows anchor at zero
|
|
30213
|
+
* - SUM / GROUP_SUM rows anchor at zero. A SUM row resets the running total to its
|
|
30214
|
+
* value, a GROUP_SUM row resets it to zero.
|
|
30166
30215
|
* - DRILLELEMENT (thereof) rows form a sub-cascade from their parent bar's start in
|
|
30167
30216
|
* the parent's direction; the running total is untouched.
|
|
30168
30217
|
* - PARTELEMENT (partof) rows cascade a `share * parent width` segment the same way.
|
|
30169
30218
|
* Note: the share denominator is the group sum (or SUM_TOTAL when ungrouped) per
|
|
30170
30219
|
* `createPartOfDrillRows`, not literally the parent row's value.
|
|
30171
|
-
* - GROUPHEAD
|
|
30220
|
+
* - GROUPHEAD rows get no bar and restart the running total at zero: every row group
|
|
30221
|
+
* is its own cascade that ends at its GROUP_SUM.
|
|
30222
|
+
* - NaN rows get no bar; a NaN parent orphans its drill children.
|
|
30172
30223
|
*
|
|
30173
30224
|
* @param queryData - Segmented result rows from DataQuery.execute().
|
|
30174
30225
|
* @param columns - Plain scenario column keys (ac1..pl4); no `##` composite keys.
|
|
@@ -30189,6 +30240,8 @@ function computeWaterfall(queryData, columns, tableType) {
|
|
|
30189
30240
|
for (const row of groupData) {
|
|
30190
30241
|
const type = row[QueryColumnNames.TYPE];
|
|
30191
30242
|
if (type === TableRowType.GROUPHEAD) {
|
|
30243
|
+
// a group sum only totals its own rows, so the cascade must not carry over
|
|
30244
|
+
running = 0;
|
|
30192
30245
|
lastParent = undefined;
|
|
30193
30246
|
continue;
|
|
30194
30247
|
}
|
|
@@ -30211,7 +30264,8 @@ function computeWaterfall(queryData, columns, tableType) {
|
|
|
30211
30264
|
emit(row, { start: 0, end: value, min: 0, max: 0, kind: "anchor" });
|
|
30212
30265
|
lastParent = { start: 0, end: value };
|
|
30213
30266
|
subCursor = 0;
|
|
30214
|
-
|
|
30267
|
+
// a group sum closes its group (there may be no GROUPHEAD row when the title is hidden)
|
|
30268
|
+
running = type === TableRowType.GROUPSUM ? 0 : value;
|
|
30215
30269
|
}
|
|
30216
30270
|
else if (type === TableRowType.DRILLELEMENT) {
|
|
30217
30271
|
if (value === null || lastParent === undefined) {
|
|
@@ -31477,7 +31531,9 @@ const BnTableRenderer = class {
|
|
|
31477
31531
|
: {})), cell.prefix != null ? (h("span", { class: cell.cssStyle + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
|
|
31478
31532
|
cell.columnStats &&
|
|
31479
31533
|
cell.value !== NOT_AVAILABLE &&
|
|
31480
|
-
|
|
31534
|
+
// an untitled group head is only a gap between list groups, a bar cell would print "-" in it
|
|
31535
|
+
(this.showGroupTitle || row.type !== TableRowType.HEADER) &&
|
|
31536
|
+
(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))));
|
|
31481
31537
|
})))))));
|
|
31482
31538
|
};
|
|
31483
31539
|
return h(Host, { class: { "no-data": ((_a = this.table) === null || _a === void 0 ? void 0 : _a.hasNoData()) === true } }, helper());
|
|
@@ -31653,14 +31709,21 @@ const BnTableRenderer = class {
|
|
|
31653
31709
|
* One scaling for all columns, so it is the smallest that fits every column.
|
|
31654
31710
|
*/
|
|
31655
31711
|
autoUnitScaling() {
|
|
31712
|
+
var _a;
|
|
31656
31713
|
const emPx = this.emPx();
|
|
31657
31714
|
const fs = emPx * BAR_LABEL_FONT_RATIO;
|
|
31658
31715
|
let scaling = Infinity;
|
|
31659
|
-
for (const { isRelative, absMax, labels } of this.barColumnLayouts.values()) {
|
|
31716
|
+
for (const { isRelative, absMax, labels, sideMax } of this.barColumnLayouts.values()) {
|
|
31660
31717
|
if (isRelative || absMax <= 0)
|
|
31661
31718
|
continue;
|
|
31662
|
-
const
|
|
31663
|
-
|
|
31719
|
+
const geometry = absoluteBarGeometry(this.barColumnMaxWidth, emPx, labels, sideMax);
|
|
31720
|
+
for (const side of ["neg", "pos"]) {
|
|
31721
|
+
const max = (_a = sideMax[side]) !== null && _a !== void 0 ? _a : 0;
|
|
31722
|
+
if (max <= 0)
|
|
31723
|
+
continue;
|
|
31724
|
+
const { maxBarWidth, cutWidth } = geometry[side];
|
|
31725
|
+
scaling = Math.min(scaling, Math.min(maxBarWidth * 0.8, cutWidth) / (max * fs));
|
|
31726
|
+
}
|
|
31664
31727
|
}
|
|
31665
31728
|
return Number.isFinite(scaling) && fs > 0 ? scaling : 0.01;
|
|
31666
31729
|
}
|
|
@@ -31725,7 +31788,7 @@ const BnTableRenderer = class {
|
|
|
31725
31788
|
for (const cell of cells) {
|
|
31726
31789
|
const value = cell.value;
|
|
31727
31790
|
const side = value > 0 || (value === 0 && zeroPositive) ? "pos" : "neg";
|
|
31728
|
-
const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign);
|
|
31791
|
+
const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign, barLabelDigits(cell, this.componentDataFormatDigits));
|
|
31729
31792
|
labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative));
|
|
31730
31793
|
}
|
|
31731
31794
|
return labels;
|
|
@@ -31758,6 +31821,12 @@ const BnTableRenderer = class {
|
|
|
31758
31821
|
function barLabelMeasureScale(cell) {
|
|
31759
31822
|
return cell.type === "percentpoint" ? 0.01 : cell.measureScale;
|
|
31760
31823
|
}
|
|
31824
|
+
/** Fraction digits of the number cells of the column, so an absolute bar label prints like them. */
|
|
31825
|
+
function barLabelDigits(cell, digits) {
|
|
31826
|
+
if (cell.type === "percentpoint")
|
|
31827
|
+
return digits.percent;
|
|
31828
|
+
return cell.type === "decimal" ? digits.decimal : undefined;
|
|
31829
|
+
}
|
|
31761
31830
|
BnTableRenderer.style = bnTableRendererCss();
|
|
31762
31831
|
|
|
31763
31832
|
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)}`;
|
|
@@ -327,6 +327,9 @@ export declare class Table {
|
|
|
327
327
|
* inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data
|
|
328
328
|
* (and a relative variance with a zero reference) sort last.
|
|
329
329
|
* <br /><br />
|
|
330
|
+
* A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays
|
|
331
|
+
* the last row of the group. Its label comes from the `REST` translation.
|
|
332
|
+
* <br /><br />
|
|
330
333
|
* When set to ```auto```, order is detected from the dataset silently.
|
|
331
334
|
*/
|
|
332
335
|
order: string;
|
|
@@ -43,6 +43,8 @@ export interface CellBarChartProps {
|
|
|
43
43
|
measureScale?: number;
|
|
44
44
|
locale?: string;
|
|
45
45
|
percentDigits?: number;
|
|
46
|
+
/** Fraction digits of an absolute label, as in the number cells; without it the label takes an SI suffix. */
|
|
47
|
+
decimalDigits?: number;
|
|
46
48
|
/** False drops the % of a relative label, for a column too narrow for it. */
|
|
47
49
|
percentSign?: boolean;
|
|
48
50
|
/** Total column width in table em - see barColumnGeometry.ts. */
|
|
@@ -62,9 +64,10 @@ export declare const PatternDefs: FunctionalComponent<{
|
|
|
62
64
|
styles: CellBarChartStyles;
|
|
63
65
|
}>;
|
|
64
66
|
/**
|
|
65
|
-
* Formats a
|
|
67
|
+
* Formats a bar or pin label. An absolute value with `decimalDigits` prints like a number
|
|
68
|
+
* cell, without them it takes an SI suffix.
|
|
66
69
|
*/
|
|
67
|
-
export declare function formatValue(value: number, isRelative: boolean, measureScale?: number, locale?: string, percentDigits?: number, percentSign?: boolean): string;
|
|
70
|
+
export declare function formatValue(value: number, isRelative: boolean, measureScale?: number, locale?: string, percentDigits?: number, percentSign?: boolean, decimalDigits?: number): string;
|
|
68
71
|
/**
|
|
69
72
|
* Gets the scenario type from the column name (ac, pp, fc, pl).
|
|
70
73
|
*/
|
|
@@ -66,6 +66,7 @@ export declare class DataQuery {
|
|
|
66
66
|
private createDataRow;
|
|
67
67
|
/** Generates a GROUPHEAD row used as a visual header when row grouping is active. */
|
|
68
68
|
private createGroupHeaderRow;
|
|
69
|
+
private hasGroupSum;
|
|
69
70
|
/** Generates a GROUP_SUM row that aggregates all entries within a single row group. */
|
|
70
71
|
private createGroupSumRow;
|
|
71
72
|
/** Generates a total SUM row across all groups (only for SUM / OPT table types). */
|
|
@@ -40,13 +40,16 @@ export declare function hasGroupingStructure(queryData: DataQueryResultRow[][]):
|
|
|
40
40
|
* segmented query result once per column in display order.
|
|
41
41
|
*
|
|
42
42
|
* - ENTRY rows (incl. REST) cascade from the running total by their signed value.
|
|
43
|
-
* - SUM / GROUP_SUM rows anchor at zero
|
|
43
|
+
* - SUM / GROUP_SUM rows anchor at zero. A SUM row resets the running total to its
|
|
44
|
+
* value, a GROUP_SUM row resets it to zero.
|
|
44
45
|
* - DRILLELEMENT (thereof) rows form a sub-cascade from their parent bar's start in
|
|
45
46
|
* the parent's direction; the running total is untouched.
|
|
46
47
|
* - PARTELEMENT (partof) rows cascade a `share * parent width` segment the same way.
|
|
47
48
|
* Note: the share denominator is the group sum (or SUM_TOTAL when ungrouped) per
|
|
48
49
|
* `createPartOfDrillRows`, not literally the parent row's value.
|
|
49
|
-
* - GROUPHEAD
|
|
50
|
+
* - GROUPHEAD rows get no bar and restart the running total at zero: every row group
|
|
51
|
+
* is its own cascade that ends at its GROUP_SUM.
|
|
52
|
+
* - NaN rows get no bar; a NaN parent orphans its drill children.
|
|
50
53
|
*
|
|
51
54
|
* @param queryData - Segmented result rows from DataQuery.execute().
|
|
52
55
|
* @param columns - Plain scenario column keys (ac1..pl4); no `##` composite keys.
|
|
@@ -32,20 +32,29 @@ export interface SideLabels {
|
|
|
32
32
|
}
|
|
33
33
|
/** True when the labels fit beside pins of at least the minimum extent; else the caller drops digits. */
|
|
34
34
|
export declare function pinLabelsFit(widthEm: number, emPx: number, labels: SideLabels, headSize: number): boolean;
|
|
35
|
-
export interface
|
|
36
|
-
/**
|
|
37
|
-
totalWidth: number;
|
|
38
|
-
/** Max bar extent on one side of the axis. */
|
|
35
|
+
export interface BarSide {
|
|
36
|
+
/** Max bar extent on this side of the axis. */
|
|
39
37
|
maxBarWidth: number;
|
|
40
|
-
axisX: number;
|
|
41
38
|
breakGap: number;
|
|
42
39
|
overdriveZoneWidth: number;
|
|
43
40
|
/** Bar length above which the overdrive break kicks in. */
|
|
44
41
|
cutWidth: number;
|
|
42
|
+
}
|
|
43
|
+
export interface AbsoluteBarGeometry {
|
|
44
|
+
/** SVG width - the cell's content box. */
|
|
45
|
+
totalWidth: number;
|
|
46
|
+
neg: BarSide;
|
|
47
|
+
pos: BarSide;
|
|
48
|
+
axisX: number;
|
|
45
49
|
/** Gap between the bar end and its value label. */
|
|
46
50
|
labelGap: number;
|
|
47
51
|
}
|
|
48
|
-
|
|
52
|
+
/**
|
|
53
|
+
* `sideMax` is the largest absolute value per side of the axis. With it, the bar room is
|
|
54
|
+
* split so the uncut bar length of each side is in that ratio: the axis sits where the
|
|
55
|
+
* values need it, at any scale. Without it, both sides get the same extent.
|
|
56
|
+
*/
|
|
57
|
+
export declare function absoluteBarGeometry(widthEm: number, emPx: number, labels: SideLabels, sideMax?: SideLabels): AbsoluteBarGeometry;
|
|
49
58
|
export interface RelativePinGeometry {
|
|
50
59
|
totalWidth: number;
|
|
51
60
|
/** Max pin extent of the longer side, to the centre of the head or the base of the arrow tip. */
|
|
@@ -1759,7 +1759,7 @@ export namespace Components {
|
|
|
1759
1759
|
*/
|
|
1760
1760
|
"measureUnit": string;
|
|
1761
1761
|
/**
|
|
1762
|
-
* Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them. <br /><br /> values: <br /> ```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto``` <br /> or a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos``` <br /><br /> With `interval="setname"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts by that block only. Without a bucket the sum over all buckets is used. <br /><br /> The scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one. A plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data (and a relative variance with a zero reference) sort last. <br /><br /> When set to ```auto```, order is detected from the dataset silently.
|
|
1762
|
+
* Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them. <br /><br /> values: <br /> ```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto``` <br /> or a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos``` <br /><br /> With `interval="setname"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts by that block only. Without a bucket the sum over all buckets is used. <br /><br /> The scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one. A plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data (and a relative variance with a zero reference) sort last. <br /><br /> A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays the last row of the group. Its label comes from the `REST` translation. <br /><br /> When set to ```auto```, order is detected from the dataset silently.
|
|
1763
1763
|
* @default "category"
|
|
1764
1764
|
*/
|
|
1765
1765
|
"order": string;
|
|
@@ -3818,7 +3818,7 @@ declare namespace LocalJSX {
|
|
|
3818
3818
|
*/
|
|
3819
3819
|
"measureUnit"?: string;
|
|
3820
3820
|
/**
|
|
3821
|
-
* Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them. <br /><br /> values: <br /> ```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto``` <br /> or a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos``` <br /><br /> With `interval="setname"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts by that block only. Without a bucket the sum over all buckets is used. <br /><br /> The scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one. A plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data (and a relative variance with a zero reference) sort last. <br /><br /> When set to ```auto```, order is detected from the dataset silently.
|
|
3821
|
+
* Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them. <br /><br /> values: <br /> ```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto``` <br /> or a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos``` <br /><br /> With `interval="setname"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts by that block only. Without a bucket the sum over all buckets is used. <br /><br /> The scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one. A plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data (and a relative variance with a zero reference) sort last. <br /><br /> A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays the last row of the group. Its label comes from the `REST` translation. <br /><br /> When set to ```auto```, order is detected from the dataset silently.
|
|
3822
3822
|
* @default "category"
|
|
3823
3823
|
*/
|
|
3824
3824
|
"order"?: string;
|
package/package.json
CHANGED