@bino-bi/bn-template-engine 1.0.0-alpha.13 → 1.0.0-alpha.15
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-637e3b8f.entry.js → p-19f49fbc.entry.js} +1 -1
- package/dist/bn-template-engine/p-209b3fd9.entry.js +1 -0
- package/dist/bn-template-engine/{p-67eae33e.entry.js → p-3465fcdc.entry.js} +1 -1
- package/dist/bn-template-engine/{p-82023539.entry.js → p-67746414.entry.js} +1 -1
- package/dist/bn-template-engine/p-BPDZcex5.js +1 -0
- package/dist/bn-template-engine/{p-DHheVOfP.js → p-Tx6omDWp.js} +1 -1
- package/dist/bn-template-engine/{p-52097456.entry.js → p-d724ab88.entry.js} +1 -1
- package/dist/bn-template-engine/p-efd3b67a.entry.js +1 -0
- package/dist/bn-template-engine/{p-46699464.entry.js → p-ff659485.entry.js} +1 -1
- package/dist/bn-template-engine/p-z9bPNFYF.js +1 -0
- package/dist/cjs/bn-asset_21.cjs.entry.js +348 -75
- package/dist/cjs/bn-grid.cjs.entry.js +2 -2
- package/dist/cjs/bn-image.cjs.entry.js +2 -2
- package/dist/cjs/bn-internationalization.cjs.entry.js +1 -1
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/bn-text.cjs.entry.js +3 -3
- package/dist/cjs/bn-tree.cjs.entry.js +2 -2
- package/dist/cjs/{context-protocol-Op7uUwN3.js → context-protocol-Cn5PL928.js} +14 -0
- package/dist/cjs/editor-companion.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{scaling-57N4Cxb_.js → scaling-DM2UILdF.js} +58 -17
- package/dist/cjs/{withStyled-C2kmGAK3.js → withStyled-Dx3uRw9g.js} +72 -1
- package/dist/collection/components/bn-chart-structure/utils/StructureChart.js +28 -10
- package/dist/collection/components/bn-chart-structure/utils/helper/ElementPositions.js +46 -4
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +39 -1
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +40 -10
- package/dist/collection/components/bn-dataset/bn-dataset.js +25 -13
- package/dist/collection/components/bn-datasource/bn-datasource.js +23 -12
- package/dist/collection/components/bn-layout-card/bn-layout-card.css +5 -0
- package/dist/collection/components/bn-layout-card/bn-layout-card.js +6 -3
- package/dist/collection/components/bn-layout-page/bn-layout-page.css +5 -0
- package/dist/collection/components/bn-layout-page/bn-layout-page.js +6 -3
- package/dist/collection/components/bn-table/bn-table.js +75 -7
- package/dist/collection/components/bn-table/ibcs-table.js +27 -0
- package/dist/collection/components/bn-table/utils/Table.js +2 -2
- package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +28 -5
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +46 -6
- package/dist/collection/components/bn-table/utils/model/TableAttribute.js +46 -0
- package/dist/collection/components/bn-table/utils/model/TableComponentConfig.js +5 -0
- package/dist/collection/context/scopedDb.js +14 -0
- package/dist/collection/utils/parentDimensions.js +57 -16
- package/dist/collection/utils/validate.js +23 -0
- package/dist/components/DateStringFactory.js +1 -1
- package/dist/components/Order.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-dataset.js +1 -1
- package/dist/components/bn-datasource.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/bn-title2.js +1 -1
- package/dist/components/context-protocol.js +1 -1
- package/dist/components/ibcs-chart-structure2.js +1 -1
- package/dist/components/ibcs-chart-time2.js +1 -1
- package/dist/components/ibcs-table2.js +1 -1
- package/dist/components/ibcs-title2.js +1 -1
- package/dist/components/scaling.js +1 -1
- package/dist/components/validate.js +1 -1
- package/dist/esm/bn-asset_21.entry.js +348 -75
- package/dist/esm/bn-grid.entry.js +2 -2
- package/dist/esm/bn-image.entry.js +2 -2
- package/dist/esm/bn-internationalization.entry.js +1 -1
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/bn-text.entry.js +3 -3
- package/dist/esm/bn-tree.entry.js +2 -2
- package/dist/esm/{context-protocol-BDhzNbeD.js → context-protocol-BB-4Onmw.js} +14 -0
- package/dist/esm/editor-companion.entry.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{scaling-La1Ow72h.js → scaling-h4KcBet3.js} +58 -17
- package/dist/esm/{withStyled-Bl9cSoRW.js → withStyled-BBvU2f-A.js} +71 -2
- package/dist/types/components/bn-chart-structure/utils/StructureChart.d.ts +4 -0
- package/dist/types/components/bn-chart-structure/utils/helper/ElementPositions.d.ts +16 -1
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +13 -0
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +4 -0
- package/dist/types/components/bn-dataset/bn-dataset.d.ts +15 -7
- package/dist/types/components/bn-datasource/bn-datasource.d.ts +13 -6
- package/dist/types/components/bn-layout-card/bn-layout-card.d.ts +1 -0
- package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +1 -0
- package/dist/types/components/bn-table/bn-table.d.ts +13 -0
- package/dist/types/components/bn-table/ibcs-table.d.ts +2 -0
- package/dist/types/components/bn-table/utils/factories/tableDataSetFactory.d.ts +3 -1
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +11 -0
- package/dist/types/components/bn-table/utils/model/TableAttribute.d.ts +22 -0
- package/dist/types/components/bn-table/utils/model/TableComponentConfig.d.ts +3 -0
- package/dist/types/components.d.ts +45 -20
- package/dist/types/utils/validate.d.ts +6 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-3c827826.entry.js +0 -1
- package/dist/bn-template-engine/p-BVFHvEXF.js +0 -1
- package/dist/bn-template-engine/p-CQnZV3JG.js +0 -1
- package/dist/bn-template-engine/p-ab3ea8cf.entry.js +0 -1
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export class ElementPositions {
|
|
17
17
|
// private smallestDataPoint: DataPoint;
|
|
18
|
-
constructor(padding, scaleFactors, fontSize, numberOfColumns, leftSideLengthSync, titleLength, leftSideWidth, categoryWidth) {
|
|
18
|
+
constructor(padding, scaleFactors, fontSize, numberOfColumns, leftSideLengthSync, titleLength, leftSideWidth, categoryWidth, hasStackedHeaders = false) {
|
|
19
19
|
this.categoryPosition = { x: 0, y: 0 };
|
|
20
20
|
this.spacings = {
|
|
21
21
|
scenarioOffset: 0,
|
|
@@ -45,6 +45,7 @@ export class ElementPositions {
|
|
|
45
45
|
this.numberOfColumns = numberOfColumns;
|
|
46
46
|
this.leftSideLengthSync = leftSideLengthSync;
|
|
47
47
|
this.topSideLabelHeight = titleLength > 0 ? this.fontSize : 0;
|
|
48
|
+
this.hasStackedHeaders = hasStackedHeaders;
|
|
48
49
|
this.leftSideLabelLength = this.calculateSideLabelLength(titleLength, leftSideWidth, categoryWidth);
|
|
49
50
|
this.calculateSpacings();
|
|
50
51
|
this.calculateCategoryPosition();
|
|
@@ -73,7 +74,10 @@ export class ElementPositions {
|
|
|
73
74
|
return this.axisPosition.x;
|
|
74
75
|
}
|
|
75
76
|
getAxisTitlePositionY() {
|
|
76
|
-
return this.axisPosition.y - this.spacings.labelToAxis;
|
|
77
|
+
return this.axisPosition.y - this.spacings.labelToAxis - this.getTopLabelOverhang();
|
|
78
|
+
}
|
|
79
|
+
getStackedHeaderPositionY() {
|
|
80
|
+
return this.getBarCenterPositionY(0) - this.spacings.barWidth * 0.5 - this.spacings.scenarioLabelToBar;
|
|
77
81
|
}
|
|
78
82
|
getNeedleWidth() {
|
|
79
83
|
return this.spacings.needleWidth;
|
|
@@ -129,7 +133,12 @@ export class ElementPositions {
|
|
|
129
133
|
}
|
|
130
134
|
getScenarioLabelPositionOffsetY(isPrimaryBar) {
|
|
131
135
|
if (isPrimaryBar) {
|
|
132
|
-
|
|
136
|
+
// The label belongs to the last bar, but the axis line runs past that bar's
|
|
137
|
+
// center by (categoryWidth - scenarioOffset); place the label below the axis
|
|
138
|
+
// end so the line does not strike through it.
|
|
139
|
+
const belowBar = this.getBarWidth() * 0.5 + this.spacings.scenarioLabelToBar;
|
|
140
|
+
const belowAxisEnd = this.spacings.categoryWidth - this.spacings.scenarioOffset + this.spacings.labelToAxis;
|
|
141
|
+
return Math.max(belowBar, belowAxisEnd);
|
|
133
142
|
}
|
|
134
143
|
return -(this.getBarWidth() * 0.5 + this.spacings.scenarioLabelToBar);
|
|
135
144
|
}
|
|
@@ -191,7 +200,40 @@ export class ElementPositions {
|
|
|
191
200
|
this.calculateAxisPosition();
|
|
192
201
|
}
|
|
193
202
|
getAxisTitleOffset() {
|
|
194
|
-
|
|
203
|
+
// Title height plus the gap to the labels that can stick out above the first bar
|
|
204
|
+
return this.topSideLabelHeight + this.spacings.labelToAxis + this.getTopLabelOverhang();
|
|
205
|
+
}
|
|
206
|
+
getTopLabelOverhang() {
|
|
207
|
+
return this.hasStackedHeaders ? this.getStackedHeaderOverhang() : this.getTopScenarioLabelOverhang();
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* How far the stacked-segment header row (anchored just above the first bar)
|
|
211
|
+
* reaches above the axis start. The title is moved up by this amount so the
|
|
212
|
+
* header row sits between title and bars without overlapping either.
|
|
213
|
+
*/
|
|
214
|
+
getStackedHeaderOverhang() {
|
|
215
|
+
return Math.max(0, this.fontSize +
|
|
216
|
+
this.spacings.scenarioLabelToBar +
|
|
217
|
+
this.spacings.barWidth * 0.5 -
|
|
218
|
+
(this.spacings.categoryWidth * 0.5 + this.spacings.scenarioOffset));
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* How far the scenario labels above the first bar (secondary bar label) or
|
|
222
|
+
* above the first marker (primary marker label) reach above the axis start.
|
|
223
|
+
* The title is moved up by this amount so it does not overlap them.
|
|
224
|
+
*/
|
|
225
|
+
getTopScenarioLabelOverhang() {
|
|
226
|
+
const barLabelOverhang = this.fontSize +
|
|
227
|
+
this.spacings.barWidth * 0.5 +
|
|
228
|
+
this.spacings.scenarioLabelToBar -
|
|
229
|
+
this.spacings.categoryWidth * 0.5;
|
|
230
|
+
const markerLabelOverhang = this.fontSize +
|
|
231
|
+
this.spacings.markerWidth * 0.5 +
|
|
232
|
+
this.spacings.scenarioLabelToBar +
|
|
233
|
+
this.spacings.markerOffset +
|
|
234
|
+
this.spacings.barWidth * 0.5 -
|
|
235
|
+
(this.spacings.categoryWidth * 0.5 + this.spacings.scenarioOffset);
|
|
236
|
+
return Math.max(0, barLabelOverhang, markerLabelOverhang);
|
|
195
237
|
}
|
|
196
238
|
calculateSideLabelLength(titleLength, leftSideWidth, categoryWidth) {
|
|
197
239
|
if (this.leftSideLengthSync) {
|
|
@@ -483,6 +483,8 @@ export class Chart {
|
|
|
483
483
|
this.pixelPerUnitGroupMap = new Map();
|
|
484
484
|
this._autoScaleGuard = false;
|
|
485
485
|
this._lastObservedWidth = 0;
|
|
486
|
+
this._settleTimer = null;
|
|
487
|
+
this._lastAppliedHeight = 0;
|
|
486
488
|
withStyled(this);
|
|
487
489
|
withComponentStatus(this);
|
|
488
490
|
withDataset(this, (name, _data) => {
|
|
@@ -612,17 +614,53 @@ export class Chart {
|
|
|
612
614
|
forceUpdate(this);
|
|
613
615
|
});
|
|
614
616
|
});
|
|
617
|
+
this.settleParentHeight();
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* The initial renders can measure mid-hydration, before ancestor CSS
|
|
621
|
+
* (fixed page height, overflow) is applied, so the height used for
|
|
622
|
+
* auto-fit may be a transient value — and the resize observer above
|
|
623
|
+
* deliberately ignores height changes. Re-measure on a short backoff
|
|
624
|
+
* schedule and re-render when the measurement no longer matches the
|
|
625
|
+
* height the last render actually used (_lastAppliedHeight, recorded
|
|
626
|
+
* in prepareDimension). The schedule is finite, so this cannot feed a
|
|
627
|
+
* render loop.
|
|
628
|
+
*/
|
|
629
|
+
settleParentHeight() {
|
|
630
|
+
const delays = [150, 400, 1000, 2500];
|
|
631
|
+
const check = () => {
|
|
632
|
+
this._settleTimer = null;
|
|
633
|
+
if (!this.element.isConnected)
|
|
634
|
+
return;
|
|
635
|
+
const { height } = getParentDimensions(this.element);
|
|
636
|
+
// 8px threshold: hydration corrections are large (hundreds of px);
|
|
637
|
+
// small jitter must not cause re-renders, because every re-render
|
|
638
|
+
// gives the width-overflow font scaler a chance to ratchet down.
|
|
639
|
+
if (height > 0 && Math.abs(height - this._lastAppliedHeight) > 8 && !this._autoScaleGuard) {
|
|
640
|
+
forceUpdate(this);
|
|
641
|
+
}
|
|
642
|
+
const next = delays.shift();
|
|
643
|
+
if (next !== undefined) {
|
|
644
|
+
this._settleTimer = setTimeout(check, next);
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
this._settleTimer = setTimeout(check, delays.shift());
|
|
615
648
|
}
|
|
616
649
|
disconnectedCallback() {
|
|
617
650
|
var _a;
|
|
618
651
|
(_a = this.layoutObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
619
652
|
this.layoutObserver = null;
|
|
653
|
+
if (this._settleTimer != null) {
|
|
654
|
+
clearTimeout(this._settleTimer);
|
|
655
|
+
this._settleTimer = null;
|
|
656
|
+
}
|
|
620
657
|
}
|
|
621
658
|
prepareDimension() {
|
|
622
659
|
const parent = getParentDimensions(this.element);
|
|
623
660
|
const scenariosList = this.prepareScenarios();
|
|
624
661
|
const variancesList = this.prepareVariances();
|
|
625
662
|
this.canvasWidthSegmented = parent.width / (scenariosList.length + variancesList.length || 1);
|
|
663
|
+
this._lastAppliedHeight = parent.height;
|
|
626
664
|
return { width: this.canvasWidthSegmented, height: parent.height };
|
|
627
665
|
}
|
|
628
666
|
prepareScenarios() {
|
|
@@ -1026,7 +1064,7 @@ export class Chart {
|
|
|
1026
1064
|
scenariosArray = [...scenariosArray, ...variancesArray];
|
|
1027
1065
|
}
|
|
1028
1066
|
const fontStyles = this.getFontStyles();
|
|
1029
|
-
return (h(Host, { key: '
|
|
1067
|
+
return (h(Host, { key: '8c90dcaacd6b4e1b64b1fb4a8aefe1345086e7e6', style: fontStyles }, h("div", { key: 'c0209d2fd9fcf5ee60c3f17697c7bcbf1b445fec', class: "container" }, scenariosArray.map(this.chartTemplate))));
|
|
1030
1068
|
}
|
|
1031
1069
|
static get is() { return "bn-chart-time"; }
|
|
1032
1070
|
static get encapsulation() { return "shadow"; }
|
|
@@ -82,6 +82,7 @@ export class TimeChart {
|
|
|
82
82
|
this.chartMode = ChartMode.BAR;
|
|
83
83
|
this.maxBars = 28;
|
|
84
84
|
this.stackConfig = null;
|
|
85
|
+
this.scenarioPropOrder = [];
|
|
85
86
|
this.lineFullWidth = true;
|
|
86
87
|
this.availableWidth = 0;
|
|
87
88
|
this.overflowConfig = null;
|
|
@@ -93,7 +94,7 @@ export class TimeChart {
|
|
|
93
94
|
this.styles = styles;
|
|
94
95
|
this.availableWidth = availableWidth;
|
|
95
96
|
this.setConfig(config);
|
|
96
|
-
this.position = this.createElementPosition(
|
|
97
|
+
this.position = this.createElementPosition(this.lastScenarios);
|
|
97
98
|
}
|
|
98
99
|
updatePosition(scenarios) {
|
|
99
100
|
this.position = this.createElementPosition(scenarios);
|
|
@@ -163,7 +164,8 @@ export class TimeChart {
|
|
|
163
164
|
setConfig(config) {
|
|
164
165
|
var _a;
|
|
165
166
|
this.state = FactoryState.DIRTY;
|
|
166
|
-
this.
|
|
167
|
+
this.scenarioPropOrder = [...config.scenarios];
|
|
168
|
+
const scenarios = this.sortScenariosbyVisualisationRules(config.scenarios);
|
|
167
169
|
this.setSource(config.filter);
|
|
168
170
|
this.hideAxisLabels = config.hideAxisLabels || false;
|
|
169
171
|
this.pixelPerUnit = config.pixelPerUnit;
|
|
@@ -171,7 +173,7 @@ export class TimeChart {
|
|
|
171
173
|
this.axisLabelsMode = config.axisLabelsMode;
|
|
172
174
|
this.intervalSpanLimit = config.intervalSpanLimit;
|
|
173
175
|
this.dateInterval = this.findDateInterval(config.dateInterval);
|
|
174
|
-
this.dataModel = this.populateModel(
|
|
176
|
+
this.dataModel = this.populateModel(scenarios, this.dateInterval, config.level, config.sortOrder);
|
|
175
177
|
this.variancesDataModel = this.populateVarianceModel(config.variances, this.dataModel);
|
|
176
178
|
this.title = config.title || Formatter.translateScenarioLabel((_a = config === null || config === void 0 ? void 0 : config.variances) === null || _a === void 0 ? void 0 : _a.toString(), this.i18n);
|
|
177
179
|
this.smallestDataPointValue = this.findSmallestDataPointValue(this.dataModel);
|
|
@@ -189,8 +191,8 @@ export class TimeChart {
|
|
|
189
191
|
this.maxBars = config.maxBars;
|
|
190
192
|
this.stackConfig = config.stackConfig;
|
|
191
193
|
this.lineFullWidth = config.lineFullWidth;
|
|
192
|
-
this.lastScenarios =
|
|
193
|
-
this.updatePosition(
|
|
194
|
+
this.lastScenarios = scenarios;
|
|
195
|
+
this.updatePosition(scenarios);
|
|
194
196
|
}
|
|
195
197
|
getFooter() {
|
|
196
198
|
if (this.measureScale.value === 1 && this.measureUnit === "") {
|
|
@@ -198,9 +200,10 @@ export class TimeChart {
|
|
|
198
200
|
}
|
|
199
201
|
return Formatter.translateScenarioLabel("in", this.i18n) + " " + this.measureScale.prefix + this.measureUnit;
|
|
200
202
|
}
|
|
201
|
-
|
|
203
|
+
/** Returns a new array; the input keeps the `scenarios` prop order (the config is reused across rebuilds). */
|
|
204
|
+
sortScenariosbyVisualisationRules(scenarios) {
|
|
202
205
|
const self = this;
|
|
203
|
-
|
|
206
|
+
return [...scenarios]
|
|
204
207
|
.sort((n1, n2) => {
|
|
205
208
|
return self.ruleSet.getScenarioSorIndex(n1) - self.ruleSet.getScenarioSorIndex(n2);
|
|
206
209
|
})
|
|
@@ -1004,6 +1007,17 @@ export class TimeChart {
|
|
|
1004
1007
|
};
|
|
1005
1008
|
return columnGroup;
|
|
1006
1009
|
}
|
|
1010
|
+
/** Restore the original `scenarios` prop order for stacked segments (IBCS sort reorders the slots). */
|
|
1011
|
+
sortSegmentsByPropOrder(segments) {
|
|
1012
|
+
if (this.scenarioPropOrder.length === 0)
|
|
1013
|
+
return;
|
|
1014
|
+
const order = this.scenarioPropOrder;
|
|
1015
|
+
segments.sort((a, b) => {
|
|
1016
|
+
const ia = order.indexOf(a.scenario);
|
|
1017
|
+
const ib = order.indexOf(b.scenario);
|
|
1018
|
+
return (ia === -1 ? order.length : ia) - (ib === -1 ? order.length : ib);
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1007
1021
|
/**
|
|
1008
1022
|
* Draw stacked bar columns. Supports stacking by scenario or by data dimension.
|
|
1009
1023
|
* When stacking by scenario with multiple scenario types (e.g. ac+pl),
|
|
@@ -1025,6 +1039,7 @@ export class TimeChart {
|
|
|
1025
1039
|
segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
|
|
1026
1040
|
}
|
|
1027
1041
|
}
|
|
1042
|
+
this.sortSegmentsByPropOrder(segments);
|
|
1028
1043
|
}
|
|
1029
1044
|
else {
|
|
1030
1045
|
const dp = elements["scenario1"];
|
|
@@ -1124,12 +1139,14 @@ export class TimeChart {
|
|
|
1124
1139
|
}
|
|
1125
1140
|
if (segments.length === 0)
|
|
1126
1141
|
return;
|
|
1142
|
+
this.sortSegmentsByPropOrder(segments);
|
|
1127
1143
|
const prefixes = new Set(segments.map((s) => getScenarioPrefix(s.scenario)));
|
|
1128
1144
|
const axisY = this.position.getColumnPositionY();
|
|
1129
1145
|
const xBase = this.position.getColumnCenterPositionX(0) - this.position.getColumnWidth() / 2;
|
|
1130
1146
|
const labelX = xBase - this.position.spacings.labelToColumn;
|
|
1131
1147
|
if (prefixes.size > 1) {
|
|
1132
|
-
// Overlay mode: one header per group
|
|
1148
|
+
// Overlay mode: one header per group — front group centered on its bar,
|
|
1149
|
+
// back groups aligned with their bar's top edge
|
|
1133
1150
|
const groupMap = new Map();
|
|
1134
1151
|
for (const seg of segments) {
|
|
1135
1152
|
const prefix = getScenarioPrefix(seg.scenario);
|
|
@@ -1147,11 +1164,15 @@ export class TimeChart {
|
|
|
1147
1164
|
for (const [prefix, segs] of groupMap) {
|
|
1148
1165
|
groups.push({ prefix, segments: segs });
|
|
1149
1166
|
}
|
|
1150
|
-
groups.forEach((group) => {
|
|
1167
|
+
groups.forEach((group, groupIdx) => {
|
|
1151
1168
|
const groupTotal = group.segments.reduce((sum, s) => sum + Math.abs(s.value), 0);
|
|
1152
1169
|
const pixelPerUnit = group.segments[0].dataPoint.pixelPerUnit;
|
|
1153
1170
|
const groupPixelHeight = this.stackConfig.mode === StackMode.RELATIVE ? pixelPerUnit : groupTotal * pixelPerUnit;
|
|
1154
|
-
|
|
1171
|
+
// The front-most group (drawn last, e.g. AC) is fully visible, so its
|
|
1172
|
+
// label is centered on the bar. Back groups are mostly hidden behind it
|
|
1173
|
+
// and only peek out at the top, so their labels align with the bar's top edge.
|
|
1174
|
+
const isFrontGroup = groupIdx === groups.length - 1;
|
|
1175
|
+
const centerY = isFrontGroup ? axisY - groupPixelHeight / 2 : axisY - groupPixelHeight;
|
|
1155
1176
|
const labelText = this.i18n.get(group.prefix + "1") || group.prefix.toUpperCase();
|
|
1156
1177
|
new Label(headerGroup, labelX, centerY, "STACK_HEADER", labelText, this.styles, HookLocation.Center, HookLocation.Right).forceStringTypeDraw();
|
|
1157
1178
|
});
|
|
@@ -1210,6 +1231,15 @@ export class TimeChart {
|
|
|
1210
1231
|
activeLayers.push(key);
|
|
1211
1232
|
}
|
|
1212
1233
|
}
|
|
1234
|
+
if (isScenarioStack && this.scenarioPropOrder.length > 0) {
|
|
1235
|
+
const order = this.scenarioPropOrder;
|
|
1236
|
+
activeLayers.sort((a, b) => {
|
|
1237
|
+
var _a, _b, _c, _d;
|
|
1238
|
+
const ia = order.indexOf((_b = (_a = dataModel[0][a]) === null || _a === void 0 ? void 0 : _a.scenario) !== null && _b !== void 0 ? _b : "");
|
|
1239
|
+
const ib = order.indexOf((_d = (_c = dataModel[0][b]) === null || _c === void 0 ? void 0 : _c.scenario) !== null && _d !== void 0 ? _d : "");
|
|
1240
|
+
return (ia === -1 ? order.length : ia) - (ib === -1 ? order.length : ib);
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1213
1243
|
// Compute cumulative values
|
|
1214
1244
|
for (let layerIdx = 0; layerIdx < activeLayers.length; layerIdx++) {
|
|
1215
1245
|
const key = activeLayers[layerIdx];
|
|
@@ -14,9 +14,10 @@ import { computeContentHash, decodeCompressedContent } from "../../utils/content
|
|
|
14
14
|
* 1. **SQL** (default) — AlaSQL query against referenced `datasources`.
|
|
15
15
|
* 2. **Static JSON** — set `static="true"` to bypass SQL and write the
|
|
16
16
|
* parsed body directly to the `datasets` store.
|
|
17
|
-
* 3. **URL** — place an `http
|
|
18
|
-
*
|
|
19
|
-
* Set the `interval` prop (in seconds)
|
|
17
|
+
* 3. **URL** — place an `http://`/`https://` URL or a same-origin path
|
|
18
|
+
* starting with `/` in the body to fetch JSON from an HTTP endpoint and
|
|
19
|
+
* write it to the `datasets` store. Set the `interval` prop (in seconds)
|
|
20
|
+
* to enable periodic re-fetching.
|
|
20
21
|
*/
|
|
21
22
|
export class Dataset {
|
|
22
23
|
constructor() {
|
|
@@ -74,7 +75,7 @@ export class Dataset {
|
|
|
74
75
|
}
|
|
75
76
|
// --- Leaving URL mode → clean up ---
|
|
76
77
|
if (this.currentUrl !== null) {
|
|
77
|
-
this.
|
|
78
|
+
this.cancelInFlight();
|
|
78
79
|
this.currentUrl = null;
|
|
79
80
|
}
|
|
80
81
|
let contentHash;
|
|
@@ -192,7 +193,7 @@ export class Dataset {
|
|
|
192
193
|
}
|
|
193
194
|
disconnectedCallback() {
|
|
194
195
|
var _a, _b;
|
|
195
|
-
this.
|
|
196
|
+
this.cancelInFlight();
|
|
196
197
|
if (((_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db) && this.name) {
|
|
197
198
|
const db = this.stores.db.db;
|
|
198
199
|
try {
|
|
@@ -213,10 +214,14 @@ export class Dataset {
|
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
216
|
/**
|
|
216
|
-
* Returns `true` if the text
|
|
217
|
+
* Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
|
|
218
|
+
* URL, or a same-origin path starting with `/` (but not `//`, which is a
|
|
219
|
+
* protocol-relative URL we treat as inline-mode escape).
|
|
217
220
|
*/
|
|
218
221
|
isUrl(text) {
|
|
219
|
-
|
|
222
|
+
if (text.startsWith("http://") || text.startsWith("https://"))
|
|
223
|
+
return true;
|
|
224
|
+
return text.startsWith("/") && !text.startsWith("//");
|
|
220
225
|
}
|
|
221
226
|
/**
|
|
222
227
|
* Fetches JSON from the given URL and stores the result as the dataset.
|
|
@@ -246,19 +251,26 @@ export class Dataset {
|
|
|
246
251
|
this.publish([]);
|
|
247
252
|
}
|
|
248
253
|
}
|
|
249
|
-
/** Stops the polling timer
|
|
250
|
-
|
|
251
|
-
var _a;
|
|
254
|
+
/** Stops the polling timer (does NOT touch any in-flight fetch). */
|
|
255
|
+
clearPollTimer() {
|
|
252
256
|
if (this.pollTimerId !== null) {
|
|
253
257
|
clearInterval(this.pollTimerId);
|
|
254
258
|
this.pollTimerId = null;
|
|
255
259
|
}
|
|
260
|
+
}
|
|
261
|
+
/** Stops the polling timer AND cancels any in-flight fetch. Use only when
|
|
262
|
+
* leaving URL mode entirely (disconnect or body changed to inline). */
|
|
263
|
+
cancelInFlight() {
|
|
264
|
+
var _a;
|
|
265
|
+
this.clearPollTimer();
|
|
256
266
|
(_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
257
267
|
this.abortController = null;
|
|
258
268
|
}
|
|
259
|
-
/** Starts (or restarts) the polling timer if in URL mode with a positive
|
|
269
|
+
/** Starts (or restarts) the polling timer if in URL mode with a positive
|
|
270
|
+
* interval. Does NOT abort the kick-off fetch issued by the caller — it
|
|
271
|
+
* only resets the interval timer. */
|
|
260
272
|
startPolling() {
|
|
261
|
-
this.
|
|
273
|
+
this.clearPollTimer();
|
|
262
274
|
if (this.currentUrl && this.interval > 0) {
|
|
263
275
|
this.pollTimerId = setInterval(() => {
|
|
264
276
|
if (this.currentUrl) {
|
|
@@ -268,7 +280,7 @@ export class Dataset {
|
|
|
268
280
|
}
|
|
269
281
|
}
|
|
270
282
|
render() {
|
|
271
|
-
return h(Host, { key: '
|
|
283
|
+
return h(Host, { key: 'a02f22a7f78c3bd2512e013ff729487c471ba9bf' });
|
|
272
284
|
}
|
|
273
285
|
static get is() { return "bn-dataset"; }
|
|
274
286
|
static get originalStyleUrls() {
|
|
@@ -10,8 +10,8 @@ import { computeContentHash, decodeCompressedContent } from "../../utils/content
|
|
|
10
10
|
* Data can be provided in three ways:
|
|
11
11
|
* 1. **Inline JSON** — Place JSON text inside the element body (default).
|
|
12
12
|
* 2. **Compressed payload** — Set `raw="false"` and provide `<hash>:<base64_gzip>` format.
|
|
13
|
-
* 3. **URL** — Place an `http
|
|
14
|
-
* from
|
|
13
|
+
* 3. **URL** — Place an `http://`/`https://` URL or a same-origin path
|
|
14
|
+
* starting with `/` in the body to fetch JSON from an HTTP endpoint.
|
|
15
15
|
*
|
|
16
16
|
* In URL mode the component fetches JSON from the URL. Set the `interval`
|
|
17
17
|
* prop (in seconds) to enable periodic re-fetching (polling).
|
|
@@ -59,7 +59,7 @@ export class Datasource {
|
|
|
59
59
|
}
|
|
60
60
|
// --- Leaving URL mode → clean up ---
|
|
61
61
|
if (this.currentUrl !== null) {
|
|
62
|
-
this.
|
|
62
|
+
this.cancelInFlight();
|
|
63
63
|
this.currentUrl = null;
|
|
64
64
|
}
|
|
65
65
|
// --- Inline JSON / compressed mode ---
|
|
@@ -103,7 +103,7 @@ export class Datasource {
|
|
|
103
103
|
}
|
|
104
104
|
disconnectedCallback() {
|
|
105
105
|
var _a, _b;
|
|
106
|
-
this.
|
|
106
|
+
this.cancelInFlight();
|
|
107
107
|
const db = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.db) === null || _b === void 0 ? void 0 : _b.db;
|
|
108
108
|
if (db && this.name) {
|
|
109
109
|
if (db.tables[this.name] != null) {
|
|
@@ -118,10 +118,14 @@ export class Datasource {
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
|
-
* Returns `true` if the text
|
|
121
|
+
* Returns `true` if the text is a fetchable URL: an absolute `http(s)://`
|
|
122
|
+
* URL, or a same-origin path starting with `/` (but not `//`, which is a
|
|
123
|
+
* protocol-relative URL we treat as inline-mode escape).
|
|
122
124
|
*/
|
|
123
125
|
isUrl(text) {
|
|
124
|
-
|
|
126
|
+
if (text.startsWith("http://") || text.startsWith("https://"))
|
|
127
|
+
return true;
|
|
128
|
+
return text.startsWith("/") && !text.startsWith("//");
|
|
125
129
|
}
|
|
126
130
|
/**
|
|
127
131
|
* Fetches JSON from the given URL and stores the result.
|
|
@@ -145,19 +149,26 @@ export class Datasource {
|
|
|
145
149
|
this.publish([]);
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
|
-
/** Stops the polling timer
|
|
149
|
-
|
|
150
|
-
var _a;
|
|
152
|
+
/** Stops the polling timer (does NOT touch any in-flight fetch). */
|
|
153
|
+
clearPollTimer() {
|
|
151
154
|
if (this.pollTimerId !== null) {
|
|
152
155
|
clearInterval(this.pollTimerId);
|
|
153
156
|
this.pollTimerId = null;
|
|
154
157
|
}
|
|
158
|
+
}
|
|
159
|
+
/** Stops the polling timer AND cancels any in-flight fetch. Use only when
|
|
160
|
+
* leaving URL mode entirely (disconnect or body changed to inline). */
|
|
161
|
+
cancelInFlight() {
|
|
162
|
+
var _a;
|
|
163
|
+
this.clearPollTimer();
|
|
155
164
|
(_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
156
165
|
this.abortController = null;
|
|
157
166
|
}
|
|
158
|
-
/** Starts (or restarts) the polling timer if in URL mode with a positive
|
|
167
|
+
/** Starts (or restarts) the polling timer if in URL mode with a positive
|
|
168
|
+
* interval. Does NOT abort the kick-off fetch issued by the caller — it
|
|
169
|
+
* only resets the interval timer. */
|
|
159
170
|
startPolling() {
|
|
160
|
-
this.
|
|
171
|
+
this.clearPollTimer();
|
|
161
172
|
if (this.currentUrl && this.interval > 0) {
|
|
162
173
|
this.pollTimerId = setInterval(() => {
|
|
163
174
|
if (this.currentUrl) {
|
|
@@ -167,7 +178,7 @@ export class Datasource {
|
|
|
167
178
|
}
|
|
168
179
|
}
|
|
169
180
|
render() {
|
|
170
|
-
return h(Host, { key: '
|
|
181
|
+
return h(Host, { key: '2af6ade861fa900974deeb1b6bcc4520997a4180' });
|
|
171
182
|
}
|
|
172
183
|
static get is() { return "bn-datasource"; }
|
|
173
184
|
static get originalStyleUrls() {
|
|
@@ -175,11 +175,14 @@ export class LayoutCard {
|
|
|
175
175
|
return "minmax(0, 1fr)";
|
|
176
176
|
return this.calculateFractions(matches[0]);
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
getRowCount(name) {
|
|
179
179
|
const template = this.getTemplatePattern(name);
|
|
180
180
|
const pattern = /"[\w\d\s.]+"/g;
|
|
181
181
|
const matches = template.match(pattern);
|
|
182
|
-
|
|
182
|
+
return matches ? matches.length : 1;
|
|
183
|
+
}
|
|
184
|
+
getGridTemplateRows(name) {
|
|
185
|
+
const rowCount = this.getRowCount(name);
|
|
183
186
|
if (this.cardFitToContent) {
|
|
184
187
|
return Array(rowCount).fill("auto").join(" ");
|
|
185
188
|
}
|
|
@@ -273,7 +276,7 @@ export class LayoutCard {
|
|
|
273
276
|
const arrOfSlots = this.extractSlotNames(style["grid-template-areas"]);
|
|
274
277
|
return (
|
|
275
278
|
// @ts-ignore
|
|
276
|
-
h("bn-card", { key: '
|
|
279
|
+
h("bn-card", { key: '513dd28a363a379adda77f55ea1de0f144589096', styles: this.styles, class: this.setCardClass() }, h("div", { key: '3d354cd83db250d243cfaf8de4abe4c7bfd2ec5b', class: "cardtitle" }, h("bn-title", { key: 'b8dfc27dfe59b8344139e09611bbbe80ab5d5cd1', 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: '69179e29f6ee21589352af938d7fe508a42d26ce' }, h("div", { key: '15c232a8887f01c86b0d977cb2f4fa1fb7b5fd53', style: style, "data-bn-fit-content": this.cardFitToContent ? String(this.getRowCount(this.cardLayout)) : null }, this.getSlots(arrOfSlots))), h("bn-footer", { key: '9f04fc230ea3a419c308a36ab03cb77b58d950f1', text: this.footerText, "page-number": 0, "display-page-number": "false" })));
|
|
277
280
|
}
|
|
278
281
|
static get is() { return "bn-layout-card"; }
|
|
279
282
|
static get encapsulation() { return "shadow"; }
|
|
@@ -143,11 +143,14 @@ export class LayoutPage {
|
|
|
143
143
|
gap: this.pageGridGap + "px",
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
getRowCount(name) {
|
|
147
147
|
const template = this.getTemplateAreas(name);
|
|
148
148
|
const pattern = /"[\w\d\s.]+"/g;
|
|
149
149
|
const matches = template.match(pattern);
|
|
150
|
-
|
|
150
|
+
return matches ? matches.length : 1;
|
|
151
|
+
}
|
|
152
|
+
getGridTemplateRows(name) {
|
|
153
|
+
const rowCount = this.getRowCount(name);
|
|
151
154
|
if (this.pageFitToContent) {
|
|
152
155
|
return Array(rowCount).fill("auto").join(" ");
|
|
153
156
|
}
|
|
@@ -241,7 +244,7 @@ export class LayoutPage {
|
|
|
241
244
|
const arrOfSlots = this.extractSlotNames(style["grid-template-areas"]);
|
|
242
245
|
return (
|
|
243
246
|
// @ts-ignore
|
|
244
|
-
h("bn-page", { key: '
|
|
247
|
+
h("bn-page", { key: 'ff44575cdb898cb284bd5cd2cefbe3fa30557ad7', styles: this.styles, format: this.pageFormat, orientation: this.pageOrientation }, h("bn-message", { key: '76282ce0765669b72a96135f5bbd08296b267c99', text: this.messageText, image: this.messageImage }), h("bn-title", { key: '2493351a6d031f0a015197c83e876969a99647c3', 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: 'f85e7bd896773f867d32d8cfeb6ab71e534db5b2' }, h("div", { key: '8ed820659c9482129670c6d00690ab8d7560dbfc', style: style, "data-bn-fit-content": this.pageFitToContent ? String(this.getRowCount(this.pageLayout)) : null }, this.getSlots(arrOfSlots))), h("bn-footer", { key: 'd796066a1c561d5966882ee3642ebe1ee591e0be', text: this.footerText, "page-number": this.pageNumber, "display-page-number": this.footerDisplayPageNumber })));
|
|
245
248
|
}
|
|
246
249
|
static get is() { return "bn-layout-page"; }
|
|
247
250
|
static get encapsulation() { return "shadow"; }
|