@bino-bi/bn-template-engine 1.0.0-alpha.7 → 1.0.0-alpha.8
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-0d41c5d8.entry.js +1 -0
- package/dist/bn-template-engine/p-67538176.entry.js +1 -0
- package/dist/bn-template-engine/p-825a07a8.entry.js +1 -0
- package/dist/bn-template-engine/p-916296a5.entry.js +1 -0
- package/dist/bn-template-engine/{p-1164c0b0.entry.js → p-96006b06.entry.js} +1 -1
- package/dist/bn-template-engine/p-B4JfKvVT.js +1 -0
- package/dist/bn-template-engine/{p-JNHhIe7t.js → p-B_d-jp99.js} +1 -1
- package/dist/bn-template-engine/p-Ck-NYtot.js +1 -0
- package/dist/bn-template-engine/p-CnDq0oVa.js +1 -0
- package/dist/bn-template-engine/p-DSXNgKLa.js +1 -0
- package/dist/bn-template-engine/p-bc711fb0.entry.js +1 -0
- package/dist/bn-template-engine/p-e6f646b1.entry.js +1 -0
- package/dist/bn-template-engine/p-f41d9242.entry.js +1 -0
- package/dist/bn-template-engine/{p-B0lsgVuN.js → p-gFbbuhtl.js} +1 -1
- package/dist/cjs/{SVGVariancesStyleGroup-BqAdPYtL.js → bn-asset_20.cjs.entry.js} +21948 -6938
- package/dist/cjs/bn-grid.cjs.entry.js +6 -9
- package/dist/cjs/bn-image.cjs.entry.js +6 -9
- package/dist/cjs/bn-internationalization.cjs.entry.js +5 -6
- package/dist/cjs/bn-template-engine.cjs.js +2 -2
- package/dist/cjs/bn-template.cjs.entry.js +3 -4
- package/dist/cjs/bn-text.cjs.entry.js +7 -10
- package/dist/cjs/bn-tree.cjs.entry.js +6 -9
- package/dist/cjs/{context-protocol-DRQWrwsA.js → context-protocol-ohYzcb5F.js} +1 -1
- package/dist/cjs/editor-companion.cjs.entry.js +2 -2
- package/dist/cjs/{index-Cjw0q6gP.js → index-CDKG4xmO.js} +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{scaling-BidPsO53.js → scaling-CIAClQR5.js} +3 -3
- package/dist/cjs/{withBodyObserver-C6gLgq_e.js → withBodyObserver-D7BKWN2N.js} +2 -2
- package/dist/cjs/{withHasError-B8gHkfV2.js → withHasError-Cl2gTQzA.js} +106 -2
- package/dist/cjs/{Order-BGx39pS5.js → withStyled-qd94SSb4.js} +648 -6
- package/dist/collection/components/bn-chart-structure/bn-chart-structure.js +20 -4
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +20 -4
- package/dist/collection/components/bn-layout-card/bn-layout-card.js +12 -6
- package/dist/collection/components/bn-layout-page/bn-layout-page.js +12 -7
- package/dist/collection/components/bn-table/bn-table.js +25 -7
- package/dist/collection/components/bn-table/ibcs-table.js +68 -3
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/components/bn-layout-page.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/ibcs-table2.js +1 -1
- package/dist/esm/{SVGVariancesStyleGroup-DOIT-zvI.js → bn-asset_20.entry.js} +22048 -7042
- package/dist/esm/bn-grid.entry.js +4 -7
- package/dist/esm/bn-image.entry.js +4 -7
- package/dist/esm/bn-internationalization.entry.js +4 -5
- package/dist/esm/bn-template-engine.js +3 -3
- package/dist/esm/bn-template.entry.js +2 -3
- package/dist/esm/bn-text.entry.js +5 -8
- package/dist/esm/bn-tree.entry.js +4 -7
- package/dist/esm/{context-protocol-2peaD4y8.js → context-protocol-DdbSplvE.js} +2 -2
- package/dist/esm/editor-companion.entry.js +2 -2
- package/dist/esm/{index-JNHhIe7t.js → index-B_d-jp99.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{scaling-BOcjT8M0.js → scaling-DGKKkuL9.js} +4 -4
- package/dist/esm/{withBodyObserver-DczL5ia8.js → withBodyObserver-AFk2wwHT.js} +2 -2
- package/dist/esm/{withHasError-B3QX2emi.js → withHasError-DW_vMDUp.js} +106 -2
- package/dist/esm/{Order-sRO-lj7X.js → withStyled-BIkqU2w4.js} +616 -1
- package/dist/types/components/bn-chart-structure/bn-chart-structure.d.ts +1 -0
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +1 -0
- package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +8 -2
- package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +8 -3
- package/dist/types/components/bn-table/ibcs-table.d.ts +19 -0
- package/dist/types/components.d.ts +8 -8
- package/package.json +1 -1
- package/dist/bn-template-engine/p-0fabe296.entry.js +0 -1
- package/dist/bn-template-engine/p-355abdf0.entry.js +0 -1
- package/dist/bn-template-engine/p-79KuA4Ox.js +0 -1
- package/dist/bn-template-engine/p-859cc06d.entry.js +0 -1
- package/dist/bn-template-engine/p-8acec99e.entry.js +0 -1
- package/dist/bn-template-engine/p-8f490c45.entry.js +0 -1
- package/dist/bn-template-engine/p-9721a5bb.entry.js +0 -1
- package/dist/bn-template-engine/p-9a564f8f.entry.js +0 -1
- package/dist/bn-template-engine/p-9cee22fa.entry.js +0 -1
- package/dist/bn-template-engine/p-B7p8beYH.js +0 -1
- package/dist/bn-template-engine/p-BDh7GfC5.js +0 -1
- package/dist/bn-template-engine/p-BoMtoHJB.js +0 -1
- package/dist/bn-template-engine/p-Bs8BqBsb.js +0 -1
- package/dist/bn-template-engine/p-CYjZRKdI.js +0 -1
- package/dist/bn-template-engine/p-DG-1MR_T.js +0 -1
- package/dist/bn-template-engine/p-Dnkv5rt8.js +0 -1
- package/dist/bn-template-engine/p-bdd2b243.entry.js +0 -1
- package/dist/bn-template-engine/p-f27995c9.entry.js +0 -1
- package/dist/bn-template-engine/p-f6ecb265.entry.js +0 -1
- package/dist/bn-template-engine/p-sRO-lj7X.js +0 -1
- package/dist/bn-template-engine/p-tzFCK9qn.js +0 -1
- package/dist/cjs/bn-asset_16.cjs.entry.js +0 -9099
- package/dist/cjs/bn-card.cjs.entry.js +0 -36
- package/dist/cjs/bn-chart-time.cjs.entry.js +0 -1031
- package/dist/cjs/bn-layout-card.cjs.entry.js +0 -279
- package/dist/cjs/formatter-4XCS0d2B.js +0 -221
- package/dist/cjs/ibcs-chart-time.cjs.entry.js +0 -4137
- package/dist/cjs/withComponentStatus-_x4LQZ0N.js +0 -109
- package/dist/cjs/withComponentStyle-ClSJfCku.js +0 -128
- package/dist/cjs/withInheritedProps-BH2KNER3.js +0 -157
- package/dist/cjs/withStyled-9tG024gQ.js +0 -522
- package/dist/esm/bn-asset_16.entry.js +0 -9082
- package/dist/esm/bn-card.entry.js +0 -34
- package/dist/esm/bn-chart-time.entry.js +0 -1029
- package/dist/esm/bn-layout-card.entry.js +0 -277
- package/dist/esm/formatter-BDh7GfC5.js +0 -215
- package/dist/esm/ibcs-chart-time.entry.js +0 -4135
- package/dist/esm/withComponentStatus-DodoSXe-.js +0 -107
- package/dist/esm/withComponentStyle-D3VWOsto.js +0 -126
- package/dist/esm/withInheritedProps-BlXDxhHK.js +0 -154
- package/dist/esm/withStyled-CE3_3taP.js +0 -495
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, Host } from "@stencil/core";
|
|
1
|
+
import { forceUpdate, h, Host, writeTask } from "@stencil/core";
|
|
2
2
|
import { isBlankInput, isValidBoolean, isValidDirection, isValidInteger, isValidLevel, isValidMeasureScale, isValidNumber, validateOrderList, validateScenarioList, validateStackConfig, validateVariancesList, } from "../../utils/validate";
|
|
3
3
|
import withDataset from "../../utils/withDataset";
|
|
4
4
|
import withComponentStatus from "../../utils/withComponentStatus";
|
|
@@ -377,7 +377,9 @@ export class Chart {
|
|
|
377
377
|
this.errors.remove("AUTO_scale");
|
|
378
378
|
if (this.appliedScaleFactor !== 1) {
|
|
379
379
|
this._autoScaleGuard = true;
|
|
380
|
-
|
|
380
|
+
writeTask(() => {
|
|
381
|
+
this.appliedScaleFactor = 1;
|
|
382
|
+
});
|
|
381
383
|
}
|
|
382
384
|
this.checkWidthOverflow();
|
|
383
385
|
return;
|
|
@@ -396,10 +398,24 @@ export class Chart {
|
|
|
396
398
|
}
|
|
397
399
|
if (Math.abs(computedFactor - this.appliedScaleFactor) > 0.001) {
|
|
398
400
|
this._autoScaleGuard = true;
|
|
399
|
-
|
|
401
|
+
writeTask(() => {
|
|
402
|
+
this.appliedScaleFactor = computedFactor;
|
|
403
|
+
});
|
|
400
404
|
}
|
|
401
405
|
this.checkWidthOverflow();
|
|
402
406
|
}
|
|
407
|
+
componentDidLoad() {
|
|
408
|
+
// After the first render the DOM is committed and the browser has computed
|
|
409
|
+
// layout. If the initial parentDimensions measurement returned 0 (common
|
|
410
|
+
// inside cards/slots whose width isn't known before first paint), force a
|
|
411
|
+
// re-render so the inner ibcs-chart-structure receives correct dimensions.
|
|
412
|
+
if (this.canvasWidthSegmented <= 0) {
|
|
413
|
+
const { width } = getParentDimensions(this.element);
|
|
414
|
+
if (width > 0) {
|
|
415
|
+
forceUpdate(this);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
403
419
|
/**
|
|
404
420
|
* Emits an error when a custom unit-scaling value causes the chart to exceed its container width.
|
|
405
421
|
* Skipped for auto/unset unit-scaling since auto-fit handles width.
|
|
@@ -751,7 +767,7 @@ export class Chart {
|
|
|
751
767
|
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
752
768
|
}
|
|
753
769
|
const fontStyles = this.getFontStyles();
|
|
754
|
-
return (h(Host, { key: '
|
|
770
|
+
return (h(Host, { key: '9c71155a82140c2020a830247c62d668fb10959e', style: fontStyles }, h("div", { key: '5d9402429fd36aa3b9615f13a5038bc38d825173', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
755
771
|
}
|
|
756
772
|
static get is() { return "bn-chart-structure"; }
|
|
757
773
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, Host } from "@stencil/core";
|
|
1
|
+
import { forceUpdate, h, Host, writeTask } from "@stencil/core";
|
|
2
2
|
import { isBlankInput, isValidAxisLabelsMode, isValidBoolean, isValidDateFormat, isValidDirection, isValidInteger, isValidLevel, isValidMeasureScale, isValidNumber, validateOrderList, validateScenarioList, validateStackConfig, validateVariancesList, } from "../../utils/validate";
|
|
3
3
|
import withDataset from "../../utils/withDataset";
|
|
4
4
|
import withComponentStatus from "../../utils/withComponentStatus";
|
|
@@ -553,7 +553,9 @@ export class Chart {
|
|
|
553
553
|
this.errors.remove("AUTO_scale");
|
|
554
554
|
if (this.appliedScaleFactor !== 1) {
|
|
555
555
|
this._autoScaleGuard = true;
|
|
556
|
-
|
|
556
|
+
writeTask(() => {
|
|
557
|
+
this.appliedScaleFactor = 1;
|
|
558
|
+
});
|
|
557
559
|
}
|
|
558
560
|
return;
|
|
559
561
|
}
|
|
@@ -571,7 +573,21 @@ export class Chart {
|
|
|
571
573
|
}
|
|
572
574
|
if (Math.abs(computedFactor - this.appliedScaleFactor) > 0.001) {
|
|
573
575
|
this._autoScaleGuard = true;
|
|
574
|
-
|
|
576
|
+
writeTask(() => {
|
|
577
|
+
this.appliedScaleFactor = computedFactor;
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
componentDidLoad() {
|
|
582
|
+
// After the first render the DOM is committed and the browser has computed
|
|
583
|
+
// layout. If the initial parentDimensions measurement returned 0 (common
|
|
584
|
+
// inside cards/slots whose width isn't known before first paint), force a
|
|
585
|
+
// re-render so the inner ibcs-chart-time receives correct dimensions.
|
|
586
|
+
if (this.canvasWidthSegmented <= 0) {
|
|
587
|
+
const { width } = getParentDimensions(this.element);
|
|
588
|
+
if (width > 0) {
|
|
589
|
+
forceUpdate(this);
|
|
590
|
+
}
|
|
575
591
|
}
|
|
576
592
|
}
|
|
577
593
|
prepareDimension() {
|
|
@@ -967,7 +983,7 @@ export class Chart {
|
|
|
967
983
|
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
968
984
|
}
|
|
969
985
|
const fontStyles = this.getFontStyles();
|
|
970
|
-
return (h(Host, { key: '
|
|
986
|
+
return (h(Host, { key: '317b1048224d8b5ede5dc4868d2d927c9c7cfee9', style: fontStyles }, h("div", { key: '3168861fc4440ea67103140c33c4aa84ac0bf245', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
971
987
|
}
|
|
972
988
|
static get is() { return "bn-chart-time"; }
|
|
973
989
|
static get encapsulation() { return "shadow"; }
|
|
@@ -102,10 +102,16 @@ export class LayoutCard {
|
|
|
102
102
|
this.cardGridGap = "0";
|
|
103
103
|
/**
|
|
104
104
|
* When `true`, the card shrinks to fit its content (`fit-content`)
|
|
105
|
-
* for both width and height. When `false
|
|
106
|
-
* fill its parent (`100%`).
|
|
105
|
+
* for both width and height. When `false` (default), the card stretches
|
|
106
|
+
* to fill its parent (`100%`).
|
|
107
|
+
* <br /><br />
|
|
108
|
+
* Use `false` (default) when the card contains components with
|
|
109
|
+
* auto-scaling (e.g. `unit-scaling="auto"`), because auto-scaling
|
|
110
|
+
* needs a fixed parent width to calculate dimensions. `fit-content`
|
|
111
|
+
* creates a circular dependency where the card width depends on the
|
|
112
|
+
* child content but the child needs the card width to render.
|
|
107
113
|
*/
|
|
108
|
-
this.cardFitToContent =
|
|
114
|
+
this.cardFitToContent = false;
|
|
109
115
|
/**
|
|
110
116
|
* Whether to display a visible border around the card.
|
|
111
117
|
*/
|
|
@@ -264,7 +270,7 @@ export class LayoutCard {
|
|
|
264
270
|
const arrOfSlots = this.extractSlotNames(style["grid-template-areas"]);
|
|
265
271
|
return (
|
|
266
272
|
// @ts-ignore
|
|
267
|
-
h("bn-card", { key: '
|
|
273
|
+
h("bn-card", { key: 'a27b2ea13406067ff661c293af1ef1d89cfdc4f1', styles: this.styles, class: this.setCardClass() }, h("div", { key: 'a4eb313d41e4b3e267057406fd6d469129e90003', class: "cardtitle" }, h("bn-title", { key: '999442b2f789bccbb00c7dd8e75e61c3a438596d', namespace: this.titleNamespace, "business-unit": this.titleBusinessUnit, scenarios: (_a = this.resolveInherited("titleScenarios", this.titleScenarios)) !== null && _a !== void 0 ? _a : this.titleScenarios, variances: (_b = this.resolveInherited("titleVariances", this.titleVariances)) !== null && _b !== void 0 ? _b : this.titleVariances, order: (_c = this.resolveInherited("titleOrder", this.titleOrder)) !== null && _c !== void 0 ? _c : this.titleOrder, "order-direction": (_d = this.resolveInherited("titleOrderDirection", this.titleOrderDirection)) !== null && _d !== void 0 ? _d : this.titleOrderDirection, measures: this.titleMeasures, "date-start": this.titleDateStart, "date-end": this.titleDateEnd, "date-format": this.titleDateFormat, "date-link": this.titleDateLink }), this.titleImage != null && this.titleImage !== "" ? (h("img", { class: "image", src: this.prepareTitleImage(this.titleImage) })) : ("")), h("bn-body", { key: '1cf38b212c60db9e4110f8340cda992d67fec350' }, h("div", { key: 'a1ac4631dfdeee4b5b87f09c2d047c86b886144a', style: style }, this.getSlots(arrOfSlots))), h("bn-footer", { key: '4397cc9f836c0271d4469a90a2f5168c7fc3cfea', text: this.footerText, "page-number": 0, "display-page-number": "false" })));
|
|
268
274
|
}
|
|
269
275
|
static get is() { return "bn-layout-card"; }
|
|
270
276
|
static get encapsulation() { return "shadow"; }
|
|
@@ -641,13 +647,13 @@ export class LayoutCard {
|
|
|
641
647
|
"optional": false,
|
|
642
648
|
"docs": {
|
|
643
649
|
"tags": [],
|
|
644
|
-
"text": "When `true`, the card shrinks to fit its content (`fit-content`)\nfor both width and height. When `false
|
|
650
|
+
"text": "When `true`, the card shrinks to fit its content (`fit-content`)\nfor both width and height. When `false` (default), the card stretches\nto fill its parent (`100%`).\n<br /><br />\nUse `false` (default) when the card contains components with\nauto-scaling (e.g. `unit-scaling=\"auto\"`), because auto-scaling\nneeds a fixed parent width to calculate dimensions. `fit-content`\ncreates a circular dependency where the card width depends on the\nchild content but the child needs the card width to render."
|
|
645
651
|
},
|
|
646
652
|
"getter": false,
|
|
647
653
|
"setter": false,
|
|
648
654
|
"reflect": false,
|
|
649
655
|
"attribute": "card-fit-to-content",
|
|
650
|
-
"defaultValue": "
|
|
656
|
+
"defaultValue": "false"
|
|
651
657
|
},
|
|
652
658
|
"cardShowBorder": {
|
|
653
659
|
"type": "boolean",
|
|
@@ -101,11 +101,16 @@ export class LayoutPage {
|
|
|
101
101
|
this.pageGridGap = "0";
|
|
102
102
|
/**
|
|
103
103
|
* When `true`, the page body height shrinks to fit its content
|
|
104
|
-
* (`fit-content`). When `false
|
|
105
|
-
* full page height (`100%`). Width is always `100%`
|
|
106
|
-
* of this setting.
|
|
104
|
+
* (`fit-content`). When `false` (default), the body stretches to
|
|
105
|
+
* fill the full page height (`100%`). Width is always `100%`
|
|
106
|
+
* regardless of this setting.
|
|
107
|
+
* <br /><br />
|
|
108
|
+
* Use `false` (default) when the page contains components with
|
|
109
|
+
* auto-scaling (e.g. `unit-scaling="auto"` or `scale="auto"`),
|
|
110
|
+
* because auto-scaling needs a fixed parent height to calculate
|
|
111
|
+
* dimensions.
|
|
107
112
|
*/
|
|
108
|
-
this.pageFitToContent =
|
|
113
|
+
this.pageFitToContent = false;
|
|
109
114
|
this.templateMap = new Map([
|
|
110
115
|
["split-vertical", '"a b"'],
|
|
111
116
|
["split-horizontal", '"a" "b"'],
|
|
@@ -230,7 +235,7 @@ export class LayoutPage {
|
|
|
230
235
|
const arrOfSlots = this.extractSlotNames(style["grid-template-areas"]);
|
|
231
236
|
return (
|
|
232
237
|
// @ts-ignore
|
|
233
|
-
h("bn-page", { key: '
|
|
238
|
+
h("bn-page", { key: '39d3769df89423fae025d924e9a69ebb3742461b', styles: this.styles, format: this.pageFormat, orientation: this.pageOrientation }, h("bn-message", { key: '0a2a28f6af09d6f58799f66c75a17c02464d57b1', text: this.messageText, image: this.messageImage }), h("bn-title", { key: '63e3dedb613fc8d4b11416321d148a22cf96af84', namespace: this.titleNamespace, "business-unit": this.titleBusinessUnit, scenarios: this.titleScenarios, variances: this.titleVariances, order: this.titleOrder, "order-direction": this.titleOrderDirection, measures: this.titleMeasures, "date-start": this.titleDateStart, "date-end": this.titleDateEnd, "date-format": this.titleDateFormat, "date-link": this.titleDateLink }), h("bn-body", { key: '1946d3d11bb663b3ba5faf73bfe5d1b2bd4329ac' }, h("div", { key: '7a97d5481163d44f582c8c8ec352954f4e75c1bb', style: style }, this.getSlots(arrOfSlots))), h("bn-footer", { key: '863e721cfdb44ab5860687f5fb4dc4705f83d81b', text: this.footerText, "page-number": this.pageNumber, "display-page-number": this.footerDisplayPageNumber })));
|
|
234
239
|
}
|
|
235
240
|
static get is() { return "bn-layout-page"; }
|
|
236
241
|
static get encapsulation() { return "shadow"; }
|
|
@@ -703,13 +708,13 @@ export class LayoutPage {
|
|
|
703
708
|
"optional": false,
|
|
704
709
|
"docs": {
|
|
705
710
|
"tags": [],
|
|
706
|
-
"text": "When `true`, the page body height shrinks to fit its content\n(`fit-content`). When `false
|
|
711
|
+
"text": "When `true`, the page body height shrinks to fit its content\n(`fit-content`). When `false` (default), the body stretches to\nfill the full page height (`100%`). Width is always `100%`\nregardless of this setting.\n<br /><br />\nUse `false` (default) when the page contains components with\nauto-scaling (e.g. `unit-scaling=\"auto\"` or `scale=\"auto\"`),\nbecause auto-scaling needs a fixed parent height to calculate\ndimensions."
|
|
707
712
|
},
|
|
708
713
|
"getter": false,
|
|
709
714
|
"setter": false,
|
|
710
715
|
"reflect": false,
|
|
711
716
|
"attribute": "page-fit-to-content",
|
|
712
|
-
"defaultValue": "
|
|
717
|
+
"defaultValue": "false"
|
|
713
718
|
}
|
|
714
719
|
};
|
|
715
720
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h, Host } from "@stencil/core";
|
|
1
|
+
import { h, Host, writeTask } from "@stencil/core";
|
|
2
2
|
import { isBlankInput, isTableBarColumnWidth, isTableCategoryWidth, isValidBoolean, isValidDataFormat, isValidDirection, isValidInteger, isValidMeasureScale, isValidMeasureType, isValidNumber, isValidTableType, validateColumnThereOfJsonStr, validateOrderList, validatePartOfJsonStr, validateScenarioList, validateThereOfJsonStr, validateVariancesList, } from "../../utils/validate";
|
|
3
3
|
import withDataset from "../../utils/withDataset";
|
|
4
4
|
import withComponentStatus from "../../utils/withComponentStatus";
|
|
@@ -344,7 +344,8 @@ export class Table {
|
|
|
344
344
|
}
|
|
345
345
|
validateUnitScaling(newValue) {
|
|
346
346
|
const errId = "ERR_unitScaling";
|
|
347
|
-
|
|
347
|
+
const isAuto = (newValue === null || newValue === void 0 ? void 0 : newValue.toString().trim().toLowerCase()) === "auto";
|
|
348
|
+
if (!isAuto && !isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
348
349
|
this.errors.addOrReplace({
|
|
349
350
|
id: errId,
|
|
350
351
|
type: "warning",
|
|
@@ -357,7 +358,8 @@ export class Table {
|
|
|
357
358
|
}
|
|
358
359
|
validatePercentageScaling(newValue) {
|
|
359
360
|
const errId = "ERR_percentageScaling";
|
|
360
|
-
|
|
361
|
+
const isAuto = (newValue === null || newValue === void 0 ? void 0 : newValue.toString().trim().toLowerCase()) === "auto";
|
|
362
|
+
if (!isAuto && !isValidNumber(newValue) && !this.pixelPerUnitGroupMap.has(newValue)) {
|
|
361
363
|
this.errors.addOrReplace({
|
|
362
364
|
id: errId,
|
|
363
365
|
type: "warning",
|
|
@@ -650,7 +652,11 @@ export class Table {
|
|
|
650
652
|
if (this.appliedScaleFactor !== 1) {
|
|
651
653
|
host.style.setProperty("--bn-font-size", `${baseFontSize}px`);
|
|
652
654
|
this._autoScaleGuard = true;
|
|
653
|
-
|
|
655
|
+
// Defer state change to avoid Stencil "changed during rendering" warning.
|
|
656
|
+
// The CSS var is already applied, so the visual update is immediate.
|
|
657
|
+
writeTask(() => {
|
|
658
|
+
this.appliedScaleFactor = 1;
|
|
659
|
+
});
|
|
654
660
|
}
|
|
655
661
|
return;
|
|
656
662
|
}
|
|
@@ -669,10 +675,14 @@ export class Table {
|
|
|
669
675
|
else {
|
|
670
676
|
this.errors.remove("AUTO_scale");
|
|
671
677
|
}
|
|
672
|
-
//
|
|
678
|
+
// Defer state update to avoid Stencil "changed during rendering" warning.
|
|
679
|
+
// The CSS var is already applied, so the visual update is immediate;
|
|
680
|
+
// the deferred state change triggers a re-render for SVG bar charts.
|
|
673
681
|
if (Math.abs(computedFactor - this.appliedScaleFactor) > 0.001) {
|
|
674
682
|
this._autoScaleGuard = true;
|
|
675
|
-
|
|
683
|
+
writeTask(() => {
|
|
684
|
+
this.appliedScaleFactor = computedFactor;
|
|
685
|
+
});
|
|
676
686
|
}
|
|
677
687
|
}
|
|
678
688
|
prepareDataFormat() {
|
|
@@ -879,15 +889,23 @@ export class Table {
|
|
|
879
889
|
return this.barColumns.split(",").map((col) => col.trim());
|
|
880
890
|
}
|
|
881
891
|
prepareUnitScaling() {
|
|
892
|
+
var _a;
|
|
882
893
|
if (this.pixelPerUnitGroupMap.has(this.unitScaling)) {
|
|
883
894
|
return this.pixelPerUnitGroupMap.get(this.unitScaling);
|
|
884
895
|
}
|
|
896
|
+
if (((_a = this.unitScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
|
|
897
|
+
return 0;
|
|
898
|
+
}
|
|
885
899
|
return Number(this.unitScaling);
|
|
886
900
|
}
|
|
887
901
|
preparePercentageScaling() {
|
|
902
|
+
var _a;
|
|
888
903
|
if (this.pixelPerUnitGroupMap.has(this.percentageScaling)) {
|
|
889
904
|
return this.pixelPerUnitGroupMap.get(this.percentageScaling);
|
|
890
905
|
}
|
|
906
|
+
if (((_a = this.percentageScaling) === null || _a === void 0 ? void 0 : _a.toString().trim().toLowerCase()) === "auto") {
|
|
907
|
+
return 0;
|
|
908
|
+
}
|
|
891
909
|
return Number(this.percentageScaling);
|
|
892
910
|
}
|
|
893
911
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -951,7 +969,7 @@ export class Table {
|
|
|
951
969
|
render() {
|
|
952
970
|
const fontStyles = this.getFontStyles();
|
|
953
971
|
const effectiveFactor = this.getEffectiveScaleFactor();
|
|
954
|
-
return (h(Host, { key: '
|
|
972
|
+
return (h(Host, { key: '95a43b9087d7d5d0be75c361795ef0a5a1cb30fe', style: fontStyles }, h("div", { key: 'a905e16727e619222b478fcc4dbe0c903306c420' }, h("ibcs-table", { key: '454d019b157c730ec0b3f7cfcf16ae0e56c4a255', data: this.data, "table-title": this.prepareTableTitle(), scenarios: this.prepareScenarios(), "scenarios-data-format": this.prepareDataFormat(), grouped: this.prepareGrouped(), limit: this.prepareLimit(), showGroupTitle: this.prepareShowGroupTitle(), thereof: this.prepareThereOf(), partof: this.preparePartOf(), order: this.prepareOrder(), categorythereof: this.prepareColumnThereOf(), type: this.prepareTableType(), "category-width": this.prepareCategoryWidth(), dataFormatDigits: this.prepareDataFormatDigits(), i18n: this.prepareI18n(), "i18n-mode": this.prepareI18nMode(), "measure-scale": this.prepareMeasureScale(), "measure-type": this.prepareMeasureType(), "measure-unit": this.prepareMeasureUnit(), showMeasureScale: this.prepareShowMeasureScale(), filter: this.prepareFilter(), barColumns: this.prepareBarColumns(), barColumnMaxWidth: this.prepareBarColumnWidth(), unitScaling: this.prepareUnitScaling(), percentageScaling: this.preparePercentageScaling(), scaleFactor: effectiveFactor }))));
|
|
955
973
|
}
|
|
956
974
|
static get is() { return "bn-table"; }
|
|
957
975
|
static get encapsulation() { return "shadow"; }
|
|
@@ -72,9 +72,9 @@ export class IbcsTable {
|
|
|
72
72
|
const config = this.prepareConfig();
|
|
73
73
|
const data = this.prepareData();
|
|
74
74
|
this.componentDataFormatDigits = new DataFormatDigitsAdapter().adapt(this.dataFormatDigits);
|
|
75
|
-
this.barChartStyles = this.prepareBarChartStyles();
|
|
76
75
|
this.table = new Table(new IBCSRuleSet(), data, config);
|
|
77
76
|
this.table.setI18n(this.i18n);
|
|
77
|
+
this.barChartStyles = this.prepareBarChartStyles();
|
|
78
78
|
}
|
|
79
79
|
prepareConfig() {
|
|
80
80
|
const config = new TableComponentConfigAdapter(new TableDrillGroupAdapter(), new StringAdapter(), new OrderAdapter(new StringAdapter()), this.data).adapt({
|
|
@@ -166,12 +166,77 @@ export class IbcsTable {
|
|
|
166
166
|
fontColor: ((_z = $["global"]) === null || _z === void 0 ? void 0 : _z["fontColor"]) || "#000000",
|
|
167
167
|
fontSize: (((_0 = $["global"]) === null || _0 === void 0 ? void 0 : _0["fontSizePx"]) || 13.3333) * 0.85 * this.scaleFactor,
|
|
168
168
|
fontFamily: ((_1 = $["global"]) === null || _1 === void 0 ? void 0 : _1["fontFamily"]) || "'Noto Sans', sans-serif",
|
|
169
|
-
unitScaling: this.unitScaling,
|
|
170
|
-
percentageScaling: this.percentageScaling,
|
|
169
|
+
unitScaling: this.unitScaling > 0 ? this.unitScaling : this.autoUnitScaling(),
|
|
170
|
+
percentageScaling: this.percentageScaling > 0 ? this.percentageScaling : this.autoPercentageScaling(),
|
|
171
171
|
scaleFactor: this.scaleFactor,
|
|
172
172
|
};
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Auto-calculate unitScaling so the largest absolute variance bar
|
|
177
|
+
* fills ~80% of the bar column width.
|
|
178
|
+
*/
|
|
179
|
+
autoUnitScaling() {
|
|
180
|
+
const fs = this.componentStyle(($) => { var _a; return (((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333) * 0.85 * this.scaleFactor; });
|
|
181
|
+
const maxBarWidthPx = this.barColumnMaxWidth * fs;
|
|
182
|
+
const targetWidth = maxBarWidthPx * 0.8;
|
|
183
|
+
const absMax = this.getMaxAbsValue();
|
|
184
|
+
if (absMax <= 0 || fs <= 0) {
|
|
185
|
+
return 0.01;
|
|
186
|
+
}
|
|
187
|
+
return targetWidth / (absMax * fs);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Auto-calculate percentageScaling so the largest relative variance pin
|
|
191
|
+
* fills ~80% of the pin area.
|
|
192
|
+
*/
|
|
193
|
+
autoPercentageScaling() {
|
|
194
|
+
const fs = this.componentStyle(($) => { var _a; return (((_a = $["global"]) === null || _a === void 0 ? void 0 : _a["fontSizePx"]) || 13.3333) * 0.85 * this.scaleFactor; });
|
|
195
|
+
const maxPinLength = Math.round(this.barColumnMaxWidth * 0.67 * fs);
|
|
196
|
+
const targetLength = maxPinLength * 0.8;
|
|
197
|
+
const maxPct = this.getMaxRelativeValue();
|
|
198
|
+
if (maxPct <= 0 || fs <= 0) {
|
|
199
|
+
return 0.5;
|
|
200
|
+
}
|
|
201
|
+
return targetLength / (maxPct * fs);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Find the maximum absolute value across all absolute variance columns (d_*) in the table body.
|
|
205
|
+
*/
|
|
206
|
+
getMaxAbsValue() {
|
|
207
|
+
if (!this.table)
|
|
208
|
+
return 0;
|
|
209
|
+
let max = 0;
|
|
210
|
+
for (const row of this.table.getBody()) {
|
|
211
|
+
if (row.type === TableRowType.SUM)
|
|
212
|
+
continue;
|
|
213
|
+
for (const cell of row.getCells()) {
|
|
214
|
+
if (cell.isBarChart && cell.columnStats && !cell.key.startsWith("dr")) {
|
|
215
|
+
max = Math.max(max, cell.columnStats.absMax);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return max;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Find the maximum percentage value across all relative variance columns (dr_*) in the table body.
|
|
223
|
+
* Values are stored as decimals (e.g. 0.2 = 20%), returned as percentage (20).
|
|
224
|
+
*/
|
|
225
|
+
getMaxRelativeValue() {
|
|
226
|
+
if (!this.table)
|
|
227
|
+
return 0;
|
|
228
|
+
let max = 0;
|
|
229
|
+
for (const row of this.table.getBody()) {
|
|
230
|
+
if (row.type === TableRowType.SUM)
|
|
231
|
+
continue;
|
|
232
|
+
for (const cell of row.getCells()) {
|
|
233
|
+
if (cell.isBarChart && cell.columnStats && cell.key.startsWith("dr")) {
|
|
234
|
+
max = Math.max(max, cell.columnStats.absMax * 100);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return max;
|
|
239
|
+
}
|
|
175
240
|
static get is() { return "ibcs-table"; }
|
|
176
241
|
static get encapsulation() { return "shadow"; }
|
|
177
242
|
static get originalStyleUrls() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as t,HTMLElement as e,h as i,Host as s,transformTag as a}from"@stencil/core/internal/client";import{v as r,a as n,h as o,j as l,b as c,c as h,k as d,l as p,m as u,n as v,i as m}from"./validate.js";import{w as g,g as f,p as y}from"./scaling.js";import{w as b,a as S}from"./withHasError.js";import{w}from"./withTranslation.js";import{a as O}from"./context-protocol.js";import{w as k}from"./withStyled.js";import{w as _}from"./withComponentStyle.js";import{i as x,w as R}from"./withInheritedProps.js";import{A,b as T,O as E,g as N,h as U,i as M}from"./Order.js";import{d as C}from"./ibcs-chart-structure2.js";const L=t(class extends e{validateScenario(t){const e="ERR_scenarios";if(x(t))return void this.errors.remove(e);const i=r(t);i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateVariances(t){const e="ERR_variances";if(x(t))return void this.errors.remove(e);const i=n(t);i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateUnitScaling(t){const e="ERR_unitScaling";o(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."})}validatePercentageScaling(t){const e="ERR_percentageScaling";o(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."})}validateLevel(t){const e="ERR_level";l(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const e="ERR_order";if(x(t))return void this.errors.remove(e);const i=c(t);i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(i)+"' are not supported."}):this.errors.remove(e)}validateOrderDirection(t){const e="ERR_orderDirection";x(t)||h(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateLimit(t){const e="ERR_limit";d(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"limit: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateShowCategories(t){const e="ERR_showCategories";p(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateMeasureScale(t){const e="ERR_measureScale";u(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateShowMeasureScale(t){const e="ERR_grouped";p(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateStack(t){const e="ERR_stack",i=v(t);i.length>0?this.errors.addOrReplace({id:e,type:"warning",message:i.join("; ")}):this.errors.remove(e)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const e=Number(t);isNaN(e)||e<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.data=[],this.datasetMeta=null,this.appliedScaleFactor=1,this.chartTitle="",this.filter="",this.limit=0,this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.measureUnit="",this.stack="",this.scenariosArray=[""],this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,k(this),b(this),g(this,((t,e)=>{this.data=e||[]}),((t,e)=>{this.datasetMeta=e})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=S(this),this.componentStyle=_(this),this.t=w(this).t,this.resolveInherited=R(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){var t,e;const{mode:i}=y(this.scale);if("auto"!==i&&"empty"!==i)return this._autoScaleGuard=!1,void this.checkWidthOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkWidthOverflow();const s=this.element,{height:a}=f(s);if(a<=0)return void this.checkWidthOverflow();const r=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}));s.style.setProperty("--bn-font-size",r+"px");const n=null===(t=s.shadowRoot)||void 0===t?void 0:t.querySelector(".container"),o=null!==(e=null==n?void 0:n.scrollHeight)&&void 0!==e?e:s.scrollHeight;if(o<=a+1)return this.errors.remove("AUTO_scale"),1!==this.appliedScaleFactor&&(this._autoScaleGuard=!0,this.appliedScaleFactor=1),void this.checkWidthOverflow();const l=(a-1)/o;s.style.setProperty("--bn-font-size",r*l+"px"),"empty"===i?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),Math.abs(l-this.appliedScaleFactor)>.001&&(this._autoScaleGuard=!0,this.appliedScaleFactor=l),this.checkWidthOverflow()}checkWidthOverflow(){var t;const e="WARN_overflow",i=((null!==(t=this.unitScaling)&&void 0!==t?t:"")+"").trim().toLowerCase();if(""===i||"auto"===i)return void this.errors.remove(e);const s=f(this.element);s.width>0&&this.element.scrollWidth>s.width+1?this.errors.addOrReplace({id:e,type:"error",message:`Chart exceeds available width (${this.element.scrollWidth}px > ${Math.round(s.width)}px). Reduce unit-scaling or set to "auto".`}):this.errors.remove(e)}prepareDimension(){const t=f(this.element);return this.canvasWidthSegmented=t.width/this.scenariosArray.length,{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,e,i,s;const a=this.resolveInherited("scenarios",this.scenarios);if(void 0!==a)return this.errors.remove("AUTO_scenarios"),a.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return m(this.scenarios)||r?(null===(i=null===(e=this.datasetMeta)||void 0===e?void 0:e.availableScenarios)||void 0===i?void 0:i.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=this.scenarios)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareVariances(){var t;const e=this.resolveInherited("variances",this.variances);return void 0!==e?e.split(",").map((t=>t.trim())):m(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideCategories(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=O,e=new Map([].map((t=>[t,this.t(".".concat(t))]))),i=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...i.entries(),...e.entries()])}preparePixelPerUnit(){var t;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(t=this.unitScaling)||void 0===t?void 0:(""+t).trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const e=Number(this.unitScaling);return!isNaN(e)&&e>0?(this.errors.remove("AUTO_unitScaling"),e):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){return this.pixelPerUnitGroupMap.has(this.percentageScaling)?this.pixelPerUnitGroupMap.get(this.percentageScaling):100*Number(this.percentageScaling)}prepareLevel(){var t,e,i;const s="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return m(this.level)||s?(null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel)?(s?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:"level: not set, auto-detected: "+this.datasetMeta.suggestedLevel}),A[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),A[null===(i=this.level)||void 0===i?void 0:i.toUpperCase()])}prepareOrder(){var t;const e=this.resolveInherited("order",this.order),i=this.resolveInherited("orderDirection",this.orderDirection),s=null!=e?e:this.order,a=null!=i?i:this.orderDirection,r="auto"===(null==s?void 0:s.trim().toLowerCase());let n;return m(s)||r?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),n=this.datasetMeta.suggestedOrder):n=s:(this.errors.remove("AUTO_order"),n=s),{hierarchy:null==n?void 0:n.split(",").map((t=>E[null==t?void 0:t.toUpperCase()])),direction:T[null==a?void 0:a.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{const i=e.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:e["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:e["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:e["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:e["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:e["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:e["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:e["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:e["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:e["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:e["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:e["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:e["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:e["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:e["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:e["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${i}px ${e.global.fontFamily}`,size:i,color:e.global.fontColor,background:e.global.fontBackgroundColor,leading:1.8},axisStyles:e["bn-chart-structure"].axisStyles,barStyles:e["bn-chart-structure"].barStyles,varianceStyles:e["bn-chart-structure"].varianceStyles,padding:e["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareStackConfig(){if(m(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),e=t.by,i="WARN_stack_dimensions_scenarios";if(e===N.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:i,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(i)}else this.errors.remove(i);return{by:e,mode:t.mode||M.ABSOLUTE,order:t.order||U.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return m(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,e){const s=this.getEffectiveScaleFactor(),a=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=this.prepareScenarios(),l=(null==n?void 0:n.by)===N.DIMENSIONS?o.slice(0,1):o;return i("ibcs-chart-structure",{data:this.data,chartTitle:this.prepareChartTitle(e),scenarios:l,variances:[t],hideCategories:this.prepareHideCategories(e),pixelPerUnit:a>0?a*s:0,pixelPerPercentage:r>0?r*s: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(e),stackConfig:n,parentDimensions:this.prepareDimension()})}getEffectiveScaleFactor(){const{mode:t,factor:e}=y(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var i,s,a,r;const n=(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=e.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=e.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=e.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const e=this.prepareVariances();e.length>0&&(t=[...t,...e]);const a=this.getFontStyles();return i(s,{key:"528b1d9607de916cb2ed06a2f2bac2acdc85da30",style:a},i("div",{key:"e5454756d03fc081e843dee241c52695212da4e3",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}static get style(){return':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}'}},[1,"bn-chart-structure",{chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],showCategories:[1,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[1,"show-measure-scale"],measureUnit:[1,"measure-unit"],stack:[1],scale:[1],data:[32],datasetMeta:[32],appliedScaleFactor:[32]},void 0,{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}]),D=L,P=function(){"undefined"!=typeof customElements&&["bn-chart-structure","ibcs-chart-structure"].forEach((t=>{switch(t){case"bn-chart-structure":customElements.get(a(t))||customElements.define(a(t),L);break;case"ibcs-chart-structure":customElements.get(a(t))||C()}}))};export{D as BnChartStructure,P as defineCustomElement}
|
|
1
|
+
import{proxyCustomElement as t,HTMLElement as i,writeTask as e,forceUpdate as s,h as a,Host as r,transformTag as n}from"@stencil/core/internal/client";import{v as o,a as l,h as c,j as h,b as d,c as p,k as u,l as v,m,n as g,i as f}from"./validate.js";import{w as y,g as b,p as S}from"./scaling.js";import{w,a as O}from"./withHasError.js";import{w as k}from"./withTranslation.js";import{a as _}from"./context-protocol.js";import{w as x}from"./withStyled.js";import{w as R}from"./withComponentStyle.js";import{i as A,w as T}from"./withInheritedProps.js";import{A as E,b as N,O as U,g as M,h as L,i as C}from"./Order.js";import{d as D}from"./ibcs-chart-structure2.js";const P=t(class extends i{validateScenario(t){const i="ERR_scenarios";if(A(t))return void this.errors.remove(i);const e=o(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateVariances(t){const i="ERR_variances";if(A(t))return void this.errors.remove(i);const e=l(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateUnitScaling(t){const i="ERR_unitScaling";c(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+t+"' are not supported."})}validatePercentageScaling(t){const i="ERR_percentageScaling";c(t)||this.pixelPerUnitGroupMap.has(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+t+"' are not supported."})}validateLevel(t){const i="ERR_level";h(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+t+"' are not supported."})}validateOrderList(t){const i="ERR_order";if(A(t))return void this.errors.remove(i);const e=d(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(t){const i="ERR_orderDirection";A(t)||p(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateLimit(t){const i="ERR_limit";u(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateShowCategories(t){const i="ERR_showCategories";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateMeasureScale(t){const i="ERR_measureScale";m(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==t?void 0:""+t)+"' is not supported."})}validateShowMeasureScale(t){const i="ERR_grouped";v(t)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==t?void 0:""+t)+"' are not supported."})}validateStack(t){const i="ERR_stack",e=g(t);e.length>0?this.errors.addOrReplace({id:i,type:"warning",message:e.join("; ")}):this.errors.remove(i)}validateScaling(t){if(null==t||""===t||"none"===t||"auto"===t)return void this.errors.remove("ERR_scale");const i=Number(t);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${t}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.data=[],this.datasetMeta=null,this.appliedScaleFactor=1,this.chartTitle="",this.filter="",this.limit=0,this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.measureUnit="",this.stack="",this.scenariosArray=[""],this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,x(this),w(this),y(this,((t,i)=>{this.data=i||[]}),((t,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=O(this),this.componentStyle=R(this),this.t=k(this).t,this.resolveInherited=T(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){var t,i;const{mode:s}=S(this.scale);if("auto"!==s&&"empty"!==s)return this._autoScaleGuard=!1,void this.checkWidthOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkWidthOverflow();const a=this.element,{height:r}=b(a);if(r<=0)return void this.checkWidthOverflow();const n=this.componentStyle((t=>{var i;return(null===(i=t.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));a.style.setProperty("--bn-font-size",n+"px");const o=null===(t=a.shadowRoot)||void 0===t?void 0:t.querySelector(".container"),l=null!==(i=null==o?void 0:o.scrollHeight)&&void 0!==i?i:a.scrollHeight;if(l<=r+1)return this.errors.remove("AUTO_scale"),1!==this.appliedScaleFactor&&(this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=1}))),void this.checkWidthOverflow();const c=(r-1)/l;a.style.setProperty("--bn-font-size",n*c+"px"),"empty"===s?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+c.toFixed(3)}):this.errors.remove("AUTO_scale"),Math.abs(c-this.appliedScaleFactor)>.001&&(this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=c}))),this.checkWidthOverflow()}componentDidLoad(){if(this.canvasWidthSegmented<=0){const{width:t}=b(this.element);t>0&&s(this)}}checkWidthOverflow(){var t;const i="WARN_overflow",e=((null!==(t=this.unitScaling)&&void 0!==t?t:"")+"").trim().toLowerCase();if(""===e||"auto"===e)return void this.errors.remove(i);const s=b(this.element);s.width>0&&this.element.scrollWidth>s.width+1?this.errors.addOrReplace({id:i,type:"error",message:`Chart exceeds available width (${this.element.scrollWidth}px > ${Math.round(s.width)}px). Reduce unit-scaling or set to "auto".`}):this.errors.remove(i)}prepareDimension(){const t=b(this.element);return this.canvasWidthSegmented=t.width/this.scenariosArray.length,{width:this.canvasWidthSegmented,height:t.height}}prepareScenarios(){var t,i,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(void 0!==a)return this.errors.remove("AUTO_scenarios"),a.split(",").map((t=>t.trim()));const r="auto"===(null===(t=this.scenarios)||void 0===t?void 0:t.trim().toLowerCase());return f(this.scenarios)||r?(null===(e=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===e?void 0:e.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=this.scenarios)||void 0===s?void 0:s.split(",").map((t=>t.trim())))}prepareVariances(){var t;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((t=>t.trim())):f(this.variances)?[]:null===(t=this.variances)||void 0===t?void 0:t.split(",").map((t=>t.trim()))}prepareHideCategories(t){return t>=1||"true"!==this.showCategories}prepareI18n(){const t=_,i=new Map([].map((t=>[t,this.t(".".concat(t))]))),e=new Map(t.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...i.entries()])}preparePixelPerUnit(){var t;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(t=this.unitScaling)||void 0===t?void 0:(""+t).trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const i=Number(this.unitScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_unitScaling"),i):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){return this.pixelPerUnitGroupMap.has(this.percentageScaling)?this.pixelPerUnitGroupMap.get(this.percentageScaling):100*Number(this.percentageScaling)}prepareLevel(){var t,i,e;const s="auto"===(null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase());return f(this.level)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(s?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:"level: not set, auto-detected: "+this.datasetMeta.suggestedLevel}),E[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),E[null===(e=this.level)||void 0===e?void 0:e.toUpperCase()])}prepareOrder(){var t;const i=this.resolveInherited("order",this.order),e=this.resolveInherited("orderDirection",this.orderDirection),s=null!=i?i:this.order,a=null!=e?e:this.orderDirection,r="auto"===(null==s?void 0:s.trim().toLowerCase());let n;return f(s)||r?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),n=this.datasetMeta.suggestedOrder):n=s:(this.errors.remove("AUTO_order"),n=s),{hierarchy:null==n?void 0:n.split(",").map((t=>U[null==t?void 0:t.toUpperCase()])),direction:N[null==a?void 0:a.toUpperCase()]}}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const e=i.global.fontSizePx*t;return{scaleFactors:{scenarioOffset:i["bn-chart-structure"].scaleFactors.scenarioOffset,scenarioLabelToBar:i["bn-chart-structure"].scaleFactors.scenarioLabelToBar,labelToBar:i["bn-chart-structure"].scaleFactors.labelToBar,labelToAxis:i["bn-chart-structure"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-structure"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-structure"].scaleFactors.needleHeadWidth,barWidth:i["bn-chart-structure"].scaleFactors.barWidth,varianceAxisLineWidth:i["bn-chart-structure"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-structure"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-structure"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-structure"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-structure"].scaleFactors.markerWidth,markerOffset:i["bn-chart-structure"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-structure"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-structure"].scaleFactors.axisTickLength},fontStyles:{font:`${e}px ${i.global.fontFamily}`,size:e,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-structure"].axisStyles,barStyles:i["bn-chart-structure"].barStyles,varianceStyles:i["bn-chart-structure"].varianceStyles,padding:i["bn-chart-structure"].padding,pattern:null}}))}prepareChartTitle(t){return t>=1?"":this.chartTitle}prepareStackConfig(){if(f(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const t=JSON.parse(this.stack),i=t.by,e="WARN_stack_dimensions_scenarios";if(i===M.DIMENSIONS){const t=this.prepareScenarios();t.length>1?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${t[0]}" is used, the rest (${t.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e)}else this.errors.remove(e);return{by:i,mode:t.mode||C.ABSOLUTE,order:t.order||L.DATASET}}catch(t){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareFilter(){return 0===this.filter.length?"":this.filter}prepareLimit(){return Math.floor(Number(this.limit)||0)}getDataStructure(){return{IStructureChartDataRow:{operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return f(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(t){return 0===t&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}chartTemplate(t,i){const e=this.getEffectiveScaleFactor(),s=this.preparePixelPerUnit(),r=this.preparePixelPerPercentage(),n=this.prepareStackConfig(),o=this.prepareScenarios(),l=(null==n?void 0:n.by)===M.DIMENSIONS?o.slice(0,1):o;return a("ibcs-chart-structure",{data:this.data,chartTitle:this.prepareChartTitle(i),scenarios:l,variances:[t],hideCategories:this.prepareHideCategories(i),pixelPerUnit:s>0?s*e:0,pixelPerPercentage:r>0?r*e: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(i),stackConfig:n,parentDimensions:this.prepareDimension()})}getEffectiveScaleFactor(){const{mode:t,factor:i}=S(this.scale);return"factor"===t?i:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var e,s,a,r;const n=(null===(e=i.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let t=[""];const i=this.prepareVariances();i.length>0&&(t=[...t,...i]);const e=this.getFontStyles();return a(r,{key:"9c71155a82140c2020a830247c62d668fb10959e",style:e},a("div",{key:"5d9402429fd36aa3b9615f13a5038bc38d825173",class:"container"},t.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}}static get style(){return':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}'}},[1,"bn-chart-structure",{chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],showCategories:[1,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[1,"show-measure-scale"],measureUnit:[1,"measure-unit"],stack:[1],scale:[1],data:[32],datasetMeta:[32],appliedScaleFactor:[32]},void 0,{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}]}]),W=P,z=function(){"undefined"!=typeof customElements&&["bn-chart-structure","ibcs-chart-structure"].forEach((t=>{switch(t){case"bn-chart-structure":customElements.get(n(t))||customElements.define(n(t),P);break;case"ibcs-chart-structure":customElements.get(n(t))||D()}}))};export{W as BnChartStructure,z as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{proxyCustomElement as e,HTMLElement as i,h as t,Host as s,transformTag as a}from"@stencil/core/internal/client";import{v as r,a as n,h as o,k as l,j as d,b as h,c,f as p,n as u,o as v,l as m,m as g,i as y}from"./validate.js";import{w as f,g as S,p as w}from"./scaling.js";import{w as b,a as O}from"./withHasError.js";import{w as x}from"./withTranslation.js";import{a as M}from"./context-protocol.js";import{w as R}from"./withStyled.js";import{w as _}from"./withComponentStyle.js";import{i as A,w as L}from"./withInheritedProps.js";import{b as T,O as E,c as C,g as I,h as U,i as k,C as W}from"./Order.js";import{F as N}from"./ibcsRuleSet.js";import{D}from"./DateStringFactory.js";import{d as F}from"./ibcs-chart-time2.js";var j;!function(e){e.ROWGROUP="rowGroup",e.ROWGROUPINDEX="rowGroupIndex",e.CATEGORY="category",e.CATEGORYINDEX="categoryIndex",e.SUBCATEGORY="subCategory",e.SUBCATEGORYINDEX="subCategoryIndex"}(j||(j={}));const P=e(class extends i{validateScenario(e){const i="ERR_scenarios";if(A(e))return void this.errors.remove(i);const t=r(e);t.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(t)+"' are not supported."}):this.errors.remove(i)}validateVariances(e){const i="ERR_variances";if(A(e))return void this.errors.remove(i);const t=n(e);t.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(t)+"' are not supported."}):this.errors.remove(i)}validateLeftSync(e){const i="ERR_syncSpaceLeft";o(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+e+"' are not supported."})}validateLimit(e){const i="ERR_limit";l(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"limit: invalid value '"+(null==e?void 0:""+e)+"' is not supported."})}validateUnitScaling(e){const i="ERR_unitScaling";o(e)||this.pixelPerUnitGroupMap.has(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"unitScaling: invalid value(s) '"+e+"' are not supported."})}validatePercentageScaling(e){const i="ERR_percentageScaling";o(e)||this.pixelPerUnitGroupMap.has(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"percentageScaling: invalid value(s) '"+e+"' are not supported."})}validateLevel(e){const i="ERR_level";d(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"level: invalid value(s) '"+e+"' are not supported."})}validateOrderList(e){const i="ERR_order";if(A(e))return void this.errors.remove(i);const t=h(e);t.length>0?this.errors.addOrReplace({id:i,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(t)+"' are not supported."}):this.errors.remove(i)}validateOrderDirection(e){const i="ERR_orderDirection";A(e)||c(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"orderDirection: invalid value '"+(null==e?void 0:""+e)+"' is not supported."})}validateDateInterval(e){const i="ERR_dateInterval";p(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"dateInterval: invalid value '"+(null==e?void 0:""+e)+"' is not supported."})}validateChartMode(e){const i="ERR_chartMode";["bar","line","auto"].includes(null==e?void 0:e.toLowerCase())?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"chartMode: invalid value '"+(null==e?void 0:""+e)+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(e){const i="ERR_maxBars";!l(e)||e<1?this.errors.addOrReplace({id:i,type:"warning",message:"maxBars: invalid value '"+(null==e?void 0:""+e)+"' is not supported. Must be a positive integer."}):this.errors.remove(i)}validateStack(e){const i="ERR_stack",t=u(e);t.length>0?this.errors.addOrReplace({id:i,type:"warning",message:t.join("; ")}):this.errors.remove(i)}validateScaling(e){if(null==e||""===e||"none"===e||"auto"===e)return void this.errors.remove("ERR_scale");const i=Number(e);isNaN(i)||i<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${e}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}validateAxisLabelsMode(e){const i="ERR_axisLabelsMode";v(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"axisLabelsMode: invalid value '"+(null==e?void 0:""+e)+"' is not supported."})}validateLineFullWidth(e){const i="ERR_lineFullWidth";m(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"lineFullWidth: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."})}validateShowCategories(e){const i="ERR_showCategories";m(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showCategories: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."})}validateMeasureScale(e){const i="ERR_measureScale";g(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"measureScale: invalid value '"+(null==e?void 0:""+e)+"' is not supported."})}validateShowMeasureScale(e){const i="ERR_grouped";m(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."})}validateShowOverlayAvg(e){const i="ERR_grouped";m(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayAvg: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."})}validateShowOverlayMedian(e){const i="ERR_grouped";m(e)?this.errors.remove(i):this.errors.addOrReplace({id:i,type:"warning",message:"showOverlayMedian: invalid value(s) '"+(null==e?void 0:""+e)+"' are not supported."})}constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.data=[],this.datasetMeta=null,this.appliedScaleFactor=1,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.limit=0,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth="true",this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.showOverlayAvg="true",this.showOverlayMedian="false",this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,R(this),b(this),f(this,((e,i)=>{this.data=i||[]}),((e,i)=>{this.datasetMeta=i})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=O(this),this.componentStyle=_(this),this.t=x(this).t,this.resolveInherited=L(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLimit(this.limit),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateLineFullWidth(this.lineFullWidth),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateShowOverlayAvg(this.showOverlayAvg),this.validateShowOverlayMedian(this.showOverlayMedian),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){var e,i;const{mode:t}=w(this.scale);if("auto"!==t&&"empty"!==t){this._autoScaleGuard=!1;const e=S(this.element),i="WARN_overflow";return void(e.width>0&&this.element.scrollWidth>e.width+1?this.errors.addOrReplace({id:i,type:"warning",message:"Chart exceeds available space and will be cut off. Check unit-scaling value."}):this.errors.remove(i))}if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const s=this.element,{width:a}=S(s);if(a<=0)return;const r=this.componentStyle((e=>{var i;return(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333}));s.style.setProperty("--bn-font-size",r+"px");const n=null===(e=s.shadowRoot)||void 0===e?void 0:e.querySelector(".container"),o=null!==(i=null==n?void 0:n.scrollWidth)&&void 0!==i?i:s.scrollWidth;if(o<=a+1)return this.errors.remove("AUTO_scale"),void(1!==this.appliedScaleFactor&&(this._autoScaleGuard=!0,this.appliedScaleFactor=1));const l=(a-1)/o;s.style.setProperty("--bn-font-size",r*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),Math.abs(l-this.appliedScaleFactor)>.001&&(this._autoScaleGuard=!0,this.appliedScaleFactor=l)}prepareDimension(){const e=S(this.element),i=this.prepareScenarios(),t=this.prepareVariances();return this.canvasWidthSegmented=e.width/(i.length+t.length||1),{width:this.canvasWidthSegmented,height:e.height}}prepareScenarios(){var e,i,t,s;const a=this.resolveInherited("scenarios",this.scenarios);if(void 0!==a)return this.errors.remove("AUTO_scenarios"),a.split(",").map((e=>e.trim()));const r="auto"===(null===(e=this.scenarios)||void 0===e?void 0:e.trim().toLowerCase());return y(this.scenarios)||r?(null===(t=null===(i=this.datasetMeta)||void 0===i?void 0:i.availableScenarios)||void 0===t?void 0:t.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=this.scenarios)||void 0===s?void 0:s.split(",").map((e=>e.trim())))}prepareAvg(){return"true"===this.showOverlayAvg}prepareMedian(){return"true"===this.showOverlayMedian}prepareVariances(){var e;const i=this.resolveInherited("variances",this.variances);return void 0!==i?i.split(",").map((e=>e.trim())):y(this.variances)?[]:null===(e=this.variances)||void 0===e?void 0:e.split(",").map((e=>e.trim()))}prepareHideAxisLabels(e){return e>=1||"true"!==this.showCategories}prepareI18n(){const e=M,i=new Map([].map((e=>[e,this.t(".".concat(e))]))),t=new Map(e.map((e=>[e,this.t("global.".concat(e))])));return new Map([...t.entries(),...i.entries()])}preparePixelPerUnit(){var e;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(e=this.unitScaling)||void 0===e?void 0:(""+e).trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const i=Number(this.unitScaling);return!isNaN(i)&&i>0?(this.errors.remove("AUTO_unitScaling"),i):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){return this.pixelPerUnitGroupMap.has(this.percentageScaling)?this.pixelPerUnitGroupMap.get(this.percentageScaling):100*Number(this.percentageScaling)}prepareLevel(){var e,i,t;const s="auto"===(null===(e=this.level)||void 0===e?void 0:e.trim().toLowerCase());return y(this.level)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?(s?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:"level: not set, auto-detected: "+this.datasetMeta.suggestedLevel}),j[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),j[null===(t=this.level)||void 0===t?void 0:t.toUpperCase()])}prepareOrder(){var e,i,t;const s=this.resolveInherited("order",this.order),a=this.resolveInherited("orderDirection",this.orderDirection),r=null!=s?s:this.order,n=null!=a?a:this.orderDirection;let o=(y(this.level)||"auto"===(null===(e=this.level)||void 0===e?void 0:e.trim().toLowerCase()))&&(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedLevel)?this.datasetMeta.suggestedLevel:this.level;const l="auto"===(null==r?void 0:r.trim().toLowerCase());return y(r)||l?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedLevel)&&(l?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+o})):(this.errors.remove("AUTO_order"),"levelindex"===(null==r?void 0:r.toLocaleLowerCase())&&(o+="Index")),{hierarchy:[E[null==o?void 0:o.toUpperCase()]],direction:T[null==n?void 0:n.toUpperCase()]}}prepareStyle(){const e=this.getEffectiveScaleFactor();return this.componentStyle((i=>{const t=i.global.fontSizePx*e;return{scaleFactors:{scenarioOffset:i["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:i["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:.3,labelToColum:i["bn-chart-time"].scaleFactors.labelToColum,labelToAxis:i["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:i["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:i["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:i["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:i["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:i["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:i["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:i["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:i["bn-chart-time"].scaleFactors.markerWidth,markerOffset:i["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:i["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:i["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${t}px ${i.global.fontFamily}`,size:t,color:i.global.fontColor,background:i.global.fontBackgroundColor,leading:1.8},axisStyles:i["bn-chart-time"].axisStyles,barStyles:i["bn-chart-time"].barStyles,varianceStyles:i["bn-chart-time"].varianceStyles,stackColors:i["bn-chart-time"].stackColors,padding:i["bn-chart-time"].padding,pattern:null}}))}prepareLeftSideOffset(e,i){return this.syncSpaceLeft>-1?this.syncSpaceLeft:N.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],e,i)}prepareChartTitle(e){return e>=1?"":this.chartTitle}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareDateInterval(){var e,i,t;const s="auto"===(null===(e=this.dateInterval)||void 0===e?void 0:e.trim().toLowerCase());return y(this.dateInterval)||s?(null===(i=this.datasetMeta)||void 0===i?void 0:i.suggestedDateInterval)?(s?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:"dateInterval: not set, auto-detected: "+this.datasetMeta.suggestedDateInterval}),D[this.datasetMeta.suggestedDateInterval.toUpperCase()]):s?D.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),D[null===(t=this.dateInterval)||void 0===t?void 0:t.toUpperCase()])}prepareIntervalSpanLimit(){return this.intervalSpanLimit}prepareAxisLabelsMode(){var e;return C[null===(e=this.axisLabelsMode)||void 0===e?void 0:e.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return y(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(e){return 0===e&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(y(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const e=JSON.parse(this.stack),i=e.by,t="WARN_stack_dimensions_scenarios";if(i===I.DIMENSIONS){const e=this.prepareScenarios();e.length>1?this.errors.addOrReplace({id:t,type:"warning",message:`stack by dimensions: only the first scenario "${e[0]}" is used, the rest (${e.slice(1).join(", ")}) are discarded.`}):this.errors.remove(t)}else this.errors.remove(t);return{by:i,mode:e.mode||k.ABSOLUTE,order:e.order||U.DATASET}}catch(e){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return"true"===this.lineFullWidth}prepareChartMode(){var e;const i=null===(e=this.chartMode)||void 0===e?void 0:e.toLowerCase();return"line"===i?W.LINE:"auto"===i?W.AUTO:W.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(e,i){const s=this.prepareI18n(),a=this.prepareStyle(),r=S(this.element).width,n=this.getEffectiveScaleFactor(),o=this.preparePixelPerUnit(),l=this.preparePixelPerPercentage(),d=this.prepareStackConfig(),h=this.prepareScenarios(),c=(null==d?void 0:d.by)===I.DIMENSIONS?h.slice(0,1):h;return t("ibcs-chart-time",{data:this.data,chartTitle:this.prepareChartTitle(i),scenarios:c,variances:[e],hideAxisLabels:this.prepareHideAxisLabels(i),pixelPerUnit:o>0?o*n:0,pixelPerPercentage:l>0?l*n:0,limit:this.prepareLimit(),leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(s,a),styles:a,i18n:s,order:this.prepareOrder(),level:this.prepareLevel(),dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(i),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:d,lineFullWidth:this.prepareLineFullWidth(),containerWidth:r,parentDimensions:this.prepareDimension()})}getEffectiveScaleFactor(){const{mode:e,factor:i}=w(this.scale);return"factor"===e?i:"auto"===e||"empty"===e?this.appliedScaleFactor:1}getFontStyles(){const e=this.getEffectiveScaleFactor();return this.componentStyle((i=>{var t,s,a,r;const n=(null===(t=i.global)||void 0===t?void 0:t.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=i.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*e+"px","--bn-font-color":(null===(a=i.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=i.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let e=[""];const i=this.prepareVariances();i.length>0&&(e=[...e,...i]);const a=this.getFontStyles();return t(s,{key:"d0625657fc6ddbacf7ad5c4cede189cc321109e1",style:a},t("div",{key:"393a0c8b00028b3edd08d6e199ffe55014251a5d",class:"container"},e.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],limit:[{validateLimit:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],lineFullWidth:[{validateLineFullWidth:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],showOverlayAvg:[{validateShowOverlayAvg:0}],showOverlayMedian:[{validateShowOverlayMedian:0}]}}static get style(){return":host{display:inline-block;position:relative;overflow:visible;}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}"}},[1,"bn-chart-time",{chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],syncSpaceLeft:[2,"sync-space-left"],limit:[2],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],dateInterval:[1,"date-interval"],chartMode:[1,"chart-mode"],maxBars:[2,"max-bars"],stack:[1],scale:[1],intervalSpanLimit:[2,"interval-span-limit"],axisLabelsMode:[1,"axis-labels-mode"],lineFullWidth:[1,"line-full-width"],showCategories:[1,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[1,"show-measure-scale"],showOverlayAvg:[1,"show-overlay-avg"],showOverlayMedian:[1,"show-overlay-median"],measureUnit:[1,"measure-unit"],data:[32],datasetMeta:[32],appliedScaleFactor:[32]},void 0,{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],limit:[{validateLimit:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],lineFullWidth:[{validateLineFullWidth:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],showOverlayAvg:[{validateShowOverlayAvg:0}],showOverlayMedian:[{validateShowOverlayMedian:0}]}]),G=P,B=function(){"undefined"!=typeof customElements&&["bn-chart-time","ibcs-chart-time"].forEach((e=>{switch(e){case"bn-chart-time":customElements.get(a(e))||customElements.define(a(e),P);break;case"ibcs-chart-time":customElements.get(a(e))||F()}}))};export{G as BnChartTime,B as defineCustomElement}
|
|
1
|
+
import{proxyCustomElement as i,HTMLElement as t,writeTask as e,forceUpdate as s,h as a,Host as r,transformTag as n}from"@stencil/core/internal/client";import{v as o,a as l,h as d,k as h,j as c,b as p,c as u,f as v,n as m,o as g,l as y,m as f,i as S}from"./validate.js";import{w,g as b,p as O}from"./scaling.js";import{w as x,a as M}from"./withHasError.js";import{w as R}from"./withTranslation.js";import{a as _}from"./context-protocol.js";import{w as A}from"./withStyled.js";import{w as L}from"./withComponentStyle.js";import{i as T,w as E}from"./withInheritedProps.js";import{b as C,O as I,c as U,g as k,h as W,i as N,C as D}from"./Order.js";import{F}from"./ibcsRuleSet.js";import{D as j}from"./DateStringFactory.js";import{d as P}from"./ibcs-chart-time2.js";var G;!function(i){i.ROWGROUP="rowGroup",i.ROWGROUPINDEX="rowGroupIndex",i.CATEGORY="category",i.CATEGORYINDEX="categoryIndex",i.SUBCATEGORY="subCategory",i.SUBCATEGORYINDEX="subCategoryIndex"}(G||(G={}));const B=i(class extends t{validateScenario(i){const t="ERR_scenarios";if(T(i))return void this.errors.remove(t);const e=o(i);e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:"scenarios: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(t)}validateVariances(i){const t="ERR_variances";if(T(i))return void this.errors.remove(t);const e=l(i);e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:"variances: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(t)}validateLeftSync(i){const t="ERR_syncSpaceLeft";d(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"syncSpaceLeft: invalid value(s) '"+i+"' are not supported."})}validateLimit(i){const t="ERR_limit";h(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"limit: invalid value '"+(null==i?void 0:""+i)+"' is not supported."})}validateUnitScaling(i){const t="ERR_unitScaling";d(i)||this.pixelPerUnitGroupMap.has(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"unitScaling: invalid value(s) '"+i+"' are not supported."})}validatePercentageScaling(i){const t="ERR_percentageScaling";d(i)||this.pixelPerUnitGroupMap.has(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"percentageScaling: invalid value(s) '"+i+"' are not supported."})}validateLevel(i){const t="ERR_level";c(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"level: invalid value(s) '"+i+"' are not supported."})}validateOrderList(i){const t="ERR_order";if(T(i))return void this.errors.remove(t);const e=p(i);e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:"order: invalid value(s) '"+JSON.stringify(e)+"' are not supported."}):this.errors.remove(t)}validateOrderDirection(i){const t="ERR_orderDirection";T(i)||u(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"orderDirection: invalid value '"+(null==i?void 0:""+i)+"' is not supported."})}validateDateInterval(i){const t="ERR_dateInterval";v(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"dateInterval: invalid value '"+(null==i?void 0:""+i)+"' is not supported."})}validateChartMode(i){const t="ERR_chartMode";["bar","line","auto"].includes(null==i?void 0:i.toLowerCase())?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"chartMode: invalid value '"+(null==i?void 0:""+i)+"' is not supported. Valid values are: bar, line, auto."})}validateMaxBars(i){const t="ERR_maxBars";!h(i)||i<1?this.errors.addOrReplace({id:t,type:"warning",message:"maxBars: invalid value '"+(null==i?void 0:""+i)+"' is not supported. Must be a positive integer."}):this.errors.remove(t)}validateStack(i){const t="ERR_stack",e=m(i);e.length>0?this.errors.addOrReplace({id:t,type:"warning",message:e.join("; ")}):this.errors.remove(t)}validateScaling(i){if(null==i||""===i||"none"===i||"auto"===i)return void this.errors.remove("ERR_scale");const t=Number(i);isNaN(t)||t<=0?this.errors.addOrReplace({id:"ERR_scale",type:"warning",message:`Invalid scale value: "${i}". Use "none", "auto", or a positive number.`}):this.errors.remove("ERR_scale")}validateAxisLabelsMode(i){const t="ERR_axisLabelsMode";g(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"axisLabelsMode: invalid value '"+(null==i?void 0:""+i)+"' is not supported."})}validateLineFullWidth(i){const t="ERR_lineFullWidth";y(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"lineFullWidth: invalid value(s) '"+(null==i?void 0:""+i)+"' are not supported."})}validateShowCategories(i){const t="ERR_showCategories";y(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"showCategories: invalid value(s) '"+(null==i?void 0:""+i)+"' are not supported."})}validateMeasureScale(i){const t="ERR_measureScale";f(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"measureScale: invalid value '"+(null==i?void 0:""+i)+"' is not supported."})}validateShowMeasureScale(i){const t="ERR_grouped";y(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"showMeasureScale: invalid value(s) '"+(null==i?void 0:""+i)+"' are not supported."})}validateShowOverlayAvg(i){const t="ERR_grouped";y(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"showOverlayAvg: invalid value(s) '"+(null==i?void 0:""+i)+"' are not supported."})}validateShowOverlayMedian(i){const t="ERR_grouped";y(i)?this.errors.remove(t):this.errors.addOrReplace({id:t,type:"warning",message:"showOverlayMedian: invalid value(s) '"+(null==i?void 0:""+i)+"' are not supported."})}constructor(i){super(),!1!==i&&this.__registerHost(),this.__attachShadow(),this.data=[],this.datasetMeta=null,this.appliedScaleFactor=1,this.chartTitle="",this.filter="",this.syncSpaceLeft=-1,this.limit=0,this.chartMode="bar",this.maxBars=28,this.stack="",this.intervalSpanLimit=28,this.lineFullWidth="true",this.showCategories="true",this.measureScale="greatest",this.showMeasureScale="false",this.showOverlayAvg="true",this.showOverlayMedian="false",this.measureUnit="",this.pixelPerUnitGroupMap=new Map,this._autoScaleGuard=!1,A(this),x(this),w(this,((i,t)=>{this.data=t||[]}),((i,t)=>{this.datasetMeta=t})),this.chartTemplate=this.chartTemplate.bind(this),this.errors=M(this),this.componentStyle=L(this),this.t=R(this).t,this.resolveInherited=E(this,[{propName:"scenarios",ancestorAttr:"title-scenarios"},{propName:"variances",ancestorAttr:"title-variances"},{propName:"order",ancestorAttr:"title-order"},{propName:"orderDirection",ancestorAttr:"title-order-direction"}])}componentWillLoad(){this.validateScenario(this.scenarios),this.validateVariances(this.variances),this.validateUnitScaling(this.unitScaling),this.validateLimit(this.limit),this.validateLevel(this.level),this.validateOrderDirection(this.orderDirection),this.validateOrderList(this.order),this.validateLeftSync(this.syncSpaceLeft),this.validateDateInterval(this.dateInterval),this.validateAxisLabelsMode(this.axisLabelsMode),this.validateLineFullWidth(this.lineFullWidth),this.validateShowCategories(this.showCategories),this.validateMeasureScale(this.measureScale),this.validateShowMeasureScale(this.showMeasureScale),this.validateShowOverlayAvg(this.showOverlayAvg),this.validateShowOverlayMedian(this.showOverlayMedian),this.validateChartMode(this.chartMode),this.validateMaxBars(this.maxBars),this.validateStack(this.stack),this.validateScaling(this.scale)}componentDidRender(){var i,t;const{mode:s}=O(this.scale);if("auto"!==s&&"empty"!==s){this._autoScaleGuard=!1;const i=b(this.element),t="WARN_overflow";return void(i.width>0&&this.element.scrollWidth>i.width+1?this.errors.addOrReplace({id:t,type:"warning",message:"Chart exceeds available space and will be cut off. Check unit-scaling value."}):this.errors.remove(t))}if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const a=this.element,{width:r}=b(a);if(r<=0)return;const n=this.componentStyle((i=>{var t;return(null===(t=i.global)||void 0===t?void 0:t.fontSizePx)||13.3333}));a.style.setProperty("--bn-font-size",n+"px");const o=null===(i=a.shadowRoot)||void 0===i?void 0:i.querySelector(".container"),l=null!==(t=null==o?void 0:o.scrollWidth)&&void 0!==t?t:a.scrollWidth;if(l<=r+1)return this.errors.remove("AUTO_scale"),void(1!==this.appliedScaleFactor&&(this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=1}))));const d=(r-1)/l;a.style.setProperty("--bn-font-size",n*d+"px"),"empty"===s?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+d.toFixed(3)}):this.errors.remove("AUTO_scale"),Math.abs(d-this.appliedScaleFactor)>.001&&(this._autoScaleGuard=!0,e((()=>{this.appliedScaleFactor=d})))}componentDidLoad(){if(this.canvasWidthSegmented<=0){const{width:i}=b(this.element);i>0&&s(this)}}prepareDimension(){const i=b(this.element),t=this.prepareScenarios(),e=this.prepareVariances();return this.canvasWidthSegmented=i.width/(t.length+e.length||1),{width:this.canvasWidthSegmented,height:i.height}}prepareScenarios(){var i,t,e,s;const a=this.resolveInherited("scenarios",this.scenarios);if(void 0!==a)return this.errors.remove("AUTO_scenarios"),a.split(",").map((i=>i.trim()));const r="auto"===(null===(i=this.scenarios)||void 0===i?void 0:i.trim().toLowerCase());return S(this.scenarios)||r?(null===(e=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)||void 0===e?void 0:e.length)>0?(r?this.errors.remove("AUTO_scenarios"):this.errors.addOrReplace({id:"AUTO_scenarios",type:"warning",message:"scenarios: not set, auto-detected: "+this.datasetMeta.availableScenarios.join(",")}),this.datasetMeta.availableScenarios):[]:(this.errors.remove("AUTO_scenarios"),null===(s=this.scenarios)||void 0===s?void 0:s.split(",").map((i=>i.trim())))}prepareAvg(){return"true"===this.showOverlayAvg}prepareMedian(){return"true"===this.showOverlayMedian}prepareVariances(){var i;const t=this.resolveInherited("variances",this.variances);return void 0!==t?t.split(",").map((i=>i.trim())):S(this.variances)?[]:null===(i=this.variances)||void 0===i?void 0:i.split(",").map((i=>i.trim()))}prepareHideAxisLabels(i){return i>=1||"true"!==this.showCategories}prepareI18n(){const i=_,t=new Map([].map((i=>[i,this.t(".".concat(i))]))),e=new Map(i.map((i=>[i,this.t("global.".concat(i))])));return new Map([...e.entries(),...t.entries()])}preparePixelPerUnit(){var i;if(this.pixelPerUnitGroupMap.has(this.unitScaling))return this.errors.remove("AUTO_unitScaling"),this.pixelPerUnitGroupMap.get(this.unitScaling);if("auto"===(null===(i=this.unitScaling)||void 0===i?void 0:(""+i).trim().toLowerCase()))return this.errors.remove("AUTO_unitScaling"),0;const t=Number(this.unitScaling);return!isNaN(t)&&t>0?(this.errors.remove("AUTO_unitScaling"),t):(this.errors.addOrReplace({id:"AUTO_unitScaling",type:"warning",message:"unit-scaling: not set, auto-calculated to fit available space."}),0)}preparePixelPerPercentage(){return this.pixelPerUnitGroupMap.has(this.percentageScaling)?this.pixelPerUnitGroupMap.get(this.percentageScaling):100*Number(this.percentageScaling)}prepareLevel(){var i,t,e;const s="auto"===(null===(i=this.level)||void 0===i?void 0:i.trim().toLowerCase());return S(this.level)||s?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedLevel)?(s?this.errors.remove("AUTO_level"):this.errors.addOrReplace({id:"AUTO_level",type:"warning",message:"level: not set, auto-detected: "+this.datasetMeta.suggestedLevel}),G[this.datasetMeta.suggestedLevel.toUpperCase()]):void 0:(this.errors.remove("AUTO_level"),G[null===(e=this.level)||void 0===e?void 0:e.toUpperCase()])}prepareOrder(){var i,t,e;const s=this.resolveInherited("order",this.order),a=this.resolveInherited("orderDirection",this.orderDirection),r=null!=s?s:this.order,n=null!=a?a:this.orderDirection;let o=(S(this.level)||"auto"===(null===(i=this.level)||void 0===i?void 0:i.trim().toLowerCase()))&&(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedLevel)?this.datasetMeta.suggestedLevel:this.level;const l="auto"===(null==r?void 0:r.trim().toLowerCase());return S(r)||l?(null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel)&&(l?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+o})):(this.errors.remove("AUTO_order"),"levelindex"===(null==r?void 0:r.toLocaleLowerCase())&&(o+="Index")),{hierarchy:[I[null==o?void 0:o.toUpperCase()]],direction:C[null==n?void 0:n.toUpperCase()]}}prepareStyle(){const i=this.getEffectiveScaleFactor();return this.componentStyle((t=>{const e=t.global.fontSizePx*i;return{scaleFactors:{scenarioOffset:t["bn-chart-time"].scaleFactors.scenarioOffset,scenarioLabelToColumn:t["bn-chart-time"].scaleFactors.scenarioLabelToColumn,labelToColumn:.3,labelToColum:t["bn-chart-time"].scaleFactors.labelToColum,labelToAxis:t["bn-chart-time"].scaleFactors.labelToAxis,needleWidth:t["bn-chart-time"].scaleFactors.needleWidth,needleHeadWidth:t["bn-chart-time"].scaleFactors.needleHeadWidth,columnWidth:t["bn-chart-time"].scaleFactors.columnWidth,varianceAxisLineWidth:t["bn-chart-time"].scaleFactors.varianceAxisLineWidth,axisLineWidth:t["bn-chart-time"].scaleFactors.axisLineWidth,auxiliaryLineWidth:t["bn-chart-time"].scaleFactors.auxiliaryLineWidth,scenarioLineWidth:t["bn-chart-time"].scaleFactors.scenarioLineWidth,markerWidth:t["bn-chart-time"].scaleFactors.markerWidth,markerOffset:t["bn-chart-time"].scaleFactors.markerOffset,categoryWidth:t["bn-chart-time"].scaleFactors.categoryWidth,axisTickLength:t["bn-chart-time"].scaleFactors.axisTickLength},fontStyles:{font:`${e}px ${t.global.fontFamily}`,size:e,color:t.global.fontColor,background:t.global.fontBackgroundColor,leading:1.8},axisStyles:t["bn-chart-time"].axisStyles,barStyles:t["bn-chart-time"].barStyles,varianceStyles:t["bn-chart-time"].varianceStyles,stackColors:t["bn-chart-time"].stackColors,padding:t["bn-chart-time"].padding,pattern:null}}))}prepareLeftSideOffset(i,t){return this.syncSpaceLeft>-1?this.syncSpaceLeft:F.getMaxWidthOfArrayItems([...this.prepareVariances(),...this.prepareScenarios(),this.chartTitle],i,t)}prepareChartTitle(i){return i>=1?"":this.chartTitle}prepareLimit(){return Math.floor(Number(this.limit)||0)}prepareDateInterval(){var i,t,e;const s="auto"===(null===(i=this.dateInterval)||void 0===i?void 0:i.trim().toLowerCase());return S(this.dateInterval)||s?(null===(t=this.datasetMeta)||void 0===t?void 0:t.suggestedDateInterval)?(s?this.errors.remove("AUTO_dateInterval"):this.errors.addOrReplace({id:"AUTO_dateInterval",type:"warning",message:"dateInterval: not set, auto-detected: "+this.datasetMeta.suggestedDateInterval}),j[this.datasetMeta.suggestedDateInterval.toUpperCase()]):s?j.AUTO:void 0:(this.errors.remove("AUTO_dateInterval"),j[null===(e=this.dateInterval)||void 0===e?void 0:e.toUpperCase()])}prepareIntervalSpanLimit(){return this.intervalSpanLimit}prepareAxisLabelsMode(){var i;return U[null===(i=this.axisLabelsMode)||void 0===i?void 0:i.toUpperCase()]}prepareFilter(){return 0===this.filter.length?"":this.filter}getDataStructure(){return{ITimeChartDataRow:{setName:{type:"string",isOptional:!1,description:""},date:{type:"string",isOptional:!1,description:""},operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!1,description:""},rowGroupIndex:{type:"number",isOptional:!1,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!1,description:""},subCategoryIndex:{type:"number",isOptional:!1,description:""},columnGroup:{type:"string",isOptional:!1,description:""},columnGroupIndex:{type:"number",isOptional:!1,description:""},columnSubGroup:{type:"string",isOptional:!1,description:""},columnSubGroupIndex:{type:"number",isOptional:!1,description:""},ac1:{type:"number",isOptional:!1,description:""},ac2:{type:"number",isOptional:!1,description:""},ac3:{type:"number",isOptional:!1,description:""},ac4:{type:"number",isOptional:!1,description:""},pp1:{type:"number",isOptional:!1,description:""},pp2:{type:"number",isOptional:!1,description:""},pp3:{type:"number",isOptional:!1,description:""},pp4:{type:"number",isOptional:!1,description:""},fc1:{type:"number",isOptional:!1,description:""},fc2:{type:"number",isOptional:!1,description:""},fc3:{type:"number",isOptional:!1,description:""},fc4:{type:"number",isOptional:!1,description:""},pl1:{type:"number",isOptional:!1,description:""},pl2:{type:"number",isOptional:!1,description:""},pl3:{type:"number",isOptional:!1,description:""},pl4:{type:"number",isOptional:!1,description:""}}}}prepareMeasureScale(){return S(this.measureScale)?"GREATEST":["_","k","M","G","T","P","E","Z","Y","m","μ","n","p","P","f","a","z","y"].includes(this.measureScale.trim())||"LEAST"===this.measureScale.trim().toUpperCase()?this.measureScale.trim():"GREATEST"}prepareShowMeasureScale(i){return 0===i&&"true"===this.showMeasureScale}prepareMeasureUnit(){return""===this.measureUnit||null==this.measureUnit?"":this.measureUnit}prepareStackConfig(){if(S(this.stack))return this.errors.remove("WARN_stack_dimensions_scenarios"),null;try{const i=JSON.parse(this.stack),t=i.by,e="WARN_stack_dimensions_scenarios";if(t===k.DIMENSIONS){const i=this.prepareScenarios();i.length>1?this.errors.addOrReplace({id:e,type:"warning",message:`stack by dimensions: only the first scenario "${i[0]}" is used, the rest (${i.slice(1).join(", ")}) are discarded.`}):this.errors.remove(e)}else this.errors.remove(e);return{by:t,mode:i.mode||N.ABSOLUTE,order:i.order||W.DATASET}}catch(i){return this.errors.remove("WARN_stack_dimensions_scenarios"),null}}prepareLineFullWidth(){return"true"===this.lineFullWidth}prepareChartMode(){var i;const t=null===(i=this.chartMode)||void 0===i?void 0:i.toLowerCase();return"line"===t?D.LINE:"auto"===t?D.AUTO:D.BAR}prepareMaxBars(){return Math.floor(Number(this.maxBars)||28)}chartTemplate(i,t){const e=this.prepareI18n(),s=this.prepareStyle(),r=b(this.element).width,n=this.getEffectiveScaleFactor(),o=this.preparePixelPerUnit(),l=this.preparePixelPerPercentage(),d=this.prepareStackConfig(),h=this.prepareScenarios(),c=(null==d?void 0:d.by)===k.DIMENSIONS?h.slice(0,1):h;return a("ibcs-chart-time",{data:this.data,chartTitle:this.prepareChartTitle(t),scenarios:c,variances:[i],hideAxisLabels:this.prepareHideAxisLabels(t),pixelPerUnit:o>0?o*n:0,pixelPerPercentage:l>0?l*n:0,limit:this.prepareLimit(),leftSideOffsetForHorizontalSync:this.prepareLeftSideOffset(e,s),styles:s,i18n:e,order:this.prepareOrder(),level:this.prepareLevel(),dateInterval:this.prepareDateInterval(),intervalSpanLimit:this.prepareIntervalSpanLimit(),axisLabelsMode:this.prepareAxisLabelsMode(),filter:this.prepareFilter(),"measure-scale":this.prepareMeasureScale(),"measure-unit":this.prepareMeasureUnit(),showOverlayAvg:this.prepareAvg(),showOverlayMedian:this.prepareMedian(),showMeasureScale:this.prepareShowMeasureScale(t),chartMode:this.prepareChartMode(),maxBars:this.prepareMaxBars(),stackConfig:d,lineFullWidth:this.prepareLineFullWidth(),containerWidth:r,parentDimensions:this.prepareDimension()})}getEffectiveScaleFactor(){const{mode:i,factor:t}=O(this.scale);return"factor"===i?t:"auto"===i||"empty"===i?this.appliedScaleFactor:1}getFontStyles(){const i=this.getEffectiveScaleFactor();return this.componentStyle((t=>{var e,s,a,r;const n=(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=t.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*i+"px","--bn-font-color":(null===(a=t.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=t.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}render(){let i=[""];const t=this.prepareVariances();t.length>0&&(i=[...i,...t]);const e=this.getFontStyles();return a(r,{key:"317b1048224d8b5ede5dc4868d2d927c9c7cfee9",style:e},a("div",{key:"3168861fc4440ea67103140c33c4aa84ac0bf245",class:"container"},i.map(this.chartTemplate)))}get element(){return this}static get watchers(){return{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],limit:[{validateLimit:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],lineFullWidth:[{validateLineFullWidth:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],showOverlayAvg:[{validateShowOverlayAvg:0}],showOverlayMedian:[{validateShowOverlayMedian:0}]}}static get style(){return":host{display:inline-block;position:relative;overflow:visible;}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}"}},[1,"bn-chart-time",{chartTitle:[1,"chart-title"],filter:[1],scenarios:[1],variances:[1],syncSpaceLeft:[2,"sync-space-left"],limit:[2],unitScaling:[8,"unit-scaling"],percentageScaling:[8,"percentage-scaling"],level:[1],order:[1],orderDirection:[1,"order-direction"],dateInterval:[1,"date-interval"],chartMode:[1,"chart-mode"],maxBars:[2,"max-bars"],stack:[1],scale:[1],intervalSpanLimit:[2,"interval-span-limit"],axisLabelsMode:[1,"axis-labels-mode"],lineFullWidth:[1,"line-full-width"],showCategories:[1,"show-categories"],measureScale:[1,"measure-scale"],showMeasureScale:[1,"show-measure-scale"],showOverlayAvg:[1,"show-overlay-avg"],showOverlayMedian:[1,"show-overlay-median"],measureUnit:[1,"measure-unit"],data:[32],datasetMeta:[32],appliedScaleFactor:[32]},void 0,{scenarios:[{validateScenario:0}],variances:[{validateVariances:0}],syncSpaceLeft:[{validateLeftSync:0}],limit:[{validateLimit:0}],unitScaling:[{validateUnitScaling:0}],percentageScaling:[{validatePercentageScaling:0}],level:[{validateLevel:0}],order:[{validateOrderList:0}],orderDirection:[{validateOrderDirection:0}],dateInterval:[{validateDateInterval:0}],chartMode:[{validateChartMode:0}],maxBars:[{validateMaxBars:0}],stack:[{validateStack:0}],scale:[{validateScaling:0}],axisLabelsMode:[{validateAxisLabelsMode:0}],lineFullWidth:[{validateLineFullWidth:0}],showCategories:[{validateShowCategories:0}],measureScale:[{validateMeasureScale:0}],showMeasureScale:[{validateShowMeasureScale:0}],showOverlayAvg:[{validateShowOverlayAvg:0}],showOverlayMedian:[{validateShowOverlayMedian:0}]}]),z=B,V=function(){"undefined"!=typeof customElements&&["bn-chart-time","ibcs-chart-time"].forEach((i=>{switch(i){case"bn-chart-time":customElements.get(n(i))||customElements.define(n(i),B);break;case"ibcs-chart-time":customElements.get(n(i))||P()}}))};export{z as BnChartTime,V as defineCustomElement}
|