@bino-bi/bn-template-engine 1.0.0-next.62 → 1.0.0-next.64
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-24a8322b.entry.js → p-07c55f50.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +687 -261
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/bn-chart-time/bn-chart-time-renderer/bn-chart-time-renderer.js +8 -8
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +116 -34
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +532 -216
- package/dist/collection/components/bn-chart-time/utils/helper/ElementPositions.js +23 -1
- package/dist/collection/components/bn-chart-time/utils/model/TimeChartComponentConfig.js +15 -8
- package/dist/components/bn-chart-time-renderer.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/p-B8-9TksQ.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +687 -261
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/bn-chart-time/bn-chart-time-renderer/bn-chart-time-renderer.d.ts +2 -2
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +30 -16
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +63 -30
- package/dist/types/components/bn-chart-time/utils/helper/ElementPositions.d.ts +8 -0
- package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +16 -7
- package/dist/types/components.d.ts +8 -8
- package/package.json +1 -1
- package/dist/components/p-Cj1iKmdF.js +0 -1
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s)
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
1
13
|
import { forceUpdate, h, Host, writeTask } from "@stencil/core";
|
|
2
14
|
import { hasInlineJs } from "../../context/scopedDb";
|
|
3
15
|
import { isBlankInput, isValidAxisLabelsMode, isValidDateFormat, isValidInteger, isValidMeasureScale, isNoScenarios, isValidNumber, validateScenarioList, validateStackConfig, validateVariancesList, } from "../../utils/validate";
|
|
@@ -19,6 +31,7 @@ import { observeParentResize } from "../../utils/layoutObserver";
|
|
|
19
31
|
import { VarianceScenario, variancesScenarios } from "../../utils/model/VarianceScenario";
|
|
20
32
|
import { Formatter } from "../../utils/formatter";
|
|
21
33
|
import { AxisLabelsMode, ChartMode, StackBy, StackMode, StackOrder } from "../../utils/constants";
|
|
34
|
+
import { getStores } from "../../context/context-protocol";
|
|
22
35
|
import { DateDistance } from "../../utils/DateStringFactory";
|
|
23
36
|
import { LAYOUT_STATE_VERSION, collectChartFacadeLayout, measure, originsFor, readDiagnostics, readChartBaseline, resolveStandaloneId, } from "../../utils/layoutState";
|
|
24
37
|
import { syncEmptyState } from "../../utils/emptyState";
|
|
@@ -255,38 +268,79 @@ export class Chart {
|
|
|
255
268
|
this.errors.remove(errId);
|
|
256
269
|
}
|
|
257
270
|
}
|
|
258
|
-
|
|
259
|
-
const errId = "
|
|
260
|
-
if (isBlankInput(newValue) || this.
|
|
271
|
+
validateTotals(newValue) {
|
|
272
|
+
const errId = "WARN_totals";
|
|
273
|
+
if (isBlankInput(newValue) || this.parseTotals(newValue) != null) {
|
|
261
274
|
this.errors.remove(errId);
|
|
262
275
|
}
|
|
263
276
|
else {
|
|
264
277
|
this.errors.addOrReplace({
|
|
265
278
|
id: errId,
|
|
266
279
|
type: "warning",
|
|
267
|
-
message: '
|
|
280
|
+
message: 'totals: needs JSON with a unitScaling greater than 0, by one of all, year, quarter, month, week, and aggregation one of sum, average, last. For example {"unitScaling":280}.',
|
|
268
281
|
});
|
|
269
282
|
}
|
|
283
|
+
this.bindTotalsDataset();
|
|
270
284
|
}
|
|
271
|
-
|
|
285
|
+
parseTotals(value) {
|
|
286
|
+
var _a, _b;
|
|
272
287
|
try {
|
|
273
288
|
const parsed = JSON.parse(value);
|
|
274
289
|
// the same values as `unit-scaling`: a number, with an SI suffix, or the name of a scaling group
|
|
275
290
|
const scaling = resolveScalingValue(parsed === null || parsed === void 0 ? void 0 : parsed.unitScaling, this.pixelPerUnitGroupMap);
|
|
276
291
|
if (scaling.kind !== "value" || !(scaling.value > 0))
|
|
277
292
|
return null;
|
|
293
|
+
const by = (_a = parsed.by) !== null && _a !== void 0 ? _a : "all";
|
|
294
|
+
const aggregation = (_b = parsed.aggregation) !== null && _b !== void 0 ? _b : "sum";
|
|
295
|
+
if (!["all", "year", "quarter", "month", "week"].includes(by))
|
|
296
|
+
return null;
|
|
297
|
+
if (!["sum", "average", "last"].includes(aggregation))
|
|
298
|
+
return null;
|
|
278
299
|
const width = Number(parsed.width);
|
|
279
300
|
const label = typeof parsed.label === "string" || typeof parsed.label === "number" ? String(parsed.label) : "";
|
|
280
|
-
return {
|
|
301
|
+
return {
|
|
302
|
+
unitScaling: scaling.value,
|
|
303
|
+
by,
|
|
304
|
+
aggregation,
|
|
305
|
+
label,
|
|
306
|
+
width: width > 0 ? width : 1,
|
|
307
|
+
dataset: typeof parsed.dataset === "string" ? parsed.dataset.trim() : "",
|
|
308
|
+
};
|
|
281
309
|
}
|
|
282
|
-
catch (
|
|
310
|
+
catch (_c) {
|
|
283
311
|
return null;
|
|
284
312
|
}
|
|
285
313
|
}
|
|
286
|
-
/**
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
314
|
+
/** Draws the chart again when the dataset of the totals gets its rows. */
|
|
315
|
+
bindTotalsDataset() {
|
|
316
|
+
var _a, _b;
|
|
317
|
+
// from the plain JSON: the name does not depend on a scaling group that may get its value later
|
|
318
|
+
let name;
|
|
319
|
+
try {
|
|
320
|
+
const dataset = isBlankInput(this.totals) ? "" : (_a = JSON.parse(this.totals)) === null || _a === void 0 ? void 0 : _a.dataset;
|
|
321
|
+
name = typeof dataset === "string" ? dataset.trim() : "";
|
|
322
|
+
}
|
|
323
|
+
catch (_c) {
|
|
324
|
+
name = "";
|
|
325
|
+
}
|
|
326
|
+
// an element that is not in the page has no subscription: it binds when it connects
|
|
327
|
+
if (!this.element.isConnected)
|
|
328
|
+
return;
|
|
329
|
+
if (name === this.totalsDatasetName)
|
|
330
|
+
return;
|
|
331
|
+
(_b = this.totalsDatasetUnsubscribe) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
332
|
+
this.totalsDatasetUnsubscribe = null;
|
|
333
|
+
this.totalsDatasetName = name;
|
|
334
|
+
if (name) {
|
|
335
|
+
this.totalsDatasetUnsubscribe = getStores(this.element).db.subscribe(name, () => {
|
|
336
|
+
this.dataVersion++;
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/** The totals in the units of the inner chart: pixels for one data unit. */
|
|
341
|
+
prepareTotals() {
|
|
342
|
+
const parsed = isBlankInput(this.totals) ? null : this.parseTotals(this.totals);
|
|
343
|
+
const errId = "WARN_totals_unitScaling";
|
|
290
344
|
if (parsed == null) {
|
|
291
345
|
this.errors.remove(errId);
|
|
292
346
|
return null;
|
|
@@ -296,12 +350,22 @@ export class Chart {
|
|
|
296
350
|
this.errors.addOrReplace({
|
|
297
351
|
id: errId,
|
|
298
352
|
type: "warning",
|
|
299
|
-
message: "
|
|
353
|
+
message: "totals: needs a fixed unitScaling of the chart, the total columns are not drawn.",
|
|
354
|
+
});
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
// without the columns each variance row would decide on its own which periods have a total
|
|
358
|
+
if (this.hidesScenarios()) {
|
|
359
|
+
this.errors.addOrReplace({
|
|
360
|
+
id: errId,
|
|
361
|
+
type: "warning",
|
|
362
|
+
message: "totals: needs the columns of the chart, a chart with scenarios none draws no total columns.",
|
|
300
363
|
});
|
|
301
364
|
return null;
|
|
302
365
|
}
|
|
303
366
|
this.errors.remove(errId);
|
|
304
|
-
|
|
367
|
+
const { unitScaling } = parsed, rest = __rest(parsed, ["unitScaling"]);
|
|
368
|
+
return Object.assign(Object.assign({}, rest), { pixelPerUnit: this.getEffectiveFontPx() / unitScaling });
|
|
305
369
|
}
|
|
306
370
|
validateAxisLabelsStep(newValue) {
|
|
307
371
|
const errId = "WARN_axisLabelsStep";
|
|
@@ -504,22 +568,33 @@ export class Chart {
|
|
|
504
568
|
*/
|
|
505
569
|
this.axisLabelsStep = 1;
|
|
506
570
|
/**
|
|
507
|
-
*
|
|
508
|
-
*
|
|
571
|
+
* Total columns at their own scale, as JSON:
|
|
572
|
+
* `{"by":"all","aggregation":"sum","unitScaling":280,"label":"2025","width":1.6}`.
|
|
509
573
|
*
|
|
510
574
|
* - `unitScaling` - data units per em of column height, like `unit-scaling`. Required.
|
|
511
|
-
* - `
|
|
575
|
+
* - `by` - what a total covers. `all` (default): one column right of the last
|
|
576
|
+
* period for all periods. `year`, `quarter`, `month`, `week`: one column
|
|
577
|
+
* behind the periods of each of them, on the axis.
|
|
578
|
+
* - `aggregation` - `sum` (default), `average` or `last`. With `sum` a column
|
|
579
|
+
* stacks one part per scenario of the series: the first scenario, and with
|
|
580
|
+
* `scenario-switch` the ones that follow it. Else it is one column, hatched
|
|
581
|
+
* when a forecast is in its value and outlined for a plan.
|
|
582
|
+
* - `dataset` - name of a dataset with one row per total (`date` and the
|
|
583
|
+
* scenario columns). The chart takes the values from it and computes none.
|
|
584
|
+
* With `average` or `last` the values of a row are one column.
|
|
585
|
+
* - `label` - text under the column of `by: all`. The other columns take the name of their period.
|
|
512
586
|
* - `width` - width in widths of a period column, default 1.
|
|
513
587
|
*
|
|
514
|
-
* The
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
* and every part of the total must be positive.
|
|
588
|
+
* The first other scenario is the reference behind a column. Each variance
|
|
589
|
+
* row gets the variance of each total at the scale of the row. With
|
|
590
|
+
* `scaling-indicator` a column has its own band, and with `by: all` a line
|
|
591
|
+
* links it to the band of the periods. Plain columns only: not with `stack`
|
|
592
|
+
* and not in line mode. The chart needs a fixed `unit-scaling`, and every
|
|
593
|
+
* part of a total must be positive.
|
|
521
594
|
*/
|
|
522
|
-
this.
|
|
595
|
+
this.totals = "";
|
|
596
|
+
this.totalsDatasetUnsubscribe = null;
|
|
597
|
+
this.totalsDatasetName = "";
|
|
523
598
|
/**
|
|
524
599
|
* For a series that changes its scenario along the time axis, for example
|
|
525
600
|
* AC up to this year and PL after it. In a period where the first scenario
|
|
@@ -624,7 +699,7 @@ export class Chart {
|
|
|
624
699
|
this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal);
|
|
625
700
|
this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent);
|
|
626
701
|
this.validateAxisLabelsStep(this.axisLabelsStep);
|
|
627
|
-
this.
|
|
702
|
+
this.validateTotals(this.totals);
|
|
628
703
|
this.validateAxisTitlePosition(this.axisTitlePosition);
|
|
629
704
|
}
|
|
630
705
|
/**
|
|
@@ -835,9 +910,16 @@ export class Chart {
|
|
|
835
910
|
};
|
|
836
911
|
this._settleTimer = setTimeout(check, delays.shift());
|
|
837
912
|
}
|
|
913
|
+
connectedCallback() {
|
|
914
|
+
// an element that is moved in the page comes back without its subscription
|
|
915
|
+
this.bindTotalsDataset();
|
|
916
|
+
}
|
|
838
917
|
disconnectedCallback() {
|
|
839
|
-
var _a;
|
|
840
|
-
(_a = this.
|
|
918
|
+
var _a, _b;
|
|
919
|
+
(_a = this.totalsDatasetUnsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
920
|
+
this.totalsDatasetUnsubscribe = null;
|
|
921
|
+
this.totalsDatasetName = "";
|
|
922
|
+
(_b = this.layoutObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
841
923
|
this.layoutObserver = null;
|
|
842
924
|
if (this._settleTimer != null) {
|
|
843
925
|
clearTimeout(this._settleTimer);
|
|
@@ -1290,7 +1372,7 @@ export class Chart {
|
|
|
1290
1372
|
percent: this.dataFormatDigitsPercent,
|
|
1291
1373
|
decimal: this.dataFormatDigitsDecimal,
|
|
1292
1374
|
percentSign: this.dataFormatPercentSign !== false,
|
|
1293
|
-
}, axisLabelsStep: Math.max(1, Math.floor(Number(this.axisLabelsStep) || 1)), scalingIndicator: Number(this.scalingIndicator) || 0,
|
|
1375
|
+
}, axisLabelsStep: Math.max(1, Math.floor(Number(this.axisLabelsStep) || 1)), scalingIndicator: Number(this.scalingIndicator) || 0, totals: this.prepareTotals(), scenarioSwitch: this.scenarioSwitch, axisTitlePosition: this.prepareAxisTitlePosition(), containerWidth: fullParentWidth, parentDimensions: this.prepareDimension(isBase), ruleSetConfig: this.ruleSetConfig() }));
|
|
1294
1376
|
}
|
|
1295
1377
|
/**
|
|
1296
1378
|
* The line this chart wants to be aligned on, in CSS px from the host's
|
|
@@ -1422,7 +1504,7 @@ export class Chart {
|
|
|
1422
1504
|
this.errors.remove("WARN_scenarios_none");
|
|
1423
1505
|
}
|
|
1424
1506
|
const fontStyles = this.getFontStyles();
|
|
1425
|
-
return (h(Host, { key: '
|
|
1507
|
+
return (h(Host, { key: 'baa11d12a8dc2e01a487b02bcd68902890ceb85a', style: fontStyles }, h("div", { key: '40a33368366a59709c8a6c0354a6aca50445778f', class: "container" }, segments.map(this.chartTemplate))));
|
|
1426
1508
|
}
|
|
1427
1509
|
static get is() { return "bn-chart-time"; }
|
|
1428
1510
|
static get encapsulation() { return "shadow"; }
|
|
@@ -2050,7 +2132,7 @@ export class Chart {
|
|
|
2050
2132
|
"reflect": false,
|
|
2051
2133
|
"attribute": "scaling-indicator"
|
|
2052
2134
|
},
|
|
2053
|
-
"
|
|
2135
|
+
"totals": {
|
|
2054
2136
|
"type": "string",
|
|
2055
2137
|
"mutable": false,
|
|
2056
2138
|
"complexType": {
|
|
@@ -2062,12 +2144,12 @@ export class Chart {
|
|
|
2062
2144
|
"optional": false,
|
|
2063
2145
|
"docs": {
|
|
2064
2146
|
"tags": [],
|
|
2065
|
-
"text": "
|
|
2147
|
+
"text": "Total columns at their own scale, as JSON:\n`{\"by\":\"all\",\"aggregation\":\"sum\",\"unitScaling\":280,\"label\":\"2025\",\"width\":1.6}`.\n\n- `unitScaling` - data units per em of column height, like `unit-scaling`. Required.\n- `by` - what a total covers. `all` (default): one column right of the last\n period for all periods. `year`, `quarter`, `month`, `week`: one column\n behind the periods of each of them, on the axis.\n- `aggregation` - `sum` (default), `average` or `last`. With `sum` a column\n stacks one part per scenario of the series: the first scenario, and with\n `scenario-switch` the ones that follow it. Else it is one column, hatched\n when a forecast is in its value and outlined for a plan.\n- `dataset` - name of a dataset with one row per total (`date` and the\n scenario columns). The chart takes the values from it and computes none.\n With `average` or `last` the values of a row are one column.\n- `label` - text under the column of `by: all`. The other columns take the name of their period.\n- `width` - width in widths of a period column, default 1.\n\nThe first other scenario is the reference behind a column. Each variance\nrow gets the variance of each total at the scale of the row. With\n`scaling-indicator` a column has its own band, and with `by: all` a line\nlinks it to the band of the periods. Plain columns only: not with `stack`\nand not in line mode. The chart needs a fixed `unit-scaling`, and every\npart of a total must be positive."
|
|
2066
2148
|
},
|
|
2067
2149
|
"getter": false,
|
|
2068
2150
|
"setter": false,
|
|
2069
2151
|
"reflect": false,
|
|
2070
|
-
"attribute": "
|
|
2152
|
+
"attribute": "totals",
|
|
2071
2153
|
"defaultValue": "\"\""
|
|
2072
2154
|
},
|
|
2073
2155
|
"scenarioSwitch": {
|
|
@@ -2231,8 +2313,8 @@ export class Chart {
|
|
|
2231
2313
|
"propName": "dataFormatDigitsPercent",
|
|
2232
2314
|
"methodName": "validateDataFormatDigitsPercent"
|
|
2233
2315
|
}, {
|
|
2234
|
-
"propName": "
|
|
2235
|
-
"methodName": "
|
|
2316
|
+
"propName": "totals",
|
|
2317
|
+
"methodName": "validateTotals"
|
|
2236
2318
|
}, {
|
|
2237
2319
|
"propName": "axisLabelsStep",
|
|
2238
2320
|
"methodName": "validateAxisLabelsStep"
|