@bino-bi/bn-template-engine 1.0.0-alpha.5 → 1.0.0-alpha.6
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-06946f44.entry.js +1 -0
- package/dist/bn-template-engine/p-0fabe296.entry.js +1 -0
- package/dist/bn-template-engine/p-1164c0b0.entry.js +1 -0
- package/dist/bn-template-engine/p-355abdf0.entry.js +1 -0
- package/dist/bn-template-engine/p-79KuA4Ox.js +1 -0
- package/dist/bn-template-engine/p-859cc06d.entry.js +1 -0
- package/dist/bn-template-engine/p-8acec99e.entry.js +1 -0
- package/dist/bn-template-engine/p-8f490c45.entry.js +1 -0
- package/dist/bn-template-engine/p-98cf512f.entry.js +1 -0
- package/dist/bn-template-engine/p-9a564f8f.entry.js +1 -0
- package/dist/bn-template-engine/{p-CL1RYuNU.js → p-B0lsgVuN.js} +1 -1
- package/dist/bn-template-engine/p-B7p8beYH.js +1 -0
- package/dist/bn-template-engine/p-BDh7GfC5.js +1 -0
- package/dist/bn-template-engine/p-BoMtoHJB.js +1 -0
- package/dist/bn-template-engine/p-Bs8BqBsb.js +1 -0
- package/dist/bn-template-engine/p-CYjZRKdI.js +1 -0
- package/dist/bn-template-engine/{p-P7pGJBgc.js → p-DG-1MR_T.js} +1 -1
- package/dist/bn-template-engine/p-bdd2b243.entry.js +1 -0
- package/dist/bn-template-engine/p-e6b24f15.entry.js +1 -0
- package/dist/bn-template-engine/p-f27995c9.entry.js +1 -0
- package/dist/bn-template-engine/{p-Bnhh02CF.js → p-sRO-lj7X.js} +1 -1
- package/dist/bn-template-engine/p-tzFCK9qn.js +1 -0
- package/dist/cjs/{Order-iG11HI4R.js → Order-BGx39pS5.js} +448 -0
- package/dist/cjs/{alasql.min-C_nHTuEQ.js → SVGVariancesStyleGroup-BqAdPYtL.js} +8228 -3
- package/dist/cjs/bn-asset_16.cjs.entry.js +9018 -0
- package/dist/cjs/bn-card.cjs.entry.js +3 -4
- package/dist/cjs/bn-chart-time.cjs.entry.js +11 -16
- package/dist/cjs/bn-grid.cjs.entry.js +5 -8
- package/dist/cjs/bn-image.cjs.entry.js +5 -8
- package/dist/cjs/bn-internationalization.cjs.entry.js +3 -4
- package/dist/cjs/bn-layout-card.cjs.entry.js +125 -6
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/bn-template.cjs.entry.js +2 -3
- package/dist/cjs/bn-text.cjs.entry.js +7 -11
- package/dist/cjs/bn-tree.cjs.entry.js +5 -8
- package/dist/cjs/{formatter-DIJL_crx.js → formatter-4XCS0d2B.js} +8 -2
- package/dist/cjs/ibcs-chart-time.cjs.entry.js +37 -42
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{scaling-9Tz595RQ.js → scaling-BidPsO53.js} +115 -12
- package/dist/cjs/{withBodyObserver-CKpSD8UT.js → withBodyObserver-C6gLgq_e.js} +3 -3
- package/dist/cjs/{withComponentStatus-Bw70BhO0.js → withComponentStatus-_x4LQZ0N.js} +5 -5
- package/dist/cjs/{withComponentStyle-aIbTCtfj.js → withComponentStyle-ClSJfCku.js} +4 -4
- package/dist/cjs/{utils-CwHIVbbL.js → withHasError-B8gHkfV2.js} +69 -1
- package/dist/cjs/{withStyled-CS1Yp4sv.js → withStyled-9tG024gQ.js} +62 -9
- package/dist/collection/components/bn-layout-card/bn-layout-card.css +1 -0
- package/dist/collection/components/bn-layout-card/bn-layout-card.js +162 -27
- package/dist/collection/components/bn-layout-page/bn-layout-page.css +1 -0
- package/dist/collection/components/bn-layout-page/bn-layout-page.js +151 -33
- package/dist/collection/utils/parentDimensions.js +38 -6
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/components/bn-layout-page.js +1 -1
- package/dist/components/scaling.js +1 -1
- package/dist/esm/{Order-Bnhh02CF.js → Order-sRO-lj7X.js} +448 -1
- package/dist/esm/{alasql.min-CWu4NkIt.js → SVGVariancesStyleGroup-DOIT-zvI.js} +8212 -2
- package/dist/esm/bn-asset_16.entry.js +9001 -0
- package/dist/esm/bn-card.entry.js +4 -5
- package/dist/esm/bn-chart-time.entry.js +8 -13
- package/dist/esm/bn-grid.entry.js +6 -9
- package/dist/esm/bn-image.entry.js +6 -9
- package/dist/esm/bn-internationalization.entry.js +4 -5
- package/dist/esm/bn-layout-card.entry.js +126 -7
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/bn-template.entry.js +2 -3
- package/dist/esm/bn-text.entry.js +7 -11
- package/dist/esm/bn-tree.entry.js +6 -9
- package/dist/esm/{context-protocol-BHnQsVsr.js → context-protocol-2peaD4y8.js} +1 -1
- package/dist/esm/editor-companion.entry.js +1 -1
- package/dist/esm/{formatter-DTMEZ6d8.js → formatter-BDh7GfC5.js} +6 -2
- package/dist/esm/ibcs-chart-time.entry.js +3 -8
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{scaling-Cehc74IE.js → scaling-BOcjT8M0.js} +112 -10
- package/dist/esm/{withBodyObserver-FQ8NwCIz.js → withBodyObserver-DczL5ia8.js} +1 -1
- package/dist/esm/{withComponentStatus-DWjDYtZ7.js → withComponentStatus-DodoSXe-.js} +1 -1
- package/dist/esm/{withComponentStyle-9uP_hcDq.js → withComponentStyle-D3VWOsto.js} +2 -2
- package/dist/esm/{utils-DvvwfRQG.js → withHasError-B3QX2emi.js} +69 -1
- package/dist/esm/{withStyled--qQWquTH.js → withStyled-CE3_3taP.js} +57 -5
- package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +139 -0
- package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +154 -0
- package/dist/types/components.d.ts +168 -0
- package/dist/types/utils/parentDimensions.d.ts +6 -1
- package/package.json +1 -1
- package/dist/bn-template-engine/p-1265d8d3.entry.js +0 -1
- package/dist/bn-template-engine/p-15516dac.entry.js +0 -1
- package/dist/bn-template-engine/p-1c716641.entry.js +0 -1
- package/dist/bn-template-engine/p-1jFf17Vj.js +0 -1
- package/dist/bn-template-engine/p-27cc8dc0.entry.js +0 -1
- package/dist/bn-template-engine/p-3b4c7425.entry.js +0 -1
- package/dist/bn-template-engine/p-4426d484.entry.js +0 -1
- package/dist/bn-template-engine/p-51f8dc9e.entry.js +0 -1
- package/dist/bn-template-engine/p-53d4e690.entry.js +0 -1
- package/dist/bn-template-engine/p-5KQYRQLK.js +0 -1
- package/dist/bn-template-engine/p-7337e03d.entry.js +0 -1
- package/dist/bn-template-engine/p-75e97c87.entry.js +0 -1
- package/dist/bn-template-engine/p-7a560278.entry.js +0 -1
- package/dist/bn-template-engine/p-BFTU3MAI.js +0 -1
- package/dist/bn-template-engine/p-BYBpC0EO.js +0 -1
- package/dist/bn-template-engine/p-BYmPQYxx.js +0 -1
- package/dist/bn-template-engine/p-BfXY5dsy.js +0 -1
- package/dist/bn-template-engine/p-BgnHJQ9Q.js +0 -1
- package/dist/bn-template-engine/p-Bhd_WSML.js +0 -1
- package/dist/bn-template-engine/p-Bka-Z6jo.js +0 -1
- package/dist/bn-template-engine/p-C7dQL8CS.js +0 -1
- package/dist/bn-template-engine/p-CYwd_ZNM.js +0 -1
- package/dist/bn-template-engine/p-ChlK-T9I.js +0 -1
- package/dist/bn-template-engine/p-DHezf8pZ.js +0 -1
- package/dist/bn-template-engine/p-DlppAFq9.js +0 -1
- package/dist/bn-template-engine/p-DvDDgmcV.js +0 -1
- package/dist/bn-template-engine/p-DvvwfRQG.js +0 -1
- package/dist/bn-template-engine/p-abc0067c.entry.js +0 -1
- package/dist/bn-template-engine/p-b34eaf86.entry.js +0 -1
- package/dist/bn-template-engine/p-bdb8b44c.entry.js +0 -1
- package/dist/bn-template-engine/p-c44fcb8e.entry.js +0 -1
- package/dist/bn-template-engine/p-c7e1a49b.entry.js +0 -1
- package/dist/bn-template-engine/p-d9003041.entry.js +0 -1
- package/dist/bn-template-engine/p-daa7ffa3.entry.js +0 -1
- package/dist/bn-template-engine/p-e084f50a.entry.js +0 -1
- package/dist/bn-template-engine/p-eaba6658.entry.js +0 -1
- package/dist/bn-template-engine/p-u8igQLRZ.js +0 -1
- package/dist/cjs/DataFormatDigits-DKcOeLNK.js +0 -142
- package/dist/cjs/DateStringFactory-CSKvbS8K.js +0 -452
- package/dist/cjs/SVGVariancesStyleGroup-K-Tw6lOD.js +0 -7960
- package/dist/cjs/_commonjsHelpers-BJu3ubxk.js +0 -10
- package/dist/cjs/bn-asset.cjs.entry.js +0 -42
- package/dist/cjs/bn-body_4.cjs.entry.js +0 -748
- package/dist/cjs/bn-chart-structure_5.cjs.entry.js +0 -3948
- package/dist/cjs/bn-component-style.cjs.entry.js +0 -44
- package/dist/cjs/bn-dataset.cjs.entry.js +0 -306
- package/dist/cjs/bn-layout-page.cjs.entry.js +0 -143
- package/dist/cjs/bn-message.cjs.entry.js +0 -52
- package/dist/cjs/bn-table.cjs.entry.js +0 -981
- package/dist/cjs/contentDecoder-JxOldq1e.js +0 -419
- package/dist/cjs/emotion-hash.esm-nbbEQ0Dn.js +0 -57
- package/dist/cjs/ibcs-table.cjs.entry.js +0 -2276
- package/dist/cjs/ibcsRuleSet-DgUoXOfd.js +0 -136
- package/dist/cjs/index-Dm85hG6t.js +0 -65
- package/dist/cjs/withHasError-D7ue5vAv.js +0 -72
- package/dist/cjs/withTranslation-rwgyITqe.js +0 -77
- package/dist/esm/DataFormatDigits-oSZ1hBKE.js +0 -137
- package/dist/esm/DateStringFactory-CSGz6TDk.js +0 -450
- package/dist/esm/SVGVariancesStyleGroup-CqTjrZYg.js +0 -7950
- package/dist/esm/_commonjsHelpers-BFTU3MAI.js +0 -7
- package/dist/esm/bn-asset.entry.js +0 -40
- package/dist/esm/bn-body_4.entry.js +0 -743
- package/dist/esm/bn-chart-structure_5.entry.js +0 -3942
- package/dist/esm/bn-component-style.entry.js +0 -42
- package/dist/esm/bn-dataset.entry.js +0 -304
- package/dist/esm/bn-layout-page.entry.js +0 -141
- package/dist/esm/bn-message.entry.js +0 -50
- package/dist/esm/bn-table.entry.js +0 -979
- package/dist/esm/contentDecoder-oMmxz6nJ.js +0 -416
- package/dist/esm/emotion-hash.esm-BYBpC0EO.js +0 -55
- package/dist/esm/ibcs-table.entry.js +0 -2274
- package/dist/esm/ibcsRuleSet-K4ytuA1f.js +0 -133
- package/dist/esm/index-DHezf8pZ.js +0 -65
- package/dist/esm/withHasError-FyY5mQ_3.js +0 -70
- package/dist/esm/withTranslation-BqD0Kp7b.js +0 -75
|
@@ -1,3942 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h, H as Host, g as getElement } from './index-JNHhIe7t.js';
|
|
2
|
-
import { v as validateScenarioList, a as validateVariancesList, i as isValidNumber, c as isValidLevel, d as validateOrderList, e as isValidDirection, b as isValidInteger, j as isValidBoolean, k as isValidMeasureScale, g as validateStackConfig, w as withStyled, l as isBlankInput } from './withStyled--qQWquTH.js';
|
|
3
|
-
import { w as withDataset, g as getParentDimensions, p as parseScaling } from './scaling-Cehc74IE.js';
|
|
4
|
-
import { w as withComponentStatus } from './withComponentStatus-DWjDYtZ7.js';
|
|
5
|
-
import { w as withTranslation } from './withTranslation-BqD0Kp7b.js';
|
|
6
|
-
import { a as globalLabelKeys, b as getOrCreateStores, g as getStores } from './context-protocol-BHnQsVsr.js';
|
|
7
|
-
import { w as withComponentStyle } from './withComponentStyle-9uP_hcDq.js';
|
|
8
|
-
import { w as withHasError } from './withHasError-FyY5mQ_3.js';
|
|
9
|
-
import { j as AggregationLevel, O as OrderDirection, a as OrderColumn, S as StackBy, b as StackOrder, c as StackMode, f as AdapterUtils, g as CompareUtil, l as OrderAdapter } from './Order-Bnhh02CF.js';
|
|
10
|
-
import { w as withBodyObserver } from './withBodyObserver-FQ8NwCIz.js';
|
|
11
|
-
import { c as computeContentHash, d as decodeCompressedContent } from './contentDecoder-oMmxz6nJ.js';
|
|
12
|
-
import { S as Svg, g as getContrastTextColor, a as getScenarioPrefix, I as IBCS_LAYER_ORDER, F as FontStyleAdapter, b as SVGStyleGroupAdapter, c as SVGStyleAdapter, d as SVGVariancesStyleGroupAdapter, P as PaddingAdapter } from './SVGVariancesStyleGroup-CqTjrZYg.js';
|
|
13
|
-
import { D as DataAnalyzer, S as SiPrefix, b as DataFormatDigitsAdapter } from './DataFormatDigits-oSZ1hBKE.js';
|
|
14
|
-
import { F as Formatter, C as CalculateSize, V as VarianceScenario } from './formatter-DTMEZ6d8.js';
|
|
15
|
-
import { a as alasql } from './alasql.min-CWu4NkIt.js';
|
|
16
|
-
import { S as StringAdapter, I as IBCSRuleSet } from './ibcsRuleSet-K4ytuA1f.js';
|
|
17
|
-
import './emotion-hash.esm-BYBpC0EO.js';
|
|
18
|
-
import './DateStringFactory-CSGz6TDk.js';
|
|
19
|
-
import './utils-DvvwfRQG.js';
|
|
20
|
-
import './_commonjsHelpers-BFTU3MAI.js';
|
|
21
|
-
|
|
22
|
-
const bnChartStructureCss$1 = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
23
|
-
|
|
24
|
-
const Chart = class {
|
|
25
|
-
validateScenario(newValue) {
|
|
26
|
-
const invalidScenarios = validateScenarioList(newValue);
|
|
27
|
-
const errId = "ERR_scenarios";
|
|
28
|
-
if (invalidScenarios.length > 0) {
|
|
29
|
-
this.errors.addOrReplace({
|
|
30
|
-
id: errId,
|
|
31
|
-
type: "warning",
|
|
32
|
-
message: "scenarios: invalid value(s) '" + JSON.stringify(invalidScenarios) + "' are not supported.",
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
this.errors.remove(errId);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
validateVariances(newValue) {
|
|
40
|
-
const errIdVar = "ERR_variances";
|
|
41
|
-
const invalidVariances = validateVariancesList(newValue);
|
|
42
|
-
if (invalidVariances.length > 0) {
|
|
43
|
-
this.errors.addOrReplace({
|
|
44
|
-
id: errIdVar,
|
|
45
|
-
type: "warning",
|
|
46
|
-
message: "variances: invalid value(s) '" + JSON.stringify(invalidVariances) + "' are not supported.",
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
this.errors.remove(errIdVar);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
validateUnitScaling(newValue) {
|
|
54
|
-
const errId = "ERR_unitScaling";
|
|
55
|
-
if (!isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
56
|
-
this.errors.addOrReplace({
|
|
57
|
-
id: errId,
|
|
58
|
-
type: "warning",
|
|
59
|
-
message: "unitScaling: invalid value(s) '" + newValue + "' are not supported.",
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
this.errors.remove(errId);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
validatePercentageScaling(newValue) {
|
|
67
|
-
const errId = "ERR_percentageScaling";
|
|
68
|
-
if (!isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
69
|
-
this.errors.addOrReplace({
|
|
70
|
-
id: errId,
|
|
71
|
-
type: "warning",
|
|
72
|
-
message: "percentageScaling: invalid value(s) '" + newValue + "' are not supported.",
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
this.errors.remove(errId);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
validateLevel(newValue) {
|
|
80
|
-
const errId = "ERR_level";
|
|
81
|
-
if (!isValidLevel(newValue)) {
|
|
82
|
-
this.errors.addOrReplace({
|
|
83
|
-
id: errId,
|
|
84
|
-
type: "warning",
|
|
85
|
-
message: "level: invalid value(s) '" + newValue + "' are not supported.",
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
this.errors.remove(errId);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
validateOrderList(newValue) {
|
|
93
|
-
const invalidElements = validateOrderList(newValue);
|
|
94
|
-
const errId = "ERR_order";
|
|
95
|
-
if (invalidElements.length > 0) {
|
|
96
|
-
this.errors.addOrReplace({
|
|
97
|
-
id: errId,
|
|
98
|
-
type: "warning",
|
|
99
|
-
message: "order: invalid value(s) '" + JSON.stringify(invalidElements) + "' are not supported.",
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
this.errors.remove(errId);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
validateOrderDirection(newValue) {
|
|
107
|
-
const errId = "ERR_orderDirection";
|
|
108
|
-
if (!isValidDirection(newValue)) {
|
|
109
|
-
this.errors.addOrReplace({
|
|
110
|
-
id: errId,
|
|
111
|
-
type: "warning",
|
|
112
|
-
message: "orderDirection: invalid value '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' is not supported.",
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
this.errors.remove(errId);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
validateLimit(newValue) {
|
|
120
|
-
const errId = "ERR_limit";
|
|
121
|
-
if (!isValidInteger(newValue)) {
|
|
122
|
-
this.errors.addOrReplace({
|
|
123
|
-
id: errId,
|
|
124
|
-
type: "warning",
|
|
125
|
-
message: "limit: invalid value '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' is not supported.",
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this.errors.remove(errId);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
validateShowCategories(newValue) {
|
|
133
|
-
const errId = "ERR_showCategories";
|
|
134
|
-
if (!isValidBoolean(newValue)) {
|
|
135
|
-
this.errors.addOrReplace({
|
|
136
|
-
id: errId,
|
|
137
|
-
type: "warning",
|
|
138
|
-
message: "showCategories: invalid value(s) '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' are not supported.",
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
this.errors.remove(errId);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
validateMeasureScale(newValue) {
|
|
146
|
-
const errId = "ERR_measureScale";
|
|
147
|
-
if (!isValidMeasureScale(newValue)) {
|
|
148
|
-
this.errors.addOrReplace({
|
|
149
|
-
id: errId,
|
|
150
|
-
type: "warning",
|
|
151
|
-
message: "measureScale: invalid value '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' is not supported.",
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
this.errors.remove(errId);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
validateShowMeasureScale(newValue) {
|
|
159
|
-
const errId = "ERR_grouped";
|
|
160
|
-
if (!isValidBoolean(newValue)) {
|
|
161
|
-
this.errors.addOrReplace({
|
|
162
|
-
id: errId,
|
|
163
|
-
type: "warning",
|
|
164
|
-
message: "showMeasureScale: invalid value(s) '" + (newValue === null || newValue === void 0 ? void 0 : newValue.toString()) + "' are not supported.",
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
this.errors.remove(errId);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
validateStack(newValue) {
|
|
172
|
-
const errId = "ERR_stack";
|
|
173
|
-
const errors = validateStackConfig(newValue);
|
|
174
|
-
if (errors.length > 0) {
|
|
175
|
-
this.errors.addOrReplace({
|
|
176
|
-
id: errId,
|
|
177
|
-
type: "warning",
|
|
178
|
-
message: errors.join("; "),
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
this.errors.remove(errId);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
validateScaling(newValue) {
|
|
186
|
-
if (newValue == null || newValue === "" || newValue === "none" || newValue === "auto") {
|
|
187
|
-
this.errors.remove("ERR_scale");
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
const num = Number(newValue);
|
|
191
|
-
if (isNaN(num) || num <= 0) {
|
|
192
|
-
this.errors.addOrReplace({
|
|
193
|
-
id: "ERR_scale",
|
|
194
|
-
type: "warning",
|
|
195
|
-
message: `Invalid scale value: "${newValue}". Use "none", "auto", or a positive number.`,
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
this.errors.remove("ERR_scale");
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
constructor(hostRef) {
|
|
203
|
-
registerInstance(this, hostRef);
|
|
204
|
-
this.data = [];
|
|
205
|
-
this.datasetMeta = null;
|
|
206
|
-
this.appliedScaleFactor = 1;
|
|
207
|
-
/**
|
|
208
|
-
* Title displayed above the chart. When empty, the title is derived
|
|
209
|
-
* from the variance scenario labels (if variances are configured).
|
|
210
|
-
*
|
|
211
|
-
* @example chart-title="Revenue by Category"
|
|
212
|
-
*/
|
|
213
|
-
this.chartTitle = "";
|
|
214
|
-
/**
|
|
215
|
-
* AlaSQL WHERE clause fragment injected into the data query to filter
|
|
216
|
-
* rows before rendering.
|
|
217
|
-
*
|
|
218
|
-
* @example filter="rowGroup = 'Revenue'"
|
|
219
|
-
*/
|
|
220
|
-
this.filter = "";
|
|
221
|
-
/**
|
|
222
|
-
* Maximum number of bars to display. Excess rows are aggregated into
|
|
223
|
-
* a "REST" summary bar. `0` means no limit (all rows are shown).
|
|
224
|
-
*
|
|
225
|
-
* @default 0
|
|
226
|
-
* @example limit="5"
|
|
227
|
-
*/
|
|
228
|
-
this.limit = 0;
|
|
229
|
-
/**
|
|
230
|
-
* Whether to display category labels on the left side of the chart.
|
|
231
|
-
*
|
|
232
|
-
* Values: `"true"` | `"false"`.
|
|
233
|
-
*
|
|
234
|
-
* @default "true"
|
|
235
|
-
* @example show-categories="false"
|
|
236
|
-
*/
|
|
237
|
-
this.showCategories = "true";
|
|
238
|
-
/**
|
|
239
|
-
* SI prefix applied to data values, dividing them for display
|
|
240
|
-
* (e.g. `"k"` divides by 1 000, showing 14 000 as "14").
|
|
241
|
-
*
|
|
242
|
-
* Common prefixes: `"k"` (×10³), `"M"` (×10⁶), `"G"` (×10⁹), `"T"` (×10¹²).
|
|
243
|
-
* Use `"_"` for no prefix (raw values).
|
|
244
|
-
*
|
|
245
|
-
* | Special value | Behavior |
|
|
246
|
-
* |---------------|--------------------------------------------------------------|
|
|
247
|
-
* | `"GREATEST"` | Auto-select prefix based on the largest value in the dataset |
|
|
248
|
-
* | `"LEAST"` | Auto-select prefix based on the smallest value |
|
|
249
|
-
*
|
|
250
|
-
* The selected prefix is shown in the chart footer when `show-measure-scale` is enabled.
|
|
251
|
-
*
|
|
252
|
-
* @default "greatest"
|
|
253
|
-
* @example measure-scale="k"
|
|
254
|
-
*/
|
|
255
|
-
this.measureScale = "greatest";
|
|
256
|
-
/**
|
|
257
|
-
* Toggles display of the SI prefix and unit label in the chart footer
|
|
258
|
-
* (e.g. "k EUR").
|
|
259
|
-
*
|
|
260
|
-
* Values: `"true"` | `"false"`.
|
|
261
|
-
*
|
|
262
|
-
* @default "false"
|
|
263
|
-
* @example show-measure-scale="true"
|
|
264
|
-
*/
|
|
265
|
-
this.showMeasureScale = "false";
|
|
266
|
-
/**
|
|
267
|
-
* Unit label displayed alongside the SI prefix in the chart footer
|
|
268
|
-
* (e.g. "EUR", "USD", "pcs"). Only visible when `show-measure-scale` is `"true"`.
|
|
269
|
-
*
|
|
270
|
-
* @default ""
|
|
271
|
-
* @example measure-unit="EUR"
|
|
272
|
-
*/
|
|
273
|
-
this.measureUnit = "";
|
|
274
|
-
/**
|
|
275
|
-
* Stacking configuration as a JSON string. When set, bars are drawn as
|
|
276
|
-
* stacked segments instead of side-by-side.
|
|
277
|
-
*
|
|
278
|
-
* **Properties:**
|
|
279
|
-
*
|
|
280
|
-
* | Key | Values | Description |
|
|
281
|
-
* |---------|-----------------------------------------------|----------------------------------------------------|
|
|
282
|
-
* | `by` | `"scenarios"` \| `"dimensions"` | **Required.** What to stack. |
|
|
283
|
-
* | `mode` | `"absolute"` \| `"relative"` \| `"absolute-relative"` | Stacking mode. Default: `"absolute"`. |
|
|
284
|
-
* | `order` | `"asc"` \| `"desc"` \| `"dataset"` | Segment sort order. Default: `"dataset"`. |
|
|
285
|
-
*
|
|
286
|
-
* - `by: "scenarios"` — stacks the scenarios listed in the `scenarios` prop end-to-end.
|
|
287
|
-
* - `by: "dimensions"` — stacks by the next-lower hierarchy level derived from `level`
|
|
288
|
-
* (e.g. level `"rowGroup"` stacks by category). Only the first scenario is used;
|
|
289
|
-
* extra scenarios trigger a `WARN_stack_dimensions_scenarios` warning.
|
|
290
|
-
* - `mode: "relative"` — normalizes each bar to 100%, showing proportions.
|
|
291
|
-
* - `mode: "absolute-relative"` — absolute bars with percentage labels.
|
|
292
|
-
*
|
|
293
|
-
* Segment colors are configurable via the `stackColors` array in component styles.
|
|
294
|
-
*
|
|
295
|
-
* @default "" (no stacking)
|
|
296
|
-
* @example stack='{"by":"scenarios","mode":"absolute"}'
|
|
297
|
-
* @example stack='{"by":"dimensions","mode":"relative"}'
|
|
298
|
-
*/
|
|
299
|
-
this.stack = "";
|
|
300
|
-
this.scenariosArray = [""];
|
|
301
|
-
this.pixelPerUnitGroupMap = new Map();
|
|
302
|
-
this._autoScaleGuard = false;
|
|
303
|
-
withStyled(this);
|
|
304
|
-
withComponentStatus(this);
|
|
305
|
-
withDataset(this, (_name, data) => {
|
|
306
|
-
this.data = (data || []);
|
|
307
|
-
}, (_name, meta) => {
|
|
308
|
-
this.datasetMeta = meta;
|
|
309
|
-
});
|
|
310
|
-
this.chartTemplate = this.chartTemplate.bind(this);
|
|
311
|
-
this.errors = withHasError(this);
|
|
312
|
-
this.componentStyle = withComponentStyle(this);
|
|
313
|
-
this.t = withTranslation(this).t;
|
|
314
|
-
}
|
|
315
|
-
componentWillLoad() {
|
|
316
|
-
this.validateScenario(this.scenarios);
|
|
317
|
-
this.validateVariances(this.variances);
|
|
318
|
-
this.validateUnitScaling(this.unitScaling);
|
|
319
|
-
//this.validateSelectedStyle(this.selectedStyle);
|
|
320
|
-
this.validateLevel(this.level);
|
|
321
|
-
this.validateOrderDirection(this.orderDirection);
|
|
322
|
-
this.validateOrderList(this.order);
|
|
323
|
-
this.validateShowCategories(this.showCategories);
|
|
324
|
-
this.validateMeasureScale(this.measureScale);
|
|
325
|
-
this.validateShowMeasureScale(this.showMeasureScale);
|
|
326
|
-
this.validateStack(this.stack);
|
|
327
|
-
this.validateScaling(this.scale);
|
|
328
|
-
}
|
|
329
|
-
componentDidRender() {
|
|
330
|
-
var _a, _b;
|
|
331
|
-
const { mode } = parseScaling(this.scale);
|
|
332
|
-
if (mode !== "auto" && mode !== "empty") {
|
|
333
|
-
this._autoScaleGuard = false;
|
|
334
|
-
this.checkWidthOverflow();
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
if (this._autoScaleGuard) {
|
|
338
|
-
this._autoScaleGuard = false;
|
|
339
|
-
this.checkWidthOverflow();
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
const host = this.element;
|
|
343
|
-
const { height: parentHeight } = getParentDimensions(host);
|
|
344
|
-
if (parentHeight <= 0) {
|
|
345
|
-
this.checkWidthOverflow();
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
// Measure at base (unscaled) font size to get true content height
|
|
349
|
-
const baseFontSize = this.componentStyle(($) => { var _a; return ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333; });
|
|
350
|
-
host.style.setProperty("--bn-font-size", `${baseFontSize}px`);
|
|
351
|
-
// Reading scrollHeight forces a synchronous reflow at base size
|
|
352
|
-
const div = (_a = host.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(".container");
|
|
353
|
-
const unscaledHeight = (_b = div === null || div === void 0 ? void 0 : div.scrollHeight) !== null && _b !== void 0 ? _b : host.scrollHeight;
|
|
354
|
-
if (unscaledHeight <= parentHeight + 1) {
|
|
355
|
-
this.errors.remove("AUTO_scale");
|
|
356
|
-
if (this.appliedScaleFactor !== 1) {
|
|
357
|
-
this._autoScaleGuard = true;
|
|
358
|
-
this.appliedScaleFactor = 1;
|
|
359
|
-
}
|
|
360
|
-
this.checkWidthOverflow();
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
const computedFactor = (parentHeight - 1) / unscaledHeight;
|
|
364
|
-
host.style.setProperty("--bn-font-size", `${baseFontSize * computedFactor}px`);
|
|
365
|
-
if (mode === "empty") {
|
|
366
|
-
this.errors.addOrReplace({
|
|
367
|
-
id: "AUTO_scale",
|
|
368
|
-
type: "warning",
|
|
369
|
-
message: `Auto-scaled chart by factor ${computedFactor.toFixed(3)}`,
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
else {
|
|
373
|
-
this.errors.remove("AUTO_scale");
|
|
374
|
-
}
|
|
375
|
-
if (Math.abs(computedFactor - this.appliedScaleFactor) > 0.001) {
|
|
376
|
-
this._autoScaleGuard = true;
|
|
377
|
-
this.appliedScaleFactor = computedFactor;
|
|
378
|
-
}
|
|
379
|
-
this.checkWidthOverflow();
|
|
380
|
-
}
|
|
381
|
-
/**
|
|
382
|
-
* Emits an error when a custom unit-scaling value causes the chart to exceed its container width.
|
|
383
|
-
* Skipped for auto/unset unit-scaling since auto-fit handles width.
|
|
384
|
-
*/
|
|
385
|
-
checkWidthOverflow() {
|
|
386
|
-
var _a;
|
|
387
|
-
const errId = "WARN_overflow";
|
|
388
|
-
const us = String((_a = this.unitScaling) !== null && _a !== void 0 ? _a : "")
|
|
389
|
-
.trim()
|
|
390
|
-
.toLowerCase();
|
|
391
|
-
if (us === "" || us === "auto") {
|
|
392
|
-
this.errors.remove(errId);
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
const parent = getParentDimensions(this.element);
|
|
396
|
-
if (parent.width > 0 && this.element.scrollWidth > parent.width + 1) {
|
|
397
|
-
this.errors.addOrReplace({
|
|
398
|
-
id: errId,
|
|
399
|
-
type: "error",
|
|
400
|
-
message: `Chart exceeds available width (${this.element.scrollWidth}px > ${Math.round(parent.width)}px). Reduce unit-scaling or set to "auto".`,
|
|
401
|
-
});
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
this.errors.remove(errId);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
prepareDimension() {
|
|
408
|
-
const parent = getParentDimensions(this.element);
|
|
409
|
-
this.canvasWidthSegmented = parent.width / this.scenariosArray.length;
|
|
410
|
-
return { width: this.canvasWidthSegmented, height: parent.height };
|
|
411
|
-
}
|
|
412
|
-
prepareScenarios() {
|
|
413
|
-
var _a, _b, _c, _d;
|
|
414
|
-
const isAuto = ((_a = this.scenarios) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
|
|
415
|
-
if (isBlankInput(this.scenarios) || isAuto) {
|
|
416
|
-
if (((_c = (_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.availableScenarios) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
417
|
-
if (!isAuto) {
|
|
418
|
-
this.errors.addOrReplace({
|
|
419
|
-
id: "AUTO_scenarios",
|
|
420
|
-
type: "warning",
|
|
421
|
-
message: `scenarios: not set, auto-detected: ${this.datasetMeta.availableScenarios.join(",")}`,
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
this.errors.remove("AUTO_scenarios");
|
|
426
|
-
}
|
|
427
|
-
return this.datasetMeta.availableScenarios;
|
|
428
|
-
}
|
|
429
|
-
return [];
|
|
430
|
-
}
|
|
431
|
-
this.errors.remove("AUTO_scenarios");
|
|
432
|
-
return (_d = this.scenarios) === null || _d === void 0 ? void 0 : _d.split(",").map((entry) => entry.trim());
|
|
433
|
-
}
|
|
434
|
-
prepareVariances() {
|
|
435
|
-
var _a;
|
|
436
|
-
if (isBlankInput(this.variances)) {
|
|
437
|
-
return [];
|
|
438
|
-
}
|
|
439
|
-
return (_a = this.variances) === null || _a === void 0 ? void 0 : _a.split(",").map((entry) => entry.trim());
|
|
440
|
-
}
|
|
441
|
-
prepareHideCategories(idx) {
|
|
442
|
-
return idx >= 1 || this.showCategories !== "true";
|
|
443
|
-
}
|
|
444
|
-
prepareI18n() {
|
|
445
|
-
const i18nMetaLabelsLocal = [];
|
|
446
|
-
const i18nMetaLabelsGlobal = globalLabelKeys;
|
|
447
|
-
const i18nMapLocal = new Map(i18nMetaLabelsLocal.map((key) => [key, this.t(".".concat(key))]));
|
|
448
|
-
const i18nMapGlobal = new Map(i18nMetaLabelsGlobal.map((key) => [key, this.t("global.".concat(key))]));
|
|
449
|
-
return new Map([...i18nMapGlobal.entries(), ...i18nMapLocal.entries()]);
|
|
450
|
-
}
|
|
451
|
-
preparePixelPerUnit() {
|
|
452
|
-
var _a;
|
|
453
|
-
if (this.pixelPerUnitGroupMap.has(this.unitScaling)) {
|
|
454
|
-
this.errors.remove("AUTO_unitScaling");
|
|
455
|
-
return this.pixelPerUnitGroupMap.get(this.unitScaling);
|
|
456
|
-
}
|
|
457
|
-
// Explicit 'auto' → auto-calculate silently
|
|
458
|
-
if (((_a = this.unitScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
|
|
459
|
-
this.errors.remove("AUTO_unitScaling");
|
|
460
|
-
return 0;
|
|
461
|
-
}
|
|
462
|
-
const numeric = Number(this.unitScaling);
|
|
463
|
-
if (!isNaN(numeric) && numeric > 0) {
|
|
464
|
-
this.errors.remove("AUTO_unitScaling");
|
|
465
|
-
return numeric;
|
|
466
|
-
}
|
|
467
|
-
// Not set / invalid → auto-calculate with warning
|
|
468
|
-
this.errors.addOrReplace({
|
|
469
|
-
id: "AUTO_unitScaling",
|
|
470
|
-
type: "warning",
|
|
471
|
-
message: `unit-scaling: not set, auto-calculated to fit available space.`,
|
|
472
|
-
});
|
|
473
|
-
return 0;
|
|
474
|
-
}
|
|
475
|
-
preparePixelPerPercentage() {
|
|
476
|
-
if (this.pixelPerUnitGroupMap.has(this.percentageScaling)) {
|
|
477
|
-
return this.pixelPerUnitGroupMap.get(this.percentageScaling);
|
|
478
|
-
}
|
|
479
|
-
return Number(this.percentageScaling) * 100;
|
|
480
|
-
}
|
|
481
|
-
prepareLevel() {
|
|
482
|
-
var _a, _b, _c;
|
|
483
|
-
const isAuto = ((_a = this.level) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
|
|
484
|
-
if (isBlankInput(this.level) || isAuto) {
|
|
485
|
-
if ((_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.suggestedLevel) {
|
|
486
|
-
if (!isAuto) {
|
|
487
|
-
this.errors.addOrReplace({
|
|
488
|
-
id: "AUTO_level",
|
|
489
|
-
type: "warning",
|
|
490
|
-
message: `level: not set, auto-detected: ${this.datasetMeta.suggestedLevel}`,
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
494
|
-
this.errors.remove("AUTO_level");
|
|
495
|
-
}
|
|
496
|
-
return AggregationLevel[this.datasetMeta.suggestedLevel.toUpperCase()];
|
|
497
|
-
}
|
|
498
|
-
return undefined;
|
|
499
|
-
}
|
|
500
|
-
this.errors.remove("AUTO_level");
|
|
501
|
-
return AggregationLevel[(_c = this.level) === null || _c === void 0 ? void 0 : _c.toUpperCase()];
|
|
502
|
-
}
|
|
503
|
-
prepareOrder() {
|
|
504
|
-
var _a, _b, _c;
|
|
505
|
-
const isAuto = ((_a = this.order) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) === "auto";
|
|
506
|
-
let orderStr;
|
|
507
|
-
if (isBlankInput(this.order) || isAuto) {
|
|
508
|
-
if ((_b = this.datasetMeta) === null || _b === void 0 ? void 0 : _b.suggestedOrder) {
|
|
509
|
-
if (!isAuto) {
|
|
510
|
-
this.errors.addOrReplace({
|
|
511
|
-
id: "AUTO_order",
|
|
512
|
-
type: "warning",
|
|
513
|
-
message: `order: not set, auto-detected: ${this.datasetMeta.suggestedOrder}`,
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
else {
|
|
517
|
-
this.errors.remove("AUTO_order");
|
|
518
|
-
}
|
|
519
|
-
orderStr = this.datasetMeta.suggestedOrder;
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
orderStr = this.order;
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
else {
|
|
526
|
-
this.errors.remove("AUTO_order");
|
|
527
|
-
orderStr = this.order;
|
|
528
|
-
}
|
|
529
|
-
const tableOrder = {
|
|
530
|
-
hierarchy: orderStr === null || orderStr === void 0 ? void 0 : orderStr.split(",").map((entry) => OrderColumn[entry === null || entry === void 0 ? void 0 : entry.toUpperCase()]),
|
|
531
|
-
direction: OrderDirection[(_c = this.orderDirection) === null || _c === void 0 ? void 0 : _c.toUpperCase()],
|
|
532
|
-
};
|
|
533
|
-
return tableOrder;
|
|
534
|
-
}
|
|
535
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
536
|
-
prepareStyle() {
|
|
537
|
-
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
538
|
-
return this.componentStyle(($) => {
|
|
539
|
-
const baseFontSize = $["global"]["fontSizePx"];
|
|
540
|
-
const scaledFontSize = baseFontSize * effectiveFactor;
|
|
541
|
-
return {
|
|
542
|
-
scaleFactors: {
|
|
543
|
-
scenarioOffset: $["bn-chart-structure"]["scaleFactors"]["scenarioOffset"],
|
|
544
|
-
scenarioLabelToBar: $["bn-chart-structure"]["scaleFactors"]["scenarioLabelToBar"],
|
|
545
|
-
labelToBar: $["bn-chart-structure"]["scaleFactors"]["labelToBar"],
|
|
546
|
-
labelToAxis: $["bn-chart-structure"]["scaleFactors"]["labelToAxis"],
|
|
547
|
-
needleWidth: $["bn-chart-structure"]["scaleFactors"]["needleWidth"],
|
|
548
|
-
needleHeadWidth: $["bn-chart-structure"]["scaleFactors"]["needleHeadWidth"],
|
|
549
|
-
barWidth: $["bn-chart-structure"]["scaleFactors"]["barWidth"],
|
|
550
|
-
varianceAxisLineWidth: $["bn-chart-structure"]["scaleFactors"]["varianceAxisLineWidth"],
|
|
551
|
-
axisLineWidth: $["bn-chart-structure"]["scaleFactors"]["axisLineWidth"],
|
|
552
|
-
auxiliaryLineWidth: $["bn-chart-structure"]["scaleFactors"]["auxiliaryLineWidth"],
|
|
553
|
-
scenarioLineWidth: $["bn-chart-structure"]["scaleFactors"]["scenarioLineWidth"],
|
|
554
|
-
markerWidth: $["bn-chart-structure"]["scaleFactors"]["markerWidth"],
|
|
555
|
-
markerOffset: $["bn-chart-structure"]["scaleFactors"]["markerOffset"],
|
|
556
|
-
categoryWidth: $["bn-chart-structure"]["scaleFactors"]["categoryWidth"],
|
|
557
|
-
axisTickLength: $["bn-chart-structure"]["scaleFactors"]["axisTickLength"],
|
|
558
|
-
},
|
|
559
|
-
fontStyles: {
|
|
560
|
-
font: `${scaledFontSize}px ${$["global"]["fontFamily"]}`,
|
|
561
|
-
size: scaledFontSize,
|
|
562
|
-
color: $["global"]["fontColor"],
|
|
563
|
-
background: $["global"]["fontBackgroundColor"],
|
|
564
|
-
leading: 1.8,
|
|
565
|
-
},
|
|
566
|
-
axisStyles: $["bn-chart-structure"]["axisStyles"],
|
|
567
|
-
barStyles: $["bn-chart-structure"]["barStyles"],
|
|
568
|
-
varianceStyles: $["bn-chart-structure"]["varianceStyles"],
|
|
569
|
-
padding: $["bn-chart-structure"]["padding"],
|
|
570
|
-
pattern: null,
|
|
571
|
-
};
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
prepareChartTitle(idx) {
|
|
575
|
-
if (idx >= 1) {
|
|
576
|
-
return "";
|
|
577
|
-
}
|
|
578
|
-
return this.chartTitle;
|
|
579
|
-
}
|
|
580
|
-
prepareStackConfig() {
|
|
581
|
-
if (isBlankInput(this.stack)) {
|
|
582
|
-
this.errors.remove("WARN_stack_dimensions_scenarios");
|
|
583
|
-
return null;
|
|
584
|
-
}
|
|
585
|
-
try {
|
|
586
|
-
const parsed = JSON.parse(this.stack);
|
|
587
|
-
const by = parsed.by;
|
|
588
|
-
const errId = "WARN_stack_dimensions_scenarios";
|
|
589
|
-
if (by === StackBy.DIMENSIONS) {
|
|
590
|
-
const scenarios = this.prepareScenarios();
|
|
591
|
-
if (scenarios.length > 1) {
|
|
592
|
-
this.errors.addOrReplace({
|
|
593
|
-
id: errId,
|
|
594
|
-
type: "warning",
|
|
595
|
-
message: `stack by dimensions: only the first scenario "${scenarios[0]}" is used, the rest (${scenarios.slice(1).join(", ")}) are discarded.`,
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
else {
|
|
599
|
-
this.errors.remove(errId);
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
else {
|
|
603
|
-
this.errors.remove(errId);
|
|
604
|
-
}
|
|
605
|
-
return {
|
|
606
|
-
by,
|
|
607
|
-
mode: parsed.mode || StackMode.ABSOLUTE,
|
|
608
|
-
order: parsed.order || StackOrder.DATASET,
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
catch (_a) {
|
|
612
|
-
this.errors.remove("WARN_stack_dimensions_scenarios");
|
|
613
|
-
return null;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
prepareFilter() {
|
|
617
|
-
if (this.filter.length === 0) {
|
|
618
|
-
return "";
|
|
619
|
-
}
|
|
620
|
-
return this.filter;
|
|
621
|
-
}
|
|
622
|
-
prepareLimit() {
|
|
623
|
-
return Math.floor(Number(this.limit) || 0);
|
|
624
|
-
}
|
|
625
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
626
|
-
getDataStructure() {
|
|
627
|
-
const dataSetStructure = {
|
|
628
|
-
IStructureChartDataRow: {
|
|
629
|
-
operation: { type: "string", isOptional: false, description: "" },
|
|
630
|
-
rowGroup: { type: "string", isOptional: false, description: "" },
|
|
631
|
-
rowGroupIndex: { type: "number", isOptional: false, description: "" },
|
|
632
|
-
category: { type: "string", isOptional: false, description: "" },
|
|
633
|
-
categoryIndex: { type: "number", isOptional: false, description: "" },
|
|
634
|
-
subCategory: { type: "string", isOptional: false, description: "" },
|
|
635
|
-
subCategoryIndex: { type: "number", isOptional: false, description: "" },
|
|
636
|
-
columnGroup: { type: "string", isOptional: false, description: "" },
|
|
637
|
-
columnGroupIndex: { type: "number", isOptional: false, description: "" },
|
|
638
|
-
columnSubGroup: { type: "string", isOptional: false, description: "" },
|
|
639
|
-
columnSubGroupIndex: { type: "number", isOptional: false, description: "" },
|
|
640
|
-
ac1: { type: "number", isOptional: false, description: "" },
|
|
641
|
-
ac2: { type: "number", isOptional: false, description: "" },
|
|
642
|
-
ac3: { type: "number", isOptional: false, description: "" },
|
|
643
|
-
ac4: { type: "number", isOptional: false, description: "" },
|
|
644
|
-
pp1: { type: "number", isOptional: false, description: "" },
|
|
645
|
-
pp2: { type: "number", isOptional: false, description: "" },
|
|
646
|
-
pp3: { type: "number", isOptional: false, description: "" },
|
|
647
|
-
pp4: { type: "number", isOptional: false, description: "" },
|
|
648
|
-
fc1: { type: "number", isOptional: false, description: "" },
|
|
649
|
-
fc2: { type: "number", isOptional: false, description: "" },
|
|
650
|
-
fc3: { type: "number", isOptional: false, description: "" },
|
|
651
|
-
fc4: { type: "number", isOptional: false, description: "" },
|
|
652
|
-
pl1: { type: "number", isOptional: false, description: "" },
|
|
653
|
-
pl2: { type: "number", isOptional: false, description: "" },
|
|
654
|
-
pl3: { type: "number", isOptional: false, description: "" },
|
|
655
|
-
pl4: { type: "number", isOptional: false, description: "" },
|
|
656
|
-
},
|
|
657
|
-
};
|
|
658
|
-
return dataSetStructure;
|
|
659
|
-
}
|
|
660
|
-
prepareMeasureScale() {
|
|
661
|
-
if (isBlankInput(this.measureScale)) {
|
|
662
|
-
return "GREATEST";
|
|
663
|
-
}
|
|
664
|
-
if (["_", "k", "M", "G", "T", "P", "E", "Z", "Y", "m", "μ", "n", "p", "P", "f", "a", "z", "y"].includes(this.measureScale.trim())) {
|
|
665
|
-
return this.measureScale.trim();
|
|
666
|
-
}
|
|
667
|
-
if (this.measureScale.trim().toUpperCase() === "LEAST") {
|
|
668
|
-
return this.measureScale.trim();
|
|
669
|
-
}
|
|
670
|
-
return "GREATEST";
|
|
671
|
-
}
|
|
672
|
-
prepareShowMeasureScale(idx) {
|
|
673
|
-
return idx === 0 && this.showMeasureScale === "true";
|
|
674
|
-
}
|
|
675
|
-
prepareMeasureUnit() {
|
|
676
|
-
if (this.measureUnit === "" || this.measureUnit == null) {
|
|
677
|
-
return "";
|
|
678
|
-
}
|
|
679
|
-
return this.measureUnit;
|
|
680
|
-
}
|
|
681
|
-
chartTemplate(localScenarioString, idx) {
|
|
682
|
-
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
683
|
-
const ppu = this.preparePixelPerUnit();
|
|
684
|
-
const ppp = this.preparePixelPerPercentage();
|
|
685
|
-
const stackConfig = this.prepareStackConfig();
|
|
686
|
-
const scenarios = this.prepareScenarios();
|
|
687
|
-
// Dimension stacking uses only the first scenario
|
|
688
|
-
const effectiveScenarios = (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
|
|
689
|
-
return (h("ibcs-chart-structure", { data: this.data, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: [localScenarioString], hideCategories: this.prepareHideCategories(idx), pixelPerUnit: ppu > 0 ? ppu * effectiveFactor : 0, pixelPerPercentage: ppp > 0 ? ppp * effectiveFactor : 0, limit: this.prepareLimit(), styles: this.prepareStyle(), i18n: this.prepareI18n(), order: this.prepareOrder(), level: this.prepareLevel(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(idx), stackConfig: stackConfig, parentDimensions: this.prepareDimension() }));
|
|
690
|
-
}
|
|
691
|
-
getEffectiveScaleFactor() {
|
|
692
|
-
const { mode, factor } = parseScaling(this.scale);
|
|
693
|
-
if (mode === "factor")
|
|
694
|
-
return factor;
|
|
695
|
-
if (mode === "auto" || mode === "empty")
|
|
696
|
-
return this.appliedScaleFactor;
|
|
697
|
-
return 1;
|
|
698
|
-
}
|
|
699
|
-
getFontStyles() {
|
|
700
|
-
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
701
|
-
return this.componentStyle(($) => {
|
|
702
|
-
var _a, _b, _c, _d;
|
|
703
|
-
const baseFontSize = ((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333;
|
|
704
|
-
return {
|
|
705
|
-
"--bn-font-family": ((_b = $["global"]) === null || _b === void 0 ? void 0 : _b["fontFamily"]) || "'Noto Sans', sans-serif",
|
|
706
|
-
"--bn-font-size": `${baseFontSize * effectiveFactor}px`,
|
|
707
|
-
"--bn-font-color": ((_c = $["global"]) === null || _c === void 0 ? void 0 : _c["fontColor"]) || "#000000",
|
|
708
|
-
"--bn-font-background": ((_d = $["global"]) === null || _d === void 0 ? void 0 : _d["fontBackgroundColor"]) || "#ffffff",
|
|
709
|
-
};
|
|
710
|
-
});
|
|
711
|
-
}
|
|
712
|
-
render() {
|
|
713
|
-
let scenariosArray = [""];
|
|
714
|
-
const variancesArray = this.prepareVariances();
|
|
715
|
-
if (variancesArray.length > 0) {
|
|
716
|
-
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
717
|
-
}
|
|
718
|
-
const fontStyles = this.getFontStyles();
|
|
719
|
-
return (h(Host, { key: '570fb741ddf481be0f3055d346314ad39a455361', style: fontStyles }, h("div", { key: 'e84cfe2e00dd2f960f038844e00449431efa6ce0', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
720
|
-
}
|
|
721
|
-
get element() { return getElement(this); }
|
|
722
|
-
static get watchers() { return {
|
|
723
|
-
"scenarios": [{
|
|
724
|
-
"validateScenario": 0
|
|
725
|
-
}],
|
|
726
|
-
"variances": [{
|
|
727
|
-
"validateVariances": 0
|
|
728
|
-
}],
|
|
729
|
-
"unitScaling": [{
|
|
730
|
-
"validateUnitScaling": 0
|
|
731
|
-
}],
|
|
732
|
-
"percentageScaling": [{
|
|
733
|
-
"validatePercentageScaling": 0
|
|
734
|
-
}],
|
|
735
|
-
"level": [{
|
|
736
|
-
"validateLevel": 0
|
|
737
|
-
}],
|
|
738
|
-
"order": [{
|
|
739
|
-
"validateOrderList": 0
|
|
740
|
-
}],
|
|
741
|
-
"orderDirection": [{
|
|
742
|
-
"validateOrderDirection": 0
|
|
743
|
-
}],
|
|
744
|
-
"limit": [{
|
|
745
|
-
"validateLimit": 0
|
|
746
|
-
}],
|
|
747
|
-
"showCategories": [{
|
|
748
|
-
"validateShowCategories": 0
|
|
749
|
-
}],
|
|
750
|
-
"measureScale": [{
|
|
751
|
-
"validateMeasureScale": 0
|
|
752
|
-
}],
|
|
753
|
-
"showMeasureScale": [{
|
|
754
|
-
"validateShowMeasureScale": 0
|
|
755
|
-
}],
|
|
756
|
-
"stack": [{
|
|
757
|
-
"validateStack": 0
|
|
758
|
-
}],
|
|
759
|
-
"scale": [{
|
|
760
|
-
"validateScaling": 0
|
|
761
|
-
}]
|
|
762
|
-
}; }
|
|
763
|
-
};
|
|
764
|
-
Chart.style = bnChartStructureCss$1();
|
|
765
|
-
|
|
766
|
-
const bnContextCss = () => `:host{display:block}`;
|
|
767
|
-
|
|
768
|
-
const Context = class {
|
|
769
|
-
constructor(hostRef) {
|
|
770
|
-
registerInstance(this, hostRef);
|
|
771
|
-
this.currentPageUpdate = undefined;
|
|
772
|
-
withComponentStatus(this);
|
|
773
|
-
this.errors = withHasError(this);
|
|
774
|
-
}
|
|
775
|
-
setLocale(newValue) {
|
|
776
|
-
this.stores.context.state.locale = newValue;
|
|
777
|
-
}
|
|
778
|
-
connectedCallback() {
|
|
779
|
-
// Retrieve (or create) the stores for this context element.
|
|
780
|
-
// A descendant component may have already triggered creation via
|
|
781
|
-
// getStores() if Stencil initialized it before this component.
|
|
782
|
-
this.stores = getOrCreateStores(this.element);
|
|
783
|
-
if (this.locale) {
|
|
784
|
-
this.stores.context.state.locale = this.locale;
|
|
785
|
-
}
|
|
786
|
-
this.currentPageUpdate = setTimeout(() => {
|
|
787
|
-
this.element.querySelectorAll("bn-page, bn-layout-page").forEach((page, index) => {
|
|
788
|
-
if (page.localName === "bn-layout-page") {
|
|
789
|
-
page.setAttribute("page-number", (index + 1).toString());
|
|
790
|
-
}
|
|
791
|
-
else {
|
|
792
|
-
const footer = page.querySelector("bn-footer");
|
|
793
|
-
if (footer) {
|
|
794
|
-
// @ts-ignore
|
|
795
|
-
footer.setAttribute("page-number", (index + 1).toString());
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
}, 250);
|
|
800
|
-
}
|
|
801
|
-
disconnectedCallback() {
|
|
802
|
-
if (this.currentPageUpdate) {
|
|
803
|
-
clearTimeout(this.currentPageUpdate);
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
componentWillLoad() {
|
|
807
|
-
// stencil needs one componenet implementing all lifecycle steps to get mixing working
|
|
808
|
-
}
|
|
809
|
-
componentDidLoad() { }
|
|
810
|
-
componentShouldUpdate() { }
|
|
811
|
-
componentWillRender() { }
|
|
812
|
-
componentDidRender() { }
|
|
813
|
-
componentWillUpdate() { }
|
|
814
|
-
componentDidUpdate() { }
|
|
815
|
-
render() {
|
|
816
|
-
return (h(Host, { key: 'b92019b909e271225baca2cf740c8301e324164e' }, h("slot", { key: '87bac4bb29bca32d961afe31355dc1bd48fff0f8' })));
|
|
817
|
-
}
|
|
818
|
-
get element() { return getElement(this); }
|
|
819
|
-
static get watchers() { return {
|
|
820
|
-
"locale": [{
|
|
821
|
-
"setLocale": 0
|
|
822
|
-
}]
|
|
823
|
-
}; }
|
|
824
|
-
};
|
|
825
|
-
Context.style = bnContextCss();
|
|
826
|
-
|
|
827
|
-
const bnDatasourceCss = () => `bn-datasource{display:none}`;
|
|
828
|
-
|
|
829
|
-
const Datasource = class {
|
|
830
|
-
constructor(hostRef) {
|
|
831
|
-
registerInstance(this, hostRef);
|
|
832
|
-
/**
|
|
833
|
-
* When true (default), body content is plain JSON text.
|
|
834
|
-
* When false, body content is a compressed payload (`<hash>:<base64_gzip>`).
|
|
835
|
-
*/
|
|
836
|
-
this.raw = true;
|
|
837
|
-
this.lastHash = null;
|
|
838
|
-
withComponentStatus(this);
|
|
839
|
-
this.errors = withHasError(this);
|
|
840
|
-
withBodyObserver(this, (data) => {
|
|
841
|
-
if (!this.stores)
|
|
842
|
-
this.stores = getStores(this.element);
|
|
843
|
-
try {
|
|
844
|
-
let contentHash;
|
|
845
|
-
let jsonString;
|
|
846
|
-
if (this.raw) {
|
|
847
|
-
contentHash = computeContentHash(data);
|
|
848
|
-
jsonString = data;
|
|
849
|
-
}
|
|
850
|
-
else {
|
|
851
|
-
const decoded = decodeCompressedContent(data);
|
|
852
|
-
contentHash = decoded.hash;
|
|
853
|
-
jsonString = decoded.json;
|
|
854
|
-
}
|
|
855
|
-
if (contentHash === this.lastHash)
|
|
856
|
-
return;
|
|
857
|
-
this.lastHash = contentHash;
|
|
858
|
-
const json = JSON.parse(jsonString);
|
|
859
|
-
// @ts-ignore
|
|
860
|
-
this.stores.datasources.set(this.name, json);
|
|
861
|
-
}
|
|
862
|
-
catch (e) {
|
|
863
|
-
console.error("Error parsing datasource", e, String(data).slice(0, 200));
|
|
864
|
-
// @ts-ignore
|
|
865
|
-
this.stores.datasources.set(this.name, []);
|
|
866
|
-
}
|
|
867
|
-
});
|
|
868
|
-
}
|
|
869
|
-
render() {
|
|
870
|
-
return h(Host, { key: '43b691b07f63d12ad6c835dfb5d5bf6053b3bbf4' });
|
|
871
|
-
}
|
|
872
|
-
get element() { return getElement(this); }
|
|
873
|
-
};
|
|
874
|
-
Datasource.style = bnDatasourceCss();
|
|
875
|
-
|
|
876
|
-
const bnPageCss = () => `:host{background:var(--bn-font-background, white);color:var(--bn-font-color, black);font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);height:768px;width:1024px;display:flex;flex-direction:column;page-break-after:always;overflow:hidden}:host([format=xga]){height:768px;width:1024px}:host([format=xga][orientation=portrait]){height:1024px;width:768px}:host([format=xga][orientation=landscape]){height:768px;width:1024px}:host([format=hd]){height:720px;width:1280px}:host([format=hd][orientation=portrait]){height:1280px;width:720px}:host([format=hd][orientation=landscape]){height:720px;width:1280px}:host([format=full_hd]){height:1080px;width:1920px}:host([format=full_hd][orientation=portrait]){height:1920px;width:1080px}:host([format=full_hd][orientation=landscape]){height:1080px;width:1920px}:host([format="4k"]){height:2160px;width:3840px}:host([format="4k"][orientation=portrait]){height:3840px;width:2160px}:host([format="4k"][orientation=landscape]){height:2160px;width:3840px}:host([format="4k2k"]){height:2160px;width:4096px}:host([format="4k2k"][orientation=portrait]){height:4096px;width:2160px}:host([format="4k2k"][orientation=landscape]){height:2160px;width:4096px}:host([format=a6]){height:5.83in;width:4.13in}:host([format=a6][orientation=portrait]){height:5.83in;width:4.13in}:host([format=a6][orientation=landscape]){height:4.13in;width:5.83in}:host([format=a5]){height:8.27in;width:5.83in}:host([format=a5][orientation=portrait]){height:8.27in;width:5.83in}:host([format=a5][orientation=landscape]){height:5.83in;width:8.27in}:host([format=a4]){height:11.6in;width:8.17in}:host([format=a4][orientation=portrait]){height:11.6in;width:8.17in}:host([format=a4][orientation=landscape]){height:8.17in;width:11.6in}:host([format=a3]){height:16.54in;width:11.7in}:host([format=a3][orientation=portrait]){height:16.54in;width:11.7in}:host([format=a3][orientation=landscape]){height:11.7in;width:16.54in}:host([format=a2]){height:23.4in;width:16.54in}:host([format=a2][orientation=portrait]){height:23.4in;width:16.54in}:host([format=a2][orientation=landscape]){height:16.54in;width:23.4in}:host([format=a1]){height:33.1in;width:23.4in}:host([format=a1][orientation=portrait]){height:33.1in;width:23.4in}:host([format=a1][orientation=landscape]){height:23.4in;width:33.1in}:host([format=a0]){height:46.8in;width:33.1in}:host([format=a0][orientation=portrait]){height:46.8in;width:33.1in}:host([format=a0][orientation=landscape]){height:33.1in;width:46.8in}:host([format=letter]){height:11in;width:8.5in}:host([format=letter][orientation=portrait]){height:11in;width:8.5in}:host([format=letter][orientation=landscape]){height:8.5in;width:11in}:host([format=legal]){height:14in;width:8.5in}:host([format=legal][orientation=portrait]){height:14in;width:8.5in}:host([format=legal][orientation=landscape]){height:8.5in;width:14in}:host([format=tabloid]){height:17in;width:11in}:host([format=tabloid][orientation=portrait]){height:17in;width:11in}:host([format=tabloid][orientation=landscape]){height:11in;width:17in}:host([format=ledger]){height:11in;width:17in}:host([format=ledger][orientation=portrait]){height:17in;width:11in}:host([format=ledger][orientation=landscape]){height:11in;width:17in}`;
|
|
877
|
-
|
|
878
|
-
const VALID_FORMATS = ["xga", "hd", "full-hd", "4k", "4k2k", "a4", "a3", "a2", "a1", "a0", "letter", "legal"];
|
|
879
|
-
const VALID_ORIENTATIONS = ["landscape", "portrait"];
|
|
880
|
-
const Page = class {
|
|
881
|
-
constructor(hostRef) {
|
|
882
|
-
registerInstance(this, hostRef);
|
|
883
|
-
withComponentStatus(this);
|
|
884
|
-
this.errors = withHasError(this);
|
|
885
|
-
this.componentStyle = withComponentStyle(this);
|
|
886
|
-
}
|
|
887
|
-
validateFormat(newValue) {
|
|
888
|
-
const errId = "ERR_format";
|
|
889
|
-
if (!isBlankInput(newValue) && !VALID_FORMATS.includes(newValue)) {
|
|
890
|
-
this.errors.addOrReplace({
|
|
891
|
-
id: errId,
|
|
892
|
-
type: "warning",
|
|
893
|
-
message: `format: invalid value '${newValue}' is not supported. Valid values: ${VALID_FORMATS.join(", ")}`,
|
|
894
|
-
});
|
|
895
|
-
}
|
|
896
|
-
else {
|
|
897
|
-
this.errors.remove(errId);
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
validateOrientation(newValue) {
|
|
901
|
-
const errId = "ERR_orientation";
|
|
902
|
-
if (!isBlankInput(newValue) && !VALID_ORIENTATIONS.includes(newValue)) {
|
|
903
|
-
this.errors.addOrReplace({
|
|
904
|
-
id: errId,
|
|
905
|
-
type: "warning",
|
|
906
|
-
message: `orientation: invalid value '${newValue}' is not supported. Valid values: ${VALID_ORIENTATIONS.join(", ")}`,
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
|
-
else {
|
|
910
|
-
this.errors.remove(errId);
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
render() {
|
|
914
|
-
return (h(Host, { key: 'b4d682a8f6e83f77c58236265eaf9d1327809c6f', format: this.format, orientation: this.orientation, style: this.prepareStyle() }, h("slot", { key: 'ef49c43c1f8926c4c968b752608627adbe330d6c' })));
|
|
915
|
-
}
|
|
916
|
-
prepareStyle() {
|
|
917
|
-
const pageStyle = {
|
|
918
|
-
"font-family": this.componentStyle(($) => $.global["fontFamily"]),
|
|
919
|
-
"font-size": `${this.componentStyle(($) => $.global["fontSizePx"])}px`,
|
|
920
|
-
"--bn-font-family": this.componentStyle(($) => $.global["fontFamily"]) || "'Noto Sans', sans-serif",
|
|
921
|
-
"--bn-font-size": `${this.componentStyle(($) => $.global["fontSizePx"]) || 13.3333}px`,
|
|
922
|
-
"--bn-font-color": this.componentStyle(($) => $.global["fontColor"]) || "#000000",
|
|
923
|
-
"--bn-font-background": this.componentStyle(($) => $.global["fontBackgroundColor"]) || "#ffffff",
|
|
924
|
-
};
|
|
925
|
-
return pageStyle;
|
|
926
|
-
}
|
|
927
|
-
get element() { return getElement(this); }
|
|
928
|
-
static get watchers() { return {
|
|
929
|
-
"format": [{
|
|
930
|
-
"validateFormat": 0
|
|
931
|
-
}],
|
|
932
|
-
"orientation": [{
|
|
933
|
-
"validateOrientation": 0
|
|
934
|
-
}]
|
|
935
|
-
}; }
|
|
936
|
-
};
|
|
937
|
-
Page.style = bnPageCss();
|
|
938
|
-
|
|
939
|
-
/**
|
|
940
|
-
* Spatial layout engine for the structure chart (horizontal bars).
|
|
941
|
-
*
|
|
942
|
-
* Converts logical data model coordinates (bar index, data values) into pixel positions
|
|
943
|
-
* for all chart elements. All spacings are derived from the font size multiplied by
|
|
944
|
-
* ScaleFactorsStructureChart factors.
|
|
945
|
-
*
|
|
946
|
-
* Key coordinate reference points:
|
|
947
|
-
* - getBarPositionX(): the X coordinate of the vertical axis baseline
|
|
948
|
-
* - getBarCenterPositionY(index): center Y for the bar at the given category index
|
|
949
|
-
* - getAxisPositionX(): axis X accounting for left-side labels and padding
|
|
950
|
-
*
|
|
951
|
-
* The layout accounts for: padding, left-side label space (title, category names,
|
|
952
|
-
* negative-value labels), scenario offsets, and marker positioning above/below bars.
|
|
953
|
-
*/
|
|
954
|
-
class ElementPositions {
|
|
955
|
-
// private smallestDataPoint: DataPoint;
|
|
956
|
-
constructor(padding, scaleFactors, fontSize, numberOfColumns, leftSideLengthSync, titleLength, leftSideWidth, categoryWidth) {
|
|
957
|
-
this.categoryPosition = { x: 0, y: 0 };
|
|
958
|
-
this.spacings = {
|
|
959
|
-
scenarioOffset: 0,
|
|
960
|
-
markerOffset: 0,
|
|
961
|
-
scenarioLabelToBar: 0,
|
|
962
|
-
labelToBar: 0,
|
|
963
|
-
labelToAxis: 0,
|
|
964
|
-
needleWidth: 0,
|
|
965
|
-
needleHeadWidth: 0,
|
|
966
|
-
barWidth: 0,
|
|
967
|
-
varianceAxisLineWidth: 0,
|
|
968
|
-
axisLineWidth: 0,
|
|
969
|
-
auxiliaryLineWidth: 0,
|
|
970
|
-
scenarioLineWidth: 0,
|
|
971
|
-
markerWidth: 0,
|
|
972
|
-
categoryWidth: 0,
|
|
973
|
-
axisTickLength: 0,
|
|
974
|
-
};
|
|
975
|
-
this.categoriesBoxOffset = {
|
|
976
|
-
width: 0,
|
|
977
|
-
height: 0,
|
|
978
|
-
};
|
|
979
|
-
this.padding = padding;
|
|
980
|
-
this.scaleFactors = scaleFactors;
|
|
981
|
-
this.fontSize = fontSize;
|
|
982
|
-
this.axisPosition = { x: 0, y: 0 };
|
|
983
|
-
this.numberOfColumns = numberOfColumns;
|
|
984
|
-
this.leftSideLengthSync = leftSideLengthSync;
|
|
985
|
-
this.topSideLabelHeight = titleLength > 0 ? this.fontSize : 0;
|
|
986
|
-
this.leftSideLabelLength = this.calculateSideLabelLength(titleLength, leftSideWidth, categoryWidth);
|
|
987
|
-
this.calculateSpacings();
|
|
988
|
-
this.calculateCategoryPosition();
|
|
989
|
-
this.calculateAxisPosition();
|
|
990
|
-
}
|
|
991
|
-
getBarPositionX() {
|
|
992
|
-
return this.axisPosition.x;
|
|
993
|
-
}
|
|
994
|
-
getBarCenterPositionY(index) {
|
|
995
|
-
return this.categoryPosition.y + this.spacings.scenarioOffset + index * this.spacings.categoryWidth;
|
|
996
|
-
}
|
|
997
|
-
getBarPositionY(index, isPrimaryMarker) {
|
|
998
|
-
if (isPrimaryMarker) {
|
|
999
|
-
return this.getBarCenterPositionY(index);
|
|
1000
|
-
}
|
|
1001
|
-
return this.getBarCenterPositionY(index) - this.spacings.scenarioOffset;
|
|
1002
|
-
}
|
|
1003
|
-
getCategoryPositionX(isPositive) {
|
|
1004
|
-
let offset = this.spacings.labelToAxis;
|
|
1005
|
-
if (isPositive) {
|
|
1006
|
-
offset = -this.spacings.labelToAxis;
|
|
1007
|
-
}
|
|
1008
|
-
return this.getAxisPositionX() + offset;
|
|
1009
|
-
}
|
|
1010
|
-
getAxisTitlePositionX() {
|
|
1011
|
-
return this.axisPosition.x;
|
|
1012
|
-
}
|
|
1013
|
-
getAxisTitlePositionY() {
|
|
1014
|
-
return this.axisPosition.y - this.spacings.labelToAxis;
|
|
1015
|
-
}
|
|
1016
|
-
getNeedleWidth() {
|
|
1017
|
-
return this.spacings.needleWidth;
|
|
1018
|
-
}
|
|
1019
|
-
getAxisPositionX() {
|
|
1020
|
-
return this.leftSideLabelLength + this.padding.left + this.spacings.labelToAxis;
|
|
1021
|
-
}
|
|
1022
|
-
getAxisPositionY() {
|
|
1023
|
-
return this.padding.top + this.getAxisTitleOffset();
|
|
1024
|
-
}
|
|
1025
|
-
loadCategoriesBox(categoriesBoxOffset) {
|
|
1026
|
-
this.categoriesBoxOffset = categoriesBoxOffset;
|
|
1027
|
-
this.calculateAxisPosition();
|
|
1028
|
-
}
|
|
1029
|
-
addOffsetByNegativeDataPoints(smallestDataPoint, boxWidth, isPercent, titleLength) {
|
|
1030
|
-
if (smallestDataPoint != null && smallestDataPoint.value != null) {
|
|
1031
|
-
if (smallestDataPoint.value < 0) {
|
|
1032
|
-
if (isPercent && smallestDataPoint.isClipped()) {
|
|
1033
|
-
this.axisPosition.x += Math.abs(smallestDataPoint.getClippedValue() * smallestDataPoint.pixelPerUnit);
|
|
1034
|
-
}
|
|
1035
|
-
else {
|
|
1036
|
-
this.axisPosition.x += Math.abs(smallestDataPoint.value * smallestDataPoint.pixelPerUnit);
|
|
1037
|
-
}
|
|
1038
|
-
this.axisPosition.x += boxWidth;
|
|
1039
|
-
this.axisPosition.x += this.spacings.labelToBar;
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
if (this.axisPosition.x < titleLength / 2) {
|
|
1043
|
-
this.axisPosition.x = titleLength / 2 + this.spacings.labelToBar;
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
getLabelPositionX(scaledUnit) {
|
|
1047
|
-
let offset = this.spacings.labelToBar;
|
|
1048
|
-
if (scaledUnit < 0) {
|
|
1049
|
-
offset *= -1;
|
|
1050
|
-
}
|
|
1051
|
-
return this.axisPosition.x + scaledUnit + offset;
|
|
1052
|
-
}
|
|
1053
|
-
getLabelPositionY(scaledUnit) {
|
|
1054
|
-
return this.axisPosition.y + scaledUnit + this.spacings.labelToBar;
|
|
1055
|
-
}
|
|
1056
|
-
getCategoryToAxisSpaceing() {
|
|
1057
|
-
return this.spacings.labelToAxis;
|
|
1058
|
-
}
|
|
1059
|
-
getCategoryToTopSpaceing() {
|
|
1060
|
-
return this.spacings.scenarioOffset;
|
|
1061
|
-
}
|
|
1062
|
-
getCategoryToBottomSpaceing() {
|
|
1063
|
-
return this.spacings.scenarioOffset; // this.categoryOffset;
|
|
1064
|
-
}
|
|
1065
|
-
getAxisEndPositionY() {
|
|
1066
|
-
return this.getAxisPositionY() + (this.numberOfColumns + 1 / 2) * this.spacings.categoryWidth;
|
|
1067
|
-
}
|
|
1068
|
-
getScenarioLabelPositionOffsetY(isPrimaryBar) {
|
|
1069
|
-
if (isPrimaryBar) {
|
|
1070
|
-
return this.getBarWidth() * 0.5 + this.spacings.scenarioLabelToBar;
|
|
1071
|
-
}
|
|
1072
|
-
return -(this.getBarWidth() * 0.5 + this.spacings.scenarioLabelToBar);
|
|
1073
|
-
}
|
|
1074
|
-
getBarWidth() {
|
|
1075
|
-
return this.spacings.barWidth;
|
|
1076
|
-
}
|
|
1077
|
-
getMarkerPositionY(index, isPrimaryMarker) {
|
|
1078
|
-
if (isPrimaryMarker) {
|
|
1079
|
-
return this.getBarCenterPositionY(index) - this.spacings.markerOffset - this.getBarWidth() * 0.5;
|
|
1080
|
-
}
|
|
1081
|
-
return this.getBarCenterPositionY(index) + this.spacings.markerOffset + this.getBarWidth() * 0.5;
|
|
1082
|
-
}
|
|
1083
|
-
getMarkerPositionX() {
|
|
1084
|
-
return this.getBarPositionX();
|
|
1085
|
-
}
|
|
1086
|
-
getMarkerScenarioLabelPositionOffsetY(isPrimaryColumn) {
|
|
1087
|
-
if (isPrimaryColumn) {
|
|
1088
|
-
return -(this.spacings.markerWidth * 0.5 + this.spacings.scenarioLabelToBar);
|
|
1089
|
-
}
|
|
1090
|
-
return this.spacings.scenarioLabelToBar + this.spacings.markerWidth * 0.5;
|
|
1091
|
-
}
|
|
1092
|
-
getAxisEndPositionX() {
|
|
1093
|
-
return this.getAxisPositionX();
|
|
1094
|
-
}
|
|
1095
|
-
calculateSpacings() {
|
|
1096
|
-
this.spacings = {
|
|
1097
|
-
scenarioOffset: this.fontSize * this.scaleFactors.scenarioOffset,
|
|
1098
|
-
markerOffset: this.fontSize * this.scaleFactors.markerOffset,
|
|
1099
|
-
scenarioLabelToBar: this.fontSize * this.scaleFactors.scenarioLabelToBar,
|
|
1100
|
-
labelToBar: this.fontSize * this.scaleFactors.labelToBar,
|
|
1101
|
-
labelToAxis: this.fontSize * this.scaleFactors.labelToAxis,
|
|
1102
|
-
needleWidth: this.fontSize * this.scaleFactors.needleWidth,
|
|
1103
|
-
needleHeadWidth: this.fontSize * this.scaleFactors.needleHeadWidth,
|
|
1104
|
-
barWidth: this.fontSize * this.scaleFactors.barWidth,
|
|
1105
|
-
varianceAxisLineWidth: this.fontSize * this.scaleFactors.varianceAxisLineWidth,
|
|
1106
|
-
axisLineWidth: this.fontSize * this.scaleFactors.axisLineWidth,
|
|
1107
|
-
auxiliaryLineWidth: this.fontSize * this.scaleFactors.auxiliaryLineWidth,
|
|
1108
|
-
scenarioLineWidth: this.fontSize * this.scaleFactors.scenarioLineWidth,
|
|
1109
|
-
markerWidth: this.fontSize * this.scaleFactors.markerWidth,
|
|
1110
|
-
categoryWidth: this.fontSize * this.scaleFactors.categoryWidth,
|
|
1111
|
-
axisTickLength: this.fontSize * this.scaleFactors.axisTickLength,
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
calculateCategoryPosition() {
|
|
1115
|
-
this.categoryPosition = {
|
|
1116
|
-
x: this.padding.left,
|
|
1117
|
-
y: this.getAxisPositionY() + this.spacings.categoryWidth * 0.5,
|
|
1118
|
-
};
|
|
1119
|
-
}
|
|
1120
|
-
calculateAxisPosition() {
|
|
1121
|
-
this.axisPosition = {
|
|
1122
|
-
x: this.getAxisPositionX(),
|
|
1123
|
-
y: this.getAxisPositionY(),
|
|
1124
|
-
};
|
|
1125
|
-
}
|
|
1126
|
-
// @ts-ignore
|
|
1127
|
-
recalculatePositions() {
|
|
1128
|
-
this.calculateCategoryPosition();
|
|
1129
|
-
this.calculateAxisPosition();
|
|
1130
|
-
}
|
|
1131
|
-
getAxisTitleOffset() {
|
|
1132
|
-
return this.topSideLabelHeight;
|
|
1133
|
-
}
|
|
1134
|
-
calculateSideLabelLength(titleLength, leftSideWidth, categoryWidth) {
|
|
1135
|
-
if (this.leftSideLengthSync) {
|
|
1136
|
-
return this.leftSideLengthSync;
|
|
1137
|
-
}
|
|
1138
|
-
const leftSideTitleLength = titleLength / 2;
|
|
1139
|
-
let sideLabelLength = leftSideWidth;
|
|
1140
|
-
if (leftSideTitleLength > sideLabelLength) {
|
|
1141
|
-
sideLabelLength = leftSideTitleLength;
|
|
1142
|
-
}
|
|
1143
|
-
if (categoryWidth > sideLabelLength) {
|
|
1144
|
-
sideLabelLength = categoryWidth;
|
|
1145
|
-
}
|
|
1146
|
-
return sideLabelLength;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
class Padding {
|
|
1151
|
-
constructor(padding) {
|
|
1152
|
-
this.top = padding.top;
|
|
1153
|
-
this.bottom = padding.bottom;
|
|
1154
|
-
this.left = padding.left;
|
|
1155
|
-
this.right = padding.right;
|
|
1156
|
-
}
|
|
1157
|
-
addBoxTopLeft(addition) {
|
|
1158
|
-
this.top += addition.height | this.top;
|
|
1159
|
-
this.left += addition.width | this.top;
|
|
1160
|
-
return this;
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
// import { SVGPolgonPattern } from "../../../../utils/model";
|
|
1165
|
-
class MarkerPattern {
|
|
1166
|
-
constructor(fontSize) {
|
|
1167
|
-
const backgroundFactor = 1;
|
|
1168
|
-
const foregroundFactor = 0.7;
|
|
1169
|
-
const maxBg = fontSize * backgroundFactor;
|
|
1170
|
-
const maxFg = fontSize * foregroundFactor;
|
|
1171
|
-
this.bgOffset = (maxBg - maxFg) / 2;
|
|
1172
|
-
this.markerUp = { top: maxFg / 2 + ",0", left: "0," + maxFg, right: maxFg + "," + maxFg };
|
|
1173
|
-
this.markerUpBackground = { top: maxBg / 2 + ",0", left: "0," + maxBg, right: maxBg + "," + maxBg };
|
|
1174
|
-
this.markerDown = { bottom: maxFg / 2 + "," + maxFg, left: "0,0", right: maxFg + ",0" };
|
|
1175
|
-
this.markerDownBackground = { bottom: maxBg / 2 + "," + maxBg, left: "0,0", right: maxBg + ",0" };
|
|
1176
|
-
}
|
|
1177
|
-
upMarkerPatternStrings() {
|
|
1178
|
-
return {
|
|
1179
|
-
background: this.markerUpBackground.left +
|
|
1180
|
-
" " +
|
|
1181
|
-
this.markerUpBackground.right +
|
|
1182
|
-
" " +
|
|
1183
|
-
this.markerUpBackground.top +
|
|
1184
|
-
" " +
|
|
1185
|
-
this.markerUpBackground.left,
|
|
1186
|
-
foreground: this.markerUp.left + " " + this.markerUp.right + " " + this.markerUp.top + " " + this.markerUp.left,
|
|
1187
|
-
bgOffset: this.bgOffset,
|
|
1188
|
-
};
|
|
1189
|
-
}
|
|
1190
|
-
downMarkerPatternStrings() {
|
|
1191
|
-
return {
|
|
1192
|
-
background: this.markerDownBackground.left +
|
|
1193
|
-
" " +
|
|
1194
|
-
this.markerDownBackground.right +
|
|
1195
|
-
" " +
|
|
1196
|
-
this.markerDownBackground.bottom +
|
|
1197
|
-
" " +
|
|
1198
|
-
this.markerDownBackground.left,
|
|
1199
|
-
foreground: this.markerDown.left + " " + this.markerDown.right + " " + this.markerDown.bottom + " " + this.markerDown.left,
|
|
1200
|
-
bgOffset: this.bgOffset,
|
|
1201
|
-
};
|
|
1202
|
-
}
|
|
1203
|
-
createPatternMapForStructureBar() {
|
|
1204
|
-
const pattern = new Map();
|
|
1205
|
-
pattern.set("marker-up", this.upMarkerPatternStrings());
|
|
1206
|
-
pattern.set("marker-down", this.downMarkerPatternStrings());
|
|
1207
|
-
return pattern;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
|
|
1211
|
-
// import { SVGPolgonPattern } from "../../../../utils/model";
|
|
1212
|
-
/**
|
|
1213
|
-
* Generates SVG diagonal-line hatching patterns for forecast (FC) scenario bars
|
|
1214
|
-
* in the structure chart.
|
|
1215
|
-
*
|
|
1216
|
-
* Creates a 10x10 SVG <pattern> tile with diagonal lines using the FC bar style colors.
|
|
1217
|
-
* Used as fill for FC horizontal bars to distinguish forecast from actual data per IBCS.
|
|
1218
|
-
*/
|
|
1219
|
-
class CustomPattern {
|
|
1220
|
-
constructor(styles) {
|
|
1221
|
-
this.container = new Svg();
|
|
1222
|
-
this.pattern = this.createFCPattern(this.container.group(), styles);
|
|
1223
|
-
this.styles = styles;
|
|
1224
|
-
const backgroundFactor = 1;
|
|
1225
|
-
const foregroundFactor = 0.7;
|
|
1226
|
-
let fontSize = 10;
|
|
1227
|
-
if (styles != null && styles.fontStyles != null && styles.fontStyles.size) {
|
|
1228
|
-
fontSize = styles.fontStyles.size;
|
|
1229
|
-
}
|
|
1230
|
-
const maxBg = fontSize * backgroundFactor;
|
|
1231
|
-
const maxFg = fontSize * foregroundFactor;
|
|
1232
|
-
this.bgOffset = (maxBg - maxFg) / 2;
|
|
1233
|
-
}
|
|
1234
|
-
createFCPattern(group, styles) {
|
|
1235
|
-
const _styles = styles;
|
|
1236
|
-
return group
|
|
1237
|
-
.pattern(10, 10, function (add) {
|
|
1238
|
-
add.rect(10, 10).fill(_styles.barStyles.fc.fill);
|
|
1239
|
-
add
|
|
1240
|
-
.line(0, 5, 5, 0)
|
|
1241
|
-
.stroke({ width: _styles.barStyles.fc.width, color: _styles.barStyles.fc.stroke, linecap: "square" });
|
|
1242
|
-
add
|
|
1243
|
-
.line(5, 10, 10, 5)
|
|
1244
|
-
.stroke({ width: _styles.barStyles.fc.width, color: _styles.barStyles.fc.stroke, linecap: "square" });
|
|
1245
|
-
})
|
|
1246
|
-
.id("pattern-structure-fc");
|
|
1247
|
-
}
|
|
1248
|
-
getFCPolygonPattern() {
|
|
1249
|
-
return { background: "", foreground: "", bgOffset: 0, pattern: this.pattern };
|
|
1250
|
-
}
|
|
1251
|
-
toString() {
|
|
1252
|
-
return this.container.svg();
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
var FactoryState;
|
|
1257
|
-
(function (FactoryState) {
|
|
1258
|
-
FactoryState[FactoryState["UP_TO_DATE"] = 0] = "UP_TO_DATE";
|
|
1259
|
-
FactoryState[FactoryState["DIRTY"] = 1] = "DIRTY";
|
|
1260
|
-
})(FactoryState || (FactoryState = {}));
|
|
1261
|
-
var VarianceType;
|
|
1262
|
-
(function (VarianceType) {
|
|
1263
|
-
VarianceType["RELATIVE"] = "dr";
|
|
1264
|
-
VarianceType["ABSOLUTE"] = "d";
|
|
1265
|
-
VarianceType["NONE"] = "";
|
|
1266
|
-
})(VarianceType || (VarianceType = {}));
|
|
1267
|
-
|
|
1268
|
-
/**
|
|
1269
|
-
* Configuration for an IBCS structural (categorical) bar chart component.
|
|
1270
|
-
*
|
|
1271
|
-
* Controls the vertical scale, category visibility, and chart rendering parameters
|
|
1272
|
-
* for charts where the x-axis represents categories rather than time periods.
|
|
1273
|
-
*/
|
|
1274
|
-
class StructureChartComponentConfig {
|
|
1275
|
-
constructor(data, scenarios) {
|
|
1276
|
-
this.data = data;
|
|
1277
|
-
this.scenarios = scenarios;
|
|
1278
|
-
/** Variance column identifiers (e.g. `["d_ac1_pl1_pos"]`) for delta visualizations. */
|
|
1279
|
-
this.variances = [];
|
|
1280
|
-
this.title = "";
|
|
1281
|
-
/** When true, category labels on the y-axis are hidden. */
|
|
1282
|
-
this.hideCategories = false;
|
|
1283
|
-
/** Vertical scale factor: pixels per one data unit. Controls bar height. */
|
|
1284
|
-
this.pixelPerUnit = 10;
|
|
1285
|
-
/** Vertical scale factor for percentage variances: pixels per 1.0 (=100%). */
|
|
1286
|
-
this.pixelPerPercentage = 50;
|
|
1287
|
-
/** Maximum data points to display; 0 means unlimited. */
|
|
1288
|
-
this.limit = 0;
|
|
1289
|
-
this.sortOrder = new OrderAdapter(new StringAdapter()).default();
|
|
1290
|
-
this.level = AggregationLevel.CATEGORY;
|
|
1291
|
-
this.filter = "";
|
|
1292
|
-
/** SI prefix for measure scaling (e.g. "k" for thousands, "M" for millions). */
|
|
1293
|
-
this.measureScale = new SiPrefix();
|
|
1294
|
-
/** Unit label displayed alongside the chart (e.g. "EUR", "USD"). */
|
|
1295
|
-
this.measureUnit = "";
|
|
1296
|
-
this.showMeasureScale = true;
|
|
1297
|
-
this.dataFormatDigits = { decimal: 1, percent: 2 };
|
|
1298
|
-
this.stackConfig = null;
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
/**
|
|
1302
|
-
* Converts untyped JSON into a validated {@link StructureChartComponentConfig}.
|
|
1303
|
-
*
|
|
1304
|
-
* Requires the raw dataset for measure scale auto-calculation.
|
|
1305
|
-
*/
|
|
1306
|
-
class StructureChartComponentConfigAdapter {
|
|
1307
|
-
constructor(dataRowAdapter, orderAdapter, stringAdapter, dataFormatDigitsAdapter, dataSet) {
|
|
1308
|
-
this.dataRowAdapter = dataRowAdapter;
|
|
1309
|
-
this.orderAdapter = orderAdapter;
|
|
1310
|
-
this.stringAdapter = stringAdapter;
|
|
1311
|
-
this.dataFormatDigitsAdapter = dataFormatDigitsAdapter;
|
|
1312
|
-
this.dataSet = dataSet;
|
|
1313
|
-
}
|
|
1314
|
-
adapt(data) {
|
|
1315
|
-
const dataSet = AdapterUtils.adaptArray(data.data, this.dataRowAdapter);
|
|
1316
|
-
const scenarios = AdapterUtils.adaptArray(data.scenarios, this.stringAdapter);
|
|
1317
|
-
const config = new StructureChartComponentConfig(dataSet, scenarios);
|
|
1318
|
-
if (CompareUtil.isArray(data.variances)) {
|
|
1319
|
-
config.variances = AdapterUtils.adaptArray(data.variances, this.stringAdapter);
|
|
1320
|
-
}
|
|
1321
|
-
if (CompareUtil.isString(data.title)) {
|
|
1322
|
-
config.title = data.title;
|
|
1323
|
-
}
|
|
1324
|
-
if (CompareUtil.isBoolean(data.hideCategories)) {
|
|
1325
|
-
config.hideCategories = data.hideCategories;
|
|
1326
|
-
}
|
|
1327
|
-
if (CompareUtil.isNumber(data.pixelPerUnit)) {
|
|
1328
|
-
config.pixelPerUnit = data.pixelPerUnit;
|
|
1329
|
-
}
|
|
1330
|
-
if (CompareUtil.isNumber(data.pixelPerPercentage)) {
|
|
1331
|
-
config.pixelPerPercentage = data.pixelPerPercentage;
|
|
1332
|
-
}
|
|
1333
|
-
if (CompareUtil.isNumber(data.limit)) {
|
|
1334
|
-
config.limit = data.limit;
|
|
1335
|
-
}
|
|
1336
|
-
if (CompareUtil.isExisting(data.sortOrder)) {
|
|
1337
|
-
config.sortOrder = this.orderAdapter.adapt(data.sortOrder);
|
|
1338
|
-
}
|
|
1339
|
-
if (CompareUtil.isExisting(data.level)) {
|
|
1340
|
-
config.level = data.level;
|
|
1341
|
-
}
|
|
1342
|
-
if (CompareUtil.isString(data.filter)) {
|
|
1343
|
-
config.filter = data.filter.trim();
|
|
1344
|
-
}
|
|
1345
|
-
if (CompareUtil.isExisting(data.measureScale)) {
|
|
1346
|
-
config.measureScale = DataAnalyzer.calculateMeasureScale(this.dataSet, config.scenarios, data.measureScale);
|
|
1347
|
-
}
|
|
1348
|
-
if (CompareUtil.isString(data.measureUnit)) {
|
|
1349
|
-
config.measureUnit = data.measureUnit;
|
|
1350
|
-
}
|
|
1351
|
-
if (CompareUtil.isBoolean(data.showMeasureScale)) {
|
|
1352
|
-
config.showMeasureScale = data.showMeasureScale;
|
|
1353
|
-
}
|
|
1354
|
-
if (CompareUtil.isExisting(data.dataFormatDigits)) {
|
|
1355
|
-
config.dataFormatDigits = this.dataFormatDigitsAdapter.adapt(data.dataFormatDigits);
|
|
1356
|
-
}
|
|
1357
|
-
if (CompareUtil.isExisting(data.stackConfig)) {
|
|
1358
|
-
config.stackConfig = data.stackConfig;
|
|
1359
|
-
}
|
|
1360
|
-
return config;
|
|
1361
|
-
}
|
|
1362
|
-
default() {
|
|
1363
|
-
return new StructureChartComponentConfig([], []);
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
/**
|
|
1368
|
-
* A single renderable data point in a structural (categorical) bar chart.
|
|
1369
|
-
*
|
|
1370
|
-
* Encapsulates a numeric value, its IBCS scenario type, and the vertical scale factor.
|
|
1371
|
-
* Provides scaling and variance styling logic used by the chart renderer.
|
|
1372
|
-
*
|
|
1373
|
-
* Variance direction follows IBCS convention: the declared variance ("pos"/"neg") applies
|
|
1374
|
-
* to non-negative values; for negative values, the style is flipped (pos becomes neg and
|
|
1375
|
-
* vice versa) so that visual encoding always reflects the economic meaning.
|
|
1376
|
-
*/
|
|
1377
|
-
class DataPoint {
|
|
1378
|
-
constructor(value, scenario, pixelPerUnit, variance) {
|
|
1379
|
-
this.value = value;
|
|
1380
|
-
this.scenario = scenario;
|
|
1381
|
-
this.pixelPerUnit = pixelPerUnit || 1;
|
|
1382
|
-
if (variance === "neg" || variance === Scenario.NEG) {
|
|
1383
|
-
this.variance = Scenario.NEG;
|
|
1384
|
-
}
|
|
1385
|
-
else if (variance === "pos" || variance === Scenario.POS) {
|
|
1386
|
-
this.variance = Scenario.POS;
|
|
1387
|
-
}
|
|
1388
|
-
else {
|
|
1389
|
-
this.variance = Scenario.NEU;
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
isEmpty() {
|
|
1393
|
-
return null == this.value || null == this.scenario;
|
|
1394
|
-
}
|
|
1395
|
-
/** Returns the value scaled to pixel length for absolute (non-percentage) bars. */
|
|
1396
|
-
getScaledUnit() {
|
|
1397
|
-
if (this.value == null) {
|
|
1398
|
-
return 0;
|
|
1399
|
-
}
|
|
1400
|
-
return this.value * this.pixelPerUnit;
|
|
1401
|
-
}
|
|
1402
|
-
/**
|
|
1403
|
-
* Returns the percentage value scaled to pixel length, clipped at +/-145%.
|
|
1404
|
-
*
|
|
1405
|
-
* Values beyond +/-1.45 (145%) are clamped to prevent extreme bars from
|
|
1406
|
-
* distorting the chart layout. Use {@link isClipped} to check if clipping occurred.
|
|
1407
|
-
*/
|
|
1408
|
-
getScaledPercentUnit() {
|
|
1409
|
-
if (this.value == null) {
|
|
1410
|
-
return 0;
|
|
1411
|
-
}
|
|
1412
|
-
if (Math.abs(this.value) > 1.45) {
|
|
1413
|
-
if (this.value >= 0) {
|
|
1414
|
-
return 1.45 * this.pixelPerUnit;
|
|
1415
|
-
}
|
|
1416
|
-
else {
|
|
1417
|
-
return -1.45 * this.pixelPerUnit;
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
else {
|
|
1421
|
-
return this.value * this.pixelPerUnit;
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
/**
|
|
1425
|
-
* Returns the IBCS variance color style, flipping pos/neg for negative values.
|
|
1426
|
-
*
|
|
1427
|
-
* IBCS rule: a "positive variance" on a negative value is economically unfavorable,
|
|
1428
|
-
* so the visual style must invert. NEU (neutral) is never flipped.
|
|
1429
|
-
*/
|
|
1430
|
-
getVarianceStyle() {
|
|
1431
|
-
if (this.value == null) {
|
|
1432
|
-
return this.variance;
|
|
1433
|
-
}
|
|
1434
|
-
if (this.value >= 0) {
|
|
1435
|
-
return this.variance;
|
|
1436
|
-
}
|
|
1437
|
-
else {
|
|
1438
|
-
//flip the style
|
|
1439
|
-
if (Scenario.NEU === this.variance) {
|
|
1440
|
-
return Scenario.NEU;
|
|
1441
|
-
}
|
|
1442
|
-
if (Scenario.POS === this.variance) {
|
|
1443
|
-
return Scenario.NEG;
|
|
1444
|
-
}
|
|
1445
|
-
else {
|
|
1446
|
-
return Scenario.POS;
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
/** Returns true if the percentage value exceeds the +/-145% clipping threshold. */
|
|
1451
|
-
isClipped() {
|
|
1452
|
-
if (this.value == null) {
|
|
1453
|
-
return false;
|
|
1454
|
-
}
|
|
1455
|
-
return Math.abs(this.value) > 1.45;
|
|
1456
|
-
}
|
|
1457
|
-
/** Returns the fixed display value (145) shown on clipped percentage bars. */
|
|
1458
|
-
getClippedValue() {
|
|
1459
|
-
return 145;
|
|
1460
|
-
}
|
|
1461
|
-
/** Extracts the 2-character scenario type prefix (e.g. "ac" from "ac1", "pl" from "pl2"). */
|
|
1462
|
-
getScenario() {
|
|
1463
|
-
var _a;
|
|
1464
|
-
return (_a = this.scenario) === null || _a === void 0 ? void 0 : _a.slice(0, 2);
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
|
|
1468
|
-
/**
|
|
1469
|
-
* IBCS-compliant data row for structural (categorical) bar chart visualizations.
|
|
1470
|
-
*
|
|
1471
|
-
* Follows the same schema as {@link TableDataRow} with the addition of optional `setName`
|
|
1472
|
-
* and `date` fields. The `date` is present because structure charts may coexist with
|
|
1473
|
-
* time-series data, but it is not used for x-axis positioning (categories are used instead).
|
|
1474
|
-
*/
|
|
1475
|
-
class StructureChartDataRow {
|
|
1476
|
-
constructor() {
|
|
1477
|
-
this.operation = "+";
|
|
1478
|
-
}
|
|
1479
|
-
addRowGroup(name, index) {
|
|
1480
|
-
this.rowGroup = name;
|
|
1481
|
-
this.rowGroupIndex = index;
|
|
1482
|
-
}
|
|
1483
|
-
addCategory(name, index) {
|
|
1484
|
-
this.category = name;
|
|
1485
|
-
this.categoryIndex = index;
|
|
1486
|
-
}
|
|
1487
|
-
addSubCategory(name, index) {
|
|
1488
|
-
this.subCategory = name;
|
|
1489
|
-
this.subCategoryIndex = index;
|
|
1490
|
-
}
|
|
1491
|
-
addColumnGroup(name, index) {
|
|
1492
|
-
this.columnGroup = name;
|
|
1493
|
-
this.columnGroupIndex = index;
|
|
1494
|
-
}
|
|
1495
|
-
addSubColumnGroup(name, index) {
|
|
1496
|
-
this.columnSubGroup = name;
|
|
1497
|
-
this.columnSubGroupIndex = index;
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
/**
|
|
1501
|
-
* Converts untyped JSON records into validated {@link StructureChartDataRow} instances.
|
|
1502
|
-
*
|
|
1503
|
-
* Only assigns fields that pass type validation via {@link CompareUtil}, so malformed
|
|
1504
|
-
* input data is silently dropped and defaults are preserved.
|
|
1505
|
-
*/
|
|
1506
|
-
class StructureChartDataRowAdapter {
|
|
1507
|
-
constructor() { }
|
|
1508
|
-
adapt(data) {
|
|
1509
|
-
const dataRow = new StructureChartDataRow();
|
|
1510
|
-
if (CompareUtil.isOperator(data.operation)) {
|
|
1511
|
-
dataRow.operation = data.operation;
|
|
1512
|
-
}
|
|
1513
|
-
if (CompareUtil.isNumber(data.rowGroupIndex) && CompareUtil.isString(data.rowGroup)) {
|
|
1514
|
-
dataRow.addRowGroup(data.rowGroup, data.rowGroupIndex);
|
|
1515
|
-
}
|
|
1516
|
-
if (CompareUtil.isNumber(data.categoryIndex) && CompareUtil.isString(data.category)) {
|
|
1517
|
-
dataRow.addCategory(data.category, data.categoryIndex);
|
|
1518
|
-
}
|
|
1519
|
-
if (CompareUtil.isNumber(data.subCategoryIndex) && CompareUtil.isString(data.subCategory)) {
|
|
1520
|
-
dataRow.addSubCategory(data.subCategory, data.subCategoryIndex);
|
|
1521
|
-
}
|
|
1522
|
-
if (CompareUtil.isNumber(data.columnGroupIndex) && CompareUtil.isString(data.columnGroup)) {
|
|
1523
|
-
dataRow.addColumnGroup(data.columnGroup, data.columnGroupIndex);
|
|
1524
|
-
}
|
|
1525
|
-
if (CompareUtil.isNumber(data.columnSubGroupIndex) && CompareUtil.isString(data.columnSubGroup)) {
|
|
1526
|
-
dataRow.addSubColumnGroup(data.columnSubGroup, data.columnSubGroupIndex);
|
|
1527
|
-
}
|
|
1528
|
-
this.setActualValues(data, dataRow);
|
|
1529
|
-
this.setPlanValues(data, dataRow);
|
|
1530
|
-
this.setPreviousPeriodValues(data, dataRow);
|
|
1531
|
-
this.setForecastValues(data, dataRow);
|
|
1532
|
-
return dataRow;
|
|
1533
|
-
}
|
|
1534
|
-
default() {
|
|
1535
|
-
return new StructureChartDataRow();
|
|
1536
|
-
}
|
|
1537
|
-
setActualValues(data, dataRow) {
|
|
1538
|
-
if (CompareUtil.isNumber(data.ac1)) {
|
|
1539
|
-
dataRow.ac1 = data.ac1;
|
|
1540
|
-
}
|
|
1541
|
-
if (CompareUtil.isNumber(data.ac2)) {
|
|
1542
|
-
dataRow.ac2 = data.ac2;
|
|
1543
|
-
}
|
|
1544
|
-
if (CompareUtil.isNumber(data.ac3)) {
|
|
1545
|
-
dataRow.ac3 = data.ac3;
|
|
1546
|
-
}
|
|
1547
|
-
if (CompareUtil.isNumber(data.ac4)) {
|
|
1548
|
-
dataRow.ac4 = data.ac4;
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
|
-
setPlanValues(data, dataRow) {
|
|
1552
|
-
if (CompareUtil.isNumber(data.pl1)) {
|
|
1553
|
-
dataRow.pl1 = data.pl1;
|
|
1554
|
-
}
|
|
1555
|
-
if (CompareUtil.isNumber(data.pl2)) {
|
|
1556
|
-
dataRow.pl2 = data.pl2;
|
|
1557
|
-
}
|
|
1558
|
-
if (CompareUtil.isNumber(data.pl3)) {
|
|
1559
|
-
dataRow.pl3 = data.pl3;
|
|
1560
|
-
}
|
|
1561
|
-
if (CompareUtil.isNumber(data.pl4)) {
|
|
1562
|
-
dataRow.pl4 = data.pl4;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
setPreviousPeriodValues(data, dataRow) {
|
|
1566
|
-
if (CompareUtil.isNumber(data.pp1)) {
|
|
1567
|
-
dataRow.pp1 = data.pp1;
|
|
1568
|
-
}
|
|
1569
|
-
if (CompareUtil.isNumber(data.pp2)) {
|
|
1570
|
-
dataRow.pp2 = data.pp2;
|
|
1571
|
-
}
|
|
1572
|
-
if (CompareUtil.isNumber(data.pp3)) {
|
|
1573
|
-
dataRow.pp3 = data.pp3;
|
|
1574
|
-
}
|
|
1575
|
-
if (CompareUtil.isNumber(data.pp4)) {
|
|
1576
|
-
dataRow.pp4 = data.pp4;
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
setForecastValues(data, dataRow) {
|
|
1580
|
-
if (CompareUtil.isNumber(data.fc1)) {
|
|
1581
|
-
dataRow.fc1 = data.fc1;
|
|
1582
|
-
}
|
|
1583
|
-
if (CompareUtil.isNumber(data.fc2)) {
|
|
1584
|
-
dataRow.fc2 = data.fc2;
|
|
1585
|
-
}
|
|
1586
|
-
if (CompareUtil.isNumber(data.fc3)) {
|
|
1587
|
-
dataRow.fc3 = data.fc3;
|
|
1588
|
-
}
|
|
1589
|
-
if (CompareUtil.isNumber(data.fc4)) {
|
|
1590
|
-
dataRow.fc4 = data.fc4;
|
|
1591
|
-
}
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
|
|
1595
|
-
// import { IAdapter } from "../../../../../utils/helper/IAdapter";
|
|
1596
|
-
// import { FontStyle, FontStyleAdapter } from "../../../../../utils/model/styles/FontStyle";
|
|
1597
|
-
// import { SVGStyleGroup, SVGStyleGroupAdapter } from "../../../../../utils/model/styles/SVGStyleGroup";
|
|
1598
|
-
// import { SVGVariancesStyleGroup, SVGVariancesStyleGroupAdapter } from "../../../../../utils/model/styles/SVGVariancesStyleGroup";
|
|
1599
|
-
// import { SVGPolgonPattern } from "../../../../../utils/model";
|
|
1600
|
-
// import { Padding, PaddingAdapter } from "../../../../../utils/model/styles/Padding";
|
|
1601
|
-
/** Aggregates all style configuration for a structure chart: scale factors, fonts, colors, patterns, and padding. */
|
|
1602
|
-
class StructureChartStyle {
|
|
1603
|
-
constructor(scaleFactors, fontStyles, axisStyles, barStyles, varianceStyles, padding) {
|
|
1604
|
-
this.scaleFactors = scaleFactors;
|
|
1605
|
-
this.fontStyles = fontStyles;
|
|
1606
|
-
this.axisStyles = axisStyles;
|
|
1607
|
-
this.barStyles = barStyles;
|
|
1608
|
-
this.varianceStyles = varianceStyles;
|
|
1609
|
-
this.padding = padding;
|
|
1610
|
-
this.pattern = new Map();
|
|
1611
|
-
this.stackColors = ["#000000", "#c0c0c0", "#808080"];
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
/** Adapts raw componentStyle JSON into a StructureChartStyle, falling back to defaults for missing properties. */
|
|
1615
|
-
class StructureChartStylesAdapter {
|
|
1616
|
-
constructor(scaleFactorsStructureChartAdapter, fontStyleAdapter, svgStyleGroupAdapter, svgVariancesStyleGroupAdapter, paddingadapter) {
|
|
1617
|
-
this.scaleFactorsStructureChartAdapter = scaleFactorsStructureChartAdapter;
|
|
1618
|
-
this.fontStyleAdapter = fontStyleAdapter;
|
|
1619
|
-
this.svgStyleGroupAdapter = svgStyleGroupAdapter;
|
|
1620
|
-
this.svgVariancesStyleGroupAdapter = svgVariancesStyleGroupAdapter;
|
|
1621
|
-
this.paddingadapter = paddingadapter;
|
|
1622
|
-
}
|
|
1623
|
-
adapt(data) {
|
|
1624
|
-
const styles = new StructureChartStyle(this.scaleFactorsStructureChartAdapter.default(), this.fontStyleAdapter.default(), this.svgStyleGroupAdapter.default(), this.svgStyleGroupAdapter.default(), this.svgVariancesStyleGroupAdapter.default(), this.paddingadapter.default());
|
|
1625
|
-
if (CompareUtil.isExisting(data)) {
|
|
1626
|
-
if (CompareUtil.isExisting(data.scaleFactors)) {
|
|
1627
|
-
styles.scaleFactors = this.scaleFactorsStructureChartAdapter.adapt(data.scaleFactors);
|
|
1628
|
-
}
|
|
1629
|
-
if (CompareUtil.isExisting(data.fontStyles)) {
|
|
1630
|
-
styles.fontStyles = this.fontStyleAdapter.adapt(data.fontStyles);
|
|
1631
|
-
}
|
|
1632
|
-
if (CompareUtil.isExisting(data.axisStyles)) {
|
|
1633
|
-
styles.axisStyles = this.svgStyleGroupAdapter.adapt(data.axisStyles);
|
|
1634
|
-
}
|
|
1635
|
-
if (CompareUtil.isExisting(data.barStyles)) {
|
|
1636
|
-
styles.barStyles = this.svgStyleGroupAdapter.adapt(data.barStyles);
|
|
1637
|
-
}
|
|
1638
|
-
if (CompareUtil.isExisting(data.varianceStyles)) {
|
|
1639
|
-
styles.varianceStyles = this.svgVariancesStyleGroupAdapter.adapt(data.varianceStyles);
|
|
1640
|
-
}
|
|
1641
|
-
if (CompareUtil.isExisting(data.padding)) {
|
|
1642
|
-
styles.padding = this.paddingadapter.adapt(data.padding);
|
|
1643
|
-
}
|
|
1644
|
-
if (Array.isArray(data.stackColors) && data.stackColors.length > 0) {
|
|
1645
|
-
styles.stackColors = data.stackColors;
|
|
1646
|
-
}
|
|
1647
|
-
styles.pattern = new MarkerPattern(styles.fontStyles.size).createPatternMapForStructureBar();
|
|
1648
|
-
}
|
|
1649
|
-
return styles;
|
|
1650
|
-
}
|
|
1651
|
-
default() {
|
|
1652
|
-
return new StructureChartStyle(this.scaleFactorsStructureChartAdapter.default(), this.fontStyleAdapter.default(), this.svgStyleGroupAdapter.default(), this.svgStyleGroupAdapter.default(), this.svgVariancesStyleGroupAdapter.default(), this.paddingadapter.default());
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
|
|
1656
|
-
// import { IAdapter } from "../../../../../utils/helper/IAdapter";
|
|
1657
|
-
// import { CompareUtil } from "../../../../../utils/helper/CompareUtil";
|
|
1658
|
-
/**
|
|
1659
|
-
* Proportional scale factors for structural (categorical) bar chart elements.
|
|
1660
|
-
*
|
|
1661
|
-
* All values are expressed in **font-size multiples** (em-like units), so the chart
|
|
1662
|
-
* scales uniformly when the base font size changes. The chart renderer multiplies
|
|
1663
|
-
* each factor by the computed font size to get pixel dimensions.
|
|
1664
|
-
*/
|
|
1665
|
-
class ScaleFactorsStructureChart {
|
|
1666
|
-
constructor() {
|
|
1667
|
-
/** Horizontal gap between adjacent scenario bars within a category. */
|
|
1668
|
-
this.scenarioOffset = 0.3;
|
|
1669
|
-
/** Gap between the scenario label and the end of its bar. */
|
|
1670
|
-
this.scenarioLabelToBar = 0.1;
|
|
1671
|
-
/** Gap between the value label and the end of its bar. */
|
|
1672
|
-
this.labelToBar = 0.3;
|
|
1673
|
-
/** Gap between axis labels and the axis line. */
|
|
1674
|
-
this.labelToAxis = 0.3;
|
|
1675
|
-
/** Width of the variance needle (pin chart element). */
|
|
1676
|
-
this.needleWidth = 0.3;
|
|
1677
|
-
/** Width of the arrowhead on variance needles. */
|
|
1678
|
-
this.needleHeadWidth = 0.6;
|
|
1679
|
-
/** Height of a single data bar. */
|
|
1680
|
-
this.barWidth = 1.2;
|
|
1681
|
-
/** Stroke width of the variance chart axis line. */
|
|
1682
|
-
this.varianceAxisLineWidth = 0.3;
|
|
1683
|
-
/** Stroke width of the main value axis line. */
|
|
1684
|
-
this.axisLineWidth = 0.1;
|
|
1685
|
-
/** Stroke width of auxiliary/grid lines. */
|
|
1686
|
-
this.auxiliaryLineWidth = 0.1;
|
|
1687
|
-
/** Stroke width of scenario indicator lines (e.g. forecast hatching). */
|
|
1688
|
-
this.scenarioLineWidth = 0.2;
|
|
1689
|
-
/** Size of plan/previous-period marker symbols. */
|
|
1690
|
-
this.markerWidth = 0.7;
|
|
1691
|
-
/** Vertical offset of markers from the bar center. */
|
|
1692
|
-
this.markerOffset = 0.0;
|
|
1693
|
-
/** Total vertical space allocated per category (bar + padding). */
|
|
1694
|
-
this.categoryWidth = 1.9;
|
|
1695
|
-
/** Length of axis tick marks. */
|
|
1696
|
-
this.axisTickLength = 0.3;
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
/** Converts untyped JSON into a validated {@link ScaleFactorsStructureChart}. */
|
|
1700
|
-
class ScaleFactorsStructureChartAdapter {
|
|
1701
|
-
adapt(data) {
|
|
1702
|
-
const scaleFactors = new ScaleFactorsStructureChart();
|
|
1703
|
-
if (CompareUtil.isNumber(data.scenarioOffset)) {
|
|
1704
|
-
scaleFactors.scenarioOffset = data.scenarioOffset;
|
|
1705
|
-
}
|
|
1706
|
-
if (CompareUtil.isNumber(data.scenarioLabelToBar)) {
|
|
1707
|
-
scaleFactors.scenarioLabelToBar = data.scenarioLabelToBar;
|
|
1708
|
-
}
|
|
1709
|
-
if (CompareUtil.isNumber(data.labelToBar)) {
|
|
1710
|
-
scaleFactors.labelToBar = data.labelToBar;
|
|
1711
|
-
}
|
|
1712
|
-
if (CompareUtil.isNumber(data.labelToAxis)) {
|
|
1713
|
-
scaleFactors.labelToAxis = data.labelToAxis;
|
|
1714
|
-
}
|
|
1715
|
-
if (CompareUtil.isNumber(data.needleWidth)) {
|
|
1716
|
-
scaleFactors.needleWidth = data.needleWidth;
|
|
1717
|
-
}
|
|
1718
|
-
if (CompareUtil.isNumber(data.needleHeadWidth)) {
|
|
1719
|
-
scaleFactors.needleHeadWidth = data.needleHeadWidth;
|
|
1720
|
-
}
|
|
1721
|
-
if (CompareUtil.isNumber(data.barWidth)) {
|
|
1722
|
-
scaleFactors.barWidth = data.barWidth;
|
|
1723
|
-
}
|
|
1724
|
-
if (CompareUtil.isNumber(data.varianceAxisLineWidth)) {
|
|
1725
|
-
scaleFactors.varianceAxisLineWidth = data.varianceAxisLineWidth;
|
|
1726
|
-
}
|
|
1727
|
-
if (CompareUtil.isNumber(data.axisLineWidth)) {
|
|
1728
|
-
scaleFactors.axisLineWidth = data.axisLineWidth;
|
|
1729
|
-
}
|
|
1730
|
-
if (CompareUtil.isNumber(data.auxiliaryLineWidth)) {
|
|
1731
|
-
scaleFactors.auxiliaryLineWidth = data.auxiliaryLineWidth;
|
|
1732
|
-
}
|
|
1733
|
-
if (CompareUtil.isNumber(data.scenarioLineWidth)) {
|
|
1734
|
-
scaleFactors.scenarioLineWidth = data.scenarioLineWidth;
|
|
1735
|
-
}
|
|
1736
|
-
if (CompareUtil.isNumber(data.markerWidth)) {
|
|
1737
|
-
scaleFactors.markerWidth = data.markerWidth;
|
|
1738
|
-
}
|
|
1739
|
-
if (CompareUtil.isNumber(data.markerOffset)) {
|
|
1740
|
-
scaleFactors.markerOffset = data.markerOffset;
|
|
1741
|
-
}
|
|
1742
|
-
if (CompareUtil.isNumber(data.categoryWidth)) {
|
|
1743
|
-
scaleFactors.categoryWidth = data.categoryWidth;
|
|
1744
|
-
}
|
|
1745
|
-
if (CompareUtil.isNumber(data.axisTickLength)) {
|
|
1746
|
-
scaleFactors.axisTickLength = data.axisTickLength;
|
|
1747
|
-
}
|
|
1748
|
-
return scaleFactors;
|
|
1749
|
-
}
|
|
1750
|
-
default() {
|
|
1751
|
-
return new ScaleFactorsStructureChart();
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
/**
|
|
1756
|
-
* IBCS scenario enumeration for structural charts.
|
|
1757
|
-
*
|
|
1758
|
-
* Includes all 16 scenario slots (4 each of ac, pp, fc, pl) plus three
|
|
1759
|
-
* variance direction markers: POS (positive/favorable), NEG (negative/unfavorable),
|
|
1760
|
-
* NEU (neutral).
|
|
1761
|
-
*/
|
|
1762
|
-
var Scenario;
|
|
1763
|
-
(function (Scenario) {
|
|
1764
|
-
Scenario["AC1"] = "ac1";
|
|
1765
|
-
Scenario["PP1"] = "pp1";
|
|
1766
|
-
Scenario["FC1"] = "fc1";
|
|
1767
|
-
Scenario["PL1"] = "pl1";
|
|
1768
|
-
Scenario["AC2"] = "ac2";
|
|
1769
|
-
Scenario["PP2"] = "pp2";
|
|
1770
|
-
Scenario["FC2"] = "fc2";
|
|
1771
|
-
Scenario["PL2"] = "pl2";
|
|
1772
|
-
Scenario["AC3"] = "ac3";
|
|
1773
|
-
Scenario["PP3"] = "pp3";
|
|
1774
|
-
Scenario["FC3"] = "fc3";
|
|
1775
|
-
Scenario["PL3"] = "pl3";
|
|
1776
|
-
Scenario["AC4"] = "ac4";
|
|
1777
|
-
Scenario["PP4"] = "pp4";
|
|
1778
|
-
Scenario["FC4"] = "fc4";
|
|
1779
|
-
Scenario["PL4"] = "pl4";
|
|
1780
|
-
/** Positive/favorable variance (rendered in green per IBCS). */
|
|
1781
|
-
Scenario["POS"] = "pos";
|
|
1782
|
-
/** Negative/unfavorable variance (rendered in red per IBCS). */
|
|
1783
|
-
Scenario["NEG"] = "neg";
|
|
1784
|
-
/** Neutral variance (rendered in grey per IBCS). */
|
|
1785
|
-
Scenario["NEU"] = "neu";
|
|
1786
|
-
})(Scenario || (Scenario = {}));
|
|
1787
|
-
/** Chart-internal table aggregation modes. */
|
|
1788
|
-
var TableType;
|
|
1789
|
-
(function (TableType) {
|
|
1790
|
-
TableType["LIST"] = "LIST";
|
|
1791
|
-
TableType["SUM"] = "SUM";
|
|
1792
|
-
TableType["OPT"] = "OPT";
|
|
1793
|
-
})(TableType || (TableType = {}));
|
|
1794
|
-
|
|
1795
|
-
// import {Formatter} from "../../../../utils";
|
|
1796
|
-
// import {StructureChartStyle} from "../model";
|
|
1797
|
-
// import { DataFormatDigits } from "../../../../utils/model/DataFormatDigits";
|
|
1798
|
-
// import { SiPrefix } from "../../../../utils/model/SiPrefix";
|
|
1799
|
-
/**
|
|
1800
|
-
* Anchor point for label positioning relative to its coordinates (structure chart variant).
|
|
1801
|
-
* Vertical hooks shift the label up/down; horizontal hooks set SVG text-anchor alignment.
|
|
1802
|
-
*/
|
|
1803
|
-
var HookLocation;
|
|
1804
|
-
(function (HookLocation) {
|
|
1805
|
-
HookLocation[HookLocation["Left"] = 0] = "Left";
|
|
1806
|
-
HookLocation[HookLocation["Center"] = 1] = "Center";
|
|
1807
|
-
HookLocation[HookLocation["Right"] = 2] = "Right";
|
|
1808
|
-
HookLocation[HookLocation["Top"] = 3] = "Top";
|
|
1809
|
-
HookLocation[HookLocation["Bottom"] = 4] = "Bottom";
|
|
1810
|
-
})(HookLocation || (HookLocation = {}));
|
|
1811
|
-
/**
|
|
1812
|
-
* SVG text label for structure chart elements (bars, needles, markers, axes).
|
|
1813
|
-
*
|
|
1814
|
-
* Handles numeric formatting via Formatter.number(), variance sign prefixing,
|
|
1815
|
-
* and hook-based positioning. Draws a semi-transparent white background rectangle
|
|
1816
|
-
* for readability, or uses contrast text color when placed inside stacked segments.
|
|
1817
|
-
*
|
|
1818
|
-
* Horizontal equivalent of the time chart Label class, adapted for horizontal bar layout.
|
|
1819
|
-
*/
|
|
1820
|
-
class Label {
|
|
1821
|
-
constructor(parent, xPosition, yPosition, groupPrefix, value, styles, verticalHookLocation, horizontalHookLocation) {
|
|
1822
|
-
this.group = null;
|
|
1823
|
-
this.segmentFillColor = null;
|
|
1824
|
-
this.maxWidth = null;
|
|
1825
|
-
this.ID_SCENARIOLABEL = "Label";
|
|
1826
|
-
this.CSS_CATEGORIES = "categories";
|
|
1827
|
-
this.x = xPosition;
|
|
1828
|
-
this.y = yPosition;
|
|
1829
|
-
this.value = value;
|
|
1830
|
-
if (parent != null) {
|
|
1831
|
-
this.group = parent.group().id(this.createElementID(parent.toString(), groupPrefix));
|
|
1832
|
-
}
|
|
1833
|
-
this.styles = styles;
|
|
1834
|
-
this.isVarianceLabel = false;
|
|
1835
|
-
this.isRelativeLabel = false;
|
|
1836
|
-
this.verticalHookLocation = verticalHookLocation || HookLocation.Top;
|
|
1837
|
-
this.horizontalHookLocation = horizontalHookLocation || HookLocation.Left;
|
|
1838
|
-
}
|
|
1839
|
-
setToVarianceLabel() {
|
|
1840
|
-
this.isVarianceLabel = true;
|
|
1841
|
-
return this;
|
|
1842
|
-
}
|
|
1843
|
-
setToRelativeVarianceLabel() {
|
|
1844
|
-
this.isVarianceLabel = true;
|
|
1845
|
-
this.isRelativeLabel = true;
|
|
1846
|
-
return this;
|
|
1847
|
-
}
|
|
1848
|
-
setSegmentFill(color) {
|
|
1849
|
-
this.segmentFillColor = color;
|
|
1850
|
-
return this;
|
|
1851
|
-
}
|
|
1852
|
-
setMaxWidth(width) {
|
|
1853
|
-
this.maxWidth = width;
|
|
1854
|
-
return this;
|
|
1855
|
-
}
|
|
1856
|
-
updateGroup(newGroup) {
|
|
1857
|
-
this.group = newGroup;
|
|
1858
|
-
return this;
|
|
1859
|
-
}
|
|
1860
|
-
createElementID(prefix, groupPrefix) {
|
|
1861
|
-
return prefix + "_" + groupPrefix + "_" + this.ID_SCENARIOLABEL;
|
|
1862
|
-
}
|
|
1863
|
-
draw(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
|
|
1864
|
-
var _a;
|
|
1865
|
-
if (this.isEmpty()) {
|
|
1866
|
-
return this;
|
|
1867
|
-
}
|
|
1868
|
-
const label = this.group;
|
|
1869
|
-
let valueStr;
|
|
1870
|
-
const background = this.styles.fontStyles.background || "#ffffff";
|
|
1871
|
-
let prefix = "";
|
|
1872
|
-
let labelAnchor = "start";
|
|
1873
|
-
if (Number.isNaN(Number(this.value)) === false) {
|
|
1874
|
-
let digits = dataFormatDigits.percent;
|
|
1875
|
-
let digitsMin = dataFormatDigits.percent;
|
|
1876
|
-
let scale = 1;
|
|
1877
|
-
const value = this.value;
|
|
1878
|
-
let type = "percent";
|
|
1879
|
-
if (this.isRelativeLabel === false) {
|
|
1880
|
-
digits = dataFormatDigits.decimal;
|
|
1881
|
-
digitsMin = dataFormatDigits.decimal;
|
|
1882
|
-
scale = measureScale.value;
|
|
1883
|
-
type = "decimal";
|
|
1884
|
-
}
|
|
1885
|
-
valueStr = Formatter.number(Number(value), type, digits, digitsMin, scale);
|
|
1886
|
-
if (Number(this.value) < 0) {
|
|
1887
|
-
labelAnchor = "end";
|
|
1888
|
-
}
|
|
1889
|
-
if (this.isVarianceLabel && Number(this.value) >= 0) {
|
|
1890
|
-
prefix = "+";
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
else {
|
|
1894
|
-
valueStr = "" + this.value;
|
|
1895
|
-
labelAnchor = "start";
|
|
1896
|
-
}
|
|
1897
|
-
// @ts-ignore
|
|
1898
|
-
const text = label.text(prefix + valueStr);
|
|
1899
|
-
text.move(this.x, this.y);
|
|
1900
|
-
const boxWidth = text.bbox().w;
|
|
1901
|
-
const boxHeight = text.bbox().h;
|
|
1902
|
-
if (this.maxWidth != null && boxWidth > this.maxWidth) {
|
|
1903
|
-
(_a = this.group) === null || _a === void 0 ? void 0 : _a.remove();
|
|
1904
|
-
this.group = null;
|
|
1905
|
-
return this;
|
|
1906
|
-
}
|
|
1907
|
-
if (this.horizontalHookLocation === HookLocation.Right) {
|
|
1908
|
-
labelAnchor = "end";
|
|
1909
|
-
text.move(text.x() - text.length(), text.y());
|
|
1910
|
-
}
|
|
1911
|
-
else if (this.horizontalHookLocation === HookLocation.Center) {
|
|
1912
|
-
labelAnchor = "middle";
|
|
1913
|
-
text.move(text.x() - text.length() / 2, text.y());
|
|
1914
|
-
}
|
|
1915
|
-
if (this.verticalHookLocation === HookLocation.Center) {
|
|
1916
|
-
text.move(text.x(), text.y() - boxHeight / 2);
|
|
1917
|
-
}
|
|
1918
|
-
else if (this.verticalHookLocation === HookLocation.Bottom) {
|
|
1919
|
-
text.move(text.x(), text.y() - boxHeight);
|
|
1920
|
-
}
|
|
1921
|
-
text.font({ anchor: labelAnchor });
|
|
1922
|
-
if (this.segmentFillColor != null) {
|
|
1923
|
-
text.fill(getContrastTextColor(this.segmentFillColor));
|
|
1924
|
-
}
|
|
1925
|
-
else {
|
|
1926
|
-
label === null || label === void 0 ? void 0 : label.rect(boxWidth, boxHeight * 0.9).stroke(background).fill(background).opacity(0.7).move(text.x(), text.y() + boxHeight * 0.1).insertBefore(text);
|
|
1927
|
-
}
|
|
1928
|
-
return this;
|
|
1929
|
-
}
|
|
1930
|
-
isEmpty() {
|
|
1931
|
-
return this.value == null || "" === this.value;
|
|
1932
|
-
}
|
|
1933
|
-
setPos(xPosition, yPosition) {
|
|
1934
|
-
this.x = xPosition;
|
|
1935
|
-
this.y = yPosition;
|
|
1936
|
-
return this;
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
|
|
1940
|
-
// import {HookLocation} from "../../../ibcs-chart-time/utils/elements";
|
|
1941
|
-
/**
|
|
1942
|
-
* Renders the vertical baseline axis for a structure chart.
|
|
1943
|
-
*
|
|
1944
|
-
* The axis line runs vertically from top to bottom of the data area.
|
|
1945
|
-
* A CSS class based on the scenario type (e.g. "axis-ac") controls stroke style.
|
|
1946
|
-
* An optional title label is drawn at the top of the axis.
|
|
1947
|
-
*/
|
|
1948
|
-
class Axis {
|
|
1949
|
-
constructor(axis, position, svgParentGroup, style) {
|
|
1950
|
-
this.height = 0;
|
|
1951
|
-
this.ID_AXIS = "axis";
|
|
1952
|
-
this.ID_AXIS_TITLE = "axis-title";
|
|
1953
|
-
this.CSS_AXIS_TITLE = "categories";
|
|
1954
|
-
this.scenarioType = axis.scenarioType;
|
|
1955
|
-
this.labelText = axis.labelText || null;
|
|
1956
|
-
this.position = position;
|
|
1957
|
-
this.style = style;
|
|
1958
|
-
this.label = new Label(svgParentGroup, this.position.getAxisTitlePositionX(), this.position.getAxisTitlePositionY(), this.ID_AXIS_TITLE, this.labelText, this.style, HookLocation.Bottom, HookLocation.Center);
|
|
1959
|
-
this.svgGroup = svgParentGroup.group().id(this.ID_AXIS);
|
|
1960
|
-
}
|
|
1961
|
-
draw() {
|
|
1962
|
-
if (this.labelText) {
|
|
1963
|
-
this.label.draw();
|
|
1964
|
-
}
|
|
1965
|
-
this.svgGroup
|
|
1966
|
-
.line(this.position.getAxisPositionX(), this.position.getAxisPositionY(), this.position.getAxisEndPositionX(), this.position.getAxisEndPositionY())
|
|
1967
|
-
.addClass(this.ID_AXIS + "-" + this.convertScenarioType());
|
|
1968
|
-
this.height = this.svgGroup.height();
|
|
1969
|
-
return this;
|
|
1970
|
-
}
|
|
1971
|
-
convertScenarioType() {
|
|
1972
|
-
if (this.scenarioType === undefined || this.scenarioType == null) {
|
|
1973
|
-
return "default";
|
|
1974
|
-
}
|
|
1975
|
-
return `${this.scenarioType}`.slice(0, 2);
|
|
1976
|
-
}
|
|
1977
|
-
}
|
|
1978
|
-
|
|
1979
|
-
// import {HookLocation} from "../../../ibcs-chart-time/utils/elements";
|
|
1980
|
-
// import {SVGPolgonPattern, SVGStyle} from "../../../../utils/model";
|
|
1981
|
-
// import {SVGStyleGroup} from "../../../../utils/model/styles/SVGStyleGroup";
|
|
1982
|
-
// import { DataFormatDigits } from "../../../../utils/model/DataFormatDigits";
|
|
1983
|
-
// import { SiPrefix } from "../../../../utils/model/SiPrefix";
|
|
1984
|
-
/**
|
|
1985
|
-
* Renders a horizontal bar in an IBCS structure chart (the horizontal equivalent of Column).
|
|
1986
|
-
*
|
|
1987
|
-
* Positive values extend rightward from the vertical axis; negative values extend leftward.
|
|
1988
|
-
* Data labels are placed to the right of positive bars and to the left of negative bars.
|
|
1989
|
-
*
|
|
1990
|
-
* Overflow handling mirrors the Column's broken-bar algorithm but on the horizontal axis:
|
|
1991
|
-
* when a bar exceeds the effective cut width, it is split into a base segment and an
|
|
1992
|
-
* overdrive segment separated by vertical zigzag break indicators.
|
|
1993
|
-
*
|
|
1994
|
-
* Primary bars (AC foreground) carry data labels; secondary bars (PP background) do not.
|
|
1995
|
-
*/
|
|
1996
|
-
class Bar {
|
|
1997
|
-
constructor(position, styles, dataPoint, index, isPrimaryBar, scenarioGroup, barLabel, overflowConfig = null) {
|
|
1998
|
-
this.ID_DATA_PREFIX = "DATA";
|
|
1999
|
-
this.ID_SCENARIO_PREFIX = "SCENARIO";
|
|
2000
|
-
this.ID_RECT = "RECT";
|
|
2001
|
-
this.FALLBACK_COLOUR = "#000000";
|
|
2002
|
-
this.label = null;
|
|
2003
|
-
this.scenarioLabel = null;
|
|
2004
|
-
this.barGroup = null;
|
|
2005
|
-
this.isVarianceBar = false;
|
|
2006
|
-
this.overflowConfig = null;
|
|
2007
|
-
this.isOverflowing = false;
|
|
2008
|
-
this.overdriveWidth = 0;
|
|
2009
|
-
this.dimensions = {
|
|
2010
|
-
barLength: 0,
|
|
2011
|
-
xPos: 0,
|
|
2012
|
-
yPos: 0,
|
|
2013
|
-
labelXPos: 0,
|
|
2014
|
-
scenarioLabelXPos: 0,
|
|
2015
|
-
scenarioLabelYPos: 0,
|
|
2016
|
-
clipped: false,
|
|
2017
|
-
};
|
|
2018
|
-
this.hasData = false;
|
|
2019
|
-
this.dataPoint = dataPoint;
|
|
2020
|
-
this.index = index;
|
|
2021
|
-
this.isPrimaryBar = isPrimaryBar;
|
|
2022
|
-
this.position = position;
|
|
2023
|
-
this.barStyles = styles.barStyles;
|
|
2024
|
-
this.overflowConfig = overflowConfig;
|
|
2025
|
-
this.scenarioGroup = scenarioGroup;
|
|
2026
|
-
this.styles = styles;
|
|
2027
|
-
if (scenarioGroup != null) {
|
|
2028
|
-
this.barGroup = scenarioGroup.group().id(scenarioGroup.toString() + "_" + this.ID_RECT);
|
|
2029
|
-
}
|
|
2030
|
-
if ((dataPoint === null || dataPoint === void 0 ? void 0 : dataPoint.isEmpty()) !== true && dataPoint.value != null) {
|
|
2031
|
-
this.hasData = true;
|
|
2032
|
-
let textLabelHook = HookLocation.Left;
|
|
2033
|
-
if (dataPoint.value < 0) {
|
|
2034
|
-
textLabelHook = HookLocation.Right;
|
|
2035
|
-
}
|
|
2036
|
-
this.dimensions = this.createDimensions(position, dataPoint, index, isPrimaryBar);
|
|
2037
|
-
this.label = new Label(this.scenarioGroup, this.dimensions.labelXPos, this.dimensions.yPos, this.ID_DATA_PREFIX, dataPoint.value, this.styles, HookLocation.Center, textLabelHook);
|
|
2038
|
-
this.scenarioLabel = this.getScenarioLabel(barLabel);
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
|
-
setAsVariance() {
|
|
2042
|
-
var _a;
|
|
2043
|
-
this.isVarianceBar = true;
|
|
2044
|
-
(_a = this.label) === null || _a === void 0 ? void 0 : _a.setToVarianceLabel();
|
|
2045
|
-
return this;
|
|
2046
|
-
}
|
|
2047
|
-
isRelativeVariance() {
|
|
2048
|
-
var _a;
|
|
2049
|
-
this.isVarianceBar = true;
|
|
2050
|
-
(_a = this.label) === null || _a === void 0 ? void 0 : _a.setToRelativeVarianceLabel();
|
|
2051
|
-
return this;
|
|
2052
|
-
}
|
|
2053
|
-
updateLabelGroup(newGroup) {
|
|
2054
|
-
var _a;
|
|
2055
|
-
if (this.isEmpty() || newGroup == null) {
|
|
2056
|
-
return this;
|
|
2057
|
-
}
|
|
2058
|
-
(_a = this.label) === null || _a === void 0 ? void 0 : _a.updateGroup(newGroup);
|
|
2059
|
-
return this;
|
|
2060
|
-
}
|
|
2061
|
-
draw(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
|
|
2062
|
-
if (this.isEmpty() || this.dataPoint.getScenario() == null) {
|
|
2063
|
-
return this;
|
|
2064
|
-
}
|
|
2065
|
-
// Bars default to barStyles (falls back to 'ac'); variance bars switch to varianceStyles below
|
|
2066
|
-
let scenarioStyle = this.barStyles.getSVGStyle(this.dataPoint.getScenario());
|
|
2067
|
-
if (this.isVarianceBar) {
|
|
2068
|
-
scenarioStyle = this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle());
|
|
2069
|
-
}
|
|
2070
|
-
const strokeStyle = this.convertToSVGStyle(scenarioStyle, "stroke");
|
|
2071
|
-
let fillStyle = this.convertToSVGStyle(scenarioStyle, "fill");
|
|
2072
|
-
const fillPattern = this.barStyles.getSVGStyle(this.dataPoint.getScenario()).fillpattern;
|
|
2073
|
-
if (fillPattern != null) {
|
|
2074
|
-
const polygonPattern = this.styles.pattern.get(fillPattern);
|
|
2075
|
-
if (polygonPattern != null) {
|
|
2076
|
-
fillStyle = polygonPattern.pattern;
|
|
2077
|
-
}
|
|
2078
|
-
}
|
|
2079
|
-
if (this.barGroup != null) {
|
|
2080
|
-
if (this.isOverflowing && this.overflowConfig) {
|
|
2081
|
-
this.drawOverdriveBar(fillStyle, strokeStyle);
|
|
2082
|
-
}
|
|
2083
|
-
else {
|
|
2084
|
-
this.barGroup
|
|
2085
|
-
.rect(this.dimensions.barLength, this.position.getBarWidth())
|
|
2086
|
-
.fill(fillStyle)
|
|
2087
|
-
.stroke(strokeStyle)
|
|
2088
|
-
.cy(this.dimensions.yPos)
|
|
2089
|
-
.x(this.dimensions.xPos);
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
this.drawBarDataLabel(dataFormatDigits, measureScale);
|
|
2093
|
-
this.drawScenarioLabel();
|
|
2094
|
-
}
|
|
2095
|
-
/** Draws a broken bar: base segment + break gap + overdrive segment (horizontal). */
|
|
2096
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2097
|
-
drawOverdriveBar(fillStyle, strokeStyle) {
|
|
2098
|
-
if (!this.barGroup || !this.overflowConfig)
|
|
2099
|
-
return;
|
|
2100
|
-
const axisX = this.position.getBarPositionX();
|
|
2101
|
-
const barHeight = this.position.getBarWidth();
|
|
2102
|
-
const effectiveCut = this.dimensions.barLength; // scenario-aware cut width
|
|
2103
|
-
const { breakGap } = this.overflowConfig;
|
|
2104
|
-
const isNegative = this.dataPoint.getScaledUnit() < 0;
|
|
2105
|
-
if (isNegative) {
|
|
2106
|
-
// Base bar: from axis leftward
|
|
2107
|
-
this.barGroup
|
|
2108
|
-
.rect(effectiveCut, barHeight)
|
|
2109
|
-
.fill(fillStyle)
|
|
2110
|
-
.stroke(strokeStyle)
|
|
2111
|
-
.x(axisX - effectiveCut)
|
|
2112
|
-
.cy(this.dimensions.yPos);
|
|
2113
|
-
// Overdrive bar: further left past the break gap
|
|
2114
|
-
this.barGroup
|
|
2115
|
-
.rect(this.overdriveWidth, barHeight)
|
|
2116
|
-
.fill(fillStyle)
|
|
2117
|
-
.stroke(strokeStyle)
|
|
2118
|
-
.x(axisX - effectiveCut - breakGap - this.overdriveWidth)
|
|
2119
|
-
.cy(this.dimensions.yPos);
|
|
2120
|
-
// Break indicator covers the full gap on top
|
|
2121
|
-
this.drawBreakIndicator(axisX - effectiveCut - breakGap, breakGap);
|
|
2122
|
-
}
|
|
2123
|
-
else {
|
|
2124
|
-
// Base bar: from axis rightward
|
|
2125
|
-
this.barGroup.rect(effectiveCut, barHeight).fill(fillStyle).stroke(strokeStyle).x(axisX).cy(this.dimensions.yPos);
|
|
2126
|
-
// Overdrive bar: further right past the break gap
|
|
2127
|
-
this.barGroup
|
|
2128
|
-
.rect(this.overdriveWidth, barHeight)
|
|
2129
|
-
.fill(fillStyle)
|
|
2130
|
-
.stroke(strokeStyle)
|
|
2131
|
-
.x(axisX + effectiveCut + breakGap)
|
|
2132
|
-
.cy(this.dimensions.yPos);
|
|
2133
|
-
// Break indicator covers the full gap on top
|
|
2134
|
-
this.drawBreakIndicator(axisX + effectiveCut, breakGap);
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
/** Draws left and right vertical zigzag lines to indicate a broken axis (horizontal bars). */
|
|
2138
|
-
drawBreakIndicator(breakX, breakGap) {
|
|
2139
|
-
if (!this.barGroup)
|
|
2140
|
-
return;
|
|
2141
|
-
const barHeight = this.position.getBarWidth();
|
|
2142
|
-
const yTop = this.dimensions.yPos - barHeight / 2;
|
|
2143
|
-
const midX = breakX + breakGap / 2;
|
|
2144
|
-
const halfGap = breakGap * 0.35;
|
|
2145
|
-
const zigCount = 3;
|
|
2146
|
-
const segHeight = barHeight / zigCount;
|
|
2147
|
-
// Left zigzag line
|
|
2148
|
-
let leftPath = `M ${midX - halfGap} ${yTop}`;
|
|
2149
|
-
for (let i = 0; i < zigCount; i++) {
|
|
2150
|
-
const y1 = yTop + segHeight * (i + 0.5);
|
|
2151
|
-
const y2 = yTop + segHeight * (i + 1);
|
|
2152
|
-
const xPeak = midX - halfGap - breakGap * 0.3;
|
|
2153
|
-
leftPath += ` L ${xPeak} ${y1} L ${midX - halfGap} ${y2}`;
|
|
2154
|
-
}
|
|
2155
|
-
// Right zigzag line
|
|
2156
|
-
let rightPath = `M ${midX + halfGap} ${yTop}`;
|
|
2157
|
-
for (let i = 0; i < zigCount; i++) {
|
|
2158
|
-
const y1 = yTop + segHeight * (i + 0.5);
|
|
2159
|
-
const y2 = yTop + segHeight * (i + 1);
|
|
2160
|
-
const xPeak = midX + halfGap + breakGap * 0.3;
|
|
2161
|
-
rightPath += ` L ${xPeak} ${y1} L ${midX + halfGap} ${y2}`;
|
|
2162
|
-
}
|
|
2163
|
-
// White background covers the full break gap (bar edges provide background for peaks)
|
|
2164
|
-
this.barGroup
|
|
2165
|
-
.rect(breakGap, barHeight + 2)
|
|
2166
|
-
.fill("#ffffff")
|
|
2167
|
-
.stroke("none")
|
|
2168
|
-
.x(breakX)
|
|
2169
|
-
.cy(this.dimensions.yPos);
|
|
2170
|
-
this.barGroup.path(leftPath).fill("none").stroke({ color: "#000000", width: 1 });
|
|
2171
|
-
this.barGroup.path(rightPath).fill("none").stroke({ color: "#000000", width: 1 });
|
|
2172
|
-
}
|
|
2173
|
-
/**
|
|
2174
|
-
* Computes the pixel geometry for the bar: position, length, label anchors.
|
|
2175
|
-
* Handles three cases: overflow (broken bar), negative value, and normal positive.
|
|
2176
|
-
*/
|
|
2177
|
-
createDimensions(position, dataPoint, index, isPrimaryBar) {
|
|
2178
|
-
const scaledUnit = dataPoint.getScaledUnit();
|
|
2179
|
-
const absScaledUnit = Math.abs(scaledUnit);
|
|
2180
|
-
// Check for overdrive overflow
|
|
2181
|
-
if (this.overflowConfig && absScaledUnit > 0) {
|
|
2182
|
-
const isAC = dataPoint.getScenario() === "ac";
|
|
2183
|
-
const effectiveCut = isAC
|
|
2184
|
-
? this.overflowConfig.cutWidth
|
|
2185
|
-
: this.overflowConfig.cutWidth - this.overflowConfig.scenarioCutOffset;
|
|
2186
|
-
if (absScaledUnit > effectiveCut) {
|
|
2187
|
-
this.isOverflowing = true;
|
|
2188
|
-
const { breakGap, overdriveZoneWidth, maxOverflow } = this.overflowConfig;
|
|
2189
|
-
const overflowAmount = absScaledUnit - effectiveCut;
|
|
2190
|
-
this.overdriveWidth = maxOverflow > 0 ? (overflowAmount / maxOverflow) * overdriveZoneWidth : 0;
|
|
2191
|
-
const totalVisualWidth = effectiveCut + breakGap + this.overdriveWidth;
|
|
2192
|
-
if (scaledUnit < 0) {
|
|
2193
|
-
return {
|
|
2194
|
-
clipped: false,
|
|
2195
|
-
barLength: effectiveCut,
|
|
2196
|
-
xPos: position.getBarPositionX() - effectiveCut,
|
|
2197
|
-
yPos: position.getBarPositionY(index, isPrimaryBar),
|
|
2198
|
-
labelXPos: position.getLabelPositionX(-totalVisualWidth),
|
|
2199
|
-
scenarioLabelXPos: position.getBarPositionX() - effectiveCut * 0.5,
|
|
2200
|
-
scenarioLabelYPos: position.getBarPositionY(index, isPrimaryBar) + position.getScenarioLabelPositionOffsetY(isPrimaryBar),
|
|
2201
|
-
};
|
|
2202
|
-
}
|
|
2203
|
-
else {
|
|
2204
|
-
return {
|
|
2205
|
-
clipped: false,
|
|
2206
|
-
barLength: effectiveCut,
|
|
2207
|
-
xPos: position.getBarPositionX(),
|
|
2208
|
-
yPos: position.getBarPositionY(index, isPrimaryBar),
|
|
2209
|
-
labelXPos: position.getLabelPositionX(totalVisualWidth),
|
|
2210
|
-
scenarioLabelXPos: position.getBarPositionX() + effectiveCut * 0.5,
|
|
2211
|
-
scenarioLabelYPos: position.getBarPositionY(index, isPrimaryBar) + position.getScenarioLabelPositionOffsetY(isPrimaryBar),
|
|
2212
|
-
};
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
if (scaledUnit < 0) {
|
|
2217
|
-
return {
|
|
2218
|
-
clipped: false,
|
|
2219
|
-
barLength: absScaledUnit,
|
|
2220
|
-
xPos: position.getBarPositionX() + scaledUnit,
|
|
2221
|
-
yPos: position.getBarPositionY(index, isPrimaryBar),
|
|
2222
|
-
labelXPos: this.position.getLabelPositionX(scaledUnit),
|
|
2223
|
-
scenarioLabelXPos: this.position.getBarPositionX() - absScaledUnit * 0.5,
|
|
2224
|
-
scenarioLabelYPos: this.position.getBarPositionY(index, isPrimaryBar) +
|
|
2225
|
-
this.position.getScenarioLabelPositionOffsetY(isPrimaryBar),
|
|
2226
|
-
};
|
|
2227
|
-
}
|
|
2228
|
-
else {
|
|
2229
|
-
return {
|
|
2230
|
-
clipped: false,
|
|
2231
|
-
barLength: scaledUnit,
|
|
2232
|
-
xPos: position.getBarPositionX(),
|
|
2233
|
-
yPos: position.getBarPositionY(index, isPrimaryBar),
|
|
2234
|
-
labelXPos: this.position.getLabelPositionX(scaledUnit),
|
|
2235
|
-
scenarioLabelXPos: this.position.getBarPositionX() + absScaledUnit * 0.5,
|
|
2236
|
-
scenarioLabelYPos: this.position.getBarPositionY(index, isPrimaryBar) +
|
|
2237
|
-
this.position.getScenarioLabelPositionOffsetY(isPrimaryBar),
|
|
2238
|
-
};
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2242
|
-
convertToSVGStyle(style, mode) {
|
|
2243
|
-
if (style == null) {
|
|
2244
|
-
style = [];
|
|
2245
|
-
}
|
|
2246
|
-
style["color"] = style[mode] || this.FALLBACK_COLOUR;
|
|
2247
|
-
return Object.assign({}, style);
|
|
2248
|
-
}
|
|
2249
|
-
drawScenarioLabel() {
|
|
2250
|
-
if (this.scenarioLabel != null && !this.scenarioLabel.isEmpty() && !this.isVarianceBar) {
|
|
2251
|
-
this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos, this.dimensions.scenarioLabelYPos).draw();
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
drawBarDataLabel(dataFormatDigits, measureScale = new SiPrefix()) {
|
|
2255
|
-
var _a;
|
|
2256
|
-
if (this.isPrimaryBar) {
|
|
2257
|
-
(_a = this.label) === null || _a === void 0 ? void 0 : _a.draw(dataFormatDigits, measureScale);
|
|
2258
|
-
}
|
|
2259
|
-
}
|
|
2260
|
-
isEmpty() {
|
|
2261
|
-
return false === this.hasData || Number.isNaN(this.dataPoint.value);
|
|
2262
|
-
}
|
|
2263
|
-
getScenarioLabel(barLabel) {
|
|
2264
|
-
if (this.isPrimaryBar) {
|
|
2265
|
-
return new Label(this.scenarioGroup, -1, -1, this.ID_SCENARIO_PREFIX, barLabel, this.styles, HookLocation.Top, HookLocation.Center);
|
|
2266
|
-
}
|
|
2267
|
-
return new Label(this.scenarioGroup, -1, -1, this.ID_SCENARIO_PREFIX, barLabel, this.styles, HookLocation.Bottom, HookLocation.Center);
|
|
2268
|
-
}
|
|
2269
|
-
}
|
|
2270
|
-
|
|
2271
|
-
/**
|
|
2272
|
-
* Renders a polygon marker for PP or PL reference values in a structure chart (horizontal layout).
|
|
2273
|
-
*
|
|
2274
|
-
* Markers are positioned horizontally at the data point's scaled value distance from the axis.
|
|
2275
|
-
* They consist of a white background polygon and a scenario-styled foreground polygon.
|
|
2276
|
-
* Primary markers sit above the bar center; secondary markers sit below it.
|
|
2277
|
-
*/
|
|
2278
|
-
class Marker {
|
|
2279
|
-
constructor(position, markerGroup, markerPattern, scenario, styles, dataPoint, index, labelText, isPrimaryMarker) {
|
|
2280
|
-
this.ID_DATA_PREFIX = "DATA";
|
|
2281
|
-
this.ID_SCENARIO_PREFIX = "SCENARIO";
|
|
2282
|
-
this.FALLBACK_COLOUR = "#000000";
|
|
2283
|
-
this.scenarioLabel = null;
|
|
2284
|
-
this._defaultMarkerPattern = null;
|
|
2285
|
-
this.dimensions = {
|
|
2286
|
-
barLength: 0,
|
|
2287
|
-
xPos: 0,
|
|
2288
|
-
yPos: 0,
|
|
2289
|
-
labelXPos: 0,
|
|
2290
|
-
scenarioLabelXPos: 0,
|
|
2291
|
-
scenarioLabelYPos: 0,
|
|
2292
|
-
clipped: false,
|
|
2293
|
-
};
|
|
2294
|
-
this.hasData = false;
|
|
2295
|
-
this.position = position;
|
|
2296
|
-
this.markerGroup = markerGroup || null;
|
|
2297
|
-
this.markerPattern = markerPattern || this._defaultMarkerPattern;
|
|
2298
|
-
this.styles = styles;
|
|
2299
|
-
this.barStyles = styles ? styles.barStyles : null;
|
|
2300
|
-
this.scenario = scenario;
|
|
2301
|
-
if ((dataPoint === null || dataPoint === void 0 ? void 0 : dataPoint.isEmpty()) !== true) {
|
|
2302
|
-
this.hasData = true;
|
|
2303
|
-
this.dimensions = this.createMarkerDimensions(dataPoint, index, isPrimaryMarker);
|
|
2304
|
-
this.scenarioLabel = this.getScenarioLabel(labelText, styles, isPrimaryMarker);
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
createMarkerDimensions(dataPoint, index, isPrimaryMarker) {
|
|
2308
|
-
if (dataPoint.getScaledUnit() < 0) {
|
|
2309
|
-
return {
|
|
2310
|
-
clipped: false,
|
|
2311
|
-
labelXPos: 0,
|
|
2312
|
-
barLength: Math.abs(dataPoint.getScaledUnit()),
|
|
2313
|
-
xPos: this.position.getMarkerPositionX() - Math.abs(dataPoint.getScaledUnit()),
|
|
2314
|
-
yPos: this.position.getMarkerPositionY(index, isPrimaryMarker),
|
|
2315
|
-
scenarioLabelXPos: this.position.getMarkerPositionX() - Math.abs(dataPoint.getScaledUnit()),
|
|
2316
|
-
scenarioLabelYPos: this.position.getMarkerPositionY(index, isPrimaryMarker) +
|
|
2317
|
-
this.position.getMarkerScenarioLabelPositionOffsetY(isPrimaryMarker),
|
|
2318
|
-
};
|
|
2319
|
-
}
|
|
2320
|
-
else {
|
|
2321
|
-
return {
|
|
2322
|
-
clipped: false,
|
|
2323
|
-
labelXPos: 0,
|
|
2324
|
-
barLength: dataPoint.getScaledUnit(),
|
|
2325
|
-
xPos: this.position.getMarkerPositionX() + dataPoint.getScaledUnit(),
|
|
2326
|
-
yPos: this.position.getMarkerPositionY(index, isPrimaryMarker),
|
|
2327
|
-
scenarioLabelXPos: this.position.getMarkerPositionX() + dataPoint.getScaledUnit(),
|
|
2328
|
-
scenarioLabelYPos: this.position.getMarkerPositionY(index, isPrimaryMarker) +
|
|
2329
|
-
this.position.getMarkerScenarioLabelPositionOffsetY(isPrimaryMarker),
|
|
2330
|
-
};
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2333
|
-
getScenarioLabel(labelText, styles, isPrimaryMarker) {
|
|
2334
|
-
if (this.markerGroup == null) {
|
|
2335
|
-
return null;
|
|
2336
|
-
}
|
|
2337
|
-
if (isPrimaryMarker) {
|
|
2338
|
-
return new Label(this.markerGroup, -1, -1, this.ID_DATA_PREFIX, labelText, styles, HookLocation.Bottom, HookLocation.Center);
|
|
2339
|
-
}
|
|
2340
|
-
return new Label(this.markerGroup, -1, -1, this.ID_DATA_PREFIX, labelText, styles, HookLocation.Top, HookLocation.Center);
|
|
2341
|
-
}
|
|
2342
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2343
|
-
convertToSVGStyle(style, mode) {
|
|
2344
|
-
if (style == null) {
|
|
2345
|
-
style = [];
|
|
2346
|
-
}
|
|
2347
|
-
style["color"] = style[mode] || this.FALLBACK_COLOUR;
|
|
2348
|
-
return Object.assign({}, style);
|
|
2349
|
-
}
|
|
2350
|
-
draw() {
|
|
2351
|
-
if (this.isEmpty()) {
|
|
2352
|
-
return this;
|
|
2353
|
-
}
|
|
2354
|
-
const whiteBorder = "#ffffff";
|
|
2355
|
-
const strokeStyle = this.convertToSVGStyle(this.barStyles[this.getScenario()], "stroke");
|
|
2356
|
-
let fillStyle = this.convertToSVGStyle(this.barStyles[this.getScenario()], "fill");
|
|
2357
|
-
const pattern = this.barStyles[this.getScenario()];
|
|
2358
|
-
if (pattern != null && pattern.fillpattern) {
|
|
2359
|
-
const polygonPattern = this.styles.pattern.get(pattern.fillpattern);
|
|
2360
|
-
if (polygonPattern != null) {
|
|
2361
|
-
fillStyle = polygonPattern.pattern;
|
|
2362
|
-
}
|
|
2363
|
-
}
|
|
2364
|
-
this.markerGroup
|
|
2365
|
-
.polygon(this.markerPattern.background)
|
|
2366
|
-
.fill(whiteBorder)
|
|
2367
|
-
.cy(this.dimensions.yPos)
|
|
2368
|
-
.cx(this.dimensions.xPos);
|
|
2369
|
-
this.markerGroup
|
|
2370
|
-
.polygon(this.markerPattern.foreground)
|
|
2371
|
-
.fill(fillStyle)
|
|
2372
|
-
.stroke(strokeStyle)
|
|
2373
|
-
.cy(this.dimensions.yPos)
|
|
2374
|
-
.cx(this.dimensions.xPos);
|
|
2375
|
-
if (this.scenarioLabel != null && !this.scenarioLabel.isEmpty()) {
|
|
2376
|
-
this.scenarioLabel.setPos(this.dimensions.scenarioLabelXPos, this.dimensions.scenarioLabelYPos).draw();
|
|
2377
|
-
}
|
|
2378
|
-
return this;
|
|
2379
|
-
}
|
|
2380
|
-
isEmpty() {
|
|
2381
|
-
return false === this.hasData;
|
|
2382
|
-
}
|
|
2383
|
-
getScenario() {
|
|
2384
|
-
var _a;
|
|
2385
|
-
return (_a = this.scenario) === null || _a === void 0 ? void 0 : _a.slice(0, 2);
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
|
|
2389
|
-
// import {SVGStyle} from "../../../../utils/model/styles/SVGStyle";
|
|
2390
|
-
/**
|
|
2391
|
-
* Renders a horizontal relative variance pin (needle) in an IBCS structure chart.
|
|
2392
|
-
*
|
|
2393
|
-
* The needle is a thin horizontal bar representing a percentage variance, with a head:
|
|
2394
|
-
* - Normal: a square crossbar at the end of the pin
|
|
2395
|
-
* - Clipped (value exceeds the percentage scale): a double-arrow polygon (left or right)
|
|
2396
|
-
* indicating the value was truncated
|
|
2397
|
-
*
|
|
2398
|
-
* Positive pins extend rightward from the axis; negative pins extend leftward.
|
|
2399
|
-
* Labels are placed beyond the needle head with variance-style formatting (percentage + sign).
|
|
2400
|
-
*/
|
|
2401
|
-
class Needle {
|
|
2402
|
-
constructor(position, styles, dataPoint, index, scenarioGroup) {
|
|
2403
|
-
this.ID_DATA_PREFIX = "DATA";
|
|
2404
|
-
this.ID_SCENARIO_PREFIX = "SCENARIO";
|
|
2405
|
-
this.ID_RECT = "RECT";
|
|
2406
|
-
this.FALLBACK_COLOUR = "#000000";
|
|
2407
|
-
this.label = null;
|
|
2408
|
-
this.dimensions = {
|
|
2409
|
-
barLength: 0,
|
|
2410
|
-
xPos: 0,
|
|
2411
|
-
yPos: 0,
|
|
2412
|
-
labelXPos: 0,
|
|
2413
|
-
scenarioLabelXPos: 0,
|
|
2414
|
-
scenarioLabelYPos: 0,
|
|
2415
|
-
clipped: false,
|
|
2416
|
-
};
|
|
2417
|
-
this.hasData = false;
|
|
2418
|
-
this.dataPoint = dataPoint;
|
|
2419
|
-
this.index = index;
|
|
2420
|
-
this.position = position;
|
|
2421
|
-
this.barStyles = styles.barStyles;
|
|
2422
|
-
this.scenarioGroup = scenarioGroup;
|
|
2423
|
-
this.styles = styles;
|
|
2424
|
-
this.barGroup = scenarioGroup.group().id(scenarioGroup.toString() + "_" + this.ID_RECT);
|
|
2425
|
-
if ((dataPoint === null || dataPoint === void 0 ? void 0 : dataPoint.isEmpty()) !== true && dataPoint.value != null) {
|
|
2426
|
-
this.hasData = true;
|
|
2427
|
-
this.dimensions = this.createDimensions(position, dataPoint, index);
|
|
2428
|
-
let textLabelHook = HookLocation.Left;
|
|
2429
|
-
if (dataPoint.value < 0) {
|
|
2430
|
-
textLabelHook = HookLocation.Right;
|
|
2431
|
-
}
|
|
2432
|
-
this.label = new Label(this.scenarioGroup, this.dimensions.labelXPos, this.dimensions.yPos, this.ID_DATA_PREFIX, dataPoint.value, this.styles, HookLocation.Center, textLabelHook);
|
|
2433
|
-
this.label.setToRelativeVarianceLabel();
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
updateLabelGroup(newGroup) {
|
|
2437
|
-
var _a;
|
|
2438
|
-
if (this.isEmpty() || newGroup == null) {
|
|
2439
|
-
return this;
|
|
2440
|
-
}
|
|
2441
|
-
(_a = this.label) === null || _a === void 0 ? void 0 : _a.updateGroup(newGroup);
|
|
2442
|
-
return this;
|
|
2443
|
-
}
|
|
2444
|
-
draw() {
|
|
2445
|
-
var _a;
|
|
2446
|
-
if (this.isEmpty()) {
|
|
2447
|
-
return this;
|
|
2448
|
-
}
|
|
2449
|
-
if (this.dimensions == null) {
|
|
2450
|
-
return this;
|
|
2451
|
-
}
|
|
2452
|
-
// Needles always use varianceStyles (falls back to 'neu'); bars use barStyles (falls back to 'ac')
|
|
2453
|
-
const scenarioStyle = this.styles.varianceStyles.getSVGStyle(this.dataPoint.getVarianceStyle());
|
|
2454
|
-
const strokeStyle = scenarioStyle.stroke;
|
|
2455
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2456
|
-
let fillStyle = scenarioStyle.fill;
|
|
2457
|
-
const pattern = this.barStyles[this.dataPoint.getScenario()];
|
|
2458
|
-
if (pattern != null && pattern.fillpattern) {
|
|
2459
|
-
const polygonPattern = this.styles.pattern.get(pattern.fillpattern);
|
|
2460
|
-
if (polygonPattern != null && polygonPattern.pattern != null) {
|
|
2461
|
-
fillStyle = polygonPattern.pattern;
|
|
2462
|
-
}
|
|
2463
|
-
}
|
|
2464
|
-
this.drawNeedleHead(fillStyle, strokeStyle);
|
|
2465
|
-
this.barGroup
|
|
2466
|
-
.rect(this.dimensions.barLength, this.position.getNeedleWidth())
|
|
2467
|
-
.fill(fillStyle)
|
|
2468
|
-
.stroke(strokeStyle)
|
|
2469
|
-
.cy(this.dimensions.yPos)
|
|
2470
|
-
.x(this.dimensions.xPos);
|
|
2471
|
-
(_a = this.label) === null || _a === void 0 ? void 0 : _a.draw();
|
|
2472
|
-
}
|
|
2473
|
-
createDimensions(position, dataPoint, index) {
|
|
2474
|
-
if (dataPoint.getScaledPercentUnit() < 0) {
|
|
2475
|
-
return {
|
|
2476
|
-
barLength: Math.abs(dataPoint.getScaledPercentUnit()),
|
|
2477
|
-
xPos: position.getBarPositionX() + dataPoint.getScaledPercentUnit(),
|
|
2478
|
-
yPos: position.getBarCenterPositionY(index),
|
|
2479
|
-
labelXPos: this.position.getLabelPositionX(dataPoint.getScaledPercentUnit() - this.position.getNeedleWidth()),
|
|
2480
|
-
clipped: dataPoint.isClipped(),
|
|
2481
|
-
scenarioLabelXPos: 0,
|
|
2482
|
-
scenarioLabelYPos: 0,
|
|
2483
|
-
};
|
|
2484
|
-
}
|
|
2485
|
-
else {
|
|
2486
|
-
return {
|
|
2487
|
-
barLength: dataPoint.getScaledPercentUnit(),
|
|
2488
|
-
xPos: position.getBarPositionX(),
|
|
2489
|
-
yPos: position.getBarCenterPositionY(index),
|
|
2490
|
-
labelXPos: this.position.getLabelPositionX(dataPoint.getScaledPercentUnit() + this.position.getNeedleWidth()),
|
|
2491
|
-
clipped: dataPoint.isClipped(),
|
|
2492
|
-
scenarioLabelXPos: 0,
|
|
2493
|
-
scenarioLabelYPos: 0,
|
|
2494
|
-
};
|
|
2495
|
-
}
|
|
2496
|
-
}
|
|
2497
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2498
|
-
drawNeedleHead(fillStyle, strokeStyle) {
|
|
2499
|
-
if (this.dimensions === null) {
|
|
2500
|
-
return;
|
|
2501
|
-
}
|
|
2502
|
-
const strokeStyleHead = this.styles.varianceStyles.needleHeadColour;
|
|
2503
|
-
const fillStyleHead = this.styles.varianceStyles.needleHeadColour;
|
|
2504
|
-
if (this.dimensions.clipped) {
|
|
2505
|
-
const LEFTARROW = "0,0 9,-5 9,5 0,0 5,0 13,-5 13,5 5,0";
|
|
2506
|
-
const RIGHTARROW = "13,0 4,-5 4,5 13,0 8,0 0,-5 0,5 8,0";
|
|
2507
|
-
let polygonPath = RIGHTARROW;
|
|
2508
|
-
if (this.dataPoint.value != null && this.dataPoint.value < 0) {
|
|
2509
|
-
polygonPath = LEFTARROW;
|
|
2510
|
-
}
|
|
2511
|
-
this.barGroup
|
|
2512
|
-
.polygon(polygonPath)
|
|
2513
|
-
.fill(fillStyle)
|
|
2514
|
-
.cx(this.getHeadXPosition())
|
|
2515
|
-
.cy(this.dimensions.yPos)
|
|
2516
|
-
.fill(fillStyle)
|
|
2517
|
-
.stroke(strokeStyle);
|
|
2518
|
-
}
|
|
2519
|
-
else {
|
|
2520
|
-
this.barGroup
|
|
2521
|
-
.rect(2 * this.position.getNeedleWidth(), 2 * this.position.getNeedleWidth())
|
|
2522
|
-
.cx(this.getHeadXPosition())
|
|
2523
|
-
.cy(this.dimensions.yPos)
|
|
2524
|
-
.fill(strokeStyleHead)
|
|
2525
|
-
.stroke(fillStyleHead);
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
isEmpty() {
|
|
2529
|
-
return false === this.hasData || Number.isNaN(this.dataPoint.value);
|
|
2530
|
-
}
|
|
2531
|
-
getHeadXPosition() {
|
|
2532
|
-
let xPosition = this.dimensions.xPos;
|
|
2533
|
-
if (this.dataPoint.value != null && this.dataPoint.value > 0) {
|
|
2534
|
-
xPosition += this.dimensions.barLength;
|
|
2535
|
-
}
|
|
2536
|
-
return xPosition;
|
|
2537
|
-
}
|
|
2538
|
-
}
|
|
2539
|
-
|
|
2540
|
-
/**
|
|
2541
|
-
* Renders a single horizontal stacked bar segment for the structure chart.
|
|
2542
|
-
*/
|
|
2543
|
-
class StackedBar {
|
|
2544
|
-
constructor(position, styles, dataPoint, index, baselineValue, _segmentLabel, segmentIndex, stackMode, totalValue, _isScenarioStack, parentGroup) {
|
|
2545
|
-
this.hasData = false;
|
|
2546
|
-
this.position = position;
|
|
2547
|
-
this.styles = styles;
|
|
2548
|
-
this.dataPoint = dataPoint;
|
|
2549
|
-
this.index = index;
|
|
2550
|
-
this.baselineValue = baselineValue;
|
|
2551
|
-
this.segmentIndex = segmentIndex;
|
|
2552
|
-
this.stackMode = stackMode;
|
|
2553
|
-
this.totalValue = totalValue;
|
|
2554
|
-
this.group = parentGroup;
|
|
2555
|
-
this.barGroup = parentGroup.group().id(`stacked_bar_${index}_seg_${segmentIndex}`);
|
|
2556
|
-
if ((dataPoint === null || dataPoint === void 0 ? void 0 : dataPoint.isEmpty()) !== true && dataPoint.value != null) {
|
|
2557
|
-
this.hasData = true;
|
|
2558
|
-
}
|
|
2559
|
-
}
|
|
2560
|
-
draw(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
|
|
2561
|
-
if (!this.hasData || this.dataPoint.value == null) {
|
|
2562
|
-
return;
|
|
2563
|
-
}
|
|
2564
|
-
const value = this.dataPoint.value;
|
|
2565
|
-
const pixelPerUnit = this.dataPoint.pixelPerUnit;
|
|
2566
|
-
const axisX = this.position.getBarPositionX();
|
|
2567
|
-
const barWidth = this.position.getBarWidth();
|
|
2568
|
-
let segmentLength;
|
|
2569
|
-
let xPos;
|
|
2570
|
-
if (this.stackMode === StackMode.RELATIVE) {
|
|
2571
|
-
const proportion = this.totalValue !== 0 ? Math.abs(value) / Math.abs(this.totalValue) : 0;
|
|
2572
|
-
const totalPixelLength = pixelPerUnit;
|
|
2573
|
-
segmentLength = proportion * totalPixelLength;
|
|
2574
|
-
const baselinePixels = (this.baselineValue / Math.abs(this.totalValue)) * totalPixelLength;
|
|
2575
|
-
xPos = axisX + baselinePixels;
|
|
2576
|
-
}
|
|
2577
|
-
else {
|
|
2578
|
-
segmentLength = Math.abs(value * pixelPerUnit);
|
|
2579
|
-
const baselinePixels = this.baselineValue * pixelPerUnit;
|
|
2580
|
-
xPos = axisX + baselinePixels;
|
|
2581
|
-
}
|
|
2582
|
-
const yPos = this.position.getBarPositionY(this.index, true);
|
|
2583
|
-
const colors = this.styles.stackColors;
|
|
2584
|
-
const fillColor = colors[this.segmentIndex % colors.length];
|
|
2585
|
-
const fillStyle = { color: fillColor };
|
|
2586
|
-
const strokeStyle = { color: fillColor, width: 0.5 };
|
|
2587
|
-
this.barGroup.rect(Math.max(segmentLength, 0.5), barWidth).fill(fillStyle).stroke(strokeStyle).cy(yPos).x(xPos);
|
|
2588
|
-
// Draw segment value label centered on bar if wide enough
|
|
2589
|
-
const LABEL_PADDING = 6;
|
|
2590
|
-
const availableWidth = segmentLength - LABEL_PADDING;
|
|
2591
|
-
if (availableWidth > 0) {
|
|
2592
|
-
const labelX = xPos + segmentLength / 2;
|
|
2593
|
-
if (this.stackMode === StackMode.RELATIVE || this.stackMode === StackMode.ABSOLUTE_RELATIVE) {
|
|
2594
|
-
const pct = this.totalValue !== 0 ? (value / this.totalValue) * 100 : 0;
|
|
2595
|
-
const labelValue = pct.toFixed(dataFormatDigits.percent) + "%";
|
|
2596
|
-
new Label(this.group, labelX, yPos, "STACK_SEG", labelValue, this.styles, HookLocation.Center, HookLocation.Center)
|
|
2597
|
-
.setSegmentFill(fillColor)
|
|
2598
|
-
.setMaxWidth(availableWidth)
|
|
2599
|
-
.draw();
|
|
2600
|
-
}
|
|
2601
|
-
else {
|
|
2602
|
-
// Pass raw numeric value — Label.draw() formats with measureScale
|
|
2603
|
-
new Label(this.group, labelX, yPos, "STACK_SEG", value, this.styles, HookLocation.Center, HookLocation.Center)
|
|
2604
|
-
.setSegmentFill(fillColor)
|
|
2605
|
-
.setMaxWidth(availableWidth)
|
|
2606
|
-
.draw(dataFormatDigits, measureScale);
|
|
2607
|
-
}
|
|
2608
|
-
}
|
|
2609
|
-
}
|
|
2610
|
-
drawTotalLabel(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
|
|
2611
|
-
if (this.stackMode === StackMode.RELATIVE) {
|
|
2612
|
-
return;
|
|
2613
|
-
}
|
|
2614
|
-
const axisX = this.position.getBarPositionX();
|
|
2615
|
-
const totalPixels = this.totalValue * this.dataPoint.pixelPerUnit;
|
|
2616
|
-
const labelX = axisX + totalPixels + this.position.spacings.labelToBar;
|
|
2617
|
-
const yPos = this.position.getBarPositionY(this.index, true);
|
|
2618
|
-
const label = new Label(this.group, labelX, yPos, "STACK_TOTAL", this.totalValue, this.styles, HookLocation.Center, HookLocation.Left);
|
|
2619
|
-
label.draw(dataFormatDigits, measureScale);
|
|
2620
|
-
}
|
|
2621
|
-
}
|
|
2622
|
-
|
|
2623
|
-
// import { SVGPolgonPattern} from "../../../../utils/model";
|
|
2624
|
-
/**
|
|
2625
|
-
* Factory for creating horizontal bar chart elements (Bar, Needle, Marker) within the
|
|
2626
|
-
* correct SVG group hierarchy for a structure chart.
|
|
2627
|
-
*
|
|
2628
|
-
* Manages 4 SVG group layers for z-ordering (back-to-front):
|
|
2629
|
-
* - scenario2: secondary bars (PP) -- inserted before scenario1 so they render behind
|
|
2630
|
-
* - scenario1: primary bars (AC) -- foreground
|
|
2631
|
-
* - scenario3: primary markers (positioned above bar center)
|
|
2632
|
-
* - scenario4: secondary markers (positioned below bar center)
|
|
2633
|
-
* - scenario1Label: label group, always on top
|
|
2634
|
-
*
|
|
2635
|
-
* createPrimaryBar() / createSecondaryBar() produce foreground/background Bar instances.
|
|
2636
|
-
* createVarianceBar() wraps a Bar with variance styling.
|
|
2637
|
-
* createRelativeVarianceBar() creates a horizontal Needle for percentage variance.
|
|
2638
|
-
*/
|
|
2639
|
-
class ScenarioFactory {
|
|
2640
|
-
constructor(position, scenariosGroupParent, styles, elementCnt, i18n) {
|
|
2641
|
-
this.overflowConfig = null;
|
|
2642
|
-
this.i18n = i18n;
|
|
2643
|
-
const primScenario = scenariosGroupParent.group().id("Scenario1");
|
|
2644
|
-
const secondScenario = scenariosGroupParent.group().id("Scenario2").insertBefore(primScenario);
|
|
2645
|
-
this.svgGroups = {
|
|
2646
|
-
parent: scenariosGroupParent,
|
|
2647
|
-
scenario1: primScenario,
|
|
2648
|
-
scenario2: secondScenario,
|
|
2649
|
-
scenario3: scenariosGroupParent.group().id("Scenario3"),
|
|
2650
|
-
scenario4: scenariosGroupParent.group().id("Scenario4"),
|
|
2651
|
-
scenario1Label: scenariosGroupParent.group().id("label"),
|
|
2652
|
-
};
|
|
2653
|
-
this.styles = styles;
|
|
2654
|
-
this.position = position;
|
|
2655
|
-
this.elementCnt = elementCnt;
|
|
2656
|
-
}
|
|
2657
|
-
setOverflowConfig(config) {
|
|
2658
|
-
this.overflowConfig = config;
|
|
2659
|
-
}
|
|
2660
|
-
isLastDataPoint(index) {
|
|
2661
|
-
return this.elementCnt - 1 === index;
|
|
2662
|
-
}
|
|
2663
|
-
isFirsttDataPoint(index) {
|
|
2664
|
-
return 0 === index;
|
|
2665
|
-
}
|
|
2666
|
-
createPrimaryBar(dataPoint, index) {
|
|
2667
|
-
var _a, _b, _c, _d;
|
|
2668
|
-
const isPrimaryBar = true;
|
|
2669
|
-
const barGroup = (_b = (_a = this.svgGroups) === null || _a === void 0 ? void 0 : _a.scenario1) === null || _b === void 0 ? void 0 : _b.group().id("" + index);
|
|
2670
|
-
const labelGroup = (_d = (_c = this.svgGroups) === null || _c === void 0 ? void 0 : _c.scenario1Label) === null || _d === void 0 ? void 0 : _d.group().id("" + index);
|
|
2671
|
-
let barLabel = null;
|
|
2672
|
-
if (this.isLastDataPoint(index)) {
|
|
2673
|
-
barLabel = `${this.i18n.get(dataPoint.scenario) || dataPoint.scenario}`;
|
|
2674
|
-
}
|
|
2675
|
-
return new Bar(this.position, this.styles, dataPoint, index, isPrimaryBar, barGroup, barLabel, this.overflowConfig).updateLabelGroup(labelGroup);
|
|
2676
|
-
}
|
|
2677
|
-
createVarianceBar(dataPoint, index) {
|
|
2678
|
-
var _a, _b, _c, _d;
|
|
2679
|
-
const isPrimaryBar = true;
|
|
2680
|
-
const barGroup = (_b = (_a = this.svgGroups) === null || _a === void 0 ? void 0 : _a.scenario1) === null || _b === void 0 ? void 0 : _b.group().id("" + index);
|
|
2681
|
-
const labelGroup = (_d = (_c = this.svgGroups) === null || _c === void 0 ? void 0 : _c.scenario1Label) === null || _d === void 0 ? void 0 : _d.group().id("" + index);
|
|
2682
|
-
let barLabel = null;
|
|
2683
|
-
if (this.isLastDataPoint(index)) {
|
|
2684
|
-
barLabel = `${this.i18n.get(dataPoint.scenario) || dataPoint.scenario}`;
|
|
2685
|
-
}
|
|
2686
|
-
return new Bar(this.position, this.styles, dataPoint, index, isPrimaryBar, barGroup, barLabel, this.overflowConfig)
|
|
2687
|
-
.updateLabelGroup(labelGroup)
|
|
2688
|
-
.setAsVariance();
|
|
2689
|
-
}
|
|
2690
|
-
createRelativeVarianceBar(dataPoint, index) {
|
|
2691
|
-
var _a, _b, _c, _d;
|
|
2692
|
-
const barGroup = (_b = (_a = this.svgGroups) === null || _a === void 0 ? void 0 : _a.scenario1) === null || _b === void 0 ? void 0 : _b.group().id("" + index);
|
|
2693
|
-
const labelGroup = (_d = (_c = this.svgGroups) === null || _c === void 0 ? void 0 : _c.scenario1Label) === null || _d === void 0 ? void 0 : _d.group().id("" + index);
|
|
2694
|
-
return new Needle(this.position, this.styles, dataPoint, index, barGroup).updateLabelGroup(labelGroup);
|
|
2695
|
-
}
|
|
2696
|
-
createSecondaryBar(dataPoint, index) {
|
|
2697
|
-
var _a, _b;
|
|
2698
|
-
const barGroup = (_b = (_a = this.svgGroups) === null || _a === void 0 ? void 0 : _a.scenario2) === null || _b === void 0 ? void 0 : _b.group().id("" + index);
|
|
2699
|
-
let barLabel = null;
|
|
2700
|
-
if (this.isFirsttDataPoint(index)) {
|
|
2701
|
-
barLabel = `${this.i18n.get(dataPoint.scenario) || dataPoint.scenario}`;
|
|
2702
|
-
}
|
|
2703
|
-
return new Bar(this.position, this.styles, dataPoint, index, false, barGroup, barLabel, this.overflowConfig);
|
|
2704
|
-
}
|
|
2705
|
-
createPrimaryMarker(dataPoint, index) {
|
|
2706
|
-
var _a, _b;
|
|
2707
|
-
const markerGroup = (_b = (_a = this.svgGroups) === null || _a === void 0 ? void 0 : _a.scenario3) === null || _b === void 0 ? void 0 : _b.group().id("" + index);
|
|
2708
|
-
const markerPattern = this.styles.pattern.get("marker-down") || {
|
|
2709
|
-
foreground: "0,0 1,0 1,1 0,1",
|
|
2710
|
-
background: "0,0 1,0 1,1 0,1",
|
|
2711
|
-
bgOffset: 0,
|
|
2712
|
-
};
|
|
2713
|
-
const isPrimaryMarker = true;
|
|
2714
|
-
let labelText = null;
|
|
2715
|
-
if (this.isFirstDataPoint(index)) {
|
|
2716
|
-
labelText = `${this.i18n.get(dataPoint.scenario) || dataPoint.scenario}`;
|
|
2717
|
-
}
|
|
2718
|
-
return new Marker(this.position, markerGroup, markerPattern, dataPoint.scenario, this.styles, dataPoint, index, labelText, isPrimaryMarker);
|
|
2719
|
-
}
|
|
2720
|
-
createSecondaryMarker(dataPoint, index) {
|
|
2721
|
-
var _a, _b;
|
|
2722
|
-
const markerGroup = (_b = (_a = this.svgGroups) === null || _a === void 0 ? void 0 : _a.scenario4) === null || _b === void 0 ? void 0 : _b.group().id("" + index);
|
|
2723
|
-
const markerPattern = this.styles.pattern.get("marker-up") || {
|
|
2724
|
-
foreground: "0,0 1,0 1,1 0,1",
|
|
2725
|
-
background: "0,0 1,0 1,1 0,1",
|
|
2726
|
-
bgOffset: 0,
|
|
2727
|
-
};
|
|
2728
|
-
const isPrimaryMarker = false;
|
|
2729
|
-
let labelText = null;
|
|
2730
|
-
if (this.isLastDataPoint(index)) {
|
|
2731
|
-
labelText = `${this.i18n.get(dataPoint.scenario) || dataPoint.scenario}`;
|
|
2732
|
-
}
|
|
2733
|
-
return new Marker(this.position, markerGroup, markerPattern, dataPoint.scenario, this.styles, dataPoint, index, labelText, isPrimaryMarker);
|
|
2734
|
-
}
|
|
2735
|
-
isFirstDataPoint(index) {
|
|
2736
|
-
return 0 === index;
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
|
|
2740
|
-
/**
|
|
2741
|
-
* Orchestrates the full rendering pipeline for an IBCS structure (categorical) chart.
|
|
2742
|
-
*
|
|
2743
|
-
* Rendering pipeline (in draw()):
|
|
2744
|
-
* 1. Clears the SVG container
|
|
2745
|
-
* 2. Routes to the appropriate drawing method:
|
|
2746
|
-
* - Variance chart: drawVarianceScenario() for absolute/relative variance bars
|
|
2747
|
-
* - Stacked chart: drawStackedScenarios() + drawStackedHeaders()
|
|
2748
|
-
* - Standard chart: drawScenarios() with primary/secondary bars and markers
|
|
2749
|
-
* 3. Draws vertical axis + category labels via drawAxisAndLabels()
|
|
2750
|
-
*
|
|
2751
|
-
* Data pipeline (in setConfig()):
|
|
2752
|
-
* 1. Raw data is filtered via AlaSQL
|
|
2753
|
-
* 2. Categories are aggregated (GROUP BY) with operation-sign-aware SUM
|
|
2754
|
-
* 3. Optional limit + REST row aggregation for top-N display
|
|
2755
|
-
* 4. Variance model is computed from base/delta scenario pairs
|
|
2756
|
-
* 5. Min/max DataPoints drive the coordinate system sizing
|
|
2757
|
-
*
|
|
2758
|
-
* Overflow handling: setAvailableWidth() can enable broken-bar rendering
|
|
2759
|
-
* when bars exceed the container width.
|
|
2760
|
-
*/
|
|
2761
|
-
class StructureChart {
|
|
2762
|
-
constructor(ruleSet, config, styles) {
|
|
2763
|
-
this.dataModel = [];
|
|
2764
|
-
this.variancesDataModel = [];
|
|
2765
|
-
this.title = "";
|
|
2766
|
-
this.smallestDataPointValue = new DataPoint(0, Scenario.AC1, 1, Scenario.NEU);
|
|
2767
|
-
this.highestDataPointValue = new DataPoint(0, Scenario.AC1, 1, Scenario.NEU);
|
|
2768
|
-
this.smallestVarianceDataPointValue = new DataPoint(0, Scenario.AC1, 1, Scenario.NEU);
|
|
2769
|
-
this.highestVarianceDataPointValue = new DataPoint(0, Scenario.AC1, 1, Scenario.NEU);
|
|
2770
|
-
this.pixelPerUnit = 1;
|
|
2771
|
-
this.pixelPerPercentage = 1;
|
|
2772
|
-
this.hideCategories = false;
|
|
2773
|
-
this.axisScenario = Scenario.AC1;
|
|
2774
|
-
this.CSS_CATEGORIES = "categories";
|
|
2775
|
-
this.preparedDataSet = [];
|
|
2776
|
-
this.state = FactoryState.DIRTY;
|
|
2777
|
-
this.titleLength = 0;
|
|
2778
|
-
this.leftSideOffsetForHorizontalSync = 0;
|
|
2779
|
-
this.limit = 0;
|
|
2780
|
-
this.measureScale = new SiPrefix();
|
|
2781
|
-
this.measureUnit = "";
|
|
2782
|
-
this.dataFormatDigits = { percent: 2, decimal: 1 };
|
|
2783
|
-
this.stackConfig = null;
|
|
2784
|
-
this.overflowConfig = null;
|
|
2785
|
-
this.highestStackedTotal = 0;
|
|
2786
|
-
this.initSQLFunctions();
|
|
2787
|
-
this.ruleSet = ruleSet || new IBCSRuleSet();
|
|
2788
|
-
this.i18n = this.createI18n(new Map());
|
|
2789
|
-
this.styles = styles;
|
|
2790
|
-
this.setConfig(config);
|
|
2791
|
-
this.position = this.createElementPosition();
|
|
2792
|
-
}
|
|
2793
|
-
updatePosition() {
|
|
2794
|
-
this.position = this.createElementPosition();
|
|
2795
|
-
}
|
|
2796
|
-
createElementPosition() {
|
|
2797
|
-
this.titleLength = this.calculateTitleLength(0);
|
|
2798
|
-
let leftSideWidth = this.calculateLeftSideWidth(this.getVarianceType());
|
|
2799
|
-
const categoryWidth = this.calculateCategoryWidth();
|
|
2800
|
-
if (this.titleLength > leftSideWidth) {
|
|
2801
|
-
leftSideWidth = this.titleLength;
|
|
2802
|
-
}
|
|
2803
|
-
return new ElementPositions(new Padding(this.styles.padding), this.styles.scaleFactors, this.styles.fontStyles.size, this.dataModel.length, this.leftSideOffsetForHorizontalSync, this.titleLength, leftSideWidth, categoryWidth);
|
|
2804
|
-
}
|
|
2805
|
-
initSQLFunctions() {
|
|
2806
|
-
alasql.fn.transformOperator = function (a) {
|
|
2807
|
-
return a === "-" ? -1 : 1;
|
|
2808
|
-
};
|
|
2809
|
-
}
|
|
2810
|
-
setStyles(newStyle) {
|
|
2811
|
-
this.styles = newStyle;
|
|
2812
|
-
}
|
|
2813
|
-
setConfig(config) {
|
|
2814
|
-
var _a;
|
|
2815
|
-
this.state = FactoryState.DIRTY;
|
|
2816
|
-
this.sortScenariosbyVisualisationRules(config);
|
|
2817
|
-
this.hideCategories = config.hideCategories || false;
|
|
2818
|
-
this.limit = config.limit;
|
|
2819
|
-
this.pixelPerUnit = config.pixelPerUnit || 1;
|
|
2820
|
-
this.pixelPerPercentage = config.pixelPerPercentage || 100;
|
|
2821
|
-
this.setData([...config.data], config.filter);
|
|
2822
|
-
this.dataModel = this.populateModel(config.scenarios, config.level, config.sortOrder);
|
|
2823
|
-
// Populate per-dimension stack segments when stacking by a data dimension
|
|
2824
|
-
if (config.stackConfig && config.stackConfig.by !== StackBy.SCENARIOS) {
|
|
2825
|
-
this.populateDimensionStackSegments(config.scenarios, config.stackConfig, config.level);
|
|
2826
|
-
}
|
|
2827
|
-
this.variancesDataModel = this.populateVarianceModel(config.variances, this.dataModel);
|
|
2828
|
-
this.title = config.title || Formatter.translateScenarioLabel((_a = config === null || config === void 0 ? void 0 : config.variances) === null || _a === void 0 ? void 0 : _a.toString(), this.i18n);
|
|
2829
|
-
this.smallestDataPointValue = this.findSmallestDataPointValue(this.dataModel);
|
|
2830
|
-
this.smallestVarianceDataPointValue = this.findSmallestDataPointValue(this.variancesDataModel);
|
|
2831
|
-
this.highestDataPointValue = this.findHighestDataPointValue(this.dataModel);
|
|
2832
|
-
this.highestVarianceDataPointValue = this.findHighestDataPointValue(this.variancesDataModel);
|
|
2833
|
-
this.axisScenario = this.setAxisScenario(config.variances);
|
|
2834
|
-
this.measureScale = config.measureScale;
|
|
2835
|
-
this.measureUnit = config.measureUnit;
|
|
2836
|
-
this.dataFormatDigits = config.dataFormatDigits;
|
|
2837
|
-
this.stackConfig = config.stackConfig;
|
|
2838
|
-
this.highestStackedTotal = this.findHighestStackedRowTotal(this.dataModel);
|
|
2839
|
-
this.updatePosition();
|
|
2840
|
-
}
|
|
2841
|
-
sortScenariosbyVisualisationRules(config) {
|
|
2842
|
-
const self = this;
|
|
2843
|
-
config.scenarios
|
|
2844
|
-
.sort((n1, n2) => {
|
|
2845
|
-
return self.ruleSet.getScenarioSorIndex(n1) - self.ruleSet.getScenarioSorIndex(n2);
|
|
2846
|
-
})
|
|
2847
|
-
.reverse();
|
|
2848
|
-
}
|
|
2849
|
-
/**
|
|
2850
|
-
* Init load of translation dictionary map
|
|
2851
|
-
* map is used to translate lables in the table
|
|
2852
|
-
*
|
|
2853
|
-
* example:
|
|
2854
|
-
* ```
|
|
2855
|
-
* let i18n: Map<string, string> = new Map();
|
|
2856
|
-
* [{key: 'ac',value: 'AC'}].forEach(function(entry){
|
|
2857
|
-
* i18n.set(entry.key, entry.value);
|
|
2858
|
-
* })
|
|
2859
|
-
* ```
|
|
2860
|
-
* @param i18n
|
|
2861
|
-
*/
|
|
2862
|
-
setI18n(i18n) {
|
|
2863
|
-
this.i18n = this.createI18n(i18n);
|
|
2864
|
-
}
|
|
2865
|
-
createI18n(i18n) {
|
|
2866
|
-
this.state = FactoryState.DIRTY;
|
|
2867
|
-
const defaultI18n = new Map([
|
|
2868
|
-
["SEPERATOR_WS", ", "],
|
|
2869
|
-
["in", "in"],
|
|
2870
|
-
["ORDER_asc", "↑"],
|
|
2871
|
-
["ORDER_desc", "↓"],
|
|
2872
|
-
["ac1", "AC"],
|
|
2873
|
-
["pp1", "PY"],
|
|
2874
|
-
["fc1", "FC"],
|
|
2875
|
-
["pl1", "PL"],
|
|
2876
|
-
["ac2", "AC2"],
|
|
2877
|
-
["pp2", "PY2"],
|
|
2878
|
-
["fc2", "FC2"],
|
|
2879
|
-
["pl2", "PL2"],
|
|
2880
|
-
["ac3", "AC3"],
|
|
2881
|
-
["pp3", "PY3"],
|
|
2882
|
-
["fc3", "FC3"],
|
|
2883
|
-
["pl3", "PL3"],
|
|
2884
|
-
["ac4", "AC4"],
|
|
2885
|
-
["pp4", "PY4"],
|
|
2886
|
-
["fc4", "FC4"],
|
|
2887
|
-
["pl4", "PL4"],
|
|
2888
|
-
["category", " "],
|
|
2889
|
-
["operation", " "],
|
|
2890
|
-
["there_of", "davon"],
|
|
2891
|
-
["part_of", "in % von"],
|
|
2892
|
-
["ibcssymbol_delta_ac", "Δ{%}"],
|
|
2893
|
-
["ibcssymbol_delta_generic", "Δ({%})"],
|
|
2894
|
-
["ibcssymbol_delta_ac_relative", "Δ{%}%"],
|
|
2895
|
-
["ibcssymbol_delta_generic_relative", "Δ({%})%"],
|
|
2896
|
-
["SUM_TOTAL", "❖"],
|
|
2897
|
-
]);
|
|
2898
|
-
return new Map([...defaultI18n, ...i18n]);
|
|
2899
|
-
}
|
|
2900
|
-
/**
|
|
2901
|
-
* Init load raw datasets the loaded dataset is
|
|
2902
|
-
* the base on which the filters defined in the config
|
|
2903
|
-
* are apllied on internaly it is called prepared DataSet
|
|
2904
|
-
*
|
|
2905
|
-
* @param data
|
|
2906
|
-
* @param filter - data filter
|
|
2907
|
-
* @param customColumnNameMap Custon ColumnNameMap can be used if data uses non standard columnames
|
|
2908
|
-
*/
|
|
2909
|
-
setData(data, filter) {
|
|
2910
|
-
if (data == null) {
|
|
2911
|
-
return;
|
|
2912
|
-
}
|
|
2913
|
-
this.state = FactoryState.DIRTY; // mark dataSet for update
|
|
2914
|
-
this.preparedDataSet.length = 0; // cleans formerly loaded and prepared dataset
|
|
2915
|
-
if (filter != null && filter.length > 0) {
|
|
2916
|
-
try {
|
|
2917
|
-
this.preparedDataSet = alasql(`SELECT * FROM ? WHERE ${filter}`, [data]);
|
|
2918
|
-
}
|
|
2919
|
-
catch (e) {
|
|
2920
|
-
console.error("StructureChart: filter query failed, using unfiltered data", filter, e);
|
|
2921
|
-
this.preparedDataSet = data;
|
|
2922
|
-
}
|
|
2923
|
-
}
|
|
2924
|
-
else {
|
|
2925
|
-
this.preparedDataSet = data;
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
/**
|
|
2929
|
-
* Returns the data value whose bar extent is proportional to pixelPerUnit.
|
|
2930
|
-
* Used by autoFitScaling to separate fixed vs variable width components.
|
|
2931
|
-
*/
|
|
2932
|
-
getMaxBarValue() {
|
|
2933
|
-
var _a, _b;
|
|
2934
|
-
// Stacked: bar extent = highestStackedTotal * ppu (or just ppu for relative)
|
|
2935
|
-
if (this.stackConfig != null && this.highestStackedTotal > 0) {
|
|
2936
|
-
if (this.stackConfig.mode === StackMode.RELATIVE) {
|
|
2937
|
-
return 1;
|
|
2938
|
-
}
|
|
2939
|
-
return this.highestStackedTotal;
|
|
2940
|
-
}
|
|
2941
|
-
// Non-stacked: bar extent = highestDataPointValue * ppu
|
|
2942
|
-
const vt = this.getVarianceType();
|
|
2943
|
-
if (vt === VarianceType.NONE && ((_a = this.highestDataPointValue) === null || _a === void 0 ? void 0 : _a.value) != null) {
|
|
2944
|
-
return Math.abs(this.highestDataPointValue.value);
|
|
2945
|
-
}
|
|
2946
|
-
if (vt === VarianceType.ABSOLUTE && ((_b = this.highestVarianceDataPointValue) === null || _b === void 0 ? void 0 : _b.value) != null) {
|
|
2947
|
-
return Math.abs(this.highestVarianceDataPointValue.value);
|
|
2948
|
-
}
|
|
2949
|
-
// RELATIVE variance depends on pixelPerPercentage, not pixelPerUnit
|
|
2950
|
-
return 0;
|
|
2951
|
-
}
|
|
2952
|
-
getAllocatedCanvasWidth() {
|
|
2953
|
-
//let columnLabelWidth = this.calculateCategoryWidth();
|
|
2954
|
-
const leftSideWidth = this.position.getAxisPositionX(); //this.calculateLeftSideWidth(this.getVarianceType());
|
|
2955
|
-
const rightSideWidth = this.calculateRightSideWidth(this.getVarianceType());
|
|
2956
|
-
let width = leftSideWidth + rightSideWidth + +this.styles.padding.left + this.styles.padding.right;
|
|
2957
|
-
if (rightSideWidth < this.titleLength / 2) {
|
|
2958
|
-
width += this.titleLength / 2;
|
|
2959
|
-
}
|
|
2960
|
-
if (leftSideWidth < this.titleLength / 2) {
|
|
2961
|
-
width += this.titleLength / 2;
|
|
2962
|
-
}
|
|
2963
|
-
return width;
|
|
2964
|
-
}
|
|
2965
|
-
getAllocatedCanvasHeight() {
|
|
2966
|
-
return ((this.dataModel.length + 1) * this.position.spacings.categoryWidth +
|
|
2967
|
-
this.styles.padding.top +
|
|
2968
|
-
this.styles.padding.bottom);
|
|
2969
|
-
}
|
|
2970
|
-
patternToString() {
|
|
2971
|
-
return "<svg></svg>";
|
|
2972
|
-
}
|
|
2973
|
-
toString() {
|
|
2974
|
-
const container = new Svg();
|
|
2975
|
-
this.draw(container);
|
|
2976
|
-
container.id("drawCanvas");
|
|
2977
|
-
container.width(this.getAllocatedCanvasWidth());
|
|
2978
|
-
container.height(this.getAllocatedCanvasHeight());
|
|
2979
|
-
return container.svg();
|
|
2980
|
-
}
|
|
2981
|
-
draw(svgContainer) {
|
|
2982
|
-
this.cleanSVGforRedraw(svgContainer);
|
|
2983
|
-
if (this.state === FactoryState.DIRTY) {
|
|
2984
|
-
this.state = FactoryState.UP_TO_DATE;
|
|
2985
|
-
}
|
|
2986
|
-
if (this.variancesDataModel && this.variancesDataModel.length > 0) {
|
|
2987
|
-
this.drawVarianceScenario(this.variancesDataModel, svgContainer);
|
|
2988
|
-
this.drawAxisAndLabels(this.variancesDataModel, svgContainer);
|
|
2989
|
-
}
|
|
2990
|
-
else if (this.stackConfig != null) {
|
|
2991
|
-
this.drawStackedScenarios(this.dataModel, svgContainer);
|
|
2992
|
-
this.drawStackedHeaders(this.dataModel, svgContainer);
|
|
2993
|
-
this.drawAxisAndLabels(this.dataModel, svgContainer);
|
|
2994
|
-
}
|
|
2995
|
-
else {
|
|
2996
|
-
this.drawScenarios(this.dataModel, svgContainer);
|
|
2997
|
-
this.drawAxisAndLabels(this.dataModel, svgContainer);
|
|
2998
|
-
}
|
|
2999
|
-
}
|
|
3000
|
-
setPattern(fc, fcPolygonPattern) {
|
|
3001
|
-
this.styles.pattern.set(fc, fcPolygonPattern);
|
|
3002
|
-
}
|
|
3003
|
-
calculateTitleLength(minWidth) {
|
|
3004
|
-
const tmpTitle = "_______"; // default width if this.title is sorther
|
|
3005
|
-
const width = CalculateSize(this.title.length > tmpTitle.length ? this.title : tmpTitle, {
|
|
3006
|
-
font: this.styles.fontStyles.font,
|
|
3007
|
-
fontSize: this.styles.fontStyles.size + "px",
|
|
3008
|
-
}).width;
|
|
3009
|
-
if (width < minWidth) {
|
|
3010
|
-
return minWidth;
|
|
3011
|
-
}
|
|
3012
|
-
return width / 2;
|
|
3013
|
-
}
|
|
3014
|
-
getFooter() {
|
|
3015
|
-
if (this.measureScale.value === 1 && this.measureUnit === "") {
|
|
3016
|
-
return " ";
|
|
3017
|
-
}
|
|
3018
|
-
return Formatter.translateScenarioLabel("in", this.i18n) + " " + this.measureScale.prefix + this.measureUnit;
|
|
3019
|
-
}
|
|
3020
|
-
setAxisScenario(scenarios) {
|
|
3021
|
-
let result = Scenario.AC1;
|
|
3022
|
-
if (scenarios != null && scenarios.length > 0) {
|
|
3023
|
-
const axis = new VarianceScenario(scenarios.toString());
|
|
3024
|
-
if (axis.isValid) {
|
|
3025
|
-
result = axis.delta;
|
|
3026
|
-
}
|
|
3027
|
-
}
|
|
3028
|
-
if (result === null) {
|
|
3029
|
-
// arrays with invalid scenarios are set to Senario.AC Fallback
|
|
3030
|
-
result = Scenario.AC1;
|
|
3031
|
-
}
|
|
3032
|
-
return result;
|
|
3033
|
-
}
|
|
3034
|
-
populateModel(selectedScenarios, level, sortOrder) {
|
|
3035
|
-
var _a;
|
|
3036
|
-
if (((_a = this.preparedDataSet) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
3037
|
-
return [];
|
|
3038
|
-
}
|
|
3039
|
-
const dataModel = [];
|
|
3040
|
-
const orderStr = this.createOrderStr(level, sortOrder);
|
|
3041
|
-
const select = this.createSelectString(level, sortOrder);
|
|
3042
|
-
const groupByStr = this.createGroupByStr(level, sortOrder);
|
|
3043
|
-
const result = alasql(`SELECT ${select} ${selectedScenarios.length > 0
|
|
3044
|
-
? "," +
|
|
3045
|
-
selectedScenarios
|
|
3046
|
-
.map((scenario) => {
|
|
3047
|
-
return `SUM(${scenario} * transformOperator(operation)) as ${scenario}, COUNT(ISNULL(${scenario})) as ${scenario}_cnt`;
|
|
3048
|
-
})
|
|
3049
|
-
.join(",")
|
|
3050
|
-
: ""}
|
|
3051
|
-
FROM ?
|
|
3052
|
-
GROUP BY ${groupByStr}
|
|
3053
|
-
ORDER BY ${orderStr}`, [this.preparedDataSet]);
|
|
3054
|
-
this.detectNaNCells(selectedScenarios, result);
|
|
3055
|
-
this.createDataRows(result, dataModel, selectedScenarios);
|
|
3056
|
-
this.crateRESTRow(result, selectedScenarios, dataModel);
|
|
3057
|
-
return dataModel;
|
|
3058
|
-
}
|
|
3059
|
-
detectNaNCells(scenarios, res) {
|
|
3060
|
-
res.forEach((row) => {
|
|
3061
|
-
scenarios.forEach((scenario) => {
|
|
3062
|
-
const varianceScenario = new VarianceScenario(scenario);
|
|
3063
|
-
if (varianceScenario.isValid === true) {
|
|
3064
|
-
if (row[varianceScenario.base + "_cnt"] === 0 || row[varianceScenario.delta + "_cnt"] === 0) {
|
|
3065
|
-
row[scenario] = Number.NaN;
|
|
3066
|
-
}
|
|
3067
|
-
}
|
|
3068
|
-
else {
|
|
3069
|
-
if (row[scenario + "_cnt"] === 0) {
|
|
3070
|
-
row[scenario] = Number.NaN;
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
});
|
|
3074
|
-
return row;
|
|
3075
|
-
});
|
|
3076
|
-
}
|
|
3077
|
-
crateRESTRow(result, selectedScenarios, dataModel) {
|
|
3078
|
-
if (this.limit === 0 || this.limit > result.length) {
|
|
3079
|
-
return;
|
|
3080
|
-
}
|
|
3081
|
-
const restDataModel = [];
|
|
3082
|
-
const restResult = result.slice(this.limit, result.length);
|
|
3083
|
-
this.createDataRows(restResult, restDataModel, selectedScenarios);
|
|
3084
|
-
const reducedRestRow = restDataModel.reduce(function (sum, current) {
|
|
3085
|
-
const obj = {
|
|
3086
|
-
id: sum.id,
|
|
3087
|
-
category: sum.category,
|
|
3088
|
-
type: sum.type,
|
|
3089
|
-
scenario1: new DataPoint(sum.scenario1.value + current.scenario1.value, selectedScenarios[0], sum.scenario1.pixelPerUnit, Scenario.NEU),
|
|
3090
|
-
scenario2: new DataPoint(sum.scenario2.value + current.scenario2.value, selectedScenarios[1], sum.scenario2.pixelPerUnit, Scenario.NEU),
|
|
3091
|
-
scenario3: new DataPoint(sum.scenario3.value + current.scenario3.value, selectedScenarios[2], sum.scenario3.pixelPerUnit, Scenario.NEU),
|
|
3092
|
-
scenario4: new DataPoint(sum.scenario4.value + current.scenario4.value, selectedScenarios[3], sum.scenario4.pixelPerUnit, Scenario.NEU),
|
|
3093
|
-
};
|
|
3094
|
-
return obj;
|
|
3095
|
-
}, {
|
|
3096
|
-
id: 9999,
|
|
3097
|
-
category: "REST",
|
|
3098
|
-
type: VarianceType.NONE,
|
|
3099
|
-
scenario1: new DataPoint(0, selectedScenarios[0], this.pixelPerUnit, Scenario.NEU),
|
|
3100
|
-
scenario2: new DataPoint(0, selectedScenarios[1], this.pixelPerUnit, Scenario.NEU),
|
|
3101
|
-
scenario3: new DataPoint(0, selectedScenarios[2], this.pixelPerUnit, Scenario.NEU),
|
|
3102
|
-
scenario4: new DataPoint(0, selectedScenarios[3], this.pixelPerUnit, Scenario.NEU),
|
|
3103
|
-
});
|
|
3104
|
-
dataModel.push(reducedRestRow);
|
|
3105
|
-
}
|
|
3106
|
-
createDataRows(result, dataModel, selectedScenarios) {
|
|
3107
|
-
let primaryResult = result;
|
|
3108
|
-
if (this.limit > 0) {
|
|
3109
|
-
primaryResult = result.slice(0, this.limit);
|
|
3110
|
-
}
|
|
3111
|
-
primaryResult.forEach((element, index) => {
|
|
3112
|
-
dataModel.push({
|
|
3113
|
-
id: index,
|
|
3114
|
-
category: element.category,
|
|
3115
|
-
type: VarianceType.NONE,
|
|
3116
|
-
scenario1: new DataPoint(element[selectedScenarios[0]], selectedScenarios[0], this.pixelPerUnit, Scenario.NEU),
|
|
3117
|
-
scenario2: new DataPoint(element[selectedScenarios[1]], selectedScenarios[1], this.pixelPerUnit, Scenario.NEU),
|
|
3118
|
-
scenario3: new DataPoint(element[selectedScenarios[2]], selectedScenarios[2], this.pixelPerUnit, Scenario.NEU),
|
|
3119
|
-
scenario4: new DataPoint(element[selectedScenarios[3]], selectedScenarios[3], this.pixelPerUnit, Scenario.NEU),
|
|
3120
|
-
});
|
|
3121
|
-
});
|
|
3122
|
-
}
|
|
3123
|
-
createOrderStr(level, sortOrder) {
|
|
3124
|
-
let orderStr = `${level.toLowerCase()}`;
|
|
3125
|
-
if (sortOrder.hierarchy.length >= 1) {
|
|
3126
|
-
orderStr = `${sortOrder.hierarchy.toString()} ${sortOrder === null || sortOrder === void 0 ? void 0 : sortOrder.direction}`;
|
|
3127
|
-
}
|
|
3128
|
-
return orderStr;
|
|
3129
|
-
}
|
|
3130
|
-
createSelectString(level, sortOrder) {
|
|
3131
|
-
if (level === AggregationLevel.CATEGORY && sortOrder.hierarchy.includes(OrderColumn.CATEGORYINDEX)) {
|
|
3132
|
-
return `${OrderColumn.CATEGORYINDEX}, ${AggregationLevel.CATEGORY} as category`;
|
|
3133
|
-
}
|
|
3134
|
-
else if (level === AggregationLevel.ROWGROUP && sortOrder.hierarchy.includes(OrderColumn.ROWGROUPINDEX)) {
|
|
3135
|
-
return `${OrderColumn.ROWGROUPINDEX}, ${AggregationLevel.ROWGROUP} as category`;
|
|
3136
|
-
}
|
|
3137
|
-
else if (level === AggregationLevel.SUBCATEGORY && sortOrder.hierarchy.includes(OrderColumn.SUBCATEGORYINDEX)) {
|
|
3138
|
-
return `${OrderColumn.SUBCATEGORYINDEX}, ${AggregationLevel.SUBCATEGORY} as category`;
|
|
3139
|
-
}
|
|
3140
|
-
else {
|
|
3141
|
-
return `${level.toString()} as category`;
|
|
3142
|
-
}
|
|
3143
|
-
}
|
|
3144
|
-
createGroupByStr(level, sortOrder) {
|
|
3145
|
-
if (level === AggregationLevel.CATEGORY && sortOrder.hierarchy.includes(OrderColumn.CATEGORYINDEX)) {
|
|
3146
|
-
return `${OrderColumn.CATEGORYINDEX}, ${AggregationLevel.CATEGORY}`;
|
|
3147
|
-
}
|
|
3148
|
-
else if (level === AggregationLevel.ROWGROUP && sortOrder.hierarchy.includes(OrderColumn.ROWGROUPINDEX)) {
|
|
3149
|
-
return `${OrderColumn.ROWGROUPINDEX}, ${AggregationLevel.ROWGROUP}`;
|
|
3150
|
-
}
|
|
3151
|
-
else if (level === AggregationLevel.SUBCATEGORY && sortOrder.hierarchy.includes(OrderColumn.SUBCATEGORYINDEX)) {
|
|
3152
|
-
return `${OrderColumn.SUBCATEGORYINDEX}, ${AggregationLevel.SUBCATEGORY}`;
|
|
3153
|
-
}
|
|
3154
|
-
else {
|
|
3155
|
-
return `${level.toString()}`;
|
|
3156
|
-
}
|
|
3157
|
-
}
|
|
3158
|
-
calculateCategoryWidth() {
|
|
3159
|
-
if (this.hideCategories) {
|
|
3160
|
-
return 5;
|
|
3161
|
-
}
|
|
3162
|
-
let longestLength = 0;
|
|
3163
|
-
for (const entry of this.dataModel) {
|
|
3164
|
-
const columnLength = CalculateSize(entry.category, {
|
|
3165
|
-
font: this.styles.fontStyles.font,
|
|
3166
|
-
fontSize: this.styles.fontStyles.size + "px",
|
|
3167
|
-
});
|
|
3168
|
-
if (columnLength.width > longestLength) {
|
|
3169
|
-
longestLength = columnLength.width;
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
// MagicNumber used to compensate differnet fontwidth rendered vs calculated
|
|
3173
|
-
const magicNumber = 1.1125;
|
|
3174
|
-
return longestLength * magicNumber;
|
|
3175
|
-
}
|
|
3176
|
-
findSmallestDataPointValue(dataModel) {
|
|
3177
|
-
let smallestDataPoint = new DataPoint(0, "default", this.pixelPerUnit, null);
|
|
3178
|
-
for (const entry of dataModel) {
|
|
3179
|
-
for (const current of [entry.scenario1, entry.scenario2, entry.scenario3, entry.scenario4]) {
|
|
3180
|
-
if (current != null && smallestDataPoint.value != null) {
|
|
3181
|
-
if (current.value < smallestDataPoint.value) {
|
|
3182
|
-
smallestDataPoint = current;
|
|
3183
|
-
}
|
|
3184
|
-
}
|
|
3185
|
-
}
|
|
3186
|
-
}
|
|
3187
|
-
return smallestDataPoint;
|
|
3188
|
-
}
|
|
3189
|
-
findHighestDataPointValue(dataModel) {
|
|
3190
|
-
let highestDataPoint = new DataPoint(0, "default", this.pixelPerUnit, null);
|
|
3191
|
-
for (const entry of dataModel) {
|
|
3192
|
-
for (const current of [entry.scenario1, entry.scenario2, entry.scenario3, entry.scenario4]) {
|
|
3193
|
-
if (current != null && highestDataPoint.value != null) {
|
|
3194
|
-
if (current.value > highestDataPoint.value) {
|
|
3195
|
-
highestDataPoint = current;
|
|
3196
|
-
}
|
|
3197
|
-
}
|
|
3198
|
-
}
|
|
3199
|
-
}
|
|
3200
|
-
return highestDataPoint;
|
|
3201
|
-
}
|
|
3202
|
-
findHighestStackedRowTotal(dataModel) {
|
|
3203
|
-
if (!this.stackConfig || dataModel.length === 0)
|
|
3204
|
-
return 0;
|
|
3205
|
-
const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
|
|
3206
|
-
let maxTotal = 0;
|
|
3207
|
-
for (const row of dataModel) {
|
|
3208
|
-
let rowTotal = 0;
|
|
3209
|
-
if (isScenarioStack) {
|
|
3210
|
-
const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
|
|
3211
|
-
const segments = [];
|
|
3212
|
-
for (const key of scenarioKeys) {
|
|
3213
|
-
const dp = row[key];
|
|
3214
|
-
if (dp && !dp.isEmpty() && dp.value != null) {
|
|
3215
|
-
segments.push({ value: dp.value, scenario: dp.scenario });
|
|
3216
|
-
}
|
|
3217
|
-
}
|
|
3218
|
-
const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
|
|
3219
|
-
if (prefixes.size > 1) {
|
|
3220
|
-
// Overlay: groups overlap from baseline, width = max group total
|
|
3221
|
-
const groupMap = new Map();
|
|
3222
|
-
for (const seg of segments) {
|
|
3223
|
-
const prefix = getScenarioPrefix(seg.scenario);
|
|
3224
|
-
groupMap.set(prefix, (groupMap.get(prefix) || 0) + Math.abs(seg.value));
|
|
3225
|
-
}
|
|
3226
|
-
rowTotal = Math.max(...groupMap.values());
|
|
3227
|
-
}
|
|
3228
|
-
else {
|
|
3229
|
-
// Single group: segments stack end-to-end, width = sum
|
|
3230
|
-
rowTotal = segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
3231
|
-
}
|
|
3232
|
-
}
|
|
3233
|
-
else {
|
|
3234
|
-
// Dimension stacking: use stackSegments
|
|
3235
|
-
if (row.stackSegments && row.stackSegments.length > 0) {
|
|
3236
|
-
rowTotal = row.stackSegments.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
|
-
if (rowTotal > maxTotal)
|
|
3240
|
-
maxTotal = rowTotal;
|
|
3241
|
-
}
|
|
3242
|
-
return maxTotal;
|
|
3243
|
-
}
|
|
3244
|
-
populateVarianceModel(variancesConfig, dataModel) {
|
|
3245
|
-
const varianceModel = [];
|
|
3246
|
-
if (variancesConfig.length === 0) {
|
|
3247
|
-
return varianceModel;
|
|
3248
|
-
}
|
|
3249
|
-
let firstRow = null;
|
|
3250
|
-
if (dataModel != null && dataModel.length > 0) {
|
|
3251
|
-
firstRow = dataModel[0];
|
|
3252
|
-
}
|
|
3253
|
-
for (const varianceScenario in variancesConfig) {
|
|
3254
|
-
const scenarios = new VarianceScenario(variancesConfig[varianceScenario]);
|
|
3255
|
-
if (scenarios.isValid) {
|
|
3256
|
-
const scenariomap = this.mapScenarios(scenarios, firstRow);
|
|
3257
|
-
const directon = scenarios.direction;
|
|
3258
|
-
let pixelPerUnit = this.pixelPerUnit;
|
|
3259
|
-
if (scenarios.type === "dr") {
|
|
3260
|
-
pixelPerUnit = this.pixelPerPercentage;
|
|
3261
|
-
}
|
|
3262
|
-
for (const index in dataModel) {
|
|
3263
|
-
varianceModel.push({
|
|
3264
|
-
id: Number(index),
|
|
3265
|
-
category: dataModel[index].category,
|
|
3266
|
-
type: scenarios.type === "dr" ? VarianceType.RELATIVE : VarianceType.ABSOLUTE,
|
|
3267
|
-
scenario1: new DataPoint(this.calculateVariance(scenarios, dataModel[index], scenariomap), scenarios.base, pixelPerUnit, directon),
|
|
3268
|
-
scenario2: new DataPoint(null, null, null, null),
|
|
3269
|
-
scenario3: new DataPoint(null, null, null, null),
|
|
3270
|
-
scenario4: new DataPoint(null, null, null, null),
|
|
3271
|
-
});
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
}
|
|
3275
|
-
return varianceModel;
|
|
3276
|
-
}
|
|
3277
|
-
calculateVariance(scenarios, element, scenarioMap) {
|
|
3278
|
-
const scenarioBase = scenarioMap.get(scenarios.base);
|
|
3279
|
-
const scenarioDelta = scenarioMap.get(scenarios.delta);
|
|
3280
|
-
if (scenarioBase == null || scenarioDelta == null) {
|
|
3281
|
-
return null;
|
|
3282
|
-
}
|
|
3283
|
-
const isRelativeVarianze = scenarios.type === VarianceType.RELATIVE;
|
|
3284
|
-
if (isRelativeVarianze) {
|
|
3285
|
-
return (element[scenarioBase].value - element[scenarioDelta].value) / element[scenarioDelta].value;
|
|
3286
|
-
}
|
|
3287
|
-
else {
|
|
3288
|
-
return element[scenarioBase].value - element[scenarioDelta].value;
|
|
3289
|
-
}
|
|
3290
|
-
}
|
|
3291
|
-
mapScenarios(scenarios, firstRow) {
|
|
3292
|
-
const varianceMap = new Map();
|
|
3293
|
-
if (firstRow == null) {
|
|
3294
|
-
return varianceMap;
|
|
3295
|
-
}
|
|
3296
|
-
["scenario1", "scenario2", "scenario3", "scenario4"].forEach((scenarioKey) => {
|
|
3297
|
-
if (firstRow[scenarioKey].scenario === scenarios.delta) {
|
|
3298
|
-
varianceMap.set(scenarios.delta, scenarioKey);
|
|
3299
|
-
}
|
|
3300
|
-
else if (firstRow[scenarioKey].scenario === scenarios.base) {
|
|
3301
|
-
varianceMap.set(scenarios.base, scenarioKey);
|
|
3302
|
-
}
|
|
3303
|
-
});
|
|
3304
|
-
return varianceMap;
|
|
3305
|
-
}
|
|
3306
|
-
calculateTextBoxWidth(value) {
|
|
3307
|
-
return CalculateSize(Formatter.number(value, "decimal", 1, 0), {
|
|
3308
|
-
font: this.styles.fontStyles.font,
|
|
3309
|
-
fontSize: this.styles.fontStyles.size + "px",
|
|
3310
|
-
}).width;
|
|
3311
|
-
}
|
|
3312
|
-
calculatePercentageTextBoxWidth(value) {
|
|
3313
|
-
let signWidth = 0;
|
|
3314
|
-
if (value >= 0) {
|
|
3315
|
-
signWidth += CalculateSize("+", {
|
|
3316
|
-
font: this.styles.fontStyles.font,
|
|
3317
|
-
fontSize: this.styles.fontStyles.size + "px",
|
|
3318
|
-
}).width;
|
|
3319
|
-
}
|
|
3320
|
-
signWidth += CalculateSize(" %", {
|
|
3321
|
-
font: this.styles.fontStyles.font,
|
|
3322
|
-
fontSize: this.styles.fontStyles.size + "px",
|
|
3323
|
-
}).width;
|
|
3324
|
-
const labelWidth = CalculateSize(Formatter.number(value, "decimal", 1, 1), {
|
|
3325
|
-
font: this.styles.fontStyles.font,
|
|
3326
|
-
fontSize: this.styles.fontStyles.size + "px",
|
|
3327
|
-
}).width + signWidth;
|
|
3328
|
-
return labelWidth + signWidth;
|
|
3329
|
-
}
|
|
3330
|
-
cleanSVGforRedraw(svgContainer) {
|
|
3331
|
-
svgContainer.clear();
|
|
3332
|
-
}
|
|
3333
|
-
drawAxisAndLabels(dataModel, svgContainer) {
|
|
3334
|
-
const axisLabelGroup = svgContainer.group().id("AxisAndDateLables");
|
|
3335
|
-
let isRelative = false;
|
|
3336
|
-
if (!this.hideCategories) {
|
|
3337
|
-
dataModel.forEach((elements, index) => {
|
|
3338
|
-
if (elements["type"] === VarianceType.RELATIVE) {
|
|
3339
|
-
isRelative = true;
|
|
3340
|
-
}
|
|
3341
|
-
let textHook = HookLocation.Right;
|
|
3342
|
-
let isPositive = true;
|
|
3343
|
-
if (elements["scenario1"].value < 0) {
|
|
3344
|
-
textHook = HookLocation.Left;
|
|
3345
|
-
isPositive = false;
|
|
3346
|
-
}
|
|
3347
|
-
new Label(axisLabelGroup, this.position.getCategoryPositionX(isPositive), this.position.getBarCenterPositionY(index), "", elements.category, this.styles, HookLocation.Center, textHook).draw();
|
|
3348
|
-
});
|
|
3349
|
-
}
|
|
3350
|
-
new Axis({
|
|
3351
|
-
scenarioType: this.axisScenario,
|
|
3352
|
-
labelText: this.title,
|
|
3353
|
-
isRelative: isRelative,
|
|
3354
|
-
}, this.position, axisLabelGroup, this.styles).draw();
|
|
3355
|
-
}
|
|
3356
|
-
drawScenarios(dataModel, svgContainer) {
|
|
3357
|
-
const barsGroup = svgContainer.group().id("Scenarios");
|
|
3358
|
-
const scenarioFactory = new ScenarioFactory(this.position, barsGroup, this.styles, dataModel.length, this.i18n);
|
|
3359
|
-
scenarioFactory.setOverflowConfig(this.overflowConfig);
|
|
3360
|
-
dataModel.forEach((elements, index) => {
|
|
3361
|
-
scenarioFactory.createPrimaryBar(elements["scenario1"], index).draw(this.dataFormatDigits, this.measureScale);
|
|
3362
|
-
scenarioFactory.createSecondaryBar(elements["scenario2"], index).draw();
|
|
3363
|
-
scenarioFactory.createPrimaryMarker(elements["scenario3"], index).draw();
|
|
3364
|
-
scenarioFactory.createSecondaryMarker(elements["scenario4"], index).draw();
|
|
3365
|
-
});
|
|
3366
|
-
}
|
|
3367
|
-
drawVarianceScenario(dataModel, svgContainer) {
|
|
3368
|
-
const barsGroup = svgContainer.group().id("Scenarios");
|
|
3369
|
-
const scenarioFactory = new ScenarioFactory(this.position, barsGroup, this.styles, dataModel.length, this.i18n);
|
|
3370
|
-
scenarioFactory.setOverflowConfig(this.overflowConfig);
|
|
3371
|
-
dataModel.forEach((elements, index) => {
|
|
3372
|
-
if (elements["type"] === VarianceType.RELATIVE) {
|
|
3373
|
-
scenarioFactory.createRelativeVarianceBar(elements["scenario1"], index).draw();
|
|
3374
|
-
}
|
|
3375
|
-
else {
|
|
3376
|
-
scenarioFactory.createVarianceBar(elements["scenario1"], index).draw(this.dataFormatDigits, this.measureScale);
|
|
3377
|
-
}
|
|
3378
|
-
});
|
|
3379
|
-
return barsGroup;
|
|
3380
|
-
}
|
|
3381
|
-
/**
|
|
3382
|
-
* Draw stacked horizontal bars. Supports stacking by scenario or by data dimension.
|
|
3383
|
-
* When stacking by scenario with multiple scenario types (e.g. ac+pl),
|
|
3384
|
-
* uses overlay mode: each type group is drawn from the same baseline,
|
|
3385
|
-
* back-to-front per IBCS convention (PL behind, AC on top).
|
|
3386
|
-
*/
|
|
3387
|
-
drawStackedScenarios(dataModel, svgContainer) {
|
|
3388
|
-
if (!this.stackConfig)
|
|
3389
|
-
return;
|
|
3390
|
-
const stackGroup = svgContainer.group().id("StackedScenarios");
|
|
3391
|
-
const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
|
|
3392
|
-
dataModel.forEach((elements, index) => {
|
|
3393
|
-
const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
|
|
3394
|
-
const segments = [];
|
|
3395
|
-
if (isScenarioStack) {
|
|
3396
|
-
for (const key of scenarioKeys) {
|
|
3397
|
-
const dp = elements[key];
|
|
3398
|
-
if (dp && !dp.isEmpty() && dp.value != null) {
|
|
3399
|
-
segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
|
|
3400
|
-
}
|
|
3401
|
-
}
|
|
3402
|
-
}
|
|
3403
|
-
else {
|
|
3404
|
-
const dp = elements["scenario1"];
|
|
3405
|
-
if (dp && !dp.isEmpty() && dp.value != null) {
|
|
3406
|
-
segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
|
|
3407
|
-
}
|
|
3408
|
-
}
|
|
3409
|
-
if (segments.length === 0)
|
|
3410
|
-
return;
|
|
3411
|
-
// Check if we have multiple scenario type groups for overlay mode
|
|
3412
|
-
const prefixes = isScenarioStack
|
|
3413
|
-
? new Set(segments.map((s) => getScenarioPrefix(s.scenario)))
|
|
3414
|
-
: new Set();
|
|
3415
|
-
if (prefixes.size > 1) {
|
|
3416
|
-
// Overlay mode: group by scenario prefix, draw each group from same baseline
|
|
3417
|
-
const groupMap = new Map();
|
|
3418
|
-
for (const seg of segments) {
|
|
3419
|
-
const prefix = getScenarioPrefix(seg.scenario);
|
|
3420
|
-
if (!groupMap.has(prefix))
|
|
3421
|
-
groupMap.set(prefix, []);
|
|
3422
|
-
groupMap.get(prefix).push(seg);
|
|
3423
|
-
}
|
|
3424
|
-
// Sort groups by IBCS layer order (back-to-front: pl, fc, pp, ac)
|
|
3425
|
-
const groups = [];
|
|
3426
|
-
for (const prefix of IBCS_LAYER_ORDER) {
|
|
3427
|
-
if (groupMap.has(prefix)) {
|
|
3428
|
-
groups.push({ prefix, segments: groupMap.get(prefix) });
|
|
3429
|
-
groupMap.delete(prefix);
|
|
3430
|
-
}
|
|
3431
|
-
}
|
|
3432
|
-
for (const [prefix, segs] of groupMap) {
|
|
3433
|
-
groups.push({ prefix, segments: segs });
|
|
3434
|
-
}
|
|
3435
|
-
// Draw each group from baseline=0 (overlapping)
|
|
3436
|
-
groups.forEach((group, groupIdx) => {
|
|
3437
|
-
const groupTotal = group.segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
3438
|
-
const colorIndex = groups.length - 1 - groupIdx; // back=lighter, front=darker
|
|
3439
|
-
let cumulativeValue = 0;
|
|
3440
|
-
let lastBar = null;
|
|
3441
|
-
group.segments.forEach((seg) => {
|
|
3442
|
-
const bar = new StackedBar(this.position, this.styles, seg.dataPoint, index, cumulativeValue, seg.scenario, colorIndex, this.stackConfig.mode, groupTotal, true, stackGroup);
|
|
3443
|
-
bar.draw(this.dataFormatDigits, this.measureScale);
|
|
3444
|
-
cumulativeValue += Math.abs(seg.value);
|
|
3445
|
-
lastBar = bar;
|
|
3446
|
-
});
|
|
3447
|
-
if (lastBar) {
|
|
3448
|
-
lastBar.drawTotalLabel(this.dataFormatDigits, this.measureScale);
|
|
3449
|
-
}
|
|
3450
|
-
});
|
|
3451
|
-
}
|
|
3452
|
-
else {
|
|
3453
|
-
// Single group, scenario or dimension stacking
|
|
3454
|
-
// For dimension stacking, use stackSegments if available
|
|
3455
|
-
let finalSegments = segments;
|
|
3456
|
-
if (!isScenarioStack && elements.stackSegments && elements.stackSegments.length > 0) {
|
|
3457
|
-
finalSegments = elements.stackSegments.map((seg) => ({
|
|
3458
|
-
value: seg.value,
|
|
3459
|
-
scenario: seg.label,
|
|
3460
|
-
dataPoint: seg.dataPoint,
|
|
3461
|
-
}));
|
|
3462
|
-
}
|
|
3463
|
-
if (this.stackConfig.order === "asc") {
|
|
3464
|
-
finalSegments.sort((a, b) => a.value - b.value);
|
|
3465
|
-
}
|
|
3466
|
-
else if (this.stackConfig.order === "desc") {
|
|
3467
|
-
finalSegments.sort((a, b) => b.value - a.value);
|
|
3468
|
-
}
|
|
3469
|
-
const total = finalSegments.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
3470
|
-
let cumulativeValue = 0;
|
|
3471
|
-
let lastBar = null;
|
|
3472
|
-
finalSegments.forEach((seg, segIdx) => {
|
|
3473
|
-
const bar = new StackedBar(this.position, this.styles, seg.dataPoint, index, cumulativeValue, seg.scenario, segIdx, this.stackConfig.mode, total, isScenarioStack, stackGroup);
|
|
3474
|
-
bar.draw(this.dataFormatDigits, this.measureScale);
|
|
3475
|
-
cumulativeValue += Math.abs(seg.value);
|
|
3476
|
-
lastBar = bar;
|
|
3477
|
-
});
|
|
3478
|
-
if (lastBar) {
|
|
3479
|
-
lastBar.drawTotalLabel(this.dataFormatDigits, this.measureScale);
|
|
3480
|
-
}
|
|
3481
|
-
}
|
|
3482
|
-
});
|
|
3483
|
-
}
|
|
3484
|
-
/**
|
|
3485
|
-
* Draw column headers above stacked bars showing what each segment/group represents.
|
|
3486
|
-
* For overlay mode (multiple scenario types): shows one header per group.
|
|
3487
|
-
* For single-group scenario stacking: shows individual segment headers.
|
|
3488
|
-
*/
|
|
3489
|
-
drawStackedHeaders(dataModel, svgContainer) {
|
|
3490
|
-
if (!this.stackConfig || dataModel.length === 0)
|
|
3491
|
-
return;
|
|
3492
|
-
const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
|
|
3493
|
-
const headerGroup = svgContainer.group().id("StackedHeaders");
|
|
3494
|
-
const firstRow = dataModel[0];
|
|
3495
|
-
// Dimension stacking: use stackSegments from first row for headers
|
|
3496
|
-
if (!isScenarioStack) {
|
|
3497
|
-
const stackSegs = firstRow.stackSegments;
|
|
3498
|
-
if (!stackSegs || stackSegs.length === 0)
|
|
3499
|
-
return;
|
|
3500
|
-
const orderedSegs = [...stackSegs];
|
|
3501
|
-
if (this.stackConfig.order === "asc")
|
|
3502
|
-
orderedSegs.sort((a, b) => a.value - b.value);
|
|
3503
|
-
else if (this.stackConfig.order === "desc")
|
|
3504
|
-
orderedSegs.sort((a, b) => b.value - a.value);
|
|
3505
|
-
const total = orderedSegs.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
3506
|
-
const axisX = this.position.getBarPositionX();
|
|
3507
|
-
const headerY = this.position.getAxisTitlePositionY();
|
|
3508
|
-
let cumulativePixels = 0;
|
|
3509
|
-
orderedSegs.forEach((seg) => {
|
|
3510
|
-
const pixelPerUnit = seg.dataPoint.pixelPerUnit;
|
|
3511
|
-
let segmentLength;
|
|
3512
|
-
if (this.stackConfig.mode === StackMode.RELATIVE) {
|
|
3513
|
-
const proportion = total !== 0 ? Math.abs(seg.value) / total : 0;
|
|
3514
|
-
segmentLength = proportion * pixelPerUnit;
|
|
3515
|
-
}
|
|
3516
|
-
else {
|
|
3517
|
-
segmentLength = Math.abs(seg.value * pixelPerUnit);
|
|
3518
|
-
}
|
|
3519
|
-
const centerX = axisX + cumulativePixels + segmentLength / 2;
|
|
3520
|
-
const labelText = this.i18n.get(seg.label) || seg.label;
|
|
3521
|
-
new Label(headerGroup, centerX, headerY, "STACK_HEADER", labelText, this.styles, HookLocation.Bottom, HookLocation.Center).draw();
|
|
3522
|
-
cumulativePixels += segmentLength;
|
|
3523
|
-
});
|
|
3524
|
-
return;
|
|
3525
|
-
}
|
|
3526
|
-
const scenarioKeys = ["scenario1", "scenario2", "scenario3", "scenario4"];
|
|
3527
|
-
const segments = [];
|
|
3528
|
-
for (const key of scenarioKeys) {
|
|
3529
|
-
const dp = firstRow[key];
|
|
3530
|
-
if (dp && !dp.isEmpty() && dp.value != null) {
|
|
3531
|
-
segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
|
|
3532
|
-
}
|
|
3533
|
-
}
|
|
3534
|
-
if (segments.length === 0)
|
|
3535
|
-
return;
|
|
3536
|
-
const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
|
|
3537
|
-
const axisX = this.position.getBarPositionX();
|
|
3538
|
-
const headerY = this.position.getAxisTitlePositionY();
|
|
3539
|
-
if (prefixes.size > 1) {
|
|
3540
|
-
// Overlay mode: one header per group, centered on group's bar extent
|
|
3541
|
-
const groupMap = new Map();
|
|
3542
|
-
for (const seg of segments) {
|
|
3543
|
-
const prefix = getScenarioPrefix(seg.scenario);
|
|
3544
|
-
if (!groupMap.has(prefix))
|
|
3545
|
-
groupMap.set(prefix, []);
|
|
3546
|
-
groupMap.get(prefix).push(seg);
|
|
3547
|
-
}
|
|
3548
|
-
const groups = [];
|
|
3549
|
-
for (const prefix of IBCS_LAYER_ORDER) {
|
|
3550
|
-
if (groupMap.has(prefix)) {
|
|
3551
|
-
groups.push({ prefix, segments: groupMap.get(prefix) });
|
|
3552
|
-
groupMap.delete(prefix);
|
|
3553
|
-
}
|
|
3554
|
-
}
|
|
3555
|
-
for (const [prefix, segs] of groupMap) {
|
|
3556
|
-
groups.push({ prefix, segments: segs });
|
|
3557
|
-
}
|
|
3558
|
-
groups.forEach((group) => {
|
|
3559
|
-
const groupTotal = group.segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
3560
|
-
const pixelPerUnit = group.segments[0].dataPoint.pixelPerUnit;
|
|
3561
|
-
const groupPixelLength = this.stackConfig.mode === StackMode.RELATIVE ? pixelPerUnit : groupTotal * pixelPerUnit;
|
|
3562
|
-
const centerX = axisX + groupPixelLength / 2;
|
|
3563
|
-
const labelText = this.i18n.get(group.prefix + "1") || group.prefix.toUpperCase();
|
|
3564
|
-
new Label(headerGroup, centerX, headerY, "STACK_HEADER", labelText, this.styles, HookLocation.Bottom, HookLocation.Center).draw();
|
|
3565
|
-
});
|
|
3566
|
-
}
|
|
3567
|
-
else {
|
|
3568
|
-
// Single group: show individual segment headers
|
|
3569
|
-
if (this.stackConfig.order === "asc")
|
|
3570
|
-
segments.sort((a, b) => a.value - b.value);
|
|
3571
|
-
else if (this.stackConfig.order === "desc")
|
|
3572
|
-
segments.sort((a, b) => b.value - a.value);
|
|
3573
|
-
const total = segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
3574
|
-
let cumulativePixels = 0;
|
|
3575
|
-
segments.forEach((seg) => {
|
|
3576
|
-
const pixelPerUnit = seg.dataPoint.pixelPerUnit;
|
|
3577
|
-
let segmentLength;
|
|
3578
|
-
if (this.stackConfig.mode === StackMode.RELATIVE) {
|
|
3579
|
-
const proportion = total !== 0 ? Math.abs(seg.value) / total : 0;
|
|
3580
|
-
segmentLength = proportion * pixelPerUnit;
|
|
3581
|
-
}
|
|
3582
|
-
else {
|
|
3583
|
-
segmentLength = Math.abs(seg.value * pixelPerUnit);
|
|
3584
|
-
}
|
|
3585
|
-
const centerX = axisX + cumulativePixels + segmentLength / 2;
|
|
3586
|
-
const labelText = this.i18n.get(seg.scenario) || seg.scenario;
|
|
3587
|
-
new Label(headerGroup, centerX, headerY, "STACK_HEADER", labelText, this.styles, HookLocation.Bottom, HookLocation.Center).draw();
|
|
3588
|
-
cumulativePixels += segmentLength;
|
|
3589
|
-
});
|
|
3590
|
-
}
|
|
3591
|
-
}
|
|
3592
|
-
getVarianceType() {
|
|
3593
|
-
if (this.variancesDataModel.length > 0) {
|
|
3594
|
-
return this.variancesDataModel[0].type;
|
|
3595
|
-
}
|
|
3596
|
-
return VarianceType.NONE;
|
|
3597
|
-
}
|
|
3598
|
-
calculateLeftSideWidth(varianceType) {
|
|
3599
|
-
var _a, _b, _c;
|
|
3600
|
-
let width = 0;
|
|
3601
|
-
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
3602
|
-
if (VarianceType.NONE === varianceType &&
|
|
3603
|
-
((_a = this.smallestDataPointValue) === null || _a === void 0 ? void 0 : _a.value) != null &&
|
|
3604
|
-
this.smallestDataPointValue.value < 0) {
|
|
3605
|
-
const sizeLabelValue = this.calculateTextBoxWidth(this.smallestDataPointValue.value);
|
|
3606
|
-
width = Math.abs(this.smallestDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
3607
|
-
}
|
|
3608
|
-
else if (VarianceType.RELATIVE === varianceType &&
|
|
3609
|
-
((_b = this.smallestVarianceDataPointValue) === null || _b === void 0 ? void 0 : _b.value) != null &&
|
|
3610
|
-
this.smallestVarianceDataPointValue.value < 0) {
|
|
3611
|
-
const sizeLabelValue = this.calculatePercentageTextBoxWidth(this.smallestVarianceDataPointValue.value);
|
|
3612
|
-
width = Math.abs(this.smallestVarianceDataPointValue.getScaledPercentUnit()) + labelToBar + sizeLabelValue;
|
|
3613
|
-
}
|
|
3614
|
-
else if (VarianceType.ABSOLUTE === varianceType &&
|
|
3615
|
-
((_c = this.smallestVarianceDataPointValue) === null || _c === void 0 ? void 0 : _c.value) != null &&
|
|
3616
|
-
this.smallestVarianceDataPointValue.value < 0) {
|
|
3617
|
-
const sizeLabelValue = this.calculateTextBoxWidth(this.smallestVarianceDataPointValue.value);
|
|
3618
|
-
width = Math.abs(this.smallestVarianceDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
3619
|
-
}
|
|
3620
|
-
if (width <= this.titleLength) {
|
|
3621
|
-
return this.titleLength;
|
|
3622
|
-
}
|
|
3623
|
-
return width;
|
|
3624
|
-
}
|
|
3625
|
-
calculateRightSideWidth(varianceType) {
|
|
3626
|
-
var _a, _b, _c;
|
|
3627
|
-
// Stacked charts: width based on max row total, not individual max
|
|
3628
|
-
if (this.stackConfig != null && this.highestStackedTotal > 0) {
|
|
3629
|
-
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
3630
|
-
let barExtent;
|
|
3631
|
-
if (this.stackConfig.mode === StackMode.RELATIVE) {
|
|
3632
|
-
barExtent = this.pixelPerUnit;
|
|
3633
|
-
}
|
|
3634
|
-
else {
|
|
3635
|
-
barExtent = this.highestStackedTotal * this.pixelPerUnit;
|
|
3636
|
-
}
|
|
3637
|
-
const sizeTotalLabel = this.calculateTextBoxWidth(this.highestStackedTotal);
|
|
3638
|
-
const width = barExtent + labelToBar + sizeTotalLabel;
|
|
3639
|
-
return Math.max(width, this.titleLength);
|
|
3640
|
-
}
|
|
3641
|
-
let width = 0;
|
|
3642
|
-
const labelToBar = this.styles.fontStyles.size * this.styles.scaleFactors.labelToBar;
|
|
3643
|
-
if (VarianceType.NONE === varianceType &&
|
|
3644
|
-
((_a = this.highestDataPointValue) === null || _a === void 0 ? void 0 : _a.value) != null &&
|
|
3645
|
-
this.highestDataPointValue.value >= 0) {
|
|
3646
|
-
const sizeLabelValue = this.calculateTextBoxWidth(this.highestDataPointValue.value);
|
|
3647
|
-
width = Math.abs(this.highestDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
3648
|
-
}
|
|
3649
|
-
else if (VarianceType.RELATIVE === varianceType &&
|
|
3650
|
-
((_b = this.highestVarianceDataPointValue) === null || _b === void 0 ? void 0 : _b.value) != null &&
|
|
3651
|
-
this.highestVarianceDataPointValue.value >= 0) {
|
|
3652
|
-
const sizeLabelValue = this.calculatePercentageTextBoxWidth(this.highestVarianceDataPointValue.value);
|
|
3653
|
-
width = Math.abs(this.highestVarianceDataPointValue.getScaledPercentUnit()) + labelToBar + sizeLabelValue;
|
|
3654
|
-
}
|
|
3655
|
-
else if (VarianceType.ABSOLUTE === varianceType &&
|
|
3656
|
-
((_c = this.highestVarianceDataPointValue) === null || _c === void 0 ? void 0 : _c.value) != null &&
|
|
3657
|
-
this.highestVarianceDataPointValue.value >= 0) {
|
|
3658
|
-
const sizeLabelValue = this.calculateTextBoxWidth(this.highestVarianceDataPointValue.value);
|
|
3659
|
-
width = Math.abs(this.highestVarianceDataPointValue.getScaledUnit()) + labelToBar + sizeLabelValue;
|
|
3660
|
-
}
|
|
3661
|
-
if (width <= this.titleLength) {
|
|
3662
|
-
return this.titleLength;
|
|
3663
|
-
}
|
|
3664
|
-
return width;
|
|
3665
|
-
}
|
|
3666
|
-
/**
|
|
3667
|
-
* For dimension stacking (by category, subcategory, or rowgroup), query the raw data
|
|
3668
|
-
* at the stack dimension level and attach stackSegments to each dataModel row.
|
|
3669
|
-
*/
|
|
3670
|
-
populateDimensionStackSegments(scenarios, _stackConfig, level) {
|
|
3671
|
-
var _a;
|
|
3672
|
-
if (((_a = this.preparedDataSet) === null || _a === void 0 ? void 0 : _a.length) === 0 || scenarios.length === 0)
|
|
3673
|
-
return;
|
|
3674
|
-
// Derive stack column from level: stack by the next-lower hierarchy dimension
|
|
3675
|
-
const nextLowerDimension = {
|
|
3676
|
-
[AggregationLevel.ROWGROUP]: "category",
|
|
3677
|
-
[AggregationLevel.ROWGROUPINDEX]: "category",
|
|
3678
|
-
[AggregationLevel.CATEGORY]: "subCategory",
|
|
3679
|
-
[AggregationLevel.CATEGORYINDEX]: "subCategory",
|
|
3680
|
-
};
|
|
3681
|
-
const stackColumn = nextLowerDimension[level];
|
|
3682
|
-
if (!stackColumn)
|
|
3683
|
-
return; // subCategory has no lower dimension
|
|
3684
|
-
// The display level column (what each bar represents)
|
|
3685
|
-
const displayColumn = level.toString(); // e.g. 'rowGroup', 'category', 'subCategory'
|
|
3686
|
-
const scenario = scenarios[0]; // dimension stacking uses first scenario
|
|
3687
|
-
const result = alasql(`SELECT [${displayColumn}] as displayGroup, [${stackColumn}] as stackLabel, ` +
|
|
3688
|
-
`SUM([${scenario}] * transformOperator(operation)) as stackValue ` +
|
|
3689
|
-
`FROM ? GROUP BY [${displayColumn}], [${stackColumn}]`, [this.preparedDataSet]);
|
|
3690
|
-
// Group results by displayGroup
|
|
3691
|
-
const groupMap = new Map();
|
|
3692
|
-
for (const row of result) {
|
|
3693
|
-
const key = row.displayGroup;
|
|
3694
|
-
if (!groupMap.has(key))
|
|
3695
|
-
groupMap.set(key, []);
|
|
3696
|
-
if (row.stackValue != null && row.stackLabel != null) {
|
|
3697
|
-
groupMap.get(key).push({ label: row.stackLabel, value: row.stackValue });
|
|
3698
|
-
}
|
|
3699
|
-
}
|
|
3700
|
-
// Attach stackSegments to each dataModel row
|
|
3701
|
-
for (const row of this.dataModel) {
|
|
3702
|
-
const segments = groupMap.get(row.category);
|
|
3703
|
-
if (segments && segments.length > 0) {
|
|
3704
|
-
row.stackSegments = segments.map((seg) => ({
|
|
3705
|
-
label: seg.label,
|
|
3706
|
-
value: seg.value,
|
|
3707
|
-
dataPoint: new DataPoint(seg.value, scenario, this.pixelPerUnit, Scenario.NEU),
|
|
3708
|
-
}));
|
|
3709
|
-
}
|
|
3710
|
-
else {
|
|
3711
|
-
row.stackSegments = [];
|
|
3712
|
-
}
|
|
3713
|
-
}
|
|
3714
|
-
}
|
|
3715
|
-
hasNoData() {
|
|
3716
|
-
return this.dataModel.length === 0;
|
|
3717
|
-
}
|
|
3718
|
-
setAvailableWidth(availableWidth) {
|
|
3719
|
-
if (this.pixelPerUnit <= 0 || availableWidth <= 0) {
|
|
3720
|
-
this.overflowConfig = null;
|
|
3721
|
-
return;
|
|
3722
|
-
}
|
|
3723
|
-
if (this.stackConfig != null) {
|
|
3724
|
-
this.overflowConfig = null;
|
|
3725
|
-
return;
|
|
3726
|
-
}
|
|
3727
|
-
this.overflowConfig = this.calculateOverflowConfig(availableWidth);
|
|
3728
|
-
if (this.overflowConfig) {
|
|
3729
|
-
const { cutWidth, overdriveZoneWidth, breakGap } = this.overflowConfig;
|
|
3730
|
-
const virtualWidth = cutWidth + overdriveZoneWidth + breakGap;
|
|
3731
|
-
const isVariance = this.variancesDataModel && this.variancesDataModel.length > 0;
|
|
3732
|
-
if (isVariance) {
|
|
3733
|
-
if (this.highestVarianceDataPointValue.getScaledUnit() > cutWidth) {
|
|
3734
|
-
this.highestVarianceDataPointValue = new DataPoint(virtualWidth, this.highestVarianceDataPointValue.scenario, 1, this.highestVarianceDataPointValue.variance);
|
|
3735
|
-
}
|
|
3736
|
-
if (this.smallestVarianceDataPointValue.value != null &&
|
|
3737
|
-
Math.abs(this.smallestVarianceDataPointValue.getScaledUnit()) > cutWidth) {
|
|
3738
|
-
this.smallestVarianceDataPointValue = new DataPoint(-virtualWidth, this.smallestVarianceDataPointValue.scenario, 1, this.smallestVarianceDataPointValue.variance);
|
|
3739
|
-
}
|
|
3740
|
-
}
|
|
3741
|
-
else {
|
|
3742
|
-
if (this.highestDataPointValue.getScaledUnit() > cutWidth) {
|
|
3743
|
-
this.highestDataPointValue = new DataPoint(virtualWidth, this.highestDataPointValue.scenario, 1, this.highestDataPointValue.variance);
|
|
3744
|
-
}
|
|
3745
|
-
if (this.smallestDataPointValue.value != null &&
|
|
3746
|
-
Math.abs(this.smallestDataPointValue.getScaledUnit()) > cutWidth) {
|
|
3747
|
-
this.smallestDataPointValue = new DataPoint(-virtualWidth, this.smallestDataPointValue.scenario, 1, this.smallestDataPointValue.variance);
|
|
3748
|
-
}
|
|
3749
|
-
}
|
|
3750
|
-
this.updatePosition();
|
|
3751
|
-
}
|
|
3752
|
-
}
|
|
3753
|
-
calculateOverflowConfig(availableWidth) {
|
|
3754
|
-
const isVariance = this.variancesDataModel && this.variancesDataModel.length > 0;
|
|
3755
|
-
const varianceType = this.getVarianceType();
|
|
3756
|
-
// Don't apply to relative variance (Needle handles its own clipping at 145%)
|
|
3757
|
-
if (varianceType === VarianceType.RELATIVE)
|
|
3758
|
-
return null;
|
|
3759
|
-
const highest = isVariance ? this.highestVarianceDataPointValue : this.highestDataPointValue;
|
|
3760
|
-
const smallest = isVariance ? this.smallestVarianceDataPointValue : this.smallestDataPointValue;
|
|
3761
|
-
const highestScaledUnit = highest.getScaledUnit();
|
|
3762
|
-
const smallestAbsScaledUnit = smallest.value != null ? Math.abs(smallest.getScaledUnit()) : 0;
|
|
3763
|
-
const maxAbsScaledUnit = Math.max(highestScaledUnit, smallestAbsScaledUnit);
|
|
3764
|
-
if (maxAbsScaledUnit <= 0)
|
|
3765
|
-
return null;
|
|
3766
|
-
const fontSize = this.styles.fontStyles.size;
|
|
3767
|
-
const labelToBar = fontSize * this.styles.scaleFactors.labelToBar;
|
|
3768
|
-
// Available space on the right side of the axis
|
|
3769
|
-
const axisX = this.position.getAxisPositionX();
|
|
3770
|
-
// Match getAllocatedCanvasWidth() which adds padding.left + padding.right on top of axisX
|
|
3771
|
-
const rightSideAvailable = availableWidth - axisX - this.styles.padding.left - this.styles.padding.right;
|
|
3772
|
-
// Estimate the label width of the largest value
|
|
3773
|
-
const maxLabelWidth = this.calculateTextBoxWidth(highest.value || 0);
|
|
3774
|
-
const overdriveZoneWidth = fontSize * 1.5;
|
|
3775
|
-
const breakGap = fontSize * 0.3;
|
|
3776
|
-
const scenarioCutOffset = fontSize * 0.8;
|
|
3777
|
-
const cutWidth = rightSideAvailable - labelToBar - maxLabelWidth - overdriveZoneWidth - breakGap;
|
|
3778
|
-
if (cutWidth <= scenarioCutOffset)
|
|
3779
|
-
return null;
|
|
3780
|
-
const lowestCutWidth = cutWidth - scenarioCutOffset;
|
|
3781
|
-
if (maxAbsScaledUnit <= lowestCutWidth)
|
|
3782
|
-
return null;
|
|
3783
|
-
const maxOverflow = maxAbsScaledUnit - lowestCutWidth;
|
|
3784
|
-
return { cutWidth, overdriveZoneWidth, breakGap, maxOverflow, scenarioCutOffset };
|
|
3785
|
-
}
|
|
3786
|
-
}
|
|
3787
|
-
|
|
3788
|
-
const bnChartStructureCss = () => `:host{display:inline-block;position:relative;overflow:hidden}.container{display:flex;flex-direction:row}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}.categories{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.label-bg{fill:var(--bn-font-background, white);opacity:0.7}.label-text{text-align:right;font-size:var(--bn-font-size, 1em);font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-title{text-align:center;font-family:var(--bn-font-family, "Noto Sans", "Helvetica Neue", Helvetica, sans-serif);color:var(--bn-font-color, black)}.axis-ac{stroke:black;stroke-width:0.1em}.axis-pp{stroke:grey;stroke-width:0.1em}.axis-fc{stroke:black;stroke-dasharray:2;stroke-width:0.1em}.axis-pl{stroke:white;stroke-width:0.1em;outline-offset:0em;outline:0.1em solid black}canvas{image-rendering:-moz-crisp-edges;image-rendering:-webkit-crisp-edges;image-rendering:pixelated;image-rendering:crisp-edges}.measure{font-weight:bold}span{display:inline-block}.hidePatternContainer{height:0;width:0}div{float:left}.warning{font-size:0.8em;font-style:italic}.footer{margin:0.2em;font-size:0.6em}.footer-hide{margin:0.2em;font-size:0.6em;opacity:0}`;
|
|
3789
|
-
|
|
3790
|
-
const IbcsChartStructure = class {
|
|
3791
|
-
constructor(hostRef) {
|
|
3792
|
-
registerInstance(this, hostRef);
|
|
3793
|
-
this.data = [];
|
|
3794
|
-
this.chartTitle = "";
|
|
3795
|
-
this.scenarios = [];
|
|
3796
|
-
this.variances = [];
|
|
3797
|
-
this.hideCategories = false;
|
|
3798
|
-
this.pixelPerUnit = 10;
|
|
3799
|
-
this.pixelPerPercentage = 50;
|
|
3800
|
-
this.limit = 0;
|
|
3801
|
-
this.i18n = new Map(); // I18nMode;
|
|
3802
|
-
this.order = {
|
|
3803
|
-
hierarchy: [],
|
|
3804
|
-
direction: OrderDirection.ASC,
|
|
3805
|
-
};
|
|
3806
|
-
this.level = AggregationLevel.CATEGORY;
|
|
3807
|
-
this.filter = "";
|
|
3808
|
-
this.measureScale = "_";
|
|
3809
|
-
this.measureUnit = "";
|
|
3810
|
-
this.showMeasureScale = true;
|
|
3811
|
-
this.dataFormatDigits = { percent: 2, decimal: 1 };
|
|
3812
|
-
this.stackConfig = null;
|
|
3813
|
-
this.parentDimensions = { width: 0, height: 0 };
|
|
3814
|
-
}
|
|
3815
|
-
render() {
|
|
3816
|
-
var _a, _b, _c;
|
|
3817
|
-
if (this.chart === undefined) {
|
|
3818
|
-
return h(Host, null);
|
|
3819
|
-
}
|
|
3820
|
-
if (this.chart.hasNoData()) {
|
|
3821
|
-
const errorMsg = this.i18n.get("NO_DATA") || "==No Data==";
|
|
3822
|
-
return (h(Host, null, h("p", { class: "warning" }, errorMsg)));
|
|
3823
|
-
}
|
|
3824
|
-
return (h(Host, null, h("div", { innerHTML: (_a = this.pattern) === null || _a === void 0 ? void 0 : _a.toString(), class: "hidePatternContainer" }), h("div", { class: this.showMeasureScale ? "footer" : "footer-hide" }, (_b = this.chart) === null || _b === void 0 ? void 0 : _b.getFooter()), h("div", { innerHTML: (_c = this.chart) === null || _c === void 0 ? void 0 : _c.toString() })));
|
|
3825
|
-
}
|
|
3826
|
-
async componentWillLoad() {
|
|
3827
|
-
var _a;
|
|
3828
|
-
const config = this.prepareConfig();
|
|
3829
|
-
const styles = this.prepareStyle();
|
|
3830
|
-
this.chart = new StructureChart(new IBCSRuleSet(), config, styles);
|
|
3831
|
-
this.chart.setI18n(this.i18n);
|
|
3832
|
-
this.autoFitScaling(config, styles);
|
|
3833
|
-
this.chart.setAvailableWidth(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
3834
|
-
this.pattern = new CustomPattern(this.chart.styles);
|
|
3835
|
-
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
3836
|
-
}
|
|
3837
|
-
async componentWillUpdate() {
|
|
3838
|
-
var _a;
|
|
3839
|
-
if (this.chart == null) {
|
|
3840
|
-
return;
|
|
3841
|
-
}
|
|
3842
|
-
const config = this.prepareConfig();
|
|
3843
|
-
const styles = this.prepareStyle();
|
|
3844
|
-
this.chart.setI18n(this.i18n);
|
|
3845
|
-
this.chart.setStyles(styles);
|
|
3846
|
-
this.chart.setConfig(config);
|
|
3847
|
-
this.autoFitScaling(config, styles);
|
|
3848
|
-
this.chart.setAvailableWidth(((_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width) || 0);
|
|
3849
|
-
this.pattern = new CustomPattern(this.chart.styles);
|
|
3850
|
-
this.chart.setPattern("fc", this.pattern.getFCPolygonPattern());
|
|
3851
|
-
}
|
|
3852
|
-
/**
|
|
3853
|
-
* Two-pass auto-fit: only when pixelPerUnit is 0 (auto mode).
|
|
3854
|
-
* Explicit values are never overridden — the outer component warns
|
|
3855
|
-
* about overflow via componentDidRender.
|
|
3856
|
-
* Structure charts grow horizontally, so we fit to width.
|
|
3857
|
-
*/
|
|
3858
|
-
autoFitScaling(config, styles) {
|
|
3859
|
-
var _a;
|
|
3860
|
-
if (config.pixelPerUnit > 0) {
|
|
3861
|
-
return; // Explicit value — respect it, do not override
|
|
3862
|
-
}
|
|
3863
|
-
const targetWidth = (_a = this.parentDimensions) === null || _a === void 0 ? void 0 : _a.width;
|
|
3864
|
-
if (!targetWidth || targetWidth <= 0) {
|
|
3865
|
-
config.pixelPerUnit = 1;
|
|
3866
|
-
this.chart = new StructureChart(new IBCSRuleSet(), config, styles);
|
|
3867
|
-
this.chart.setI18n(this.i18n);
|
|
3868
|
-
return;
|
|
3869
|
-
}
|
|
3870
|
-
// First pass with pixelPerUnit=1 to measure total width and bar extent
|
|
3871
|
-
config.pixelPerUnit = 1;
|
|
3872
|
-
this.chart = new StructureChart(new IBCSRuleSet(), config, styles);
|
|
3873
|
-
this.chart.setI18n(this.i18n);
|
|
3874
|
-
this.chart.toString();
|
|
3875
|
-
const svgWidth = this.chart.getAllocatedCanvasWidth();
|
|
3876
|
-
if (svgWidth <= 0) {
|
|
3877
|
-
return;
|
|
3878
|
-
}
|
|
3879
|
-
// Separate fixed parts (labels, padding, spacing) from variable part (bar extent).
|
|
3880
|
-
// totalWidth(ppu) = fixedWidth + maxBarValue * ppu
|
|
3881
|
-
// Solving for ppu: ppu = (targetWidth - fixedWidth) / maxBarValue
|
|
3882
|
-
const maxBarValue = this.chart.getMaxBarValue();
|
|
3883
|
-
if (maxBarValue > 0) {
|
|
3884
|
-
const fixedWidth = svgWidth - maxBarValue; // at ppu=1, barExtent = maxBarValue * 1
|
|
3885
|
-
config.pixelPerUnit = Math.max(0.001, (targetWidth - fixedWidth) / maxBarValue);
|
|
3886
|
-
}
|
|
3887
|
-
else {
|
|
3888
|
-
// Fallback (e.g. relative variance charts)
|
|
3889
|
-
config.pixelPerUnit = (targetWidth * 0.9) / svgWidth;
|
|
3890
|
-
}
|
|
3891
|
-
// Second pass with the corrected scaling
|
|
3892
|
-
this.chart = new StructureChart(new IBCSRuleSet(), config, styles);
|
|
3893
|
-
this.chart.setI18n(this.i18n);
|
|
3894
|
-
}
|
|
3895
|
-
async componentWillRender() {
|
|
3896
|
-
// return await (async () => {
|
|
3897
|
-
//
|
|
3898
|
-
// if (this.chart) {
|
|
3899
|
-
// this.chart.draw(SVG(this.drawElement) as Svg);
|
|
3900
|
-
// }
|
|
3901
|
-
// })()
|
|
3902
|
-
}
|
|
3903
|
-
componentDidLoad() {
|
|
3904
|
-
// if (this.chart == null) {
|
|
3905
|
-
// return;
|
|
3906
|
-
// }
|
|
3907
|
-
// this.chart.draw(SVG(this.drawElement) as Svg);
|
|
3908
|
-
// forceUpdate(getElement(this));
|
|
3909
|
-
}
|
|
3910
|
-
componentDidUpdate() {
|
|
3911
|
-
// if (this.chart) {
|
|
3912
|
-
// this.chart.draw(SVG(this.drawElement) as Svg);
|
|
3913
|
-
// }
|
|
3914
|
-
}
|
|
3915
|
-
prepareConfig() {
|
|
3916
|
-
return new StructureChartComponentConfigAdapter(new StructureChartDataRowAdapter(), new OrderAdapter(new StringAdapter()), new StringAdapter(), new DataFormatDigitsAdapter(), this.data).adapt({
|
|
3917
|
-
data: this.data,
|
|
3918
|
-
scenarios: this.scenarios,
|
|
3919
|
-
variances: this.variances,
|
|
3920
|
-
title: this.chartTitle,
|
|
3921
|
-
hideCategories: this.hideCategories,
|
|
3922
|
-
pixelPerUnit: this.pixelPerUnit,
|
|
3923
|
-
pixelPerPercentage: this.pixelPerPercentage,
|
|
3924
|
-
level: this.level,
|
|
3925
|
-
limit: this.limit,
|
|
3926
|
-
sortOrder: this.order,
|
|
3927
|
-
filter: this.filter,
|
|
3928
|
-
measureScale: this.measureScale,
|
|
3929
|
-
measureUnit: this.measureUnit,
|
|
3930
|
-
showMeasureScale: this.showMeasureScale,
|
|
3931
|
-
dataFormatDigits: this.dataFormatDigits,
|
|
3932
|
-
stackConfig: this.stackConfig,
|
|
3933
|
-
});
|
|
3934
|
-
}
|
|
3935
|
-
prepareStyle() {
|
|
3936
|
-
return new StructureChartStylesAdapter(new ScaleFactorsStructureChartAdapter(), new FontStyleAdapter(), new SVGStyleGroupAdapter(new SVGStyleAdapter()), new SVGVariancesStyleGroupAdapter(new SVGStyleAdapter()), new PaddingAdapter()).adapt(this.styles);
|
|
3937
|
-
}
|
|
3938
|
-
get element() { return getElement(this); }
|
|
3939
|
-
};
|
|
3940
|
-
IbcsChartStructure.style = bnChartStructureCss();
|
|
3941
|
-
|
|
3942
|
-
export { Chart as bn_chart_structure, Context as bn_context, Datasource as bn_datasource, Page as bn_page, IbcsChartStructure as ibcs_chart_structure };
|