@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
|
@@ -476,7 +476,7 @@ function matchPoint(state, point) {
|
|
|
476
476
|
|
|
477
477
|
const bnAnnotationLayerCss = () => `:host{position:absolute;inset:0;z-index:1;display:block;pointer-events:none;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px)}svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}.badge-text{fill:#ffffff;font-weight:bold;text-anchor:middle;dominant-baseline:central}.mark-text{fill:#000000;dominant-baseline:central}.mark-text.caption{text-anchor:middle;font-size:0.9em}.mark-text .percent{font-size:0.85em}.difference-line{stroke:#000000;stroke-width:0.75}`;
|
|
478
478
|
|
|
479
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
479
|
+
var __rest$1 = (undefined && undefined.__rest) || function (s, e) {
|
|
480
480
|
var t = {};
|
|
481
481
|
for (var p in s)
|
|
482
482
|
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -734,7 +734,7 @@ const AnnotationLayer = class {
|
|
|
734
734
|
if (!visual || !state || !item.point)
|
|
735
735
|
return undefined;
|
|
736
736
|
const host = visual.getBoundingClientRect();
|
|
737
|
-
const _a = item.point, series = __rest(_a, ["rowGroup", "category", "subCategory", "date"]);
|
|
737
|
+
const _a = item.point, series = __rest$1(_a, ["rowGroup", "category", "subCategory", "date"]);
|
|
738
738
|
const bars = matchPoint(state, Object.assign(Object.assign({}, series), { part: "element" })).filter((bar) => bar.value != null);
|
|
739
739
|
const all = bars.reduce((sum, bar) => sum + bar.value, 0);
|
|
740
740
|
const inside = bars
|
|
@@ -20192,6 +20192,18 @@ function settleHeightBonus(current, measured) {
|
|
|
20192
20192
|
|
|
20193
20193
|
const bnChartTimeCss = () => `:host(.no-data){display:block;box-sizing:border-box;width:100%;height:100%}:host(.no-data)>div{float:none;width:100%;height:100%}:host(.no-data) .no-data~.no-data{display:none}.empty-state{box-sizing:border-box;display:flex;align-items:center;justify-content:center;float:none;width:100%;height:100%;min-height:3em;margin:0;padding:0.5em;overflow:hidden;border:0.1em dashed #ddd;color:#808080;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);font-style:normal;text-align:center}:host{display:inline-block;position:relative;overflow:hidden;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.container{display:flex;flex-direction:column-reverse}.background-image{display:flex;flex-wrap:wrap;justify-content:flex-end}`;
|
|
20194
20194
|
|
|
20195
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
20196
|
+
var t = {};
|
|
20197
|
+
for (var p in s)
|
|
20198
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
20199
|
+
t[p] = s[p];
|
|
20200
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
20201
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
20202
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20203
|
+
t[p[i]] = s[p[i]];
|
|
20204
|
+
}
|
|
20205
|
+
return t;
|
|
20206
|
+
};
|
|
20195
20207
|
const Chart = class {
|
|
20196
20208
|
validateFilter(newValue) {
|
|
20197
20209
|
const errId = "ERR_filter";
|
|
@@ -20415,38 +20427,79 @@ const Chart = class {
|
|
|
20415
20427
|
this.errors.remove(errId);
|
|
20416
20428
|
}
|
|
20417
20429
|
}
|
|
20418
|
-
|
|
20419
|
-
const errId = "
|
|
20420
|
-
if (isBlankInput(newValue) || this.
|
|
20430
|
+
validateTotals(newValue) {
|
|
20431
|
+
const errId = "WARN_totals";
|
|
20432
|
+
if (isBlankInput(newValue) || this.parseTotals(newValue) != null) {
|
|
20421
20433
|
this.errors.remove(errId);
|
|
20422
20434
|
}
|
|
20423
20435
|
else {
|
|
20424
20436
|
this.errors.addOrReplace({
|
|
20425
20437
|
id: errId,
|
|
20426
20438
|
type: "warning",
|
|
20427
|
-
message: '
|
|
20439
|
+
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}.',
|
|
20428
20440
|
});
|
|
20429
20441
|
}
|
|
20442
|
+
this.bindTotalsDataset();
|
|
20430
20443
|
}
|
|
20431
|
-
|
|
20444
|
+
parseTotals(value) {
|
|
20445
|
+
var _a, _b;
|
|
20432
20446
|
try {
|
|
20433
20447
|
const parsed = JSON.parse(value);
|
|
20434
20448
|
// the same values as `unit-scaling`: a number, with an SI suffix, or the name of a scaling group
|
|
20435
20449
|
const scaling = resolveScalingValue(parsed === null || parsed === void 0 ? void 0 : parsed.unitScaling, this.pixelPerUnitGroupMap);
|
|
20436
20450
|
if (scaling.kind !== "value" || !(scaling.value > 0))
|
|
20437
20451
|
return null;
|
|
20452
|
+
const by = (_a = parsed.by) !== null && _a !== void 0 ? _a : "all";
|
|
20453
|
+
const aggregation = (_b = parsed.aggregation) !== null && _b !== void 0 ? _b : "sum";
|
|
20454
|
+
if (!["all", "year", "quarter", "month", "week"].includes(by))
|
|
20455
|
+
return null;
|
|
20456
|
+
if (!["sum", "average", "last"].includes(aggregation))
|
|
20457
|
+
return null;
|
|
20438
20458
|
const width = Number(parsed.width);
|
|
20439
20459
|
const label = typeof parsed.label === "string" || typeof parsed.label === "number" ? String(parsed.label) : "";
|
|
20440
|
-
return {
|
|
20460
|
+
return {
|
|
20461
|
+
unitScaling: scaling.value,
|
|
20462
|
+
by,
|
|
20463
|
+
aggregation,
|
|
20464
|
+
label,
|
|
20465
|
+
width: width > 0 ? width : 1,
|
|
20466
|
+
dataset: typeof parsed.dataset === "string" ? parsed.dataset.trim() : "",
|
|
20467
|
+
};
|
|
20441
20468
|
}
|
|
20442
|
-
catch (
|
|
20469
|
+
catch (_c) {
|
|
20443
20470
|
return null;
|
|
20444
20471
|
}
|
|
20445
20472
|
}
|
|
20446
|
-
/**
|
|
20447
|
-
|
|
20448
|
-
|
|
20449
|
-
|
|
20473
|
+
/** Draws the chart again when the dataset of the totals gets its rows. */
|
|
20474
|
+
bindTotalsDataset() {
|
|
20475
|
+
var _a, _b;
|
|
20476
|
+
// from the plain JSON: the name does not depend on a scaling group that may get its value later
|
|
20477
|
+
let name;
|
|
20478
|
+
try {
|
|
20479
|
+
const dataset = isBlankInput(this.totals) ? "" : (_a = JSON.parse(this.totals)) === null || _a === void 0 ? void 0 : _a.dataset;
|
|
20480
|
+
name = typeof dataset === "string" ? dataset.trim() : "";
|
|
20481
|
+
}
|
|
20482
|
+
catch (_c) {
|
|
20483
|
+
name = "";
|
|
20484
|
+
}
|
|
20485
|
+
// an element that is not in the page has no subscription: it binds when it connects
|
|
20486
|
+
if (!this.element.isConnected)
|
|
20487
|
+
return;
|
|
20488
|
+
if (name === this.totalsDatasetName)
|
|
20489
|
+
return;
|
|
20490
|
+
(_b = this.totalsDatasetUnsubscribe) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
20491
|
+
this.totalsDatasetUnsubscribe = null;
|
|
20492
|
+
this.totalsDatasetName = name;
|
|
20493
|
+
if (name) {
|
|
20494
|
+
this.totalsDatasetUnsubscribe = getStores(this.element).db.subscribe(name, () => {
|
|
20495
|
+
this.dataVersion++;
|
|
20496
|
+
});
|
|
20497
|
+
}
|
|
20498
|
+
}
|
|
20499
|
+
/** The totals in the units of the inner chart: pixels for one data unit. */
|
|
20500
|
+
prepareTotals() {
|
|
20501
|
+
const parsed = isBlankInput(this.totals) ? null : this.parseTotals(this.totals);
|
|
20502
|
+
const errId = "WARN_totals_unitScaling";
|
|
20450
20503
|
if (parsed == null) {
|
|
20451
20504
|
this.errors.remove(errId);
|
|
20452
20505
|
return null;
|
|
@@ -20456,12 +20509,22 @@ const Chart = class {
|
|
|
20456
20509
|
this.errors.addOrReplace({
|
|
20457
20510
|
id: errId,
|
|
20458
20511
|
type: "warning",
|
|
20459
|
-
message: "
|
|
20512
|
+
message: "totals: needs a fixed unitScaling of the chart, the total columns are not drawn.",
|
|
20513
|
+
});
|
|
20514
|
+
return null;
|
|
20515
|
+
}
|
|
20516
|
+
// without the columns each variance row would decide on its own which periods have a total
|
|
20517
|
+
if (this.hidesScenarios()) {
|
|
20518
|
+
this.errors.addOrReplace({
|
|
20519
|
+
id: errId,
|
|
20520
|
+
type: "warning",
|
|
20521
|
+
message: "totals: needs the columns of the chart, a chart with scenarios none draws no total columns.",
|
|
20460
20522
|
});
|
|
20461
20523
|
return null;
|
|
20462
20524
|
}
|
|
20463
20525
|
this.errors.remove(errId);
|
|
20464
|
-
|
|
20526
|
+
const { unitScaling } = parsed, rest = __rest(parsed, ["unitScaling"]);
|
|
20527
|
+
return Object.assign(Object.assign({}, rest), { pixelPerUnit: this.getEffectiveFontPx() / unitScaling });
|
|
20465
20528
|
}
|
|
20466
20529
|
validateAxisLabelsStep(newValue) {
|
|
20467
20530
|
const errId = "WARN_axisLabelsStep";
|
|
@@ -20665,22 +20728,33 @@ const Chart = class {
|
|
|
20665
20728
|
*/
|
|
20666
20729
|
this.axisLabelsStep = 1;
|
|
20667
20730
|
/**
|
|
20668
|
-
*
|
|
20669
|
-
*
|
|
20731
|
+
* Total columns at their own scale, as JSON:
|
|
20732
|
+
* `{"by":"all","aggregation":"sum","unitScaling":280,"label":"2025","width":1.6}`.
|
|
20670
20733
|
*
|
|
20671
20734
|
* - `unitScaling` - data units per em of column height, like `unit-scaling`. Required.
|
|
20672
|
-
* - `
|
|
20735
|
+
* - `by` - what a total covers. `all` (default): one column right of the last
|
|
20736
|
+
* period for all periods. `year`, `quarter`, `month`, `week`: one column
|
|
20737
|
+
* behind the periods of each of them, on the axis.
|
|
20738
|
+
* - `aggregation` - `sum` (default), `average` or `last`. With `sum` a column
|
|
20739
|
+
* stacks one part per scenario of the series: the first scenario, and with
|
|
20740
|
+
* `scenario-switch` the ones that follow it. Else it is one column, hatched
|
|
20741
|
+
* when a forecast is in its value and outlined for a plan.
|
|
20742
|
+
* - `dataset` - name of a dataset with one row per total (`date` and the
|
|
20743
|
+
* scenario columns). The chart takes the values from it and computes none.
|
|
20744
|
+
* With `average` or `last` the values of a row are one column.
|
|
20745
|
+
* - `label` - text under the column of `by: all`. The other columns take the name of their period.
|
|
20673
20746
|
* - `width` - width in widths of a period column, default 1.
|
|
20674
20747
|
*
|
|
20675
|
-
* The
|
|
20676
|
-
*
|
|
20677
|
-
*
|
|
20678
|
-
*
|
|
20679
|
-
*
|
|
20680
|
-
*
|
|
20681
|
-
* and every part of the total must be positive.
|
|
20748
|
+
* The first other scenario is the reference behind a column. Each variance
|
|
20749
|
+
* row gets the variance of each total at the scale of the row. With
|
|
20750
|
+
* `scaling-indicator` a column has its own band, and with `by: all` a line
|
|
20751
|
+
* links it to the band of the periods. Plain columns only: not with `stack`
|
|
20752
|
+
* and not in line mode. The chart needs a fixed `unit-scaling`, and every
|
|
20753
|
+
* part of a total must be positive.
|
|
20682
20754
|
*/
|
|
20683
|
-
this.
|
|
20755
|
+
this.totals = "";
|
|
20756
|
+
this.totalsDatasetUnsubscribe = null;
|
|
20757
|
+
this.totalsDatasetName = "";
|
|
20684
20758
|
/**
|
|
20685
20759
|
* For a series that changes its scenario along the time axis, for example
|
|
20686
20760
|
* AC up to this year and PL after it. In a period where the first scenario
|
|
@@ -20785,7 +20859,7 @@ const Chart = class {
|
|
|
20785
20859
|
this.validateDataFormatDigitsDecimal(this.dataFormatDigitsDecimal);
|
|
20786
20860
|
this.validateDataFormatDigitsPercent(this.dataFormatDigitsPercent);
|
|
20787
20861
|
this.validateAxisLabelsStep(this.axisLabelsStep);
|
|
20788
|
-
this.
|
|
20862
|
+
this.validateTotals(this.totals);
|
|
20789
20863
|
this.validateAxisTitlePosition(this.axisTitlePosition);
|
|
20790
20864
|
}
|
|
20791
20865
|
/**
|
|
@@ -20996,9 +21070,16 @@ const Chart = class {
|
|
|
20996
21070
|
};
|
|
20997
21071
|
this._settleTimer = setTimeout(check, delays.shift());
|
|
20998
21072
|
}
|
|
21073
|
+
connectedCallback() {
|
|
21074
|
+
// an element that is moved in the page comes back without its subscription
|
|
21075
|
+
this.bindTotalsDataset();
|
|
21076
|
+
}
|
|
20999
21077
|
disconnectedCallback() {
|
|
21000
|
-
var _a;
|
|
21001
|
-
(_a = this.
|
|
21078
|
+
var _a, _b;
|
|
21079
|
+
(_a = this.totalsDatasetUnsubscribe) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
21080
|
+
this.totalsDatasetUnsubscribe = null;
|
|
21081
|
+
this.totalsDatasetName = "";
|
|
21082
|
+
(_b = this.layoutObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
21002
21083
|
this.layoutObserver = null;
|
|
21003
21084
|
if (this._settleTimer != null) {
|
|
21004
21085
|
clearTimeout(this._settleTimer);
|
|
@@ -21451,7 +21532,7 @@ const Chart = class {
|
|
|
21451
21532
|
percent: this.dataFormatDigitsPercent,
|
|
21452
21533
|
decimal: this.dataFormatDigitsDecimal,
|
|
21453
21534
|
percentSign: this.dataFormatPercentSign !== false,
|
|
21454
|
-
}, axisLabelsStep: Math.max(1, Math.floor(Number(this.axisLabelsStep) || 1)), scalingIndicator: Number(this.scalingIndicator) || 0,
|
|
21535
|
+
}, 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() }));
|
|
21455
21536
|
}
|
|
21456
21537
|
/**
|
|
21457
21538
|
* The line this chart wants to be aligned on, in CSS px from the host's
|
|
@@ -21583,7 +21664,7 @@ const Chart = class {
|
|
|
21583
21664
|
this.errors.remove("WARN_scenarios_none");
|
|
21584
21665
|
}
|
|
21585
21666
|
const fontStyles = this.getFontStyles();
|
|
21586
|
-
return (h(Host, { key: '
|
|
21667
|
+
return (h(Host, { key: 'baa11d12a8dc2e01a487b02bcd68902890ceb85a', style: fontStyles }, h("div", { key: '40a33368366a59709c8a6c0354a6aca50445778f', class: "container" }, segments.map(this.chartTemplate))));
|
|
21587
21668
|
}
|
|
21588
21669
|
get element() { return getElement(this); }
|
|
21589
21670
|
static get watchers() { return {
|
|
@@ -21632,8 +21713,8 @@ const Chart = class {
|
|
|
21632
21713
|
"dataFormatDigitsPercent": [{
|
|
21633
21714
|
"validateDataFormatDigitsPercent": 0
|
|
21634
21715
|
}],
|
|
21635
|
-
"
|
|
21636
|
-
"
|
|
21716
|
+
"totals": [{
|
|
21717
|
+
"validateTotals": 0
|
|
21637
21718
|
}],
|
|
21638
21719
|
"axisLabelsStep": [{
|
|
21639
21720
|
"validateAxisLabelsStep": 0
|
|
@@ -21769,6 +21850,11 @@ class ElementPositions {
|
|
|
21769
21850
|
width: 0,
|
|
21770
21851
|
height: 0,
|
|
21771
21852
|
};
|
|
21853
|
+
/**
|
|
21854
|
+
* Places on the axis in category widths, by index: the periods first, then
|
|
21855
|
+
* the total columns. Without it the place of an index is the index itself.
|
|
21856
|
+
*/
|
|
21857
|
+
this.slots = null;
|
|
21772
21858
|
this.padding = padding;
|
|
21773
21859
|
this.scaleFactors = scaleFactors;
|
|
21774
21860
|
this.fontStlye = fontstyle;
|
|
@@ -21792,10 +21878,27 @@ class ElementPositions {
|
|
|
21792
21878
|
}).height;
|
|
21793
21879
|
return height * 1.1;
|
|
21794
21880
|
}
|
|
21881
|
+
setSlots(slots) {
|
|
21882
|
+
this.slots = slots;
|
|
21883
|
+
}
|
|
21884
|
+
/** The place of an index on the axis, in category widths. Between two indexes it lies between their places. */
|
|
21885
|
+
slotOf(index) {
|
|
21886
|
+
const slots = this.slots;
|
|
21887
|
+
if (slots == null || slots.length === 0) {
|
|
21888
|
+
return index;
|
|
21889
|
+
}
|
|
21890
|
+
const last = slots.length - 1;
|
|
21891
|
+
if (index <= 0)
|
|
21892
|
+
return slots[0] + index;
|
|
21893
|
+
if (index >= last)
|
|
21894
|
+
return slots[last] + (index - last);
|
|
21895
|
+
const low = Math.floor(index);
|
|
21896
|
+
return slots[low] + (slots[low + 1] - slots[low]) * (index - low);
|
|
21897
|
+
}
|
|
21795
21898
|
getColumnCenterPositionX(index) {
|
|
21796
21899
|
return (this.categoryPosition.y +
|
|
21797
21900
|
this.spacings.scenarioOffset +
|
|
21798
|
-
index * this.spacings.categoryWidth +
|
|
21901
|
+
this.slotOf(index) * this.spacings.categoryWidth +
|
|
21799
21902
|
this.leftSideLabelLength +
|
|
21800
21903
|
this.spacings.columnWidth * 0.5);
|
|
21801
21904
|
}
|
|
@@ -23968,8 +24071,9 @@ class TimeChart {
|
|
|
23968
24071
|
this.lastScenarios = [];
|
|
23969
24072
|
this.axisLabelsStep = 1;
|
|
23970
24073
|
this.scalingIndicator = 0;
|
|
23971
|
-
this.
|
|
23972
|
-
this.
|
|
24074
|
+
this.totals = null;
|
|
24075
|
+
this.totalColumns = [];
|
|
24076
|
+
this.totalVariances = [];
|
|
23973
24077
|
this.highestColumnDataPointValue = new DataPoint(0, "default", 0, Scenario.NEU);
|
|
23974
24078
|
this.highestPeriodVarianceDataPointValue = new DataPoint(0, "default", 0, Scenario.NEU);
|
|
23975
24079
|
this.scenarioSwitch = false;
|
|
@@ -24072,7 +24176,7 @@ class TimeChart {
|
|
|
24072
24176
|
this.intervalSpanLimit = config.intervalSpanLimit;
|
|
24073
24177
|
this.axisLabelsStep = (_a = config.axisLabelsStep) !== null && _a !== void 0 ? _a : 1;
|
|
24074
24178
|
this.scalingIndicator = (_b = config.scalingIndicator) !== null && _b !== void 0 ? _b : 0;
|
|
24075
|
-
this.
|
|
24179
|
+
this.totals = (_c = config.totals) !== null && _c !== void 0 ? _c : null;
|
|
24076
24180
|
this.scenarioSwitch = (_d = config.scenarioSwitch) !== null && _d !== void 0 ? _d : false;
|
|
24077
24181
|
this.axisTitlePosition = (_e = config.axisTitlePosition) !== null && _e !== void 0 ? _e : "left";
|
|
24078
24182
|
this.dateInterval = this.findDateInterval(config.dateInterval);
|
|
@@ -24124,13 +24228,16 @@ class TimeChart {
|
|
|
24124
24228
|
this.highestColumnDataPointValue = this.highestDataPointValue;
|
|
24125
24229
|
// the highest period variance: a break mark is for a variance of a period, the total has its own cut
|
|
24126
24230
|
this.highestPeriodVarianceDataPointValue = this.highestVarianceDataPointValue;
|
|
24127
|
-
this.
|
|
24128
|
-
|
|
24129
|
-
|
|
24130
|
-
|
|
24231
|
+
this.totalColumns = this.computeTotalColumns();
|
|
24232
|
+
this.totalVariances = this.computeTotalVariances();
|
|
24233
|
+
for (const point of this.totalVariances) {
|
|
24234
|
+
if (point == null || !Number.isFinite(point.value))
|
|
24235
|
+
continue;
|
|
24236
|
+
if (point.value > Number(this.highestVarianceDataPointValue.value)) {
|
|
24237
|
+
this.highestVarianceDataPointValue = point;
|
|
24131
24238
|
}
|
|
24132
|
-
if (
|
|
24133
|
-
this.smallestVarianceDataPointValue =
|
|
24239
|
+
if (point.value < Number(this.smallestVarianceDataPointValue.value)) {
|
|
24240
|
+
this.smallestVarianceDataPointValue = point;
|
|
24134
24241
|
}
|
|
24135
24242
|
}
|
|
24136
24243
|
if (this.hasScalingIndicator() && this.scalingIndicator > Number(this.highestDataPointValue.value)) {
|
|
@@ -24139,7 +24246,7 @@ class TimeChart {
|
|
|
24139
24246
|
this.highestDataPointValue = new DataPoint(this.scalingIndicator, scenario, this.pixelPerUnit, variance);
|
|
24140
24247
|
}
|
|
24141
24248
|
// the total column has its own scale: it counts for the height with the pixels it needs
|
|
24142
|
-
const totalHeight = this.isVarianceChart() ? 0 : this.
|
|
24249
|
+
const totalHeight = this.isVarianceChart() ? 0 : this.totalsHeight();
|
|
24143
24250
|
if (totalHeight > this.highestDataPointValue.getScaledUnit() && this.pixelPerUnit > 0) {
|
|
24144
24251
|
const { scenario, variance } = this.highestDataPointValue;
|
|
24145
24252
|
this.highestDataPointValue = new DataPoint(totalHeight / this.pixelPerUnit, scenario, this.pixelPerUnit, variance);
|
|
@@ -24259,8 +24366,8 @@ class TimeChart {
|
|
|
24259
24366
|
}).width;
|
|
24260
24367
|
indicatorEnd = this.scalingIndicatorLabelX() + textWidth + this.styles.padding.right;
|
|
24261
24368
|
}
|
|
24262
|
-
const totalEnd = this.
|
|
24263
|
-
? this.
|
|
24369
|
+
const totalEnd = this.hasEndTotal()
|
|
24370
|
+
? this.totalGeometry(0).right + this.endTotalTextWidth() + this.styles.padding.right
|
|
24264
24371
|
: 0;
|
|
24265
24372
|
return Math.max(axisEnd + labelBuffer, bboxTotal, titleEnd, legendEnd, indicatorEnd, totalEnd);
|
|
24266
24373
|
}
|
|
@@ -24500,9 +24607,9 @@ class TimeChart {
|
|
|
24500
24607
|
const points = this.variancesDataModel
|
|
24501
24608
|
.filter((entry) => entry.type === VarianceType.RELATIVE)
|
|
24502
24609
|
.map((entry) => entry.scenario1);
|
|
24503
|
-
if (points.length > 0
|
|
24504
|
-
// the
|
|
24505
|
-
points.push(this.
|
|
24610
|
+
if (points.length > 0) {
|
|
24611
|
+
// the pins of the total columns are pins of the row
|
|
24612
|
+
points.push(...this.totalVariances.filter((point) => point != null));
|
|
24506
24613
|
}
|
|
24507
24614
|
if (points.length === 0 || !points.some((point) => point.isClipped())) {
|
|
24508
24615
|
return;
|
|
@@ -24603,7 +24710,7 @@ class TimeChart {
|
|
|
24603
24710
|
if (this.isVarianceChart()) {
|
|
24604
24711
|
this.drawVarianceScenario(this.variancesDataModel, svgContainer);
|
|
24605
24712
|
// before the axis: the line of a scenario switch runs over the full height of the row
|
|
24606
|
-
this.
|
|
24713
|
+
this.drawTotalVariances(svgContainer);
|
|
24607
24714
|
this.drawAxisAndLabels(this.variancesDataModel, svgContainer);
|
|
24608
24715
|
}
|
|
24609
24716
|
else if (this.stackConfig != null) {
|
|
@@ -24630,7 +24737,7 @@ class TimeChart {
|
|
|
24630
24737
|
this.drawOverlayLayer(this.dataModel, svgContainer);
|
|
24631
24738
|
this.drawAxisAndLabels(this.dataModel, svgContainer);
|
|
24632
24739
|
this.drawScalingIndicator(svgContainer);
|
|
24633
|
-
this.
|
|
24740
|
+
this.drawTotalColumns(svgContainer);
|
|
24634
24741
|
}
|
|
24635
24742
|
}
|
|
24636
24743
|
}
|
|
@@ -24660,7 +24767,11 @@ class TimeChart {
|
|
|
24660
24767
|
scalingIndicatorLabelX() {
|
|
24661
24768
|
const gap = this.position.spacings.labelToColumn;
|
|
24662
24769
|
const half = this.position.getColumnWidth() / 2 + this.position.spacings.scenarioOffset;
|
|
24663
|
-
|
|
24770
|
+
let right = this.position.getColumnCenterPositionX(Math.max(0, this.dataModel.length - 1)) + half;
|
|
24771
|
+
if (this.hasTotals() && !this.hasEndTotal()) {
|
|
24772
|
+
// a total stands behind the last period: the value goes behind it
|
|
24773
|
+
right = Math.max(right, this.totalGeometry(this.totalColumns.length - 1).right);
|
|
24774
|
+
}
|
|
24664
24775
|
const legendWidth = this.legendWidth("right");
|
|
24665
24776
|
return right + gap + (legendWidth > 0 ? legendWidth + gap : 0);
|
|
24666
24777
|
}
|
|
@@ -24693,154 +24804,448 @@ class TimeChart {
|
|
|
24693
24804
|
const { left, right, height } = band;
|
|
24694
24805
|
const axisY = this.position.getColumnPositionY();
|
|
24695
24806
|
const group = svgContainer.group().id("ScalingIndicator");
|
|
24696
|
-
|
|
24697
|
-
|
|
24698
|
-
|
|
24699
|
-
.
|
|
24700
|
-
|
|
24807
|
+
// totals on the axis have their own band at their own scale: the band of the periods leaves their place free
|
|
24808
|
+
const half = this.position.getColumnWidth() / 2 + this.position.spacings.scenarioOffset;
|
|
24809
|
+
const runs = this.hasTotals() && !this.hasEndTotal()
|
|
24810
|
+
? this.totalRuns().map((run) => ({
|
|
24811
|
+
left: this.position.getColumnCenterPositionX(run.from) - half,
|
|
24812
|
+
right: this.position.getColumnCenterPositionX(run.to) + half,
|
|
24813
|
+
}))
|
|
24814
|
+
: [{ left, right }];
|
|
24815
|
+
for (const run of runs) {
|
|
24816
|
+
group
|
|
24817
|
+
.rect(run.right - run.left, height)
|
|
24818
|
+
.x(run.left)
|
|
24819
|
+
.y(axisY - height)
|
|
24820
|
+
.fill(SCALING_INDICATOR_FILL);
|
|
24821
|
+
}
|
|
24701
24822
|
group.back();
|
|
24702
24823
|
new Label$1(svgContainer.group().id("ScalingIndicatorLabel"), this.scalingIndicatorLabelX(), axisY - height, "SCALING_INDICATOR", this.scalingIndicatorText(), this.styles, HookLocation$1.Center, HookLocation$1.Left).forceStringTypeDraw();
|
|
24703
24824
|
}
|
|
24704
|
-
/** Where a title at the right starts when a total column stands
|
|
24825
|
+
/** Where a title at the right starts when a total column stands at the end: behind the column and its texts. */
|
|
24705
24826
|
rightTitleX() {
|
|
24706
|
-
if (!this.
|
|
24827
|
+
if (!this.hasEndTotal()) {
|
|
24707
24828
|
return undefined;
|
|
24708
24829
|
}
|
|
24709
|
-
return this.
|
|
24830
|
+
return this.totalGeometry(0).right + this.endTotalTextWidth() + this.position.spacings.labelToColumn;
|
|
24831
|
+
}
|
|
24832
|
+
/** True for a chart with total columns. */
|
|
24833
|
+
hasTotals() {
|
|
24834
|
+
return this.totalColumns.length > 0;
|
|
24710
24835
|
}
|
|
24711
|
-
/** True for
|
|
24712
|
-
|
|
24713
|
-
return this.
|
|
24836
|
+
/** True for the one total column of `by: all`: it stands apart at the end, with its own axis and its names. */
|
|
24837
|
+
hasEndTotal() {
|
|
24838
|
+
return this.hasTotals() && this.totals.by === "all";
|
|
24714
24839
|
}
|
|
24715
|
-
/**
|
|
24716
|
-
|
|
24840
|
+
/** The index of a total column for the positions: the totals follow the periods. */
|
|
24841
|
+
totalIndex(total) {
|
|
24842
|
+
// the index behind the last period stays what it is without totals: the end of the overlay lines
|
|
24843
|
+
return this.dataModel.length + 1 + total;
|
|
24844
|
+
}
|
|
24845
|
+
/** Place of a total column. `left` and `right` are the ends of its band, and of its own axis at the end. */
|
|
24846
|
+
totalGeometry(total) {
|
|
24717
24847
|
var _a, _b;
|
|
24718
|
-
const
|
|
24719
|
-
const
|
|
24720
|
-
// one period of room between the last period and the column: the axis of the periods ends before it
|
|
24721
|
-
const center = this.position.getColumnCenterPositionX(this.dataModel.length + 1) + (width - columnWidth) / 2;
|
|
24848
|
+
const width = this.position.getColumnWidth() * ((_b = (_a = this.totals) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 1);
|
|
24849
|
+
const center = this.position.getColumnCenterPositionX(this.totalIndex(total));
|
|
24722
24850
|
const margin = this.position.spacings.scenarioOffset;
|
|
24723
|
-
|
|
24724
|
-
// Every tier of the chart knows the indicator, so the column has the same place in all of them.
|
|
24725
|
-
const x = center + (this.scalingIndicator > 0 ? this.scalingIndicatorTextWidth() + margin : 0);
|
|
24726
|
-
return { center: x, width, left: x - width / 2 - 2 * margin, right: x + width / 2 + margin };
|
|
24851
|
+
return { center, width, left: center - width / 2 - 2 * margin, right: center + width / 2 + margin };
|
|
24727
24852
|
}
|
|
24728
24853
|
/**
|
|
24729
|
-
*
|
|
24730
|
-
*
|
|
24731
|
-
*
|
|
24732
|
-
*
|
|
24733
|
-
*
|
|
24734
|
-
* show a negative part, so such a chart has no total column at all.
|
|
24854
|
+
* The places of the periods and of the total columns on the axis, in category
|
|
24855
|
+
* widths, and the number of places the axis of the periods covers. A total of
|
|
24856
|
+
* `by: all` stands one period behind the last one, with its own axis. The
|
|
24857
|
+
* other totals stand right behind the last period of their group, and the
|
|
24858
|
+
* periods after them move on.
|
|
24735
24859
|
*/
|
|
24736
|
-
|
|
24737
|
-
var _a;
|
|
24738
|
-
|
|
24739
|
-
|
|
24740
|
-
|
|
24741
|
-
|
|
24742
|
-
|
|
24860
|
+
totalSlots(columnWidth, categoryWidth, fontSize, scenarioOffset) {
|
|
24861
|
+
var _a, _b, _c;
|
|
24862
|
+
const count = this.dataModel.length;
|
|
24863
|
+
const extra = categoryWidth > 0 ? ((((_b = (_a = this.totals) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 1) - 1) * columnWidth) / categoryWidth : 0;
|
|
24864
|
+
const slots = [];
|
|
24865
|
+
const totals = [];
|
|
24866
|
+
if (this.totals.by === "all") {
|
|
24867
|
+
for (let index = 0; index < count; index++)
|
|
24868
|
+
slots.push(index);
|
|
24869
|
+
// the value of the band of the periods stands in the gap: the column moves right by its width.
|
|
24870
|
+
// Every tier of the chart knows the indicator, so the column has the same place in all of them.
|
|
24871
|
+
const shift = this.scalingIndicator > 0 && categoryWidth > 0
|
|
24872
|
+
? (this.scalingIndicatorTextWidth() + scenarioOffset * fontSize) / (categoryWidth * fontSize)
|
|
24873
|
+
: 0;
|
|
24874
|
+
totals.push(count + 1 + extra / 2 + shift);
|
|
24875
|
+
return { slots: [...slots, count, ...totals], axisColumns: count };
|
|
24743
24876
|
}
|
|
24877
|
+
// the names of the scenarios stand right of the last period: its total keeps one place of room for them.
|
|
24878
|
+
// A series with a scenario switch has its names under the axis.
|
|
24744
24879
|
const followers = this.followerSlots();
|
|
24745
|
-
const
|
|
24746
|
-
|
|
24747
|
-
|
|
24748
|
-
|
|
24749
|
-
|
|
24750
|
-
|
|
24751
|
-
|
|
24752
|
-
|
|
24753
|
-
|
|
24880
|
+
const lastRow = this.dataModel[count - 1];
|
|
24881
|
+
const lastIsFollower = followers.includes((_c = this.visibleSlot(lastRow, followers)) !== null && _c !== void 0 ? _c : "scenario1");
|
|
24882
|
+
// the second marker prints its name there too
|
|
24883
|
+
const markerName = !followers.includes("scenario4") && this.dataModel.some((row) => TimeChart.hasValue(row.scenario4));
|
|
24884
|
+
const namesRoom = lastIsFollower && !markerName ? 0 : 1;
|
|
24885
|
+
let offset = 0;
|
|
24886
|
+
let next = 0;
|
|
24887
|
+
for (let index = 0; index < count; index++) {
|
|
24888
|
+
slots.push(index + offset);
|
|
24889
|
+
const group = this.totalColumns[next];
|
|
24890
|
+
if (group != null && group.to === index) {
|
|
24891
|
+
const room = index === count - 1 ? namesRoom : 0;
|
|
24892
|
+
totals.push(index + offset + room + 1 + extra / 2);
|
|
24893
|
+
offset += room + 1 + extra;
|
|
24894
|
+
next++;
|
|
24895
|
+
}
|
|
24754
24896
|
}
|
|
24755
|
-
|
|
24756
|
-
|
|
24897
|
+
return { slots: [...slots, count + offset, ...totals], axisColumns: count + offset };
|
|
24898
|
+
}
|
|
24899
|
+
/** The runs of periods between the total columns on the axis: each ends with the last period of a total, or of the chart. */
|
|
24900
|
+
totalRuns() {
|
|
24901
|
+
const runs = [];
|
|
24902
|
+
let from = 0;
|
|
24903
|
+
for (const column of this.totalColumns) {
|
|
24904
|
+
runs.push({ from, to: column.to });
|
|
24905
|
+
from = column.to + 1;
|
|
24906
|
+
}
|
|
24907
|
+
if (from < this.dataModel.length) {
|
|
24908
|
+
runs.push({ from, to: this.dataModel.length - 1 });
|
|
24909
|
+
}
|
|
24910
|
+
return runs;
|
|
24911
|
+
}
|
|
24912
|
+
/** The start of the group of a date, null for one group over all periods. */
|
|
24913
|
+
totalGroupStart(date, period = false) {
|
|
24914
|
+
var _a, _b;
|
|
24915
|
+
const by = (_b = (_a = this.totals) === null || _a === void 0 ? void 0 : _a.by) !== null && _b !== void 0 ? _b : "all";
|
|
24916
|
+
if (by === "all" || date == null || !date.isValid) {
|
|
24757
24917
|
return null;
|
|
24758
24918
|
}
|
|
24759
|
-
|
|
24919
|
+
// a week belongs to the year, quarter or month of its Thursday, as its number does
|
|
24920
|
+
const day = period && this.dateInterval === DateDistance.WEEK && by !== "week" ? date.plus({ days: 3 }) : date;
|
|
24921
|
+
return day.startOf(by);
|
|
24922
|
+
}
|
|
24923
|
+
/** The name of a total column under the axis: the text of the config at the end, else the name of its period. */
|
|
24924
|
+
totalLabel(start) {
|
|
24925
|
+
var _a, _b;
|
|
24926
|
+
if (start == null) {
|
|
24927
|
+
return (_b = (_a = this.totals) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : "";
|
|
24928
|
+
}
|
|
24929
|
+
const interval = {
|
|
24930
|
+
year: DateDistance.YEAR,
|
|
24931
|
+
quarter: DateDistance.QUARTER,
|
|
24932
|
+
month: DateDistance.MONTH,
|
|
24933
|
+
week: DateDistance.WEEK,
|
|
24934
|
+
}[this.totals.by];
|
|
24935
|
+
return this.createDateFactory().getShortDateString(start, interval);
|
|
24936
|
+
}
|
|
24937
|
+
/** The scenarios of the series: the first one, and the ones that follow it. */
|
|
24938
|
+
seriesSlotKeys() {
|
|
24939
|
+
return ["scenario1", ...this.followerSlots()];
|
|
24940
|
+
}
|
|
24941
|
+
/** The slot of the reference of a total: the first scenario with values that is not part of the series. */
|
|
24942
|
+
referenceSlot() {
|
|
24943
|
+
const followers = this.followerSlots();
|
|
24760
24944
|
for (const slot of ["scenario2", "scenario3", "scenario4"]) {
|
|
24761
24945
|
if (followers.includes(slot))
|
|
24762
24946
|
continue;
|
|
24763
|
-
|
|
24764
|
-
|
|
24765
|
-
reference = {
|
|
24766
|
-
scenario: values[0].scenario,
|
|
24767
|
-
value: values.reduce((sum, point) => sum + point.value, 0),
|
|
24768
|
-
};
|
|
24769
|
-
break;
|
|
24947
|
+
if (this.dataModel.some((row) => { var _a; return Number.isFinite((_a = row[slot]) === null || _a === void 0 ? void 0 : _a.value); })) {
|
|
24948
|
+
return slot;
|
|
24770
24949
|
}
|
|
24771
24950
|
}
|
|
24772
|
-
return
|
|
24773
|
-
parts,
|
|
24774
|
-
height: parts.reduce((sum, part) => sum + part.value, 0),
|
|
24775
|
-
total: parts.reduce((sum, part) => sum + part.value, 0),
|
|
24776
|
-
reference,
|
|
24777
|
-
};
|
|
24951
|
+
return null;
|
|
24778
24952
|
}
|
|
24779
|
-
/**
|
|
24780
|
-
|
|
24953
|
+
/** The look of one column for several scenarios: a forecast wins, then a plan, then the first one. */
|
|
24954
|
+
mixedScenario(scenarios) {
|
|
24781
24955
|
var _a, _b;
|
|
24782
|
-
|
|
24783
|
-
|
|
24956
|
+
return ((_b = (_a = scenarios.find((scenario) => getScenarioPrefix(scenario) === "fc")) !== null && _a !== void 0 ? _a : scenarios.find((scenario) => getScenarioPrefix(scenario) === "pl")) !== null && _b !== void 0 ? _b : scenarios[0]);
|
|
24957
|
+
}
|
|
24958
|
+
/** The rows of the totals dataset, one per group, with the scenario columns added up. */
|
|
24959
|
+
totalDatasetRows() {
|
|
24960
|
+
var _a, _b, _c, _d;
|
|
24961
|
+
const name = (_a = this.totals) === null || _a === void 0 ? void 0 : _a.dataset;
|
|
24962
|
+
if (!name) {
|
|
24963
|
+
return null;
|
|
24964
|
+
}
|
|
24965
|
+
const from = sourceExpr(this.db, name, "");
|
|
24966
|
+
const rows = new Map();
|
|
24967
|
+
if (!from) {
|
|
24968
|
+
return rows;
|
|
24969
|
+
}
|
|
24970
|
+
let result;
|
|
24971
|
+
try {
|
|
24972
|
+
result = this.db.exec(`SELECT * FROM ${from}`);
|
|
24973
|
+
}
|
|
24974
|
+
catch (e) {
|
|
24975
|
+
this.failQuery(e);
|
|
24976
|
+
return rows;
|
|
24977
|
+
}
|
|
24978
|
+
for (const row of result) {
|
|
24979
|
+
const date = TimeChart.parseDate(row.date);
|
|
24980
|
+
const start = date ? this.totalGroupStart(date) : null;
|
|
24981
|
+
const key = start ? ((_b = start.toISODate()) !== null && _b !== void 0 ? _b : "") : "";
|
|
24982
|
+
if (this.totals.by !== "all" && key === "")
|
|
24983
|
+
continue;
|
|
24984
|
+
const sums = (_c = rows.get(key)) !== null && _c !== void 0 ? _c : {};
|
|
24985
|
+
for (const [column, raw] of Object.entries(row)) {
|
|
24986
|
+
// a value can come as a text, like in the dataset of the chart
|
|
24987
|
+
const value = typeof raw === "string" && raw.trim() !== "" ? Number(raw) : raw;
|
|
24988
|
+
if (column !== "date" && typeof value === "number" && Number.isFinite(value)) {
|
|
24989
|
+
sums[column] = ((_d = sums[column]) !== null && _d !== void 0 ? _d : 0) + value;
|
|
24990
|
+
}
|
|
24991
|
+
}
|
|
24992
|
+
rows.set(key, sums);
|
|
24993
|
+
}
|
|
24994
|
+
return rows;
|
|
24995
|
+
}
|
|
24996
|
+
static parseDate(value) {
|
|
24997
|
+
if (value instanceof Date) {
|
|
24998
|
+
return DateTime.fromJSDate(value, { zone: "utc" });
|
|
24999
|
+
}
|
|
25000
|
+
if (typeof value === "string") {
|
|
25001
|
+
const date = DateTime.fromISO(value, { zone: "utc" });
|
|
25002
|
+
return date.isValid ? date : null;
|
|
25003
|
+
}
|
|
25004
|
+
if (typeof value === "number") {
|
|
25005
|
+
return DateTime.fromMillis(value, { zone: "utc" });
|
|
25006
|
+
}
|
|
25007
|
+
return null;
|
|
25008
|
+
}
|
|
25009
|
+
/**
|
|
25010
|
+
* The total columns of the chart. A group is the run of periods of one year,
|
|
25011
|
+
* quarter, month or week, or all periods. With `sum` a column stacks one part
|
|
25012
|
+
* per scenario of the series, else it is one column in the look of the
|
|
25013
|
+
* scenarios in it. The first other scenario is the reference behind. The
|
|
25014
|
+
* variance rows read the same list, for the same answer to "are there
|
|
25015
|
+
* totals". Empty without the config, with a stack, in line mode, and when a
|
|
25016
|
+
* part is not positive: a column cannot show that, so the chart has none.
|
|
25017
|
+
*/
|
|
25018
|
+
computeTotalColumns() {
|
|
25019
|
+
var _a, _b, _c, _d, _e;
|
|
25020
|
+
if (this.totals == null ||
|
|
25021
|
+
this.stackConfig != null ||
|
|
25022
|
+
this.dataModel.length === 0 ||
|
|
25023
|
+
this.determineEffectiveChartMode() !== ChartMode.BAR) {
|
|
25024
|
+
return [];
|
|
25025
|
+
}
|
|
25026
|
+
const followers = this.followerSlots();
|
|
25027
|
+
const series = this.seriesSlotKeys();
|
|
25028
|
+
const referenceSlot = this.referenceSlot();
|
|
25029
|
+
const referenceScenario = referenceSlot
|
|
25030
|
+
? (_a = this.dataModel.find((row) => { var _a; return ((_a = row[referenceSlot]) === null || _a === void 0 ? void 0 : _a.scenario) != null; })) === null || _a === void 0 ? void 0 : _a[referenceSlot].scenario
|
|
25031
|
+
: null;
|
|
25032
|
+
const fromData = this.totalDatasetRows();
|
|
25033
|
+
// the groups: runs of periods with the same start
|
|
25034
|
+
const groups = [];
|
|
25035
|
+
this.dataModel.forEach((row, index) => {
|
|
25036
|
+
const start = this.totalGroupStart(row.date, true);
|
|
25037
|
+
const last = groups[groups.length - 1];
|
|
25038
|
+
if (last != null && (start == null || (last.start != null && +last.start === +start))) {
|
|
25039
|
+
last.to = index;
|
|
25040
|
+
}
|
|
25041
|
+
else {
|
|
25042
|
+
groups.push({ from: index, to: index, start });
|
|
25043
|
+
}
|
|
25044
|
+
});
|
|
25045
|
+
// a total per period would repeat every column: `by` is not coarser than the periods of the chart
|
|
25046
|
+
if (this.totals.by !== "all" && groups.length === this.dataModel.length && groups.length > 1) {
|
|
25047
|
+
return [];
|
|
25048
|
+
}
|
|
25049
|
+
const columns = [];
|
|
25050
|
+
for (const group of groups) {
|
|
25051
|
+
const rows = this.dataModel.slice(group.from, group.to + 1);
|
|
25052
|
+
let parts = [];
|
|
25053
|
+
let reference = null;
|
|
25054
|
+
let counted = [];
|
|
25055
|
+
let scenarios;
|
|
25056
|
+
if (fromData != null) {
|
|
25057
|
+
// the values as the dataset gives them: one part per scenario of the series
|
|
25058
|
+
const data = (_c = fromData.get(group.start ? ((_b = group.start.toISODate()) !== null && _b !== void 0 ? _b : "") : "")) !== null && _c !== void 0 ? _c : {};
|
|
25059
|
+
for (const slot of series) {
|
|
25060
|
+
const scenario = (_d = this.dataModel.find((row) => { var _a; return ((_a = row[slot]) === null || _a === void 0 ? void 0 : _a.scenario) != null; })) === null || _d === void 0 ? void 0 : _d[slot].scenario;
|
|
25061
|
+
// a 0 is a scenario without a value in this total
|
|
25062
|
+
if (scenario != null && Number.isFinite(data[scenario]) && data[scenario] !== 0) {
|
|
25063
|
+
parts.push({ scenario, value: data[scenario] });
|
|
25064
|
+
}
|
|
25065
|
+
}
|
|
25066
|
+
if (referenceScenario != null && Number.isFinite(data[referenceScenario])) {
|
|
25067
|
+
reference = { scenario: referenceScenario, value: data[referenceScenario] };
|
|
25068
|
+
}
|
|
25069
|
+
scenarios = parts.map((part) => part.scenario);
|
|
25070
|
+
if (this.totals.aggregation !== "sum" && parts.length > 1 && parts.every((part) => part.value > 0)) {
|
|
25071
|
+
// an average or a last value is one column: the dataset gives the value, not its parts
|
|
25072
|
+
parts = [
|
|
25073
|
+
{ scenario: this.mixedScenario(scenarios), value: parts.reduce((sum, part) => sum + part.value, 0) },
|
|
25074
|
+
];
|
|
25075
|
+
}
|
|
25076
|
+
}
|
|
25077
|
+
else {
|
|
25078
|
+
// the periods where the series has a value. The reference counts in the same periods only,
|
|
25079
|
+
// as the variance of the total does: else the two would not tell the same.
|
|
25080
|
+
const used = rows.filter((row) => {
|
|
25081
|
+
var _a;
|
|
25082
|
+
const slot = this.visibleSlot(row, followers);
|
|
25083
|
+
return slot != null && Number.isFinite((_a = row[slot]) === null || _a === void 0 ? void 0 : _a.value);
|
|
25084
|
+
});
|
|
25085
|
+
counted = used.map((row) => this.dataModel.indexOf(row));
|
|
25086
|
+
scenarios = [...new Set(used.map((row) => row[this.visibleSlot(row, followers)].scenario))];
|
|
25087
|
+
const visible = used.map((row) => row[this.visibleSlot(row, followers)]);
|
|
25088
|
+
// with `last` the one period that gives the value counts. A reference with a gap in
|
|
25089
|
+
// the counted periods is no reference: half a sum would stand against a full one.
|
|
25090
|
+
const referenceRows = this.totals.aggregation === "last" ? used.slice(-1) : used;
|
|
25091
|
+
const found = referenceSlot
|
|
25092
|
+
? referenceRows.map((row) => row[referenceSlot]).filter((point) => Number.isFinite(point === null || point === void 0 ? void 0 : point.value))
|
|
25093
|
+
: [];
|
|
25094
|
+
const references = found.length === referenceRows.length ? found : [];
|
|
25095
|
+
const sum = (points) => points.reduce((total, point) => total + point.value, 0);
|
|
25096
|
+
if (this.totals.aggregation === "sum") {
|
|
25097
|
+
const sums = new Map();
|
|
25098
|
+
for (const point of visible) {
|
|
25099
|
+
sums.set(point.scenario, ((_e = sums.get(point.scenario)) !== null && _e !== void 0 ? _e : 0) + point.value);
|
|
25100
|
+
}
|
|
25101
|
+
parts = [...sums.entries()].map(([scenario, value]) => ({ scenario, value }));
|
|
25102
|
+
if (references.length > 0) {
|
|
25103
|
+
reference = { scenario: referenceScenario, value: sum(references) };
|
|
25104
|
+
}
|
|
25105
|
+
}
|
|
25106
|
+
else if (visible.length > 0) {
|
|
25107
|
+
const last = this.totals.aggregation === "last";
|
|
25108
|
+
parts = [
|
|
25109
|
+
{
|
|
25110
|
+
scenario: last
|
|
25111
|
+
? visible[visible.length - 1].scenario
|
|
25112
|
+
: this.mixedScenario(visible.map((point) => point.scenario)),
|
|
25113
|
+
value: last ? visible[visible.length - 1].value : sum(visible) / visible.length,
|
|
25114
|
+
},
|
|
25115
|
+
];
|
|
25116
|
+
if (references.length > 0) {
|
|
25117
|
+
reference = {
|
|
25118
|
+
scenario: referenceScenario,
|
|
25119
|
+
value: last ? references[references.length - 1].value : sum(references) / references.length,
|
|
25120
|
+
};
|
|
25121
|
+
}
|
|
25122
|
+
}
|
|
25123
|
+
}
|
|
25124
|
+
if (parts.length === 0) {
|
|
25125
|
+
// a group without a value of the series has no total, the others keep theirs
|
|
25126
|
+
continue;
|
|
25127
|
+
}
|
|
25128
|
+
if (parts.some((part) => !(part.value > 0))) {
|
|
25129
|
+
return [];
|
|
25130
|
+
}
|
|
25131
|
+
const total = parts.reduce((sum, part) => sum + part.value, 0);
|
|
25132
|
+
columns.push(Object.assign(Object.assign({}, group), { label: this.totalLabel(group.start), parts, total, reference, counted, scenarios }));
|
|
25133
|
+
}
|
|
25134
|
+
return columns;
|
|
25135
|
+
}
|
|
25136
|
+
/** Height of the highest total column in pixels: its parts, its reference and its band of the scaling indicator. */
|
|
25137
|
+
totalsHeight() {
|
|
25138
|
+
if (!this.hasTotals()) {
|
|
24784
25139
|
return 0;
|
|
24785
25140
|
}
|
|
24786
25141
|
const band = this.hasScalingIndicator() ? this.scalingIndicator : 0;
|
|
24787
|
-
return Math.max(total
|
|
25142
|
+
const units = Math.max(...this.totalColumns.map((column) => { var _a, _b; return Math.max(column.total, (_b = (_a = column.reference) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0); }));
|
|
25143
|
+
return Math.max(units, band) * this.totals.pixelPerUnit;
|
|
24788
25144
|
}
|
|
24789
25145
|
/**
|
|
24790
|
-
* The
|
|
24791
|
-
*
|
|
24792
|
-
*
|
|
25146
|
+
* The variances of the total columns in a variance chart, one per column:
|
|
25147
|
+
* the series against the reference, put together the way the total is. With
|
|
25148
|
+
* a dataset the values come from its row. A total takes the notation of the
|
|
25149
|
+
* forecast when a forecast is part of it.
|
|
24793
25150
|
*/
|
|
24794
|
-
|
|
24795
|
-
var _a, _b
|
|
24796
|
-
if (!this.
|
|
24797
|
-
return
|
|
25151
|
+
computeTotalVariances() {
|
|
25152
|
+
var _a, _b;
|
|
25153
|
+
if (!this.hasTotals() || !this.isVarianceChart()) {
|
|
25154
|
+
return [];
|
|
24798
25155
|
}
|
|
24799
25156
|
const firstRow = (_a = this.dataModel[0]) !== null && _a !== void 0 ? _a : null;
|
|
24800
25157
|
const candidates = ((_b = this.configVariances) !== null && _b !== void 0 ? _b : [])
|
|
24801
25158
|
.map((name) => ({ name, variance: new VarianceScenario(name) }))
|
|
24802
25159
|
.filter((entry) => entry.variance.isValid);
|
|
24803
25160
|
if (candidates.length === 0) {
|
|
24804
|
-
return
|
|
25161
|
+
return [];
|
|
24805
25162
|
}
|
|
24806
|
-
|
|
24807
|
-
|
|
24808
|
-
const
|
|
24809
|
-
|
|
24810
|
-
|
|
24811
|
-
|
|
24812
|
-
|
|
24813
|
-
|
|
24814
|
-
|
|
24815
|
-
|
|
24816
|
-
|
|
24817
|
-
|
|
24818
|
-
|
|
25163
|
+
const first = candidates[0].variance;
|
|
25164
|
+
const relative = first.type === VarianceType.RELATIVE;
|
|
25165
|
+
const fromData = this.totalDatasetRows();
|
|
25166
|
+
const aggregation = this.totals.aggregation;
|
|
25167
|
+
return this.totalColumns.map((column) => {
|
|
25168
|
+
var _a, _b, _c, _d, _e, _f;
|
|
25169
|
+
let base;
|
|
25170
|
+
let delta;
|
|
25171
|
+
const notations = new Set();
|
|
25172
|
+
if (fromData != null) {
|
|
25173
|
+
base = 0;
|
|
25174
|
+
const data = (_b = fromData.get(column.start ? ((_a = column.start.toISODate()) !== null && _a !== void 0 ? _a : "") : "")) !== null && _b !== void 0 ? _b : {};
|
|
25175
|
+
// the bases of the row are the scenarios of the series, each counts once
|
|
25176
|
+
const bases = new Set(candidates.map((entry) => entry.variance.base));
|
|
25177
|
+
// a row for a part of the series only has no total: the reference of the dataset is the one of the whole total
|
|
25178
|
+
const covered = column.scenarios.filter((scenario) => bases.has(scenario)).length;
|
|
25179
|
+
if (covered > 0 && covered < column.scenarios.length) {
|
|
25180
|
+
return null;
|
|
25181
|
+
}
|
|
25182
|
+
for (const name of bases) {
|
|
25183
|
+
// a 0 is a scenario without a value in this total, as for the parts
|
|
25184
|
+
if (Number.isFinite(data[name]) && data[name] !== 0) {
|
|
25185
|
+
base += data[name];
|
|
25186
|
+
notations.add(name.slice(0, 2));
|
|
25187
|
+
}
|
|
24819
25188
|
}
|
|
25189
|
+
if (notations.size === 0 || !Number.isFinite(data[first.delta])) {
|
|
25190
|
+
return null;
|
|
25191
|
+
}
|
|
25192
|
+
delta = data[first.delta];
|
|
24820
25193
|
}
|
|
25194
|
+
else {
|
|
25195
|
+
// the same periods as the column, so the two tell the same: with `last` the one
|
|
25196
|
+
// period of the value. Without both values in each of them there is no variance.
|
|
25197
|
+
const rows = (aggregation === "last" ? column.counted.slice(-1) : column.counted).map((index) => this.dataModel[index]);
|
|
25198
|
+
const pairs = [];
|
|
25199
|
+
for (const row of rows) {
|
|
25200
|
+
for (const { variance } of candidates) {
|
|
25201
|
+
const slots = this.mapScenarios(variance, firstRow);
|
|
25202
|
+
const baseValue = (_d = row[(_c = slots.get(variance.base)) !== null && _c !== void 0 ? _c : ""]) === null || _d === void 0 ? void 0 : _d.value;
|
|
25203
|
+
const deltaValue = (_f = row[(_e = slots.get(variance.delta)) !== null && _e !== void 0 ? _e : ""]) === null || _f === void 0 ? void 0 : _f.value;
|
|
25204
|
+
if (Number.isFinite(baseValue) && Number.isFinite(deltaValue)) {
|
|
25205
|
+
pairs.push({ base: baseValue, delta: deltaValue, notation: variance.base.slice(0, 2) });
|
|
25206
|
+
break;
|
|
25207
|
+
}
|
|
25208
|
+
}
|
|
25209
|
+
}
|
|
25210
|
+
if (pairs.length === 0 || pairs.length !== rows.length) {
|
|
25211
|
+
return null;
|
|
25212
|
+
}
|
|
25213
|
+
const divisor = aggregation === "average" ? pairs.length : 1;
|
|
25214
|
+
base = pairs.reduce((sum, pair) => sum + pair.base, 0) / divisor;
|
|
25215
|
+
delta = pairs.reduce((sum, pair) => sum + pair.delta, 0) / divisor;
|
|
25216
|
+
pairs.forEach((pair) => notations.add(pair.notation));
|
|
25217
|
+
}
|
|
25218
|
+
const point = new DataPoint(relative ? relativeVariance(base - delta, delta) : base - delta, first.delta, relative ? this.pixelPerPercentage : this.pixelPerUnit, first.direction);
|
|
25219
|
+
if (this.scenarioSwitch) {
|
|
25220
|
+
point.notation = notations.has("fc") ? "fc" : notations.size === 1 ? [...notations][0] : "ac";
|
|
25221
|
+
}
|
|
25222
|
+
point.key = this.totalKey(column, candidates[0].name);
|
|
25223
|
+
return point;
|
|
25224
|
+
});
|
|
25225
|
+
}
|
|
25226
|
+
/** The point key of an element of a total column: `row: total`, and the start of its group when there are several. */
|
|
25227
|
+
totalKey(column, scenario) {
|
|
25228
|
+
const key = { row: "total" };
|
|
25229
|
+
if (column.start != null) {
|
|
25230
|
+
key.date = TimeChart.pointDate(column.start);
|
|
24821
25231
|
}
|
|
24822
|
-
if (
|
|
24823
|
-
|
|
24824
|
-
}
|
|
24825
|
-
const first = candidates[0].variance;
|
|
24826
|
-
const relative = first.type === VarianceType.RELATIVE;
|
|
24827
|
-
const point = new DataPoint(relative ? relativeVariance(base - delta, delta) : base - delta, first.delta, relative ? this.pixelPerPercentage : this.pixelPerUnit, first.direction);
|
|
24828
|
-
if (this.scenarioSwitch) {
|
|
24829
|
-
point.notation = notations.has("fc") ? "fc" : notations.size === 1 ? [...notations][0] : "ac";
|
|
25232
|
+
if (scenario) {
|
|
25233
|
+
key.scenario = scenario;
|
|
24830
25234
|
}
|
|
24831
|
-
|
|
24832
|
-
return point;
|
|
25235
|
+
return key;
|
|
24833
25236
|
}
|
|
24834
|
-
/** Width of the texts right of the total column: the names of its parts, and the value of
|
|
24835
|
-
|
|
25237
|
+
/** Width of the texts right of the total column at the end: the names of its parts, and the value of its band. */
|
|
25238
|
+
endTotalTextWidth() {
|
|
25239
|
+
if (!this.hasEndTotal()) {
|
|
25240
|
+
return 0;
|
|
25241
|
+
}
|
|
24836
25242
|
const width = (text) => CalculateSize(text, { font: this.styles.fontStyles.font, fontSize: this.styles.fontStyles.size + "px" }).width;
|
|
24837
25243
|
const gap = this.position.spacings.labelToColumn;
|
|
24838
|
-
const
|
|
24839
|
-
|
|
24840
|
-
|
|
24841
|
-
|
|
24842
|
-
|
|
24843
|
-
const indicator = total != null && this.hasScalingIndicator() ? gap + width(this.scalingIndicatorText()) : 0;
|
|
25244
|
+
const parts = this.totalColumns[0].parts;
|
|
25245
|
+
const names = !this.isVarianceChart() && parts.length > 1
|
|
25246
|
+
? gap + Math.max(...parts.map((part) => width(this.scenarioName(part.scenario))))
|
|
25247
|
+
: 0;
|
|
25248
|
+
const indicator = this.hasScalingIndicator() ? gap + width(this.scalingIndicatorText()) : 0;
|
|
24844
25249
|
return names + indicator;
|
|
24845
25250
|
}
|
|
24846
25251
|
scenarioName(scenario) {
|
|
@@ -24861,131 +25266,137 @@ class TimeChart {
|
|
|
24861
25266
|
solid: pattern ? null : color,
|
|
24862
25267
|
};
|
|
24863
25268
|
}
|
|
24864
|
-
/** The axis of the total column: its own piece of line, in the look of the axis of the chart. */
|
|
25269
|
+
/** The axis of the total column at the end: its own piece of line, in the look of the axis of the chart. */
|
|
24865
25270
|
drawTotalAxis(group, y) {
|
|
24866
|
-
const { left, right } = this.
|
|
25271
|
+
const { left, right } = this.totalGeometry(0);
|
|
24867
25272
|
const scenario = this.axisScenario == null ? "default" : `${this.axisScenario}`.slice(0, 2);
|
|
24868
25273
|
group.line(left, y, right, y).addClass("axis-" + scenario);
|
|
24869
25274
|
}
|
|
24870
25275
|
/**
|
|
24871
|
-
* The total
|
|
24872
|
-
*
|
|
24873
|
-
*
|
|
24874
|
-
*
|
|
25276
|
+
* The total columns of the base chart, at their own scale: the parts, the
|
|
25277
|
+
* reference behind, the total above and the name under the axis. With a
|
|
25278
|
+
* scaling indicator a column has its own band. The column at the end has its
|
|
25279
|
+
* own axis and the names of its parts at the right, and a line links its band
|
|
25280
|
+
* to the band of the periods.
|
|
24875
25281
|
*/
|
|
24876
|
-
|
|
24877
|
-
|
|
24878
|
-
if (total == null) {
|
|
25282
|
+
drawTotalColumns(svgContainer) {
|
|
25283
|
+
if (!this.hasTotals() || this.isVarianceChart()) {
|
|
24879
25284
|
return;
|
|
24880
25285
|
}
|
|
24881
|
-
const
|
|
24882
|
-
const scale = this.totalColumn.pixelPerUnit;
|
|
25286
|
+
const scale = this.totals.pixelPerUnit;
|
|
24883
25287
|
const axisY = this.position.getColumnPositionY();
|
|
24884
25288
|
const gap = this.position.spacings.labelToColumn;
|
|
25289
|
+
const atEnd = this.hasEndTotal();
|
|
24885
25290
|
const group = svgContainer.group().id("TotalColumn");
|
|
24886
|
-
if (this.hasScalingIndicator()) {
|
|
24887
|
-
const height = this.scalingIndicator * scale;
|
|
24888
|
-
const periods = this.scalingIndicatorBand();
|
|
24889
|
-
group
|
|
24890
|
-
.rect(right - left, height)
|
|
24891
|
-
.x(left)
|
|
24892
|
-
.y(axisY - height)
|
|
24893
|
-
.fill(SCALING_INDICATOR_FILL);
|
|
24894
|
-
if (periods != null) {
|
|
24895
|
-
// the line starts behind the value of the band of the periods
|
|
24896
|
-
const from = this.scalingIndicatorLabelX() + this.scalingIndicatorTextWidth() + gap / 2;
|
|
24897
|
-
group
|
|
24898
|
-
.line(Math.min(from, left), axisY - periods.height, left, axisY - height)
|
|
24899
|
-
.stroke({ color: SCALING_INDICATOR_LINE, width: 1 })
|
|
24900
|
-
.id("ScalingIndicatorLink");
|
|
24901
|
-
}
|
|
24902
|
-
}
|
|
24903
|
-
if (total.reference != null && total.reference.value > 0) {
|
|
24904
|
-
const look = this.columnLook(total.reference.scenario);
|
|
24905
|
-
const height = total.reference.value * scale;
|
|
24906
|
-
group
|
|
24907
|
-
.rect(width, height)
|
|
24908
|
-
.cx(center - this.position.spacings.scenarioOffset)
|
|
24909
|
-
.y(axisY - height)
|
|
24910
|
-
.fill(look.fill)
|
|
24911
|
-
.stroke(look.stroke)
|
|
24912
|
-
.attr(dataPointAttributes({ row: "total", scenario: total.reference.scenario }, "element"))
|
|
24913
|
-
.attr("data-bn-value", total.reference.value);
|
|
24914
|
-
}
|
|
24915
|
-
let top = axisY;
|
|
24916
25291
|
const labelGroup = svgContainer.group().id("TotalColumnLabels");
|
|
24917
|
-
|
|
24918
|
-
const
|
|
24919
|
-
|
|
24920
|
-
|
|
24921
|
-
|
|
24922
|
-
|
|
24923
|
-
|
|
24924
|
-
|
|
24925
|
-
|
|
24926
|
-
|
|
24927
|
-
|
|
24928
|
-
.
|
|
24929
|
-
|
|
24930
|
-
|
|
24931
|
-
|
|
24932
|
-
|
|
24933
|
-
|
|
24934
|
-
|
|
25292
|
+
this.totalColumns.forEach((column, index) => {
|
|
25293
|
+
const { center, width, left, right } = this.totalGeometry(index);
|
|
25294
|
+
if (this.hasScalingIndicator()) {
|
|
25295
|
+
const height = this.scalingIndicator * scale;
|
|
25296
|
+
const periods = this.scalingIndicatorBand();
|
|
25297
|
+
const band = group
|
|
25298
|
+
.rect(right - left, height)
|
|
25299
|
+
.x(left)
|
|
25300
|
+
.y(axisY - height)
|
|
25301
|
+
.fill(SCALING_INDICATOR_FILL);
|
|
25302
|
+
// behind the columns of the periods that stand next to it
|
|
25303
|
+
band.back();
|
|
25304
|
+
if (atEnd && periods != null) {
|
|
25305
|
+
// the line starts behind the value of the band of the periods
|
|
25306
|
+
const from = this.scalingIndicatorLabelX() + this.scalingIndicatorTextWidth() + gap / 2;
|
|
25307
|
+
group
|
|
25308
|
+
.line(Math.min(from, left), axisY - periods.height, left, axisY - height)
|
|
25309
|
+
.stroke({ color: SCALING_INDICATOR_LINE, width: 1 })
|
|
25310
|
+
.id("ScalingIndicatorLink");
|
|
24935
25311
|
}
|
|
24936
|
-
new Label$1(labelGroup, center + width / 2 + gap,
|
|
24937
|
-
// the name of a thin top part stays below the total above the column
|
|
24938
|
-
Math.max(top + height / 2, axisY - total.height * scale + this.position.dataLabelHeight / 2), "TOTAL_NAME", this.scenarioName(part.scenario), this.styles, HookLocation$1.Center, HookLocation$1.Left).forceStringTypeDraw();
|
|
24939
25312
|
}
|
|
24940
|
-
|
|
24941
|
-
|
|
24942
|
-
|
|
24943
|
-
|
|
24944
|
-
|
|
24945
|
-
|
|
24946
|
-
|
|
24947
|
-
|
|
24948
|
-
|
|
24949
|
-
|
|
24950
|
-
|
|
24951
|
-
|
|
24952
|
-
|
|
24953
|
-
|
|
24954
|
-
|
|
25313
|
+
if (column.reference != null && column.reference.value > 0) {
|
|
25314
|
+
const look = this.columnLook(column.reference.scenario);
|
|
25315
|
+
const height = column.reference.value * scale;
|
|
25316
|
+
group
|
|
25317
|
+
.rect(width, height)
|
|
25318
|
+
.cx(center - this.position.spacings.scenarioOffset)
|
|
25319
|
+
.y(axisY - height)
|
|
25320
|
+
.fill(look.fill)
|
|
25321
|
+
.stroke(look.stroke)
|
|
25322
|
+
.attr(dataPointAttributes(this.totalKey(column, column.reference.scenario), "element"))
|
|
25323
|
+
.attr("data-bn-value", column.reference.value);
|
|
25324
|
+
}
|
|
25325
|
+
let top = axisY;
|
|
25326
|
+
for (const part of column.parts) {
|
|
25327
|
+
const look = this.columnLook(part.scenario);
|
|
25328
|
+
const height = part.value * scale;
|
|
25329
|
+
top -= height;
|
|
25330
|
+
const key = this.totalKey(column, part.scenario);
|
|
25331
|
+
group
|
|
25332
|
+
.rect(width, height)
|
|
25333
|
+
.cx(center)
|
|
25334
|
+
.y(top)
|
|
25335
|
+
.fill(look.fill)
|
|
25336
|
+
.stroke(look.stroke)
|
|
25337
|
+
.attr(dataPointAttributes(key, "element"))
|
|
25338
|
+
.attr("data-bn-value", part.value);
|
|
25339
|
+
if (column.parts.length > 1) {
|
|
25340
|
+
if (height >= this.position.dataLabelHeight) {
|
|
25341
|
+
const label = new Label$1(labelGroup, center, top + height / 2, "TOTAL_PART", part.value, this.styles, HookLocation$1.Center, HookLocation$1.Center).setPoint(key);
|
|
25342
|
+
// a label on a hatching keeps the background of a plain label
|
|
25343
|
+
(look.solid ? label.setSegmentFill(look.solid) : label).draw(true, this.dataFormatDigits, this.measureScale);
|
|
25344
|
+
}
|
|
25345
|
+
if (atEnd) {
|
|
25346
|
+
new Label$1(labelGroup, center + width / 2 + gap,
|
|
25347
|
+
// the name of a thin top part stays below the total above the column
|
|
25348
|
+
Math.max(top + height / 2, axisY - column.total * scale + this.position.dataLabelHeight / 2), "TOTAL_NAME", this.scenarioName(part.scenario), this.styles, HookLocation$1.Center, HookLocation$1.Left).forceStringTypeDraw();
|
|
25349
|
+
}
|
|
25350
|
+
}
|
|
25351
|
+
}
|
|
25352
|
+
new Label$1(labelGroup, center, top - gap, "TOTAL", column.total, this.styles, HookLocation$1.Bottom, HookLocation$1.Center)
|
|
25353
|
+
.setPoint(this.totalKey(column), "total")
|
|
25354
|
+
.draw(true, this.dataFormatDigits, this.measureScale);
|
|
25355
|
+
if (this.hideAxisLabels === false && column.label) {
|
|
25356
|
+
new Label$1(labelGroup, center, this.position.getAxisPositionY(false) + this.position.spacings.labelToAxis, "TOTAL_LABEL", column.label, this.styles, HookLocation$1.Top, HookLocation$1.Center).forceStringTypeDraw();
|
|
25357
|
+
}
|
|
25358
|
+
});
|
|
25359
|
+
if (atEnd) {
|
|
25360
|
+
this.drawTotalAxis(group, this.position.getAxisPositionY(false));
|
|
25361
|
+
if (this.hasScalingIndicator()) {
|
|
25362
|
+
new Label$1(labelGroup, this.totalGeometry(0).right + this.endTotalTextWidth() - this.scalingIndicatorTextWidth(), axisY - this.scalingIndicator * scale, "SCALING_INDICATOR_TOTAL", this.scalingIndicatorText(), this.styles, HookLocation$1.Center, HookLocation$1.Left).forceStringTypeDraw();
|
|
25363
|
+
}
|
|
24955
25364
|
}
|
|
24956
25365
|
}
|
|
24957
|
-
/** The
|
|
24958
|
-
|
|
25366
|
+
/** The variances of the total columns, in the tier of their variance chart: columns or pins like the others. */
|
|
25367
|
+
drawTotalVariances(svgContainer) {
|
|
24959
25368
|
var _a;
|
|
24960
|
-
|
|
24961
|
-
if (point == null) {
|
|
25369
|
+
if (!this.totalVariances.some((point) => point != null)) {
|
|
24962
25370
|
return;
|
|
24963
25371
|
}
|
|
24964
25372
|
// inside the group of the variances: its box is the height of the row, also below the axis
|
|
24965
25373
|
const scenarios = (_a = svgContainer.findOne("#Scenarios")) !== null && _a !== void 0 ? _a : svgContainer.group().id("Scenarios");
|
|
24966
25374
|
const group = scenarios.group().id("TotalColumn");
|
|
24967
25375
|
const labelGroup = scenarios.group().id("TotalColumnLabels");
|
|
24968
|
-
const { center } = this.totalColumnGeometry();
|
|
24969
|
-
// the elements take their place from an index: the one of the centre of the total column
|
|
24970
|
-
const index = (center - this.position.getColumnCenterPositionX(0)) /
|
|
24971
|
-
(this.position.getColumnCenterPositionX(1) - this.position.getColumnCenterPositionX(0));
|
|
24972
25376
|
const relative = this.variancesDataModel.some((entry) => entry.type === VarianceType.RELATIVE);
|
|
24973
|
-
|
|
24974
|
-
|
|
24975
|
-
|
|
24976
|
-
|
|
24977
|
-
|
|
24978
|
-
|
|
25377
|
+
this.totalVariances.forEach((point, total) => {
|
|
25378
|
+
if (point == null) {
|
|
25379
|
+
return;
|
|
25380
|
+
}
|
|
25381
|
+
const index = this.totalIndex(total);
|
|
25382
|
+
if (relative) {
|
|
25383
|
+
new Needle(this.position, this.scenarioStyles(), point, index, group.group())
|
|
25384
|
+
.updateLabelGroup(labelGroup.group())
|
|
25385
|
+
.draw(this.dataFormatDigits);
|
|
25386
|
+
return;
|
|
25387
|
+
}
|
|
24979
25388
|
// a row whose period variances are cut cuts the total the same way. The part above the
|
|
24980
|
-
// break is scaled by the largest overflow: that
|
|
25389
|
+
// break is scaled by the largest overflow: that can be the one of the total.
|
|
24981
25390
|
const overflow = this.overflowConfig
|
|
24982
25391
|
? Object.assign(Object.assign({}, this.overflowConfig), { maxOverflow: Math.max(this.overflowConfig.maxOverflow, point.getScaledUnit() - (this.overflowConfig.cutHeight - this.overflowConfig.scenarioCutOffset)) }) : null;
|
|
24983
25392
|
new Column(this.position, this.scenarioStyles(), point, index, true, group.group(), null, overflow)
|
|
24984
25393
|
.updateLabelGroup(labelGroup.group())
|
|
24985
25394
|
.setAsVariance()
|
|
24986
25395
|
.draw(this.dataFormatDigits, this.measureScale);
|
|
25396
|
+
});
|
|
25397
|
+
if (this.hasEndTotal()) {
|
|
25398
|
+
this.drawTotalAxis(group, this.position.getAxisPositionY(relative));
|
|
24987
25399
|
}
|
|
24988
|
-
this.drawTotalAxis(group, this.position.getAxisPositionY(relative));
|
|
24989
25400
|
const box = scenarios.bbox();
|
|
24990
25401
|
this.scenariosArea = {
|
|
24991
25402
|
height: box.height + this.styles.padding.top + this.styles.padding.bottom,
|
|
@@ -25062,6 +25473,7 @@ class TimeChart {
|
|
|
25062
25473
|
return new Map([...defaultI18n, ...i18n]);
|
|
25063
25474
|
}
|
|
25064
25475
|
createElementPosition(scenarios) {
|
|
25476
|
+
var _a, _b;
|
|
25065
25477
|
let maxLabelLengthLeft;
|
|
25066
25478
|
// only need scenarios written on the leftside of bar/ marker
|
|
25067
25479
|
const scenarioLabelLeft = CalculateSize(scenarios
|
|
@@ -25105,7 +25517,7 @@ class TimeChart {
|
|
|
25105
25517
|
if (this.overflowConfig) {
|
|
25106
25518
|
const { cutHeight, overdriveZoneHeight, breakGap } = this.overflowConfig;
|
|
25107
25519
|
// the total column is not cut: it keeps its room above the cut columns
|
|
25108
|
-
const virtualHeight = Math.max(cutHeight + overdriveZoneHeight + breakGap, this.isVarianceChart() ? 0 : this.
|
|
25520
|
+
const virtualHeight = Math.max(cutHeight + overdriveZoneHeight + breakGap, this.isVarianceChart() ? 0 : this.totalsHeight());
|
|
25109
25521
|
// Create a virtual DataPoint with pixelPerUnit=1 so getScaledUnit() returns virtualHeight directly
|
|
25110
25522
|
max = new DataPoint(virtualHeight, max.scenario, 1, max.variance);
|
|
25111
25523
|
}
|
|
@@ -25136,7 +25548,13 @@ class TimeChart {
|
|
|
25136
25548
|
effectiveScaleFactors = cloned;
|
|
25137
25549
|
}
|
|
25138
25550
|
}
|
|
25139
|
-
|
|
25551
|
+
// total columns take places on the axis: the periods behind them move on
|
|
25552
|
+
const places = this.hasTotals()
|
|
25553
|
+
? this.totalSlots(effectiveScaleFactors.columnWidth, effectiveScaleFactors.categoryWidth, this.styles.fontStyles.size, effectiveScaleFactors.scenarioOffset)
|
|
25554
|
+
: null;
|
|
25555
|
+
const position = new ElementPositions(new Padding(this.styles.padding), effectiveScaleFactors, this.styles.fontStyles, min, max, (_a = places === null || places === void 0 ? void 0 : places.axisColumns) !== null && _a !== void 0 ? _a : this.dataModel.length, maxLabelLengthLeft);
|
|
25556
|
+
position.setSlots((_b = places === null || places === void 0 ? void 0 : places.slots) !== null && _b !== void 0 ? _b : null);
|
|
25557
|
+
return position;
|
|
25140
25558
|
}
|
|
25141
25559
|
calculateTitleLength(minWidth) {
|
|
25142
25560
|
let tmpTitle = "_______"; // default width if this.title is sorther
|
|
@@ -25674,7 +26092,8 @@ class TimeChart {
|
|
|
25674
26092
|
const bottom = namesHeight > 0 ? height - this.styles.padding.bottom : height;
|
|
25675
26093
|
const lineWidth = Math.max(1, this.position.spacings.auxiliaryLineWidth);
|
|
25676
26094
|
runs.slice(1).forEach((run) => {
|
|
25677
|
-
|
|
26095
|
+
// half a period before the first period of the run: a total column can stand between the two runs
|
|
26096
|
+
const x = this.position.getColumnCenterPositionX(run.from) - this.position.spacings.categoryWidth / 2;
|
|
25678
26097
|
group
|
|
25679
26098
|
.line(x, 0, x, bottom)
|
|
25680
26099
|
.stroke({ color: this.styles.fontStyles.color || "#000000", width: lineWidth })
|
|
@@ -26489,8 +26908,8 @@ class TimeChartComponentConfig {
|
|
|
26489
26908
|
this.axisLabelsStep = 1;
|
|
26490
26909
|
/** Value of the scaling indicator band, 0 for none. */
|
|
26491
26910
|
this.scalingIndicator = 0;
|
|
26492
|
-
/** The
|
|
26493
|
-
this.
|
|
26911
|
+
/** The total columns, null for none. */
|
|
26912
|
+
this.totals = null;
|
|
26494
26913
|
/** One series that changes its scenario along the time axis, see `bn-chart-time`. */
|
|
26495
26914
|
this.scenarioSwitch = false;
|
|
26496
26915
|
/** Side of the axis title: left, right or none. */
|
|
@@ -26583,12 +27002,19 @@ class TimeChartComponentConfigAdapter {
|
|
|
26583
27002
|
if (CompareUtil.isNumber(data.scalingIndicator) && data.scalingIndicator > 0) {
|
|
26584
27003
|
config.scalingIndicator = data.scalingIndicator;
|
|
26585
27004
|
}
|
|
26586
|
-
const
|
|
26587
|
-
if (
|
|
26588
|
-
|
|
26589
|
-
|
|
26590
|
-
|
|
26591
|
-
|
|
27005
|
+
const totals = data.totals;
|
|
27006
|
+
if (totals != null && CompareUtil.isNumber(totals.pixelPerUnit) && totals.pixelPerUnit > 0) {
|
|
27007
|
+
const by = ["all", "year", "quarter", "month", "week"].includes(totals.by) ? totals.by : "all";
|
|
27008
|
+
const aggregation = ["sum", "average", "last"].includes(totals.aggregation)
|
|
27009
|
+
? totals.aggregation
|
|
27010
|
+
: "sum";
|
|
27011
|
+
config.totals = {
|
|
27012
|
+
by,
|
|
27013
|
+
aggregation,
|
|
27014
|
+
pixelPerUnit: totals.pixelPerUnit,
|
|
27015
|
+
label: typeof totals.label === "string" ? totals.label : "",
|
|
27016
|
+
width: CompareUtil.isNumber(totals.width) && totals.width > 0 ? totals.width : 1,
|
|
27017
|
+
dataset: typeof totals.dataset === "string" ? totals.dataset : "",
|
|
26592
27018
|
};
|
|
26593
27019
|
}
|
|
26594
27020
|
if (CompareUtil.isBoolean(data.scenarioSwitch)) {
|
|
@@ -26678,7 +27104,7 @@ const BnChartTimeRenderer = class {
|
|
|
26678
27104
|
/** @internal */
|
|
26679
27105
|
this.scalingIndicator = 0;
|
|
26680
27106
|
/** @internal */
|
|
26681
|
-
this.
|
|
27107
|
+
this.totals = null;
|
|
26682
27108
|
/** @internal */
|
|
26683
27109
|
this.scenarioSwitch = false;
|
|
26684
27110
|
/** @internal */
|
|
@@ -26970,7 +27396,7 @@ const BnChartTimeRenderer = class {
|
|
|
26970
27396
|
lineFullWidth: this.lineFullWidth,
|
|
26971
27397
|
axisLabelsStep: this.axisLabelsStep,
|
|
26972
27398
|
scalingIndicator: this.scalingIndicator,
|
|
26973
|
-
|
|
27399
|
+
totals: this.totals,
|
|
26974
27400
|
scenarioSwitch: this.scenarioSwitch,
|
|
26975
27401
|
axisTitlePosition: this.axisTitlePosition,
|
|
26976
27402
|
locale: ((_c = (_b = (_a = this.stores) === null || _a === void 0 ? void 0 : _a.context) === null || _b === void 0 ? void 0 : _b.state) === null || _c === void 0 ? void 0 : _c.locale) || "de",
|