@bino-bi/bn-template-engine 1.0.0-next.34 → 1.0.0-next.35
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-4ef6683e.entry.js +1 -0
- package/dist/bn-template-engine/{p-7d475277.entry.js → p-5a64f90f.entry.js} +1 -1
- package/dist/bn-template-engine/{p-789bfd06.entry.js → p-93b8387f.entry.js} +1 -1
- package/dist/bn-template-engine/{p-66ed6259.entry.js → p-9a61f59d.entry.js} +1 -1
- package/dist/bn-template-engine/p-BVU4bIsi.js +1 -0
- package/dist/bn-template-engine/{p-CJfJQT0m.js → p-D0tNATZq.js} +1 -1
- package/dist/bn-template-engine/p-DF9sfwBN.js +1 -0
- package/dist/bn-template-engine/{p-CAvWZ3a5.js → p-DyupX-Z-.js} +1 -1
- package/dist/bn-template-engine/{p-14d021be.entry.js → p-b0dfc113.entry.js} +1 -1
- package/dist/bn-template-engine/{p-dec6837c.entry.js → p-eea538f1.entry.js} +1 -1
- package/dist/bn-template-engine/{p-CHZ50kEY.js → p-qpZjVnX5.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +206 -48
- package/dist/cjs/bn-grid.cjs.entry.js +3 -3
- package/dist/cjs/bn-image.cjs.entry.js +2 -2
- package/dist/cjs/bn-internationalization.cjs.entry.js +2 -2
- package/dist/cjs/bn-ruleset.cjs.entry.js +2 -2
- package/dist/cjs/bn-text.cjs.entry.js +3 -3
- package/dist/cjs/{localFrame-P5SDUOto.js → localFrame-U3Qs0psw.js} +1 -1
- package/dist/cjs/{withBodyObserver-B1_hmuUz.js → withBodyObserver-S-FGHpAX.js} +1 -1
- package/dist/cjs/{withHasError-3kR2tdhJ.js → withHasError-BkBrsCpI.js} +8 -7
- package/dist/cjs/{withStyled-eHD8Yt2K.js → withStyled-DfE0aW7D.js} +63 -3
- package/dist/cjs/{withTranslation-yJ-j0lsu.js → withTranslation-0gkn9xoC.js} +2 -2
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +9 -2
- package/dist/collection/components/bn-table/bn-table.js +19 -10
- package/dist/collection/components/bn-table/utils/Table.js +34 -8
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +84 -13
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +57 -10
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +5 -5
- package/dist/collection/stores/ruleSets.js +8 -7
- package/dist/collection/utils/ibcsRuleSet.js +2 -1
- package/dist/collection/utils/model/Order.js +49 -2
- package/dist/collection/utils/validate.js +11 -1
- package/dist/components/bn-annotation-layer.js +1 -1
- package/dist/components/bn-annotation-list.js +1 -1
- package/dist/components/bn-asset.js +1 -1
- package/dist/components/bn-body.js +1 -1
- package/dist/components/bn-card.js +1 -1
- 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-renderer.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time-renderer.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-component-style.js +1 -1
- package/dist/components/bn-context.js +1 -1
- package/dist/components/bn-dataset.js +1 -1
- package/dist/components/bn-datasource.js +1 -1
- package/dist/components/bn-footer.js +1 -1
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-image.js +1 -1
- package/dist/components/bn-internationalization.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/components/bn-layout-page.js +1 -1
- package/dist/components/bn-message.js +1 -1
- package/dist/components/bn-page.js +1 -1
- package/dist/components/bn-ruleset.js +1 -1
- package/dist/components/bn-scaling-group.js +1 -1
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/bn-text.js +1 -1
- package/dist/components/bn-title-renderer.js +1 -1
- package/dist/components/bn-title.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/p-16rjcQ0t.js +1 -0
- package/dist/components/{p-8a2-IS-y.js → p-2eicD9rF.js} +1 -1
- package/dist/components/p-4vVbchX2.js +1 -0
- package/dist/components/{p-VIw66ez1.js → p-7ieJFBUk.js} +1 -1
- package/dist/components/{p-Dn3DJxQQ.js → p-9mUU4itF.js} +1 -1
- package/dist/components/{p-D5LDmR4u.js → p-B5tixDPM.js} +1 -1
- package/dist/components/p-BPGLOHUe.js +1 -0
- package/dist/components/{p-B3F_c9GB.js → p-BU_53KVT.js} +1 -1
- package/dist/components/p-BW842XlW.js +1 -0
- package/dist/components/p-BXXjh6We.js +1 -0
- package/dist/components/{p-C-oNdJj9.js → p-BXg3v5AO.js} +1 -1
- package/dist/components/{p-B7UDMyar.js → p-BhEdmPjm.js} +1 -1
- package/dist/components/{p-nHZ8466v.js → p-BmOWXYHF.js} +1 -1
- package/dist/components/{p-DLLljAll.js → p-Bo_R7f_T.js} +1 -1
- package/dist/components/{p-DdG2Ylar.js → p-BqUB56k1.js} +1 -1
- package/dist/components/{p-DHAoxu6M.js → p-BzjGUtYh.js} +1 -1
- package/dist/components/{p-BtH2oezK.js → p-C-KX1_tw.js} +1 -1
- package/dist/components/{p-BldMZbAf.js → p-C3gYq-HU.js} +1 -1
- package/dist/components/{p-CPC9Vkmg.js → p-CQVAHG6w.js} +1 -1
- package/dist/components/{p-4BanAktr.js → p-C_6KHDYv.js} +1 -1
- package/dist/components/{p-ClGOhg6P.js → p-Cel0a6ma.js} +1 -1
- package/dist/components/{p-Ku08TQL1.js → p-Chuj-LpI.js} +1 -1
- package/dist/components/{p-M6hn0BuZ.js → p-CniN8ALm.js} +1 -1
- package/dist/components/{p-BcOud3dQ.js → p-DDvWTgk1.js} +1 -1
- package/dist/components/p-DJUffGeB.js +1 -0
- package/dist/components/p-DQl2K2Xl.js +1 -0
- package/dist/components/p-DT04Cka0.js +1 -0
- package/dist/components/{p-BVnYDfb8.js → p-DTmqMQpw.js} +1 -1
- package/dist/components/{p-DSkyHSIL.js → p-DaOm9YwQ.js} +1 -1
- package/dist/components/p-DjPWZfry.js +1 -0
- package/dist/components/{p-BXt0ers2.js → p-Dm6EAaJ9.js} +1 -1
- package/dist/components/p-Do4oPrkE.js +1 -0
- package/dist/components/{p-DEHnizot.js → p-Dq9dG0Kr.js} +1 -1
- package/dist/components/{p-D6cWoDk1.js → p-M2k_I8lv.js} +1 -1
- package/dist/components/{p-B4pmO5QQ.js → p-NBaq67dL.js} +1 -1
- package/dist/components/p-OquycEMA.js +1 -0
- package/dist/components/{p-CJtE8Pyr.js → p-eWxolPDU.js} +1 -1
- package/dist/components/{p-De82WP7z.js → p-fKJx8WtW.js} +1 -1
- package/dist/components/{p-xhiPDAZa.js → p-sLbQ7yZ1.js} +1 -1
- package/dist/components/{p-GrpYAVHb.js → p-sar8m7th.js} +1 -1
- package/dist/components/{p-CYqHwYgQ.js → p-tkB96Ena.js} +1 -1
- package/dist/esm/bn-annotation-layer_30.entry.js +206 -48
- package/dist/esm/bn-grid.entry.js +3 -3
- package/dist/esm/bn-image.entry.js +2 -2
- package/dist/esm/bn-internationalization.entry.js +2 -2
- package/dist/esm/bn-ruleset.entry.js +2 -2
- package/dist/esm/bn-text.entry.js +3 -3
- package/dist/esm/{localFrame-IW84cmdb.js → localFrame-BNWPPaQa.js} +1 -1
- package/dist/esm/{withBodyObserver-CAnnvrE_.js → withBodyObserver-AHQAUV85.js} +1 -1
- package/dist/esm/{withHasError-Cj_MzZ8Q.js → withHasError-B6Lvj9Cq.js} +8 -7
- package/dist/esm/{withStyled-Cxua0iTP.js → withStyled-CIoJ86RM.js} +61 -4
- package/dist/esm/{withTranslation-BeAbw2--.js → withTranslation-BX9T3dfm.js} +2 -2
- package/dist/types/components/bn-table/bn-table.d.ts +17 -4
- package/dist/types/components/bn-table/utils/Table.d.ts +2 -0
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +1 -1
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +8 -0
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +3 -2
- package/dist/types/components.d.ts +4 -4
- package/dist/types/stores/ruleSets.d.ts +2 -1
- package/dist/types/utils/ibcsRuleSet.d.ts +2 -1
- package/dist/types/utils/model/Order.d.ts +18 -1
- package/dist/types/utils/validate.d.ts +2 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-BNCLKXjM.js +0 -1
- package/dist/bn-template-engine/p-_SKPuKfK.js +0 -1
- package/dist/bn-template-engine/p-dc12ff1b.entry.js +0 -1
- package/dist/components/p-BNWZoAip.js +0 -1
- package/dist/components/p-BT2WH_CP.js +0 -1
- package/dist/components/p-BVtD8O36.js +0 -1
- package/dist/components/p-BWRE5w0i.js +0 -1
- package/dist/components/p-C6XrNN2m.js +0 -1
- package/dist/components/p-CGI6XIaK.js +0 -1
- package/dist/components/p-CLkpoHdg.js +0 -1
- package/dist/components/p-CYv_8LrR.js +0 -1
- package/dist/components/p-Ckl1aEvn.js +0 -1
- package/dist/components/p-CurWSJkH.js +0 -1
- package/dist/components/p-D7X69xMg.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-DGis1BzT.js');
|
|
4
|
-
var withHasError = require('./withHasError-
|
|
4
|
+
var withHasError = require('./withHasError-BkBrsCpI.js');
|
|
5
5
|
|
|
6
6
|
const isObject = (obj) => {
|
|
7
7
|
if (typeof obj === 'object' && obj !== null) {
|
|
@@ -949,15 +949,62 @@ class Order {
|
|
|
949
949
|
this.direction = direction;
|
|
950
950
|
}
|
|
951
951
|
}
|
|
952
|
+
const DIM_COLUMNS = [
|
|
953
|
+
exports.OrderColumn.ROWGROUP,
|
|
954
|
+
exports.OrderColumn.ROWGROUPINDEX,
|
|
955
|
+
exports.OrderColumn.CATEGORY,
|
|
956
|
+
exports.OrderColumn.CATEGORYINDEX,
|
|
957
|
+
exports.OrderColumn.SUBCATEGORY,
|
|
958
|
+
exports.OrderColumn.SUBCATEGORYINDEX,
|
|
959
|
+
];
|
|
960
|
+
const ORDER_SCENARIO_REGEX = /^(?:ac|fc|pp|pl)[1-4]$/;
|
|
961
|
+
const ORDER_VARIANCE_REGEX = /^(dr|d)((?:ac|fc|pp|pl)[1-4])_((?:ac|fc|pp|pl)[1-4])(?:_(?:pos|neg|neu|opinv|op))?$/;
|
|
962
|
+
/** Parses one bn-table order token, case-insensitive except for the bucket. undefined: not a valid token. */
|
|
963
|
+
function parseOrderToken(token) {
|
|
964
|
+
if (token == null) {
|
|
965
|
+
return undefined;
|
|
966
|
+
}
|
|
967
|
+
const at = token.indexOf("@");
|
|
968
|
+
const head = (at < 0 ? token : token.slice(0, at)).trim().toLowerCase();
|
|
969
|
+
const bucket = at < 0 ? undefined : token.slice(at + 1).trim();
|
|
970
|
+
if (bucket === "") {
|
|
971
|
+
return undefined;
|
|
972
|
+
}
|
|
973
|
+
const dim = exports.OrderColumn[head.toUpperCase()];
|
|
974
|
+
if (dim != null && DIM_COLUMNS.includes(dim)) {
|
|
975
|
+
return bucket === undefined ? { kind: "dim", column: dim } : undefined;
|
|
976
|
+
}
|
|
977
|
+
if (ORDER_SCENARIO_REGEX.test(head)) {
|
|
978
|
+
return { kind: "scenario", column: head, bucket };
|
|
979
|
+
}
|
|
980
|
+
const variance = ORDER_VARIANCE_REGEX.exec(head);
|
|
981
|
+
if (variance != null) {
|
|
982
|
+
const [, type, base, delta] = variance;
|
|
983
|
+
return { kind: "variance", column: `${type}${base}_${delta}`, type: type, base, delta, bucket };
|
|
984
|
+
}
|
|
985
|
+
return undefined;
|
|
986
|
+
}
|
|
987
|
+
/** Normalized form of a bn-table order token (`column[@bucket]`), undefined when it does not parse. */
|
|
988
|
+
function normalizeOrderToken(token) {
|
|
989
|
+
const parsed = parseOrderToken(token);
|
|
990
|
+
if (parsed == null) {
|
|
991
|
+
return undefined;
|
|
992
|
+
}
|
|
993
|
+
return parsed.bucket === undefined ? parsed.column : `${parsed.column}@${parsed.bucket}`;
|
|
994
|
+
}
|
|
952
995
|
class OrderAdapter {
|
|
953
|
-
|
|
996
|
+
/** @param allowMeasures bn-table only: keep variance and `@bucket` tokens instead of mapping them to category. */
|
|
997
|
+
constructor(stringAdapter, allowMeasures = false) {
|
|
954
998
|
this.stringAdapter = stringAdapter;
|
|
999
|
+
this.allowMeasures = allowMeasures;
|
|
955
1000
|
}
|
|
956
1001
|
adapt(data) {
|
|
957
1002
|
var _a;
|
|
958
1003
|
const hierarchy = AdapterUtils.adaptArray(data.hierarchy, this.stringAdapter);
|
|
959
1004
|
const order = exports.OrderDirection[(_a = data.direction) === null || _a === void 0 ? void 0 : _a.toUpperCase()] || exports.OrderDirection.ASC;
|
|
960
|
-
return new Order(hierarchy.map((str) =>
|
|
1005
|
+
return new Order(hierarchy.map((str) => (this.allowMeasures
|
|
1006
|
+
? normalizeOrderToken(str)
|
|
1007
|
+
: exports.OrderColumn[str.toUpperCase()]) || exports.OrderColumn.CATEGORY), order);
|
|
961
1008
|
}
|
|
962
1009
|
default() {
|
|
963
1010
|
return new Order(["category"], exports.OrderDirection.ASC);
|
|
@@ -1150,6 +1197,16 @@ function validateOrderList(value) {
|
|
|
1150
1197
|
const invalidScenarios = value.split(",").filter((element) => !(element.toUpperCase() in exports.OrderColumn));
|
|
1151
1198
|
return validateVariancesList(invalidScenarios.toString());
|
|
1152
1199
|
}
|
|
1200
|
+
/** bn-table order: dims, scenarios and variances, the last two optionally with `@<setname>`. */
|
|
1201
|
+
function validateTableOrderList(value) {
|
|
1202
|
+
if (isBlankInput(value)) {
|
|
1203
|
+
return [];
|
|
1204
|
+
}
|
|
1205
|
+
if (value.trim().toLowerCase() === "auto") {
|
|
1206
|
+
return [];
|
|
1207
|
+
}
|
|
1208
|
+
return value.split(",").filter((element) => parseOrderToken(element) === undefined);
|
|
1209
|
+
}
|
|
1153
1210
|
function isValidInteger(value) {
|
|
1154
1211
|
if (isBlankInput(value)) {
|
|
1155
1212
|
return false;
|
|
@@ -1642,6 +1699,8 @@ exports.isValidNumber = isValidNumber;
|
|
|
1642
1699
|
exports.isValidTableType = isValidTableType;
|
|
1643
1700
|
exports.merge = merge;
|
|
1644
1701
|
exports.murmur2 = murmur2;
|
|
1702
|
+
exports.normalizeOrderToken = normalizeOrderToken;
|
|
1703
|
+
exports.parseOrderToken = parseOrderToken;
|
|
1645
1704
|
exports.parseTableAttributeExpression = parseTableAttributeExpression;
|
|
1646
1705
|
exports.relativeVariance = relativeVariance;
|
|
1647
1706
|
exports.resolveMeasure = resolveMeasure;
|
|
@@ -1655,6 +1714,7 @@ exports.validateOrderList = validateOrderList;
|
|
|
1655
1714
|
exports.validatePartOfJsonStr = validatePartOfJsonStr;
|
|
1656
1715
|
exports.validateScenarioList = validateScenarioList;
|
|
1657
1716
|
exports.validateStackConfig = validateStackConfig;
|
|
1717
|
+
exports.validateTableOrderList = validateTableOrderList;
|
|
1658
1718
|
exports.validateThereOfJsonStr = validateThereOfJsonStr;
|
|
1659
1719
|
exports.validateVariancesList = validateVariancesList;
|
|
1660
1720
|
exports.withComponentStyle = withComponentStyle;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var withHasError = require('./withHasError-
|
|
3
|
+
var withHasError = require('./withHasError-BkBrsCpI.js');
|
|
4
4
|
var index = require('./index-DGis1BzT.js');
|
|
5
|
-
var withStyled = require('./withStyled-
|
|
5
|
+
var withStyled = require('./withStyled-DfE0aW7D.js');
|
|
6
6
|
|
|
7
7
|
const ALLOWED_TAGS = new Set([
|
|
8
8
|
"br",
|
|
@@ -240,7 +240,7 @@ export class BnTableRenderer {
|
|
|
240
240
|
return h(Host, { class: { "no-data": ((_a = this.table) === null || _a === void 0 ? void 0 : _a.hasNoData()) === true } }, helper());
|
|
241
241
|
}
|
|
242
242
|
componentWillRender() {
|
|
243
|
-
var _a, _b, _c, _d, _e;
|
|
243
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
244
244
|
if (!this.stores)
|
|
245
245
|
this.stores = getStores(this.element);
|
|
246
246
|
const db = this.stores.db.db;
|
|
@@ -273,12 +273,19 @@ export class BnTableRenderer {
|
|
|
273
273
|
else {
|
|
274
274
|
(_e = this.errors) === null || _e === void 0 ? void 0 : _e.remove("WARN_blankRowGroup");
|
|
275
275
|
}
|
|
276
|
+
const orderBucketWarning = (_f = this.table) === null || _f === void 0 ? void 0 : _f.orderBucketWarning();
|
|
277
|
+
if (orderBucketWarning) {
|
|
278
|
+
(_g = this.errors) === null || _g === void 0 ? void 0 : _g.addOrReplace({ id: "WARN_orderBucket", type: "warning", message: orderBucketWarning });
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
(_h = this.errors) === null || _h === void 0 ? void 0 : _h.remove("WARN_orderBucket");
|
|
282
|
+
}
|
|
276
283
|
this.barChartStyles = this.prepareBarChartStyles();
|
|
277
284
|
}
|
|
278
285
|
prepareConfig(db) {
|
|
279
286
|
var _a, _b, _c;
|
|
280
287
|
const fromExpr = sourceExpr(db, this.tableName, this.filter);
|
|
281
|
-
const config = new TableComponentConfigAdapter(new TableDrillGroupAdapter(), new StringAdapter(), new OrderAdapter(new StringAdapter()), db, fromExpr,
|
|
288
|
+
const config = new TableComponentConfigAdapter(new TableDrillGroupAdapter(), new StringAdapter(), new OrderAdapter(new StringAdapter(), true), db, fromExpr,
|
|
282
289
|
// a failed measure-scale query ends in the ERR_sql of componentWillRender
|
|
283
290
|
(e) => {
|
|
284
291
|
throw e;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { forceUpdate, h, Host, writeTask } from "@stencil/core";
|
|
2
2
|
import { hasInlineJs } from "../../context/scopedDb";
|
|
3
|
-
import { isBlankInput, isTableBarColumnWidth, isTableCategoryWidth, isValidDataFormat, isValidDateFormat, isValidDirection, isValidInteger, isValidMeasureScale, isValidMeasureType, isValidTableType, validateAttributesJsonStr, validateBarColumnsList, validateColumnThereOfJsonStr,
|
|
3
|
+
import { isBlankInput, isTableBarColumnWidth, isTableCategoryWidth, isValidDataFormat, isValidDateFormat, isValidDirection, isValidInteger, isValidMeasureScale, isValidMeasureType, isValidTableType, validateAttributesJsonStr, validateBarColumnsList, validateColumnThereOfJsonStr, validateTableOrderList, validatePartOfJsonStr, validateScenarioList, validateThereOfJsonStr, validateVariancesList, } from "../../utils/validate";
|
|
4
4
|
import withDataset from "../../utils/withDataset";
|
|
5
5
|
import withComponentStatus from "../../utils/withComponentStatus";
|
|
6
6
|
import withScalingGroup from "../../utils/withScalingGroup";
|
|
@@ -19,7 +19,7 @@ import { BAR_COLUMN_WIDTH_EM, DataFormat, I18nMode, MeasureType, TableBarColumnW
|
|
|
19
19
|
import { TableType } from "./utils/model";
|
|
20
20
|
import { INTERVAL_NONE, INTERVAL_SETNAME } from "./utils/helper/IntervalColumns";
|
|
21
21
|
import { parseTableAttributeExpression } from "./utils/model/TableAttribute";
|
|
22
|
-
import {
|
|
22
|
+
import { normalizeOrderToken, OrderDirection } from "../../utils/model/Order";
|
|
23
23
|
import { LAYOUT_STATE_VERSION, measure, originsFor, readDiagnostics, readTableBaseline, resolveStandaloneId, } from "../../utils/layoutState";
|
|
24
24
|
import { syncEmptyState } from "../../utils/emptyState";
|
|
25
25
|
/**
|
|
@@ -195,11 +195,20 @@ export class Table {
|
|
|
195
195
|
* ```[{"rowGroup": "Umsatz", "category": "Applications"}]```
|
|
196
196
|
*/
|
|
197
197
|
this.partof = "[]";
|
|
198
|
-
/**
|
|
199
|
-
* If order is set to a scenario it has also exists in scenariolist
|
|
198
|
+
/** Comma list of the columns the rows are sorted by, left to right. `orderDirection` applies to all of them.
|
|
200
199
|
* <br /><br />
|
|
201
200
|
* values: <br />
|
|
202
|
-
* ```category // categoryindex // rowgroup //
|
|
201
|
+
* ```category // categoryindex // rowgroup // rowgroupindex // subcategory // subcategoryindex // ac[1-4] // fc[1-4] // pp[1-4] // pl[1-4] // auto```
|
|
202
|
+
* <br />
|
|
203
|
+
* or a variance, written like a scenario column, the sentiment is optional and ignored: ```dac1_pp1```, ```drfc1_pp1_pos```
|
|
204
|
+
* <br /><br />
|
|
205
|
+
* With `interval="setname"` a scenario or variance can name one bucket after `@`: ```dac1_pp1@_November``` sorts
|
|
206
|
+
* by that block only. Without a bucket the sum over all buckets is used.
|
|
207
|
+
* <br /><br />
|
|
208
|
+
* The scenario or variance does not have to be a shown column; the sort arrow appears only on a shown one.
|
|
209
|
+
* A plain scenario also sorts the row groups by their sum. A variance or a token with `@` sorts only the rows
|
|
210
|
+
* inside each group, the groups keep their rowgroupindex order. With a variance or `@`, rows without data
|
|
211
|
+
* (and a relative variance with a zero reference) sort last.
|
|
203
212
|
* <br /><br />
|
|
204
213
|
* When set to ```auto```, order is detected from the dataset silently.
|
|
205
214
|
*/
|
|
@@ -554,7 +563,7 @@ export class Table {
|
|
|
554
563
|
this.errors.remove(errId);
|
|
555
564
|
return;
|
|
556
565
|
}
|
|
557
|
-
const invalidElements =
|
|
566
|
+
const invalidElements = validateTableOrderList(newValue);
|
|
558
567
|
if (invalidElements.length > 0) {
|
|
559
568
|
this.errors.addOrReplace({
|
|
560
569
|
id: errId,
|
|
@@ -882,7 +891,7 @@ export class Table {
|
|
|
882
891
|
orderStr = this.datasetMeta.suggestedOrder;
|
|
883
892
|
}
|
|
884
893
|
const tableOrder = {
|
|
885
|
-
hierarchy: orderStr.split(",").map((entry) =>
|
|
894
|
+
hierarchy: orderStr.split(",").map((entry) => normalizeOrderToken(entry)),
|
|
886
895
|
direction: OrderDirection[effectiveDirection === null || effectiveDirection === void 0 ? void 0 : effectiveDirection.toUpperCase()],
|
|
887
896
|
};
|
|
888
897
|
return tableOrder;
|
|
@@ -1330,7 +1339,7 @@ export class Table {
|
|
|
1330
1339
|
render() {
|
|
1331
1340
|
const fontStyles = this.getFontStyles();
|
|
1332
1341
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
1333
|
-
return (h(Host, { key: '
|
|
1342
|
+
return (h(Host, { key: '2f24deddc4e58f57ef27443a27b4706b5f1b90db', style: fontStyles }, h("div", { key: 'b6368e143f868d9c2a7ad8ec753a14813b60e197' }, h("bn-table-renderer", { key: '399b2dc8d5cf3e7a8093a9a486635ea4d1bb74b9', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
|
|
1334
1343
|
}
|
|
1335
1344
|
static get is() { return "bn-table"; }
|
|
1336
1345
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1554,7 +1563,7 @@ export class Table {
|
|
|
1554
1563
|
"optional": false,
|
|
1555
1564
|
"docs": {
|
|
1556
1565
|
"tags": [],
|
|
1557
|
-
"text": "List of column names to render as bar charts instead of numbers.\n<br /><br />\nAbsolute variances (d_*) render as horizontal bar charts.\nRelative variances (dr_*) render as pin
|
|
1566
|
+
"text": "List of column names to render as bar charts instead of numbers.\n<br /><br />\nAbsolute variances (d_*) render as horizontal bar charts.\nRelative variances (dr_*) render as pin charts with a square head.\nBars take the pattern of the minuend (FC hatched, PL outlined) in the colour\nof the sentiment; pin heads take the look of the minuend scenario (AC solid\ndark, PY solid grey, FC hatched, PL outlined); the axis takes the look of the\nreference scenario.\nScenario columns (ac1..pl4) render as horizontal bar charts; when the table\ncontains grouping structure (sum rows, thereof, or partof) they automatically\nrender as an IBCS waterfall - data rows cascade from the running total and\nsum rows anchor at zero. Waterfall columns auto-scale to fit the bar column\nwidth (unit-scaling does not apply) and are not supported in combination\nwith `interval` or `columnthereof`.\n<br /><br />\nexample:<br />\n```dac1_pp1_pos,drac1_pp1_pos,ac1```"
|
|
1558
1567
|
},
|
|
1559
1568
|
"getter": false,
|
|
1560
1569
|
"setter": false,
|
|
@@ -1805,7 +1814,7 @@ export class Table {
|
|
|
1805
1814
|
"optional": false,
|
|
1806
1815
|
"docs": {
|
|
1807
1816
|
"tags": [],
|
|
1808
|
-
"text": "
|
|
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."
|
|
1809
1818
|
},
|
|
1810
1819
|
"getter": false,
|
|
1811
1820
|
"setter": false,
|
|
@@ -4,7 +4,8 @@ import { TableDataSetFactory } from "./factories/tableDataSetFactory";
|
|
|
4
4
|
// import { Order } from "../../../utils/model/Order";
|
|
5
5
|
import { IBCSRuleSet } from "../../../utils/ibcsRuleSet";
|
|
6
6
|
import { sourceExpr } from "../../../context/scopedDb";
|
|
7
|
-
import { INTERVAL_NONE, queryIntervalBuckets, resolveIntervalGranularity } from "./helper";
|
|
7
|
+
import { INTERVAL_NONE, INTERVAL_SETNAME, queryIntervalBuckets, resolveIntervalGranularity, } from "./helper";
|
|
8
|
+
import { parseOrderToken } from "../../../utils/model/Order";
|
|
8
9
|
/**
|
|
9
10
|
* High-level controller for IBCS table generation.
|
|
10
11
|
*
|
|
@@ -182,8 +183,19 @@ export class Table {
|
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
normalizeScenarios(scenarios, categoryThereOf, order, intervalBuckets = []) {
|
|
185
|
-
var _a
|
|
186
|
+
var _a;
|
|
186
187
|
const normalizedScenarios = [];
|
|
188
|
+
// the arrow marks the first scenario or variance token; a bucket only counts under interval setname
|
|
189
|
+
const sortToken = (_a = order === null || order === void 0 ? void 0 : order.hierarchy) === null || _a === void 0 ? void 0 : _a.map((entry) => parseOrderToken(entry)).find((token) => (token === null || token === void 0 ? void 0 : token.kind) !== "dim");
|
|
190
|
+
const sortBucket = this.config.interval === INTERVAL_SETNAME ? sortToken === null || sortToken === void 0 ? void 0 : sortToken.bucket : undefined;
|
|
191
|
+
const sortDirection = (scenario, bucket) => {
|
|
192
|
+
var _a;
|
|
193
|
+
return sortToken != null &&
|
|
194
|
+
((_a = parseOrderToken(scenario)) === null || _a === void 0 ? void 0 : _a.column) === sortToken.column &&
|
|
195
|
+
(sortBucket === undefined || sortBucket === bucket)
|
|
196
|
+
? order.direction
|
|
197
|
+
: undefined;
|
|
198
|
+
};
|
|
187
199
|
if (intervalBuckets.length > 0) {
|
|
188
200
|
for (const bucket of intervalBuckets) {
|
|
189
201
|
for (const scenario of scenarios) {
|
|
@@ -191,7 +203,7 @@ export class Table {
|
|
|
191
203
|
name: scenario,
|
|
192
204
|
group: scenario,
|
|
193
205
|
type: scenario,
|
|
194
|
-
order: (
|
|
206
|
+
order: sortDirection(scenario, bucket.key),
|
|
195
207
|
bucket: bucket.key,
|
|
196
208
|
bucketLabel: bucket.label,
|
|
197
209
|
});
|
|
@@ -220,17 +232,31 @@ export class Table {
|
|
|
220
232
|
}
|
|
221
233
|
normalizedScenarios.push({ name: "REST", group: "REST", type: scenario, order: undefined });
|
|
222
234
|
}
|
|
223
|
-
|
|
224
|
-
if (((_b = order === null || order === void 0 ? void 0 : order.hierarchy) === null || _b === void 0 ? void 0 : _b.at(0)) === scenario) {
|
|
225
|
-
orderDirection = order.direction;
|
|
226
|
-
}
|
|
227
|
-
normalizedScenarios.push({ name: scenario, group: scenario, type: scenario, order: orderDirection });
|
|
235
|
+
normalizedScenarios.push({ name: scenario, group: scenario, type: scenario, order: sortDirection(scenario) });
|
|
228
236
|
}
|
|
229
237
|
return normalizedScenarios;
|
|
230
238
|
}
|
|
231
239
|
hasNoData() {
|
|
232
240
|
return this.rowCount === 0;
|
|
233
241
|
}
|
|
242
|
+
/** Warning for an order `@bucket` that cannot apply, once the body was built; undefined when all apply. */
|
|
243
|
+
orderBucketWarning() {
|
|
244
|
+
var _a, _b;
|
|
245
|
+
if (this.hasNoData() || this.state !== FactoryState.UP_TO_DATE) {
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
const buckets = ((_b = (_a = this.config.sortOrder) === null || _a === void 0 ? void 0 : _a.hierarchy) !== null && _b !== void 0 ? _b : [])
|
|
249
|
+
.map((entry) => { var _a; return (_a = parseOrderToken(entry)) === null || _a === void 0 ? void 0 : _a.bucket; })
|
|
250
|
+
.filter((bucket) => bucket !== undefined);
|
|
251
|
+
if (buckets.length === 0) {
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
if (this.config.interval !== INTERVAL_SETNAME) {
|
|
255
|
+
return `order: '@${buckets[0]}' needs interval setname, the bucket is ignored.`;
|
|
256
|
+
}
|
|
257
|
+
const unknown = buckets.find((bucket) => !this.intervalBuckets.some((b) => b.key === bucket));
|
|
258
|
+
return unknown === undefined ? undefined : `order: setname '${unknown}' not found, the rows are not sorted by it.`;
|
|
259
|
+
}
|
|
234
260
|
/** True once the body was built and the grouped table has rows with a blank rowGroup. */
|
|
235
261
|
hasBlankRowGroup() {
|
|
236
262
|
return this.dataSetFactory.hasBlankRowGroup;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { Formatter } from "../../../../utils";
|
|
3
|
+
import { VarianceScenario } from "../../../../utils/model/VarianceScenario";
|
|
3
4
|
import { absoluteBarGeometry, BAR_LABEL_FONT_RATIO, relativePinGeometry } from "../helper/barColumnGeometry";
|
|
4
5
|
/** Matches SYSTEM_STYLE_DEFAULTS.global.fontSizePx; only used when `styles` is omitted. */
|
|
5
6
|
const DEFAULT_EM_PX = 13.3333;
|
|
@@ -23,6 +24,13 @@ export const DEFAULT_STYLES = {
|
|
|
23
24
|
scaleFactor: 1,
|
|
24
25
|
};
|
|
25
26
|
export const AXIS_COLOR = "#666666";
|
|
27
|
+
/** Width of the axis of a variance bar or pin, in em: near the 0.3em scenario marker in the header. */
|
|
28
|
+
const VARIANCE_AXIS_EM = 0.25;
|
|
29
|
+
/** Side of the square pin head and width of the pin line, in px before scaleFactor. */
|
|
30
|
+
const PIN_HEAD_SIZE = 10;
|
|
31
|
+
const PIN_LINE_WIDTH = 3;
|
|
32
|
+
/** Rough average glyph width, in label font sizes, to tell if an outlier label fits inside its pin. */
|
|
33
|
+
const LABEL_CHAR_WIDTH = 0.6;
|
|
26
34
|
/**
|
|
27
35
|
* Creates a unique pattern ID for the SVG defs
|
|
28
36
|
*/
|
|
@@ -112,6 +120,43 @@ function getScenarioStyle(scenario, styles) {
|
|
|
112
120
|
const type = getScenarioType(scenario);
|
|
113
121
|
return styles.scenarios[type];
|
|
114
122
|
}
|
|
123
|
+
function getVarianceLook(scenario, styles) {
|
|
124
|
+
if (isScenarioColumn(scenario))
|
|
125
|
+
return null;
|
|
126
|
+
const variance = new VarianceScenario(scenario);
|
|
127
|
+
if (!variance.isValid)
|
|
128
|
+
return null;
|
|
129
|
+
const minuendSlot = getScenarioType(variance.base);
|
|
130
|
+
const referenceSlot = getScenarioType(variance.delta);
|
|
131
|
+
return {
|
|
132
|
+
minuend: styles.scenarios[minuendSlot],
|
|
133
|
+
minuendSlot,
|
|
134
|
+
reference: styles.scenarios[referenceSlot],
|
|
135
|
+
referenceSlot,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Axis of a variance bar or pin in the look of the reference scenario: solid (AC, PY),
|
|
140
|
+
* a double line (PL, outlined) or dashed (FC, hatched). Lines only, so the bar stays the
|
|
141
|
+
* one direct-child rect of the svg.
|
|
142
|
+
*/
|
|
143
|
+
const VarianceAxis = ({ x, height, look, styles }) => {
|
|
144
|
+
const s = styles.scaleFactor;
|
|
145
|
+
const width = VARIANCE_AXIS_EM * styles.emPx;
|
|
146
|
+
const { reference, referenceSlot } = look;
|
|
147
|
+
let lines;
|
|
148
|
+
if (reference.fillpattern === "outlined") {
|
|
149
|
+
const offset = width / 2 - 0.5 * s;
|
|
150
|
+
lines = [x - offset, x + offset].map((lineX) => (h("line", { x1: lineX, y1: 0, x2: lineX, y2: height, stroke: reference.stroke, "stroke-width": 1 * s })));
|
|
151
|
+
}
|
|
152
|
+
else if (reference.fillpattern === "hatched") {
|
|
153
|
+
lines = (h("line", { x1: x, y1: 0, x2: x, y2: height, stroke: reference.stroke, "stroke-width": width, "stroke-dasharray": `${2 * s}` }));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
lines = h("line", { x1: x, y1: 0, x2: x, y2: height, stroke: reference.fill, "stroke-width": width });
|
|
157
|
+
}
|
|
158
|
+
return h("g", { class: `variance-axis axis-${referenceSlot}` }, lines);
|
|
159
|
+
};
|
|
115
160
|
/**
|
|
116
161
|
* Gets the variance style based on value and sentiment direction.
|
|
117
162
|
* pos suffix = positive values are good (green), negative are bad (red)
|
|
@@ -221,7 +266,12 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
221
266
|
const barY = padding;
|
|
222
267
|
const isPositive = value >= 0;
|
|
223
268
|
// Get style based on column type (scenario vs variance)
|
|
224
|
-
const
|
|
269
|
+
const look = getVarianceLook(scenario, styles);
|
|
270
|
+
const sentimentStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
271
|
+
const minuendPattern = look === null || look === void 0 ? void 0 : look.minuend.fillpattern;
|
|
272
|
+
// the colour stays the sentiment, the pattern follows the minuend (AC solid, FC hatched, PL outlined)
|
|
273
|
+
const barStyle = minuendPattern === "hatched" || minuendPattern === "outlined"
|
|
274
|
+
? Object.assign(Object.assign({}, sentimentStyle), { fillpattern: minuendPattern }) : sentimentStyle;
|
|
225
275
|
const patternPrefix = isScenarioColumn(scenario)
|
|
226
276
|
? getScenarioType(scenario)
|
|
227
277
|
: isPositiveGood
|
|
@@ -232,52 +282,73 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
232
282
|
? "neg"
|
|
233
283
|
: "pos";
|
|
234
284
|
const fillValue = getBarFill(barStyle, patternPrefix);
|
|
235
|
-
|
|
285
|
+
// a hatched variance bar keeps an outline, the shared getBarStroke also serves the waterfall
|
|
286
|
+
const { stroke: barStroke, strokeWidth: barStrokeWidth } = look && barStyle.fillpattern === "hatched" ? { stroke: barStyle.stroke, strokeWidth: 1 } : getBarStroke(barStyle);
|
|
236
287
|
const displayValue = formattedValue || formatValue(value, false, measureScale, locale);
|
|
288
|
+
// bars start at the outer edge of the thick variance axis
|
|
289
|
+
const axisOffset = look ? (VARIANCE_AXIS_EM * styles.emPx) / 2 : 0;
|
|
290
|
+
const rootX = isPositive ? axisX + axisOffset : axisX - axisOffset;
|
|
237
291
|
// Normal bar width (clamped to cutWidth when extreme)
|
|
238
292
|
const baseBarWidth = isExtreme ? cutWidth : scaledWidth;
|
|
239
293
|
// Label position accounts for overdrive
|
|
240
294
|
const totalVisualWidth = isExtreme ? cutWidth + breakGap + overdriveWidth : scaledWidth;
|
|
241
|
-
const labelX = isPositive ?
|
|
295
|
+
const labelX = isPositive ? rootX + totalVisualWidth + labelGap : rootX - totalVisualWidth - labelGap;
|
|
242
296
|
const labelAnchor = isPositive ? "start" : "end";
|
|
243
|
-
return (h("svg", { width: totalWidth, height: height, class: "cell-bar-chart absolute-variance", style: { overflow: "visible" } }, h(PatternDefs, { styles: styles }), h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s }), baseBarWidth > 0 && (h("rect", { x: isPositive ?
|
|
244
|
-
renderZigzagBreak(isPositive ?
|
|
297
|
+
return (h("svg", { width: totalWidth, height: height, class: "cell-bar-chart absolute-variance", style: { overflow: "visible" } }, h(PatternDefs, { styles: styles }), !look && h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s }), baseBarWidth > 0 && (h("rect", { x: isPositive ? rootX : rootX - baseBarWidth, y: barY, width: baseBarWidth, height: barHeight, fill: fillValue, stroke: barStroke, "stroke-width": barStrokeWidth * s })), isExtreme && overdriveWidth > 0 && (h("rect", { x: isPositive ? rootX + cutWidth + breakGap : rootX - cutWidth - breakGap - overdriveWidth, y: barY, width: overdriveWidth, height: barHeight, fill: fillValue, stroke: barStroke, "stroke-width": barStrokeWidth * s })), isExtreme &&
|
|
298
|
+
renderZigzagBreak(isPositive ? rootX + cutWidth : rootX - cutWidth - breakGap, breakGap, barY, barHeight, s), look && h(VarianceAxis, { x: axisX, height: height, look: look, styles: styles }), h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": labelAnchor, fill: styles.fontColor, "font-size": fs, "font-family": styles.fontFamily }, displayValue)));
|
|
245
299
|
};
|
|
246
300
|
/**
|
|
247
301
|
* Renders a relative variance pin chart (dr_ prefix).
|
|
248
|
-
*
|
|
302
|
+
* Line from the axis in the sentiment colour, ending in a square head in the look of the
|
|
303
|
+
* minuend, with the value label beside the head like an absolute bar label. A pin beyond
|
|
304
|
+
* the pin area is cut and ends in an arrow, its label inside the pin before the arrow.
|
|
249
305
|
*
|
|
250
|
-
* Layout: [pin area with axis][label area
|
|
306
|
+
* Layout: [left label area][pin area with axis][right label area], summing to exactly
|
|
251
307
|
* `columnWidthEm` em - see barColumnGeometry.ts.
|
|
252
308
|
* Uses percentageScaling to determine pin length (pixels per percentage point).
|
|
253
309
|
*/
|
|
254
310
|
const RelativeVariancePin = (props) => {
|
|
311
|
+
var _a, _b;
|
|
255
312
|
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, percentDigits, columnWidthEm = 10, styles = DEFAULT_STYLES, } = props;
|
|
256
313
|
const s = styles.scaleFactor;
|
|
257
314
|
const fs = styles.fontSize;
|
|
258
315
|
// Adaptive axis placement based on data range
|
|
259
316
|
const hasNeg = columnStats.min < 0;
|
|
260
317
|
const hasPos = columnStats.max > 0;
|
|
261
|
-
const { totalWidth, maxPinLength, axisX,
|
|
318
|
+
const { totalWidth, maxPinLength, axisX, labelGap } = relativePinGeometry(columnWidthEm, styles.emPx, hasNeg, hasPos);
|
|
262
319
|
const centerY = height / 2;
|
|
263
320
|
// Direct unit scaling via fontSize
|
|
264
321
|
const percentValue = Math.abs(value) * 100;
|
|
265
322
|
const scaledLength = percentValue * styles.percentageScaling * fs;
|
|
266
323
|
const isExtreme = scaledLength > maxPinLength;
|
|
267
324
|
const pinLength = Math.min(scaledLength, maxPinLength);
|
|
268
|
-
|
|
269
|
-
const
|
|
325
|
+
// a zero label goes to the side that has a label gutter
|
|
326
|
+
const isPositive = value > 0 || (value === 0 && (hasPos || !hasNeg));
|
|
327
|
+
const direction = isPositive ? 1 : -1;
|
|
328
|
+
const pinEndX = axisX + direction * pinLength;
|
|
270
329
|
// Get style based on column type (scenario vs variance)
|
|
271
330
|
const barStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
272
|
-
const
|
|
331
|
+
const look = getVarianceLook(scenario, styles);
|
|
332
|
+
const headStyle = (_a = look === null || look === void 0 ? void 0 : look.minuend) !== null && _a !== void 0 ? _a : styles.scenarios.ac;
|
|
333
|
+
const headSize = PIN_HEAD_SIZE * s;
|
|
273
334
|
const displayValue = formattedValue || formatValue(value, true, measureScale, locale, percentDigits);
|
|
274
|
-
|
|
335
|
+
// the arrow tip lands on the outer edge of a full-length head
|
|
336
|
+
const tipX = axisX + direction * (maxPinLength + headSize / 2);
|
|
337
|
+
const arrowBaseX = tipX - direction * headSize;
|
|
338
|
+
const labelFitsInside = maxPinLength - headSize / 2 - labelGap >= displayValue.length * LABEL_CHAR_WIDTH * fs;
|
|
339
|
+
const labelInside = isExtreme && labelFitsInside;
|
|
340
|
+
let labelX = pinEndX + direction * (headSize / 2 + labelGap);
|
|
341
|
+
if (isExtreme) {
|
|
342
|
+
labelX = labelInside ? arrowBaseX - direction * labelGap : tipX + direction * labelGap;
|
|
343
|
+
}
|
|
344
|
+
const labelAtStart = isPositive !== labelInside;
|
|
345
|
+
return (h("svg", { width: totalWidth, height: height, class: "cell-bar-chart relative-variance", style: { overflow: "visible" } }, h(PatternDefs, { styles: styles }), look ? (h(VarianceAxis, { x: axisX, height: height, look: look, styles: styles })) : (h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s })), h("line", { x1: axisX, y1: centerY, x2: isExtreme ? arrowBaseX : pinEndX, y2: centerY, stroke: barStyle.fill, "stroke-width": PIN_LINE_WIDTH * s }), isExtreme ? (h("polygon", { points: `${tipX},${centerY} ${arrowBaseX},${centerY - headSize / 2} ${arrowBaseX},${centerY + headSize / 2}`, fill: barStyle.fill })) : (h("rect", { x: pinEndX - headSize / 2, y: centerY - headSize / 2, width: headSize, height: headSize, fill: headStyle.fillpattern === "outlined" ? "#ffffff" : getBarFill(headStyle, (_b = look === null || look === void 0 ? void 0 : look.minuendSlot) !== null && _b !== void 0 ? _b : "ac"), stroke: headStyle.stroke, "stroke-width": 1 * s })), h("text", Object.assign({ x: labelX, y: height / 2, dy: "0.35em", "text-anchor": labelAtStart ? "start" : "end", fill: styles.fontColor, "font-size": fs, "font-style": "italic", "font-family": styles.fontFamily }, (labelInside ? { stroke: "#ffffff", "stroke-width": 3 * s, "paint-order": "stroke" } : {})), displayValue)));
|
|
275
346
|
};
|
|
276
347
|
/**
|
|
277
348
|
* CellBarChart - Renders IBCS-compliant variance bar charts.
|
|
278
349
|
*
|
|
279
350
|
* Absolute variance (d_ prefix): Horizontal bars with centered axis
|
|
280
|
-
* Relative variance (dr_ prefix): Pin
|
|
351
|
+
* Relative variance (dr_ prefix): Pin charts with a square head and value indication
|
|
281
352
|
*
|
|
282
353
|
* Uses componentStyle patterns from chart components for consistent styling.
|
|
283
354
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { OrderDirection, TableType } from "../model";
|
|
2
2
|
import { BLANK_SAFE_ROWGROUP, QueryGroups } from "./QueryGroup";
|
|
3
|
-
import { BLANK_BUCKET_LABEL, coerceBucketKey, INTERVAL_NONE, intervalBucketSQL } from "./IntervalColumns";
|
|
3
|
+
import { BLANK_BUCKET_LABEL, coerceBucketKey, INTERVAL_NONE, INTERVAL_SETNAME, intervalBucketSQL, } from "./IntervalColumns";
|
|
4
4
|
import { FIELD_IDENTIFIER_REGEX } from "../model/TableAttribute";
|
|
5
|
+
import { parseOrderToken } from "../../../../utils/model/Order";
|
|
5
6
|
import { Scenarios } from "../../../../utils/constants";
|
|
6
7
|
import { QueryColumnNames, VarianceScenario } from "../../../../utils/model";
|
|
7
8
|
import { NOT_AVAILABLE, relativeVariance } from "../../../../utils/relativeVariance";
|
|
@@ -18,6 +19,8 @@ export class DataQuery {
|
|
|
18
19
|
this.hasPartOf = false;
|
|
19
20
|
/** Values bound as AlaSQL parameters ($0, $1, ...): row values and free-text config never become SQL text. */
|
|
20
21
|
this.params = [];
|
|
22
|
+
/** Select fragment (leading comma) of the sort keys for variance and bucketed order tokens. */
|
|
23
|
+
this.sortSelect = "";
|
|
21
24
|
/** Set by execute: the grouped table has rows with a blank rowGroup (null, '' or missing). */
|
|
22
25
|
this.hasBlankRowGroup = false;
|
|
23
26
|
this.config = config;
|
|
@@ -63,15 +66,22 @@ export class DataQuery {
|
|
|
63
66
|
const relativeScenarios = this.getRelativeScenarios();
|
|
64
67
|
const attributesSQL = this.config.attributes.map((attribute) => this.translateAttributeSQL(attribute)).toString();
|
|
65
68
|
const groups = new QueryGroups(this.config);
|
|
69
|
+
// a bucket only applies under interval setname, else the token sorts like its bare column
|
|
70
|
+
const sortOrder = this.config.interval === INTERVAL_SETNAME
|
|
71
|
+
? this.config.sortOrder
|
|
72
|
+
: {
|
|
73
|
+
hierarchy: this.config.sortOrder.hierarchy.map((column) => { var _a, _b; return (_b = (_a = parseOrderToken(column)) === null || _a === void 0 ? void 0 : _a.column) !== null && _b !== void 0 ? _b : column; }),
|
|
74
|
+
direction: this.config.sortOrder.direction,
|
|
75
|
+
};
|
|
66
76
|
let order = ["", ""];
|
|
67
|
-
if (
|
|
68
|
-
order = this.createOrderString(
|
|
77
|
+
if (sortOrder.hierarchy.length > 0) {
|
|
78
|
+
order = this.createOrderString(sortOrder);
|
|
69
79
|
}
|
|
70
80
|
this.hasPartOf = this.checkConfigForPartOf();
|
|
71
81
|
// meta defines groups and the number detail rows in each group
|
|
72
82
|
// Bsp: 0: Object { totalrowcnt: 7, rowgroup: "Umsatz" }
|
|
73
83
|
// groups follow the order entries that exist per group (rowGroup, rowGroupIndex, scenario sum), else rowGroupIndex
|
|
74
|
-
const { hierarchy, direction } =
|
|
84
|
+
const { hierarchy, direction } = sortOrder;
|
|
75
85
|
const groupOrderColumns = hierarchy.filter((column) => column === QueryColumnNames.ROWGROUP ||
|
|
76
86
|
column === QueryColumnNames.ROWGROUPINDEX ||
|
|
77
87
|
column.toUpperCase() in Scenarios);
|
|
@@ -205,7 +215,7 @@ export class DataQuery {
|
|
|
205
215
|
? `, CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation`
|
|
206
216
|
: "";
|
|
207
217
|
querys.push(`SELECT ${QueryColumnNames.ROWNR}, 1 as ${QueryColumnNames.ROWGROUPINDEX} , 'ENTRY' as ${QueryColumnNames.TYPE}, 'NO_GROUP' as ${QueryColumnNames.ROWGROUP}, ${this.bind(String((_a = rowGroupEntry.rowGroup) !== null && _a !== void 0 ? _a : ""))} as restRowGroup, 'REST' as ${QueryColumnNames.CATEGORY}${restOperation} ${restScenarios.length > 0 ? ", " + restScenarios : ""} FROM` +
|
|
208
|
-
` (SELECT ROWNUM() AS ${QueryColumnNames.ROWNR}, ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX} , 'ENTRY' as ${QueryColumnNames.TYPE}, ${this.bind(String(rowGroupEntry.rowGroup || "NO_GROUP"))} as ${QueryColumnNames.ROWGROUP}, ${groups.select()} ${scenarios.length > 0 ? ",".concat(scenarios) : ""} FROM ${this.fromExpr} ${queryWhereSection} GROUP BY ${groups} ORDER BY ${order[0]})` +
|
|
218
|
+
` (SELECT ROWNUM() AS ${QueryColumnNames.ROWNR}, ${querys.length} as ${QueryColumnNames.ROWGROUPINDEX} , 'ENTRY' as ${QueryColumnNames.TYPE}, ${this.bind(String(rowGroupEntry.rowGroup || "NO_GROUP"))} as ${QueryColumnNames.ROWGROUP}, ${groups.select()} ${scenarios.length > 0 ? ",".concat(scenarios) : ""}${this.sortSelect} FROM ${this.fromExpr} ${queryWhereSection} GROUP BY ${groups} ORDER BY ${order[0]})` +
|
|
209
219
|
` t WHERE t.rowNr > ${this.config.limit}`);
|
|
210
220
|
}
|
|
211
221
|
}
|
|
@@ -217,7 +227,7 @@ export class DataQuery {
|
|
|
217
227
|
'ENTRY' as ${QueryColumnNames.TYPE},
|
|
218
228
|
${this.bind(String(rowGroupEntry.rowGroup || "NO_GROUP"))} as ${QueryColumnNames.ROWGROUP},
|
|
219
229
|
'${QueryColumnNames.CATEGORYINDEX}',
|
|
220
|
-
${groups.select()} ${scenarios.length > 0 ? ",".concat(scenarios) : ""} ${attributes.length > 0 ? ",".concat(attributes) : ""}
|
|
230
|
+
${groups.select()} ${scenarios.length > 0 ? ",".concat(scenarios) : ""} ${attributes.length > 0 ? ",".concat(attributes) : ""}${this.sortSelect}
|
|
221
231
|
FROM ${this.fromExpr} ${queryWhereSection}
|
|
222
232
|
GROUP BY ${groups}
|
|
223
233
|
ORDER BY ${order[0]} ${queryLimitSection}`);
|
|
@@ -407,7 +417,7 @@ export class DataQuery {
|
|
|
407
417
|
${QueryColumnNames.CATEGORY},
|
|
408
418
|
${QueryColumnNames.SUBCATEGORY},
|
|
409
419
|
${this.drillRowGroup} as ${QueryColumnNames.ROWGROUP},
|
|
410
|
-
${scenarios} ${attributes.length > 0 ? ",".concat(attributes) : ""}
|
|
420
|
+
${scenarios} ${attributes.length > 0 ? ",".concat(attributes) : ""}${this.sortSelect}
|
|
411
421
|
FROM ${this.fromExpr}
|
|
412
422
|
WHERE ${fromString}
|
|
413
423
|
GROUP BY ${this.drillRowGroup}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.SUBCATEGORY}
|
|
@@ -865,10 +875,47 @@ export class DataQuery {
|
|
|
865
875
|
*/
|
|
866
876
|
createOrderString(orderComponent) {
|
|
867
877
|
const inverse = OrderDirection.ASC === orderComponent.direction ? OrderDirection.DESC : OrderDirection.ASC;
|
|
868
|
-
const
|
|
869
|
-
|
|
878
|
+
const sortKeys = new Map();
|
|
879
|
+
orderComponent.hierarchy.forEach((column, i) => {
|
|
880
|
+
const token = parseOrderToken(column);
|
|
881
|
+
const bucket = token === null || token === void 0 ? void 0 : token.bucket;
|
|
882
|
+
if ((token === null || token === void 0 ? void 0 : token.kind) === "variance" || ((token === null || token === void 0 ? void 0 : token.kind) === "scenario" && bucket !== undefined)) {
|
|
883
|
+
sortKeys.set(i, this.translateSortKeySQL(token, bucket, i));
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
this.sortSelect = [...sortKeys.values()].map((key) => `, ${key}`).join("");
|
|
887
|
+
// rows without a value sort last in both directions
|
|
888
|
+
const orderBy = (column, i, direction) => sortKeys.has(i) ? `__sortnull${i} asc, __sort${i} ${direction}` : `${column} ${direction}`;
|
|
889
|
+
const base = orderComponent.hierarchy.map((column, i) => orderBy(column, i, orderComponent.direction)).toString();
|
|
890
|
+
const inverted = orderComponent.hierarchy.map((column, i) => orderBy(column, i, inverse)).toString();
|
|
870
891
|
return [base, inverted];
|
|
871
892
|
}
|
|
893
|
+
/**
|
|
894
|
+
* Sort key `__sort<i>` of a scenario or variance order token, as printed in an entry cell
|
|
895
|
+
* (OPT entry rows unsigned), restricted to one setname bucket when given.
|
|
896
|
+
* `__sortnull<i>` is 1 when the cell has no value: no data, or a relative variance with a zero reference.
|
|
897
|
+
*/
|
|
898
|
+
translateSortKeySQL(token, bucket, i) {
|
|
899
|
+
const isOpt = TableType.OPT === this.config.type || TableType.OPTNOTOTAL === this.config.type;
|
|
900
|
+
const sign = isOpt ? "" : " * transformOperator(operation)";
|
|
901
|
+
const inBucket = bucket === undefined ? "" : `TRIM(CAST(${intervalBucketSQL(INTERVAL_SETNAME)} AS STRING)) = ${this.bind(bucket)}`;
|
|
902
|
+
const value = (x) => `SUM(${inBucket ? `(CASE WHEN ${inBucket} THEN ${x} ELSE 0 END)` : x}${sign})`;
|
|
903
|
+
const missing = (x) => `SUM(CASE WHEN ${inBucket ? `${inBucket} AND ` : ""}${x} IS NOT NULL THEN 1 ELSE 0 END) = 0`;
|
|
904
|
+
if (token.kind === "scenario") {
|
|
905
|
+
return `${value(token.column)} as __sort${i}, CASE WHEN ${missing(token.column)} THEN 1 ELSE 0 END as __sortnull${i}`;
|
|
906
|
+
}
|
|
907
|
+
const difference = `(${value(token.base)} - ${value(token.delta)})`;
|
|
908
|
+
let key = difference;
|
|
909
|
+
let noValue = `${missing(token.base)} OR ${missing(token.delta)}`;
|
|
910
|
+
if (token.type === "dr") {
|
|
911
|
+
const reference = value(token.delta);
|
|
912
|
+
// same rule as relativeVariance(); a decimal literal, alasql reads 1e-9 as a column name
|
|
913
|
+
const zeroReference = `ABS(${reference}) <= ABS(${difference}) * 0.000000001`;
|
|
914
|
+
key = `CASE WHEN ${zeroReference} THEN 0 ELSE ${difference} / ABS(${reference}) END`;
|
|
915
|
+
noValue += ` OR ${zeroReference}`;
|
|
916
|
+
}
|
|
917
|
+
return `${key} as __sort${i}, CASE WHEN ${noValue} THEN 1 ELSE 0 END as __sortnull${i}`;
|
|
918
|
+
}
|
|
872
919
|
/** Returns a key/value pair mapping a relative variance column to its denominator, or null for non-relative scenarios. */
|
|
873
920
|
createRelativeScenario(scenario) {
|
|
874
921
|
const scenarios = new VarianceScenario(scenario);
|
|
@@ -923,7 +970,7 @@ export class DataQuery {
|
|
|
923
970
|
'PARTELEMENT' as ${QueryColumnNames.TYPE},
|
|
924
971
|
${QueryColumnNames.CATEGORY},
|
|
925
972
|
${groupName},
|
|
926
|
-
${scenarios}
|
|
973
|
+
${scenarios}${this.sortSelect}
|
|
927
974
|
FROM ${this.fromExpr}
|
|
928
975
|
WHERE ${fromString}
|
|
929
976
|
GROUP BY ${this.drillRowGroup}, ${QueryColumnNames.CATEGORY}, ${QueryColumnNames.TYPE}
|