@bino-bi/bn-template-engine 1.0.0-next.39 → 1.0.0-next.41
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-2dd69cb9.entry.js +1 -0
- package/dist/bn-template-engine/{p-9a61f59d.entry.js → p-8b28c9bd.entry.js} +1 -1
- package/dist/bn-template-engine/{p-DyupX-Z-.js → p-BjozxTTW.js} +1 -1
- package/dist/bn-template-engine/p-EcC0qLtU.js +1 -0
- package/dist/bn-template-engine/{p-eea538f1.entry.js → p-a4b76176.entry.js} +1 -1
- package/dist/bn-template-engine/{p-93b8387f.entry.js → p-ce764078.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +785 -378
- package/dist/cjs/bn-grid.cjs.entry.js +1 -1
- package/dist/cjs/bn-image.cjs.entry.js +1 -1
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/bn-text.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{withStyled-DfE0aW7D.js → withStyled-BZb6snOx.js} +74 -0
- package/dist/cjs/{withTranslation-0gkn9xoC.js → withTranslation-FxXGUB3H.js} +1 -1
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +4 -1
- package/dist/collection/components/bn-chart-structure/utils/elements/Label.js +3 -1
- package/dist/collection/components/bn-chart-time/utils/elements/Label.js +3 -1
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.css +25 -1
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +156 -11
- package/dist/collection/components/bn-table/bn-table.js +134 -5
- package/dist/collection/components/bn-table/utils/elements/Cell.js +10 -1
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +25 -10
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +50 -12
- package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +44 -14
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +63 -2
- package/dist/collection/components/bn-table/utils/helper/WaterfallCalculator.js +123 -11
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +57 -9
- package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +16 -1
- package/dist/collection/components/bn-table/utils/model/index.js +6 -0
- package/dist/collection/utils/validate.js +4 -0
- 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.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-grid.js +1 -1
- package/dist/components/bn-image.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-page.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.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/p-1B_s8oPY.js +1 -0
- package/dist/components/{p-BqUB56k1.js → p-B4L069XF.js} +1 -1
- package/dist/components/p-BZXiWkDS.js +1 -0
- package/dist/components/p-BiSytXUy.js +1 -0
- package/dist/components/p-Bn7J1pgl.js +1 -0
- package/dist/components/{p-BmOWXYHF.js → p-CEf5X8MZ.js} +1 -1
- package/dist/components/p-CGySoYRH.js +1 -0
- package/dist/components/{p-Cyf5ZEXs.js → p-CUSAlS2o.js} +1 -1
- package/dist/components/p-CvEdUq8i.js +1 -0
- package/dist/components/{p-OquycEMA.js → p-D40Am1Ap.js} +1 -1
- package/dist/components/{p-B4Cf0cVi.js → p-DM4Up10X.js} +1 -1
- package/dist/components/{p-Bo_R7f_T.js → p-DwuXVo2h.js} +1 -1
- package/dist/components/{p-DTmqMQpw.js → p-Y9bth2Y_.js} +1 -1
- package/dist/components/{p-BU_53KVT.js → p-xIWChKGS.js} +1 -1
- package/dist/esm/bn-annotation-layer_30.entry.js +903 -496
- package/dist/esm/bn-grid.entry.js +1 -1
- package/dist/esm/bn-image.entry.js +1 -1
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/bn-text.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{withStyled-CIoJ86RM.js → withStyled-CzzXg64f.js} +77 -4
- package/dist/esm/{withTranslation-BX9T3dfm.js → withTranslation-Daq2JXkv.js} +1 -1
- package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +20 -1
- package/dist/types/components/bn-table/bn-table.d.ts +49 -1
- package/dist/types/components/bn-table/utils/elements/Cell.d.ts +3 -0
- package/dist/types/components/bn-table/utils/elements/CellBarChart.d.ts +26 -0
- package/dist/types/components/bn-table/utils/elements/WaterfallBar.d.ts +22 -2
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +13 -0
- package/dist/types/components/bn-table/utils/helper/WaterfallCalculator.d.ts +30 -2
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +24 -4
- package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +7 -1
- package/dist/types/components/bn-table/utils/model/index.d.ts +5 -0
- package/dist/types/components.d.ts +49 -4
- package/dist/types/utils/validate.d.ts +1 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-8c84d57e.entry.js +0 -1
- package/dist/bn-template-engine/p-BVU4bIsi.js +0 -1
- package/dist/components/p-BsJOvfIg.js +0 -1
- package/dist/components/p-DCPLGEs_.js +0 -1
- package/dist/components/p-DT04Cka0.js +0 -1
- package/dist/components/p-Dm6EAaJ9.js +0 -1
- package/dist/components/p-dRPJiQB6.js +0 -1
- package/dist/components/p-tkB96Ena.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, h, a as Host, g as getElement, f as forceUpdate, d as writeTask, F as Fragment$1 } from './index-CCZcKl0Q.js';
|
|
2
2
|
import { S as SYSTEM_STYLE_DEFAULTS, w as withComponentStatus, a as withHasError, g as getStores, C as ComponentRegister, r as runIfExisits, c as clearStoresCache, h as hasInlineJs, d as globalLabelKeys, e as SYSTEM_RULESET_DEFAULTS, X as XY_SERIES_PALETTE, i as getDefaultExportFromCjs, D as DateTime, j as resolveSeriesColor, m as markTreatment, s as shade, k as sourceExpr, l as reportOverflow, u as unknownStyleKeys, n as getOrCreateStores } from './withHasError-B6Lvj9Cq.js';
|
|
3
|
-
import { a as withComponentStyle, m as merge, C as CompareUtil, i as isBlankInput, b as isValidInteger, w as withStyled, c as isValidMeasureToken, r as resolveMeasure, s as scenarioFamily, d as scenarioSlotNumber, e as axisInValueUnits, f as isRelativeMeasure, v as validateOrderList, g as isValidDirection, A as AggregationLevel, O as OrderDirection
|
|
4
|
-
import { s as sanitizeHtml, g as getParentDimensions, b as getClippedHeight, i as isInheritedValue, f as findLayoutAncestors, r as readInherited, a as withDataset, w as withTranslation, p as parseScaling, c as strokeWidthPx, d as resolveScalingValue, e as formatScalingValue, h as withInheritedProps, j as parseScalingValue } from './withTranslation-
|
|
3
|
+
import { a as withComponentStyle, m as merge, C as CompareUtil, i as isBlankInput, b as isValidInteger, w as withStyled, c as isValidMeasureToken, r as resolveMeasure, s as scenarioFamily, d as scenarioSlotNumber, e as axisInValueUnits, f as isRelativeMeasure, v as validateOrderList, g as isValidDirection, A as AggregationLevel, O as OrderDirection, h as Order, j as OrderColumn, k as validateScenarioList, l as validateVariancesList, n as isValidLevel, o as isValidMeasureScale, p as validateStackConfig, S as StackBy, q as StackOrder, t as StackMode, u as AdapterUtils, x as OrderAdapter, N as NOT_AVAILABLE, y as relativeVariance, z as isValidNumber, B as isValidDateFormat, D as isValidAxisLabelsMode, E as DateDistance, F as AxisLabelsMode, G as ChartMode, H as DateStringFactory, R as RELATIVE_STACK_UNITS, I as murmur2, J as validateBarColumnsList, K as isTableBarColumnWidth, L as isValidDataFormat, M as isValidTableType, P as validateThereOfJsonStr, Q as isValidThereofPosition, T as validatePartOfJsonStr, U as validateTableOrderList, V as isValidMeasureType, W as isTableCategoryWidth, X as validateColumnThereOfJsonStr, Y as validateAttributesJsonStr, Z as DataFormat, _ as ThereofPosition, $ as TableType$2, a0 as normalizeOrderToken, a1 as I18nMode, a2 as TableCategoryWidth, a3 as MeasureType, a4 as parseTableAttributeExpression, a5 as BAR_COLUMN_WIDTH_EM, a6 as TableBarColumnWidth, a7 as TableRowType, a8 as FIELD_IDENTIFIER_REGEX, a9 as parseOrderToken, aa as Scenarios, ab as OrderDirection$1, ac as FactoryState$3, ad as validateMeasureList, ae as isValidDate, af as isValidDateLink, ag as DateLink } from './withStyled-CzzXg64f.js';
|
|
4
|
+
import { s as sanitizeHtml, g as getParentDimensions, b as getClippedHeight, i as isInheritedValue, f as findLayoutAncestors, r as readInherited, a as withDataset, w as withTranslation, p as parseScaling, c as strokeWidthPx, d as resolveScalingValue, e as formatScalingValue, h as withInheritedProps, j as parseScalingValue } from './withTranslation-Daq2JXkv.js';
|
|
5
5
|
import { w as withBodyObserver } from './withBodyObserver-AHQAUV85.js';
|
|
6
6
|
import { r as readDiagnostics, m as measure, a as resolveStandaloneId, l as localFrameOf, o as originsFor, b as assignIds, c as resolveOwnIdentity, t as toLayoutRect, d as measureContent, e as measureSign } from './localFrame-BNWPPaQa.js';
|
|
7
7
|
import { LAYOUT_STATE_VERSION } from './index.js';
|
|
@@ -9568,7 +9568,9 @@ let Label$1 = class Label {
|
|
|
9568
9568
|
type = "decimal";
|
|
9569
9569
|
}
|
|
9570
9570
|
valueStr = Formatter.number(Number(value), type, digits, digitsMin, scale, this.styles.locale);
|
|
9571
|
-
|
|
9571
|
+
// a value that rounds to zero prints without a sign
|
|
9572
|
+
const zeroStr = Formatter.number(0, type, digits, digitsMin, scale, this.styles.locale);
|
|
9573
|
+
if (this.isVarianceLabel && Number(this.value) > 0 && valueStr !== zeroStr) {
|
|
9572
9574
|
prefix = "+";
|
|
9573
9575
|
}
|
|
9574
9576
|
}
|
|
@@ -11840,7 +11842,7 @@ const ChartBullet = class {
|
|
|
11840
11842
|
this.errors.remove("AUTO_order");
|
|
11841
11843
|
orderStr = this.order;
|
|
11842
11844
|
}
|
|
11843
|
-
const direction = (_d = OrderDirection
|
|
11845
|
+
const direction = (_d = OrderDirection[(_c = this.orderDirection) === null || _c === void 0 ? void 0 : _c.toUpperCase()]) !== null && _d !== void 0 ? _d : OrderDirection.ASC;
|
|
11844
11846
|
if (isBlankInput(orderStr)) {
|
|
11845
11847
|
return new Order([OrderColumn.CATEGORYINDEX], direction);
|
|
11846
11848
|
}
|
|
@@ -14912,7 +14914,7 @@ const Chart$1 = class Chart {
|
|
|
14912
14914
|
}
|
|
14913
14915
|
const tableOrder = {
|
|
14914
14916
|
hierarchy: orderStr === null || orderStr === void 0 ? void 0 : orderStr.split(",").map((entry) => OrderColumn[entry === null || entry === void 0 ? void 0 : entry.toUpperCase()]),
|
|
14915
|
-
direction: OrderDirection
|
|
14917
|
+
direction: OrderDirection[effectiveDirection === null || effectiveDirection === void 0 ? void 0 : effectiveDirection.toUpperCase()],
|
|
14916
14918
|
};
|
|
14917
14919
|
return tableOrder;
|
|
14918
14920
|
}
|
|
@@ -15598,11 +15600,11 @@ let CustomPattern$1 = class CustomPattern {
|
|
|
15598
15600
|
}
|
|
15599
15601
|
};
|
|
15600
15602
|
|
|
15601
|
-
var FactoryState$
|
|
15603
|
+
var FactoryState$2;
|
|
15602
15604
|
(function (FactoryState) {
|
|
15603
15605
|
FactoryState[FactoryState["UP_TO_DATE"] = 0] = "UP_TO_DATE";
|
|
15604
15606
|
FactoryState[FactoryState["DIRTY"] = 1] = "DIRTY";
|
|
15605
|
-
})(FactoryState$
|
|
15607
|
+
})(FactoryState$2 || (FactoryState$2 = {}));
|
|
15606
15608
|
var VarianceType$1;
|
|
15607
15609
|
(function (VarianceType) {
|
|
15608
15610
|
VarianceType["RELATIVE"] = "dr";
|
|
@@ -16260,12 +16262,12 @@ var Scenario$1;
|
|
|
16260
16262
|
Scenario["NEU"] = "neu";
|
|
16261
16263
|
})(Scenario$1 || (Scenario$1 = {}));
|
|
16262
16264
|
/** Chart-internal table aggregation modes. */
|
|
16263
|
-
var TableType$
|
|
16265
|
+
var TableType$1;
|
|
16264
16266
|
(function (TableType) {
|
|
16265
16267
|
TableType["LIST"] = "LIST";
|
|
16266
16268
|
TableType["SUM"] = "SUM";
|
|
16267
16269
|
TableType["OPT"] = "OPT";
|
|
16268
|
-
})(TableType$
|
|
16270
|
+
})(TableType$1 || (TableType$1 = {}));
|
|
16269
16271
|
|
|
16270
16272
|
// import {Formatter} from "../../../../utils";
|
|
16271
16273
|
// import {StructureChartStyle} from "../model";
|
|
@@ -16368,7 +16370,9 @@ class Label {
|
|
|
16368
16370
|
if (Number(this.value) < 0) {
|
|
16369
16371
|
labelAnchor = "end";
|
|
16370
16372
|
}
|
|
16371
|
-
|
|
16373
|
+
// a value that rounds to zero prints without a sign
|
|
16374
|
+
const zeroStr = Formatter.number(0, type, digits, digitsMin, scale, this.styles.locale);
|
|
16375
|
+
if (this.isVarianceLabel && Number(this.value) > 0 && valueStr !== zeroStr) {
|
|
16372
16376
|
prefix = "+";
|
|
16373
16377
|
}
|
|
16374
16378
|
}
|
|
@@ -17408,7 +17412,7 @@ class StructureChart {
|
|
|
17408
17412
|
this.hideCategories = false;
|
|
17409
17413
|
this.axisScenario = Scenario$1.AC1;
|
|
17410
17414
|
this.CSS_CATEGORIES = "categories";
|
|
17411
|
-
this.state = FactoryState$
|
|
17415
|
+
this.state = FactoryState$2.DIRTY;
|
|
17412
17416
|
this.titleLength = 0;
|
|
17413
17417
|
this.leftSideOffsetForHorizontalSync = 0;
|
|
17414
17418
|
this.limit = 0;
|
|
@@ -17452,7 +17456,7 @@ class StructureChart {
|
|
|
17452
17456
|
}
|
|
17453
17457
|
setConfig(config) {
|
|
17454
17458
|
var _a, _b;
|
|
17455
|
-
this.state = FactoryState$
|
|
17459
|
+
this.state = FactoryState$2.DIRTY;
|
|
17456
17460
|
this.scenarioPropOrder = [...config.scenarios];
|
|
17457
17461
|
const scenarios = this.sortScenariosbyVisualisationRules(config.scenarios);
|
|
17458
17462
|
this.hideCategories = config.hideCategories || false;
|
|
@@ -17525,7 +17529,7 @@ class StructureChart {
|
|
|
17525
17529
|
this.title = this.configTitle || Formatter.translateScenarioLabel((_a = this.configVariances) === null || _a === void 0 ? void 0 : _a.toString(), this.i18n);
|
|
17526
17530
|
}
|
|
17527
17531
|
createI18n(i18n) {
|
|
17528
|
-
this.state = FactoryState$
|
|
17532
|
+
this.state = FactoryState$2.DIRTY;
|
|
17529
17533
|
const defaultI18n = new Map([
|
|
17530
17534
|
["SEPARATOR_WS", ", "],
|
|
17531
17535
|
["in", "in"],
|
|
@@ -17566,7 +17570,7 @@ class StructureChart {
|
|
|
17566
17570
|
*/
|
|
17567
17571
|
setSource(filter) {
|
|
17568
17572
|
var _a, _b;
|
|
17569
|
-
this.state = FactoryState$
|
|
17573
|
+
this.state = FactoryState$2.DIRTY;
|
|
17570
17574
|
this.queryError = undefined;
|
|
17571
17575
|
// "" while the source is not registered yet: no data, and no error
|
|
17572
17576
|
this.fromExpr = sourceExpr(this.db, this.tableName, filter);
|
|
@@ -17692,8 +17696,8 @@ class StructureChart {
|
|
|
17692
17696
|
draw(svgContainer) {
|
|
17693
17697
|
this.cleanSVGforRedraw(svgContainer);
|
|
17694
17698
|
this.applyFontToContainer(svgContainer);
|
|
17695
|
-
if (this.state === FactoryState$
|
|
17696
|
-
this.state = FactoryState$
|
|
17699
|
+
if (this.state === FactoryState$2.DIRTY) {
|
|
17700
|
+
this.state = FactoryState$2.UP_TO_DATE;
|
|
17697
17701
|
}
|
|
17698
17702
|
if (this.variancesDataModel && this.variancesDataModel.length > 0) {
|
|
17699
17703
|
this.drawVarianceScenario(this.variancesDataModel, svgContainer);
|
|
@@ -18110,7 +18114,10 @@ class StructureChart {
|
|
|
18110
18114
|
}
|
|
18111
18115
|
calculatePercentageTextBoxWidth(value) {
|
|
18112
18116
|
let signWidth = 0;
|
|
18113
|
-
|
|
18117
|
+
// like the label: no sign for a value that rounds to zero
|
|
18118
|
+
const digits = this.dataFormatDigits.percent;
|
|
18119
|
+
const percent = (v) => Formatter.number(v, "percent", digits, digits, 1, this.styles.locale);
|
|
18120
|
+
if (value > 0 && percent(value) !== percent(0)) {
|
|
18114
18121
|
signWidth += CalculateSize("+", {
|
|
18115
18122
|
font: this.styles.fontStyles.font,
|
|
18116
18123
|
fontSize: this.styles.fontStyles.size + "px",
|
|
@@ -18540,7 +18547,7 @@ const BnChartStructureRenderer = class {
|
|
|
18540
18547
|
/** @internal */
|
|
18541
18548
|
this.order = {
|
|
18542
18549
|
hierarchy: [],
|
|
18543
|
-
direction: OrderDirection
|
|
18550
|
+
direction: OrderDirection.ASC,
|
|
18544
18551
|
};
|
|
18545
18552
|
/** @internal */
|
|
18546
18553
|
this.level = AggregationLevel.CATEGORY;
|
|
@@ -20731,12 +20738,12 @@ var Scenario;
|
|
|
20731
20738
|
Scenario["NEU"] = "neu";
|
|
20732
20739
|
})(Scenario || (Scenario = {}));
|
|
20733
20740
|
/** Chart-internal table aggregation modes. */
|
|
20734
|
-
var TableType
|
|
20741
|
+
var TableType;
|
|
20735
20742
|
(function (TableType) {
|
|
20736
20743
|
TableType["LIST"] = "LIST";
|
|
20737
20744
|
TableType["SUM"] = "SUM";
|
|
20738
20745
|
TableType["OPT"] = "OPT";
|
|
20739
|
-
})(TableType
|
|
20746
|
+
})(TableType || (TableType = {}));
|
|
20740
20747
|
|
|
20741
20748
|
/**
|
|
20742
20749
|
* Renders the horizontal baseline axis for a time chart.
|
|
@@ -22131,11 +22138,11 @@ function drawAttached(container, drawFn) {
|
|
|
22131
22138
|
/** Above this many periods between the first and the last date, gaps are not filled with empty periods. */
|
|
22132
22139
|
const MAX_GAP_FILLED_PERIODS = 10000;
|
|
22133
22140
|
/** Tracks whether the internal data model needs to be regenerated. */
|
|
22134
|
-
var FactoryState$
|
|
22141
|
+
var FactoryState$1;
|
|
22135
22142
|
(function (FactoryState) {
|
|
22136
22143
|
FactoryState[FactoryState["UP_TO_DATE"] = 0] = "UP_TO_DATE";
|
|
22137
22144
|
FactoryState[FactoryState["DIRTY"] = 1] = "DIRTY";
|
|
22138
|
-
})(FactoryState$
|
|
22145
|
+
})(FactoryState$1 || (FactoryState$1 = {}));
|
|
22139
22146
|
/** Classifies how a data model entry should be rendered: as an absolute or relative variance, or as a regular scenario. */
|
|
22140
22147
|
var VarianceType;
|
|
22141
22148
|
(function (VarianceType) {
|
|
@@ -22185,7 +22192,7 @@ class TimeChart {
|
|
|
22185
22192
|
this.rowCount = 0;
|
|
22186
22193
|
this.axisCategoryArea = { width: 0, height: 0 };
|
|
22187
22194
|
this.scenariosArea = { width: 0, height: 0 };
|
|
22188
|
-
this.state = FactoryState$
|
|
22195
|
+
this.state = FactoryState$1.DIRTY;
|
|
22189
22196
|
this.i18n = new Map();
|
|
22190
22197
|
this.leftSideOffsetForHorizontalSync = -1;
|
|
22191
22198
|
this.dateInterval = DateDistance.DAY;
|
|
@@ -22284,7 +22291,7 @@ class TimeChart {
|
|
|
22284
22291
|
}
|
|
22285
22292
|
setConfig(config) {
|
|
22286
22293
|
var _a;
|
|
22287
|
-
this.state = FactoryState$
|
|
22294
|
+
this.state = FactoryState$1.DIRTY;
|
|
22288
22295
|
// Must precede setSource/populateModel: the locale is baked into the
|
|
22289
22296
|
// normalizeDate() SQL as well as into the axis date labels.
|
|
22290
22297
|
this.locale = config.locale;
|
|
@@ -22378,7 +22385,7 @@ class TimeChart {
|
|
|
22378
22385
|
*/
|
|
22379
22386
|
setSource(filter) {
|
|
22380
22387
|
var _a, _b;
|
|
22381
|
-
this.state = FactoryState$
|
|
22388
|
+
this.state = FactoryState$1.DIRTY;
|
|
22382
22389
|
this.queryError = undefined;
|
|
22383
22390
|
// "" while the source is not registered yet: no data, and no error
|
|
22384
22391
|
this.fromExpr = sourceExpr(this.db, this.tableName, filter);
|
|
@@ -22522,8 +22529,8 @@ class TimeChart {
|
|
|
22522
22529
|
draw(svgContainer) {
|
|
22523
22530
|
this.cleanSVGforRedraw(svgContainer);
|
|
22524
22531
|
this.applyFontToContainer(svgContainer);
|
|
22525
|
-
if (this.state === FactoryState$
|
|
22526
|
-
this.state = FactoryState$
|
|
22532
|
+
if (this.state === FactoryState$1.DIRTY) {
|
|
22533
|
+
this.state = FactoryState$1.UP_TO_DATE;
|
|
22527
22534
|
}
|
|
22528
22535
|
if (this.isVarianceChart()) {
|
|
22529
22536
|
this.drawVarianceScenario(this.variancesDataModel, svgContainer);
|
|
@@ -22589,7 +22596,7 @@ class TimeChart {
|
|
|
22589
22596
|
}
|
|
22590
22597
|
}
|
|
22591
22598
|
createI18n(i18n) {
|
|
22592
|
-
this.state = FactoryState$
|
|
22599
|
+
this.state = FactoryState$1.DIRTY;
|
|
22593
22600
|
const defaultI18n = new Map([
|
|
22594
22601
|
["SEPARATOR_WS", ", "],
|
|
22595
22602
|
["in", "in"],
|
|
@@ -26547,70 +26554,6 @@ const ScalingGroup = class {
|
|
|
26547
26554
|
};
|
|
26548
26555
|
ScalingGroup.style = bnScalingGroupCss();
|
|
26549
26556
|
|
|
26550
|
-
/** Sentinel value indicating all groups should be included. */
|
|
26551
|
-
var GroupSelection;
|
|
26552
|
-
(function (GroupSelection) {
|
|
26553
|
-
GroupSelection[GroupSelection["ALL"] = -1] = "ALL";
|
|
26554
|
-
})(GroupSelection || (GroupSelection = {}));
|
|
26555
|
-
/**
|
|
26556
|
-
* Tracks whether a factory's output is current or needs recalculation.
|
|
26557
|
-
* Used to avoid redundant re-rendering when underlying data has not changed.
|
|
26558
|
-
*/
|
|
26559
|
-
var FactoryState$1;
|
|
26560
|
-
(function (FactoryState) {
|
|
26561
|
-
/** Output matches the current input data. */
|
|
26562
|
-
FactoryState[FactoryState["UP_TO_DATE"] = 0] = "UP_TO_DATE";
|
|
26563
|
-
/** Input data has changed; output needs to be regenerated. */
|
|
26564
|
-
FactoryState[FactoryState["DIRTY"] = 1] = "DIRTY";
|
|
26565
|
-
})(FactoryState$1 || (FactoryState$1 = {}));
|
|
26566
|
-
/**
|
|
26567
|
-
* Table aggregation modes controlling how rows are grouped and totalled.
|
|
26568
|
-
*
|
|
26569
|
-
* - `LIST` -- Flat list with no aggregation.
|
|
26570
|
-
* - `SUM` -- Grouped rows with sum totals per group and a grand total.
|
|
26571
|
-
* - `SUMNOTOTAL` -- Grouped rows with group sums but no grand total row.
|
|
26572
|
-
* - `OPT` -- Operation-aware aggregation (respects the +/- operation field).
|
|
26573
|
-
* - `OPTNOTOTAL` -- Operation-aware aggregation without a grand total row.
|
|
26574
|
-
*/
|
|
26575
|
-
var TableType;
|
|
26576
|
-
(function (TableType) {
|
|
26577
|
-
TableType["LIST"] = "list";
|
|
26578
|
-
TableType["SUM"] = "sum";
|
|
26579
|
-
TableType["SUMNOTOTAL"] = "sumnototal";
|
|
26580
|
-
TableType["OPT"] = "opt";
|
|
26581
|
-
TableType["OPTNOTOTAL"] = "optnototal";
|
|
26582
|
-
})(TableType || (TableType = {}));
|
|
26583
|
-
var OrderDirection;
|
|
26584
|
-
(function (OrderDirection) {
|
|
26585
|
-
OrderDirection["ASC"] = "asc";
|
|
26586
|
-
OrderDirection["DESC"] = "desc";
|
|
26587
|
-
})(OrderDirection || (OrderDirection = {}));
|
|
26588
|
-
/**
|
|
26589
|
-
* Discriminator for rendered table rows, controlling visual styling and behavior.
|
|
26590
|
-
*
|
|
26591
|
-
* - `HEADER` -- Column header row.
|
|
26592
|
-
* - `GROUPHEAD` -- Group title row (rendered when `grouped` is true).
|
|
26593
|
-
* - `SEPERATORLINE` -- Visual divider between groups.
|
|
26594
|
-
* - `SUM` -- Grand total row.
|
|
26595
|
-
* - `GROUPSUM` -- Sub-total row for a single group.
|
|
26596
|
-
* - `DRILLELEMENT` -- "Thereof" drill-down sub-row.
|
|
26597
|
-
* - `STANDARD` -- Normal data row.
|
|
26598
|
-
* - `PARTELEMENT` -- "Part of" percentage row.
|
|
26599
|
-
* - `ENTRY` -- Generic entry row.
|
|
26600
|
-
*/
|
|
26601
|
-
var TableRowType;
|
|
26602
|
-
(function (TableRowType) {
|
|
26603
|
-
TableRowType["HEADER"] = "HEADER";
|
|
26604
|
-
TableRowType["GROUPHEAD"] = "GROUPHEAD";
|
|
26605
|
-
TableRowType["SEPERATORLINE"] = "SEPERATORLINE";
|
|
26606
|
-
TableRowType["SUM"] = "SUM";
|
|
26607
|
-
TableRowType["GROUPSUM"] = "GROUP_SUM";
|
|
26608
|
-
TableRowType["DRILLELEMENT"] = "DRILLELEMENT";
|
|
26609
|
-
TableRowType["STANDARD"] = "STANDARD";
|
|
26610
|
-
TableRowType["PARTELEMENT"] = "PARTELEMENT";
|
|
26611
|
-
TableRowType["ENTRY"] = "ENTRY";
|
|
26612
|
-
})(TableRowType || (TableRowType = {}));
|
|
26613
|
-
|
|
26614
26557
|
/** `interval` value deactivating the feature. */
|
|
26615
26558
|
const INTERVAL_NONE = "none";
|
|
26616
26559
|
/** `interval` value grouping by the dataset's `setname` column. */
|
|
@@ -26823,7 +26766,7 @@ const Table$1 = class Table {
|
|
|
26823
26766
|
/**
|
|
26824
26767
|
* Data units displayed per 1 em of bar length for absolute variance bar
|
|
26825
26768
|
* charts (ΔPY) - map-scale semantics: a larger value means smaller bars.
|
|
26826
|
-
* Bars exceeding barColumnWidth are
|
|
26769
|
+
* Bars exceeding barColumnWidth are cut with a zigzag break.
|
|
26827
26770
|
*
|
|
26828
26771
|
* | Value | Behavior |
|
|
26829
26772
|
* |------------------|----------------------------------------------------------------|
|
|
@@ -26891,6 +26834,37 @@ const Table$1 = class Table {
|
|
|
26891
26834
|
*
|
|
26892
26835
|
*/
|
|
26893
26836
|
this.showGroupTitle = true;
|
|
26837
|
+
/**
|
|
26838
|
+
* Turns the sum row of each (row-)group into a running result: the sum of all
|
|
26839
|
+
* rows from the first group down to its own group, with the matching absolute
|
|
26840
|
+
* and relative variances. Use it for a calculation scheme such as an income
|
|
26841
|
+
* statement, where each `rowGroup` ends in a result.
|
|
26842
|
+
* <br /><br />
|
|
26843
|
+
* Needs `grouped` and a type with group sums (```sum // opt // sumnototal // optnototal```).
|
|
26844
|
+
* The total row of ```sum``` and ```opt``` stays and repeats the last running
|
|
26845
|
+
* result, so ```sumnototal``` or ```optnototal``` is the usual choice.
|
|
26846
|
+
* `partof` shares still refer to the sum of their own group.
|
|
26847
|
+
* Not supported together with `columnthereof`: there it has no effect.
|
|
26848
|
+
* <br /><br />
|
|
26849
|
+
* values: <br />
|
|
26850
|
+
* ```true // false```
|
|
26851
|
+
*/
|
|
26852
|
+
this.runningSum = false;
|
|
26853
|
+
/**
|
|
26854
|
+
* Draws every absolute variance column (d_*) listed in ```barColumns``` as a
|
|
26855
|
+
* variance waterfall down the rows instead of single bars from the axis.
|
|
26856
|
+
* A row starts where the row above ended; on ```opt``` and ```optnototal```
|
|
26857
|
+
* tables a "-" row with a positive variance moves to the left. Sum rows are
|
|
26858
|
+
* bars from the axis. Thin lines join the bars. Each row group starts at the
|
|
26859
|
+
* axis again, with ```runningSum``` the walk goes on from the sum row.
|
|
26860
|
+
* The column scales to fit the whole walk (unit-scaling does not apply).
|
|
26861
|
+
* Relative variance columns (dr_*) stay pins.
|
|
26862
|
+
* Has no effect together with ```interval``` or ```columnthereof```.
|
|
26863
|
+
* <br /><br />
|
|
26864
|
+
* values: <br />
|
|
26865
|
+
* ```true // false```
|
|
26866
|
+
*/
|
|
26867
|
+
this.varianceWaterfall = false;
|
|
26894
26868
|
/**
|
|
26895
26869
|
* Set the table type
|
|
26896
26870
|
* <br /><br />
|
|
@@ -26918,6 +26892,21 @@ const Table$1 = class Table {
|
|
|
26918
26892
|
* ```[{"rowGroup": "Umsatz", "category": "Applications", "subCategory": "Applications-A"}]```
|
|
26919
26893
|
*/
|
|
26920
26894
|
this.thereof = "[]";
|
|
26895
|
+
/**
|
|
26896
|
+
* Position of the `thereof` rows relative to their parent row.
|
|
26897
|
+
* <br /><br />
|
|
26898
|
+
* ```below``` (default) prints them below the parent, small and italic, with
|
|
26899
|
+
* the thereof label. ```above``` prints them before the parent in normal
|
|
26900
|
+
* size with an indented label, and the parent row looks like a subtotal
|
|
26901
|
+
* (bold, with a line above it). The parent keeps its operation sign and its
|
|
26902
|
+
* value, so a parent of `-` rows reads like "- Operating expenses".
|
|
26903
|
+
* With ```above``` list all subcategories of the parent (`"subCategory": ""`):
|
|
26904
|
+
* with only some of them the parent looks like a subtotal that does not add up.
|
|
26905
|
+
* <br /><br />
|
|
26906
|
+
* values: <br />
|
|
26907
|
+
* ```below // above```
|
|
26908
|
+
*/
|
|
26909
|
+
this.thereofPosition = "below";
|
|
26921
26910
|
/**
|
|
26922
26911
|
* JSON array of part-of objects with the keys `rowGroup` and `category`
|
|
26923
26912
|
* (both strings, both required).
|
|
@@ -27306,6 +27295,19 @@ const Table$1 = class Table {
|
|
|
27306
27295
|
this.errors.remove(errId);
|
|
27307
27296
|
}
|
|
27308
27297
|
}
|
|
27298
|
+
validateThereofPosition(newValue) {
|
|
27299
|
+
const errId = "WARN_thereofPosition";
|
|
27300
|
+
if (isBlankInput(newValue) || isValidThereofPosition(newValue)) {
|
|
27301
|
+
this.errors.remove(errId);
|
|
27302
|
+
}
|
|
27303
|
+
else {
|
|
27304
|
+
this.errors.addOrReplace({
|
|
27305
|
+
id: errId,
|
|
27306
|
+
type: "warning",
|
|
27307
|
+
message: "thereofPosition: invalid value '" + newValue + "' is not supported.",
|
|
27308
|
+
});
|
|
27309
|
+
}
|
|
27310
|
+
}
|
|
27309
27311
|
validatePartOf(newValue) {
|
|
27310
27312
|
const errId = "WARN_partof";
|
|
27311
27313
|
const invalidElements = validatePartOfJsonStr(newValue);
|
|
@@ -27483,6 +27485,7 @@ const Table$1 = class Table {
|
|
|
27483
27485
|
this.validateType(this.type);
|
|
27484
27486
|
this.validateLimit(this.limit);
|
|
27485
27487
|
this.validateThereOf(this.thereof);
|
|
27488
|
+
this.validateThereofPosition(this.thereofPosition);
|
|
27486
27489
|
this.validatePartOf(this.partof);
|
|
27487
27490
|
this.validateOrderDirection(this.orderDirection);
|
|
27488
27491
|
this.validateOrderList(this.order);
|
|
@@ -27626,9 +27629,15 @@ const Table$1 = class Table {
|
|
|
27626
27629
|
prepareShowGroupTitle() {
|
|
27627
27630
|
return this.showGroupTitle;
|
|
27628
27631
|
}
|
|
27632
|
+
prepareThereofPosition() {
|
|
27633
|
+
var _a;
|
|
27634
|
+
return ((_a = this.thereofPosition) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ThereofPosition.ABOVE
|
|
27635
|
+
? ThereofPosition.ABOVE
|
|
27636
|
+
: ThereofPosition.BELOW;
|
|
27637
|
+
}
|
|
27629
27638
|
prepareTableType() {
|
|
27630
27639
|
var _a;
|
|
27631
|
-
return TableType[(_a = this.type) === null || _a === void 0 ? void 0 : _a.toUpperCase()];
|
|
27640
|
+
return TableType$2[(_a = this.type) === null || _a === void 0 ? void 0 : _a.toUpperCase()];
|
|
27632
27641
|
}
|
|
27633
27642
|
prepareLimit() {
|
|
27634
27643
|
return Math.floor(Number(this.limit) || 0);
|
|
@@ -27669,7 +27678,7 @@ const Table$1 = class Table {
|
|
|
27669
27678
|
}
|
|
27670
27679
|
const tableOrder = {
|
|
27671
27680
|
hierarchy: orderStr.split(",").map((entry) => normalizeOrderToken(entry)),
|
|
27672
|
-
direction: OrderDirection
|
|
27681
|
+
direction: OrderDirection[effectiveDirection === null || effectiveDirection === void 0 ? void 0 : effectiveDirection.toUpperCase()],
|
|
27673
27682
|
};
|
|
27674
27683
|
return tableOrder;
|
|
27675
27684
|
}
|
|
@@ -28135,7 +28144,7 @@ const Table$1 = class Table {
|
|
|
28135
28144
|
render() {
|
|
28136
28145
|
const fontStyles = this.getFontStyles();
|
|
28137
28146
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
28138
|
-
return (h(Host, { key: '
|
|
28147
|
+
return (h(Host, { key: '2af1b7f31952cd0ba32e0a069ce143d3402b4a77', style: fontStyles }, h("div", { key: 'b78ad13abb48a43c1da0aec4727372a482c39701' }, h("bn-table-renderer", { key: 'ab0132a3b57953379f6d8f5f19a18f95a14cc326', tableName: this.datasetName, dataVersion: this.dataVersion, sumTitle: this.prepareSumTitle(), scenarios: this.prepareScenarios(), scenariosDataFormat: this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), runningSum: this.runningSum, varianceWaterfall: this.varianceWaterfall, thereof: this.prepareThereOf(), thereofPosition: this.prepareThereofPosition(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), attributeColumns: this.prepareAttributes(), type: this.prepareTableType(), categoryWidth: this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), i18nMode: this.prepareI18nMode(), measureScale: this.prepareMeasureScale(), measureType: this.prepareMeasureType(), measureUnit: this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), interval: this.prepareInterval(), categoryIntervalPosition: this.prepareCategoryIntervalPosition(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, scaleFactor: effectiveFactor, ruleSetConfig: this.ruleSetConfig(), selectedStyle: this.selectedStyle }))));
|
|
28139
28148
|
}
|
|
28140
28149
|
get element() { return getElement(this); }
|
|
28141
28150
|
static get watchers() { return {
|
|
@@ -28175,6 +28184,9 @@ const Table$1 = class Table {
|
|
|
28175
28184
|
"thereof": [{
|
|
28176
28185
|
"validateThereOf": 0
|
|
28177
28186
|
}],
|
|
28187
|
+
"thereofPosition": [{
|
|
28188
|
+
"validateThereofPosition": 0
|
|
28189
|
+
}],
|
|
28178
28190
|
"partof": [{
|
|
28179
28191
|
"validatePartOf": 0
|
|
28180
28192
|
}],
|
|
@@ -28256,7 +28268,16 @@ class Cell {
|
|
|
28256
28268
|
return result;
|
|
28257
28269
|
}
|
|
28258
28270
|
draw(dataFormatDigits, locale) {
|
|
28259
|
-
|
|
28271
|
+
return this.format(this.value, dataFormatDigits, locale);
|
|
28272
|
+
}
|
|
28273
|
+
/** True when the cell prints a number that is zero at the displayed digits. */
|
|
28274
|
+
roundsToZero(dataFormatDigits, locale) {
|
|
28275
|
+
return (typeof this.value === "number" &&
|
|
28276
|
+
!!this.type &&
|
|
28277
|
+
this.draw(dataFormatDigits, locale) === this.format(0, dataFormatDigits, locale));
|
|
28278
|
+
}
|
|
28279
|
+
format(value, dataFormatDigits, locale) {
|
|
28280
|
+
let cellValue = value;
|
|
28260
28281
|
if (cellValue === "undefined" || cellValue === undefined || cellValue == null) {
|
|
28261
28282
|
return "";
|
|
28262
28283
|
}
|
|
@@ -28461,24 +28482,27 @@ function labelMeasureContext() {
|
|
|
28461
28482
|
}
|
|
28462
28483
|
return measureContext;
|
|
28463
28484
|
}
|
|
28485
|
+
/** Bold digits of a font can be wider than the regular ones the glyph table lists. */
|
|
28486
|
+
const BOLD_WIDTH_MARGIN = 1.08;
|
|
28464
28487
|
/**
|
|
28465
28488
|
* Rendered width of a value label in px, measured with the font the SVG text uses. Falls
|
|
28466
28489
|
* back to estimateLabelWidth where no canvas can measure.
|
|
28467
28490
|
*/
|
|
28468
|
-
function labelWidth(text, fontSize, fontFamily, italic) {
|
|
28491
|
+
function labelWidth(text, fontSize, fontFamily, italic, bold = false) {
|
|
28492
|
+
const estimate = () => estimateLabelWidth(text, fontSize) * (bold ? BOLD_WIDTH_MARGIN : 1);
|
|
28469
28493
|
const ctx = labelMeasureContext();
|
|
28470
28494
|
if (ctx) {
|
|
28471
28495
|
// the canvas ignores a font it cannot parse and keeps the last one: the sentinel shows that
|
|
28472
28496
|
ctx.font = FONT_SENTINEL;
|
|
28473
28497
|
const sentinel = ctx.font;
|
|
28474
|
-
ctx.font = `${italic ? "italic " : ""}${fontSize}px ${fontFamily}`;
|
|
28498
|
+
ctx.font = `${italic ? "italic " : ""}${bold ? "bold " : ""}${fontSize}px ${fontFamily}`;
|
|
28475
28499
|
if (ctx.font === sentinel)
|
|
28476
|
-
return
|
|
28500
|
+
return estimate();
|
|
28477
28501
|
const width = ctx.measureText(text).width;
|
|
28478
28502
|
if (Number.isFinite(width) && (width > 0 || text === ""))
|
|
28479
28503
|
return width + MEASURE_PAD * fontSize;
|
|
28480
28504
|
}
|
|
28481
|
-
return
|
|
28505
|
+
return estimate();
|
|
28482
28506
|
}
|
|
28483
28507
|
/** The SVG fills the cell's content box: the requested column width minus the cell padding. */
|
|
28484
28508
|
function contentWidth(widthEm, emPx) {
|
|
@@ -28594,14 +28618,59 @@ function relativePinGeometry(widthEm, emPx, labels, headSize, reach) {
|
|
|
28594
28618
|
labelGap,
|
|
28595
28619
|
};
|
|
28596
28620
|
}
|
|
28597
|
-
|
|
28621
|
+
/**
|
|
28622
|
+
* Without `column` both sides get the fixed gutter. With it each side gets the room its
|
|
28623
|
+
* labels need beyond the bar area at the scale of the bars. The bar area keeps at least
|
|
28624
|
+
* half the width: only gutters that need more shrink, and a side that fits the fixed
|
|
28625
|
+
* gutter keeps its room then.
|
|
28626
|
+
*/
|
|
28627
|
+
function waterfallGeometry(widthEm, emPx, column) {
|
|
28598
28628
|
const totalWidth = contentWidth(widthEm, emPx);
|
|
28599
|
-
const
|
|
28629
|
+
const labelGap = LABEL_GAP_EM * emPx;
|
|
28630
|
+
const fixed = Math.min(BAR_LABEL_EM * emPx, totalWidth / 4);
|
|
28631
|
+
let left = fixed;
|
|
28632
|
+
let right = fixed;
|
|
28633
|
+
const range = column ? column.max - column.min : 0;
|
|
28634
|
+
if (column && range > 0) {
|
|
28635
|
+
// what the labels of one side stick out of the bar area at the given scale
|
|
28636
|
+
const room = (pointsLeft, pxPerUnit) => Math.max(0, ...column.labels
|
|
28637
|
+
.filter((label) => label.pointsLeft === pointsLeft)
|
|
28638
|
+
.map((label) => label.width + labelGap - (pointsLeft ? label.end - column.min : column.max - label.end) * pxPerUnit));
|
|
28639
|
+
left = room(true, 0);
|
|
28640
|
+
right = room(false, 0);
|
|
28641
|
+
const budget = totalWidth / 2;
|
|
28642
|
+
// a label needs less room the further its bar ends from the edge; a smaller gutter only widens the scale.
|
|
28643
|
+
// One pass is enough for gutters that fit; more passes only while they take more than half the width.
|
|
28644
|
+
for (let pass = 0; pass < 8; pass++) {
|
|
28645
|
+
const pxPerUnit = Math.max(0, totalWidth - left - right) / range;
|
|
28646
|
+
const nextLeft = Math.min(left, room(true, pxPerUnit));
|
|
28647
|
+
const nextRight = Math.min(right, room(false, pxPerUnit));
|
|
28648
|
+
const settled = nextLeft + nextRight <= budget || (nextLeft === left && nextRight === right);
|
|
28649
|
+
left = nextLeft;
|
|
28650
|
+
right = nextRight;
|
|
28651
|
+
if (settled)
|
|
28652
|
+
break;
|
|
28653
|
+
}
|
|
28654
|
+
if (left + right > budget) {
|
|
28655
|
+
if (Math.min(left, right) > fixed) {
|
|
28656
|
+
const shrink = budget / (left + right);
|
|
28657
|
+
left *= shrink;
|
|
28658
|
+
right *= shrink;
|
|
28659
|
+
}
|
|
28660
|
+
else if (left <= right) {
|
|
28661
|
+
right = budget - left;
|
|
28662
|
+
}
|
|
28663
|
+
else {
|
|
28664
|
+
left = budget - right;
|
|
28665
|
+
}
|
|
28666
|
+
}
|
|
28667
|
+
}
|
|
28600
28668
|
return {
|
|
28601
28669
|
totalWidth,
|
|
28602
|
-
|
|
28603
|
-
|
|
28604
|
-
|
|
28670
|
+
labelAreaLeft: left,
|
|
28671
|
+
labelAreaRight: right,
|
|
28672
|
+
barAreaWidth: totalWidth - left - right,
|
|
28673
|
+
labelGap,
|
|
28605
28674
|
};
|
|
28606
28675
|
}
|
|
28607
28676
|
|
|
@@ -28629,6 +28698,10 @@ const DEFAULT_STYLES = {
|
|
|
28629
28698
|
const AXIS_COLOR = "#666666";
|
|
28630
28699
|
/** Width of the pin line, in px before scaleFactor. */
|
|
28631
28700
|
const PIN_LINE_WIDTH = 3;
|
|
28701
|
+
/** Arrow head of a cut pin, in sides of the square pin head: IBCS draws it a bit larger. */
|
|
28702
|
+
const PIN_ARROW_RATIO = 1.2;
|
|
28703
|
+
/** Padding of the light band under the label on a cut pin, in label font sizes. */
|
|
28704
|
+
const PIN_BAND_PAD = 0.2;
|
|
28632
28705
|
/**
|
|
28633
28706
|
* Creates a unique pattern ID for the SVG defs
|
|
28634
28707
|
*/
|
|
@@ -28863,11 +28936,11 @@ function renderZigzagBreak(breakX, breakGap, yTop, barHeight, s) {
|
|
|
28863
28936
|
* exactly `columnWidthEm` em - see barColumnGeometry.ts.
|
|
28864
28937
|
*/
|
|
28865
28938
|
const AbsoluteVarianceBar = (props) => {
|
|
28866
|
-
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
|
|
28939
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, decimalDigits, columnWidthEm = 10, labelWidths, sideMax, bold, styles = DEFAULT_STYLES, } = props;
|
|
28867
28940
|
const s = styles.scaleFactor;
|
|
28868
28941
|
const fs = styles.fontSize;
|
|
28869
28942
|
const displayValue = formattedValue || formatValue(value, false, measureScale, locale, 0, true, decimalDigits);
|
|
28870
|
-
const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false));
|
|
28943
|
+
const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, labelWidth(displayValue, fs, styles.fontFamily, false, bold));
|
|
28871
28944
|
const isPositive = value > 0 || (value === 0 && zeroOnPositiveSide(sides));
|
|
28872
28945
|
const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
|
|
28873
28946
|
const geometry = absoluteBarGeometry(columnWidthEm, styles.emPx, sides, { neg, pos });
|
|
@@ -28920,7 +28993,8 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
28920
28993
|
* Renders a relative variance pin chart (dr_ prefix).
|
|
28921
28994
|
* Line from the axis in the sentiment colour, ending in a square head in the look of the
|
|
28922
28995
|
* minuend, with the value label beside the head like an absolute bar label. A pin beyond
|
|
28923
|
-
* the pin area is cut and ends in an arrow
|
|
28996
|
+
* the pin area is cut and ends in an arrow. Its label stands on the line behind the arrow
|
|
28997
|
+
* head, on a light band, or after the arrow tip when the line is too short for it.
|
|
28924
28998
|
*
|
|
28925
28999
|
* Layout: [left label area][pin area with axis][right label area], summing to exactly
|
|
28926
29000
|
* `columnWidthEm` em - see barColumnGeometry.ts.
|
|
@@ -28928,13 +29002,14 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
28928
29002
|
*/
|
|
28929
29003
|
const RelativeVariancePin = (props) => {
|
|
28930
29004
|
var _a, _b;
|
|
28931
|
-
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, percentDigits, percentSign, columnWidthEm = 10, labelWidths, sideMax, styles = DEFAULT_STYLES, } = props;
|
|
29005
|
+
const { value, scenario, columnStats, height, isPositiveGood, formattedValue, measureScale, locale, percentDigits, percentSign, columnWidthEm = 10, labelWidths, sideMax, bold, styles = DEFAULT_STYLES, } = props;
|
|
28932
29006
|
const s = styles.scaleFactor;
|
|
28933
29007
|
const fs = styles.fontSize;
|
|
28934
29008
|
const headSize = PIN_HEAD_SIZE * s;
|
|
28935
29009
|
const pinPx = 100 * styles.percentageScaling * fs;
|
|
28936
29010
|
const displayValue = formattedValue || formatValue(value, true, measureScale, locale, percentDigits, percentSign);
|
|
28937
|
-
const
|
|
29011
|
+
const ownWidth = labelWidth(displayValue, fs, styles.fontFamily, true, bold);
|
|
29012
|
+
const sides = labelWidths !== null && labelWidths !== void 0 ? labelWidths : ownLabelWidths(columnStats, ownWidth);
|
|
28938
29013
|
const { neg = Math.max(0, -columnStats.min), pos = Math.max(0, columnStats.max) } = sideMax !== null && sideMax !== void 0 ? sideMax : {};
|
|
28939
29014
|
const { totalWidth, negPinLength, posPinLength, axisX, labelGap } = relativePinGeometry(columnWidthEm, styles.emPx, sides, headSize, { neg: neg * pinPx, pos: pos * pinPx });
|
|
28940
29015
|
const centerY = height / 2;
|
|
@@ -28953,9 +29028,18 @@ const RelativeVariancePin = (props) => {
|
|
|
28953
29028
|
const headStyle = (_a = look === null || look === void 0 ? void 0 : look.minuend) !== null && _a !== void 0 ? _a : styles.scenarios.ac;
|
|
28954
29029
|
// the arrow tip lands on the outer edge of a full-length head, so the label after it stays in the cell
|
|
28955
29030
|
const tipX = axisX + direction * (maxPinLength + headSize / 2);
|
|
28956
|
-
const
|
|
28957
|
-
const
|
|
28958
|
-
|
|
29031
|
+
const arrowSize = PIN_ARROW_RATIO * headSize;
|
|
29032
|
+
const arrowBaseX = tipX - direction * arrowSize;
|
|
29033
|
+
// the band keeps a pad of full line to the arrow head and to the axis, else the label goes after the tip
|
|
29034
|
+
const bandPad = PIN_BAND_PAD * fs;
|
|
29035
|
+
const bandWidth = ownWidth + 2 * bandPad;
|
|
29036
|
+
const shaftLength = Math.abs(arrowBaseX - axisX) - (VARIANCE_AXIS_EM * styles.emPx) / 2;
|
|
29037
|
+
const labelOnShaft = isExtreme && shaftLength >= bandWidth + 2 * bandPad;
|
|
29038
|
+
const bandX = arrowBaseX - direction * (bandPad + bandWidth / 2) - bandWidth / 2;
|
|
29039
|
+
const labelX = labelOnShaft
|
|
29040
|
+
? bandX + bandWidth / 2
|
|
29041
|
+
: (isExtreme ? tipX : pinEndX + direction * (headSize / 2)) + direction * labelGap;
|
|
29042
|
+
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 - arrowSize / 2} ${arrowBaseX},${centerY + arrowSize / 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 })), labelOnShaft && (h("rect", { class: "pin-label-band", x: bandX, y: centerY - (PIN_LINE_WIDTH * s) / 2, width: bandWidth, height: PIN_LINE_WIDTH * s, fill: "#ffffff", "fill-opacity": "0.5" })), h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": labelOnShaft ? "middle" : isPositive ? "start" : "end", fill: styles.fontColor, "font-size": fs, "font-style": "italic", "font-family": styles.fontFamily }, displayValue)));
|
|
28959
29043
|
};
|
|
28960
29044
|
/**
|
|
28961
29045
|
* CellBarChart - Renders IBCS-compliant variance bar charts.
|
|
@@ -28977,6 +29061,14 @@ const CellBarChart = (props) => {
|
|
|
28977
29061
|
return h(AbsoluteVarianceBar, Object.assign({}, props));
|
|
28978
29062
|
};
|
|
28979
29063
|
|
|
29064
|
+
/**
|
|
29065
|
+
* Label text of a waterfall bar. Scenario values carry no variance sentiment: unsigned per
|
|
29066
|
+
* IBCS. A variance keeps its sign (`signed`).
|
|
29067
|
+
*/
|
|
29068
|
+
function waterfallLabelText(value, kind, measureScale, locale, decimalDigits, signed = false) {
|
|
29069
|
+
const text = formatValue(value, kind === "partof", measureScale, locale, 0, true, decimalDigits);
|
|
29070
|
+
return signed ? text : text.replace(/^\+/, "");
|
|
29071
|
+
}
|
|
28980
29072
|
/**
|
|
28981
29073
|
* Renders one row of an IBCS waterfall for a scenario bar column.
|
|
28982
29074
|
*
|
|
@@ -28989,19 +29081,27 @@ const CellBarChart = (props) => {
|
|
|
28989
29081
|
* Layout: [left label area][bar area][right label area]
|
|
28990
29082
|
* The value label sits at the bar's free end (right of rightward bars,
|
|
28991
29083
|
* left of leftward bars). thereof/partof rows additionally get dashed
|
|
28992
|
-
* guides marking their parent bar's extent.
|
|
29084
|
+
* guides marking their parent bar's extent. A guide or axis line that would
|
|
29085
|
+
* run through the label is left out in that row.
|
|
29086
|
+
*
|
|
29087
|
+
* An absolute variance column is drawn as a variance waterfall: the bar in the color of
|
|
29088
|
+
* the sentiment and the pattern of the minuend, the axis in the look of the reference
|
|
29089
|
+
* scenario in every row, a signed label, and thin connectors to the rows above and below
|
|
29090
|
+
* in place of the dashed guides. The axis and the connectors join the rows, so where one
|
|
29091
|
+
* meets the label it is only interrupted over the height of the text.
|
|
28993
29092
|
*/
|
|
28994
29093
|
const WaterfallBar = (props) => {
|
|
28995
|
-
|
|
29094
|
+
var _a;
|
|
29095
|
+
const { value, scenario, height, isPositiveGood, measureScale, locale, decimalDigits, columnWidthEm = 10, styles = DEFAULT_STYLES, waterfall, geometry, bold, connectorReach = { top: 0, bottom: 0 }, } = props;
|
|
28996
29096
|
const s = styles.scaleFactor;
|
|
28997
29097
|
const fs = styles.fontSize;
|
|
28998
29098
|
const range = waterfall.max - waterfall.min;
|
|
28999
29099
|
if (value === null || value === undefined || isNaN(value) || range <= 0) {
|
|
29000
29100
|
return (h("span", { class: "bar-chart-empty", style: { color: styles.fontColor, fontStyle: "italic" } }, "-"));
|
|
29001
29101
|
}
|
|
29002
|
-
const { totalWidth,
|
|
29102
|
+
const { totalWidth, labelAreaLeft, barAreaWidth, labelGap } = geometry !== null && geometry !== void 0 ? geometry : waterfallGeometry(columnWidthEm, styles.emPx);
|
|
29003
29103
|
const pxPerUnit = barAreaWidth / range;
|
|
29004
|
-
const xOf = (coordinate) =>
|
|
29104
|
+
const xOf = (coordinate) => labelAreaLeft + (coordinate - waterfall.min) * pxPerUnit;
|
|
29005
29105
|
const padding = 2 * s;
|
|
29006
29106
|
const barHeight = height - padding * 2;
|
|
29007
29107
|
const barY = padding;
|
|
@@ -29010,15 +29110,37 @@ const WaterfallBar = (props) => {
|
|
|
29010
29110
|
const endX = xOf(waterfall.end);
|
|
29011
29111
|
const barX = Math.min(startX, endX);
|
|
29012
29112
|
const barWidth = Math.abs(endX - startX);
|
|
29013
|
-
|
|
29014
|
-
const
|
|
29015
|
-
const
|
|
29016
|
-
|
|
29017
|
-
const
|
|
29113
|
+
// null for a scenario column, which ignores the sentiment
|
|
29114
|
+
const look = getVarianceLook(scenario, styles);
|
|
29115
|
+
const sentimentStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
29116
|
+
const minuendPattern = look === null || look === void 0 ? void 0 : look.minuend.fillpattern;
|
|
29117
|
+
const barStyle = minuendPattern === "hatched" || minuendPattern === "outlined"
|
|
29118
|
+
? Object.assign(Object.assign({}, sentimentStyle), { fillpattern: minuendPattern }) : sentimentStyle;
|
|
29119
|
+
const patternPrefix = look ? (sentimentStyle === styles.positive ? "pos" : "neg") : getScenarioType(scenario);
|
|
29120
|
+
const fillValue = getBarFill(barStyle, patternPrefix);
|
|
29121
|
+
const { stroke: barStroke, strokeWidth: barStrokeWidth } = look && barStyle.fillpattern === "hatched" ? { stroke: barStyle.stroke, strokeWidth: 1 } : getBarStroke(barStyle);
|
|
29122
|
+
const displayValue = waterfallLabelText(value, waterfall.kind, measureScale, locale, decimalDigits, look !== null);
|
|
29018
29123
|
const pointsLeft = endX < startX;
|
|
29019
29124
|
const labelX = pointsLeft ? barX - labelGap : barX + barWidth + labelGap;
|
|
29020
29125
|
const labelAnchor = pointsLeft ? "end" : "start";
|
|
29021
|
-
|
|
29126
|
+
// a line through the label makes it unreadable, so the row drops it
|
|
29127
|
+
const labelSize = labelWidth(displayValue, fs, styles.fontFamily, false, bold);
|
|
29128
|
+
const labelPad = labelGap / 2;
|
|
29129
|
+
const labelFrom = (pointsLeft ? labelX - labelSize : labelX) - labelPad;
|
|
29130
|
+
const labelTo = (pointsLeft ? labelX : labelX + labelSize) + labelPad;
|
|
29131
|
+
const meetsLabel = (x) => x > labelFrom && x < labelTo;
|
|
29132
|
+
const parentEndX = waterfall.parentEnd !== undefined ? xOf(waterfall.parentEnd) : undefined;
|
|
29133
|
+
// the parts of a vertical line of a variance waterfall that stay clear of the label text
|
|
29134
|
+
const labelTop = height / 2 - fs / 2;
|
|
29135
|
+
const labelBottom = height / 2 + fs / 2;
|
|
29136
|
+
const clearOfLabel = (x, y1, y2, halfWidth = 0) => x + halfWidth > labelFrom && x - halfWidth < labelTo
|
|
29137
|
+
? [[y1, Math.min(y2, labelTop)], [Math.max(y1, labelBottom), y2]].filter(([from, to]) => to > from)
|
|
29138
|
+
: [[y1, y2]];
|
|
29139
|
+
const axisTop = -connectorReach.top;
|
|
29140
|
+
const axisBottom = height + connectorReach.bottom;
|
|
29141
|
+
return (h("svg", { width: totalWidth, height: height, class: `cell-bar-chart waterfall-bar${look ? " variance-waterfall" : ""}`, style: { overflow: "visible" } }, h(PatternDefs, { styles: styles }), !look && !meetsLabel(axisX) && (h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s })), waterfall.parentStart !== undefined && waterfall.parentEnd !== undefined && (h("line", { x1: xOf(waterfall.parentStart), y1: 0, x2: xOf(waterfall.parentStart), y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s, "stroke-dasharray": `${2 * s},${2 * s}` })), waterfall.parentStart !== undefined && parentEndX !== undefined && !meetsLabel(parentEndX) && (h("line", { x1: parentEndX, y1: 0, x2: parentEndX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s, "stroke-dasharray": `${2 * s},${2 * s}` })), (_a = waterfall.connectors) === null || _a === void 0 ? void 0 :
|
|
29142
|
+
_a.map(({ at, part }) => clearOfLabel(xOf(at), part === "bottom" ? barY + barHeight : axisTop, part === "top" ? barY : axisBottom).map(([y1, y2]) => (h("line", { class: "waterfall-connector", x1: xOf(at), y1: y1, x2: xOf(at), y2: y2, stroke: AXIS_COLOR, "stroke-width": 1 * s })))), barWidth > 0 && (h("rect", { x: barX, y: barY, width: barWidth, height: barHeight, fill: fillValue, stroke: barStroke, "stroke-width": barStrokeWidth * s })), look &&
|
|
29143
|
+
clearOfLabel(axisX, axisTop, axisBottom, (VARIANCE_AXIS_EM * styles.emPx) / 2).map(([y1, y2]) => (h("g", { transform: `translate(0,${y1})` }, h(VarianceAxis, { x: axisX, height: y2 - y1, 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)));
|
|
29022
29144
|
};
|
|
29023
29145
|
|
|
29024
29146
|
/** '', null and a missing rowGroup are one group. */
|
|
@@ -29036,7 +29158,7 @@ const BLANK_SAFE_ROWGROUP = `IFNULL(${QueryColumnNames.ROWGROUP}, '')`;
|
|
|
29036
29158
|
class QueryGroups {
|
|
29037
29159
|
constructor(config) {
|
|
29038
29160
|
this.groups = [QueryColumnNames.CATEGORY, QueryColumnNames.CATEGORYINDEX];
|
|
29039
|
-
if (TableType.OPT === config.type || TableType.OPTNOTOTAL === config.type) {
|
|
29161
|
+
if (TableType$2.OPT === config.type || TableType$2.OPTNOTOTAL === config.type) {
|
|
29040
29162
|
this.groups.unshift(QueryColumnNames.OPERATION);
|
|
29041
29163
|
}
|
|
29042
29164
|
if (config.grouped) {
|
|
@@ -29060,155 +29182,444 @@ class QueryGroups {
|
|
|
29060
29182
|
}
|
|
29061
29183
|
}
|
|
29062
29184
|
|
|
29185
|
+
function sameCoordinate(a, b) {
|
|
29186
|
+
return Math.abs(a - b) <= 1e-9 * Math.max(1, Math.abs(a), Math.abs(b));
|
|
29187
|
+
}
|
|
29063
29188
|
/**
|
|
29064
|
-
*
|
|
29065
|
-
*
|
|
29066
|
-
*
|
|
29067
|
-
* against in-memory data rows. The pipeline handles scenario aggregation, row/column
|
|
29068
|
-
* grouping, drill-down expansion (thereof / partof), REST rows, sum rows, NaN detection,
|
|
29069
|
-
* column-level drill columns, and relative variance calculation.
|
|
29189
|
+
* Sets the connectors of a variance walk in print order. A null unit is a printed row
|
|
29190
|
+
* without a bar. Two rows are joined only where the walk goes on: a group that restarts
|
|
29191
|
+
* at zero gets no line from the sum row above it.
|
|
29070
29192
|
*/
|
|
29071
|
-
|
|
29072
|
-
|
|
29073
|
-
this.hasPartOf = false;
|
|
29074
|
-
/** Values bound as AlaSQL parameters ($0, $1, ...): row values and free-text config never become SQL text. */
|
|
29075
|
-
this.params = [];
|
|
29076
|
-
/** Select fragment (leading comma) of the sort keys for variance and bucketed order tokens. */
|
|
29077
|
-
this.sortSelect = "";
|
|
29078
|
-
/** Set by execute: the grouped table has rows with a blank rowGroup (null, '' or missing). */
|
|
29079
|
-
this.hasBlankRowGroup = false;
|
|
29080
|
-
this.config = config;
|
|
29081
|
-
this.i18n = i18n;
|
|
29082
|
-
}
|
|
29083
|
-
/**
|
|
29084
|
-
* Executes the full query pipeline and returns a segmented result set.
|
|
29085
|
-
*
|
|
29086
|
-
* Pipeline steps:
|
|
29087
|
-
* 1. Translate scenario columns into SQL aggregation expressions
|
|
29088
|
-
* 2. Run a meta query to discover row groups and their category counts
|
|
29089
|
-
* 3. For each group: generate header row, data rows, REST overflow row, and group sum row
|
|
29090
|
-
* 4. Append a total sum row (if table type requires it)
|
|
29091
|
-
* 5. Execute all accumulated SQL statements against the input data
|
|
29092
|
-
* 6. Detect NaN cells (aggregated cells with zero contributing rows)
|
|
29093
|
-
* 7. Inject thereof/partof drill rows and column-level drill columns
|
|
29094
|
-
* 8. Calculate REST columns (parent minus drilled children)
|
|
29095
|
-
* 9. Divide absolute variances by their denominator to produce relative variances
|
|
29096
|
-
*
|
|
29097
|
-
* @param db - The shared alasql database.
|
|
29098
|
-
* @param fromExpr - SQL FROM-clause expression naming the source table or filtered view.
|
|
29099
|
-
* @returns Array of row-group segments; each segment is an array of result rows.
|
|
29100
|
-
*/
|
|
29101
|
-
execute(db, fromExpr) {
|
|
29193
|
+
function connectWalk(units, thereofAbove) {
|
|
29194
|
+
const add = (bar, at, part) => {
|
|
29102
29195
|
var _a;
|
|
29103
|
-
|
|
29104
|
-
|
|
29105
|
-
|
|
29106
|
-
|
|
29107
|
-
|
|
29108
|
-
|
|
29109
|
-
|
|
29110
|
-
|
|
29111
|
-
|
|
29112
|
-
|
|
29113
|
-
|
|
29114
|
-
|
|
29115
|
-
.map((s) => this.translateScenarioSQL(s, false, this.config.type))
|
|
29116
|
-
.toString();
|
|
29117
|
-
const scenariosSUMQuery = this.config.scenarios
|
|
29118
|
-
.map((s) => this.translateScenarioSQL(s, true, this.config.type))
|
|
29119
|
-
.toString();
|
|
29120
|
-
const relativeScenarios = this.getRelativeScenarios();
|
|
29121
|
-
const attributesSQL = this.config.attributes.map((attribute) => this.translateAttributeSQL(attribute)).toString();
|
|
29122
|
-
const groups = new QueryGroups(this.config);
|
|
29123
|
-
// a bucket only applies under interval setname, else the token sorts like its bare column
|
|
29124
|
-
const sortOrder = this.config.interval === INTERVAL_SETNAME
|
|
29125
|
-
? this.config.sortOrder
|
|
29126
|
-
: {
|
|
29127
|
-
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; }),
|
|
29128
|
-
direction: this.config.sortOrder.direction,
|
|
29129
|
-
};
|
|
29130
|
-
let order = ["", ""];
|
|
29131
|
-
if (sortOrder.hierarchy.length > 0) {
|
|
29132
|
-
order = this.createOrderString(sortOrder);
|
|
29196
|
+
bar.connectors = [...((_a = bar.connectors) !== null && _a !== void 0 ? _a : []), { at, part }];
|
|
29197
|
+
};
|
|
29198
|
+
const link = (from, between, to, at) => {
|
|
29199
|
+
add(from, at, "bottom");
|
|
29200
|
+
between.forEach((bar) => add(bar, at, "through"));
|
|
29201
|
+
add(to, at, "top");
|
|
29202
|
+
};
|
|
29203
|
+
let previous = null;
|
|
29204
|
+
for (const unit of units) {
|
|
29205
|
+
if (unit === null) {
|
|
29206
|
+
previous = null;
|
|
29207
|
+
continue;
|
|
29133
29208
|
}
|
|
29134
|
-
|
|
29135
|
-
|
|
29136
|
-
|
|
29137
|
-
|
|
29138
|
-
|
|
29139
|
-
const groupOrderColumns = hierarchy.filter((column) => column === QueryColumnNames.ROWGROUP ||
|
|
29140
|
-
column === QueryColumnNames.ROWGROUPINDEX ||
|
|
29141
|
-
column.toUpperCase() in Scenarios);
|
|
29142
|
-
const groupSums = groupOrderColumns
|
|
29143
|
-
.filter((column) => column.toUpperCase() in Scenarios)
|
|
29144
|
-
.map((column) => `, SUM(${column} * transformOperator(operation)) as ${column}`)
|
|
29145
|
-
.join("");
|
|
29146
|
-
const groupOrder = groupOrderColumns.length > 0
|
|
29147
|
-
? groupOrderColumns.map((column) => `${column} ${direction}`).toString()
|
|
29148
|
-
: `${QueryColumnNames.ROWGROUPINDEX} asc`;
|
|
29149
|
-
const meta = db.exec(`SELECT COUNT(DISTINCT ${QueryColumnNames.CATEGORY}) as ${QueryColumnNames.TOTALROWCOUNT} ${this.config.grouped ? `, ${BLANK_SAFE_ROWGROUP} as ${QueryColumnNames.ROWGROUP}, FIRST(${QueryColumnNames.ROWGROUPINDEX}) as ${QueryColumnNames.ROWGROUPINDEX}${groupSums}` : ""}
|
|
29150
|
-
FROM ${fromExpr} ${this.config.grouped ? `GROUP BY ${BLANK_SAFE_ROWGROUP} ORDER BY ${groupOrder}` : ""}`);
|
|
29151
|
-
if (meta.length === 0 ||
|
|
29152
|
-
(meta.length === 1 && ((_a = meta[0][QueryColumnNames.TOTALROWCOUNT]) !== null && _a !== void 0 ? _a : 0) === 0 && !this.config.grouped)) {
|
|
29153
|
-
return [];
|
|
29209
|
+
const { main, children } = unit;
|
|
29210
|
+
const entry = main.kind === "anchor" ? main.end : main.start;
|
|
29211
|
+
if (previous && !unit.gapAbove && sameCoordinate(previous.main.end, entry)) {
|
|
29212
|
+
// the line runs beside the thereof rows printed between the two rows
|
|
29213
|
+
link(previous.main, thereofAbove ? children : previous.children, main, entry);
|
|
29154
29214
|
}
|
|
29155
|
-
|
|
29156
|
-
|
|
29157
|
-
|
|
29158
|
-
|
|
29159
|
-
|
|
29160
|
-
|
|
29161
|
-
|
|
29162
|
-
|
|
29163
|
-
|
|
29164
|
-
|
|
29165
|
-
|
|
29166
|
-
|
|
29167
|
-
|
|
29168
|
-
queryLimitSection = `LIMIT ${this.config.limit}`;
|
|
29215
|
+
if (!unit.gapAbove && !unit.gapBelow) {
|
|
29216
|
+
children.forEach((child, index) => {
|
|
29217
|
+
if (index > 0)
|
|
29218
|
+
link(children[index - 1], [], child, child.start);
|
|
29219
|
+
});
|
|
29220
|
+
if (children.length > 0) {
|
|
29221
|
+
const last = children[children.length - 1];
|
|
29222
|
+
if (!thereofAbove) {
|
|
29223
|
+
link(main, [], children[0], main.start);
|
|
29224
|
+
}
|
|
29225
|
+
else if (sameCoordinate(last.end, main.end)) {
|
|
29226
|
+
link(last, [], main, main.end);
|
|
29227
|
+
}
|
|
29169
29228
|
}
|
|
29170
|
-
|
|
29171
|
-
|
|
29172
|
-
this.createRestRow(rowGroupEntry, queries, groups, scenarios, queryWhereSection, order);
|
|
29173
|
-
this.createGroupSumRow(queries, sumGroupQueries, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order);
|
|
29174
|
-
});
|
|
29175
|
-
this.createTotalSumRow(queries, sumGroupQueries, scenariosSUMQuery);
|
|
29176
|
-
// executes main queries
|
|
29177
|
-
queries.forEach((query) => res.push(this.exec(query)));
|
|
29178
|
-
this.detectNaNCells(this.config.scenarios, res);
|
|
29179
|
-
this.createThereOfDrillRows(scenarios, attributesSQL, order, res);
|
|
29180
|
-
this.createPartOfDrillRows(scenarios, order, sumGroupQueries, res);
|
|
29181
|
-
this.createIntervalColumns(res);
|
|
29182
|
-
this.createThereOfDrillColumns(this.config.categoryThereOf, res);
|
|
29183
|
-
this.calculateColumnGroupRest(res, this.config.categoryThereOf);
|
|
29184
|
-
this.calculateRelativeVariances(res, relativeScenarios);
|
|
29185
|
-
return res;
|
|
29229
|
+
}
|
|
29230
|
+
previous = unit.gapBelow ? null : unit;
|
|
29186
29231
|
}
|
|
29187
|
-
|
|
29188
|
-
|
|
29189
|
-
|
|
29190
|
-
|
|
29191
|
-
|
|
29192
|
-
|
|
29193
|
-
|
|
29194
|
-
|
|
29195
|
-
|
|
29196
|
-
|
|
29197
|
-
|
|
29198
|
-
|
|
29199
|
-
|
|
29200
|
-
|
|
29201
|
-
|
|
29202
|
-
|
|
29203
|
-
|
|
29204
|
-
|
|
29205
|
-
|
|
29206
|
-
|
|
29207
|
-
|
|
29208
|
-
|
|
29209
|
-
|
|
29210
|
-
|
|
29211
|
-
|
|
29232
|
+
}
|
|
29233
|
+
/**
|
|
29234
|
+
* Waterfall geometry per raw result row and column, keyed by row identity
|
|
29235
|
+
* (the factory iterates the same row objects the calculator walked).
|
|
29236
|
+
*/
|
|
29237
|
+
class WaterfallResult {
|
|
29238
|
+
constructor() {
|
|
29239
|
+
this.geometry = new Map();
|
|
29240
|
+
this.columns = new Set();
|
|
29241
|
+
}
|
|
29242
|
+
set(row, column, data) {
|
|
29243
|
+
let columns = this.geometry.get(row);
|
|
29244
|
+
if (!columns) {
|
|
29245
|
+
columns = new Map();
|
|
29246
|
+
this.geometry.set(row, columns);
|
|
29247
|
+
}
|
|
29248
|
+
columns.set(column, data);
|
|
29249
|
+
this.columns.add(column);
|
|
29250
|
+
}
|
|
29251
|
+
get(row, column) {
|
|
29252
|
+
var _a;
|
|
29253
|
+
return (_a = this.geometry.get(row)) === null || _a === void 0 ? void 0 : _a.get(column);
|
|
29254
|
+
}
|
|
29255
|
+
/** True when the column has waterfall bars, also for a row of it that got none. */
|
|
29256
|
+
has(column) {
|
|
29257
|
+
return this.columns.has(column);
|
|
29258
|
+
}
|
|
29259
|
+
}
|
|
29260
|
+
/** True when the result contains grouping structure (sum, subtotal, or drill rows). */
|
|
29261
|
+
function hasGroupingStructure(queryData) {
|
|
29262
|
+
for (const groupData of queryData) {
|
|
29263
|
+
for (const row of groupData) {
|
|
29264
|
+
const type = row[QueryColumnNames.TYPE];
|
|
29265
|
+
if (type === TableRowType.SUM ||
|
|
29266
|
+
type === TableRowType.GROUPSUM ||
|
|
29267
|
+
type === TableRowType.DRILLELEMENT ||
|
|
29268
|
+
type === TableRowType.PARTELEMENT) {
|
|
29269
|
+
return true;
|
|
29270
|
+
}
|
|
29271
|
+
}
|
|
29272
|
+
}
|
|
29273
|
+
return false;
|
|
29274
|
+
}
|
|
29275
|
+
/**
|
|
29276
|
+
* Alias of the signed sum of a bar column on the generated REST row of an OPT table. The
|
|
29277
|
+
* row prints the unsigned sum of the rows it folds, the walk needs the signed one.
|
|
29278
|
+
*/
|
|
29279
|
+
function restSignedAlias(column) {
|
|
29280
|
+
return `${column}__signed`;
|
|
29281
|
+
}
|
|
29282
|
+
/** Sign of an OPT entry row; the generated REST row has `restOperation` in place of `operation`. */
|
|
29283
|
+
function operationSign(row) {
|
|
29284
|
+
var _a;
|
|
29285
|
+
return ((_a = row[QueryColumnNames.OPERATION]) !== null && _a !== void 0 ? _a : row.restOperation) === "-" ? -1 : 1;
|
|
29286
|
+
}
|
|
29287
|
+
/**
|
|
29288
|
+
* Signed waterfall contribution of a row for one column.
|
|
29289
|
+
*
|
|
29290
|
+
* Non-OPT table types aggregate `SUM(scn * transformOperator(operation))`, so ENTRY
|
|
29291
|
+
* values arrive already signed. OPT types aggregate plain `SUM(scn)` with the sign
|
|
29292
|
+
* carried in the visible operation column, so the sign is applied here. A REST row that
|
|
29293
|
+
* folds "+" and "-" rows has no single sign, it brings its signed sum. Sum rows are
|
|
29294
|
+
* fully signed in both modes.
|
|
29295
|
+
*/
|
|
29296
|
+
function signedValue(row, column, tableType) {
|
|
29297
|
+
const raw = row[column];
|
|
29298
|
+
if (raw === null || raw === undefined) {
|
|
29299
|
+
return null;
|
|
29300
|
+
}
|
|
29301
|
+
const value = Number(raw);
|
|
29302
|
+
if (isNaN(value)) {
|
|
29303
|
+
return null;
|
|
29304
|
+
}
|
|
29305
|
+
const isOpt = tableType === TableType$2.OPT || tableType === TableType$2.OPTNOTOTAL;
|
|
29306
|
+
if (isOpt && row[QueryColumnNames.TYPE] === TableRowType.ENTRY) {
|
|
29307
|
+
const signed = row[restSignedAlias(column)];
|
|
29308
|
+
return typeof signed === "number" ? signed : operationSign(row) * value;
|
|
29309
|
+
}
|
|
29310
|
+
return value;
|
|
29311
|
+
}
|
|
29312
|
+
/**
|
|
29313
|
+
* Computes waterfall bar geometry for the given scenario columns by walking the
|
|
29314
|
+
* segmented query result once per column in display order.
|
|
29315
|
+
*
|
|
29316
|
+
* - ENTRY rows (incl. REST) cascade from the running total by their signed value.
|
|
29317
|
+
* The REST row of an OPT table takes the sign of `restOperation`, or its signed sum.
|
|
29318
|
+
* - SUM / GROUP_SUM rows anchor at zero. A SUM row resets the running total to its
|
|
29319
|
+
* value, a GROUP_SUM row resets it to zero.
|
|
29320
|
+
* - DRILLELEMENT (thereof) rows form a sub-cascade from their parent bar's start in
|
|
29321
|
+
* the parent's direction; the running total is untouched.
|
|
29322
|
+
* - PARTELEMENT (partof) rows cascade a `share * parent width` segment the same way.
|
|
29323
|
+
* Note: the share denominator is the group sum (or SUM_TOTAL when ungrouped) per
|
|
29324
|
+
* `createPartOfDrillRows`, not literally the parent row's value.
|
|
29325
|
+
* - GROUPHEAD rows get no bar and restart the running total at zero: every row group
|
|
29326
|
+
* is its own cascade that ends at its GROUP_SUM.
|
|
29327
|
+
* - With `runningSum` a GROUP_SUM row holds the result of all groups so far, so the
|
|
29328
|
+
* cascade goes on from its value and no GROUPHEAD restarts it.
|
|
29329
|
+
* - NaN rows get no bar; a NaN parent orphans its drill children.
|
|
29330
|
+
*
|
|
29331
|
+
* An absolute variance column walks the same way with three differences: a thereof row
|
|
29332
|
+
* steps by its signed value times the operation sign of its parent, so its siblings can
|
|
29333
|
+
* go both ways and leave the parent bar; a partof row gets no bar; and the bars carry
|
|
29334
|
+
* connectors to the rows printed above and below.
|
|
29335
|
+
*
|
|
29336
|
+
* @param queryData - Segmented result rows from DataQuery.execute().
|
|
29337
|
+
* @param columns - Plain scenario (ac1..pl4) or absolute variance column keys; no `##` composite keys.
|
|
29338
|
+
* @param tableType - Table aggregation mode, needed for OPT sign handling.
|
|
29339
|
+
* @param runningSum - True when the GROUP_SUM rows are running results.
|
|
29340
|
+
* @param thereofAbove - True when thereof rows are printed above their parent; only the connectors depend on it.
|
|
29341
|
+
*/
|
|
29342
|
+
function computeWaterfall(queryData, columns, tableType, runningSum = false, thereofAbove = false) {
|
|
29343
|
+
const result = new WaterfallResult();
|
|
29344
|
+
const isOpt = tableType === TableType$2.OPT || tableType === TableType$2.OPTNOTOTAL;
|
|
29345
|
+
for (const column of columns) {
|
|
29346
|
+
const variance = new VarianceScenario(column).isValid;
|
|
29347
|
+
let running = 0;
|
|
29348
|
+
let lastParent;
|
|
29349
|
+
let subCursor = 0;
|
|
29350
|
+
const emitted = [];
|
|
29351
|
+
const units = [];
|
|
29352
|
+
let unit = null;
|
|
29353
|
+
const emit = (row, data) => {
|
|
29354
|
+
emitted.push(data);
|
|
29355
|
+
result.set(row, column, data);
|
|
29356
|
+
return data;
|
|
29357
|
+
};
|
|
29358
|
+
const startUnit = (main) => {
|
|
29359
|
+
unit = main && { main, children: [], gapAbove: false, gapBelow: false };
|
|
29360
|
+
units.push(unit);
|
|
29361
|
+
};
|
|
29362
|
+
for (const groupData of queryData) {
|
|
29363
|
+
for (const row of groupData) {
|
|
29364
|
+
const type = row[QueryColumnNames.TYPE];
|
|
29365
|
+
if (type === TableRowType.GROUPHEAD) {
|
|
29366
|
+
// a group sum only totals its own rows, so the cascade must not carry over
|
|
29367
|
+
if (!runningSum) {
|
|
29368
|
+
running = 0;
|
|
29369
|
+
}
|
|
29370
|
+
lastParent = undefined;
|
|
29371
|
+
startUnit(null);
|
|
29372
|
+
continue;
|
|
29373
|
+
}
|
|
29374
|
+
const value = signedValue(row, column, tableType);
|
|
29375
|
+
if (type === TableRowType.ENTRY) {
|
|
29376
|
+
if (value === null) {
|
|
29377
|
+
lastParent = undefined;
|
|
29378
|
+
startUnit(null);
|
|
29379
|
+
continue;
|
|
29380
|
+
}
|
|
29381
|
+
startUnit(emit(row, { start: running, end: running + value, min: 0, max: 0, kind: "cascade" }));
|
|
29382
|
+
// thereof values of an OPT table are unsigned like the entries, so they take the sign of the parent
|
|
29383
|
+
const sign = isOpt ? operationSign(row) : 1;
|
|
29384
|
+
lastParent = { start: running, end: running + value, sign };
|
|
29385
|
+
subCursor = lastParent.start;
|
|
29386
|
+
running += value;
|
|
29387
|
+
}
|
|
29388
|
+
else if (type === TableRowType.SUM || type === TableRowType.GROUPSUM) {
|
|
29389
|
+
if (value === null) {
|
|
29390
|
+
lastParent = undefined;
|
|
29391
|
+
startUnit(null);
|
|
29392
|
+
continue;
|
|
29393
|
+
}
|
|
29394
|
+
startUnit(emit(row, { start: 0, end: value, min: 0, max: 0, kind: "anchor" }));
|
|
29395
|
+
lastParent = { start: 0, end: value, sign: 1 };
|
|
29396
|
+
subCursor = 0;
|
|
29397
|
+
// a group sum closes its group (there may be no GROUPHEAD row when the title is hidden)
|
|
29398
|
+
running = type === TableRowType.GROUPSUM && !runningSum ? 0 : value;
|
|
29399
|
+
}
|
|
29400
|
+
else if (variance && (type === TableRowType.DRILLELEMENT || type === TableRowType.PARTELEMENT)) {
|
|
29401
|
+
if (type === TableRowType.DRILLELEMENT && value !== null && lastParent !== undefined && unit) {
|
|
29402
|
+
const end = subCursor + lastParent.sign * value;
|
|
29403
|
+
unit.children.push(emit(row, { start: subCursor, end, min: 0, max: 0, kind: "thereof" }));
|
|
29404
|
+
subCursor = end;
|
|
29405
|
+
}
|
|
29406
|
+
else if (unit) {
|
|
29407
|
+
// only thereof rows move above the parent
|
|
29408
|
+
if (thereofAbove && type === TableRowType.DRILLELEMENT)
|
|
29409
|
+
unit.gapAbove = true;
|
|
29410
|
+
else
|
|
29411
|
+
unit.gapBelow = true;
|
|
29412
|
+
}
|
|
29413
|
+
}
|
|
29414
|
+
else if (type === TableRowType.DRILLELEMENT) {
|
|
29415
|
+
if (value === null || lastParent === undefined) {
|
|
29416
|
+
continue;
|
|
29417
|
+
}
|
|
29418
|
+
const direction = Math.sign(lastParent.end - lastParent.start) || 1;
|
|
29419
|
+
const end = subCursor + direction * Math.abs(value);
|
|
29420
|
+
emit(row, {
|
|
29421
|
+
start: subCursor,
|
|
29422
|
+
end,
|
|
29423
|
+
min: 0,
|
|
29424
|
+
max: 0,
|
|
29425
|
+
kind: "thereof",
|
|
29426
|
+
parentStart: lastParent.start,
|
|
29427
|
+
parentEnd: lastParent.end,
|
|
29428
|
+
});
|
|
29429
|
+
subCursor = end;
|
|
29430
|
+
}
|
|
29431
|
+
else if (type === TableRowType.PARTELEMENT) {
|
|
29432
|
+
if (value === null || lastParent === undefined) {
|
|
29433
|
+
continue;
|
|
29434
|
+
}
|
|
29435
|
+
const end = subCursor + value * (lastParent.end - lastParent.start);
|
|
29436
|
+
emit(row, {
|
|
29437
|
+
start: subCursor,
|
|
29438
|
+
end,
|
|
29439
|
+
min: 0,
|
|
29440
|
+
max: 0,
|
|
29441
|
+
kind: "partof",
|
|
29442
|
+
parentStart: lastParent.start,
|
|
29443
|
+
parentEnd: lastParent.end,
|
|
29444
|
+
});
|
|
29445
|
+
subCursor = end;
|
|
29446
|
+
}
|
|
29447
|
+
}
|
|
29448
|
+
}
|
|
29449
|
+
if (variance) {
|
|
29450
|
+
connectWalk(units, thereofAbove);
|
|
29451
|
+
}
|
|
29452
|
+
// All rows of a column share one coordinate system including zero
|
|
29453
|
+
let min = 0;
|
|
29454
|
+
let max = 0;
|
|
29455
|
+
for (const data of emitted) {
|
|
29456
|
+
min = Math.min(min, data.start, data.end);
|
|
29457
|
+
max = Math.max(max, data.start, data.end);
|
|
29458
|
+
}
|
|
29459
|
+
for (const data of emitted) {
|
|
29460
|
+
data.min = min;
|
|
29461
|
+
data.max = max;
|
|
29462
|
+
}
|
|
29463
|
+
}
|
|
29464
|
+
return result;
|
|
29465
|
+
}
|
|
29466
|
+
|
|
29467
|
+
/** Adds a group sum to a running result; it stays missing as long as no group had a value. */
|
|
29468
|
+
function addGroupSum(running, value) {
|
|
29469
|
+
return running == null && value == null ? value : (running !== null && running !== void 0 ? running : 0) + (value !== null && value !== void 0 ? value : 0);
|
|
29470
|
+
}
|
|
29471
|
+
/**
|
|
29472
|
+
* AlaSQL-based query builder that produces the complete table result set for bn-table.
|
|
29473
|
+
*
|
|
29474
|
+
* Translates a {@link TableComponentConfig} into a series of SQL statements executed
|
|
29475
|
+
* against in-memory data rows. The pipeline handles scenario aggregation, row/column
|
|
29476
|
+
* grouping, drill-down expansion (thereof / partof), REST rows, sum rows, NaN detection,
|
|
29477
|
+
* column-level drill columns, and relative variance calculation.
|
|
29478
|
+
*/
|
|
29479
|
+
class DataQuery {
|
|
29480
|
+
constructor(config, i18n) {
|
|
29481
|
+
this.hasPartOf = false;
|
|
29482
|
+
/** Values bound as AlaSQL parameters ($0, $1, ...): row values and free-text config never become SQL text. */
|
|
29483
|
+
this.params = [];
|
|
29484
|
+
/** Select fragment (leading comma) of the sort keys for variance and bucketed order tokens. */
|
|
29485
|
+
this.sortSelect = "";
|
|
29486
|
+
/** Set by execute: the grouped table has rows with a blank rowGroup (null, '' or missing). */
|
|
29487
|
+
this.hasBlankRowGroup = false;
|
|
29488
|
+
this.config = config;
|
|
29489
|
+
this.i18n = i18n;
|
|
29490
|
+
}
|
|
29491
|
+
/**
|
|
29492
|
+
* Executes the full query pipeline and returns a segmented result set.
|
|
29493
|
+
*
|
|
29494
|
+
* Pipeline steps:
|
|
29495
|
+
* 1. Translate scenario columns into SQL aggregation expressions
|
|
29496
|
+
* 2. Run a meta query to discover row groups and their category counts
|
|
29497
|
+
* 3. For each group: generate header row, data rows, REST overflow row, and group sum row
|
|
29498
|
+
* 4. Append a total sum row (if table type requires it)
|
|
29499
|
+
* 5. Execute all accumulated SQL statements against the input data
|
|
29500
|
+
* 6. Detect NaN cells (aggregated cells with zero contributing rows)
|
|
29501
|
+
* 7. Inject thereof/partof drill rows and column-level drill columns
|
|
29502
|
+
* 8. Calculate REST columns (parent minus drilled children)
|
|
29503
|
+
* 9. Divide absolute variances by their denominator to produce relative variances
|
|
29504
|
+
*
|
|
29505
|
+
* @param db - The shared alasql database.
|
|
29506
|
+
* @param fromExpr - SQL FROM-clause expression naming the source table or filtered view.
|
|
29507
|
+
* @returns Array of row-group segments; each segment is an array of result rows.
|
|
29508
|
+
*/
|
|
29509
|
+
execute(db, fromExpr) {
|
|
29510
|
+
var _a;
|
|
29511
|
+
this.db = db;
|
|
29512
|
+
this.fromExpr = fromExpr;
|
|
29513
|
+
// these names are written into the SQL text as column names
|
|
29514
|
+
for (const name of [...this.config.scenarios, ...this.config.categoryThereOf.keys()]) {
|
|
29515
|
+
if (!FIELD_IDENTIFIER_REGEX.test(name)) {
|
|
29516
|
+
throw new Error(`invalid identifier "${name}"`);
|
|
29517
|
+
}
|
|
29518
|
+
}
|
|
29519
|
+
const queries = [];
|
|
29520
|
+
const sumGroupQueries = [];
|
|
29521
|
+
const res = [];
|
|
29522
|
+
const scenarios = this.config.scenarios
|
|
29523
|
+
.map((s) => this.translateScenarioSQL(s, false, this.config.type))
|
|
29524
|
+
.toString();
|
|
29525
|
+
const scenariosSUMQuery = this.config.scenarios
|
|
29526
|
+
.map((s) => this.translateScenarioSQL(s, true, this.config.type))
|
|
29527
|
+
.toString();
|
|
29528
|
+
const relativeScenarios = this.getRelativeScenarios();
|
|
29529
|
+
const attributesSQL = this.config.attributes.map((attribute) => this.translateAttributeSQL(attribute)).toString();
|
|
29530
|
+
const groups = new QueryGroups(this.config);
|
|
29531
|
+
// a bucket only applies under interval setname, else the token sorts like its bare column
|
|
29532
|
+
const sortOrder = this.config.interval === INTERVAL_SETNAME
|
|
29533
|
+
? this.config.sortOrder
|
|
29534
|
+
: {
|
|
29535
|
+
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; }),
|
|
29536
|
+
direction: this.config.sortOrder.direction,
|
|
29537
|
+
};
|
|
29538
|
+
let order = ["", ""];
|
|
29539
|
+
if (sortOrder.hierarchy.length > 0) {
|
|
29540
|
+
order = this.createOrderString(sortOrder);
|
|
29541
|
+
}
|
|
29542
|
+
this.hasPartOf = this.checkConfigForPartOf();
|
|
29543
|
+
// meta defines groups and the number detail rows in each group
|
|
29544
|
+
// Bsp: 0: Object { totalrowcnt: 7, rowgroup: "Umsatz" }
|
|
29545
|
+
// groups follow the order entries that exist per group (rowGroup, rowGroupIndex, scenario sum), else rowGroupIndex
|
|
29546
|
+
const { hierarchy, direction } = sortOrder;
|
|
29547
|
+
const groupOrderColumns = hierarchy.filter((column) => column === QueryColumnNames.ROWGROUP ||
|
|
29548
|
+
column === QueryColumnNames.ROWGROUPINDEX ||
|
|
29549
|
+
column.toUpperCase() in Scenarios);
|
|
29550
|
+
const groupSums = groupOrderColumns
|
|
29551
|
+
.filter((column) => column.toUpperCase() in Scenarios)
|
|
29552
|
+
.map((column) => `, SUM(${column} * transformOperator(operation)) as ${column}`)
|
|
29553
|
+
.join("");
|
|
29554
|
+
const groupOrder = groupOrderColumns.length > 0
|
|
29555
|
+
? groupOrderColumns.map((column) => `${column} ${direction}`).toString()
|
|
29556
|
+
: `${QueryColumnNames.ROWGROUPINDEX} asc`;
|
|
29557
|
+
const meta = db.exec(`SELECT COUNT(DISTINCT ${QueryColumnNames.CATEGORY}) as ${QueryColumnNames.TOTALROWCOUNT} ${this.config.grouped ? `, ${BLANK_SAFE_ROWGROUP} as ${QueryColumnNames.ROWGROUP}, FIRST(${QueryColumnNames.ROWGROUPINDEX}) as ${QueryColumnNames.ROWGROUPINDEX}${groupSums}` : ""}
|
|
29558
|
+
FROM ${fromExpr} ${this.config.grouped ? `GROUP BY ${BLANK_SAFE_ROWGROUP} ORDER BY ${groupOrder}` : ""}`);
|
|
29559
|
+
if (meta.length === 0 ||
|
|
29560
|
+
(meta.length === 1 && ((_a = meta[0][QueryColumnNames.TOTALROWCOUNT]) !== null && _a !== void 0 ? _a : 0) === 0 && !this.config.grouped)) {
|
|
29561
|
+
return [];
|
|
29562
|
+
}
|
|
29563
|
+
this.hasBlankRowGroup = this.config.grouped && meta.some((row) => row.rowGroup === "");
|
|
29564
|
+
// Creates DataSelection for LIST
|
|
29565
|
+
meta.forEach((rowGroupEntry) => {
|
|
29566
|
+
// the following variables are 'helper sections' which are used to constuct dynamicly the sql statement depending of the given config
|
|
29567
|
+
// is grouping active?
|
|
29568
|
+
const queryWhereSection = !this.config.grouped
|
|
29569
|
+
? ``
|
|
29570
|
+
: rowGroupEntry.rowGroup === ""
|
|
29571
|
+
? `WHERE (${QueryColumnNames.ROWGROUP} IS NULL OR ${QueryColumnNames.ROWGROUP} = '')`
|
|
29572
|
+
: `WHERE ${QueryColumnNames.ROWGROUP} = ${this.bind(rowGroupEntry.rowGroup)}`;
|
|
29573
|
+
// is limit active?
|
|
29574
|
+
let queryLimitSection = "";
|
|
29575
|
+
if (this.config.limit) {
|
|
29576
|
+
queryLimitSection = `LIMIT ${this.config.limit}`;
|
|
29577
|
+
}
|
|
29578
|
+
this.createGroupHeaderRow(rowGroupEntry, queries);
|
|
29579
|
+
this.createDataRow(queries, rowGroupEntry, groups, scenarios, attributesSQL, queryWhereSection, order, queryLimitSection);
|
|
29580
|
+
this.createRestRow(rowGroupEntry, queries, groups, scenarios, queryWhereSection, order);
|
|
29581
|
+
this.createGroupSumRow(queries, sumGroupQueries, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order);
|
|
29582
|
+
});
|
|
29583
|
+
this.createTotalSumRow(queries, sumGroupQueries, scenariosSUMQuery);
|
|
29584
|
+
// executes main queries
|
|
29585
|
+
queries.forEach((query) => res.push(this.exec(query)));
|
|
29586
|
+
if (this.hasRunningSum()) {
|
|
29587
|
+
this.accumulateGroupSums(res, [...new Set(this.exctractScenarioNames(scenariosSUMQuery))]);
|
|
29588
|
+
}
|
|
29589
|
+
this.detectNaNCells(this.config.scenarios, res);
|
|
29590
|
+
this.createThereOfDrillRows(scenarios, attributesSQL, order, res);
|
|
29591
|
+
this.createPartOfDrillRows(scenarios, order, sumGroupQueries, res);
|
|
29592
|
+
this.createIntervalColumns(res);
|
|
29593
|
+
this.createThereOfDrillColumns(this.config.categoryThereOf, res);
|
|
29594
|
+
this.calculateColumnGroupRest(res, this.config.categoryThereOf);
|
|
29595
|
+
this.calculateRelativeVariances(res, relativeScenarios);
|
|
29596
|
+
return res;
|
|
29597
|
+
}
|
|
29598
|
+
/**
|
|
29599
|
+
* Marks aggregated cells as NaN when no source rows contributed to the sum.
|
|
29600
|
+
*
|
|
29601
|
+
* Without this step, SUM() over zero matching rows would produce 0, which is
|
|
29602
|
+
* misleading -- it would be indistinguishable from an actual zero value.
|
|
29603
|
+
* Each scenario column has a companion `_cnt` counter; when that counter is 0
|
|
29604
|
+
* the cell is overwritten with NaN. For variance scenarios, both base and delta
|
|
29605
|
+
* counters must be non-zero.
|
|
29606
|
+
*/
|
|
29607
|
+
detectNaNCells(scenarios, res) {
|
|
29608
|
+
res.forEach((group) => {
|
|
29609
|
+
group.map((row) => {
|
|
29610
|
+
scenarios.forEach((scenario) => {
|
|
29611
|
+
const varianceScenario = new VarianceScenario(scenario);
|
|
29612
|
+
if (varianceScenario.isValid === true) {
|
|
29613
|
+
if (row[varianceScenario.base + "_cnt"] === 0 || row[varianceScenario.delta + "_cnt"] === 0) {
|
|
29614
|
+
row[scenario] = Number.NaN;
|
|
29615
|
+
}
|
|
29616
|
+
}
|
|
29617
|
+
else {
|
|
29618
|
+
if (row[scenario + "_cnt"] === 0) {
|
|
29619
|
+
row[scenario] = Number.NaN;
|
|
29620
|
+
}
|
|
29621
|
+
}
|
|
29622
|
+
});
|
|
29212
29623
|
return row;
|
|
29213
29624
|
});
|
|
29214
29625
|
});
|
|
@@ -29219,7 +29630,7 @@ class DataQuery {
|
|
|
29219
29630
|
* value by the corresponding group sum to produce a percentage.
|
|
29220
29631
|
*/
|
|
29221
29632
|
createPartOfDrillRows(scenarios, order, sumGroupQueries, res) {
|
|
29222
|
-
if (this.config.partOf == null || this.config.partOf.length === 0 || this.config.type === TableType.LIST) {
|
|
29633
|
+
if (this.config.partOf == null || this.config.partOf.length === 0 || this.config.type === TableType$2.LIST) {
|
|
29223
29634
|
return;
|
|
29224
29635
|
}
|
|
29225
29636
|
const drillQueries = this.createPartOfQuery(scenarios, order);
|
|
@@ -29265,8 +29676,13 @@ class DataQuery {
|
|
|
29265
29676
|
.map((name) => `SUM(${name}) as ${name}`)
|
|
29266
29677
|
.join(", ");
|
|
29267
29678
|
// a REST row of only "-" rows counts as "-" for the op sentiment; not named operation, so it stays hidden
|
|
29268
|
-
|
|
29269
|
-
|
|
29679
|
+
// the row prints the unsigned sum; the walk of a waterfall needs the signed sum of its bar columns
|
|
29680
|
+
const restSigned = this.exctractScenarioNames(scenarios)
|
|
29681
|
+
.filter((name) => { var _a; return (_a = this.config.barColumns) === null || _a === void 0 ? void 0 : _a.includes(name); })
|
|
29682
|
+
.map((name) => `, SUM(${name} * transformOperator(operation)) as ${restSignedAlias(name)}`)
|
|
29683
|
+
.join("");
|
|
29684
|
+
const restOperation = TableType$2.OPT === this.config.type || TableType$2.OPTNOTOTAL === this.config.type
|
|
29685
|
+
? `, CASE WHEN MAX(transformOperator(operation)) = -1 THEN '-' ELSE '+' END as restOperation${restSigned}`
|
|
29270
29686
|
: "";
|
|
29271
29687
|
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` +
|
|
29272
29688
|
` (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]})` +
|
|
@@ -29303,10 +29719,38 @@ class DataQuery {
|
|
|
29303
29719
|
}
|
|
29304
29720
|
}
|
|
29305
29721
|
hasGroupSum() {
|
|
29306
|
-
return (TableType.SUM === this.config.type ||
|
|
29307
|
-
TableType.SUMNOTOTAL === this.config.type ||
|
|
29308
|
-
TableType.OPT === this.config.type ||
|
|
29309
|
-
TableType.OPTNOTOTAL === this.config.type);
|
|
29722
|
+
return (TableType$2.SUM === this.config.type ||
|
|
29723
|
+
TableType$2.SUMNOTOTAL === this.config.type ||
|
|
29724
|
+
TableType$2.OPT === this.config.type ||
|
|
29725
|
+
TableType$2.OPTNOTOTAL === this.config.type);
|
|
29726
|
+
}
|
|
29727
|
+
/**
|
|
29728
|
+
* True when the group sum rows are running results: only a grouped table with group sum
|
|
29729
|
+
* rows has them. Column drill values of the group sum rows are not accumulated, so
|
|
29730
|
+
* `runningSum` is off with columnthereof.
|
|
29731
|
+
*/
|
|
29732
|
+
hasRunningSum() {
|
|
29733
|
+
return (this.config.runningSum && this.config.grouped && this.hasGroupSum() && this.config.categoryThereOf.size === 0);
|
|
29734
|
+
}
|
|
29735
|
+
/**
|
|
29736
|
+
* Turns the GROUP_SUM rows into running results: each one gets the raw aliases of all
|
|
29737
|
+
* group sums before it added (scenarios, `_cnt`, variances and `dr_*` denominators).
|
|
29738
|
+
* Runs before the NaN step and the relative variance division, where all of them are sums.
|
|
29739
|
+
* A missing value stays missing until a group brings a real one.
|
|
29740
|
+
*/
|
|
29741
|
+
accumulateGroupSums(res, aliases) {
|
|
29742
|
+
const running = {};
|
|
29743
|
+
for (const segment of res) {
|
|
29744
|
+
for (const row of segment) {
|
|
29745
|
+
if (row[QueryColumnNames.TYPE] !== "GROUP_SUM") {
|
|
29746
|
+
continue;
|
|
29747
|
+
}
|
|
29748
|
+
for (const alias of aliases) {
|
|
29749
|
+
running[alias] = addGroupSum(running[alias], row[alias]);
|
|
29750
|
+
row[alias] = running[alias];
|
|
29751
|
+
}
|
|
29752
|
+
}
|
|
29753
|
+
}
|
|
29310
29754
|
}
|
|
29311
29755
|
/** Generates a GROUP_SUM row that aggregates all entries within a single row group. */
|
|
29312
29756
|
createGroupSumRow(querys, groupSumQuery, rowGroupEntry, scenariosSUMQuery, queryWhereSection, order) {
|
|
@@ -29332,7 +29776,7 @@ class DataQuery {
|
|
|
29332
29776
|
/** Generates a total SUM row across all groups (only for SUM / OPT table types). */
|
|
29333
29777
|
createTotalSumRow(querys, sumGroupQueries, scenariosSUMQuery) {
|
|
29334
29778
|
var _a;
|
|
29335
|
-
if (TableType.SUM === this.config.type || TableType.OPT === this.config.type) {
|
|
29779
|
+
if (TableType$2.SUM === this.config.type || TableType$2.OPT === this.config.type) {
|
|
29336
29780
|
// An empty label falls back to the SUM_TOTAL key, which tableDataSetFactory
|
|
29337
29781
|
// resolves to the IBCS total symbol (❖).
|
|
29338
29782
|
const label = ((_a = this.config.title) === null || _a === void 0 ? void 0 : _a.trim()) || "SUM_TOTAL";
|
|
@@ -29584,13 +30028,13 @@ class DataQuery {
|
|
|
29584
30028
|
const entryAliases = [...new Set(this.exctractScenarioNames(scenarios))];
|
|
29585
30029
|
const relativeScenarios = this.getRelativeScenarios();
|
|
29586
30030
|
const groups = new QueryGroups(this.config);
|
|
29587
|
-
const isOpt = TableType.OPT === this.config.type || TableType.OPTNOTOTAL === this.config.type;
|
|
30031
|
+
const isOpt = TableType$2.OPT === this.config.type || TableType$2.OPTNOTOTAL === this.config.type;
|
|
29588
30032
|
const isSumTypeGrouped = this.config.grouped &&
|
|
29589
|
-
(TableType.SUM === this.config.type ||
|
|
29590
|
-
TableType.SUMNOTOTAL === this.config.type ||
|
|
29591
|
-
TableType.OPT === this.config.type ||
|
|
29592
|
-
TableType.OPTNOTOTAL === this.config.type);
|
|
29593
|
-
const hasPartOfActive = this.checkConfigForPartOf() && this.config.type !== TableType.LIST;
|
|
30033
|
+
(TableType$2.SUM === this.config.type ||
|
|
30034
|
+
TableType$2.SUMNOTOTAL === this.config.type ||
|
|
30035
|
+
TableType$2.OPT === this.config.type ||
|
|
30036
|
+
TableType$2.OPTNOTOTAL === this.config.type);
|
|
30037
|
+
const hasPartOfActive = this.checkConfigForPartOf() && this.config.type !== TableType$2.LIST;
|
|
29594
30038
|
const exec = (query) => this.exec(query);
|
|
29595
30039
|
// mirrors detectNaNCells + calculateRelativeVariances for a single bucket row
|
|
29596
30040
|
const finalizeBucketRow = (row) => {
|
|
@@ -29689,7 +30133,27 @@ class DataQuery {
|
|
|
29689
30133
|
: [];
|
|
29690
30134
|
const groupTotalsByKey = new Map();
|
|
29691
30135
|
groupTotalRowsRaw.forEach((row) => groupTotalsByKey.set(`${row.rowGroup}${separator}${coerceBucketKey(row.__interval)}`, row));
|
|
29692
|
-
if (isSumTypeGrouped) {
|
|
30136
|
+
if (isSumTypeGrouped && this.hasRunningSum()) {
|
|
30137
|
+
// per bucket, each group sum row gets the totals of all groups up to its own
|
|
30138
|
+
const sumAliases = [...new Set(this.exctractScenarioNames(scenariosSUMQuery))];
|
|
30139
|
+
const groupSumRows = res.flat().filter((row) => row.type === "GROUP_SUM");
|
|
30140
|
+
for (const bucketKey of new Set(groupTotalRowsRaw.map((row) => coerceBucketKey(row.__interval)))) {
|
|
30141
|
+
let running;
|
|
30142
|
+
for (const row of groupSumRows) {
|
|
30143
|
+
const totalRow = groupTotalsByKey.get(`${row.rowGroup}${separator}${bucketKey}`);
|
|
30144
|
+
if (totalRow) {
|
|
30145
|
+
running !== null && running !== void 0 ? running : (running = {});
|
|
30146
|
+
for (const alias of sumAliases) {
|
|
30147
|
+
running[alias] = addGroupSum(running[alias], totalRow[alias]);
|
|
30148
|
+
}
|
|
30149
|
+
}
|
|
30150
|
+
if (running) {
|
|
30151
|
+
writeBucketValues(row, finalizeBucketRow(Object.assign({}, running)), bucketKey);
|
|
30152
|
+
}
|
|
30153
|
+
}
|
|
30154
|
+
}
|
|
30155
|
+
}
|
|
30156
|
+
else if (isSumTypeGrouped) {
|
|
29693
30157
|
for (const totalRow of groupTotalRowsRaw) {
|
|
29694
30158
|
const bucketKey = coerceBucketKey(totalRow.__interval);
|
|
29695
30159
|
const finalized = finalizeBucketRow(Object.assign({}, totalRow));
|
|
@@ -29702,7 +30166,7 @@ class DataQuery {
|
|
|
29702
30166
|
}
|
|
29703
30167
|
}
|
|
29704
30168
|
}
|
|
29705
|
-
const hasTotalSumRow = TableType.SUM === this.config.type || TableType.OPT === this.config.type;
|
|
30169
|
+
const hasTotalSumRow = TableType$2.SUM === this.config.type || TableType$2.OPT === this.config.type;
|
|
29706
30170
|
const sumTotalRowsRaw = hasTotalSumRow || (hasPartOfActive && !this.config.grouped)
|
|
29707
30171
|
? exec(`SELECT __interval ${scenariosSUMQuery.length > 0 ? ",".concat(scenariosSUMQuery) : ""}
|
|
29708
30172
|
FROM ${bucketSource}
|
|
@@ -29842,7 +30306,7 @@ class DataQuery {
|
|
|
29842
30306
|
*/
|
|
29843
30307
|
translateScenarioSQL(scenario, isSumRow, type) {
|
|
29844
30308
|
const scenarios = new VarianceScenario(scenario);
|
|
29845
|
-
if (TableType.OPT === type || TableType.OPTNOTOTAL === type) {
|
|
30309
|
+
if (TableType$2.OPT === type || TableType$2.OPTNOTOTAL === type) {
|
|
29846
30310
|
if (scenarios.isValid) {
|
|
29847
30311
|
// sum rows show signed scenario values, so their variances must be signed too
|
|
29848
30312
|
const sign = isSumRow ? " * transformOperator(operation)" : "";
|
|
@@ -29882,7 +30346,7 @@ class DataQuery {
|
|
|
29882
30346
|
translateAttributeSQL(attribute) {
|
|
29883
30347
|
const field = `[${attribute.arg}]`;
|
|
29884
30348
|
const isScenarioField = /^(ac|pp|fc|pl)[1-4]$/.test(attribute.arg);
|
|
29885
|
-
const useOperator = isScenarioField && this.config.type !== TableType.OPT && this.config.type !== TableType.OPTNOTOTAL;
|
|
30349
|
+
const useOperator = isScenarioField && this.config.type !== TableType$2.OPT && this.config.type !== TableType$2.OPTNOTOTAL;
|
|
29886
30350
|
switch (attribute.fn) {
|
|
29887
30351
|
case "set":
|
|
29888
30352
|
return `SETAGG(${field}) as ${attribute.alias}`;
|
|
@@ -29933,7 +30397,7 @@ class DataQuery {
|
|
|
29933
30397
|
* @param orderComponent
|
|
29934
30398
|
*/
|
|
29935
30399
|
createOrderString(orderComponent) {
|
|
29936
|
-
const inverse = OrderDirection.ASC === orderComponent.direction ? OrderDirection.DESC : OrderDirection.ASC;
|
|
30400
|
+
const inverse = OrderDirection$1.ASC === orderComponent.direction ? OrderDirection$1.DESC : OrderDirection$1.ASC;
|
|
29937
30401
|
const sortKeys = new Map();
|
|
29938
30402
|
orderComponent.hierarchy.forEach((column, i) => {
|
|
29939
30403
|
const token = parseOrderToken(column);
|
|
@@ -29964,7 +30428,7 @@ class DataQuery {
|
|
|
29964
30428
|
* `__sortnull<i>` is 1 when the cell has no value: no data, or a relative variance with a zero reference.
|
|
29965
30429
|
*/
|
|
29966
30430
|
translateSortKeySQL(token, bucket, i) {
|
|
29967
|
-
const isOpt = TableType.OPT === this.config.type || TableType.OPTNOTOTAL === this.config.type;
|
|
30431
|
+
const isOpt = TableType$2.OPT === this.config.type || TableType$2.OPTNOTOTAL === this.config.type;
|
|
29968
30432
|
const sign = isOpt ? "" : " * transformOperator(operation)";
|
|
29969
30433
|
const inBucket = bucket === undefined ? "" : `TRIM(CAST(${intervalBucketSQL(INTERVAL_SETNAME)} AS STRING)) = ${this.bind(bucket)}`;
|
|
29970
30434
|
const value = (x) => `SUM(${inBucket ? `(CASE WHEN ${inBucket} THEN ${x} ELSE 0 END)` : x}${sign})`;
|
|
@@ -30235,177 +30699,6 @@ class DataQuery {
|
|
|
30235
30699
|
}
|
|
30236
30700
|
}
|
|
30237
30701
|
|
|
30238
|
-
/**
|
|
30239
|
-
* Waterfall geometry per raw result row and column, keyed by row identity
|
|
30240
|
-
* (the factory iterates the same row objects the calculator walked).
|
|
30241
|
-
*/
|
|
30242
|
-
class WaterfallResult {
|
|
30243
|
-
constructor() {
|
|
30244
|
-
this.geometry = new Map();
|
|
30245
|
-
}
|
|
30246
|
-
set(row, column, data) {
|
|
30247
|
-
let columns = this.geometry.get(row);
|
|
30248
|
-
if (!columns) {
|
|
30249
|
-
columns = new Map();
|
|
30250
|
-
this.geometry.set(row, columns);
|
|
30251
|
-
}
|
|
30252
|
-
columns.set(column, data);
|
|
30253
|
-
}
|
|
30254
|
-
get(row, column) {
|
|
30255
|
-
var _a;
|
|
30256
|
-
return (_a = this.geometry.get(row)) === null || _a === void 0 ? void 0 : _a.get(column);
|
|
30257
|
-
}
|
|
30258
|
-
}
|
|
30259
|
-
/** True when the result contains grouping structure (sum, subtotal, or drill rows). */
|
|
30260
|
-
function hasGroupingStructure(queryData) {
|
|
30261
|
-
for (const groupData of queryData) {
|
|
30262
|
-
for (const row of groupData) {
|
|
30263
|
-
const type = row[QueryColumnNames.TYPE];
|
|
30264
|
-
if (type === TableRowType.SUM ||
|
|
30265
|
-
type === TableRowType.GROUPSUM ||
|
|
30266
|
-
type === TableRowType.DRILLELEMENT ||
|
|
30267
|
-
type === TableRowType.PARTELEMENT) {
|
|
30268
|
-
return true;
|
|
30269
|
-
}
|
|
30270
|
-
}
|
|
30271
|
-
}
|
|
30272
|
-
return false;
|
|
30273
|
-
}
|
|
30274
|
-
/**
|
|
30275
|
-
* Signed waterfall contribution of a row for one column.
|
|
30276
|
-
*
|
|
30277
|
-
* Non-OPT table types aggregate `SUM(scn * transformOperator(operation))`, so ENTRY
|
|
30278
|
-
* values arrive already signed. OPT types aggregate plain `SUM(scn)` with the sign
|
|
30279
|
-
* carried in the visible operation column, so the sign is applied here. Sum rows are
|
|
30280
|
-
* fully signed in both modes.
|
|
30281
|
-
*/
|
|
30282
|
-
function signedValue(row, column, tableType) {
|
|
30283
|
-
const raw = row[column];
|
|
30284
|
-
if (raw === null || raw === undefined) {
|
|
30285
|
-
return null;
|
|
30286
|
-
}
|
|
30287
|
-
const value = Number(raw);
|
|
30288
|
-
if (isNaN(value)) {
|
|
30289
|
-
return null;
|
|
30290
|
-
}
|
|
30291
|
-
const isOpt = tableType === TableType.OPT || tableType === TableType.OPTNOTOTAL;
|
|
30292
|
-
if (isOpt && row[QueryColumnNames.TYPE] === TableRowType.ENTRY && row[QueryColumnNames.OPERATION] === "-") {
|
|
30293
|
-
return -value;
|
|
30294
|
-
}
|
|
30295
|
-
return value;
|
|
30296
|
-
}
|
|
30297
|
-
/**
|
|
30298
|
-
* Computes waterfall bar geometry for the given scenario columns by walking the
|
|
30299
|
-
* segmented query result once per column in display order.
|
|
30300
|
-
*
|
|
30301
|
-
* - ENTRY rows (incl. REST) cascade from the running total by their signed value.
|
|
30302
|
-
* - SUM / GROUP_SUM rows anchor at zero. A SUM row resets the running total to its
|
|
30303
|
-
* value, a GROUP_SUM row resets it to zero.
|
|
30304
|
-
* - DRILLELEMENT (thereof) rows form a sub-cascade from their parent bar's start in
|
|
30305
|
-
* the parent's direction; the running total is untouched.
|
|
30306
|
-
* - PARTELEMENT (partof) rows cascade a `share * parent width` segment the same way.
|
|
30307
|
-
* Note: the share denominator is the group sum (or SUM_TOTAL when ungrouped) per
|
|
30308
|
-
* `createPartOfDrillRows`, not literally the parent row's value.
|
|
30309
|
-
* - GROUPHEAD rows get no bar and restart the running total at zero: every row group
|
|
30310
|
-
* is its own cascade that ends at its GROUP_SUM.
|
|
30311
|
-
* - NaN rows get no bar; a NaN parent orphans its drill children.
|
|
30312
|
-
*
|
|
30313
|
-
* @param queryData - Segmented result rows from DataQuery.execute().
|
|
30314
|
-
* @param columns - Plain scenario column keys (ac1..pl4); no `##` composite keys.
|
|
30315
|
-
* @param tableType - Table aggregation mode, needed for OPT sign handling.
|
|
30316
|
-
*/
|
|
30317
|
-
function computeWaterfall(queryData, columns, tableType) {
|
|
30318
|
-
const result = new WaterfallResult();
|
|
30319
|
-
for (const column of columns) {
|
|
30320
|
-
let running = 0;
|
|
30321
|
-
let lastParent;
|
|
30322
|
-
let subCursor = 0;
|
|
30323
|
-
const emitted = [];
|
|
30324
|
-
const emit = (row, data) => {
|
|
30325
|
-
emitted.push(data);
|
|
30326
|
-
result.set(row, column, data);
|
|
30327
|
-
};
|
|
30328
|
-
for (const groupData of queryData) {
|
|
30329
|
-
for (const row of groupData) {
|
|
30330
|
-
const type = row[QueryColumnNames.TYPE];
|
|
30331
|
-
if (type === TableRowType.GROUPHEAD) {
|
|
30332
|
-
// a group sum only totals its own rows, so the cascade must not carry over
|
|
30333
|
-
running = 0;
|
|
30334
|
-
lastParent = undefined;
|
|
30335
|
-
continue;
|
|
30336
|
-
}
|
|
30337
|
-
const value = signedValue(row, column, tableType);
|
|
30338
|
-
if (type === TableRowType.ENTRY) {
|
|
30339
|
-
if (value === null) {
|
|
30340
|
-
lastParent = undefined;
|
|
30341
|
-
continue;
|
|
30342
|
-
}
|
|
30343
|
-
emit(row, { start: running, end: running + value, min: 0, max: 0, kind: "cascade" });
|
|
30344
|
-
lastParent = { start: running, end: running + value };
|
|
30345
|
-
subCursor = lastParent.start;
|
|
30346
|
-
running += value;
|
|
30347
|
-
}
|
|
30348
|
-
else if (type === TableRowType.SUM || type === TableRowType.GROUPSUM) {
|
|
30349
|
-
if (value === null) {
|
|
30350
|
-
lastParent = undefined;
|
|
30351
|
-
continue;
|
|
30352
|
-
}
|
|
30353
|
-
emit(row, { start: 0, end: value, min: 0, max: 0, kind: "anchor" });
|
|
30354
|
-
lastParent = { start: 0, end: value };
|
|
30355
|
-
subCursor = 0;
|
|
30356
|
-
// a group sum closes its group (there may be no GROUPHEAD row when the title is hidden)
|
|
30357
|
-
running = type === TableRowType.GROUPSUM ? 0 : value;
|
|
30358
|
-
}
|
|
30359
|
-
else if (type === TableRowType.DRILLELEMENT) {
|
|
30360
|
-
if (value === null || lastParent === undefined) {
|
|
30361
|
-
continue;
|
|
30362
|
-
}
|
|
30363
|
-
const direction = Math.sign(lastParent.end - lastParent.start) || 1;
|
|
30364
|
-
const end = subCursor + direction * Math.abs(value);
|
|
30365
|
-
emit(row, {
|
|
30366
|
-
start: subCursor,
|
|
30367
|
-
end,
|
|
30368
|
-
min: 0,
|
|
30369
|
-
max: 0,
|
|
30370
|
-
kind: "thereof",
|
|
30371
|
-
parentStart: lastParent.start,
|
|
30372
|
-
parentEnd: lastParent.end,
|
|
30373
|
-
});
|
|
30374
|
-
subCursor = end;
|
|
30375
|
-
}
|
|
30376
|
-
else if (type === TableRowType.PARTELEMENT) {
|
|
30377
|
-
if (value === null || lastParent === undefined) {
|
|
30378
|
-
continue;
|
|
30379
|
-
}
|
|
30380
|
-
const end = subCursor + value * (lastParent.end - lastParent.start);
|
|
30381
|
-
emit(row, {
|
|
30382
|
-
start: subCursor,
|
|
30383
|
-
end,
|
|
30384
|
-
min: 0,
|
|
30385
|
-
max: 0,
|
|
30386
|
-
kind: "partof",
|
|
30387
|
-
parentStart: lastParent.start,
|
|
30388
|
-
parentEnd: lastParent.end,
|
|
30389
|
-
});
|
|
30390
|
-
subCursor = end;
|
|
30391
|
-
}
|
|
30392
|
-
}
|
|
30393
|
-
}
|
|
30394
|
-
// All rows of a column share one coordinate system including zero
|
|
30395
|
-
let min = 0;
|
|
30396
|
-
let max = 0;
|
|
30397
|
-
for (const data of emitted) {
|
|
30398
|
-
min = Math.min(min, data.start, data.end);
|
|
30399
|
-
max = Math.max(max, data.start, data.end);
|
|
30400
|
-
}
|
|
30401
|
-
for (const data of emitted) {
|
|
30402
|
-
data.min = min;
|
|
30403
|
-
data.max = max;
|
|
30404
|
-
}
|
|
30405
|
-
}
|
|
30406
|
-
return result;
|
|
30407
|
-
}
|
|
30408
|
-
|
|
30409
30702
|
/**
|
|
30410
30703
|
* Transforms raw query results into structured TableRow collections for header and body.
|
|
30411
30704
|
*
|
|
@@ -30525,7 +30818,7 @@ class TableDataSetFactory {
|
|
|
30525
30818
|
order: undefined,
|
|
30526
30819
|
},
|
|
30527
30820
|
];
|
|
30528
|
-
if (TableType.OPT === type || TableType.OPTNOTOTAL === type) {
|
|
30821
|
+
if (TableType$2.OPT === type || TableType$2.OPTNOTOTAL === type) {
|
|
30529
30822
|
header = [
|
|
30530
30823
|
{
|
|
30531
30824
|
name: QueryColumnNames.OPERATION,
|
|
@@ -30567,25 +30860,29 @@ class TableDataSetFactory {
|
|
|
30567
30860
|
let iGroupIndex = -1; // index used in detailRow JSON to count the current group
|
|
30568
30861
|
const dataQuery = new DataQuery(config, i18n);
|
|
30569
30862
|
this.dateBuckets = isDateInterval(config.interval);
|
|
30570
|
-
this.unsignedEntries = TableType.OPT === config.type || TableType.OPTNOTOTAL === config.type;
|
|
30863
|
+
this.unsignedEntries = TableType$2.OPT === config.type || TableType$2.OPTNOTOTAL === config.type;
|
|
30571
30864
|
const queryData = dataQuery.execute(db, fromExpr); // collection of all query results
|
|
30572
30865
|
this.hasBlankRowGroup = dataQuery.hasBlankRowGroup;
|
|
30573
30866
|
// Calculate column statistics for bar columns
|
|
30574
30867
|
const columnStatsMap = this.calculateColumnStatistics(queryData, config.barColumns, config.interval !== INTERVAL_NONE);
|
|
30575
|
-
// Scenario bar columns render as a waterfall when grouping structure is present
|
|
30868
|
+
// Scenario bar columns render as a waterfall when grouping structure is present,
|
|
30869
|
+
// absolute variance bar columns when varianceWaterfall is set;
|
|
30576
30870
|
// interval/columnthereof composite columns are excluded and render as today
|
|
30577
|
-
const
|
|
30578
|
-
const
|
|
30579
|
-
|
|
30580
|
-
|
|
30581
|
-
hasGroupingStructure(queryData)
|
|
30582
|
-
?
|
|
30871
|
+
const thereOfAbove = config.thereOfPosition === ThereofPosition.ABOVE;
|
|
30872
|
+
const barColumns = (_a = config.barColumns) !== null && _a !== void 0 ? _a : [];
|
|
30873
|
+
const scenarioColumns = barColumns.filter((column) => column.toUpperCase().trim() in Scenarios);
|
|
30874
|
+
const waterfallColumns = [
|
|
30875
|
+
...(scenarioColumns.length > 0 && hasGroupingStructure(queryData) ? scenarioColumns : []),
|
|
30876
|
+
...(config.varianceWaterfall ? barColumns.filter((column) => new VarianceScenario(column).type === "d") : []),
|
|
30877
|
+
];
|
|
30878
|
+
const waterfallResult = waterfallColumns.length > 0 && config.interval === INTERVAL_NONE && config.categoryThereOf.size === 0
|
|
30879
|
+
? computeWaterfall(queryData, waterfallColumns, config.type, dataQuery.hasRunningSum(), thereOfAbove)
|
|
30583
30880
|
: undefined;
|
|
30584
30881
|
for (const groupData of queryData) {
|
|
30585
30882
|
// groupData is a collection of dataRows, each group base on a query and represents a 'row' group
|
|
30586
30883
|
iGroupIndex += 1;
|
|
30587
30884
|
const iRowIndex = -1;
|
|
30588
|
-
bodyRows.push(...this.createRow(config.i18n, i18n, config.scenariosUnitType, groupData, iGroupIndex, iRowIndex, config.categoryWidth, config.measureScale, config.barColumns, columnStatsMap, waterfallResult));
|
|
30885
|
+
bodyRows.push(...this.createRow(config.i18n, i18n, config.scenariosUnitType, groupData, iGroupIndex, iRowIndex, config.categoryWidth, config.measureScale, config.barColumns, columnStatsMap, waterfallResult, thereOfAbove));
|
|
30589
30886
|
}
|
|
30590
30887
|
return bodyRows;
|
|
30591
30888
|
}
|
|
@@ -30696,9 +30993,12 @@ class TableDataSetFactory {
|
|
|
30696
30993
|
* @param barColumns
|
|
30697
30994
|
* @param columnStatsMap
|
|
30698
30995
|
*/
|
|
30699
|
-
createRow(i18nMode, i18n, scenariosUnitType, groupData, iGroupIndex, iRowIndex, categoryWidth, measureScale, barColumns, columnStatsMap, waterfallResult) {
|
|
30996
|
+
createRow(i18nMode, i18n, scenariosUnitType, groupData, iGroupIndex, iRowIndex, categoryWidth, measureScale, barColumns, columnStatsMap, waterfallResult, thereOfAbove = false) {
|
|
30700
30997
|
var _a, _b, _c;
|
|
30701
30998
|
const result = [];
|
|
30999
|
+
// the last entry row and its index in result: the parent of the thereof rows that follow it
|
|
31000
|
+
let parentIndex = -1;
|
|
31001
|
+
let parent;
|
|
30702
31002
|
// thereof and partof rows have no operation, they take the one of the row above
|
|
30703
31003
|
let operation;
|
|
30704
31004
|
for (const rawDataRow of groupData) {
|
|
@@ -30710,20 +31010,31 @@ class TableDataSetFactory {
|
|
|
30710
31010
|
const type = rawDataRow[QueryColumnNames.TYPE];
|
|
30711
31011
|
const isSecondElement = rawDataRow[QueryColumnNames.ROWNR] >= 2;
|
|
30712
31012
|
operation = ((_b = (_a = rawDataRow.operation) !== null && _a !== void 0 ? _a : rawDataRow.restOperation) !== null && _b !== void 0 ? _b : operation);
|
|
31013
|
+
// a thereof row moves above the entry row before it only when that row is its parent
|
|
31014
|
+
const moved = thereOfAbove &&
|
|
31015
|
+
type === TableRowType.DRILLELEMENT &&
|
|
31016
|
+
parent !== undefined &&
|
|
31017
|
+
parent[QueryColumnNames.CATEGORY] === rawDataRow[QueryColumnNames.CATEGORY] &&
|
|
31018
|
+
(parent[QueryColumnNames.ROWGROUP] === "NO_GROUP" || parent[QueryColumnNames.ROWGROUP] === rowGroup);
|
|
30713
31019
|
const detailsRow = this.createDetailRow(type, iRowIndex, iGroupIndex, groupData.length);
|
|
30714
31020
|
detailsRow.key = this.rowKey(rawDataRow);
|
|
30715
31021
|
for (const scenario of this.normalizedHeader) {
|
|
30716
31022
|
const value = this.getRawDataRowElement(rawDataRow, scenario);
|
|
30717
|
-
const
|
|
30718
|
-
const columnStats = isBarChart ? columnStatsMap === null || columnStatsMap === void 0 ? void 0 : columnStatsMap.get(scenario.type) : undefined;
|
|
31023
|
+
const isBarColumn = (_c = barColumns === null || barColumns === void 0 ? void 0 : barColumns.includes(scenario.type)) !== null && _c !== void 0 ? _c : false;
|
|
30719
31024
|
// waterfall geometry only exists for plain scenario columns (no ## composites)
|
|
30720
|
-
const waterfall =
|
|
31025
|
+
const waterfall = isBarColumn &&
|
|
30721
31026
|
scenario.bucket === undefined &&
|
|
30722
31027
|
scenario.name === scenario.group &&
|
|
30723
31028
|
scenario.name === scenario.type
|
|
30724
31029
|
? waterfallResult === null || waterfallResult === void 0 ? void 0 : waterfallResult.get(rawDataRow, scenario.type)
|
|
30725
31030
|
: undefined;
|
|
30726
|
-
|
|
31031
|
+
// a share of a variance has no place in the walk of a variance waterfall: the row prints the number
|
|
31032
|
+
const isBarChart = isBarColumn &&
|
|
31033
|
+
!(type === TableRowType.PARTELEMENT &&
|
|
31034
|
+
new VarianceScenario(scenario.type).isValid &&
|
|
31035
|
+
(waterfallResult === null || waterfallResult === void 0 ? void 0 : waterfallResult.has(scenario.type)));
|
|
31036
|
+
const columnStats = isBarChart ? columnStatsMap === null || columnStatsMap === void 0 ? void 0 : columnStatsMap.get(scenario.type) : undefined;
|
|
31037
|
+
detailsRow.createElement(this.translateSumCellLabel(i18nMode, i18n, value, groupName, subCategory, type, scenario.type), scenario.type, this.createColumnType(scenario), this.setCellType(scenario.type, scenariosUnitType), moved ? null : this.translateCellPrefix(i18n, type, scenario.type), this.translateScenarioCSS(scenario.type, value, operation), isSecondElement, categoryWidth, measureScale === null || measureScale === void 0 ? void 0 : measureScale.value, isBarChart, columnStats, 1, waterfall);
|
|
30727
31038
|
const cell = detailsRow.elements[detailsRow.elements.length - 1];
|
|
30728
31039
|
if (this.dateBuckets && scenario.bucket !== undefined) {
|
|
30729
31040
|
cell.date = pointDate(scenario.bucket);
|
|
@@ -30733,6 +31044,18 @@ class TableDataSetFactory {
|
|
|
30733
31044
|
cell.direction = this.resolveDirection(varianceScenario, operation);
|
|
30734
31045
|
}
|
|
30735
31046
|
}
|
|
31047
|
+
// moved only here: the operation above and the waterfall geometry both rely on the parent coming first
|
|
31048
|
+
if (moved) {
|
|
31049
|
+
detailsRow.cssStyle = "ofit-above";
|
|
31050
|
+
result[parentIndex].cssStyle = "ofit-sum";
|
|
31051
|
+
result.splice(parentIndex, 0, detailsRow);
|
|
31052
|
+
parentIndex += 1;
|
|
31053
|
+
continue;
|
|
31054
|
+
}
|
|
31055
|
+
if (type === TableRowType.ENTRY) {
|
|
31056
|
+
parentIndex = result.length;
|
|
31057
|
+
parent = rawDataRow;
|
|
31058
|
+
}
|
|
30736
31059
|
result.push(detailsRow);
|
|
30737
31060
|
}
|
|
30738
31061
|
return result;
|
|
@@ -31037,11 +31360,11 @@ class Table {
|
|
|
31037
31360
|
["ibcssymbol_delta_generic_relative", "Δ({%})%"],
|
|
31038
31361
|
["SUM_TOTAL", "❖"],
|
|
31039
31362
|
]);
|
|
31040
|
-
this.state = FactoryState$
|
|
31363
|
+
this.state = FactoryState$3.DIRTY; // mark dataSet for update
|
|
31041
31364
|
return new Map([...defaultI18n, ...(i18n || new Map())]);
|
|
31042
31365
|
}
|
|
31043
31366
|
initConfig(config) {
|
|
31044
|
-
this.state = FactoryState$
|
|
31367
|
+
this.state = FactoryState$3.DIRTY; // mark dataSet for update
|
|
31045
31368
|
const tmpConfig = config;
|
|
31046
31369
|
// sorting scenario order based on Ruleset
|
|
31047
31370
|
const self = this;
|
|
@@ -31076,7 +31399,7 @@ class Table {
|
|
|
31076
31399
|
*/
|
|
31077
31400
|
setSource(tableName, filter) {
|
|
31078
31401
|
var _a, _b;
|
|
31079
|
-
this.state = FactoryState$
|
|
31402
|
+
this.state = FactoryState$3.DIRTY;
|
|
31080
31403
|
// "" while the source is not registered (e.g. the datasource has not loaded yet): treated as empty
|
|
31081
31404
|
this.fromExpr = sourceExpr(this.db, tableName, filter);
|
|
31082
31405
|
if (!this.fromExpr) {
|
|
@@ -31097,16 +31420,16 @@ class Table {
|
|
|
31097
31420
|
this.rowCount === 0 || !this.fromExpr
|
|
31098
31421
|
? []
|
|
31099
31422
|
: this.dataSetFactory.createBodyRows(this.config, this.i18n, this.db, this.fromExpr);
|
|
31100
|
-
this.state = FactoryState$
|
|
31423
|
+
this.state = FactoryState$3.UP_TO_DATE;
|
|
31101
31424
|
}
|
|
31102
31425
|
getHeader() {
|
|
31103
|
-
if (this.state === FactoryState$
|
|
31426
|
+
if (this.state === FactoryState$3.DIRTY) {
|
|
31104
31427
|
this.update();
|
|
31105
31428
|
}
|
|
31106
31429
|
return this.headerRows;
|
|
31107
31430
|
}
|
|
31108
31431
|
getBody() {
|
|
31109
|
-
if (this.state === FactoryState$
|
|
31432
|
+
if (this.state === FactoryState$3.DIRTY) {
|
|
31110
31433
|
this.update();
|
|
31111
31434
|
}
|
|
31112
31435
|
return this.bodyRows;
|
|
@@ -31116,7 +31439,7 @@ class Table {
|
|
|
31116
31439
|
* With `categoryIntervalPosition` the first interval buckets come before the category/operation column.
|
|
31117
31440
|
*/
|
|
31118
31441
|
getColumns() {
|
|
31119
|
-
if (this.state === FactoryState$
|
|
31442
|
+
if (this.state === FactoryState$3.DIRTY) {
|
|
31120
31443
|
this.update();
|
|
31121
31444
|
}
|
|
31122
31445
|
return this.dataSetFactory.getNormalizedHeader();
|
|
@@ -31200,7 +31523,7 @@ class Table {
|
|
|
31200
31523
|
/** Warning for an order `@bucket` that cannot apply, once the body was built; undefined when all apply. */
|
|
31201
31524
|
orderBucketWarning() {
|
|
31202
31525
|
var _a, _b;
|
|
31203
|
-
if (this.hasNoData() || this.state !== FactoryState$
|
|
31526
|
+
if (this.hasNoData() || this.state !== FactoryState$3.UP_TO_DATE) {
|
|
31204
31527
|
return undefined;
|
|
31205
31528
|
}
|
|
31206
31529
|
const buckets = ((_b = (_a = this.config.sortOrder) === null || _a === void 0 ? void 0 : _a.hierarchy) !== null && _b !== void 0 ? _b : [])
|
|
@@ -31223,7 +31546,7 @@ class Table {
|
|
|
31223
31546
|
/** Warning for a `categoryIntervalPosition` that cannot apply, once the body was built; undefined when it applies. */
|
|
31224
31547
|
categoryIntervalPositionWarning() {
|
|
31225
31548
|
const position = this.categoryIntervalPosition();
|
|
31226
|
-
if (position <= 0 || this.hasNoData() || this.state !== FactoryState$
|
|
31549
|
+
if (position <= 0 || this.hasNoData() || this.state !== FactoryState$3.UP_TO_DATE) {
|
|
31227
31550
|
return undefined;
|
|
31228
31551
|
}
|
|
31229
31552
|
const groups = this.intervalBuckets.length;
|
|
@@ -31271,8 +31594,14 @@ class TableComponentConfig {
|
|
|
31271
31594
|
/** When true, rows are visually grouped by rowGroup. */
|
|
31272
31595
|
this.grouped = false;
|
|
31273
31596
|
this.showGroupTitle = true;
|
|
31597
|
+
/** When true, each group sum row holds the running result of all groups up to its own (see bn-table `runningSum` prop). */
|
|
31598
|
+
this.runningSum = false;
|
|
31599
|
+
/** When true, absolute variance bar columns are drawn as a waterfall (see bn-table `varianceWaterfall` prop). */
|
|
31600
|
+
this.varianceWaterfall = false;
|
|
31274
31601
|
/** Drill-down sub-row definitions -- "thereof" breakdowns within a category. */
|
|
31275
31602
|
this.thereOf = [];
|
|
31603
|
+
/** Thereof rows below or above their parent row (see bn-table `thereofPosition` prop). */
|
|
31604
|
+
this.thereOfPosition = ThereofPosition.BELOW;
|
|
31276
31605
|
/** Column-level drill-down using `##` separator in category names. */
|
|
31277
31606
|
this.categoryThereOf = new Map();
|
|
31278
31607
|
/** Percentage-of-total sub-row definitions. */
|
|
@@ -31281,7 +31610,7 @@ class TableComponentConfig {
|
|
|
31281
31610
|
this.attributes = [];
|
|
31282
31611
|
this.sortOrder = new OrderAdapter(new StringAdapter()).default();
|
|
31283
31612
|
/** Table aggregation mode: LIST (flat), SUM (with totals), OPT (with optional totals), etc. */
|
|
31284
|
-
this.type = TableType.LIST;
|
|
31613
|
+
this.type = TableType$2.LIST;
|
|
31285
31614
|
/** Maximum rows to display; 0 means unlimited. */
|
|
31286
31615
|
this.limit = 0;
|
|
31287
31616
|
this.i18n = I18nMode.ALL;
|
|
@@ -31337,6 +31666,15 @@ class TableComponentConfigAdapter {
|
|
|
31337
31666
|
if (CompareUtil.isBoolean(data.showGroupTitle)) {
|
|
31338
31667
|
config.showGroupTitle = data.showGroupTitle;
|
|
31339
31668
|
}
|
|
31669
|
+
if (CompareUtil.isBoolean(data.runningSum)) {
|
|
31670
|
+
config.runningSum = data.runningSum;
|
|
31671
|
+
}
|
|
31672
|
+
if (CompareUtil.isBoolean(data.varianceWaterfall)) {
|
|
31673
|
+
config.varianceWaterfall = data.varianceWaterfall;
|
|
31674
|
+
}
|
|
31675
|
+
if (data.thereOfPosition === ThereofPosition.ABOVE) {
|
|
31676
|
+
config.thereOfPosition = ThereofPosition.ABOVE;
|
|
31677
|
+
}
|
|
31340
31678
|
if (CompareUtil.isBoolean(data.showMeasureScale)) {
|
|
31341
31679
|
config.showMeasureScale = data.showMeasureScale;
|
|
31342
31680
|
}
|
|
@@ -31440,7 +31778,7 @@ class TableDrillGroupAdapter {
|
|
|
31440
31778
|
}
|
|
31441
31779
|
}
|
|
31442
31780
|
|
|
31443
|
-
const bnTableRendererCss = () => `:host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}`;
|
|
31781
|
+
const bnTableRendererCss = () => `:host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{position:relative;display:inline-block}table{background-color:var(--bn-font-background, white);font-size:var(--bn-font-size, 1em);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);border-spacing:0.3em 0}thead{border-style:none}tr:first-child td{border-top:none;padding-top:0.5em}td.ac1,td.ac2,td.ac3,td.ac4,td.pp1,td.pp2,td.pp3,td.pp4,td.pl1,td.pl2,td.pl3,td.pl4,td.fc1,td.fc2,td.fc3,td.fc4,td.share,td.variance,td.pos_pos,td.pos_neg,td.neg_pos,td.neg_neg,td.pos_neutral,td.neg_neutral,td.zero{text-align:right}.category-w100{min-width:100em;max-width:100em}.category-w50{min-width:50em;max-width:50em}.category-w25{min-width:25em;max-width:25em}.category-w20{min-width:20em;max-width:20em}.category-w15{min-width:15em;max-width:15em}.category-w10{min-width:10em;max-width:10em}.category-w5{min-width:5em;max-width:5em}.prefix-second{color:transparent;font-style:normal}.prefix-first{font-style:normal}th{border-bottom:0.1em solid black;text-align:right;font-weight:normal;vertical-align:text-top}td.columnGroup,th.columnGroup{font-size:0.6em}td.columnSubGroup,th.columnSubGroup{font-size:0.6em;border-spacing:0em 0;font-style:italic}td.base,th.base{font-style:normal}th.ofit,td.ofit,tr.ofit,th.partof,td.partof,tr.partof{font-size:0.6em;font-style:italic}td.ofit,td.partof{font-size:0.6em;font-style:italic}th.ofit td,tr.ofit td,th.partof td,tr.partof td{border-top:0em solid black;padding-left:1em}th.ofit share,th.partof share,tr.share td{border-top:0em solid black}th.share,tr.share,td.share{font-size:0.6em;font-style:italic}th.filler{border-bottom:0em solid black;text-align:right}td.filler{border-top:0em none !important;border-bottom:0em none;text-align:right}th.group{text-align:center;border-spacing:1em 0}th.headerlabel{border-bottom:0em none black;padding-bottom:0em}th.intervalGroup{border-bottom:0.1em solid black;text-align:center;font-weight:bold}td.variance:after{content:"%"}td.relative_variance{font-style:italic}td.percent{font-style:italic;text-align:right}td.decimal,td.percentpoint{text-align:right}td.pos_pos{color:#008f96}td.neg_pos{color:#ff0000}td.pos_neg{color:#ff0000}td.neg_neg{color:#008f96}td.pos_pos:before{content:"+"}td.pos_neg:before{content:"+"}td.pos_neu:before{content:"+"}th.ac1,th.ac2,th.ac3,th.ac4{padding-top:0em;border-bottom:0.3em solid black}th.pp1,th.pp2,th.pp3,th.pp4{padding-top:0em;border-bottom:0.3em solid grey}th.pl1,th.pl2,th.pl3,th.pl4{padding-top:0em;border-bottom:0.3em double black}th.fc1,th.fc2,th.fc3,th.fc4{border-bottom:0.3em solid;border-image:repeating-linear-gradient(-45deg, white, white, black, white, white 0.3em) 2}td.colsum{font-weight:bold}th.colsum{padding-top:0em;font-weight:bold}tr.sum td{border-top:0.1em solid black;font-weight:bold;padding-bottom:0.5em}tr.ofit-above td[class^=category]{padding-left:1em}tr.ofit-sum td{border-top:0.1em solid black;font-weight:bold}tr.groupheader td{border-top:0em dotted #ddd;padding-top:0.5em;font-weight:bold;font-style:italic}tr.begingroup td{border-top:0em dotted #ddd;padding-top:0.5em}th.begin-group{padding-left:0.75em}th.end-group{padding-left:0.75em}td{box-sizing:border-box;-webkit-box-sizing:border-box;border-top:0.1em dashed #ddd;padding-left:0.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.table-footer{font-size:0.6em}.cell-bar-chart{display:inline-block;vertical-align:middle}.bar-chart-empty{color:#999}td:has(.variance-waterfall){overflow:visible}td:has(.cell-bar-chart){padding:0 0.25em;vertical-align:middle}tr.ofit td:has(.cell-bar-chart),tr.partof td:has(.cell-bar-chart),tr.share td:has(.cell-bar-chart){padding:0 0.4166666667em}td:has(.cell-bar-chart).pos_pos:before,td:has(.cell-bar-chart).pos_neg:before,td:has(.cell-bar-chart).pos_neu:before{content:none}td:has(.cell-bar-chart).variance:after{content:none}`;
|
|
31444
31782
|
|
|
31445
31783
|
const BnTableRenderer = class {
|
|
31446
31784
|
constructor(hostRef) {
|
|
@@ -31474,20 +31812,26 @@ const BnTableRenderer = class {
|
|
|
31474
31812
|
/** @internal */
|
|
31475
31813
|
this.showGroupTitle = true;
|
|
31476
31814
|
/** @internal */
|
|
31815
|
+
this.runningSum = false;
|
|
31816
|
+
/** @internal */
|
|
31817
|
+
this.varianceWaterfall = false;
|
|
31818
|
+
/** @internal */
|
|
31477
31819
|
this.thereof = [];
|
|
31478
31820
|
/** @internal */
|
|
31821
|
+
this.thereofPosition = ThereofPosition.BELOW;
|
|
31822
|
+
/** @internal */
|
|
31479
31823
|
this.partof = [];
|
|
31480
31824
|
/** @internal */
|
|
31481
31825
|
this.order = {
|
|
31482
31826
|
hierarchy: [],
|
|
31483
|
-
direction: OrderDirection.ASC,
|
|
31827
|
+
direction: OrderDirection$1.ASC,
|
|
31484
31828
|
};
|
|
31485
31829
|
/** @internal */
|
|
31486
31830
|
this.categorythereof = new Map();
|
|
31487
31831
|
/** @internal */
|
|
31488
31832
|
this.attributeColumns = [];
|
|
31489
31833
|
/** @internal */
|
|
31490
|
-
this.type = TableType.LIST;
|
|
31834
|
+
this.type = TableType$2.LIST;
|
|
31491
31835
|
/** @internal */
|
|
31492
31836
|
this.categoryWidth = TableCategoryWidth.INF;
|
|
31493
31837
|
/** @internal */
|
|
@@ -31526,9 +31870,10 @@ const BnTableRenderer = class {
|
|
|
31526
31870
|
this.scaleFactor = 1;
|
|
31527
31871
|
this.componentDataFormatDigits = new DataFormatDigits();
|
|
31528
31872
|
this.barColumnLayouts = new Map();
|
|
31873
|
+
this.waterfallGeometries = new Map();
|
|
31529
31874
|
// labels measured in the fallback font are too narrow or too wide once the web font is there: lay out again
|
|
31530
31875
|
this.relayout = () => {
|
|
31531
|
-
if (this.barColumnLayouts.size > 0)
|
|
31876
|
+
if (this.barColumnLayouts.size > 0 || this.waterfallGeometries.size > 0)
|
|
31532
31877
|
forceUpdate(this);
|
|
31533
31878
|
};
|
|
31534
31879
|
withComponentStatus(this);
|
|
@@ -31661,14 +32006,16 @@ const BnTableRenderer = class {
|
|
|
31661
32006
|
const locale = (_d = (_c = (_b = this.stores) === null || _b === void 0 ? void 0 : _b.context) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.locale;
|
|
31662
32007
|
return (h("table", null, h("thead", null, this.table.getHeader().map((row) => (h("tr", { class: row.cssStyle }, row.getCells().map((cell) => (h("th", { colSpan: cell.colSpan, class: cell.cssStyle }, cell.getAsHeaderList().map((line, i, arr) => (h("span", null, i === arr.length - 1 ? (h("span", { class: line === " " ? "table-footer" : "" }, line, cell.drawPrefix(), " ")) : (h("span", null, line, cell.drawPrefix(), h("br", null))))))))))))), h("tbody", null, this.table.getBody().map((row) => (h("tr", Object.assign({ class: row.cssStyle }, dataPointAttributes(row.key, "element")), row === null || row === void 0 ? void 0 : row.getCells().map((cell) => {
|
|
31663
32008
|
var _a, _b, _c, _d, _e;
|
|
31664
|
-
return (h("td", Object.assign({ colSpan: cell.colSpan, class: cell.type ? `${cell
|
|
32009
|
+
return (h("td", Object.assign({ colSpan: cell.colSpan, class: cell.type ? `${this.cellClass(cell, locale)} ${cell.type}` : cell.cssStyle }, (row.key && cell.value != null && cell.value !== "" && cell.value !== "-"
|
|
31665
32010
|
? dataPointAttributes(Object.assign(Object.assign({}, row.key), { date: cell.date, scenario: cell.key }), "element")
|
|
31666
|
-
: {})), cell.prefix != null ? (h("span", { class: cell
|
|
32011
|
+
: {})), cell.prefix != null ? (h("span", { class: this.cellClass(cell, locale) + " " + cell.prefixStyle }, cell.drawPrefix())) : (""), cell.isBarChart &&
|
|
31667
32012
|
cell.columnStats &&
|
|
31668
32013
|
cell.value !== NOT_AVAILABLE &&
|
|
31669
32014
|
// an untitled group head is only a gap between list groups, a bar cell would print "-" in it
|
|
31670
32015
|
(this.showGroupTitle || row.type !== TableRowType.HEADER) &&
|
|
31671
|
-
(cell.waterfall !== undefined || row.type !== TableRowType.SUM)
|
|
32016
|
+
(cell.waterfall !== undefined || row.type !== TableRowType.SUM) &&
|
|
32017
|
+
// a variance walk where every step is zero has no extent: the rows print their zero
|
|
32018
|
+
!(cell.direction !== undefined && cell.waterfall && cell.waterfall.max === cell.waterfall.min) ? (cell.waterfall !== undefined ? (h(WaterfallBar, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: false, isPositiveGood: cell.direction === "pos", measureScale: barLabelMeasureScale(cell), locale: locale, decimalDigits: barLabelDigits(cell, this.componentDataFormatDigits), columnWidthEm: this.barColumnMaxWidth, styles: this.barChartStyles, waterfall: cell.waterfall, geometry: this.waterfallGeometries.get(cell.key), bold: isBoldRow(row), connectorReach: this.connectorReach(row) })) : (h(CellBarChart, { value: cell.value, scenario: cell.key, columnStats: cell.columnStats, height: 18 * this.scaleFactor, isRelative: cell.key.startsWith("dr"), isPositiveGood: cell.direction === "pos", measureScale: barLabelMeasureScale(cell), locale: locale, decimalDigits: barLabelDigits(cell, this.componentDataFormatDigits), percentDigits: (_b = (_a = this.barColumnLayouts.get(cell.key)) === null || _a === void 0 ? void 0 : _a.percentDigits) !== null && _b !== void 0 ? _b : this.componentDataFormatDigits.percent, percentSign: (_c = this.barColumnLayouts.get(cell.key)) === null || _c === void 0 ? void 0 : _c.percentSign, columnWidthEm: this.barColumnMaxWidth, labelWidths: (_d = this.barColumnLayouts.get(cell.key)) === null || _d === void 0 ? void 0 : _d.labels, sideMax: (_e = this.barColumnLayouts.get(cell.key)) === null || _e === void 0 ? void 0 : _e.sideMax, bold: isBoldRow(row), styles: this.barChartStyles }))) : (cell.draw(this.componentDataFormatDigits, locale))));
|
|
31672
32019
|
})))))));
|
|
31673
32020
|
};
|
|
31674
32021
|
return h(Host, { class: { "no-data": ((_a = this.table) === null || _a === void 0 ? void 0 : _a.hasNoData()) === true } }, helper());
|
|
@@ -31724,8 +32071,16 @@ const BnTableRenderer = class {
|
|
|
31724
32071
|
}
|
|
31725
32072
|
}
|
|
31726
32073
|
this.barColumnLayouts = this.collectBarColumnLayouts();
|
|
32074
|
+
this.waterfallGeometries = this.collectWaterfallGeometries();
|
|
31727
32075
|
this.barChartStyles = this.prepareBarChartStyles();
|
|
31728
32076
|
}
|
|
32077
|
+
/** The classes of a number cell. A variance that prints as zero loses its sign and its sentiment color. */
|
|
32078
|
+
cellClass(cell, locale) {
|
|
32079
|
+
if (cell.direction === undefined || !cell.roundsToZero(this.componentDataFormatDigits, locale)) {
|
|
32080
|
+
return cell.cssStyle;
|
|
32081
|
+
}
|
|
32082
|
+
return cell.cssStyle.replace(/^(pos|neg)_\w+/, "zero");
|
|
32083
|
+
}
|
|
31729
32084
|
prepareConfig(db) {
|
|
31730
32085
|
var _a, _b, _c;
|
|
31731
32086
|
const fromExpr = sourceExpr(db, this.tableName, this.filter);
|
|
@@ -31739,7 +32094,10 @@ const BnTableRenderer = class {
|
|
|
31739
32094
|
scenariosUnitType: this.scenariosDataFormat,
|
|
31740
32095
|
grouped: this.grouped,
|
|
31741
32096
|
showGroupTitle: this.showGroupTitle,
|
|
32097
|
+
runningSum: this.runningSum,
|
|
32098
|
+
varianceWaterfall: this.varianceWaterfall,
|
|
31742
32099
|
thereOf: this.thereof,
|
|
32100
|
+
thereOfPosition: this.thereofPosition,
|
|
31743
32101
|
partOf: this.partof,
|
|
31744
32102
|
categoryThereOf: this.categorythereof,
|
|
31745
32103
|
attributes: this.attributeColumns,
|
|
@@ -31902,6 +32260,7 @@ const BnTableRenderer = class {
|
|
|
31902
32260
|
const layouts = new Map();
|
|
31903
32261
|
if (!this.table || this.table.hasNoData())
|
|
31904
32262
|
return layouts;
|
|
32263
|
+
// a cell with the weight its row prints in
|
|
31905
32264
|
const cellsByKey = new Map();
|
|
31906
32265
|
for (const row of this.table.getBody()) {
|
|
31907
32266
|
if (row.type === TableRowType.SUM)
|
|
@@ -31912,7 +32271,7 @@ const BnTableRenderer = class {
|
|
|
31912
32271
|
continue;
|
|
31913
32272
|
if (typeof cell.value !== "number" || isNaN(cell.value))
|
|
31914
32273
|
continue;
|
|
31915
|
-
cellsByKey.set(cell.key, [...((_a = cellsByKey.get(cell.key)) !== null && _a !== void 0 ? _a : []), cell]);
|
|
32274
|
+
cellsByKey.set(cell.key, [...((_a = cellsByKey.get(cell.key)) !== null && _a !== void 0 ? _a : []), { cell, bold: isBoldRow(row) }]);
|
|
31916
32275
|
}
|
|
31917
32276
|
}
|
|
31918
32277
|
const emPx = this.emPx();
|
|
@@ -31922,7 +32281,7 @@ const BnTableRenderer = class {
|
|
|
31922
32281
|
const fontFamily = this.labelFontFamily();
|
|
31923
32282
|
for (const [key, cells] of cellsByKey) {
|
|
31924
32283
|
const isRelative = key.startsWith("dr");
|
|
31925
|
-
const values = cells.map((cell) => cell.value);
|
|
32284
|
+
const values = cells.map(({ cell }) => cell.value);
|
|
31926
32285
|
const measure = (percentDigits, percentSign) => {
|
|
31927
32286
|
var _a;
|
|
31928
32287
|
const labels = {
|
|
@@ -31930,11 +32289,11 @@ const BnTableRenderer = class {
|
|
|
31930
32289
|
pos: values.some((value) => value > 0) ? 0 : undefined,
|
|
31931
32290
|
};
|
|
31932
32291
|
const zeroPositive = zeroOnPositiveSide(labels);
|
|
31933
|
-
for (const cell of cells) {
|
|
32292
|
+
for (const { cell, bold } of cells) {
|
|
31934
32293
|
const value = cell.value;
|
|
31935
32294
|
const side = value > 0 || (value === 0 && zeroPositive) ? "pos" : "neg";
|
|
31936
32295
|
const text = formatValue(value, isRelative, barLabelMeasureScale(cell), locale, percentDigits, percentSign, barLabelDigits(cell, this.componentDataFormatDigits));
|
|
31937
|
-
labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative));
|
|
32296
|
+
labels[side] = Math.max((_a = labels[side]) !== null && _a !== void 0 ? _a : 0, labelWidth(text, fs, fontFamily, isRelative, bold));
|
|
31938
32297
|
}
|
|
31939
32298
|
return labels;
|
|
31940
32299
|
};
|
|
@@ -31960,8 +32319,56 @@ const BnTableRenderer = class {
|
|
|
31960
32319
|
}
|
|
31961
32320
|
return layouts;
|
|
31962
32321
|
}
|
|
32322
|
+
/**
|
|
32323
|
+
* What a variance waterfall connector crosses outside the bar svg: the border of its own
|
|
32324
|
+
* row above, the padding of a sum row below.
|
|
32325
|
+
*/
|
|
32326
|
+
connectorReach(row) {
|
|
32327
|
+
const emPx = this.emPx();
|
|
32328
|
+
return { top: 0.1 * emPx, bottom: row.type === TableRowType.SUM ? 0.5 * emPx : 0 };
|
|
32329
|
+
}
|
|
32330
|
+
/**
|
|
32331
|
+
* Geometry of every waterfall column from the measured labels of all cells that draw a
|
|
32332
|
+
* bar, sum rows included: each side gets the room its labels need.
|
|
32333
|
+
*/
|
|
32334
|
+
collectWaterfallGeometries() {
|
|
32335
|
+
var _a, _b, _c, _d;
|
|
32336
|
+
const geometries = new Map();
|
|
32337
|
+
if (!this.table || this.table.hasNoData())
|
|
32338
|
+
return geometries;
|
|
32339
|
+
const emPx = this.emPx();
|
|
32340
|
+
const fs = emPx * BAR_LABEL_FONT_RATIO;
|
|
32341
|
+
const locale = (_c = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.locale;
|
|
32342
|
+
const fontFamily = this.labelFontFamily();
|
|
32343
|
+
const columns = new Map();
|
|
32344
|
+
for (const row of this.table.getBody()) {
|
|
32345
|
+
for (const cell of row.getCells()) {
|
|
32346
|
+
if (!cell.isBarChart || !cell.columnStats || cell.waterfall === undefined)
|
|
32347
|
+
continue;
|
|
32348
|
+
if (typeof cell.value !== "number" || isNaN(cell.value))
|
|
32349
|
+
continue;
|
|
32350
|
+
const { start, end, min, max, kind } = cell.waterfall;
|
|
32351
|
+
const text = waterfallLabelText(cell.value, kind, barLabelMeasureScale(cell), locale, barLabelDigits(cell, this.componentDataFormatDigits), cell.direction !== undefined);
|
|
32352
|
+
const column = (_d = columns.get(cell.key)) !== null && _d !== void 0 ? _d : { min, max, labels: [] };
|
|
32353
|
+
column.labels.push({
|
|
32354
|
+
end,
|
|
32355
|
+
pointsLeft: end < start,
|
|
32356
|
+
width: labelWidth(text, fs, fontFamily, false, isBoldRow(row)),
|
|
32357
|
+
});
|
|
32358
|
+
columns.set(cell.key, column);
|
|
32359
|
+
}
|
|
32360
|
+
}
|
|
32361
|
+
for (const [key, column] of columns) {
|
|
32362
|
+
geometries.set(key, waterfallGeometry(this.barColumnMaxWidth, emPx, column));
|
|
32363
|
+
}
|
|
32364
|
+
return geometries;
|
|
32365
|
+
}
|
|
31963
32366
|
get element() { return getElement(this); }
|
|
31964
32367
|
};
|
|
32368
|
+
/** Sum rows and the parent of thereof rows printed above it are bold. */
|
|
32369
|
+
function isBoldRow(row) {
|
|
32370
|
+
return row.type === TableRowType.SUM || row.cssStyle === "ofit-sum";
|
|
32371
|
+
}
|
|
31965
32372
|
/** Percentage points: the fraction times 100, no measure scale. */
|
|
31966
32373
|
function barLabelMeasureScale(cell) {
|
|
31967
32374
|
return cell.type === "percentpoint" ? 0.01 : cell.measureScale;
|
|
@@ -32201,7 +32608,7 @@ const Title$1 = class Title {
|
|
|
32201
32608
|
}
|
|
32202
32609
|
return {
|
|
32203
32610
|
hierarchy: this.order.split(",").map((entry) => entry.trim()),
|
|
32204
|
-
direction: OrderDirection
|
|
32611
|
+
direction: OrderDirection[(_a = this.orderDirection) === null || _a === void 0 ? void 0 : _a.toUpperCase()],
|
|
32205
32612
|
};
|
|
32206
32613
|
}
|
|
32207
32614
|
prepareTitleTimePeriod() {
|
|
@@ -32602,7 +33009,7 @@ const BnTitleRenderer = class {
|
|
|
32602
33009
|
/** @internal */
|
|
32603
33010
|
this.order = {
|
|
32604
33011
|
hierarchy: [],
|
|
32605
|
-
direction: OrderDirection
|
|
33012
|
+
direction: OrderDirection.ASC,
|
|
32606
33013
|
};
|
|
32607
33014
|
/** @internal */
|
|
32608
33015
|
this.i18n = new Map(); // I18nMode;
|