@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
|
@@ -810,8 +810,10 @@ function readChartBaseline(host, innerTag) {
|
|
|
810
810
|
}
|
|
811
811
|
/**
|
|
812
812
|
* Baseline of a rendered `<table>`, in the layout px of `host`: y is the
|
|
813
|
-
* bottom of the header, x the left edge of the first value column
|
|
814
|
-
*
|
|
813
|
+
* bottom of the header, x the left edge of the first value column of the last
|
|
814
|
+
* header row, else of the first body row. That is the first cell that is not
|
|
815
|
+
* the operation or the category column. Interval groups can stand left of the
|
|
816
|
+
* category column, then it is the first cell of the row.
|
|
815
817
|
*/
|
|
816
818
|
function readTableBaseline(table, host) {
|
|
817
819
|
var _a;
|
|
@@ -827,10 +829,9 @@ function readTableBaseline(table, host) {
|
|
|
827
829
|
const rows = (section) => section ? Array.from(section.children).filter((child) => child.localName === "tr") : [];
|
|
828
830
|
const headerRows = rows(thead);
|
|
829
831
|
const row = (_a = headerRows[headerRows.length - 1]) !== null && _a !== void 0 ? _a : rows(table.querySelector("tbody"))[0];
|
|
830
|
-
// an operation column can come before the category column (table type opt)
|
|
831
832
|
const cells = row ? Array.from(row.children) : [];
|
|
832
|
-
const
|
|
833
|
-
const valueCell = cells
|
|
833
|
+
const isRowHeader = (cell) => cell.classList.contains("category") || cell.classList.contains("operation");
|
|
834
|
+
const valueCell = cells.some(isRowHeader) ? cells.find((cell) => !isRowHeader(cell)) : cells[1];
|
|
834
835
|
if (valueCell) {
|
|
835
836
|
baseline.x = round2(frame.toLocal(valueCell.getBoundingClientRect()).x);
|
|
836
837
|
}
|
|
@@ -26634,6 +26635,16 @@ function intervalBucketSQL(interval) {
|
|
|
26634
26635
|
}
|
|
26635
26636
|
return `normalizeDate([date], '${interval}')`;
|
|
26636
26637
|
}
|
|
26638
|
+
/** SQL expression reading the optional `setnameIndex` column, tolerant like `setname`. */
|
|
26639
|
+
const SETNAME_INDEX_SQL = "COALESCE([setnameIndex],[setNameIndex])";
|
|
26640
|
+
/** A raw `setnameIndex` value as a number; undefined when it is blank or not numeric. */
|
|
26641
|
+
function coerceSetnameIndex(value) {
|
|
26642
|
+
if (typeof value === "string" ? value.trim() === "" : typeof value !== "number") {
|
|
26643
|
+
return undefined;
|
|
26644
|
+
}
|
|
26645
|
+
const index = Number(value);
|
|
26646
|
+
return Number.isFinite(index) ? index : undefined;
|
|
26647
|
+
}
|
|
26637
26648
|
/** Coerces a raw bucket value (luxon DateTime, string, millis) to a stable string key. */
|
|
26638
26649
|
function coerceBucketKey(value) {
|
|
26639
26650
|
if (value == null) {
|
|
@@ -26680,22 +26691,36 @@ function resolveIntervalGranularity(db, fromExpr, interval) {
|
|
|
26680
26691
|
* Date buckets are sorted chronologically ascending and labeled locale-aware;
|
|
26681
26692
|
* setname buckets keep their order of first appearance in the data, blank
|
|
26682
26693
|
* setnames are collected in a trailing-position "-" bucket where they occur.
|
|
26694
|
+
* When rows carry a numeric `setnameIndex`, the setname buckets are sorted
|
|
26695
|
+
* ascending by the smallest index of each setname. Buckets without an index
|
|
26696
|
+
* follow, and ties keep the order of first appearance.
|
|
26683
26697
|
*/
|
|
26684
26698
|
function queryIntervalBuckets(db, fromExpr, interval, locale) {
|
|
26685
|
-
const rows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval FROM ${fromExpr}`);
|
|
26686
26699
|
if (interval === INTERVAL_SETNAME) {
|
|
26700
|
+
const setRows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval, ${SETNAME_INDEX_SQL} as __index FROM ${fromExpr}`);
|
|
26687
26701
|
const seen = new Set();
|
|
26702
|
+
const indexes = new Map();
|
|
26688
26703
|
const buckets = [];
|
|
26689
|
-
for (const row of
|
|
26704
|
+
for (const row of setRows) {
|
|
26690
26705
|
const key = coerceBucketKey(row.__interval);
|
|
26691
|
-
if (seen.has(key)) {
|
|
26692
|
-
|
|
26706
|
+
if (!seen.has(key)) {
|
|
26707
|
+
seen.add(key);
|
|
26708
|
+
buckets.push({ key, label: key.length === 0 ? BLANK_BUCKET_LABEL : key });
|
|
26693
26709
|
}
|
|
26694
|
-
|
|
26695
|
-
|
|
26710
|
+
const index = coerceSetnameIndex(row.__index);
|
|
26711
|
+
const known = indexes.get(key);
|
|
26712
|
+
if (index !== undefined && (known === undefined || index < known)) {
|
|
26713
|
+
indexes.set(key, index);
|
|
26714
|
+
}
|
|
26715
|
+
}
|
|
26716
|
+
// without any index the order of first appearance stays as it is
|
|
26717
|
+
if (indexes.size > 0) {
|
|
26718
|
+
const rank = (bucket) => { var _a; return (_a = indexes.get(bucket.key)) !== null && _a !== void 0 ? _a : Number.POSITIVE_INFINITY; };
|
|
26719
|
+
buckets.sort((a, b) => (rank(a) === rank(b) ? 0 : rank(a) < rank(b) ? -1 : 1));
|
|
26696
26720
|
}
|
|
26697
26721
|
return buckets;
|
|
26698
26722
|
}
|
|
26723
|
+
const rows = db.exec(`SELECT ${intervalBucketSQL(interval)} as __interval FROM ${fromExpr}`);
|
|
26699
26724
|
const seen = new Set();
|
|
26700
26725
|
const dates = [];
|
|
26701
26726
|
for (const row of rows) {
|
|
@@ -26770,6 +26795,8 @@ const Table$1 = class Table {
|
|
|
26770
26795
|
this.appliedScaleFactor = 1;
|
|
26771
26796
|
/** True when the active dataset contains rows with a blank `setname` (relevant for `interval='setname'`). */
|
|
26772
26797
|
this.hasBlankSetnames = false;
|
|
26798
|
+
/** True when the active dataset contains rows with a `setnameIndex` but a blank `setname`. */
|
|
26799
|
+
this.hasSetnameIndexWithoutSetname = false;
|
|
26773
26800
|
/**
|
|
26774
26801
|
* Label of the grand-total row at the bottom of the table. Only rendered for
|
|
26775
26802
|
* `type="sum"` and `type="opt"`; the other table types have no total row.
|
|
@@ -26919,6 +26946,9 @@ const Table$1 = class Table {
|
|
|
26919
26946
|
* inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data
|
|
26920
26947
|
* (and a relative variance with a zero reference) sort last.
|
|
26921
26948
|
* <br /><br />
|
|
26949
|
+
* A data row with the category `REST` is the rest row of its group: sorted by a scenario or variance it stays
|
|
26950
|
+
* the last row of the group. Its label comes from the `REST` translation.
|
|
26951
|
+
* <br /><br />
|
|
26922
26952
|
* When set to ```auto```, order is detected from the dataset silently.
|
|
26923
26953
|
*/
|
|
26924
26954
|
this.order = "category";
|
|
@@ -27015,8 +27045,27 @@ const Table$1 = class Table {
|
|
|
27015
27045
|
* raise a warning and are grouped under `-`. Date values bucket rows by the
|
|
27016
27046
|
* `date` column; ```auto``` detects the granularity from the date span.
|
|
27017
27047
|
* Cannot be combined with `columnthereof`.
|
|
27048
|
+
* <br /><br />
|
|
27049
|
+
* Date groups are shown in chronological order. Setname groups are shown in
|
|
27050
|
+
* order of first appearance in the dataset. When the rows carry the optional
|
|
27051
|
+
* numeric column `setnameIndex`, the setname groups are sorted ascending by
|
|
27052
|
+
* it: the smallest index of a setname counts, groups without an index come
|
|
27053
|
+
* last.
|
|
27018
27054
|
*/
|
|
27019
27055
|
this.interval = "none";
|
|
27056
|
+
/**
|
|
27057
|
+
* Number of interval groups that stand left of the category column. Needs
|
|
27058
|
+
* an active `interval`.
|
|
27059
|
+
* <br /><br />
|
|
27060
|
+
* ```0``` (default) keeps the category column first. ```1``` puts one
|
|
27061
|
+
* interval group left of it and the rest right. The number of interval
|
|
27062
|
+
* groups puts the category column last. A greater value raises a warning
|
|
27063
|
+
* and is used as the number of groups.
|
|
27064
|
+
* <br /><br />
|
|
27065
|
+
* The operation column and the `attributes` columns move with the category
|
|
27066
|
+
* column.
|
|
27067
|
+
*/
|
|
27068
|
+
this.categoryIntervalPosition = 0;
|
|
27020
27069
|
/**
|
|
27021
27070
|
* Stringified JSON object defining custom columns computed from dataset fields.<br />
|
|
27022
27071
|
* Keys are column labels, values are aggregate expressions over the rows that
|
|
@@ -27082,6 +27131,13 @@ const Table$1 = class Table {
|
|
|
27082
27131
|
this.dataVersion = this.dataVersion + 1;
|
|
27083
27132
|
this.hasBlankSetnames =
|
|
27084
27133
|
Array.isArray(data) && data.some((row) => { var _a; return withStyled.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)); });
|
|
27134
|
+
this.hasSetnameIndexWithoutSetname =
|
|
27135
|
+
Array.isArray(data) &&
|
|
27136
|
+
data.some((row) => {
|
|
27137
|
+
var _a, _b;
|
|
27138
|
+
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 &&
|
|
27139
|
+
withStyled.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));
|
|
27140
|
+
});
|
|
27085
27141
|
}, (_name, meta) => {
|
|
27086
27142
|
this.datasetMeta = meta;
|
|
27087
27143
|
});
|
|
@@ -27394,6 +27450,19 @@ const Table$1 = class Table {
|
|
|
27394
27450
|
});
|
|
27395
27451
|
}
|
|
27396
27452
|
}
|
|
27453
|
+
validateCategoryIntervalPosition(newValue) {
|
|
27454
|
+
const errId = "WARN_categoryIntervalPosition";
|
|
27455
|
+
if (withStyled.isBlankInput(newValue) || (withStyled.isValidInteger(newValue) && Number(newValue) >= 0)) {
|
|
27456
|
+
this.errors.remove(errId);
|
|
27457
|
+
}
|
|
27458
|
+
else {
|
|
27459
|
+
this.errors.addOrReplace({
|
|
27460
|
+
id: errId,
|
|
27461
|
+
type: "warning",
|
|
27462
|
+
message: "categoryIntervalPosition: invalid value '" + newValue + "' is not supported.",
|
|
27463
|
+
});
|
|
27464
|
+
}
|
|
27465
|
+
}
|
|
27397
27466
|
validateTableAttributes(newValue) {
|
|
27398
27467
|
const errId = "WARN_attributes";
|
|
27399
27468
|
const invalidElements = withStyled.validateAttributesJsonStr(newValue);
|
|
@@ -27426,6 +27495,7 @@ const Table$1 = class Table {
|
|
|
27426
27495
|
this.validateMeasureScale(this.measureScale);
|
|
27427
27496
|
this.validateColumnThereOf(this.columnthereof);
|
|
27428
27497
|
this.validateInterval(this.interval);
|
|
27498
|
+
this.validateCategoryIntervalPosition(this.categoryIntervalPosition);
|
|
27429
27499
|
this.validateTableAttributes(this.tableAttributes);
|
|
27430
27500
|
this.validateBarColumns(this.barColumns);
|
|
27431
27501
|
this.validateBarColumnWidth(this.barColumnWidth);
|
|
@@ -27742,6 +27812,7 @@ const Table$1 = class Table {
|
|
|
27742
27812
|
const conflictErrId = "WARN_intervalConflict";
|
|
27743
27813
|
const noDateErrId = "WARN_intervalNoDate";
|
|
27744
27814
|
const setnameErrId = "WARN_intervalSetname";
|
|
27815
|
+
const setnameIndexErrId = "WARN_intervalSetnameIndex";
|
|
27745
27816
|
const interval = withStyled.isBlankInput(this.interval) ? INTERVAL_NONE : this.interval.trim().toLowerCase();
|
|
27746
27817
|
const isValid = interval === INTERVAL_NONE || interval === INTERVAL_SETNAME || withStyled.isValidDateFormat(interval);
|
|
27747
27818
|
// invalid values are already reported by validateInterval
|
|
@@ -27749,6 +27820,7 @@ const Table$1 = class Table {
|
|
|
27749
27820
|
this.errors.remove(conflictErrId);
|
|
27750
27821
|
this.errors.remove(noDateErrId);
|
|
27751
27822
|
this.errors.remove(setnameErrId);
|
|
27823
|
+
this.errors.remove(setnameIndexErrId);
|
|
27752
27824
|
return INTERVAL_NONE;
|
|
27753
27825
|
}
|
|
27754
27826
|
if (this.columnthereof != null && this.columnthereof.trim() !== "") {
|
|
@@ -27759,6 +27831,7 @@ const Table$1 = class Table {
|
|
|
27759
27831
|
});
|
|
27760
27832
|
this.errors.remove(noDateErrId);
|
|
27761
27833
|
this.errors.remove(setnameErrId);
|
|
27834
|
+
this.errors.remove(setnameIndexErrId);
|
|
27762
27835
|
return INTERVAL_NONE;
|
|
27763
27836
|
}
|
|
27764
27837
|
this.errors.remove(conflictErrId);
|
|
@@ -27773,10 +27846,21 @@ const Table$1 = class Table {
|
|
|
27773
27846
|
else {
|
|
27774
27847
|
this.errors.remove(setnameErrId);
|
|
27775
27848
|
}
|
|
27849
|
+
if (this.hasSetnameIndexWithoutSetname) {
|
|
27850
|
+
this.errors.addOrReplace({
|
|
27851
|
+
id: setnameIndexErrId,
|
|
27852
|
+
type: "warning",
|
|
27853
|
+
message: "interval: rows with setnameIndex but blank setname found, setnameIndex needs setname.",
|
|
27854
|
+
});
|
|
27855
|
+
}
|
|
27856
|
+
else {
|
|
27857
|
+
this.errors.remove(setnameIndexErrId);
|
|
27858
|
+
}
|
|
27776
27859
|
this.errors.remove(noDateErrId);
|
|
27777
27860
|
return INTERVAL_SETNAME;
|
|
27778
27861
|
}
|
|
27779
27862
|
this.errors.remove(setnameErrId);
|
|
27863
|
+
this.errors.remove(setnameIndexErrId);
|
|
27780
27864
|
if (this.datasetMeta && !((_a = this.datasetMeta.dateRange) === null || _a === void 0 ? void 0 : _a.hasData)) {
|
|
27781
27865
|
this.errors.addOrReplace({
|
|
27782
27866
|
id: noDateErrId,
|
|
@@ -27788,6 +27872,10 @@ const Table$1 = class Table {
|
|
|
27788
27872
|
this.errors.remove(noDateErrId);
|
|
27789
27873
|
return interval;
|
|
27790
27874
|
}
|
|
27875
|
+
prepareCategoryIntervalPosition() {
|
|
27876
|
+
const position = Number(this.categoryIntervalPosition);
|
|
27877
|
+
return Number.isInteger(position) && position > 0 ? position : 0;
|
|
27878
|
+
}
|
|
27791
27879
|
prepareAttributes() {
|
|
27792
27880
|
if (this.tableAttributes == null || this.tableAttributes.trim() === "") {
|
|
27793
27881
|
return [];
|
|
@@ -27893,6 +27981,7 @@ const Table$1 = class Table {
|
|
|
27893
27981
|
const dataSetStructure = {
|
|
27894
27982
|
ITableDataRow: {
|
|
27895
27983
|
setName: { type: "string", isOptional: false, description: "" },
|
|
27984
|
+
setNameIndex: { type: "number", isOptional: true, description: "" },
|
|
27896
27985
|
date: { type: "string", isOptional: false, description: "" },
|
|
27897
27986
|
operation: { type: "string", isOptional: false, description: "" },
|
|
27898
27987
|
rowGroup: { type: "string", isOptional: false, description: "" },
|
|
@@ -28048,7 +28137,7 @@ const Table$1 = class Table {
|
|
|
28048
28137
|
render() {
|
|
28049
28138
|
const fontStyles = this.getFontStyles();
|
|
28050
28139
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
28051
|
-
return (index.h(index.Host, { key: '
|
|
28140
|
+
return (index.h(index.Host, { key: '9c4b7d3df45c425ab5d6f1443a3a067220d3a451', style: fontStyles }, index.h("div", { key: 'b0332096da43ca9d5c139da7f18abdcb89356c37' }, index.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 }))));
|
|
28052
28141
|
}
|
|
28053
28142
|
get element() { return index.getElement(this); }
|
|
28054
28143
|
static get watchers() { return {
|
|
@@ -28118,6 +28207,9 @@ const Table$1 = class Table {
|
|
|
28118
28207
|
"interval": [{
|
|
28119
28208
|
"validateInterval": 0
|
|
28120
28209
|
}],
|
|
28210
|
+
"categoryIntervalPosition": [{
|
|
28211
|
+
"validateCategoryIntervalPosition": 0
|
|
28212
|
+
}],
|
|
28121
28213
|
"tableAttributes": [{
|
|
28122
28214
|
"validateTableAttributes": 0
|
|
28123
28215
|
}]
|
|
@@ -28423,20 +28515,43 @@ function pinLabelsFit(widthEm, emPx, labels, headSize) {
|
|
|
28423
28515
|
const { sides, neg, pos } = sideNeeds(labels, headSize / 2, LABEL_GAP_EM * emPx);
|
|
28424
28516
|
return neg + pos + sides * minExtent(totalWidth, emPx, sides) <= totalWidth + 1e-6;
|
|
28425
28517
|
}
|
|
28426
|
-
function
|
|
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);
|
|
28518
|
+
function barSide(maxBarWidth, breakGap) {
|
|
28432
28519
|
const overdriveZoneWidth = maxBarWidth * OVERDRIVE_FRACTION;
|
|
28433
28520
|
return {
|
|
28434
|
-
totalWidth,
|
|
28435
28521
|
maxBarWidth,
|
|
28436
|
-
axisX,
|
|
28437
28522
|
breakGap,
|
|
28438
28523
|
overdriveZoneWidth,
|
|
28439
28524
|
cutWidth: Math.max(0, maxBarWidth - breakGap - overdriveZoneWidth),
|
|
28525
|
+
};
|
|
28526
|
+
}
|
|
28527
|
+
/**
|
|
28528
|
+
* `sideMax` is the largest absolute value per side of the axis. With it, the bar room is
|
|
28529
|
+
* split so the uncut bar length of each side is in that ratio: the axis sits where the
|
|
28530
|
+
* values need it, at any scale. Without it, both sides get the same extent.
|
|
28531
|
+
*/
|
|
28532
|
+
function absoluteBarGeometry(widthEm, emPx, labels, sideMax) {
|
|
28533
|
+
var _a, _b;
|
|
28534
|
+
const totalWidth = contentWidth(widthEm, emPx);
|
|
28535
|
+
const labelGap = LABEL_GAP_EM * emPx;
|
|
28536
|
+
// a variance bar starts at the outer edge of the thick axis
|
|
28537
|
+
const { extent, axisX } = splitSides(totalWidth, labels, (VARIANCE_AXIS_EM * emPx) / 2, labelGap);
|
|
28538
|
+
const breakGap = Math.min(BREAK_GAP_EM * emPx, extent * 0.2);
|
|
28539
|
+
const hasNeg = labels.neg !== undefined;
|
|
28540
|
+
const hasPos = labels.pos !== undefined || !hasNeg;
|
|
28541
|
+
let neg = hasNeg ? extent : 0;
|
|
28542
|
+
const maxNeg = Math.max(0, (_a = sideMax === null || sideMax === void 0 ? void 0 : sideMax.neg) !== null && _a !== void 0 ? _a : 0);
|
|
28543
|
+
const maxPos = Math.max(0, (_b = sideMax === null || sideMax === void 0 ? void 0 : sideMax.pos) !== null && _b !== void 0 ? _b : 0);
|
|
28544
|
+
if (hasNeg && hasPos && maxNeg + maxPos > 0) {
|
|
28545
|
+
// every side keeps its break gap and overdrive stub, only the uncut length follows the values
|
|
28546
|
+
const uncut = 2 * extent * (1 - OVERDRIVE_FRACTION) - 2 * breakGap;
|
|
28547
|
+
neg = (breakGap + (uncut * maxNeg) / (maxNeg + maxPos)) / (1 - OVERDRIVE_FRACTION);
|
|
28548
|
+
}
|
|
28549
|
+
const pos = hasPos ? (hasNeg ? 2 * extent - neg : extent) : 0;
|
|
28550
|
+
return {
|
|
28551
|
+
totalWidth,
|
|
28552
|
+
neg: barSide(neg, breakGap),
|
|
28553
|
+
pos: barSide(pos, breakGap),
|
|
28554
|
+
axisX: hasNeg ? axisX - extent + neg : 0,
|
|
28440
28555
|
labelGap,
|
|
28441
28556
|
};
|
|
28442
28557
|
}
|
|
@@ -28543,9 +28658,10 @@ const PatternDefs = ({ styles }) => {
|
|
|
28543
28658
|
/** Longest relative label that keeps all percent digits; a longer one drops digits so its gutter does not eat the pins. */
|
|
28544
28659
|
const PIN_LABEL_CHARS = 7;
|
|
28545
28660
|
/**
|
|
28546
|
-
* Formats a
|
|
28661
|
+
* Formats a bar or pin label. An absolute value with `decimalDigits` prints like a number
|
|
28662
|
+
* cell, without them it takes an SI suffix.
|
|
28547
28663
|
*/
|
|
28548
|
-
function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0, percentSign = true) {
|
|
28664
|
+
function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0, percentSign = true, decimalDigits) {
|
|
28549
28665
|
// IBCS prints a value that rounds to zero without a sign
|
|
28550
28666
|
const signed = (text, zero) => (value > 0 && text !== zero ? "+" : "") + text;
|
|
28551
28667
|
if (isRelative) {
|
|
@@ -28563,6 +28679,10 @@ function formatValue(value, isRelative, measureScale = 1, locale, percentDigits
|
|
|
28563
28679
|
}
|
|
28564
28680
|
// Absolute variance - apply measure scale and use SI prefixes
|
|
28565
28681
|
const scaledValue = value / measureScale;
|
|
28682
|
+
if (decimalDigits !== undefined) {
|
|
28683
|
+
const number = (v) => Formatter.number(v, "decimal", decimalDigits, decimalDigits, 1, locale);
|
|
28684
|
+
return signed(number(scaledValue), number(0));
|
|
28685
|
+
}
|
|
28566
28686
|
const absValue = Math.abs(scaledValue);
|
|
28567
28687
|
let unit = 1;
|
|
28568
28688
|
let suffix = "";
|
|
@@ -28745,25 +28865,28 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
|
|
|
28745
28865
|
* exactly `columnWidthEm` em - see barColumnGeometry.ts.
|
|
28746
28866
|
*/
|
|
28747
28867
|
const AbsoluteVarianceBar = (props) => {
|
|
28748
|
-
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, columnWidthEm = 10, labelWidths, styles = DEFAULT_STYLES, } = props;
|
|
28868
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
|
|
28749
28869
|
const s = styles.scaleFactor;
|
|
28750
28870
|
const fs = styles.fontSize;
|
|
28751
|
-
const displayValue = formattedValue || formatValue(value, false, measureScale, locale);
|
|
28871
|
+
const displayValue = formattedValue || formatValue(value, false, measureScale, locale, 0, true, decimalDigits);
|
|
28752
28872
|
const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false));
|
|
28753
|
-
const
|
|
28873
|
+
const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
|
|
28874
|
+
const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
|
|
28875
|
+
const geometry = absoluteBarGeometry(columnWidthEm, styles.emPx, sides, { neg, pos });
|
|
28876
|
+
const { totalWidth, axisX, labelGap } = geometry;
|
|
28877
|
+
const { breakGap, overdriveZoneWidth, cutWidth } = isPositive ? geometry.pos : geometry.neg;
|
|
28754
28878
|
// Direct unit scaling via fontSize
|
|
28755
28879
|
const scaledWidth = Math.abs(value) * styles.unitScaling * fs;
|
|
28756
28880
|
// auto scaling puts the largest bar on the cut, float rounding must not turn it into an overdrive bar
|
|
28757
28881
|
const isExtreme = scaledWidth - cutWidth > 1e-6;
|
|
28758
28882
|
// Compute proportional overdrive width across the column
|
|
28759
|
-
const maxScaledWidth =
|
|
28883
|
+
const maxScaledWidth = (isPositive ? pos : neg) * styles.unitScaling * fs;
|
|
28760
28884
|
const maxOverflow = Math.max(0, maxScaledWidth - cutWidth);
|
|
28761
28885
|
const overflowAmount = Math.max(0, scaledWidth - cutWidth);
|
|
28762
28886
|
const overdriveWidth = maxOverflow > 0 ? (overflowAmount / maxOverflow) * overdriveZoneWidth : 0;
|
|
28763
28887
|
const padding = 2 * s;
|
|
28764
28888
|
const barHeight = height - padding * 2;
|
|
28765
28889
|
const barY = padding;
|
|
28766
|
-
const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
|
|
28767
28890
|
// Get style based on column type (scenario vs variance)
|
|
28768
28891
|
const look = getVarianceLook(scenario, styles);
|
|
28769
28892
|
const sentimentStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
@@ -28871,7 +28994,7 @@ const CellBarChart = (props) => {
|
|
|
28871
28994
|
* guides marking their parent bar's extent.
|
|
28872
28995
|
*/
|
|
28873
28996
|
const WaterfallBar = (props) => {
|
|
28874
|
-
const { value, scenario, height, measureScale, locale, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, } = props;
|
|
28997
|
+
const { value, scenario, height, measureScale, locale, decimalDigits, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, } = props;
|
|
28875
28998
|
const s = styles.scaleFactor;
|
|
28876
28999
|
const fs = styles.fontSize;
|
|
28877
29000
|
const range = waterfall.max - waterfall.min;
|
|
@@ -28893,7 +29016,7 @@ const WaterfallBar = (props) => {
|
|
|
28893
29016
|
const fillValue = getBarFill(barStyle, getScenarioType(scenario));
|
|
28894
29017
|
const { stroke: barStroke, strokeWidth: barStrokeWidth } = getBarStroke(barStyle);
|
|
28895
29018
|
// Scenario values carry no variance sentiment - labels are unsigned per IBCS
|
|
28896
|
-
const displayValue = formatValue(value, waterfall.kind === "partof", measureScale, locale).replace(/^\+/, "");
|
|
29019
|
+
const displayValue = formatValue(value, waterfall.kind === "partof", measureScale, locale, 0, true, decimalDigits).replace(/^\+/, "");
|
|
28897
29020
|
const pointsLeft = endX < startX;
|
|
28898
29021
|
const labelX = pointsLeft ? barX - labelGap : barX + barWidth + labelGap;
|
|
28899
29022
|
const labelAnchor = pointsLeft ? "end" : "start";
|
|
@@ -29168,7 +29291,8 @@ class DataQuery {
|
|
|
29168
29291
|
/** Generates a GROUPHEAD row used as a visual header when row grouping is active. */
|
|
29169
29292
|
createGroupHeaderRow(rowGroupEntry, querys) {
|
|
29170
29293
|
// Generates GroupHeader Row
|
|
29171
|
-
|
|
29294
|
+
// Without a title the group sum row alone closes the group; only a list has no sum row and keeps the head as gap
|
|
29295
|
+
if (true === this.config.grouped && (this.config.showGroupTitle || !this.hasGroupSum())) {
|
|
29172
29296
|
const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
|
|
29173
29297
|
const title = rowGroupEntry.rowGroup === "" ? this.bind(BLANK_BUCKET_LABEL) : rowGroup;
|
|
29174
29298
|
const groupTitle = this.config.showGroupTitle ? `,${title} as ${QueryColumnNames.CATEGORY}` : "";
|
|
@@ -29180,14 +29304,16 @@ class DataQuery {
|
|
|
29180
29304
|
GROUP BY '1'`);
|
|
29181
29305
|
}
|
|
29182
29306
|
}
|
|
29307
|
+
hasGroupSum() {
|
|
29308
|
+
return (TableType.SUM === this.config.type ||
|
|
29309
|
+
TableType.SUMNOTOTAL === this.config.type ||
|
|
29310
|
+
TableType.OPT === this.config.type ||
|
|
29311
|
+
TableType.OPTNOTOTAL === this.config.type);
|
|
29312
|
+
}
|
|
29183
29313
|
/** Generates a GROUP_SUM row that aggregates all entries within a single row group. */
|
|
29184
29314
|
createGroupSumRow(querys, groupSumQuery, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order) {
|
|
29185
29315
|
// 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)) {
|
|
29316
|
+
if (true === this.config.grouped && this.hasGroupSum()) {
|
|
29191
29317
|
const rowGroup = this.bind(String(rowGroupEntry.rowGroup));
|
|
29192
29318
|
querys.push(`SELECT ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX},
|
|
29193
29319
|
'=' as ${QueryColumnNames.OPERATION},
|
|
@@ -29495,17 +29621,19 @@ class DataQuery {
|
|
|
29495
29621
|
const entryRowsRaw = exec(`SELECT ${groups.select()}, __interval ${scenarios.length > 0 ? ",".concat(scenarios) : ""}
|
|
29496
29622
|
FROM ${bucketSource}
|
|
29497
29623
|
GROUP BY ${groups}, __interval`);
|
|
29624
|
+
// only the generated REST row has restRowGroup; a data row with the category REST keeps its own values
|
|
29625
|
+
const isGeneratedRest = (row) => row.type === "ENTRY" && row.restRowGroup != null;
|
|
29498
29626
|
// REST rows first: the math needs the raw (not yet finalized) entry aliases
|
|
29499
29627
|
if (this.config.limit > 0) {
|
|
29500
29628
|
for (let segmentIndex = 0; segmentIndex < res.length; segmentIndex++) {
|
|
29501
|
-
const restRow = res[segmentIndex].find(
|
|
29629
|
+
const restRow = res[segmentIndex].find(isGeneratedRest);
|
|
29502
29630
|
if (!restRow) {
|
|
29503
29631
|
continue;
|
|
29504
29632
|
}
|
|
29505
29633
|
// nearest preceding segment holding the displayed ENTRY rows
|
|
29506
29634
|
let entrySegment;
|
|
29507
29635
|
for (let i = segmentIndex - 1; i >= 0 && !entrySegment; i--) {
|
|
29508
|
-
const candidate = res[i].filter((row) => row.type === "ENTRY" && row
|
|
29636
|
+
const candidate = res[i].filter((row) => row.type === "ENTRY" && !isGeneratedRest(row));
|
|
29509
29637
|
if (candidate.length > 0) {
|
|
29510
29638
|
entrySegment = candidate;
|
|
29511
29639
|
}
|
|
@@ -29543,7 +29671,7 @@ class DataQuery {
|
|
|
29543
29671
|
finalizeBucketRow(entryRow);
|
|
29544
29672
|
for (const segment of res) {
|
|
29545
29673
|
for (const row of segment) {
|
|
29546
|
-
if (row.type !== "ENTRY" || row
|
|
29674
|
+
if (row.type !== "ENTRY" || isGeneratedRest(row) || row.category !== entryRow.category) {
|
|
29547
29675
|
continue;
|
|
29548
29676
|
}
|
|
29549
29677
|
if (this.config.grouped && row.rowGroup !== entryRow.rowGroup) {
|
|
@@ -29817,11 +29945,20 @@ class DataQuery {
|
|
|
29817
29945
|
}
|
|
29818
29946
|
});
|
|
29819
29947
|
this.sortSelect = [...sortKeys.values()].map((key) => `, ${key}`).join("");
|
|
29948
|
+
// a data row with the reserved category REST stays last in its group when the rows are sorted by value
|
|
29949
|
+
const sortsByValue = orderComponent.hierarchy.some((column) => {
|
|
29950
|
+
var _a;
|
|
29951
|
+
const kind = (_a = withStyled.parseOrderToken(column)) === null || _a === void 0 ? void 0 : _a.kind;
|
|
29952
|
+
return kind === "scenario" || kind === "variance";
|
|
29953
|
+
});
|
|
29954
|
+
if (sortsByValue) {
|
|
29955
|
+
this.sortSelect += `, CASE WHEN ${QueryColumnNames.CATEGORY} = 'REST' THEN 1 ELSE 0 END as __sortrest`;
|
|
29956
|
+
}
|
|
29820
29957
|
// rows without a value sort last in both directions
|
|
29821
29958
|
const orderBy = (column, i, direction) => sortKeys.has(i) ? `__sortnull${i} asc, __sort${i} ${direction}` : `${column} ${direction}`;
|
|
29822
29959
|
const base = orderComponent.hierarchy.map((column, i) => orderBy(column, i, orderComponent.direction)).toString();
|
|
29823
29960
|
const inverted = orderComponent.hierarchy.map((column, i) => orderBy(column, i, inverse)).toString();
|
|
29824
|
-
return [base, inverted];
|
|
29961
|
+
return sortsByValue ? [`__sortrest asc, ${base}`, `__sortrest desc, ${inverted}`] : [base, inverted];
|
|
29825
29962
|
}
|
|
29826
29963
|
/**
|
|
29827
29964
|
* Sort key `__sort<i>` of a scenario or variance order token, as printed in an entry cell
|
|
@@ -30164,13 +30301,16 @@ function signedValue(row, column, tableType) {
|
|
|
30164
30301
|
* segmented query result once per column in display order.
|
|
30165
30302
|
*
|
|
30166
30303
|
* - ENTRY rows (incl. REST) cascade from the running total by their signed value.
|
|
30167
|
-
* - SUM / GROUP_SUM rows anchor at zero
|
|
30304
|
+
* - SUM / GROUP_SUM rows anchor at zero. A SUM row resets the running total to its
|
|
30305
|
+
* value, a GROUP_SUM row resets it to zero.
|
|
30168
30306
|
* - DRILLELEMENT (thereof) rows form a sub-cascade from their parent bar's start in
|
|
30169
30307
|
* the parent's direction; the running total is untouched.
|
|
30170
30308
|
* - PARTELEMENT (partof) rows cascade a `share * parent width` segment the same way.
|
|
30171
30309
|
* Note: the share denominator is the group sum (or SUM_TOTAL when ungrouped) per
|
|
30172
30310
|
* `createPartOfDrillRows`, not literally the parent row's value.
|
|
30173
|
-
* - GROUPHEAD
|
|
30311
|
+
* - GROUPHEAD rows get no bar and restart the running total at zero: every row group
|
|
30312
|
+
* is its own cascade that ends at its GROUP_SUM.
|
|
30313
|
+
* - NaN rows get no bar; a NaN parent orphans its drill children.
|
|
30174
30314
|
*
|
|
30175
30315
|
* @param queryData - Segmented result rows from DataQuery.execute().
|
|
30176
30316
|
* @param columns - Plain scenario column keys (ac1..pl4); no `##` composite keys.
|
|
@@ -30191,6 +30331,8 @@ function computeWaterfall(queryData, columns, tableType) {
|
|
|
30191
30331
|
for (const row of groupData) {
|
|
30192
30332
|
const type = row[QueryColumnNames.TYPE];
|
|
30193
30333
|
if (type === TableRowType.GROUPHEAD) {
|
|
30334
|
+
// a group sum only totals its own rows, so the cascade must not carry over
|
|
30335
|
+
running = 0;
|
|
30194
30336
|
lastParent = undefined;
|
|
30195
30337
|
continue;
|
|
30196
30338
|
}
|
|
@@ -30213,7 +30355,8 @@ function computeWaterfall(queryData, columns, tableType) {
|
|
|
30213
30355
|
emit(row, { start: 0, end: value, min: 0, max: 0, kind: "anchor" });
|
|
30214
30356
|
lastParent = { start: 0, end: value };
|
|
30215
30357
|
subCursor = 0;
|
|
30216
|
-
|
|
30358
|
+
// a group sum closes its group (there may be no GROUPHEAD row when the title is hidden)
|
|
30359
|
+
running = type === TableRowType.GROUPSUM ? 0 : value;
|
|
30217
30360
|
}
|
|
30218
30361
|
else if (type === TableRowType.DRILLELEMENT) {
|
|
30219
30362
|
if (value === null || lastParent === undefined) {
|
|
@@ -30268,7 +30411,7 @@ function computeWaterfall(queryData, columns, tableType) {
|
|
|
30268
30411
|
/**
|
|
30269
30412
|
* Transforms raw query results into structured TableRow collections for header and body.
|
|
30270
30413
|
*
|
|
30271
|
-
* Header normalization:
|
|
30414
|
+
* Header normalization: adds the fixed columns (operation, category) to the configured
|
|
30272
30415
|
* scenarios, then translates labels via i18n and adds separator rows for IBCS-style borders.
|
|
30273
30416
|
*
|
|
30274
30417
|
* Body row creation: iterates DataQuery results grouped by rowGroup, creates detail rows
|
|
@@ -30295,7 +30438,7 @@ class TableDataSetFactory {
|
|
|
30295
30438
|
}
|
|
30296
30439
|
return styleSlot(this.ruleSet.getScenarioColorIndex(type)) + type.slice(2);
|
|
30297
30440
|
}
|
|
30298
|
-
/** Effective column list (category/operation + attributes + scenarios × buckets), set by createHeader(). */
|
|
30441
|
+
/** Effective column list (category/operation + attributes + scenarios × buckets) in render order, set by createHeader(). */
|
|
30299
30442
|
getNormalizedHeader() {
|
|
30300
30443
|
return this.normalizedHeader;
|
|
30301
30444
|
}
|
|
@@ -30307,10 +30450,10 @@ class TableDataSetFactory {
|
|
|
30307
30450
|
* visualise grouping.
|
|
30308
30451
|
* finally a seperator header row is created for the header underlining (border)
|
|
30309
30452
|
*/
|
|
30310
|
-
createHeader(type, scenarios, i18n, measureScale, measureUnit, showMeasureScale, attributes = []) {
|
|
30453
|
+
createHeader(type, scenarios, i18n, measureScale, measureUnit, showMeasureScale, attributes = [], leadingScenarioColumns = 0) {
|
|
30311
30454
|
const header = [];
|
|
30312
30455
|
this.attributesByAlias = new Map(attributes.map((attribute) => [attribute.alias, attribute]));
|
|
30313
|
-
this.normalizedHeader = this.normalizeHeader(type, scenarios, attributes);
|
|
30456
|
+
this.normalizedHeader = this.normalizeHeader(type, scenarios, attributes, leadingScenarioColumns);
|
|
30314
30457
|
const hasIntervalColumns = this.normalizedHeader.some((column) => column.bucket !== undefined);
|
|
30315
30458
|
if (hasIntervalColumns) {
|
|
30316
30459
|
header.push(this.createIntervalBandRow());
|
|
@@ -30330,7 +30473,7 @@ class TableDataSetFactory {
|
|
|
30330
30473
|
}
|
|
30331
30474
|
/**
|
|
30332
30475
|
* Creates the spanning interval band row (e.g. `2023 | 2024 | 2025`) rendered
|
|
30333
|
-
* above the scenario label row.
|
|
30476
|
+
* above the scenario label row. Non-interval columns (category,
|
|
30334
30477
|
* operation, attributes) receive borderless filler cells; each run of
|
|
30335
30478
|
* consecutive columns of the same bucket is spanned by one label cell.
|
|
30336
30479
|
*/
|
|
@@ -30371,8 +30514,11 @@ class TableDataSetFactory {
|
|
|
30371
30514
|
* configured scenarios.
|
|
30372
30515
|
* depending of table type operation column is used (OPT) or not (SUM | LIST)
|
|
30373
30516
|
* in addition the headers are sorted based on the ruleset and duplicates are removed
|
|
30517
|
+
*
|
|
30518
|
+
* operation, category and the attribute columns are the row header block. It moves
|
|
30519
|
+
* as one unit: `leadingScenarioColumns` scenario columns stand left of it.
|
|
30374
30520
|
*/
|
|
30375
|
-
normalizeHeader(type, scenarios, attributes) {
|
|
30521
|
+
normalizeHeader(type, scenarios, attributes, leadingScenarioColumns = 0) {
|
|
30376
30522
|
let header = [
|
|
30377
30523
|
{
|
|
30378
30524
|
name: QueryColumnNames.CATEGORY,
|
|
@@ -30405,7 +30551,12 @@ class TableDataSetFactory {
|
|
|
30405
30551
|
order: undefined,
|
|
30406
30552
|
}));
|
|
30407
30553
|
// NOTE: scenarios are already sorted in setConfig
|
|
30408
|
-
return [
|
|
30554
|
+
return [
|
|
30555
|
+
...scenarios.slice(0, leadingScenarioColumns),
|
|
30556
|
+
...header,
|
|
30557
|
+
...attributeColumns,
|
|
30558
|
+
...scenarios.slice(leadingScenarioColumns),
|
|
30559
|
+
];
|
|
30409
30560
|
}
|
|
30410
30561
|
/**
|
|
30411
30562
|
* Creates table data colelction,
|
|
@@ -30941,7 +31092,9 @@ class Table {
|
|
|
30941
31092
|
update() {
|
|
30942
31093
|
this.prepareIntervalBuckets();
|
|
30943
31094
|
const normalizedScenarios = this.normalizeScenarios(this.config.scenarios, this.config.categoryThereOf, this.config.sortOrder, this.intervalBuckets);
|
|
30944
|
-
this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes
|
|
31095
|
+
this.headerRows = this.dataSetFactory.createHeader(this.config.type, normalizedScenarios, this.i18n, this.config.measureScale, this.config.measureUnit, this.config.showMeasureScale, this.config.attributes,
|
|
31096
|
+
// every interval group has one column per scenario
|
|
31097
|
+
Math.min(this.categoryIntervalPosition(), this.intervalBuckets.length) * this.config.scenarios.length);
|
|
30945
31098
|
this.bodyRows =
|
|
30946
31099
|
this.rowCount === 0 || !this.fromExpr
|
|
30947
31100
|
? []
|
|
@@ -30960,7 +31113,10 @@ class Table {
|
|
|
30960
31113
|
}
|
|
30961
31114
|
return this.bodyRows;
|
|
30962
31115
|
}
|
|
30963
|
-
/**
|
|
31116
|
+
/**
|
|
31117
|
+
* Effective column definitions in render order: category/operation + attributes + scenarios × interval buckets.
|
|
31118
|
+
* With `categoryIntervalPosition` the first interval buckets come before the category/operation column.
|
|
31119
|
+
*/
|
|
30964
31120
|
getColumns() {
|
|
30965
31121
|
if (this.state === FactoryState$1.DIRTY) {
|
|
30966
31122
|
this.update();
|
|
@@ -31061,6 +31217,32 @@ class Table {
|
|
|
31061
31217
|
const unknown = buckets.find((bucket) => !this.intervalBuckets.some((b) => b.key === bucket));
|
|
31062
31218
|
return unknown === undefined ? undefined : `order: setname '${unknown}' not found, the rows are not sorted by it.`;
|
|
31063
31219
|
}
|
|
31220
|
+
/** The configured `categoryIntervalPosition`; anything but a positive integer counts as 0. */
|
|
31221
|
+
categoryIntervalPosition() {
|
|
31222
|
+
const position = this.config.categoryIntervalPosition;
|
|
31223
|
+
return Number.isInteger(position) && position > 0 ? position : 0;
|
|
31224
|
+
}
|
|
31225
|
+
/** Warning for a `categoryIntervalPosition` that cannot apply, once the body was built; undefined when it applies. */
|
|
31226
|
+
categoryIntervalPositionWarning() {
|
|
31227
|
+
const position = this.categoryIntervalPosition();
|
|
31228
|
+
if (position <= 0 || this.hasNoData() || this.state !== FactoryState$1.UP_TO_DATE) {
|
|
31229
|
+
return undefined;
|
|
31230
|
+
}
|
|
31231
|
+
const groups = this.intervalBuckets.length;
|
|
31232
|
+
if (groups === 0) {
|
|
31233
|
+
return {
|
|
31234
|
+
id: "WARN_categoryIntervalPositionNoInterval",
|
|
31235
|
+
message: "categoryIntervalPosition: needs an active interval, the value is ignored.",
|
|
31236
|
+
};
|
|
31237
|
+
}
|
|
31238
|
+
if (position > groups) {
|
|
31239
|
+
return {
|
|
31240
|
+
id: "WARN_categoryIntervalPositionRange",
|
|
31241
|
+
message: `categoryIntervalPosition: '${position}' is greater than the number of interval groups, ${groups} is used.`,
|
|
31242
|
+
};
|
|
31243
|
+
}
|
|
31244
|
+
return undefined;
|
|
31245
|
+
}
|
|
31064
31246
|
/** True once the body was built and the grouped table has rows with a blank rowGroup. */
|
|
31065
31247
|
hasBlankRowGroup() {
|
|
31066
31248
|
return this.dataSetFactory.hasBlankRowGroup;
|
|
@@ -31120,6 +31302,8 @@ class TableComponentConfig {
|
|
|
31120
31302
|
this.barColumns = [];
|
|
31121
31303
|
/** Interval column grouping: "none", "setname" or a DateDistance value (see bn-table `interval` prop). */
|
|
31122
31304
|
this.interval = "none";
|
|
31305
|
+
/** Number of interval groups left of the row header block (see bn-table `categoryIntervalPosition` prop). */
|
|
31306
|
+
this.categoryIntervalPosition = 0;
|
|
31123
31307
|
/** Locale used for interval bucket labels. */
|
|
31124
31308
|
this.locale = "de";
|
|
31125
31309
|
}
|
|
@@ -31203,6 +31387,9 @@ class TableComponentConfigAdapter {
|
|
|
31203
31387
|
if (withStyled.CompareUtil.isString(data.interval)) {
|
|
31204
31388
|
config.interval = data.interval;
|
|
31205
31389
|
}
|
|
31390
|
+
if (withStyled.CompareUtil.isNumber(data.categoryIntervalPosition)) {
|
|
31391
|
+
config.categoryIntervalPosition = data.categoryIntervalPosition;
|
|
31392
|
+
}
|
|
31206
31393
|
if (withStyled.CompareUtil.isString(data.locale)) {
|
|
31207
31394
|
config.locale = data.locale;
|
|
31208
31395
|
}
|
|
@@ -31325,6 +31512,8 @@ const BnTableRenderer = class {
|
|
|
31325
31512
|
this.barColumns = [];
|
|
31326
31513
|
/** @internal */
|
|
31327
31514
|
this.interval = "none";
|
|
31515
|
+
/** @internal */
|
|
31516
|
+
this.categoryIntervalPosition = 0;
|
|
31328
31517
|
/**
|
|
31329
31518
|
* Total width of a bar chart column, in em of the table font - the same unit
|
|
31330
31519
|
* `categoryWidth` uses, so the two render at the same width for the same value.
|
|
@@ -31479,13 +31668,15 @@ const BnTableRenderer = class {
|
|
|
31479
31668
|
: {})), cell.prefix != null ? (index.h("span", { class: cell.cssStyle + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
|
|
31480
31669
|
cell.columnStats &&
|
|
31481
31670
|
cell.value !== withStyled.NOT_AVAILABLE &&
|
|
31482
|
-
|
|
31671
|
+
// an untitled group head is only a gap between list groups, a bar cell would print "-" in it
|
|
31672
|
+
(this.showGroupTitle || row.type !== TableRowType.HEADER) &&
|
|
31673
|
+
(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
31674
|
})))))));
|
|
31484
31675
|
};
|
|
31485
31676
|
return index.h(index.Host, { class: { "no-data": ((_a = this.table) === null || _a === void 0 ? void 0 : _a.hasNoData()) === true } }, helper());
|
|
31486
31677
|
}
|
|
31487
31678
|
componentWillRender() {
|
|
31488
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
31679
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
31489
31680
|
if (!this.stores)
|
|
31490
31681
|
this.stores = withHasError.getStores(this.element);
|
|
31491
31682
|
const db = this.stores.db.db;
|
|
@@ -31525,6 +31716,15 @@ const BnTableRenderer = class {
|
|
|
31525
31716
|
else {
|
|
31526
31717
|
(_h = this.errors) === null || _h === void 0 ? void 0 : _h.remove("WARN_orderBucket");
|
|
31527
31718
|
}
|
|
31719
|
+
const positionWarning = (_j = this.table) === null || _j === void 0 ? void 0 : _j.categoryIntervalPositionWarning();
|
|
31720
|
+
for (const id of ["WARN_categoryIntervalPositionNoInterval", "WARN_categoryIntervalPositionRange"]) {
|
|
31721
|
+
if ((positionWarning === null || positionWarning === void 0 ? void 0 : positionWarning.id) === id) {
|
|
31722
|
+
(_k = this.errors) === null || _k === void 0 ? void 0 : _k.addOrReplace({ id, type: "warning", message: positionWarning.message });
|
|
31723
|
+
}
|
|
31724
|
+
else {
|
|
31725
|
+
(_l = this.errors) === null || _l === void 0 ? void 0 : _l.remove(id);
|
|
31726
|
+
}
|
|
31727
|
+
}
|
|
31528
31728
|
this.barColumnLayouts = this.collectBarColumnLayouts();
|
|
31529
31729
|
this.barChartStyles = this.prepareBarChartStyles();
|
|
31530
31730
|
}
|
|
@@ -31557,6 +31757,7 @@ const BnTableRenderer = class {
|
|
|
31557
31757
|
filter: this.filter,
|
|
31558
31758
|
barColumns: this.barColumns,
|
|
31559
31759
|
interval: this.interval,
|
|
31760
|
+
categoryIntervalPosition: this.categoryIntervalPosition,
|
|
31560
31761
|
locale: ((_c = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.locale) || "de",
|
|
31561
31762
|
});
|
|
31562
31763
|
return config;
|
|
@@ -31655,14 +31856,21 @@ const BnTableRenderer = class {
|
|
|
31655
31856
|
* One scaling for all columns, so it is the smallest that fits every column.
|
|
31656
31857
|
*/
|
|
31657
31858
|
autoUnitScaling() {
|
|
31859
|
+
var _a;
|
|
31658
31860
|
const emPx = this.emPx();
|
|
31659
31861
|
const fs = emPx * BAR_LABEL_FONT_RATIO;
|
|
31660
31862
|
let scaling = Infinity;
|
|
31661
|
-
for (const { isRelative, absMax, labels } of this.barColumnLayouts.values()) {
|
|
31863
|
+
for (const { isRelative, absMax, labels, sideMax } of this.barColumnLayouts.values()) {
|
|
31662
31864
|
if (isRelative || absMax <= 0)
|
|
31663
31865
|
continue;
|
|
31664
|
-
const
|
|
31665
|
-
|
|
31866
|
+
const geometry = absoluteBarGeometry(this.barColumnMaxWidth, emPx, labels, sideMax);
|
|
31867
|
+
for (const side of ["neg", "pos"]) {
|
|
31868
|
+
const max = (_a = sideMax[side]) !== null && _a !== void 0 ? _a : 0;
|
|
31869
|
+
if (max <= 0)
|
|
31870
|
+
continue;
|
|
31871
|
+
const { maxBarWidth, cutWidth } = geometry[side];
|
|
31872
|
+
scaling = Math.min(scaling, Math.min(maxBarWidth * 0.8, cutWidth) / (max * fs));
|
|
31873
|
+
}
|
|
31666
31874
|
}
|
|
31667
31875
|
return Number.isFinite(scaling) && fs > 0 ? scaling : 0.01;
|
|
31668
31876
|
}
|
|
@@ -31727,7 +31935,7 @@ const BnTableRenderer = class {
|
|
|
31727
31935
|
for (const cell of cells) {
|
|
31728
31936
|
const value = cell.value;
|
|
31729
31937
|
const side = value > 0 || (value === 0 && zeroPositive) ? "pos" : "neg";
|
|
31730
|
-
const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign);
|
|
31938
|
+
const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign, barLabelDigits(cell, this.componentDataFormatDigits));
|
|
31731
31939
|
labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative));
|
|
31732
31940
|
}
|
|
31733
31941
|
return labels;
|
|
@@ -31760,6 +31968,12 @@ const BnTableRenderer = class {
|
|
|
31760
31968
|
function barLabelMeasureScale(cell) {
|
|
31761
31969
|
return cell.type === "percentpoint" ? 0.01 : cell.measureScale;
|
|
31762
31970
|
}
|
|
31971
|
+
/** Fraction digits of the number cells of the column, so an absolute bar label prints like them. */
|
|
31972
|
+
function barLabelDigits(cell, digits) {
|
|
31973
|
+
if (cell.type === "percentpoint")
|
|
31974
|
+
return digits.percent;
|
|
31975
|
+
return cell.type === "decimal" ? digits.decimal : undefined;
|
|
31976
|
+
}
|
|
31763
31977
|
BnTableRenderer.style = bnTableRendererCss();
|
|
31764
31978
|
|
|
31765
31979
|
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)}`;
|