@bino-bi/bn-template-engine 1.0.0-next.37 → 1.0.0-next.39
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-8c84d57e.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +271 -57
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +56 -6
- package/dist/collection/components/bn-table/bn-table.js +93 -5
- package/dist/collection/components/bn-table/utils/Table.js +33 -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/factories/tableDataSetFactory.js +15 -7
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +24 -10
- package/dist/collection/components/bn-table/utils/helper/IntervalColumns.js +30 -6
- 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/collection/components/bn-table/utils/model/TableComponentConfig.js +5 -0
- package/dist/collection/utils/layoutState/baseline.js +6 -5
- package/dist/components/bn-chart-bubble-renderer.js +1 -1
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet-renderer.js +1 -1
- package/dist/components/bn-chart-bullet.js +1 -1
- package/dist/components/bn-chart-scatter-renderer.js +1 -1
- package/dist/components/bn-chart-scatter.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/{p-CQVAHG6w.js → p-B4Cf0cVi.js} +1 -1
- package/dist/components/{p-C-KX1_tw.js → p-BsJOvfIg.js} +1 -1
- package/dist/components/p-ChaSU4fh.js +1 -0
- package/dist/components/{p-BhEdmPjm.js → p-Cyf5ZEXs.js} +1 -1
- package/dist/components/{p-t4xPltK2.js → p-XFZYX7DZ.js} +1 -1
- package/dist/components/{p-C_6KHDYv.js → p-chnyMHJT.js} +1 -1
- package/dist/components/p-dRPJiQB6.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +271 -57
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +2 -0
- package/dist/types/components/bn-table/bn-table.d.ts +26 -0
- package/dist/types/components/bn-table/utils/Table.d.ts +11 -1
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +5 -2
- package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +7 -4
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +1 -0
- package/dist/types/components/bn-table/utils/helper/IntervalColumns.d.ts +7 -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/bn-table/utils/model/TableComponentConfig.d.ts +2 -0
- package/dist/types/components.d.ts +19 -4
- package/dist/types/utils/layoutState/baseline.d.ts +4 -2
- package/package.json +1 -1
- package/dist/components/p-CHQ67u2G.js +0 -1
- package/dist/components/p-sar8m7th.js +0 -1
|
@@ -17,7 +17,7 @@ import { formatScalingValue, parseScaling, resolveScalingValue } from "../../uti
|
|
|
17
17
|
import { observeParentResize } from "../../utils/layoutObserver";
|
|
18
18
|
import { BAR_COLUMN_WIDTH_EM, DataFormat, I18nMode, MeasureType, TableBarColumnWidth, TableCategoryWidth, } from "../../utils/constants";
|
|
19
19
|
import { TableType } from "./utils/model";
|
|
20
|
-
import { INTERVAL_NONE, INTERVAL_SETNAME } from "./utils/helper/IntervalColumns";
|
|
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";
|
|
23
23
|
import { LAYOUT_STATE_VERSION, measure, originsFor, readDiagnostics, readTableBaseline, resolveStandaloneId, } from "../../utils/layoutState";
|
|
@@ -61,6 +61,8 @@ export class Table {
|
|
|
61
61
|
this.appliedScaleFactor = 1;
|
|
62
62
|
/** True when the active dataset contains rows with a blank `setname` (relevant for `interval='setname'`). */
|
|
63
63
|
this.hasBlankSetnames = false;
|
|
64
|
+
/** True when the active dataset contains rows with a `setnameIndex` but a blank `setname`. */
|
|
65
|
+
this.hasSetnameIndexWithoutSetname = false;
|
|
64
66
|
/**
|
|
65
67
|
* Label of the grand-total row at the bottom of the table. Only rendered for
|
|
66
68
|
* `type="sum"` and `type="opt"`; the other table types have no total row.
|
|
@@ -210,6 +212,9 @@ export class Table {
|
|
|
210
212
|
* inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data
|
|
211
213
|
* (and a relative variance with a zero reference) sort last.
|
|
212
214
|
* <br /><br />
|
|
215
|
+
* A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays
|
|
216
|
+
* the last row of the group. Its label comes from the `REST` translation.
|
|
217
|
+
* <br /><br />
|
|
213
218
|
* When set to ```auto```, order is detected from the dataset silently.
|
|
214
219
|
*/
|
|
215
220
|
this.order = "category";
|
|
@@ -306,8 +311,27 @@ export class Table {
|
|
|
306
311
|
* raise a warning and are grouped under `-`. Date values bucket rows by the
|
|
307
312
|
* `date` column; ```auto``` detects the granularity from the date span.
|
|
308
313
|
* Cannot be combined with `columnthereof`.
|
|
314
|
+
* <br /><br />
|
|
315
|
+
* Date groups are shown in chronological order. Setname groups are shown in
|
|
316
|
+
* order of first appearance in the dataset. When the rows carry the optional
|
|
317
|
+
* numeric column `setnameIndex`, the setname groups are sorted ascending by
|
|
318
|
+
* it: the smallest index of a setname counts, groups without an index come
|
|
319
|
+
* last.
|
|
309
320
|
*/
|
|
310
321
|
this.interval = "none";
|
|
322
|
+
/**
|
|
323
|
+
* Number of interval groups that stand left of the category column. Needs
|
|
324
|
+
* an active `interval`.
|
|
325
|
+
* <br /><br />
|
|
326
|
+
* ```0``` (default) keeps the category column first. ```1``` puts one
|
|
327
|
+
* interval group left of it and the rest right. The number of interval
|
|
328
|
+
* groups puts the category column last. A greater value raises a warning
|
|
329
|
+
* and is used as the number of groups.
|
|
330
|
+
* <br /><br />
|
|
331
|
+
* The operation column and the `attributes` columns move with the category
|
|
332
|
+
* column.
|
|
333
|
+
*/
|
|
334
|
+
this.categoryIntervalPosition = 0;
|
|
311
335
|
/**
|
|
312
336
|
* Stringified JSON object defining custom columns computed from dataset fields.<br />
|
|
313
337
|
* Keys are column labels, values are aggregate expressions over the rows that
|
|
@@ -373,6 +397,13 @@ export class Table {
|
|
|
373
397
|
this.dataVersion = this.dataVersion + 1;
|
|
374
398
|
this.hasBlankSetnames =
|
|
375
399
|
Array.isArray(data) && data.some((row) => { var _a; return isBlankInput(((_a = row === null || row === void 0 ? void 0 : row.setname) !== null && _a !== void 0 ? _a : row === null || row === void 0 ? void 0 : row.setName)); });
|
|
400
|
+
this.hasSetnameIndexWithoutSetname =
|
|
401
|
+
Array.isArray(data) &&
|
|
402
|
+
data.some((row) => {
|
|
403
|
+
var _a, _b;
|
|
404
|
+
return coerceSetnameIndex((_a = row === null || row === void 0 ? void 0 : row.setnameIndex) !== null && _a !== void 0 ? _a : row === null || row === void 0 ? void 0 : row.setNameIndex) !== undefined &&
|
|
405
|
+
isBlankInput(((_b = row === null || row === void 0 ? void 0 : row.setname) !== null && _b !== void 0 ? _b : row === null || row === void 0 ? void 0 : row.setName));
|
|
406
|
+
});
|
|
376
407
|
}, (_name, meta) => {
|
|
377
408
|
this.datasetMeta = meta;
|
|
378
409
|
});
|
|
@@ -685,6 +716,19 @@ export class Table {
|
|
|
685
716
|
});
|
|
686
717
|
}
|
|
687
718
|
}
|
|
719
|
+
validateCategoryIntervalPosition(newValue) {
|
|
720
|
+
const errId = "WARN_categoryIntervalPosition";
|
|
721
|
+
if (isBlankInput(newValue) || (isValidInteger(newValue) && Number(newValue) >= 0)) {
|
|
722
|
+
this.errors.remove(errId);
|
|
723
|
+
}
|
|
724
|
+
else {
|
|
725
|
+
this.errors.addOrReplace({
|
|
726
|
+
id: errId,
|
|
727
|
+
type: "warning",
|
|
728
|
+
message: "categoryIntervalPosition: invalid value '" + newValue + "' is not supported.",
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
}
|
|
688
732
|
validateTableAttributes(newValue) {
|
|
689
733
|
const errId = "WARN_attributes";
|
|
690
734
|
const invalidElements = validateAttributesJsonStr(newValue);
|
|
@@ -717,6 +761,7 @@ export class Table {
|
|
|
717
761
|
this.validateMeasureScale(this.measureScale);
|
|
718
762
|
this.validateColumnThereOf(this.columnthereof);
|
|
719
763
|
this.validateInterval(this.interval);
|
|
764
|
+
this.validateCategoryIntervalPosition(this.categoryIntervalPosition);
|
|
720
765
|
this.validateTableAttributes(this.tableAttributes);
|
|
721
766
|
this.validateBarColumns(this.barColumns);
|
|
722
767
|
this.validateBarColumnWidth(this.barColumnWidth);
|
|
@@ -1033,6 +1078,7 @@ export class Table {
|
|
|
1033
1078
|
const conflictErrId = "WARN_intervalConflict";
|
|
1034
1079
|
const noDateErrId = "WARN_intervalNoDate";
|
|
1035
1080
|
const setnameErrId = "WARN_intervalSetname";
|
|
1081
|
+
const setnameIndexErrId = "WARN_intervalSetnameIndex";
|
|
1036
1082
|
const interval = isBlankInput(this.interval) ? INTERVAL_NONE : this.interval.trim().toLowerCase();
|
|
1037
1083
|
const isValid = interval === INTERVAL_NONE || interval === INTERVAL_SETNAME || isValidDateFormat(interval);
|
|
1038
1084
|
// invalid values are already reported by validateInterval
|
|
@@ -1040,6 +1086,7 @@ export class Table {
|
|
|
1040
1086
|
this.errors.remove(conflictErrId);
|
|
1041
1087
|
this.errors.remove(noDateErrId);
|
|
1042
1088
|
this.errors.remove(setnameErrId);
|
|
1089
|
+
this.errors.remove(setnameIndexErrId);
|
|
1043
1090
|
return INTERVAL_NONE;
|
|
1044
1091
|
}
|
|
1045
1092
|
if (this.columnthereof != null && this.columnthereof.trim() !== "") {
|
|
@@ -1050,6 +1097,7 @@ export class Table {
|
|
|
1050
1097
|
});
|
|
1051
1098
|
this.errors.remove(noDateErrId);
|
|
1052
1099
|
this.errors.remove(setnameErrId);
|
|
1100
|
+
this.errors.remove(setnameIndexErrId);
|
|
1053
1101
|
return INTERVAL_NONE;
|
|
1054
1102
|
}
|
|
1055
1103
|
this.errors.remove(conflictErrId);
|
|
@@ -1064,10 +1112,21 @@ export class Table {
|
|
|
1064
1112
|
else {
|
|
1065
1113
|
this.errors.remove(setnameErrId);
|
|
1066
1114
|
}
|
|
1115
|
+
if (this.hasSetnameIndexWithoutSetname) {
|
|
1116
|
+
this.errors.addOrReplace({
|
|
1117
|
+
id: setnameIndexErrId,
|
|
1118
|
+
type: "warning",
|
|
1119
|
+
message: "interval: rows with setnameIndex but blank setname found, setnameIndex needs setname.",
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
else {
|
|
1123
|
+
this.errors.remove(setnameIndexErrId);
|
|
1124
|
+
}
|
|
1067
1125
|
this.errors.remove(noDateErrId);
|
|
1068
1126
|
return INTERVAL_SETNAME;
|
|
1069
1127
|
}
|
|
1070
1128
|
this.errors.remove(setnameErrId);
|
|
1129
|
+
this.errors.remove(setnameIndexErrId);
|
|
1071
1130
|
if (this.datasetMeta && !((_a = this.datasetMeta.dateRange) === null || _a === void 0 ? void 0 : _a.hasData)) {
|
|
1072
1131
|
this.errors.addOrReplace({
|
|
1073
1132
|
id: noDateErrId,
|
|
@@ -1079,6 +1138,10 @@ export class Table {
|
|
|
1079
1138
|
this.errors.remove(noDateErrId);
|
|
1080
1139
|
return interval;
|
|
1081
1140
|
}
|
|
1141
|
+
prepareCategoryIntervalPosition() {
|
|
1142
|
+
const position = Number(this.categoryIntervalPosition);
|
|
1143
|
+
return Number.isInteger(position) && position > 0 ? position : 0;
|
|
1144
|
+
}
|
|
1082
1145
|
prepareAttributes() {
|
|
1083
1146
|
if (this.tableAttributes == null || this.tableAttributes.trim() === "") {
|
|
1084
1147
|
return [];
|
|
@@ -1184,6 +1247,7 @@ export class Table {
|
|
|
1184
1247
|
const dataSetStructure = {
|
|
1185
1248
|
ITableDataRow: {
|
|
1186
1249
|
setName: { type: "string", isOptional: false, description: "" },
|
|
1250
|
+
setNameIndex: { type: "number", isOptional: true, description: "" },
|
|
1187
1251
|
date: { type: "string", isOptional: false, description: "" },
|
|
1188
1252
|
operation: { type: "string", isOptional: false, description: "" },
|
|
1189
1253
|
rowGroup: { type: "string", isOptional: false, description: "" },
|
|
@@ -1339,7 +1403,7 @@ export class Table {
|
|
|
1339
1403
|
render() {
|
|
1340
1404
|
const fontStyles = this.getFontStyles();
|
|
1341
1405
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
1342
|
-
return (h(Host, { key: '
|
|
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 }))));
|
|
1343
1407
|
}
|
|
1344
1408
|
static get is() { return "bn-table"; }
|
|
1345
1409
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1814,7 +1878,7 @@ export class Table {
|
|
|
1814
1878
|
"optional": false,
|
|
1815
1879
|
"docs": {
|
|
1816
1880
|
"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."
|
|
1881
|
+
"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
1882
|
},
|
|
1819
1883
|
"getter": false,
|
|
1820
1884
|
"setter": false,
|
|
@@ -1974,7 +2038,7 @@ export class Table {
|
|
|
1974
2038
|
"optional": false,
|
|
1975
2039
|
"docs": {
|
|
1976
2040
|
"tags": [],
|
|
1977
|
-
"text": "Repeats the entire scenario/variance column block once per interval group,\nrendered under a spanning header band (e.g. `2023 | 2024 | 2025`, each with\nthe configured columns).\n<br /><br />\nvalues:<br /> ```none // setname // year // quarter // month // week // day // hour // minute // second // millisecond // auto```\n<br /><br />\n```none``` (default) deactivates the feature. ```setname``` groups by the\ndataset's `setname` column (non-date comparison); rows with a blank setname\nraise a warning and are grouped under `-`. Date values bucket rows by the\n`date` column; ```auto``` detects the granularity from the date span.\nCannot be combined with `columnthereof
|
|
2041
|
+
"text": "Repeats the entire scenario/variance column block once per interval group,\nrendered under a spanning header band (e.g. `2023 | 2024 | 2025`, each with\nthe configured columns).\n<br /><br />\nvalues:<br /> ```none // setname // year // quarter // month // week // day // hour // minute // second // millisecond // auto```\n<br /><br />\n```none``` (default) deactivates the feature. ```setname``` groups by the\ndataset's `setname` column (non-date comparison); rows with a blank setname\nraise a warning and are grouped under `-`. Date values bucket rows by the\n`date` column; ```auto``` detects the granularity from the date span.\nCannot be combined with `columnthereof`.\n<br /><br />\nDate groups are shown in chronological order. Setname groups are shown in\norder of first appearance in the dataset. When the rows carry the optional\nnumeric column `setnameIndex`, the setname groups are sorted ascending by\nit: the smallest index of a setname counts, groups without an index come\nlast."
|
|
1978
2042
|
},
|
|
1979
2043
|
"getter": false,
|
|
1980
2044
|
"setter": false,
|
|
@@ -1982,6 +2046,26 @@ export class Table {
|
|
|
1982
2046
|
"attribute": "interval",
|
|
1983
2047
|
"defaultValue": "\"none\""
|
|
1984
2048
|
},
|
|
2049
|
+
"categoryIntervalPosition": {
|
|
2050
|
+
"type": "number",
|
|
2051
|
+
"mutable": false,
|
|
2052
|
+
"complexType": {
|
|
2053
|
+
"original": "number",
|
|
2054
|
+
"resolved": "number",
|
|
2055
|
+
"references": {}
|
|
2056
|
+
},
|
|
2057
|
+
"required": false,
|
|
2058
|
+
"optional": false,
|
|
2059
|
+
"docs": {
|
|
2060
|
+
"tags": [],
|
|
2061
|
+
"text": "Number of interval groups that stand left of the category column. Needs\nan active `interval`.\n<br /><br />\n```0``` (default) keeps the category column first. ```1``` puts one\ninterval group left of it and the rest right. The number of interval\ngroups puts the category column last. A greater value raises a warning\nand is used as the number of groups.\n<br /><br />\nThe operation column and the `attributes` columns move with the category\ncolumn."
|
|
2062
|
+
},
|
|
2063
|
+
"getter": false,
|
|
2064
|
+
"setter": false,
|
|
2065
|
+
"reflect": false,
|
|
2066
|
+
"attribute": "category-interval-position",
|
|
2067
|
+
"defaultValue": "0"
|
|
2068
|
+
},
|
|
1985
2069
|
"tableAttributes": {
|
|
1986
2070
|
"type": "string",
|
|
1987
2071
|
"mutable": false,
|
|
@@ -2010,7 +2094,8 @@ export class Table {
|
|
|
2010
2094
|
"dataVersion": {},
|
|
2011
2095
|
"datasetMeta": {},
|
|
2012
2096
|
"appliedScaleFactor": {},
|
|
2013
|
-
"hasBlankSetnames": {}
|
|
2097
|
+
"hasBlankSetnames": {},
|
|
2098
|
+
"hasSetnameIndexWithoutSetname": {}
|
|
2014
2099
|
};
|
|
2015
2100
|
}
|
|
2016
2101
|
static get methods() {
|
|
@@ -2150,6 +2235,9 @@ export class Table {
|
|
|
2150
2235
|
}, {
|
|
2151
2236
|
"propName": "interval",
|
|
2152
2237
|
"methodName": "validateInterval"
|
|
2238
|
+
}, {
|
|
2239
|
+
"propName": "categoryIntervalPosition",
|
|
2240
|
+
"methodName": "validateCategoryIntervalPosition"
|
|
2153
2241
|
}, {
|
|
2154
2242
|
"propName": "tableAttributes",
|
|
2155
2243
|
"methodName": "validateTableAttributes"
|
|
@@ -137,7 +137,9 @@ export class Table {
|
|
|
137
137
|
update() {
|
|
138
138
|
this.prepareIntervalBuckets();
|
|
139
139
|
const normalizedScenarios = this.normalizeScenarios(this.config.scenarios, this.config.categoryThereOf, this.config.sortOrder, this.intervalBuckets);
|
|
140
|
-
this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes
|
|
140
|
+
this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes,
|
|
141
|
+
// every interval group has one column per scenario
|
|
142
|
+
Math.min(this.categoryIntervalPosition(), this.intervalBuckets.length) * this.config.scenarios.length);
|
|
141
143
|
this.bodyRows =
|
|
142
144
|
this.rowCount === 0 || !this.fromExpr
|
|
143
145
|
? []
|
|
@@ -156,7 +158,10 @@ export class Table {
|
|
|
156
158
|
}
|
|
157
159
|
return this.bodyRows;
|
|
158
160
|
}
|
|
159
|
-
/**
|
|
161
|
+
/**
|
|
162
|
+
* Effective column definitions in render order: category/operation + attributes + scenarios × interval buckets.
|
|
163
|
+
* With `categoryIntervalPosition` the first interval buckets come before the category/operation column.
|
|
164
|
+
*/
|
|
160
165
|
getColumns() {
|
|
161
166
|
if (this.state === FactoryState.DIRTY) {
|
|
162
167
|
this.update();
|
|
@@ -257,6 +262,32 @@ export class Table {
|
|
|
257
262
|
const unknown = buckets.find((bucket) => !this.intervalBuckets.some((b) => b.key === bucket));
|
|
258
263
|
return unknown === undefined ? undefined : `order: setname '${unknown}' not found, the rows are not sorted by it.`;
|
|
259
264
|
}
|
|
265
|
+
/** The configured `categoryIntervalPosition`; anything but a positive integer counts as 0. */
|
|
266
|
+
categoryIntervalPosition() {
|
|
267
|
+
const position = this.config.categoryIntervalPosition;
|
|
268
|
+
return Number.isInteger(position) && position > 0 ? position : 0;
|
|
269
|
+
}
|
|
270
|
+
/** Warning for a `categoryIntervalPosition` that cannot apply, once the body was built; undefined when it applies. */
|
|
271
|
+
categoryIntervalPositionWarning() {
|
|
272
|
+
const position = this.categoryIntervalPosition();
|
|
273
|
+
if (position <= 0 || this.hasNoData() || this.state !== FactoryState.UP_TO_DATE) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
const groups = this.intervalBuckets.length;
|
|
277
|
+
if (groups === 0) {
|
|
278
|
+
return {
|
|
279
|
+
id: "WARN_categoryIntervalPositionNoInterval",
|
|
280
|
+
message: "categoryIntervalPosition: needs an active interval, the value is ignored.",
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
if (position > groups) {
|
|
284
|
+
return {
|
|
285
|
+
id: "WARN_categoryIntervalPositionRange",
|
|
286
|
+
message: `categoryIntervalPosition: '${position}' is greater than the number of interval groups, ${groups} is used.`,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return undefined;
|
|
290
|
+
}
|
|
260
291
|
/** True once the body was built and the grouped table has rows with a blank rowGroup. */
|
|
261
292
|
hasBlankRowGroup() {
|
|
262
293
|
return this.dataSetFactory.hasBlankRowGroup;
|
|
@@ -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
|
|
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
|
|
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 =
|
|
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";
|
|
@@ -11,7 +11,7 @@ import { pointDate } from "../../../../utils/layoutState/dataPoint";
|
|
|
11
11
|
/**
|
|
12
12
|
* Transforms raw query results into structured TableRow collections for header and body.
|
|
13
13
|
*
|
|
14
|
-
* Header normalization:
|
|
14
|
+
* Header normalization: adds the fixed columns (operation, category) to the configured
|
|
15
15
|
* scenarios, then translates labels via i18n and adds separator rows for IBCS-style borders.
|
|
16
16
|
*
|
|
17
17
|
* Body row creation: iterates DataQuery results grouped by rowGroup, creates detail rows
|
|
@@ -38,7 +38,7 @@ export class TableDataSetFactory {
|
|
|
38
38
|
}
|
|
39
39
|
return styleSlot(this.ruleSet.getScenarioColorIndex(type)) + type.slice(2);
|
|
40
40
|
}
|
|
41
|
-
/** Effective column list (category/operation + attributes + scenarios × buckets), set by createHeader(). */
|
|
41
|
+
/** Effective column list (category/operation + attributes + scenarios × buckets) in render order, set by createHeader(). */
|
|
42
42
|
getNormalizedHeader() {
|
|
43
43
|
return this.normalizedHeader;
|
|
44
44
|
}
|
|
@@ -50,10 +50,10 @@ export class TableDataSetFactory {
|
|
|
50
50
|
* visualise grouping.
|
|
51
51
|
* finally a seperator header row is created for the header underlining (border)
|
|
52
52
|
*/
|
|
53
|
-
createHeader(type, scenarios, i18n, measureScale, measureUnit, showMeasureScale, attributes = []) {
|
|
53
|
+
createHeader(type, scenarios, i18n, measureScale, measureUnit, showMeasureScale, attributes = [], leadingScenarioColumns = 0) {
|
|
54
54
|
const header = [];
|
|
55
55
|
this.attributesByAlias = new Map(attributes.map((attribute) => [attribute.alias, attribute]));
|
|
56
|
-
this.normalizedHeader = this.normalizeHeader(type, scenarios, attributes);
|
|
56
|
+
this.normalizedHeader = this.normalizeHeader(type, scenarios, attributes, leadingScenarioColumns);
|
|
57
57
|
const hasIntervalColumns = this.normalizedHeader.some((column) => column.bucket !== undefined);
|
|
58
58
|
if (hasIntervalColumns) {
|
|
59
59
|
header.push(this.createIntervalBandRow());
|
|
@@ -73,7 +73,7 @@ export class TableDataSetFactory {
|
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* Creates the spanning interval band row (e.g. `2023 | 2024 | 2025`) rendered
|
|
76
|
-
* above the scenario label row.
|
|
76
|
+
* above the scenario label row. Non-interval columns (category,
|
|
77
77
|
* operation, attributes) receive borderless filler cells; each run of
|
|
78
78
|
* consecutive columns of the same bucket is spanned by one label cell.
|
|
79
79
|
*/
|
|
@@ -114,8 +114,11 @@ export class TableDataSetFactory {
|
|
|
114
114
|
* configured scenarios.
|
|
115
115
|
* depending of table type operation column is used (OPT) or not (SUM | LIST)
|
|
116
116
|
* in addition the headers are sorted based on the ruleset and duplicates are removed
|
|
117
|
+
*
|
|
118
|
+
* operation, category and the attribute columns are the row header block. It moves
|
|
119
|
+
* as one unit: `leadingScenarioColumns` scenario columns stand left of it.
|
|
117
120
|
*/
|
|
118
|
-
normalizeHeader(type, scenarios, attributes) {
|
|
121
|
+
normalizeHeader(type, scenarios, attributes, leadingScenarioColumns = 0) {
|
|
119
122
|
let header = [
|
|
120
123
|
{
|
|
121
124
|
name: QueryColumnNames.CATEGORY,
|
|
@@ -148,7 +151,12 @@ export class TableDataSetFactory {
|
|
|
148
151
|
order: undefined,
|
|
149
152
|
}));
|
|
150
153
|
// NOTE: scenarios are already sorted in setConfig
|
|
151
|
-
return [
|
|
154
|
+
return [
|
|
155
|
+
...scenarios.slice(0, leadingScenarioColumns),
|
|
156
|
+
...header,
|
|
157
|
+
...attributeColumns,
|
|
158
|
+
...scenarios.slice(leadingScenarioColumns),
|
|
159
|
+
];
|
|
152
160
|
}
|
|
153
161
|
/**
|
|
154
162
|
* Creates table data colelction,
|
|
@@ -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
|
-
|
|
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(
|
|
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
|
|
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
|
|
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
|
|
@@ -22,6 +22,16 @@ export function intervalBucketSQL(interval) {
|
|
|
22
22
|
}
|
|
23
23
|
return `normalizeDate([date], '${interval}')`;
|
|
24
24
|
}
|
|
25
|
+
/** SQL expression reading the optional `setnameIndex` column, tolerant like `setname`. */
|
|
26
|
+
export const SETNAME_INDEX_SQL = "COALESCE([setnameIndex],[setNameIndex])";
|
|
27
|
+
/** A raw `setnameIndex` value as a number; undefined when it is blank or not numeric. */
|
|
28
|
+
export function coerceSetnameIndex(value) {
|
|
29
|
+
if (typeof value === "string" ? value.trim() === "" : typeof value !== "number") {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const index = Number(value);
|
|
33
|
+
return Number.isFinite(index) ? index : undefined;
|
|
34
|
+
}
|
|
25
35
|
/** Coerces a raw bucket value (luxon DateTime, string, millis) to a stable string key. */
|
|
26
36
|
export function coerceBucketKey(value) {
|
|
27
37
|
if (value == null) {
|
|
@@ -68,22 +78,36 @@ export function resolveIntervalGranularity(db, fromExpr, interval) {
|
|
|
68
78
|
* Date buckets are sorted chronologically ascending and labeled locale-aware;
|
|
69
79
|
* setname buckets keep their order of first appearance in the data, blank
|
|
70
80
|
* setnames are collected in a trailing-position "-" bucket where they occur.
|
|
81
|
+
* When rows carry a numeric `setnameIndex`, the setname buckets are sorted
|
|
82
|
+
* ascending by the smallest index of each setname. Buckets without an index
|
|
83
|
+
* follow, and ties keep the order of first appearance.
|
|
71
84
|
*/
|
|
72
85
|
export function queryIntervalBuckets(db, fromExpr, interval, locale) {
|
|
73
|
-
const rows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval FROM ${fromExpr}`);
|
|
74
86
|
if (interval === INTERVAL_SETNAME) {
|
|
87
|
+
const setRows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval, ${SETNAME_INDEX_SQL} as __index FROM ${fromExpr}`);
|
|
75
88
|
const seen = new Set();
|
|
89
|
+
const indexes = new Map();
|
|
76
90
|
const buckets = [];
|
|
77
|
-
for (const row of
|
|
91
|
+
for (const row of setRows) {
|
|
78
92
|
const key = coerceBucketKey(row.__interval);
|
|
79
|
-
if (seen.has(key)) {
|
|
80
|
-
|
|
93
|
+
if (!seen.has(key)) {
|
|
94
|
+
seen.add(key);
|
|
95
|
+
buckets.push({ key, label: key.length === 0 ? BLANK_BUCKET_LABEL : key });
|
|
81
96
|
}
|
|
82
|
-
|
|
83
|
-
|
|
97
|
+
const index = coerceSetnameIndex(row.__index);
|
|
98
|
+
const known = indexes.get(key);
|
|
99
|
+
if (index !== undefined && (known === undefined || index < known)) {
|
|
100
|
+
indexes.set(key, index);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// without any index the order of first appearance stays as it is
|
|
104
|
+
if (indexes.size > 0) {
|
|
105
|
+
const rank = (bucket) => { var _a; return (_a = indexes.get(bucket.key)) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY; };
|
|
106
|
+
buckets.sort((a, b) => (rank(a) === rank(b) ? 0 : rank(a) < rank(b) ? -1 : 1));
|
|
84
107
|
}
|
|
85
108
|
return buckets;
|
|
86
109
|
}
|
|
110
|
+
const rows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval FROM ${fromExpr}`);
|
|
87
111
|
const seen = new Set();
|
|
88
112
|
const dates = [];
|
|
89
113
|
for (const row of rows) {
|
|
@@ -64,13 +64,16 @@ function signedValue(row, column, tableType) {
|
|
|
64
64
|
* segmented query result once per column in display order.
|
|
65
65
|
*
|
|
66
66
|
* - ENTRY rows (incl. REST) cascade from the running total by their signed value.
|
|
67
|
-
* - SUM / GROUP_SUM rows anchor at zero
|
|
67
|
+
* - SUM / GROUP_SUM rows anchor at zero. A SUM row resets the running total to its
|
|
68
|
+
* value, a GROUP_SUM row resets it to zero.
|
|
68
69
|
* - DRILLELEMENT (thereof) rows form a sub-cascade from their parent bar's start in
|
|
69
70
|
* the parent's direction; the running total is untouched.
|
|
70
71
|
* - PARTELEMENT (partof) rows cascade a `share * parent width` segment the same way.
|
|
71
72
|
* Note: the share denominator is the group sum (or SUM_TOTAL when ungrouped) per
|
|
72
73
|
* `createPartOfDrillRows`, not literally the parent row's value.
|
|
73
|
-
* - GROUPHEAD
|
|
74
|
+
* - GROUPHEAD rows get no bar and restart the running total at zero: every row group
|
|
75
|
+
* is its own cascade that ends at its GROUP_SUM.
|
|
76
|
+
* - NaN rows get no bar; a NaN parent orphans its drill children.
|
|
74
77
|
*
|
|
75
78
|
* @param queryData - Segmented result rows from DataQuery.execute().
|
|
76
79
|
* @param columns - Plain scenario column keys (ac1..pl4); no `##` composite keys.
|
|
@@ -91,6 +94,8 @@ export function computeWaterfall(queryData, columns, tableType) {
|
|
|
91
94
|
for (const row of groupData) {
|
|
92
95
|
const type = row[QueryColumnNames.TYPE];
|
|
93
96
|
if (type === TableRowType.GROUPHEAD) {
|
|
97
|
+
// a group sum only totals its own rows, so the cascade must not carry over
|
|
98
|
+
running = 0;
|
|
94
99
|
lastParent = undefined;
|
|
95
100
|
continue;
|
|
96
101
|
}
|
|
@@ -113,7 +118,8 @@ export function computeWaterfall(queryData, columns, tableType) {
|
|
|
113
118
|
emit(row, { start: 0, end: value, min: 0, max: 0, kind: "anchor" });
|
|
114
119
|
lastParent = { start: 0, end: value };
|
|
115
120
|
subCursor = 0;
|
|
116
|
-
|
|
121
|
+
// a group sum closes its group (there may be no GROUPHEAD row when the title is hidden)
|
|
122
|
+
running = type === TableRowType.GROUPSUM ? 0 : value;
|
|
117
123
|
}
|
|
118
124
|
else if (type === TableRowType.DRILLELEMENT) {
|
|
119
125
|
if (value === null || lastParent === undefined) {
|