@bino-bi/bn-template-engine 1.0.0-next.34 → 1.0.0-next.36
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-2dcdac86.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 +378 -135
- 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 +97 -48
- 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 +103 -32
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +57 -10
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +73 -30
- 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-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-CLilvhjH.js +1 -0
- 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 +378 -135
- 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-renderer/bn-table-renderer.d.ts +8 -12
- 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 +9 -2
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +8 -0
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +18 -9
- 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
|
@@ -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,6 +1,7 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { Formatter } from "../../../../utils";
|
|
3
|
-
import {
|
|
3
|
+
import { VarianceScenario } from "../../../../utils/model/VarianceScenario";
|
|
4
|
+
import { absoluteBarGeometry, BAR_LABEL_FONT_RATIO, estimateLabelWidth, PIN_HEAD_SIZE, relativePinGeometry, VARIANCE_AXIS_EM, } 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;
|
|
6
7
|
// Default fallback colors (should come from componentStyle)
|
|
@@ -23,6 +24,8 @@ export const DEFAULT_STYLES = {
|
|
|
23
24
|
scaleFactor: 1,
|
|
24
25
|
};
|
|
25
26
|
export const AXIS_COLOR = "#666666";
|
|
27
|
+
/** Width of the pin line, in px before scaleFactor. */
|
|
28
|
+
const PIN_LINE_WIDTH = 3;
|
|
26
29
|
/**
|
|
27
30
|
* Creates a unique pattern ID for the SVG defs
|
|
28
31
|
*/
|
|
@@ -47,16 +50,20 @@ export const PatternDefs = ({ styles }) => {
|
|
|
47
50
|
];
|
|
48
51
|
return (h("defs", null, patterns.map((p) => (h("pattern", { id: p.id, patternUnits: "userSpaceOnUse", width: patternSize, height: patternSize }, h("rect", { width: patternSize, height: patternSize, fill: "#ffffff" }), h("line", { x1: "0", y1: patternSize, x2: patternSize, y2: "0", stroke: p.stroke, "stroke-width": 1.5 * s }))))));
|
|
49
52
|
};
|
|
50
|
-
/**
|
|
53
|
+
/** Longest relative label that keeps all percent digits; a longer one drops digits so its gutter does not eat the pins. */
|
|
51
54
|
const PIN_LABEL_CHARS = 7;
|
|
52
55
|
/**
|
|
53
56
|
* Formats a number for display with appropriate SI prefix.
|
|
54
57
|
*/
|
|
55
|
-
export function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0) {
|
|
56
|
-
|
|
58
|
+
export function formatValue(value, isRelative, measureScale = 1, locale, percentDigits = 0, percentSign = true) {
|
|
59
|
+
// IBCS prints a value that rounds to zero without a sign
|
|
60
|
+
const signed = (text, zero) => (value > 0 && text !== zero ? "+" : "") + text;
|
|
57
61
|
if (isRelative) {
|
|
58
62
|
// Relative variance is stored as decimal (e.g., -2.0 = -200%)
|
|
59
|
-
const
|
|
63
|
+
const number = (v, digits) => percentSign
|
|
64
|
+
? Formatter.number(v, "percent", digits, digits, 1, locale)
|
|
65
|
+
: Formatter.number(v * 100, "decimal", digits, digits, 1, locale);
|
|
66
|
+
const format = (digits) => signed(number(value, digits), number(0, digits));
|
|
60
67
|
// Intl throws on a digit count outside 0 to 20
|
|
61
68
|
let digits = Math.min(20, Math.max(0, Math.trunc(percentDigits) || 0));
|
|
62
69
|
while (digits > 0 && format(digits).length > PIN_LABEL_CHARS) {
|
|
@@ -83,7 +90,7 @@ export function formatValue(value, isRelative, measureScale = 1, locale, percent
|
|
|
83
90
|
suffix = "K";
|
|
84
91
|
}
|
|
85
92
|
const digits = absValue >= unit * 10 ? 0 : 1;
|
|
86
|
-
return
|
|
93
|
+
return (signed(Formatter.number(scaledValue / unit, "decimal", digits, 0, 1, locale), Formatter.number(0, "decimal", digits, 0, 1, locale)) + suffix);
|
|
87
94
|
}
|
|
88
95
|
/**
|
|
89
96
|
* Checks if the column is a scenario column (ac, pp, fc, pl) vs variance (d_, dr_).
|
|
@@ -112,6 +119,54 @@ function getScenarioStyle(scenario, styles) {
|
|
|
112
119
|
const type = getScenarioType(scenario);
|
|
113
120
|
return styles.scenarios[type];
|
|
114
121
|
}
|
|
122
|
+
function getVarianceLook(scenario, styles) {
|
|
123
|
+
if (isScenarioColumn(scenario))
|
|
124
|
+
return null;
|
|
125
|
+
const variance = new VarianceScenario(scenario);
|
|
126
|
+
if (!variance.isValid)
|
|
127
|
+
return null;
|
|
128
|
+
const minuendSlot = getScenarioType(variance.base);
|
|
129
|
+
const referenceSlot = getScenarioType(variance.delta);
|
|
130
|
+
return {
|
|
131
|
+
minuend: styles.scenarios[minuendSlot],
|
|
132
|
+
minuendSlot,
|
|
133
|
+
reference: styles.scenarios[referenceSlot],
|
|
134
|
+
referenceSlot,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Axis of a variance bar or pin in the look of the reference scenario: solid (AC, PY),
|
|
139
|
+
* a double line (PL, outlined) or dashed (FC, hatched). Lines only, so the bar stays the
|
|
140
|
+
* one direct-child rect of the svg.
|
|
141
|
+
*/
|
|
142
|
+
const VarianceAxis = ({ x, height, look, styles }) => {
|
|
143
|
+
const s = styles.scaleFactor;
|
|
144
|
+
const width = VARIANCE_AXIS_EM * styles.emPx;
|
|
145
|
+
const { reference, referenceSlot } = look;
|
|
146
|
+
let lines;
|
|
147
|
+
if (reference.fillpattern === "outlined") {
|
|
148
|
+
const offset = width / 2 - 0.5 * s;
|
|
149
|
+
lines = [x - offset, x + offset].map((lineX) => (h("line", { x1: lineX, y1: 0, x2: lineX, y2: height, stroke: reference.stroke, "stroke-width": 1 * s })));
|
|
150
|
+
}
|
|
151
|
+
else if (reference.fillpattern === "hatched") {
|
|
152
|
+
lines = (h("line", { x1: x, y1: 0, x2: x, y2: height, stroke: reference.stroke, "stroke-width": width, "stroke-dasharray": `${2 * s}` }));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
lines = h("line", { x1: x, y1: 0, x2: x, y2: height, stroke: reference.fill, "stroke-width": width });
|
|
156
|
+
}
|
|
157
|
+
return h("g", { class: `variance-axis axis-${referenceSlot}` }, lines);
|
|
158
|
+
};
|
|
159
|
+
/** A zero value is drawn on the positive side, unless the column only has negative values. */
|
|
160
|
+
export function zeroOnPositiveSide(labels) {
|
|
161
|
+
return labels.pos !== undefined || labels.neg === undefined;
|
|
162
|
+
}
|
|
163
|
+
/** Side coverage from the column statistics, with only this cell's label as the width. */
|
|
164
|
+
function ownLabelWidths(columnStats, width) {
|
|
165
|
+
return {
|
|
166
|
+
neg: columnStats.min < 0 ? width : undefined,
|
|
167
|
+
pos: columnStats.max > 0 ? width : undefined,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
115
170
|
/**
|
|
116
171
|
* Gets the variance style based on value and sentiment direction.
|
|
117
172
|
* pos suffix = positive values are good (green), negative are bad (red)
|
|
@@ -200,13 +255,12 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
|
|
|
200
255
|
* exactly `columnWidthEm` em - see barColumnGeometry.ts.
|
|
201
256
|
*/
|
|
202
257
|
const AbsoluteVarianceBar = (props) => {
|
|
203
|
-
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, columnWidthEm = 10, styles = DEFAULT_STYLES, } = props;
|
|
258
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, columnWidthEm = 10, labelWidths, styles = DEFAULT_STYLES, } = props;
|
|
204
259
|
const s = styles.scaleFactor;
|
|
205
260
|
const fs = styles.fontSize;
|
|
206
|
-
|
|
207
|
-
const
|
|
208
|
-
const
|
|
209
|
-
const { totalWidth, axisX, breakGap, overdriveZoneWidth, cutWidth, labelGap } = absoluteBarGeometry(columnWidthEm, styles.emPx, hasNeg, hasPos);
|
|
261
|
+
const displayValue = formattedValue || formatValue(value, false, measureScale, locale);
|
|
262
|
+
const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, estimateLabelWidth(displayValue, fs));
|
|
263
|
+
const { totalWidth, axisX, breakGap, overdriveZoneWidth, cutWidth, labelGap } = absoluteBarGeometry(columnWidthEm, styles.emPx, sides);
|
|
210
264
|
// Direct unit scaling via fontSize
|
|
211
265
|
const scaledWidth = Math.abs(value) * styles.unitScaling * fs;
|
|
212
266
|
// auto scaling puts the largest bar on the cut, float rounding must not turn it into an overdrive bar
|
|
@@ -219,9 +273,14 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
219
273
|
const padding = 2 * s;
|
|
220
274
|
const barHeight = height - padding * 2;
|
|
221
275
|
const barY = padding;
|
|
222
|
-
const isPositive = value
|
|
276
|
+
const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
|
|
223
277
|
// Get style based on column type (scenario vs variance)
|
|
224
|
-
const
|
|
278
|
+
const look = getVarianceLook(scenario, styles);
|
|
279
|
+
const sentimentStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
280
|
+
const minuendPattern = look === null || look === void 0 ? void 0 : look.minuend.fillpattern;
|
|
281
|
+
// the colour stays the sentiment, the pattern follows the minuend (AC solid, FC hatched, PL outlined)
|
|
282
|
+
const barStyle = minuendPattern === "hatched" || minuendPattern === "outlined"
|
|
283
|
+
? Object.assign(Object.assign({}, sentimentStyle), { fillpattern: minuendPattern }) : sentimentStyle;
|
|
225
284
|
const patternPrefix = isScenarioColumn(scenario)
|
|
226
285
|
? getScenarioType(scenario)
|
|
227
286
|
: isPositiveGood
|
|
@@ -232,52 +291,64 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
232
291
|
? "neg"
|
|
233
292
|
: "pos";
|
|
234
293
|
const fillValue = getBarFill(barStyle, patternPrefix);
|
|
235
|
-
|
|
236
|
-
const
|
|
294
|
+
// a hatched variance bar keeps an outline, the shared getBarStroke also serves the waterfall
|
|
295
|
+
const { stroke: barStroke, strokeWidth: barStrokeWidth } = look && barStyle.fillpattern === "hatched" ? { stroke: barStyle.stroke, strokeWidth: 1 } : getBarStroke(barStyle);
|
|
296
|
+
// bars start at the outer edge of the thick variance axis
|
|
297
|
+
const axisOffset = look ? (VARIANCE_AXIS_EM * styles.emPx) / 2 : 0;
|
|
298
|
+
const rootX = isPositive ? axisX + axisOffset : axisX - axisOffset;
|
|
237
299
|
// Normal bar width (clamped to cutWidth when extreme)
|
|
238
300
|
const baseBarWidth = isExtreme ? cutWidth : scaledWidth;
|
|
239
301
|
// Label position accounts for overdrive
|
|
240
302
|
const totalVisualWidth = isExtreme ? cutWidth + breakGap + overdriveWidth : scaledWidth;
|
|
241
|
-
const labelX = isPositive ?
|
|
303
|
+
const labelX = isPositive ? rootX + totalVisualWidth + labelGap : rootX - totalVisualWidth - labelGap;
|
|
242
304
|
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 ?
|
|
305
|
+
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 &&
|
|
306
|
+
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
307
|
};
|
|
246
308
|
/**
|
|
247
309
|
* Renders a relative variance pin chart (dr_ prefix).
|
|
248
|
-
*
|
|
310
|
+
* Line from the axis in the sentiment colour, ending in a square head in the look of the
|
|
311
|
+
* minuend, with the value label beside the head like an absolute bar label. A pin beyond
|
|
312
|
+
* the pin area is cut and ends in an arrow, its label after the arrow tip.
|
|
249
313
|
*
|
|
250
|
-
* Layout: [pin area with axis][label area
|
|
314
|
+
* Layout: [left label area][pin area with axis][right label area], summing to exactly
|
|
251
315
|
* `columnWidthEm` em - see barColumnGeometry.ts.
|
|
252
316
|
* Uses percentageScaling to determine pin length (pixels per percentage point).
|
|
253
317
|
*/
|
|
254
318
|
const RelativeVariancePin = (props) => {
|
|
255
|
-
|
|
319
|
+
var _a, _b;
|
|
320
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, percentDigits, percentSign, columnWidthEm = 10, labelWidths, styles = DEFAULT_STYLES, } = props;
|
|
256
321
|
const s = styles.scaleFactor;
|
|
257
322
|
const fs = styles.fontSize;
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
const
|
|
261
|
-
const { totalWidth, maxPinLength, axisX,
|
|
323
|
+
const headSize = PIN_HEAD_SIZE * s;
|
|
324
|
+
const displayValue = formattedValue || formatValue(value, true, measureScale, locale, percentDigits, percentSign);
|
|
325
|
+
const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, estimateLabelWidth(displayValue, fs));
|
|
326
|
+
const { totalWidth, maxPinLength, axisX, labelGap } = relativePinGeometry(columnWidthEm, styles.emPx, sides, headSize);
|
|
262
327
|
const centerY = height / 2;
|
|
263
328
|
// Direct unit scaling via fontSize
|
|
264
329
|
const percentValue = Math.abs(value) * 100;
|
|
265
330
|
const scaledLength = percentValue * styles.percentageScaling * fs;
|
|
266
|
-
|
|
331
|
+
// auto scaling puts the longest pin on the limit, float rounding must not cut it
|
|
332
|
+
const isExtreme = scaledLength - maxPinLength > 1e-6;
|
|
267
333
|
const pinLength = Math.min(scaledLength, maxPinLength);
|
|
268
|
-
const isPositive = value
|
|
269
|
-
const
|
|
334
|
+
const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
|
|
335
|
+
const direction = isPositive ? 1 : -1;
|
|
336
|
+
const pinEndX = axisX + direction * pinLength;
|
|
270
337
|
// Get style based on column type (scenario vs variance)
|
|
271
338
|
const barStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
272
|
-
const
|
|
273
|
-
const
|
|
274
|
-
|
|
339
|
+
const look = getVarianceLook(scenario, styles);
|
|
340
|
+
const headStyle = (_a = look === null || look === void 0 ? void 0 : look.minuend) !== null && _a !== void 0 ? _a : styles.scenarios.ac;
|
|
341
|
+
// the arrow tip lands on the outer edge of a full-length head, so the label after it stays in the cell
|
|
342
|
+
const tipX = axisX + direction * (maxPinLength + headSize / 2);
|
|
343
|
+
const arrowBaseX = tipX - direction * headSize;
|
|
344
|
+
const labelX = (isExtreme ? tipX : pinEndX + direction * (headSize / 2)) + direction * labelGap;
|
|
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", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": isPositive ? "start" : "end", fill: styles.fontColor, "font-size": fs, "font-style": "italic", "font-family": styles.fontFamily }, 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}
|
|
@@ -22,60 +22,103 @@ export const BAR_LABEL_FONT_RATIO = 0.85;
|
|
|
22
22
|
* `.category-wN` (bn-table-renderer.scss:50-83) produces.
|
|
23
23
|
*/
|
|
24
24
|
const BAR_CELL_PADDING_EM = 0.5;
|
|
25
|
-
/** Value-label gutter beside a bar, in em (was a hardcoded 38 px at the 13.3333 px em). */
|
|
25
|
+
/** Value-label gutter beside a waterfall bar, in em (was a hardcoded 38 px at the 13.3333 px em). */
|
|
26
26
|
const BAR_LABEL_EM = 2.85;
|
|
27
|
-
/** Value-label gutter beside a pin, in em (was 45 px). */
|
|
28
|
-
const PIN_LABEL_EM = 3.375;
|
|
29
|
-
/** Gap between the axis and the start of a pin's reserved side, in em (was 5 px). */
|
|
30
|
-
const PIN_PADDING_EM = 0.375;
|
|
31
27
|
/** Zigzag break gap of an overdrive bar, in em (was 4 px). */
|
|
32
28
|
const BREAK_GAP_EM = 0.3;
|
|
33
29
|
/** Gap between a bar/pin end and its value label, in em (was 4 px). */
|
|
34
30
|
const LABEL_GAP_EM = 0.3;
|
|
31
|
+
/** Pin extent per side kept before a pin column drops label digits, in em. */
|
|
32
|
+
const MIN_EXTENT_EM = 1;
|
|
35
33
|
/** Share of the per-side bar extent reserved for the overdrive stub. */
|
|
36
34
|
const OVERDRIVE_FRACTION = 0.15;
|
|
35
|
+
/** Width of the axis of a variance bar or pin, in em: near the 0.3em scenario marker in the header. */
|
|
36
|
+
export const VARIANCE_AXIS_EM = 0.25;
|
|
37
|
+
/** Side of the square pin head, in px before scaleFactor. */
|
|
38
|
+
export const PIN_HEAD_SIZE = 10;
|
|
39
|
+
/**
|
|
40
|
+
* Advance widths in em, the larger of Noto Sans and Arial. The engine ships no font, so a
|
|
41
|
+
* wider fallback (DejaVu Sans, Verdana) is possible: LABEL_WIDTH_MARGIN and the cell
|
|
42
|
+
* padding cover it. Any glyph not listed counts as a wide letter.
|
|
43
|
+
*/
|
|
44
|
+
const GLYPH_EM = {
|
|
45
|
+
".": 0.28,
|
|
46
|
+
",": 0.28,
|
|
47
|
+
"-": 0.34,
|
|
48
|
+
"%": 0.89,
|
|
49
|
+
" ": 0.28,
|
|
50
|
+
"\u00a0": 0.28,
|
|
51
|
+
"\u202f": 0.28,
|
|
52
|
+
M: 0.9,
|
|
53
|
+
};
|
|
54
|
+
const DIGIT_EM = 0.59;
|
|
55
|
+
const OTHER_EM = 0.72;
|
|
56
|
+
/** Labels fill the cell to the edge, so the estimate keeps room for a wider fallback font. */
|
|
57
|
+
const LABEL_WIDTH_MARGIN = 1.1;
|
|
58
|
+
/** Estimated rendered width of a value label in px, with a margin for wider fonts. */
|
|
59
|
+
export function estimateLabelWidth(text, fontSize) {
|
|
60
|
+
var _a;
|
|
61
|
+
let em = 0;
|
|
62
|
+
for (const char of text) {
|
|
63
|
+
em += (_a = GLYPH_EM[char]) !== null && _a !== void 0 ? _a : (/[0-9+]/.test(char) ? DIGIT_EM : OTHER_EM);
|
|
64
|
+
}
|
|
65
|
+
return em * fontSize * LABEL_WIDTH_MARGIN;
|
|
66
|
+
}
|
|
37
67
|
/** The SVG fills the cell's content box: the requested column width minus the cell padding. */
|
|
38
68
|
function contentWidth(widthEm, emPx) {
|
|
39
69
|
return Math.max(0, (widthEm - BAR_CELL_PADDING_EM) * emPx);
|
|
40
70
|
}
|
|
41
|
-
/**
|
|
42
|
-
function
|
|
43
|
-
|
|
71
|
+
/** `outerReserve` covers what sticks out beyond the bar or pin end, e.g. the half head. */
|
|
72
|
+
function sideNeeds(labels, outerReserve, labelGap) {
|
|
73
|
+
const hasNeg = labels.neg !== undefined;
|
|
74
|
+
const hasPos = labels.pos !== undefined || !hasNeg;
|
|
75
|
+
const need = (has, width) => (has ? outerReserve + labelGap + (width !== null && width !== void 0 ? width : 0) : 0);
|
|
76
|
+
return { sides: (hasNeg ? 1 : 0) + (hasPos ? 1 : 0), neg: need(hasNeg, labels.neg), pos: need(hasPos, labels.pos) };
|
|
77
|
+
}
|
|
78
|
+
/** Bar or pin extent per side that a column keeps as long as its labels allow. */
|
|
79
|
+
function minExtent(totalWidth, emPx, sides) {
|
|
80
|
+
return Math.min(MIN_EXTENT_EM * emPx, totalWidth / (2 * sides));
|
|
44
81
|
}
|
|
45
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Reserves per side only what its widest label needs and gives the rest to the bars or
|
|
84
|
+
* pins. A column too narrow for that shortens the bars or pins first, down to zero, so a
|
|
85
|
+
* label keeps its sign. Only a column narrower than its labels alone shrinks the
|
|
86
|
+
* reserves, and then the labels overflow. wN stays wN in every case.
|
|
87
|
+
*/
|
|
88
|
+
function splitSides(totalWidth, labels, outerReserve, labelGap) {
|
|
89
|
+
const { sides, neg, pos } = sideNeeds(labels, outerReserve, labelGap);
|
|
90
|
+
const shrink = neg + pos > 0 ? Math.min(1, totalWidth / (neg + pos)) : 1;
|
|
91
|
+
const extent = Math.max(0, (totalWidth - (neg + pos) * shrink) / sides);
|
|
92
|
+
return { extent, axisX: labels.neg !== undefined ? neg * shrink + extent : 0 };
|
|
93
|
+
}
|
|
94
|
+
/** True when the labels fit beside pins of at least the minimum extent; else the caller drops digits. */
|
|
95
|
+
export function pinLabelsFit(widthEm, emPx, labels, headSize) {
|
|
46
96
|
const totalWidth = contentWidth(widthEm, emPx);
|
|
47
|
-
const sides =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
97
|
+
const { sides, neg, pos } = sideNeeds(labels, headSize / 2, LABEL_GAP_EM * emPx);
|
|
98
|
+
return neg + pos + sides * minExtent(totalWidth, emPx, sides) <= totalWidth + 1e-6;
|
|
99
|
+
}
|
|
100
|
+
export function absoluteBarGeometry(widthEm, emPx, labels) {
|
|
101
|
+
const totalWidth = contentWidth(widthEm, emPx);
|
|
102
|
+
const labelGap = LABEL_GAP_EM * emPx;
|
|
103
|
+
// a variance bar starts at the outer edge of the thick axis
|
|
104
|
+
const { extent: maxBarWidth, axisX } = splitSides(totalWidth, labels, (VARIANCE_AXIS_EM * emPx) / 2, labelGap);
|
|
51
105
|
const breakGap = Math.min(BREAK_GAP_EM * emPx, maxBarWidth * 0.2);
|
|
52
106
|
const overdriveZoneWidth = maxBarWidth * OVERDRIVE_FRACTION;
|
|
53
107
|
return {
|
|
54
108
|
totalWidth,
|
|
55
|
-
labelAreaWidth,
|
|
56
109
|
maxBarWidth,
|
|
57
|
-
axisX
|
|
110
|
+
axisX,
|
|
58
111
|
breakGap,
|
|
59
112
|
overdriveZoneWidth,
|
|
60
113
|
cutWidth: Math.max(0, maxBarWidth - breakGap - overdriveZoneWidth),
|
|
61
|
-
labelGap
|
|
114
|
+
labelGap,
|
|
62
115
|
};
|
|
63
116
|
}
|
|
64
|
-
export function relativePinGeometry(widthEm, emPx,
|
|
117
|
+
export function relativePinGeometry(widthEm, emPx, labels, headSize) {
|
|
65
118
|
const totalWidth = contentWidth(widthEm, emPx);
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
const sideWidth = pinAreaWidth / sides;
|
|
70
|
-
const pinPadding = Math.min(PIN_PADDING_EM * emPx, sideWidth * 0.2);
|
|
71
|
-
return {
|
|
72
|
-
totalWidth,
|
|
73
|
-
labelAreaWidth,
|
|
74
|
-
maxPinLength: Math.max(0, sideWidth - pinPadding),
|
|
75
|
-
pinPadding,
|
|
76
|
-
axisX: hasNeg ? sideWidth : 0,
|
|
77
|
-
labelX: pinAreaWidth + LABEL_GAP_EM * emPx,
|
|
78
|
-
};
|
|
119
|
+
const labelGap = LABEL_GAP_EM * emPx;
|
|
120
|
+
const { extent, axisX } = splitSides(totalWidth, labels, headSize / 2, labelGap);
|
|
121
|
+
return { totalWidth, maxPinLength: extent, axisX, labelGap };
|
|
79
122
|
}
|
|
80
123
|
export function waterfallGeometry(widthEm, emPx) {
|
|
81
124
|
const totalWidth = contentWidth(widthEm, emPx);
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
/**
|
|
15
15
|
* Built-in IBCS rule-set defaults per IBCS notation standard v1.2.
|
|
16
16
|
* Sort order: PP(100s) < PL(200s) < FC(300s) < AC(400s); variance prefixes
|
|
17
|
-
* add +1000 (absolute) or +
|
|
17
|
+
* add +1000 (absolute) or +1005 (relative), so a relative variance sorts
|
|
18
|
+
* directly after the absolute variance with the same reference.
|
|
18
19
|
*/
|
|
19
20
|
export const SYSTEM_RULESET_DEFAULTS = {
|
|
20
21
|
scenarios: {
|
|
@@ -30,12 +31,12 @@ export const SYSTEM_RULESET_DEFAULTS = {
|
|
|
30
31
|
dbu: { name: "dBU", colorIndex: 50, sortIndex: 1200 },
|
|
31
32
|
dpp: { name: "dPP", colorIndex: 20, sortIndex: 1100 },
|
|
32
33
|
dpy: { name: "dPY", colorIndex: 20, sortIndex: 1100 },
|
|
33
|
-
drac: { name: "drAC", colorIndex: 10, sortIndex:
|
|
34
|
-
drfc: { name: "drFC", colorIndex: 30, sortIndex:
|
|
35
|
-
drpl: { name: "drPL", colorIndex: 50, sortIndex:
|
|
36
|
-
drbu: { name: "drBU", colorIndex: 50, sortIndex:
|
|
37
|
-
drpp: { name: "drPP", colorIndex: 20, sortIndex:
|
|
38
|
-
drpy: { name: "drPY", colorIndex: 20, sortIndex:
|
|
34
|
+
drac: { name: "drAC", colorIndex: 10, sortIndex: 1405 },
|
|
35
|
+
drfc: { name: "drFC", colorIndex: 30, sortIndex: 1305 },
|
|
36
|
+
drpl: { name: "drPL", colorIndex: 50, sortIndex: 1205 },
|
|
37
|
+
drbu: { name: "drBU", colorIndex: 50, sortIndex: 1205 },
|
|
38
|
+
drpp: { name: "drPP", colorIndex: 20, sortIndex: 1105 },
|
|
39
|
+
drpy: { name: "drPY", colorIndex: 20, sortIndex: 1105 },
|
|
39
40
|
},
|
|
40
41
|
fallback: {
|
|
41
42
|
name: "Series",
|
|
@@ -53,7 +53,8 @@ export function ruleSetLabels(config) {
|
|
|
53
53
|
* - 50 = PL: outlined (no fill)
|
|
54
54
|
*
|
|
55
55
|
* Sort indices determine column display order: PP(100s) < PL(200s) < FC(300s) < AC(400s).
|
|
56
|
-
* Variance columns add +1000 (absolute) or +
|
|
56
|
+
* Variance columns add +1000 (absolute) or +1005 (relative) to the base sort index,
|
|
57
|
+
* so a relative variance sorts directly after the absolute variance with the same reference.
|
|
57
58
|
* Within each group, variant number (1-4) adds multiples of 10.
|
|
58
59
|
*
|
|
59
60
|
* The built-in rules live in `SYSTEM_RULESET_DEFAULTS` (stores/ruleSets); an
|