@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,142 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var alasql_min = require('./alasql.min-C_nHTuEQ.js');
|
|
4
|
-
var Order = require('./Order-iG11HI4R.js');
|
|
5
|
-
|
|
6
|
-
/** SI metric prefix for number scaling (e.g. prefix="M", value=1000000 divides displayed values by one million). */
|
|
7
|
-
class SiPrefix {
|
|
8
|
-
constructor(prefix = "", value = 1) {
|
|
9
|
-
this.prefix = prefix;
|
|
10
|
-
this.value = value;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* SI prefix lookup table mapping prefix symbols to their numeric multipliers.
|
|
16
|
-
* Used by {@link DataAnalyzer.calculateMeasureScale} to convert a prefix string
|
|
17
|
-
* (e.g. `"M"` for mega) into the corresponding divisor for display scaling.
|
|
18
|
-
*
|
|
19
|
-
* Covers the full SI range from yocto (10^-24) to yotta (10^24).
|
|
20
|
-
* Note: `"my"` is used instead of `"μ"` (micro) for ASCII compatibility.
|
|
21
|
-
*/
|
|
22
|
-
var NumeralFigure;
|
|
23
|
-
(function (NumeralFigure) {
|
|
24
|
-
NumeralFigure[NumeralFigure["Y"] = 1e+24] = "Y";
|
|
25
|
-
NumeralFigure[NumeralFigure["Z"] = 1e+21] = "Z";
|
|
26
|
-
NumeralFigure[NumeralFigure["E"] = 1000000000000000000] = "E";
|
|
27
|
-
NumeralFigure[NumeralFigure["P"] = 1000000000000000] = "P";
|
|
28
|
-
NumeralFigure[NumeralFigure["T"] = 1000000000000] = "T";
|
|
29
|
-
NumeralFigure[NumeralFigure["G"] = 1000000000] = "G";
|
|
30
|
-
NumeralFigure[NumeralFigure["M"] = 1000000] = "M";
|
|
31
|
-
NumeralFigure[NumeralFigure["k"] = 1000] = "k";
|
|
32
|
-
NumeralFigure[NumeralFigure["h"] = 100] = "h";
|
|
33
|
-
NumeralFigure[NumeralFigure["da"] = 10] = "da";
|
|
34
|
-
NumeralFigure[NumeralFigure["d"] = 0.1] = "d";
|
|
35
|
-
NumeralFigure[NumeralFigure["c"] = 0.01] = "c";
|
|
36
|
-
NumeralFigure[NumeralFigure["m"] = 0.001] = "m";
|
|
37
|
-
NumeralFigure[NumeralFigure["my"] = 0.000001] = "my";
|
|
38
|
-
NumeralFigure[NumeralFigure["n"] = 1e-9] = "n";
|
|
39
|
-
NumeralFigure[NumeralFigure["p"] = 1e-12] = "p";
|
|
40
|
-
NumeralFigure[NumeralFigure["f"] = 1e-15] = "f";
|
|
41
|
-
NumeralFigure[NumeralFigure["a"] = 1e-18] = "a";
|
|
42
|
-
NumeralFigure[NumeralFigure["z"] = 1e-21] = "z";
|
|
43
|
-
NumeralFigure[NumeralFigure["y"] = 1e-24] = "y";
|
|
44
|
-
})(NumeralFigure || (NumeralFigure = {}));
|
|
45
|
-
/**
|
|
46
|
-
* Analyzes dataset values to determine the appropriate SI prefix for display scaling.
|
|
47
|
-
*/
|
|
48
|
-
class DataAnalyzer {
|
|
49
|
-
/**
|
|
50
|
-
* Determines the appropriate SI prefix for scaling displayed values.
|
|
51
|
-
*
|
|
52
|
-
* Modes:
|
|
53
|
-
* - `"_"` (underscore): no scaling, returns identity prefix
|
|
54
|
-
* - Explicit prefix (e.g. `"k"`, `"M"`): direct lookup in NumeralFigure enum
|
|
55
|
-
* - `"GREATEST"` (default) / `"LEAST"`: auto-detect from the MAX or MIN of
|
|
56
|
-
* absolute base scenario values. Only 3-character scenario names (e.g. `ac1`)
|
|
57
|
-
* are considered; variance columns are excluded.
|
|
58
|
-
* - `null` with data: defaults to GREATEST auto-detection
|
|
59
|
-
*/
|
|
60
|
-
static calculateMeasureScale(data, scenarios, mode) {
|
|
61
|
-
var _a;
|
|
62
|
-
if (mode === "_") {
|
|
63
|
-
return new SiPrefix();
|
|
64
|
-
}
|
|
65
|
-
if (mode != null) {
|
|
66
|
-
if ([...this.unitsLeast, ...this.unitsGreat].includes(mode)) {
|
|
67
|
-
return this.lookupPrefix(mode);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (scenarios.length === 0) {
|
|
71
|
-
return new SiPrefix();
|
|
72
|
-
}
|
|
73
|
-
// filtering wordlenght == 3, so variances are not considered
|
|
74
|
-
const queryMax = `SELECT MAX(GREATEST(${scenarios
|
|
75
|
-
.filter((word) => word.length === 3)
|
|
76
|
-
.map((x) => "ABS(" + x + ")")
|
|
77
|
-
.toString()})) as prefixvalue
|
|
78
|
-
FROM ?`;
|
|
79
|
-
const queryMin = `SELECT MIN(LEAST(${scenarios
|
|
80
|
-
.filter((word) => word.length === 3)
|
|
81
|
-
.map((x) => "ABS(" + x + ")")
|
|
82
|
-
.toString()})) as prefixvalue
|
|
83
|
-
FROM ?`;
|
|
84
|
-
let query = queryMax;
|
|
85
|
-
if ((mode === null || mode === void 0 ? void 0 : mode.toUpperCase()) === "LEAST") {
|
|
86
|
-
query = queryMin;
|
|
87
|
-
}
|
|
88
|
-
const result = alasql_min.alasql(query, [data]);
|
|
89
|
-
const num = (_a = result[0]) === null || _a === void 0 ? void 0 : _a.prefixvalue;
|
|
90
|
-
return this.determinePrefix(Math.abs(num));
|
|
91
|
-
}
|
|
92
|
-
/** Maps an absolute numeric value to the best-fitting SI prefix based on digit count. */
|
|
93
|
-
static determinePrefix(num) {
|
|
94
|
-
if (num >= 1000) {
|
|
95
|
-
const floor = Math.floor(Math.floor(Math.abs(num)).toString().length / 3);
|
|
96
|
-
const value = +Math.pow(1000, floor);
|
|
97
|
-
return new SiPrefix(this.unitsGreat[floor - 1], value);
|
|
98
|
-
}
|
|
99
|
-
if (num <= 0.001) {
|
|
100
|
-
const floor = Math.floor(Math.abs(num).toString().length / 3);
|
|
101
|
-
const value = +(1 / Math.pow(1000, floor));
|
|
102
|
-
return new SiPrefix(this.unitsLeast[floor - 1], value);
|
|
103
|
-
}
|
|
104
|
-
return new SiPrefix();
|
|
105
|
-
}
|
|
106
|
-
/** Looks up an explicit SI prefix string in the NumeralFigure enum. */
|
|
107
|
-
static lookupPrefix(mode) {
|
|
108
|
-
return new SiPrefix(mode, NumeralFigure[mode]);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
/** SI prefixes for large numbers, ordered by magnitude (k=10^3 .. Y=10^24). */
|
|
112
|
-
DataAnalyzer.unitsGreat = ["k", "M", "G", "T", "P", "E", "Z", "Y"];
|
|
113
|
-
/** SI prefixes for small numbers, ordered by magnitude (m=10^-3 .. y=10^-24). */
|
|
114
|
-
DataAnalyzer.unitsLeast = ["m", "my", "n", "p", "P", "f", "a", "z", "y"];
|
|
115
|
-
|
|
116
|
-
/** Decimal precision configuration: separate digit counts for percent columns vs absolute (decimal) columns. */
|
|
117
|
-
class DataFormatDigits {
|
|
118
|
-
constructor(percent = 2, decimal = 1) {
|
|
119
|
-
this.percent = percent;
|
|
120
|
-
this.decimal = decimal;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
class DataFormatDigitsAdapter {
|
|
124
|
-
adapt(data) {
|
|
125
|
-
const prefix = new DataFormatDigits();
|
|
126
|
-
if (Order.CompareUtil.isNumber(data.percent)) {
|
|
127
|
-
prefix.percent = data.percent;
|
|
128
|
-
}
|
|
129
|
-
if (Order.CompareUtil.isNumber(data.decimal)) {
|
|
130
|
-
prefix.decimal = data.decimal;
|
|
131
|
-
}
|
|
132
|
-
return prefix;
|
|
133
|
-
}
|
|
134
|
-
default() {
|
|
135
|
-
return new DataFormatDigits();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
exports.DataAnalyzer = DataAnalyzer;
|
|
140
|
-
exports.DataFormatDigits = DataFormatDigits;
|
|
141
|
-
exports.DataFormatDigitsAdapter = DataFormatDigitsAdapter;
|
|
142
|
-
exports.SiPrefix = SiPrefix;
|
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Order = require('./Order-iG11HI4R.js');
|
|
4
|
-
|
|
5
|
-
/** Granularity levels for date intervals, from YEAR down to MILLISECOND. AUTO triggers auto-detection. */
|
|
6
|
-
exports.DateDistance = void 0;
|
|
7
|
-
(function (DateDistance) {
|
|
8
|
-
DateDistance["YEAR"] = "year";
|
|
9
|
-
DateDistance["QUARTER"] = "quarter";
|
|
10
|
-
DateDistance["MONTH"] = "month";
|
|
11
|
-
DateDistance["WEEK"] = "week";
|
|
12
|
-
DateDistance["DAY"] = "day";
|
|
13
|
-
DateDistance["HOUR"] = "hour";
|
|
14
|
-
DateDistance["MINUTE"] = "minute";
|
|
15
|
-
DateDistance["SECOND"] = "second";
|
|
16
|
-
DateDistance["MILLISECOND"] = "millisecond";
|
|
17
|
-
DateDistance["NONE"] = "fallback";
|
|
18
|
-
DateDistance["AUTO"] = "auto";
|
|
19
|
-
})(exports.DateDistance || (exports.DateDistance = {}));
|
|
20
|
-
/** IBCS date-link modes controlling how start/end dates are rendered in titles and axis labels. */
|
|
21
|
-
exports.DateLink = void 0;
|
|
22
|
-
(function (DateLink) {
|
|
23
|
-
DateLink["AVG"] = "avg";
|
|
24
|
-
DateLink["INTERVAL"] = "interval";
|
|
25
|
-
DateLink["START"] = "start";
|
|
26
|
-
DateLink["END"] = "end";
|
|
27
|
-
DateLink["YTD"] = "ytd";
|
|
28
|
-
DateLink["YTG"] = "ytg";
|
|
29
|
-
DateLink["CUM"] = "cum";
|
|
30
|
-
DateLink["MAT"] = "mat";
|
|
31
|
-
DateLink["NONE"] = "none";
|
|
32
|
-
DateLink["AUTO"] = "auto";
|
|
33
|
-
})(exports.DateLink || (exports.DateLink = {}));
|
|
34
|
-
/**
|
|
35
|
-
* Produces formatted date strings and IBCS date-link notations for time-series charts.
|
|
36
|
-
*
|
|
37
|
-
* Supports configurable date formats (full and abbreviated), locale-aware formatting
|
|
38
|
-
* via Luxon, smart boundary labels that append the parent period at crossings
|
|
39
|
-
* (e.g. month name shown at the first day of a new month), and IBCS date-link
|
|
40
|
-
* notation (AVG, YTD, YTG, CUM, MAT, INTERVAL, START, END).
|
|
41
|
-
*/
|
|
42
|
-
class DateStringFactory {
|
|
43
|
-
constructor() {
|
|
44
|
-
this._dateFormat = {
|
|
45
|
-
year: "yyyy",
|
|
46
|
-
quarter: "q'Q' yyyy",
|
|
47
|
-
month: "LLL yyyy",
|
|
48
|
-
week: "'KW'WW yyyy",
|
|
49
|
-
day: "dd.MM.yyyy",
|
|
50
|
-
hour: "TT",
|
|
51
|
-
minute: "TT",
|
|
52
|
-
second: "TT",
|
|
53
|
-
millisecond: "TT:SSS",
|
|
54
|
-
fallback: "dd.MM.yyyy",
|
|
55
|
-
};
|
|
56
|
-
this._dateFormatShort = {
|
|
57
|
-
year: "yy",
|
|
58
|
-
quarter: "q'Q'",
|
|
59
|
-
month: "LLL",
|
|
60
|
-
week: "'KW'WW",
|
|
61
|
-
day: "dd",
|
|
62
|
-
hour: "hh'h'",
|
|
63
|
-
minute: "mm'm'",
|
|
64
|
-
second: "ss's'",
|
|
65
|
-
millisecond: "SSS'ms'",
|
|
66
|
-
fallback: "dd.MM.yyyy",
|
|
67
|
-
};
|
|
68
|
-
this._dateLinkFormat = {
|
|
69
|
-
avg: "Ø[LINK]",
|
|
70
|
-
interval: "[DATE]..[DATE2]",
|
|
71
|
-
start: ".[DATE]",
|
|
72
|
-
end: "[DATE].",
|
|
73
|
-
ytd: "_[DATE]",
|
|
74
|
-
ytg: "[DATE]_",
|
|
75
|
-
cum: "[DATE]_[DATE2]",
|
|
76
|
-
mat: "~[DATE]",
|
|
77
|
-
none: "[DATE]",
|
|
78
|
-
};
|
|
79
|
-
this.locale = "de";
|
|
80
|
-
this.dateFormat = this._dateFormat;
|
|
81
|
-
this.dateLinkFormat = this._dateLinkFormat;
|
|
82
|
-
this.dateFormatShort = this._dateFormatShort;
|
|
83
|
-
}
|
|
84
|
-
setDateLinkFormat(datelink) {
|
|
85
|
-
this.dateLinkFormat = datelink;
|
|
86
|
-
}
|
|
87
|
-
setDateFormat(dateFormat) {
|
|
88
|
-
this.dateFormat = dateFormat;
|
|
89
|
-
}
|
|
90
|
-
setDateFormatShort(dateFormatShort) {
|
|
91
|
-
this.dateFormatShort = dateFormatShort;
|
|
92
|
-
}
|
|
93
|
-
setLocale(locale) {
|
|
94
|
-
this.locale = locale;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Converts date string based on dateFormatMap and the selected Type
|
|
98
|
-
*
|
|
99
|
-
* @param date
|
|
100
|
-
* @param type?
|
|
101
|
-
*/
|
|
102
|
-
getDateString(date, type) {
|
|
103
|
-
return date.setLocale(this.locale).toFormat(this.dateFormat[type] || this.dateFormat["fallback"]);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Produces abbreviated date labels that include the parent period at boundary crossings.
|
|
107
|
-
*
|
|
108
|
-
* For example, with MONTH granularity, most ticks show just "Jan", "Feb", etc.,
|
|
109
|
-
* but the first month of a new year also appends the year ("Jan 24").
|
|
110
|
-
* This avoids redundant repetition while keeping boundary context visible.
|
|
111
|
-
*/
|
|
112
|
-
getSmartDateString(date, type) {
|
|
113
|
-
switch (type) {
|
|
114
|
-
case exports.DateDistance.DAY: {
|
|
115
|
-
return this.getFormatedDayDate(date);
|
|
116
|
-
}
|
|
117
|
-
case exports.DateDistance.MONTH: {
|
|
118
|
-
return this.getFormatedMonthDate(date);
|
|
119
|
-
}
|
|
120
|
-
case exports.DateDistance.QUARTER: {
|
|
121
|
-
return this.getFormatedQuarterDate(date);
|
|
122
|
-
}
|
|
123
|
-
case exports.DateDistance.WEEK: {
|
|
124
|
-
return this.getFormatedWeekDate(date);
|
|
125
|
-
}
|
|
126
|
-
case exports.DateDistance.HOUR: {
|
|
127
|
-
return this.getFormatedHourDate(date);
|
|
128
|
-
}
|
|
129
|
-
case exports.DateDistance.MINUTE: {
|
|
130
|
-
return this.getFormatedMinuteDate(date);
|
|
131
|
-
}
|
|
132
|
-
case exports.DateDistance.SECOND: {
|
|
133
|
-
return this.getFormatedSecondDate(date);
|
|
134
|
-
}
|
|
135
|
-
case exports.DateDistance.MILLISECOND: {
|
|
136
|
-
return this.getFormatedMilliSecondDate(date);
|
|
137
|
-
}
|
|
138
|
-
default: {
|
|
139
|
-
return this.getDateString(date, type);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Determines the best-fitting {@link DateDistance} granularity for the span between two dates.
|
|
145
|
-
*
|
|
146
|
-
* Cascades through granularities from finest (millisecond) to coarsest (year),
|
|
147
|
-
* comparing the span against the `limit` threshold at each level. Returns the
|
|
148
|
-
* first granularity where the span is below the limit, ensuring the number of
|
|
149
|
-
* axis ticks stays manageable. Defaults to DAY for zero-span or null end dates.
|
|
150
|
-
*
|
|
151
|
-
* @param limit Maximum number of intervals before stepping up to a coarser granularity (default 32).
|
|
152
|
-
*/
|
|
153
|
-
calculateDistanceType(start, end, limit = 32) {
|
|
154
|
-
if (end == null) {
|
|
155
|
-
return exports.DateDistance.DAY;
|
|
156
|
-
}
|
|
157
|
-
const mStart = typeof start == "number" ? Order.DateTime.fromMillis(start) : start;
|
|
158
|
-
const mEnd = typeof end == "number" ? Order.DateTime.fromMillis(end) : end;
|
|
159
|
-
if (mEnd.diff(mStart).as("milliseconds") === 0) {
|
|
160
|
-
return exports.DateDistance.DAY;
|
|
161
|
-
}
|
|
162
|
-
else if (mEnd.diff(mStart).as("milliseconds") < limit) {
|
|
163
|
-
return exports.DateDistance.MILLISECOND;
|
|
164
|
-
}
|
|
165
|
-
else if (mEnd.diff(mStart).as("seconds") < limit) {
|
|
166
|
-
return exports.DateDistance.SECOND;
|
|
167
|
-
}
|
|
168
|
-
else if (mEnd.diff(mStart).as("minutes") < limit) {
|
|
169
|
-
return exports.DateDistance.MINUTE;
|
|
170
|
-
}
|
|
171
|
-
else if (mEnd.diff(mStart).as("hours") < limit) {
|
|
172
|
-
return exports.DateDistance.HOUR;
|
|
173
|
-
}
|
|
174
|
-
else if (mEnd.diff(mStart).as("days") < limit) {
|
|
175
|
-
return exports.DateDistance.DAY;
|
|
176
|
-
}
|
|
177
|
-
else if (mEnd.diff(mStart).as("weeks") < limit) {
|
|
178
|
-
return exports.DateDistance.WEEK;
|
|
179
|
-
}
|
|
180
|
-
else if (mEnd.diff(mStart).as("months") < limit) {
|
|
181
|
-
return exports.DateDistance.MONTH;
|
|
182
|
-
}
|
|
183
|
-
else if (mEnd.diff(mStart).as("quarters") < limit) {
|
|
184
|
-
return exports.DateDistance.QUARTER;
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
return exports.DateDistance.YEAR;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Get an array of moment instances, each representing a day beween given timestamps.
|
|
192
|
-
* @param {string|Date} from start date
|
|
193
|
-
* @param {string|Date} to end date
|
|
194
|
-
* @param dateInterval
|
|
195
|
-
* @param spanLimit
|
|
196
|
-
*/
|
|
197
|
-
datesBetween(from, to, dateInterval, spanLimit) {
|
|
198
|
-
const unit = this.convertDateDistanceToMomentunitOfTime(dateInterval);
|
|
199
|
-
const fromDate = from.startOf(unit);
|
|
200
|
-
const toDate = to.endOf(unit);
|
|
201
|
-
let span = toDate.diff(fromDate).as(unit);
|
|
202
|
-
const days = [];
|
|
203
|
-
if (span >= spanLimit) {
|
|
204
|
-
span = spanLimit;
|
|
205
|
-
}
|
|
206
|
-
let currentDate = fromDate;
|
|
207
|
-
do {
|
|
208
|
-
days.push(currentDate);
|
|
209
|
-
currentDate = currentDate.plus(this.createDiratonLike(unit, 1));
|
|
210
|
-
} while (currentDate <= toDate && days.length < span);
|
|
211
|
-
return days;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Produces an IBCS date-link string combining date formatting with link notation.
|
|
215
|
-
*
|
|
216
|
-
* Supported modes map to IBCS conventions:
|
|
217
|
-
* - `AVG`: average symbol `Ø` wrapping the interval
|
|
218
|
-
* - `YTD` / `YTG`: year-to-date / year-to-go underline notation
|
|
219
|
-
* - `CUM`: cumulative range `start_end`
|
|
220
|
-
* - `MAT`: moving annual total `~date`
|
|
221
|
-
* - `INTERVAL`: `start..end` range
|
|
222
|
-
* - `START` / `END`: dot-prefixed/suffixed single date
|
|
223
|
-
*
|
|
224
|
-
* When start and end resolve to the same formatted string, INTERVAL is collapsed
|
|
225
|
-
* to NONE to avoid redundant display. Year parts are deduplicated when both dates
|
|
226
|
-
* share the same year (e.g. "Q1 .. Q3 2024" instead of "Q1 2024 .. Q3 2024").
|
|
227
|
-
*
|
|
228
|
-
* @param type DateDistance granularity; when AUTO, it is auto-detected via `calculateDistanceType`.
|
|
229
|
-
*/
|
|
230
|
-
getDateLinkString(startDateTime, endDateTime, mode, type, spanLimit) {
|
|
231
|
-
// No Start/ End Date exists
|
|
232
|
-
if (startDateTime == null && endDateTime == null) {
|
|
233
|
-
// BinoSystem.warn('NO START AND END DATE SELECTED');
|
|
234
|
-
return "";
|
|
235
|
-
}
|
|
236
|
-
if (startDateTime == null && !(mode === exports.DateLink.END || mode === exports.DateLink.YTD)) {
|
|
237
|
-
// BinoSystem.warn('NO START N SELECTED');
|
|
238
|
-
return "";
|
|
239
|
-
}
|
|
240
|
-
if (endDateTime == null &&
|
|
241
|
-
(exports.DateLink.INTERVAL === mode || exports.DateLink.CUM === mode || exports.DateLink.END === mode || exports.DateLink.YTD === mode)) {
|
|
242
|
-
// BinoSystem.warn('NO END N SELECTED');
|
|
243
|
-
return "";
|
|
244
|
-
}
|
|
245
|
-
const date1 = startDateTime || Order.DateTime.now();
|
|
246
|
-
const date2 = endDateTime;
|
|
247
|
-
// calculate type value aka. auto-mode
|
|
248
|
-
if (type === exports.DateDistance.AUTO) {
|
|
249
|
-
type = this.calculateDistanceType(date1, date2, spanLimit);
|
|
250
|
-
}
|
|
251
|
-
let dateString1 = this.getDateString(date1, type);
|
|
252
|
-
let dateString2 = "";
|
|
253
|
-
let link = exports.DateLink.NONE;
|
|
254
|
-
if (date2 != null) {
|
|
255
|
-
dateString2 = this.getDateString(date2, type);
|
|
256
|
-
link = exports.DateLink.INTERVAL;
|
|
257
|
-
// clean up visualisation if start and end (formated) ist identical
|
|
258
|
-
if (dateString1 === dateString2 && mode === exports.DateLink.INTERVAL) {
|
|
259
|
-
// BinoSystem.warn('CHANGED INTERVAL TO NONE; START AND END ARE IDENTICAL');
|
|
260
|
-
mode = exports.DateLink.NONE;
|
|
261
|
-
}
|
|
262
|
-
if (dateString1 === dateString2 && mode === exports.DateLink.AVG) {
|
|
263
|
-
// BinoSystem.warn('CHANGED INTERVAL TO NONE; START AND END ARE IDENTICAL');
|
|
264
|
-
link = exports.DateLink.NONE;
|
|
265
|
-
}
|
|
266
|
-
if (exports.DateLink.END === mode || exports.DateLink.YTD === mode) {
|
|
267
|
-
dateString1 = dateString2;
|
|
268
|
-
}
|
|
269
|
-
// clean up dateString1 if same year
|
|
270
|
-
if (mode === exports.DateLink.INTERVAL || mode === exports.DateLink.CUM || exports.DateLink.AVG) {
|
|
271
|
-
if (type === exports.DateDistance.QUARTER) {
|
|
272
|
-
if (date1.quarter === date2.quarter && date1.year === date2.year) {
|
|
273
|
-
dateString2 = dateString2.replace(" " + date2.year, "");
|
|
274
|
-
}
|
|
275
|
-
else if (date1.year === date2.year) {
|
|
276
|
-
dateString1 = dateString1.replace(" " + date1.year, "");
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
else if (type === exports.DateDistance.MONTH) {
|
|
280
|
-
if (date1.month === date2.month && date1.year === date2.year) {
|
|
281
|
-
dateString2 = dateString2.replace(" " + date2.year, "");
|
|
282
|
-
}
|
|
283
|
-
else if (date1.year === date2.year) {
|
|
284
|
-
dateString1 = dateString1.replace(" " + date1.year, "");
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
else if (type === exports.DateDistance.WEEK) {
|
|
288
|
-
if (date1.weekNumber === date2.weekNumber && date1.year === date2.year) {
|
|
289
|
-
dateString2 = dateString2.replace(" " + date2.year, "");
|
|
290
|
-
}
|
|
291
|
-
else if (date1.year === date2.year) {
|
|
292
|
-
dateString1 = dateString1.replace(" " + date1.year, "");
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return this.dateLinkFormat[mode]
|
|
298
|
-
.replace("[LINK]", this.dateLinkFormat[link])
|
|
299
|
-
.replace("[DATE]", dateString1)
|
|
300
|
-
.replace("[DATE2]", dateString2);
|
|
301
|
-
}
|
|
302
|
-
/** Returns an abbreviated date string using the short format map (e.g. "yy" for year, "LLL" for month). */
|
|
303
|
-
getShortDateString(date, type) {
|
|
304
|
-
return date
|
|
305
|
-
.setLocale(this.locale)
|
|
306
|
-
.toFormat(this.dateFormatShort[type] || this.dateFormatShort["fallback"]);
|
|
307
|
-
}
|
|
308
|
-
getFormatedDayDate(date) {
|
|
309
|
-
let format = this.dateFormatShort["day"];
|
|
310
|
-
if (this.isFirstInMonth(date)) {
|
|
311
|
-
format += " " + this.dateFormatShort["month"];
|
|
312
|
-
}
|
|
313
|
-
if (this.isJanuary(date)) {
|
|
314
|
-
format += " " + this.dateFormatShort["year"];
|
|
315
|
-
}
|
|
316
|
-
return date.setLocale(this.locale).toFormat(format);
|
|
317
|
-
}
|
|
318
|
-
getFormatedMonthDate(date) {
|
|
319
|
-
let format = this.dateFormatShort["month"];
|
|
320
|
-
if (this.isJanuary(date)) {
|
|
321
|
-
format += " " + this.dateFormatShort["year"];
|
|
322
|
-
}
|
|
323
|
-
return date.setLocale(this.locale).toFormat(format);
|
|
324
|
-
}
|
|
325
|
-
getFormatedQuarterDate(date) {
|
|
326
|
-
let format = this.dateFormatShort["quarter"];
|
|
327
|
-
if (this.isFirstQuarter(date)) {
|
|
328
|
-
format += " " + this.dateFormatShort["year"];
|
|
329
|
-
}
|
|
330
|
-
return date.setLocale(this.locale).toFormat(format);
|
|
331
|
-
}
|
|
332
|
-
getFormatedWeekDate(date) {
|
|
333
|
-
let format = this.dateFormatShort["week"];
|
|
334
|
-
if (this.isFirstWeek(date)) {
|
|
335
|
-
format += " " + this.dateFormatShort["year"];
|
|
336
|
-
}
|
|
337
|
-
return date.setLocale(this.locale).toFormat(format);
|
|
338
|
-
}
|
|
339
|
-
getFormatedHourDate(date) {
|
|
340
|
-
let format = this.dateFormatShort["hour"];
|
|
341
|
-
if (this.isFirstHour(date)) {
|
|
342
|
-
format += " " + this.dateFormatShort["day"];
|
|
343
|
-
}
|
|
344
|
-
return date.setLocale(this.locale).toFormat(format);
|
|
345
|
-
}
|
|
346
|
-
getFormatedMinuteDate(date) {
|
|
347
|
-
let format = this.dateFormatShort["minute"];
|
|
348
|
-
if (this.isFirstMinute(date)) {
|
|
349
|
-
format = this.dateFormatShort["hour"] + ":" + format;
|
|
350
|
-
}
|
|
351
|
-
return date.setLocale(this.locale).toFormat(format);
|
|
352
|
-
}
|
|
353
|
-
getFormatedSecondDate(date) {
|
|
354
|
-
let format = this.dateFormatShort["second"];
|
|
355
|
-
if (this.isFirstSecond(date)) {
|
|
356
|
-
format = this.dateFormatShort["minute"] + ":" + format;
|
|
357
|
-
}
|
|
358
|
-
return date.setLocale(this.locale).toFormat(format);
|
|
359
|
-
}
|
|
360
|
-
getFormatedMilliSecondDate(date) {
|
|
361
|
-
let format = this.dateFormatShort["millisecond"];
|
|
362
|
-
if (this.isFirstMilliSecond(date)) {
|
|
363
|
-
format = this.dateFormatShort["second"] + ":" + format;
|
|
364
|
-
}
|
|
365
|
-
return date.setLocale(this.locale).toFormat(format);
|
|
366
|
-
}
|
|
367
|
-
isFirstInMonth(date) {
|
|
368
|
-
return date.day === 1;
|
|
369
|
-
}
|
|
370
|
-
isJanuary(date) {
|
|
371
|
-
return date.month === 1;
|
|
372
|
-
}
|
|
373
|
-
isFirstQuarter(date) {
|
|
374
|
-
return date.quarter === 1;
|
|
375
|
-
}
|
|
376
|
-
isFirstWeek(date) {
|
|
377
|
-
return date.weekNumber === 1;
|
|
378
|
-
}
|
|
379
|
-
isFirstHour(date) {
|
|
380
|
-
return date.hour === 0;
|
|
381
|
-
}
|
|
382
|
-
isFirstMinute(date) {
|
|
383
|
-
return date.minute === 0;
|
|
384
|
-
}
|
|
385
|
-
isFirstSecond(date) {
|
|
386
|
-
return date.second === 0;
|
|
387
|
-
}
|
|
388
|
-
isFirstMilliSecond(date) {
|
|
389
|
-
return date.millisecond === 0;
|
|
390
|
-
}
|
|
391
|
-
convertDateDistanceToMomentunitOfTime(dateInterval) {
|
|
392
|
-
let unitOfTime;
|
|
393
|
-
switch (dateInterval) {
|
|
394
|
-
case exports.DateDistance.YEAR:
|
|
395
|
-
unitOfTime = "year";
|
|
396
|
-
break;
|
|
397
|
-
case exports.DateDistance.MONTH:
|
|
398
|
-
unitOfTime = "month";
|
|
399
|
-
break;
|
|
400
|
-
case exports.DateDistance.QUARTER:
|
|
401
|
-
unitOfTime = "quarter";
|
|
402
|
-
break;
|
|
403
|
-
case exports.DateDistance.WEEK:
|
|
404
|
-
unitOfTime = "week";
|
|
405
|
-
break;
|
|
406
|
-
case exports.DateDistance.DAY:
|
|
407
|
-
unitOfTime = "day";
|
|
408
|
-
break;
|
|
409
|
-
case exports.DateDistance.HOUR:
|
|
410
|
-
unitOfTime = "hour";
|
|
411
|
-
break;
|
|
412
|
-
case exports.DateDistance.MINUTE:
|
|
413
|
-
unitOfTime = "minute";
|
|
414
|
-
break;
|
|
415
|
-
case exports.DateDistance.SECOND:
|
|
416
|
-
unitOfTime = "second";
|
|
417
|
-
break;
|
|
418
|
-
case exports.DateDistance.MILLISECOND:
|
|
419
|
-
unitOfTime = "millisecond";
|
|
420
|
-
break;
|
|
421
|
-
default:
|
|
422
|
-
unitOfTime = "day";
|
|
423
|
-
}
|
|
424
|
-
return unitOfTime;
|
|
425
|
-
}
|
|
426
|
-
createDiratonLike(unit, number) {
|
|
427
|
-
switch (unit) {
|
|
428
|
-
case "year":
|
|
429
|
-
return { years: number };
|
|
430
|
-
case "month":
|
|
431
|
-
return { months: number };
|
|
432
|
-
case "quarter":
|
|
433
|
-
return { quarters: number };
|
|
434
|
-
case "week":
|
|
435
|
-
return { weeks: number };
|
|
436
|
-
case "day":
|
|
437
|
-
return { days: number };
|
|
438
|
-
case "hour":
|
|
439
|
-
return { hours: number };
|
|
440
|
-
case "minute":
|
|
441
|
-
return { minutes: number };
|
|
442
|
-
case "second":
|
|
443
|
-
return { seconds: number };
|
|
444
|
-
case "millisecond":
|
|
445
|
-
return { milliseconds: number };
|
|
446
|
-
default:
|
|
447
|
-
return { days: number };
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
exports.DateStringFactory = DateStringFactory;
|