@bino-bi/bn-template-engine 1.0.0-next.47 → 1.0.0-next.49
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-b3f5eba0.entry.js → p-2de524d0.entry.js} +1 -1
- package/dist/bn-template-engine/{p-a6017fce.entry.js → p-510d2ee6.entry.js} +1 -1
- package/dist/bn-template-engine/{p-6ab684a9.entry.js → p-8fc90dc8.entry.js} +1 -1
- package/dist/bn-template-engine/p-BFl7OwcC.js +1 -0
- package/dist/bn-template-engine/{p-3ktFZb1x.js → p-Bxa4pX1M.js} +1 -1
- package/dist/bn-template-engine/p-c1d679af.entry.js +1 -0
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +632 -112
- package/dist/cjs/bn-grid.cjs.entry.js +1 -1
- package/dist/cjs/bn-image.cjs.entry.js +1 -1
- package/dist/cjs/bn-template-engine.cjs.js +1 -1
- package/dist/cjs/bn-text.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{withStyled-DHKHBdRb.js → withStyled-pkdctrK9.js} +18 -1
- package/dist/cjs/{withTranslation-CLwC9a8V.js → withTranslation-BIzTNYZM.js} +1 -1
- package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.css +19 -0
- package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +65 -8
- package/dist/collection/components/bn-annotation-layer/utils/marks.js +85 -5
- package/dist/collection/components/bn-annotation-layer/utils/matchPoint.js +7 -1
- package/dist/collection/components/bn-chart-time/bn-chart-time-renderer/bn-chart-time-renderer.js +20 -6
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +55 -23
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +329 -53
- package/dist/collection/components/bn-chart-time/utils/elements/Column.js +4 -1
- package/dist/collection/components/bn-chart-time/utils/elements/Label.js +2 -1
- package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +53 -11
- package/dist/collection/components/bn-layout-page/bn-layout-page.js +1 -23
- package/dist/collection/components/bn-title/bn-title-renderer/bn-title-renderer.css +0 -10
- package/dist/collection/components/bn-title/bn-title-renderer/bn-title-renderer.js +1 -23
- package/dist/collection/components/bn-title/bn-title.js +1 -20
- package/dist/collection/utils/annotations.js +1 -1
- package/dist/collection/utils/constants.js +2 -0
- package/dist/collection/utils/layoutState/svgChartElements.js +10 -0
- package/dist/collection/utils/validate.js +16 -1
- package/dist/components/bn-annotation-layer.js +1 -1
- package/dist/components/bn-annotation-list.js +1 -1
- package/dist/components/bn-chart-bubble-renderer.js +1 -1
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet-renderer.js +1 -1
- package/dist/components/bn-chart-bullet.js +1 -1
- package/dist/components/bn-chart-scatter-renderer.js +1 -1
- package/dist/components/bn-chart-scatter.js +1 -1
- package/dist/components/bn-chart-structure-renderer.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time-renderer.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-image.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-page.js +1 -1
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/bn-text.js +1 -1
- package/dist/components/bn-title-renderer.js +1 -1
- package/dist/components/bn-title.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/{p-CLjuZoiT.js → p-B11cXOLy.js} +1 -1
- package/dist/components/p-BBdzTx8V.js +1 -0
- package/dist/components/p-BVNOmHh4.js +1 -0
- package/dist/components/p-BXP6aagM.js +1 -0
- package/dist/components/{p-CG-iY7pQ.js → p-Blre9f28.js} +1 -1
- package/dist/components/p-CHJ6WE0l.js +1 -0
- package/dist/components/{p-Do4GqlMV.js → p-CHhxQoF9.js} +1 -1
- package/dist/components/{p-C-3TOa6K.js → p-CJ0-xdfZ.js} +1 -1
- package/dist/components/{p-BFoRIqDi.js → p-CO6bgquz.js} +1 -1
- package/dist/components/{p-CytMTBFu.js → p-CSJCkHEL.js} +1 -1
- package/dist/components/p-CVfmhtEW.js +1 -0
- package/dist/components/{p-Zuxd3z0q.js → p-Cc0gaLwp.js} +1 -1
- package/dist/components/p-CuUfiEu0.js +1 -0
- package/dist/components/{p-DUZCLRVu.js → p-D362XOg2.js} +1 -1
- package/dist/components/p-DBj1Yd3M.js +1 -0
- package/dist/components/{p-BjgkgCAQ.js → p-DHX92KDP.js} +1 -1
- package/dist/components/p-DHloMyxV.js +1 -0
- package/dist/components/{p-Uc0zvXcQ.js → p-Dd1QOWDV.js} +1 -1
- package/dist/components/p-DguYWLBj.js +1 -0
- package/dist/components/p-Do-IGHJk.js +1 -0
- package/dist/components/{p-DDo-fu3v.js → p-DsC0ew4j.js} +1 -1
- package/dist/components/p-HVN8BNWN.js +1 -0
- package/dist/components/{p-Dyzb4ika.js → p-YSRTB0jS.js} +1 -1
- package/dist/components/{p-CrZ_O3DT.js → p-k7heRDPP.js} +1 -1
- package/dist/components/{p-dO0utE8m.js → p-keKnrAVS.js} +1 -1
- package/dist/components/p-x0W2_FAX.js +1 -0
- package/dist/components/{p-BgdoWKFY.js → p-y12CmIFS.js} +1 -1
- package/dist/esm/bn-annotation-layer_30.entry.js +632 -112
- package/dist/esm/bn-grid.entry.js +1 -1
- package/dist/esm/bn-image.entry.js +1 -1
- package/dist/esm/bn-template-engine.js +1 -1
- package/dist/esm/bn-text.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{withStyled-CTZFjg4L.js → withStyled-B62R20Zx.js} +18 -1
- package/dist/esm/{withTranslation-BESW5BNq.js → withTranslation-BEseMLQ6.js} +1 -1
- package/dist/types/components/bn-annotation-layer/utils/marks.d.ts +48 -0
- package/dist/types/components/bn-annotation-layer/utils/matchPoint.d.ts +4 -0
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +29 -6
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +51 -2
- package/dist/types/components/bn-chart-time/utils/elements/StackedColumn.d.ts +5 -1
- package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +6 -0
- package/dist/types/components/bn-layout-page/bn-layout-page.d.ts +0 -9
- package/dist/types/components/bn-title/bn-title-renderer/bn-title-renderer.d.ts +0 -2
- package/dist/types/components/bn-title/bn-title.d.ts +0 -5
- package/dist/types/components.d.ts +6 -27
- package/dist/types/utils/annotations.d.ts +11 -1
- package/dist/types/utils/constants.d.ts +3 -1
- package/dist/types/utils/layoutState/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-444a231f.entry.js +0 -1
- package/dist/bn-template-engine/p-DXtYQE4s.js +0 -1
- package/dist/components/p-6gET6YXc.js +0 -1
- package/dist/components/p-BFWvVe7v.js +0 -1
- package/dist/components/p-C8rpOS5t.js +0 -1
- package/dist/components/p-CUoPUIej.js +0 -1
- package/dist/components/p-D3hr9wra.js +0 -1
- package/dist/components/p-DFybNETX.js +0 -1
- package/dist/components/p-DJSj3oQq.js +0 -1
- package/dist/components/p-DRmphEA0.js +0 -1
- package/dist/components/p-D_K7tYhY.js +0 -1
- package/dist/components/p-Dw3rv_Y9.js +0 -1
- package/dist/components/p-TNX3alPU.js +0 -1
- package/dist/components/p-j42D1yrQ.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, h, a as Host, g as getElement, f as forceUpdate, d as writeTask, e as createEvent, F as Fragment$1 } from './index-GstO_GU5.js';
|
|
2
2
|
import { S as SYSTEM_STYLE_DEFAULTS, w as withComponentStatus, a as withHasError, g as getStores, C as ComponentRegister, r as runIfExisits, c as clearStoresCache, h as hasInlineJs, d as globalLabelKeys, e as SYSTEM_RULESET_DEFAULTS, X as XY_SERIES_PALETTE, i as getDefaultExportFromCjs, D as DateTime, j as resolveSeriesColor, m as markTreatment, s as shade, k as sourceExpr, l as reportOverflow, u as unknownStyleKeys, n as getOrCreateStores } from './withHasError-BDWEBrrb.js';
|
|
3
|
-
import { a as withComponentStyle, m as merge, C as CompareUtil, i as isBlankInput, b as isValidInteger, w as withStyled, c as isValidMeasureToken, r as resolveMeasure, s as scenarioFamily, d as scenarioSlotNumber, e as axisInValueUnits, f as isRelativeMeasure, v as validateOrderList, g as isValidDirection, A as AggregationLevel, O as OrderDirection, h as Order, j as OrderColumn, k as isNoScenarios, l as validateScenarioList, n as validateVariancesList, o as isValidLevel, p as isValidMeasureScale, q as validateStackConfig, S as StackBy, t as StackOrder, u as StackMode, x as AdapterUtils, y as OrderAdapter, N as NOT_AVAILABLE, z as relativeVariance, B as isValidNumber, D as isValidDateFormat, E as isValidAxisLabelsMode, F as DateDistance, G as AxisLabelsMode, H as ChartMode, I as DateStringFactory, R as RELATIVE_STACK_UNITS, J as mergeStyleLayers, K as murmur2, L as validateBarColumnsList, M as isTableBarColumnWidth, P as isValidDataFormat, Q as isValidTableType, T as validateThereOfJsonStr, U as isValidThereofPosition, V as validatePartOfJsonStr, W as validateTableOrderList, X as isValidMeasureType, Y as isTableCategoryWidth, Z as validateColumnThereOfJsonStr, _ as validateAttributesJsonStr, $ as DataFormat, a0 as ThereofPosition, a1 as TableType$2, a2 as normalizeOrderToken, a3 as I18nMode, a4 as TableCategoryWidth, a5 as MeasureType, a6 as parseTableAttributeExpression, a7 as BAR_COLUMN_WIDTH_EM, a8 as TableBarColumnWidth, a9 as TableRowType, aa as FIELD_IDENTIFIER_REGEX, ab as parseOrderToken, ac as Scenarios, ad as OrderDirection$1, ae as FactoryState$3, af as validateMeasureList, ag as isValidDate, ah as isValidDateLink, ai as DateLink } from './withStyled-
|
|
4
|
-
import { s as sanitizeHtml, g as getParentDimensions, b as getClippedHeight, i as isInheritedValue, f as findLayoutAncestors, r as readInherited, a as withDataset, w as withTranslation, p as parseScaling, c as strokeWidthPx, d as resolveScalingValue, e as formatScalingValue, h as withInheritedProps, j as parseScalingValue } from './withTranslation-
|
|
3
|
+
import { a as withComponentStyle, m as merge, C as CompareUtil, i as isBlankInput, b as isValidInteger, w as withStyled, c as isValidMeasureToken, r as resolveMeasure, s as scenarioFamily, d as scenarioSlotNumber, e as axisInValueUnits, f as isRelativeMeasure, v as validateOrderList, g as isValidDirection, A as AggregationLevel, O as OrderDirection, h as Order, j as OrderColumn, k as isNoScenarios, l as validateScenarioList, n as validateVariancesList, o as isValidLevel, p as isValidMeasureScale, q as validateStackConfig, S as StackBy, t as StackOrder, u as StackMode, x as AdapterUtils, y as OrderAdapter, N as NOT_AVAILABLE, z as relativeVariance, B as isValidNumber, D as isValidDateFormat, E as isValidAxisLabelsMode, F as DateDistance, G as AxisLabelsMode, H as ChartMode, I as DateStringFactory, R as RELATIVE_STACK_UNITS, J as mergeStyleLayers, K as murmur2, L as validateBarColumnsList, M as isTableBarColumnWidth, P as isValidDataFormat, Q as isValidTableType, T as validateThereOfJsonStr, U as isValidThereofPosition, V as validatePartOfJsonStr, W as validateTableOrderList, X as isValidMeasureType, Y as isTableCategoryWidth, Z as validateColumnThereOfJsonStr, _ as validateAttributesJsonStr, $ as DataFormat, a0 as ThereofPosition, a1 as TableType$2, a2 as normalizeOrderToken, a3 as I18nMode, a4 as TableCategoryWidth, a5 as MeasureType, a6 as parseTableAttributeExpression, a7 as BAR_COLUMN_WIDTH_EM, a8 as TableBarColumnWidth, a9 as TableRowType, aa as FIELD_IDENTIFIER_REGEX, ab as parseOrderToken, ac as Scenarios, ad as OrderDirection$1, ae as FactoryState$3, af as validateMeasureList, ag as isValidDate, ah as isValidDateLink, ai as DateLink } from './withStyled-B62R20Zx.js';
|
|
4
|
+
import { s as sanitizeHtml, g as getParentDimensions, b as getClippedHeight, i as isInheritedValue, f as findLayoutAncestors, r as readInherited, a as withDataset, w as withTranslation, p as parseScaling, c as strokeWidthPx, d as resolveScalingValue, e as formatScalingValue, h as withInheritedProps, j as parseScalingValue } from './withTranslation-BEseMLQ6.js';
|
|
5
5
|
import { w as withBodyObserver } from './withBodyObserver-wJgSN1Pj.js';
|
|
6
6
|
import { r as readDiagnostics, m as measure, a as resolveStandaloneId, l as localFrameOf, o as originsFor, b as assignIds, c as resolveOwnIdentity, t as toLayoutRect, d as measureContent, e as measureSign } from './localFrame-WNu1bAPm.js';
|
|
7
7
|
import { L as LAYOUT_STATE_VERSION } from './types-DY5fMUX8.js';
|
|
@@ -33,7 +33,7 @@ function parseLayerItems(json) {
|
|
|
33
33
|
var _a;
|
|
34
34
|
return (_a = parseItems(json)) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
35
35
|
var _a;
|
|
36
|
-
return (Object.assign(Object.assign({}, item), { label: text(item.label), color: text(item.color), target: (_a = text(item.target)) !== null && _a !== void 0 ? _a : "", to: text(item.to) }));
|
|
36
|
+
return (Object.assign(Object.assign({}, item), { label: text(item.label), color: text(item.color), target: (_a = text(item.target)) !== null && _a !== void 0 ? _a : "", to: text(item.to), text: text(item.text) }));
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
/** The `items` of a list. `undefined` when it is not a JSON array of objects. */
|
|
@@ -129,6 +129,71 @@ function besideText(text, r, unit, options) {
|
|
|
129
129
|
// the number in the circle must stay readable
|
|
130
130
|
return { x, y, r: Math.min(r, Math.max(wider / 2, 0.3 * unit)) };
|
|
131
131
|
}
|
|
132
|
+
/** A text cannot be measured here: the width of the digits and signs of a number, close enough for a frame. */
|
|
133
|
+
const textWidth = (text, em) => text.length * 0.6 * em;
|
|
134
|
+
const signed = (value, digits) => (value < 0 ? "-" : "+") + Math.abs(value).toFixed(digits);
|
|
135
|
+
/**
|
|
136
|
+
* The difference of two values of a chart. `box` and `toBox` are the bars of
|
|
137
|
+
* the two values, and the upper edge of each is its level. A thin line runs
|
|
138
|
+
* from each level to a bar behind the second value, which spans the
|
|
139
|
+
* difference. The label is `to - from`, and with `percent` also relative to
|
|
140
|
+
* `from`. A difference in the good direction has the colour `positive`, else
|
|
141
|
+
* `negative`. Without two values there is nothing to print. `levels` gives
|
|
142
|
+
* the y of the two values when it is not the upper edge of the boxes.
|
|
143
|
+
*/
|
|
144
|
+
function buildDifference(item, box, toBox, fromValue, toValue, em, levels) {
|
|
145
|
+
var _a, _b, _c;
|
|
146
|
+
if (fromValue == null || toValue == null)
|
|
147
|
+
return undefined;
|
|
148
|
+
const difference = toValue - fromValue;
|
|
149
|
+
const digits = Number.isInteger(item.digits) && item.digits >= 0 ? item.digits : 1;
|
|
150
|
+
const good = item.sentiment === "good-down" ? difference <= 0 : difference >= 0;
|
|
151
|
+
// the bar stands behind the second value, away from the first one
|
|
152
|
+
const direction = toBox.x + toBox.width / 2 >= box.x + box.width / 2 ? 1 : -1;
|
|
153
|
+
const edge = (of) => (direction === 1 ? of.x + of.width : of.x);
|
|
154
|
+
const barX = edge(toBox) + direction * 0.9 * em;
|
|
155
|
+
const lineEnd = barX + direction * 0.125 * em;
|
|
156
|
+
// the upper edge is the level of a positive value only: the caller knows better for a negative one
|
|
157
|
+
const fromY = (_a = levels === null || levels === void 0 ? void 0 : levels.from) !== null && _a !== void 0 ? _a : box.y;
|
|
158
|
+
const toY = (_b = levels === null || levels === void 0 ? void 0 : levels.to) !== null && _b !== void 0 ? _b : toBox.y;
|
|
159
|
+
const barWidth = 0.25 * em;
|
|
160
|
+
const percent = item.percent && fromValue !== 0 ? `(${signed((difference / Math.abs(fromValue)) * 100, 0)}%)` : undefined;
|
|
161
|
+
const value = signed(difference, digits);
|
|
162
|
+
const textX = barX + direction * 0.6 * em;
|
|
163
|
+
const textY = (fromY + toY) / 2;
|
|
164
|
+
const percentWidth = percent ? textWidth(percent, 0.85 * em) : 0;
|
|
165
|
+
// digits and signs alone are narrower than a text with a percent sign
|
|
166
|
+
const valueWidth = value.length * 0.5 * em;
|
|
167
|
+
// the percent is the last part of the text, which ends at textX when it stands at the left
|
|
168
|
+
const percentX = direction === 1 ? textX + valueWidth + 0.35 * em : textX - percentWidth;
|
|
169
|
+
return {
|
|
170
|
+
kind: "difference",
|
|
171
|
+
color: (_c = item.color) !== null && _c !== void 0 ? _c : (good ? "positive" : "negative"),
|
|
172
|
+
lines: [
|
|
173
|
+
{ x1: edge(box), y1: fromY, x2: lineEnd, y2: fromY },
|
|
174
|
+
{ x1: edge(toBox), y1: toY, x2: lineEnd, y2: toY },
|
|
175
|
+
],
|
|
176
|
+
bar: {
|
|
177
|
+
x: barX - barWidth / 2,
|
|
178
|
+
y: Math.min(fromY, toY),
|
|
179
|
+
width: barWidth,
|
|
180
|
+
height: Math.max(Math.abs(toY - fromY), 1),
|
|
181
|
+
},
|
|
182
|
+
text: { x: textX, y: textY, anchor: direction === 1 ? "start" : "end", value, percent },
|
|
183
|
+
frame: percent && item.highlight
|
|
184
|
+
? {
|
|
185
|
+
x: percentX - 0.25 * em,
|
|
186
|
+
y: textY - 0.65 * em,
|
|
187
|
+
width: percentWidth + 0.5 * em,
|
|
188
|
+
height: 1.3 * em,
|
|
189
|
+
r: 0.65 * em,
|
|
190
|
+
}
|
|
191
|
+
: undefined,
|
|
192
|
+
badge: item.label != null
|
|
193
|
+
? { cx: barX, cy: Math.min(fromY, toY) - 0.9 * em, r: 0.65 * em, label: item.label }
|
|
194
|
+
: undefined,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
132
197
|
/**
|
|
133
198
|
* The geometry of one item. On a whole component a marker sits in the top-right
|
|
134
199
|
* corner, and on a table cell next to the number. A frame goes around the text
|
|
@@ -137,7 +202,7 @@ function besideText(text, r, unit, options) {
|
|
|
137
202
|
* two boxes with the same centre has no direction and gives `undefined`.
|
|
138
203
|
*/
|
|
139
204
|
function buildMark(item, box, toBox, em, options = {}) {
|
|
140
|
-
var _a;
|
|
205
|
+
var _a, _b, _c, _d;
|
|
141
206
|
const { label, color } = item;
|
|
142
207
|
const { whole, area, text } = options;
|
|
143
208
|
// a table row has no text of its own, but the same font
|
|
@@ -181,9 +246,19 @@ function buildMark(item, box, toBox, em, options = {}) {
|
|
|
181
246
|
};
|
|
182
247
|
}
|
|
183
248
|
if (item.mark === "frame") {
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
249
|
+
// a text of its own stands in the upper part of the target, above a value label in its middle
|
|
250
|
+
const caption = item.text != null && !whole
|
|
251
|
+
? { x: box.x + box.width / 2, y: box.y + Math.min(box.height / 2, Math.max(0.9 * em, 0.3 * box.height)) }
|
|
252
|
+
: undefined;
|
|
253
|
+
const captionBox = caption && {
|
|
254
|
+
x: caption.x - textWidth(item.text, em) / 2,
|
|
255
|
+
y: caption.y - 0.6 * em,
|
|
256
|
+
width: textWidth(item.text, em),
|
|
257
|
+
height: 1.2 * em,
|
|
258
|
+
};
|
|
259
|
+
const around = (_a = captionBox !== null && captionBox !== void 0 ? captionBox : text) !== null && _a !== void 0 ? _a : box;
|
|
260
|
+
const part = (_b = item.point) === null || _b === void 0 ? void 0 : _b.part;
|
|
261
|
+
const oval = !whole && (captionBox != null || text != null || part === "label" || part === "total");
|
|
187
262
|
const paddingX = (oval ? 0.45 : 0.2) * unit;
|
|
188
263
|
const paddingY = (oval ? 0.1 : 0.2) * unit;
|
|
189
264
|
// a single digit gets a circle and not a narrow upright oval
|
|
@@ -214,6 +289,7 @@ function buildMark(item, box, toBox, em, options = {}) {
|
|
|
214
289
|
badge: label != null
|
|
215
290
|
? keepInside({ cx: x2 - rx * curve + outside, cy: top + ry * curve - outside, r: badgeR, label }, area)
|
|
216
291
|
: undefined,
|
|
292
|
+
caption: caption && Object.assign(Object.assign({}, caption), { text: item.text }),
|
|
217
293
|
};
|
|
218
294
|
}
|
|
219
295
|
// without a number the circle is only a dot
|
|
@@ -223,7 +299,11 @@ function buildMark(item, box, toBox, em, options = {}) {
|
|
|
223
299
|
}
|
|
224
300
|
const size = (label == null ? 0.4 : 0.75) * unit;
|
|
225
301
|
const r = isRow ? Math.min(size, box.height / 2) : size;
|
|
226
|
-
|
|
302
|
+
let at = whole ? { x: box.x + box.width - r, y: box.y + r } : centre(box);
|
|
303
|
+
if (!whole && options.stacked && ((_c = item.point) === null || _c === void 0 ? void 0 : _c.part) !== "label" && ((_d = item.point) === null || _d === void 0 ? void 0 : _d.part) !== "total") {
|
|
304
|
+
// on the upper right corner: the label in the middle and a name beside the segment stay free
|
|
305
|
+
at = { x: box.x + box.width, y: box.y + Math.min(0.5 * r, box.height / 2) };
|
|
306
|
+
}
|
|
227
307
|
if (isRow) {
|
|
228
308
|
// the middle of a row is free in a wide table. In a narrow one it is a number: then next to that number
|
|
229
309
|
const circle = { x: at.x - r, y: at.y - r, width: 2 * r, height: 2 * r };
|
|
@@ -259,10 +339,16 @@ function matchPoint(state, point) {
|
|
|
259
339
|
const noThereof = state.table != null && point.subCategory == null;
|
|
260
340
|
return candidates
|
|
261
341
|
.filter((candidate) => matches(candidate.point, point) && !(noThereof && candidate.point.subCategory != null))
|
|
262
|
-
.map(({ rect, content, contentSign }) => ({
|
|
342
|
+
.map(({ rect, content, contentSign, value, scenario }) => ({
|
|
343
|
+
rect,
|
|
344
|
+
content,
|
|
345
|
+
contentSign,
|
|
346
|
+
value,
|
|
347
|
+
stacked: typeof scenario === "string" && scenario.startsWith("stack:"),
|
|
348
|
+
}));
|
|
263
349
|
}
|
|
264
350
|
|
|
265
|
-
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}`;
|
|
351
|
+
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}`;
|
|
266
352
|
|
|
267
353
|
/** A chart can draw its data late: a point without a match is reported when the page has been quiet for two checks. */
|
|
268
354
|
const REPORT_CHECK_MS = 200;
|
|
@@ -395,7 +481,7 @@ const AnnotationLayer = class {
|
|
|
395
481
|
this.parsedItems = items !== null && items !== void 0 ? items : [];
|
|
396
482
|
}
|
|
397
483
|
async place() {
|
|
398
|
-
var _a;
|
|
484
|
+
var _a, _b;
|
|
399
485
|
const run = ++this.run;
|
|
400
486
|
if (!this.element.isConnected || !this.svg)
|
|
401
487
|
return;
|
|
@@ -456,7 +542,7 @@ const AnnotationLayer = class {
|
|
|
456
542
|
}
|
|
457
543
|
const content = found[0].content;
|
|
458
544
|
if (!state.table)
|
|
459
|
-
return { box, whole: false };
|
|
545
|
+
return { box, whole: false, stacked: found[0].stacked };
|
|
460
546
|
const cells = ((_a = state.elements) !== null && _a !== void 0 ? _a : []).flatMap((element) => element.kind === "cell" && element.content
|
|
461
547
|
? [{ box: onScreen(element.content), sign: element.contentSign }]
|
|
462
548
|
: []);
|
|
@@ -467,6 +553,38 @@ const AnnotationLayer = class {
|
|
|
467
553
|
obstacles: cells,
|
|
468
554
|
};
|
|
469
555
|
};
|
|
556
|
+
// a difference takes all bars of a point: the segments of a stack together are its sum
|
|
557
|
+
const sumOf = (id, point) => {
|
|
558
|
+
const visual = id != null ? targets.get(id) : undefined;
|
|
559
|
+
if (!visual)
|
|
560
|
+
return { problem: `no target "${id}" on this page` };
|
|
561
|
+
const state = states.get(visual);
|
|
562
|
+
const found = state && point ? matchPoint(state, Object.assign(Object.assign({}, point), { part: "element" })) : [];
|
|
563
|
+
const bars = found.filter((match) => match.value != null);
|
|
564
|
+
if (bars.length === 0) {
|
|
565
|
+
return { problem: `no bar with a value matches the point ${JSON.stringify(point)} in "${id}"` };
|
|
566
|
+
}
|
|
567
|
+
// bars side by side or behind each other are no sum: the point must name one of them
|
|
568
|
+
if (bars.length > 1 && !bars.every((bar) => bar.stacked)) {
|
|
569
|
+
return { problem: `${bars.length} elements match the point ${JSON.stringify(point)} in "${id}"` };
|
|
570
|
+
}
|
|
571
|
+
const host = visual.getBoundingClientRect();
|
|
572
|
+
const left = Math.min(...bars.map((bar) => bar.rect.component.x));
|
|
573
|
+
const top = Math.min(...bars.map((bar) => bar.rect.component.y));
|
|
574
|
+
const right = Math.max(...bars.map((bar) => bar.rect.component.x + bar.rect.component.width));
|
|
575
|
+
const bottom = Math.max(...bars.map((bar) => bar.rect.component.y + bar.rect.component.height));
|
|
576
|
+
const screen = (rect) => ({
|
|
577
|
+
x: host.left + rect.x,
|
|
578
|
+
y: host.top + rect.y,
|
|
579
|
+
width: rect.width,
|
|
580
|
+
height: rect.height,
|
|
581
|
+
});
|
|
582
|
+
return {
|
|
583
|
+
box: { x: host.left + left, y: host.top + top, width: right - left, height: bottom - top },
|
|
584
|
+
negatives: bars.filter((bar) => bar.value < 0).map((bar) => screen(bar.rect.component)),
|
|
585
|
+
value: bars.reduce((sum, bar) => sum + bar.value, 0),
|
|
586
|
+
};
|
|
587
|
+
};
|
|
470
588
|
const toLocal = this.toLocalSpace();
|
|
471
589
|
// here the text runs along x and a layout px is a px, also on a rotated or scaled page
|
|
472
590
|
const textToLocal = ({ box, sign = 0 }) => {
|
|
@@ -479,6 +597,26 @@ const AnnotationLayer = class {
|
|
|
479
597
|
const marks = [];
|
|
480
598
|
const problems = [];
|
|
481
599
|
for (const item of this.parsedItems) {
|
|
600
|
+
if (item.mark === "difference") {
|
|
601
|
+
const first = sumOf(item.target, item.point);
|
|
602
|
+
const second = sumOf((_a = item.to) !== null && _a !== void 0 ? _a : item.target, item.toPoint);
|
|
603
|
+
const failed = "problem" in first ? first : "problem" in second ? second : undefined;
|
|
604
|
+
if (failed) {
|
|
605
|
+
problems.push({ item, problem: failed.problem });
|
|
606
|
+
continue;
|
|
607
|
+
}
|
|
608
|
+
const [a, b] = [first, second];
|
|
609
|
+
// the level of a sum: the top for positive values, and below it by the length of the negative ones.
|
|
610
|
+
// Measured in the space of the layer, so it holds on a turned page too.
|
|
611
|
+
const levelOf = (anchor) => toLocal(anchor.box).y + anchor.negatives.reduce((sum, bar) => sum + toLocal(bar).height, 0);
|
|
612
|
+
const mark = buildDifference(item, toLocal(a.box), toLocal(b.box), a.value, b.value, em, {
|
|
613
|
+
from: levelOf(a),
|
|
614
|
+
to: levelOf(b),
|
|
615
|
+
});
|
|
616
|
+
if (mark)
|
|
617
|
+
marks.push(mark);
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
482
620
|
const from = anchorOf(item.target, item.point);
|
|
483
621
|
const to = item.mark === "arrow" ? anchorOf(item.to, item.toPoint) : undefined;
|
|
484
622
|
const failed = "problem" in from ? from : to && "problem" in to ? to : undefined;
|
|
@@ -492,7 +630,8 @@ const AnnotationLayer = class {
|
|
|
492
630
|
whole: start.whole,
|
|
493
631
|
area,
|
|
494
632
|
text: start.text && textToLocal(start.text),
|
|
495
|
-
obstacles: (
|
|
633
|
+
obstacles: (_b = start.obstacles) === null || _b === void 0 ? void 0 : _b.map(textToLocal),
|
|
634
|
+
stacked: start.stacked,
|
|
496
635
|
});
|
|
497
636
|
if (mark) {
|
|
498
637
|
marks.push(mark);
|
|
@@ -612,18 +751,22 @@ const AnnotationLayer = class {
|
|
|
612
751
|
return (h("g", null, h("circle", { cx: badge.cx, cy: badge.cy, r: badge.r, style: { fill: color } }), badge.label != null ? (h("text", { class: "badge-text", x: badge.cx, y: badge.cy, style: { fontSize: `${badge.r * 1.1}px` } }, badge.label)) : null));
|
|
613
752
|
}
|
|
614
753
|
renderMark(mark) {
|
|
615
|
-
var _a, _b;
|
|
754
|
+
var _a, _b, _c;
|
|
616
755
|
const color = annotationColor(mark.color, this.componentStyle(($) => $["bn-annotation"]));
|
|
617
756
|
if (mark.kind === "marker") {
|
|
618
757
|
return (h("g", { class: "mark marker", "data-label": mark.badge.label }, this.renderBadge(mark.badge, color)));
|
|
619
758
|
}
|
|
620
759
|
if (mark.kind === "frame") {
|
|
621
|
-
return (h("g", { class: "mark frame", "data-label": (_a = mark.badge) === null || _a === void 0 ? void 0 : _a.label }, h("rect", { x: mark.x, y: mark.y, width: mark.width, height: mark.height, rx: mark.rx, ry: mark.ry, style: { fill: "none", stroke: color, strokeWidth: "1.5" } }), this.renderBadge(mark.badge, color)));
|
|
760
|
+
return (h("g", { class: "mark frame", "data-label": (_a = mark.badge) === null || _a === void 0 ? void 0 : _a.label }, h("rect", { x: mark.x, y: mark.y, width: mark.width, height: mark.height, rx: mark.rx, ry: mark.ry, style: { fill: mark.caption ? "#ffffff" : "none", stroke: color, strokeWidth: "1.5" } }), mark.caption ? (h("text", { class: "mark-text caption", x: mark.caption.x, y: mark.caption.y }, mark.caption.text)) : null, this.renderBadge(mark.badge, color)));
|
|
761
|
+
}
|
|
762
|
+
if (mark.kind === "difference") {
|
|
763
|
+
const main = annotationColor(undefined, this.componentStyle(($) => $["bn-annotation"]));
|
|
764
|
+
return (h("g", { class: "mark difference", "data-label": (_b = mark.badge) === null || _b === void 0 ? void 0 : _b.label }, mark.lines.map((line) => (h("line", { class: "difference-line", x1: line.x1, y1: line.y1, x2: line.x2, y2: line.y2 }))), h("rect", { x: mark.bar.x, y: mark.bar.y, width: mark.bar.width, height: mark.bar.height, style: { fill: color } }), h("text", { class: "mark-text", x: mark.text.x, y: mark.text.y, style: { textAnchor: mark.text.anchor } }, mark.text.value, mark.text.percent ? (h("tspan", { class: "percent", dx: "0.35em" }, mark.text.percent)) : null), mark.frame ? (h("rect", { x: mark.frame.x, y: mark.frame.y, width: mark.frame.width, height: mark.frame.height, rx: mark.frame.r, ry: mark.frame.r, style: { fill: "none", stroke: main, strokeWidth: "1.5" } })) : null, this.renderBadge(mark.badge, main)));
|
|
622
765
|
}
|
|
623
|
-
return (h("g", { class: "mark arrow", "data-label": (
|
|
766
|
+
return (h("g", { class: "mark arrow", "data-label": (_c = mark.badge) === null || _c === void 0 ? void 0 : _c.label }, h("line", { x1: mark.x1, y1: mark.y1, x2: mark.x2, y2: mark.y2, style: { stroke: color, strokeWidth: "1.5" } }), h("polygon", { points: mark.head, style: { fill: color } }), this.renderBadge(mark.badge, color)));
|
|
624
767
|
}
|
|
625
768
|
render() {
|
|
626
|
-
return (h(Host, { key: '
|
|
769
|
+
return (h(Host, { key: 'f2864246b86078e97a15f58cab7f46a792e6d300' }, h("svg", { key: '52f932a7f8dff3e00773f8f827c82ec62848cb34', ref: (el) => (this.svg = el) }, this.marks.map((mark) => this.renderMark(mark)))));
|
|
627
770
|
}
|
|
628
771
|
get element() { return getElement(this); }
|
|
629
772
|
static get watchers() { return {
|
|
@@ -931,6 +1074,14 @@ function levelKey(level, value) {
|
|
|
931
1074
|
const SCENARIO_GROUP_RE = /^Scenario([1-4])$/;
|
|
932
1075
|
const STACK_SEGMENT_RE = /^stacked_(?:col|bar)_(\d+)_seg_\d+$/;
|
|
933
1076
|
const STACK_SEGMENTS = 'g[id^="stacked_col_"], g[id^="stacked_bar_"]';
|
|
1077
|
+
/** The value a bar group carries in `data-bn-value`. */
|
|
1078
|
+
function readValue(group) {
|
|
1079
|
+
const raw = group.getAttribute("data-bn-value");
|
|
1080
|
+
if (raw == null || raw === "")
|
|
1081
|
+
return undefined;
|
|
1082
|
+
const value = Number(raw);
|
|
1083
|
+
return Number.isFinite(value) ? value : undefined;
|
|
1084
|
+
}
|
|
934
1085
|
/** Nearest `#Scenario1..4` ancestor of an element, as "scenario1".."scenario4". */
|
|
935
1086
|
function scenarioOf(el, root) {
|
|
936
1087
|
var _a;
|
|
@@ -1003,6 +1154,7 @@ function collectChartSegmentElements(svgRoot, segment, origins) {
|
|
|
1003
1154
|
index: (_a = indexOfGroup(group.id)) !== null && _a !== void 0 ? _a : walkIndex,
|
|
1004
1155
|
rect: measure(group, origins),
|
|
1005
1156
|
point: readLayoutPoint(group),
|
|
1157
|
+
value: readValue(group),
|
|
1006
1158
|
};
|
|
1007
1159
|
elements.push(bar);
|
|
1008
1160
|
});
|
|
@@ -1022,6 +1174,7 @@ function collectChartSegmentElements(svgRoot, segment, origins) {
|
|
|
1022
1174
|
index: Number(match[1]),
|
|
1023
1175
|
rect: measure(group, origins),
|
|
1024
1176
|
point,
|
|
1177
|
+
value: readValue(group),
|
|
1025
1178
|
};
|
|
1026
1179
|
elements.push(bar);
|
|
1027
1180
|
});
|
|
@@ -9705,7 +9858,8 @@ let Label$1 = class Label {
|
|
|
9705
9858
|
.stroke(background)
|
|
9706
9859
|
.fill(background)
|
|
9707
9860
|
.opacity(0.9)
|
|
9708
|
-
|
|
9861
|
+
// the box of a centred label is already centred with its margin
|
|
9862
|
+
.move(this.horizontalHookLocation === HookLocation$1.Center ? rectX : rectX - 1, rectY)
|
|
9709
9863
|
.insertBefore(text);
|
|
9710
9864
|
}
|
|
9711
9865
|
return text;
|
|
@@ -19212,14 +19366,22 @@ const Chart = class {
|
|
|
19212
19366
|
* {
|
|
19213
19367
|
* "by": "scenarios" | "dimensions",
|
|
19214
19368
|
* "mode": "absolute" | "relative" | "absolute-relative",
|
|
19215
|
-
* "order": "asc" | "desc" | "dataset"
|
|
19369
|
+
* "order": "asc" | "desc" | "dataset",
|
|
19370
|
+
* "notation": "none" | "scenario",
|
|
19371
|
+
* "legend": "left" | "right" | "both" | "none",
|
|
19372
|
+
* "percentMark": true | false
|
|
19216
19373
|
* }
|
|
19217
19374
|
* ```
|
|
19218
19375
|
*
|
|
19219
19376
|
* - `by` (required): What a stack is made of.
|
|
19220
|
-
* - `"scenarios"` - stack the scenarios from the `scenarios` prop as layers
|
|
19221
|
-
*
|
|
19222
|
-
*
|
|
19377
|
+
* - `"scenarios"` - stack the scenarios from the `scenarios` prop as layers,
|
|
19378
|
+
* four at most.
|
|
19379
|
+
* - `"dimensions"` - one segment per value of the `category` column of the
|
|
19380
|
+
* dataset, ordered by `categoryIndex`, else by first appearance. There is
|
|
19381
|
+
* no limit on the number of series, and a series keeps its colour in
|
|
19382
|
+
* every period. The first scenario is drawn. With `scenario-switch` the
|
|
19383
|
+
* scenario that has values in the period is drawn, so one axis can go
|
|
19384
|
+
* from AC to FC to PL.
|
|
19223
19385
|
* - `mode` (optional, default `"absolute"`):
|
|
19224
19386
|
* - `"absolute"` - additive stacking, axis shows absolute units.
|
|
19225
19387
|
* - `"relative"` - 100% stacking, axis shows 0%-100%. `unit-scaling` is
|
|
@@ -19230,6 +19392,17 @@ const Chart = class {
|
|
|
19230
19392
|
* - `order` (optional, default `"dataset"`): Segment order within each stack.
|
|
19231
19393
|
* `"asc"` / `"desc"` sort segments by value; `"dataset"` preserves the
|
|
19232
19394
|
* original data/scenario order.
|
|
19395
|
+
* - `notation` (optional, default `"none"`): with `"scenario"` a segment takes
|
|
19396
|
+
* the look of its scenario. A forecast segment is hatched over the shade of
|
|
19397
|
+
* its series, a plan segment is outlined, and the first series takes the
|
|
19398
|
+
* fill of the scenario from `barStyles`.
|
|
19399
|
+
* - `legend` (optional, default `"left"`): where the series names stand. Left
|
|
19400
|
+
* of the first column, right of the last column with a value, at both, or
|
|
19401
|
+
* nowhere.
|
|
19402
|
+
* - `percentMark` (optional, default `false`): for `mode: "relative"`. The
|
|
19403
|
+
* shares are plain numbers without the % sign, with
|
|
19404
|
+
* `data-format-digits-percent` digits, and one `100%` mark stands at the
|
|
19405
|
+
* upper end of the stack, on the side of the series names.
|
|
19233
19406
|
*
|
|
19234
19407
|
* @default '' (empty - no stacking)
|
|
19235
19408
|
*
|
|
@@ -19323,7 +19496,8 @@ const Chart = class {
|
|
|
19323
19496
|
* has no value, the next scenario with a value is drawn in its place with
|
|
19324
19497
|
* its value label. A vertical line marks the change, and the scenario names
|
|
19325
19498
|
* stand under the axis. Variances with the same reference and type share
|
|
19326
|
-
* one row.
|
|
19499
|
+
* one row. A chart with one scenario gets the name of that scenario under
|
|
19500
|
+
* the axis. Bar mode, without a stack or with a stack by dimensions.
|
|
19327
19501
|
*/
|
|
19328
19502
|
this.scenarioSwitch = false;
|
|
19329
19503
|
/**
|
|
@@ -19903,7 +20077,7 @@ const Chart = class {
|
|
|
19903
20077
|
}
|
|
19904
20078
|
prepareAxisLabelsMode() {
|
|
19905
20079
|
var _a;
|
|
19906
|
-
return AxisLabelsMode[(_a = this.axisLabelsMode) === null || _a === void 0 ? void 0 : _a.toUpperCase()];
|
|
20080
|
+
return AxisLabelsMode[(_a = this.axisLabelsMode) === null || _a === void 0 ? void 0 : _a.toUpperCase().replace("-", "_")];
|
|
19907
20081
|
}
|
|
19908
20082
|
prepareFilter() {
|
|
19909
20083
|
if (this.filter.length === 0) {
|
|
@@ -19972,36 +20146,48 @@ const Chart = class {
|
|
|
19972
20146
|
prepareStackConfig() {
|
|
19973
20147
|
if (isBlankInput(this.stack)) {
|
|
19974
20148
|
this.errors.remove("WARN_stack_dimensions_scenarios");
|
|
20149
|
+
this.errors.remove("WARN_stack_scenarios_max");
|
|
19975
20150
|
return null;
|
|
19976
20151
|
}
|
|
19977
20152
|
try {
|
|
19978
20153
|
const parsed = JSON.parse(this.stack);
|
|
19979
20154
|
const by = parsed.by;
|
|
19980
20155
|
const errId = "WARN_stack_dimensions_scenarios";
|
|
19981
|
-
|
|
19982
|
-
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
})
|
|
19989
|
-
}
|
|
19990
|
-
else {
|
|
19991
|
-
this.errors.remove(errId);
|
|
19992
|
-
}
|
|
20156
|
+
const maxId = "WARN_stack_scenarios_max";
|
|
20157
|
+
const scenarios = this.prepareScenarios();
|
|
20158
|
+
// with scenarioSwitch the further scenarios continue the first one along the time axis
|
|
20159
|
+
if (by === StackBy.DIMENSIONS && scenarios.length > 1 && !this.scenarioSwitch) {
|
|
20160
|
+
this.errors.addOrReplace({
|
|
20161
|
+
id: errId,
|
|
20162
|
+
type: "warning",
|
|
20163
|
+
message: `stack by dimensions: only the first scenario "${scenarios[0]}" is used, the rest (${scenarios.slice(1).join(", ")}) are discarded.`,
|
|
20164
|
+
});
|
|
19993
20165
|
}
|
|
19994
20166
|
else {
|
|
19995
20167
|
this.errors.remove(errId);
|
|
19996
20168
|
}
|
|
20169
|
+
if (by === StackBy.SCENARIOS && scenarios.length > 4) {
|
|
20170
|
+
this.errors.addOrReplace({
|
|
20171
|
+
id: maxId,
|
|
20172
|
+
type: "warning",
|
|
20173
|
+
message: `stack by scenarios: at most four scenarios are stacked, the rest (${scenarios.slice(4).join(", ")}) are discarded. Use stack by dimensions for more series.`,
|
|
20174
|
+
});
|
|
20175
|
+
}
|
|
20176
|
+
else {
|
|
20177
|
+
this.errors.remove(maxId);
|
|
20178
|
+
}
|
|
19997
20179
|
return {
|
|
19998
20180
|
by,
|
|
19999
20181
|
mode: parsed.mode || StackMode.ABSOLUTE,
|
|
20000
20182
|
order: parsed.order || StackOrder.DATASET,
|
|
20183
|
+
notation: parsed.notation === "scenario" ? "scenario" : "none",
|
|
20184
|
+
legend: ["right", "both", "none"].includes(parsed.legend) ? parsed.legend : "left",
|
|
20185
|
+
percentMark: parsed.percentMark === true,
|
|
20001
20186
|
};
|
|
20002
20187
|
}
|
|
20003
20188
|
catch (_a) {
|
|
20004
20189
|
this.errors.remove("WARN_stack_dimensions_scenarios");
|
|
20190
|
+
this.errors.remove("WARN_stack_scenarios_max");
|
|
20005
20191
|
return null;
|
|
20006
20192
|
}
|
|
20007
20193
|
}
|
|
@@ -20032,7 +20218,7 @@ const Chart = class {
|
|
|
20032
20218
|
const isBase = segmentVariances.length === 0;
|
|
20033
20219
|
const scenarios = this.hidesScenarios() ? variancesScenarios(segmentVariances) : this.prepareScenarios();
|
|
20034
20220
|
// only the base chart draws a stack, a variance needs both of its scenarios
|
|
20035
|
-
const effectiveScenarios = isBase && (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS ? scenarios.slice(0, 1) : scenarios;
|
|
20221
|
+
const effectiveScenarios = isBase && (stackConfig === null || stackConfig === void 0 ? void 0 : stackConfig.by) === StackBy.DIMENSIONS && !this.scenarioSwitch ? scenarios.slice(0, 1) : scenarios;
|
|
20036
20222
|
return (h("bn-chart-time-renderer", { tableName: this.datasetName, dataVersion: this.dataVersion, chartTitle: this.prepareChartTitle(idx), scenarios: effectiveScenarios, variances: segmentVariances.length > 0 ? segmentVariances : [""], hideAxisLabels: this.prepareHideAxisLabels(idx), pixelPerUnit: ppu, pixelPerPercentage: ppp, reportAutoScaling: this.handleAutoScalingReport, errors: this.errors, leftSideOffsetForHorizontalSync: this.prepareLeftSideOffset(preparedI18n, preparedStyle), styles: preparedStyle, i18n: preparedI18n, dateInterval: this.prepareDateInterval(), intervalSpanLimit: this.prepareIntervalSpanLimit(), axisLabelsMode: this.prepareAxisLabelsMode(), filter: this.prepareFilter(), "measure-scale": this.prepareMeasureScale(), "measure-unit": this.prepareMeasureUnit(), showOverlayAvg: this.prepareAvg(), showOverlayMedian: this.prepareMedian(), showMeasureScale: this.prepareShowMeasureScale(idx), chartMode: this.prepareChartMode(), maxBars: this.prepareMaxBars(), stackConfig: stackConfig, lineFullWidth: this.prepareLineFullWidth(), dataFormatDigits: { percent: this.dataFormatDigitsPercent, decimal: this.dataFormatDigitsDecimal }, axisLabelsStep: Math.max(1, Math.floor(Number(this.axisLabelsStep) || 1)), scenarioSwitch: this.scenarioSwitch, axisTitlePosition: this.prepareAxisTitlePosition(), containerWidth: fullParentWidth, parentDimensions: this.prepareDimension(), ruleSetConfig: this.ruleSetConfig() }));
|
|
20037
20223
|
}
|
|
20038
20224
|
/**
|
|
@@ -20165,7 +20351,7 @@ const Chart = class {
|
|
|
20165
20351
|
this.errors.remove("WARN_scenarios_none");
|
|
20166
20352
|
}
|
|
20167
20353
|
const fontStyles = this.getFontStyles();
|
|
20168
|
-
return (h(Host, { key: '
|
|
20354
|
+
return (h(Host, { key: 'c998214052bad19811135a7c48e669d6ebfdb8cc', style: fontStyles }, h("div", { key: '8c877fda1575246a4cecc5610aa3b66d6b6f60ce', class: "container" }, segments.map(this.chartTemplate))));
|
|
20169
20355
|
}
|
|
20170
20356
|
get element() { return getElement(this); }
|
|
20171
20357
|
static get watchers() { return {
|
|
@@ -21109,7 +21295,7 @@ class Column {
|
|
|
21109
21295
|
return this;
|
|
21110
21296
|
}
|
|
21111
21297
|
draw(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
|
|
21112
|
-
var _a, _b, _c;
|
|
21298
|
+
var _a, _b, _c, _d;
|
|
21113
21299
|
// TODE: JHE: Remove DataFOrmatDigits Type Duplicates
|
|
21114
21300
|
if (this.isEmpty()) {
|
|
21115
21301
|
return this;
|
|
@@ -21125,6 +21311,9 @@ class Column {
|
|
|
21125
21311
|
}
|
|
21126
21312
|
this.scenarioGroup.attr(dataPointAttributes(this.dataPoint.key));
|
|
21127
21313
|
(_c = this.columnGroup) === null || _c === void 0 ? void 0 : _c.attr(dataPointAttributes(this.dataPoint.key, "element"));
|
|
21314
|
+
if (this.dataPoint.key && Number.isFinite(this.dataPoint.value)) {
|
|
21315
|
+
(_d = this.columnGroup) === null || _d === void 0 ? void 0 : _d.attr("data-bn-value", this.dataPoint.value);
|
|
21316
|
+
}
|
|
21128
21317
|
if (this.columnGroup != null) {
|
|
21129
21318
|
if (this.isOverflowing && this.overflowConfig) {
|
|
21130
21319
|
this.drawOverdriveBar(fillStyle, strokeStyle);
|
|
@@ -21879,7 +22068,9 @@ class LineSeries {
|
|
|
21879
22068
|
* The last segment can draw the total label of the full stack via drawTotalLabel().
|
|
21880
22069
|
*/
|
|
21881
22070
|
class StackedColumn {
|
|
21882
|
-
constructor(position, styles, dataPoint, index, segment, _segmentLabel, segmentIndex, stackMode, stack, _isScenarioStack, parentGroup) {
|
|
22071
|
+
constructor(position, styles, dataPoint, index, segment, _segmentLabel, segmentIndex, stackMode, stack, _isScenarioStack, parentGroup, notation = false, plainShares = false) {
|
|
22072
|
+
this.notation = notation;
|
|
22073
|
+
this.plainShares = plainShares;
|
|
21883
22074
|
this.hasData = false;
|
|
21884
22075
|
this.position = position;
|
|
21885
22076
|
this.styles = styles;
|
|
@@ -21896,6 +22087,7 @@ class StackedColumn {
|
|
|
21896
22087
|
}
|
|
21897
22088
|
}
|
|
21898
22089
|
draw(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
|
|
22090
|
+
var _a, _b;
|
|
21899
22091
|
// a segment without a value (NaN) keeps its place in the stack, so the colours stay, but draws nothing
|
|
21900
22092
|
if (!this.hasData || !Number.isFinite(this.dataPoint.value)) {
|
|
21901
22093
|
return;
|
|
@@ -21909,10 +22101,28 @@ class StackedColumn {
|
|
|
21909
22101
|
const xPos = this.position.getColumnCenterPositionX(this.index);
|
|
21910
22102
|
const columnWidth = this.position.getColumnWidth();
|
|
21911
22103
|
const colors = this.styles.stackColors;
|
|
21912
|
-
|
|
21913
|
-
|
|
21914
|
-
|
|
22104
|
+
let fillColor = colors[this.segmentIndex % colors.length];
|
|
22105
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22106
|
+
let fillStyle = { color: fillColor };
|
|
22107
|
+
let strokeStyle = { color: fillColor, width: 0.5 };
|
|
22108
|
+
let hatched = false;
|
|
22109
|
+
// FC and PL: the series keeps its shade, the scenario adds the hatching or the outline.
|
|
22110
|
+
// The first series is the darkest: it takes the fill of the scenario, as a plain column does.
|
|
22111
|
+
const family = getScenarioPrefix((_a = this.dataPoint.scenario) !== null && _a !== void 0 ? _a : "");
|
|
22112
|
+
if (this.notation && (family === "fc" || family === "pl")) {
|
|
22113
|
+
const look = this.styles.barStyles.getSVGStyle(family);
|
|
22114
|
+
if (this.segmentIndex === 0) {
|
|
22115
|
+
fillColor = look.fill;
|
|
22116
|
+
}
|
|
22117
|
+
fillStyle = { color: fillColor };
|
|
22118
|
+
strokeStyle = { color: look.stroke, width: 1 };
|
|
22119
|
+
if (look.fillpattern === "hatched") {
|
|
22120
|
+
hatched = true;
|
|
22121
|
+
fillStyle = (_b = this.hatchPattern(fillColor, look.stroke)) !== null && _b !== void 0 ? _b : fillStyle;
|
|
22122
|
+
}
|
|
22123
|
+
}
|
|
21915
22124
|
this.columnGroup.attr(dataPointAttributes(this.dataPoint.key, "element"));
|
|
22125
|
+
this.columnGroup.attr("data-bn-value", value);
|
|
21916
22126
|
// Draw rectangle
|
|
21917
22127
|
this.columnGroup
|
|
21918
22128
|
.rect(columnWidth, Math.max(segmentHeight, 0.5))
|
|
@@ -21920,26 +22130,46 @@ class StackedColumn {
|
|
|
21920
22130
|
.stroke(strokeStyle)
|
|
21921
22131
|
.y(yPos)
|
|
21922
22132
|
.cx(xPos);
|
|
21923
|
-
// Draw segment value label if segment is tall enough
|
|
21924
|
-
const MIN_SEGMENT_HEIGHT_FOR_LABEL = 18;
|
|
22133
|
+
// Draw segment value label if the segment is tall enough: 18px, less for a font that is smaller than that
|
|
22134
|
+
const MIN_SEGMENT_HEIGHT_FOR_LABEL = Math.min(18, (this.styles.fontStyles.size || 18) * 1.15);
|
|
21925
22135
|
if (segmentHeight >= MIN_SEGMENT_HEIGHT_FOR_LABEL) {
|
|
21926
22136
|
const labelY = yPos + segmentHeight / 2;
|
|
22137
|
+
// a label on a hatching keeps the background of a plain label
|
|
22138
|
+
const onFill = (label) => (hatched ? label : label.setSegmentFill(fillColor));
|
|
21927
22139
|
if (this.stackMode === StackMode.RELATIVE || this.stackMode === StackMode.ABSOLUTE_RELATIVE) {
|
|
21928
|
-
|
|
21929
|
-
|
|
21930
|
-
.
|
|
22140
|
+
// with the 100 % mark the unit stands there once, and the shares are plain numbers
|
|
22141
|
+
const labelValue = this.plainShares
|
|
22142
|
+
? Formatter.number(this.segment.share * 100, "decimal", dataFormatDigits.percent, dataFormatDigits.percent, 1, this.styles.locale)
|
|
22143
|
+
: Formatter.number(this.segment.share, "percent", dataFormatDigits.percent, dataFormatDigits.percent, 1, this.styles.locale);
|
|
22144
|
+
onFill(new Label$1(this.group, xPos, labelY, "STACK_SEG", labelValue, this.styles, HookLocation$1.Center, HookLocation$1.Center))
|
|
21931
22145
|
.setPoint(this.dataPoint.key)
|
|
21932
22146
|
.forceStringTypeDraw();
|
|
21933
22147
|
}
|
|
21934
22148
|
else {
|
|
21935
22149
|
// Pass raw numeric value - Label.draw() formats with measureScale
|
|
21936
|
-
new Label$1(this.group, xPos, labelY, "STACK_SEG", value, this.styles, HookLocation$1.Center, HookLocation$1.Center)
|
|
21937
|
-
.setSegmentFill(fillColor)
|
|
22150
|
+
onFill(new Label$1(this.group, xPos, labelY, "STACK_SEG", value, this.styles, HookLocation$1.Center, HookLocation$1.Center))
|
|
21938
22151
|
.setPoint(this.dataPoint.key)
|
|
21939
22152
|
.draw(true, dataFormatDigits, measureScale);
|
|
21940
22153
|
}
|
|
21941
22154
|
}
|
|
21942
22155
|
}
|
|
22156
|
+
/** The hatching of a forecast over the shade of the series. One pattern per shade in the SVG. */
|
|
22157
|
+
hatchPattern(background, color) {
|
|
22158
|
+
const root = this.group.root();
|
|
22159
|
+
if (!root)
|
|
22160
|
+
return null;
|
|
22161
|
+
const id = `pattern-stack-fc-${this.segmentIndex}`;
|
|
22162
|
+
const existing = root.findOne(`#${id}`);
|
|
22163
|
+
if (existing)
|
|
22164
|
+
return existing;
|
|
22165
|
+
return root
|
|
22166
|
+
.pattern(10, 10, (add) => {
|
|
22167
|
+
add.rect(10, 10).fill(background);
|
|
22168
|
+
add.line(0, 5, 5, 0).stroke({ width: 1, color, linecap: "square" });
|
|
22169
|
+
add.line(5, 10, 10, 5).stroke({ width: 1, color, linecap: "square" });
|
|
22170
|
+
})
|
|
22171
|
+
.id(id);
|
|
22172
|
+
}
|
|
21943
22173
|
/**
|
|
21944
22174
|
* Draw the signed total of the stack: above the positive side, or below the negative side for a negative total.
|
|
21945
22175
|
*/
|
|
@@ -22562,6 +22792,8 @@ class TimeChart {
|
|
|
22562
22792
|
this.scenarioSwitch = (_b = config.scenarioSwitch) !== null && _b !== void 0 ? _b : false;
|
|
22563
22793
|
this.axisTitlePosition = (_c = config.axisTitlePosition) !== null && _c !== void 0 ? _c : "left";
|
|
22564
22794
|
this.dateInterval = this.findDateInterval(config.dateInterval);
|
|
22795
|
+
// the model of a stack by dimension holds the series
|
|
22796
|
+
this.stackConfig = config.stackConfig;
|
|
22565
22797
|
this.dataModel = this.populateModel(scenarios, this.dateInterval);
|
|
22566
22798
|
this.variancesDataModel = this.populateVarianceModel(config.variances, this.dataModel);
|
|
22567
22799
|
this.configTitle = config.title;
|
|
@@ -22685,7 +22917,9 @@ class TimeChart {
|
|
|
22685
22917
|
}).width;
|
|
22686
22918
|
titleEnd = axisEnd + this.position.spacings.labelToColumn + titleWidth + this.styles.padding.right;
|
|
22687
22919
|
}
|
|
22688
|
-
|
|
22920
|
+
const legendWidth = this.legendWidth("right");
|
|
22921
|
+
const legendEnd = legendWidth > 0 ? axisEnd + this.position.spacings.labelToColumn + legendWidth + this.styles.padding.right : 0;
|
|
22922
|
+
return Math.max(axisEnd + labelBuffer, bboxTotal, titleEnd, legendEnd);
|
|
22689
22923
|
}
|
|
22690
22924
|
getAllocatedCanvasHeight() {
|
|
22691
22925
|
if (this.smallestVarianceDataPointValue.value == null ||
|
|
@@ -22718,9 +22952,71 @@ class TimeChart {
|
|
|
22718
22952
|
: this.scenariosArea.height;
|
|
22719
22953
|
return Math.max(analyticalHeight, bboxHeight) + this.switchNamesHeight();
|
|
22720
22954
|
}
|
|
22721
|
-
/**
|
|
22955
|
+
/**
|
|
22956
|
+
* Room for the second row under the category labels: the scenario names of a
|
|
22957
|
+
* `scenarioSwitch` chart, and in `two-row` mode the parent periods.
|
|
22958
|
+
*/
|
|
22722
22959
|
switchNamesHeight() {
|
|
22723
|
-
return !this.hideAxisLabels && this.
|
|
22960
|
+
return !this.hideAxisLabels && this.contextRow().length > 0 ? this.position.dataLabelHeight : 0;
|
|
22961
|
+
}
|
|
22962
|
+
/** The parent period of a period in `two-row` mode: the year of a month, quarter or week, the month of a day. */
|
|
22963
|
+
parentPeriodLabel(date) {
|
|
22964
|
+
if (this.axisLabelsMode !== AxisLabelsMode.TWO_ROW || date == null || !date.isValid) {
|
|
22965
|
+
return "";
|
|
22966
|
+
}
|
|
22967
|
+
switch (this.dateInterval) {
|
|
22968
|
+
case DateDistance.MONTH:
|
|
22969
|
+
case DateDistance.QUARTER:
|
|
22970
|
+
return date.setLocale(this.locale).toFormat("yyyy");
|
|
22971
|
+
case DateDistance.WEEK:
|
|
22972
|
+
// week 1 can start in December: the week year, as the week labels use it
|
|
22973
|
+
return date.setLocale(this.locale).toFormat("kkkk");
|
|
22974
|
+
case DateDistance.DAY:
|
|
22975
|
+
return date.setLocale(this.locale).toFormat("LLL yyyy");
|
|
22976
|
+
default:
|
|
22977
|
+
return "";
|
|
22978
|
+
}
|
|
22979
|
+
}
|
|
22980
|
+
/**
|
|
22981
|
+
* The texts of the second row under the category labels. `two-row` mode: the
|
|
22982
|
+
* parent period under the first period and where it changes, joined with the
|
|
22983
|
+
* scenario name where a run starts, each under its period. Else the scenario
|
|
22984
|
+
* names alone, each under the middle of its run.
|
|
22985
|
+
*/
|
|
22986
|
+
contextRow() {
|
|
22987
|
+
const runs = this.switchRuns();
|
|
22988
|
+
if (this.axisLabelsMode !== AxisLabelsMode.TWO_ROW) {
|
|
22989
|
+
return runs.map((run) => ({
|
|
22990
|
+
from: run.from,
|
|
22991
|
+
to: run.to,
|
|
22992
|
+
text: Formatter.translateScenarioLabel(run.scenario, this.i18n),
|
|
22993
|
+
scenario: run.scenario,
|
|
22994
|
+
}));
|
|
22995
|
+
}
|
|
22996
|
+
// the line chart writes its own labels and has no second row
|
|
22997
|
+
if (!this.isVarianceChart() && this.determineEffectiveChartMode() !== ChartMode.BAR) {
|
|
22998
|
+
return [];
|
|
22999
|
+
}
|
|
23000
|
+
const model = this.isVarianceChart() ? this.variancesDataModel : this.dataModel;
|
|
23001
|
+
const entries = [];
|
|
23002
|
+
let lastParent = "";
|
|
23003
|
+
model.forEach((row, index) => {
|
|
23004
|
+
var _a;
|
|
23005
|
+
const run = runs.find((candidate) => candidate.from === index);
|
|
23006
|
+
const parent = this.parentPeriodLabel(row.date);
|
|
23007
|
+
const parts = [];
|
|
23008
|
+
if (parent !== "" && parent !== lastParent) {
|
|
23009
|
+
parts.push(parent);
|
|
23010
|
+
}
|
|
23011
|
+
lastParent = parent;
|
|
23012
|
+
if (run) {
|
|
23013
|
+
parts.push(Formatter.translateScenarioLabel(run.scenario, this.i18n));
|
|
23014
|
+
}
|
|
23015
|
+
if (parts.length > 0) {
|
|
23016
|
+
entries.push({ from: index, to: index, text: parts.join(" "), scenario: (_a = run === null || run === void 0 ? void 0 : run.scenario) !== null && _a !== void 0 ? _a : "parent" });
|
|
23017
|
+
}
|
|
23018
|
+
});
|
|
23019
|
+
return entries;
|
|
22724
23020
|
}
|
|
22725
23021
|
/** True for a scenario slot that has a value in this period. */
|
|
22726
23022
|
static hasValue(dataPoint) {
|
|
@@ -22731,7 +23027,9 @@ class TimeChart {
|
|
|
22731
23027
|
* periods where the first scenario has none. Empty without `scenarioSwitch`.
|
|
22732
23028
|
*/
|
|
22733
23029
|
followerSlots() {
|
|
22734
|
-
|
|
23030
|
+
// a stack by scenario draws its scenarios on top of each other: nothing follows there
|
|
23031
|
+
const stacksScenarios = this.stackConfig != null && this.stackConfig.by !== StackBy.DIMENSIONS;
|
|
23032
|
+
if (!this.scenarioSwitch || stacksScenarios || this.determineEffectiveChartMode() !== ChartMode.BAR) {
|
|
22735
23033
|
return [];
|
|
22736
23034
|
}
|
|
22737
23035
|
return ["scenario2", "scenario3", "scenario4"].filter((slot) => {
|
|
@@ -22757,8 +23055,13 @@ class TimeChart {
|
|
|
22757
23055
|
}
|
|
22758
23056
|
/** Runs of periods with the same visible scenario. A period without a value belongs to the run before it. */
|
|
22759
23057
|
switchRuns() {
|
|
23058
|
+
const stacksScenarios = this.stackConfig != null && this.stackConfig.by !== StackBy.DIMENSIONS;
|
|
23059
|
+
if (!this.scenarioSwitch || stacksScenarios || this.determineEffectiveChartMode() !== ChartMode.BAR) {
|
|
23060
|
+
return [];
|
|
23061
|
+
}
|
|
22760
23062
|
const followers = this.followerSlots();
|
|
22761
|
-
|
|
23063
|
+
// a chart with one scenario is one run: its scenario still gets its name under the axis
|
|
23064
|
+
if (followers.length === 0 && this.scenarioPropOrder.length !== 1) {
|
|
22762
23065
|
return [];
|
|
22763
23066
|
}
|
|
22764
23067
|
const runs = [];
|
|
@@ -22775,6 +23078,21 @@ class TimeChart {
|
|
|
22775
23078
|
});
|
|
22776
23079
|
return runs;
|
|
22777
23080
|
}
|
|
23081
|
+
/**
|
|
23082
|
+
* Stack by dimensions with `scenarioSwitch`: the scenarios with values that
|
|
23083
|
+
* are not drawn, because they have values in periods of the first scenario
|
|
23084
|
+
* or because the chart is a stacked area. The component warns about them.
|
|
23085
|
+
*/
|
|
23086
|
+
getIgnoredSwitchScenarios() {
|
|
23087
|
+
var _a;
|
|
23088
|
+
if (!this.scenarioSwitch || ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.by) !== StackBy.DIMENSIONS || this.isVarianceChart()) {
|
|
23089
|
+
return [];
|
|
23090
|
+
}
|
|
23091
|
+
const followers = this.followerSlots();
|
|
23092
|
+
return ["scenario2", "scenario3", "scenario4"]
|
|
23093
|
+
.filter((slot) => !followers.includes(slot) && this.dataModel.some((row) => TimeChart.hasValue(row[slot])))
|
|
23094
|
+
.map((slot) => { var _a; return (_a = this.dataModel.find((row) => { var _a; return ((_a = row[slot]) === null || _a === void 0 ? void 0 : _a.scenario) != null; })) === null || _a === void 0 ? void 0 : _a[slot].scenario; });
|
|
23095
|
+
}
|
|
22778
23096
|
/** Number of periods where variances of one row overlap. The component warns about it. */
|
|
22779
23097
|
getVarianceOverlaps() {
|
|
22780
23098
|
return this.varianceOverlaps;
|
|
@@ -23008,6 +23326,8 @@ class TimeChart {
|
|
|
23008
23326
|
if (this.leftSideOffsetForHorizontalSync > -1) {
|
|
23009
23327
|
maxLabelLengthLeft = this.leftSideOffsetForHorizontalSync;
|
|
23010
23328
|
}
|
|
23329
|
+
// the series names of a stack by dimension are not known to the component that hands in the offset
|
|
23330
|
+
maxLabelLengthLeft = Math.max(maxLabelLengthLeft, this.legendWidth("left"));
|
|
23011
23331
|
let min;
|
|
23012
23332
|
let max;
|
|
23013
23333
|
if (this.isVarianceChart()) {
|
|
@@ -23097,6 +23417,7 @@ class TimeChart {
|
|
|
23097
23417
|
return result;
|
|
23098
23418
|
}
|
|
23099
23419
|
populateModel(selectedScenarios, dateInterval) {
|
|
23420
|
+
var _a;
|
|
23100
23421
|
if (this.rowCount === 0 || !this.fromExpr) {
|
|
23101
23422
|
return [];
|
|
23102
23423
|
}
|
|
@@ -23106,8 +23427,64 @@ class TimeChart {
|
|
|
23106
23427
|
this.detectNaNCells(selectedScenarios, result);
|
|
23107
23428
|
result = this.leftOuterJoinDates(result, dateInterval);
|
|
23108
23429
|
const dataModel = this.createDataRows(result, selectedScenarios);
|
|
23430
|
+
if (((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.by) === StackBy.DIMENSIONS) {
|
|
23431
|
+
this.populateSeries(dataModel, selectedScenarios, dateInterval);
|
|
23432
|
+
}
|
|
23109
23433
|
return dataModel;
|
|
23110
23434
|
}
|
|
23435
|
+
/**
|
|
23436
|
+
* Stack by dimension: one series per `category`, ordered by `categoryIndex`, else by first appearance.
|
|
23437
|
+
* Every period gets every series, so a series keeps its place and colour when a value is missing.
|
|
23438
|
+
*/
|
|
23439
|
+
populateSeries(dataModel, selectedScenarios, dateInterval) {
|
|
23440
|
+
const rows = this.queryDataSet(dateInterval, ", [category]", ", [category]");
|
|
23441
|
+
this.detectNaNCells(selectedScenarios, rows);
|
|
23442
|
+
const keyOf = (row) => (row.category == null ? "" : String(row.category));
|
|
23443
|
+
const timeOf = (date) => { var _a, _b; return (_b = (_a = date === null || date === void 0 ? void 0 : date.toMillis) === null || _a === void 0 ? void 0 : _a.call(date)) !== null && _b !== void 0 ? _b : Number.NaN; };
|
|
23444
|
+
const order = [];
|
|
23445
|
+
const byPeriod = new Map();
|
|
23446
|
+
for (const row of rows) {
|
|
23447
|
+
const key = keyOf(row);
|
|
23448
|
+
if (!order.includes(key))
|
|
23449
|
+
order.push(key);
|
|
23450
|
+
const time = timeOf(row.calcdate);
|
|
23451
|
+
if (!byPeriod.has(time))
|
|
23452
|
+
byPeriod.set(time, new Map());
|
|
23453
|
+
byPeriod.get(time).set(key, row);
|
|
23454
|
+
}
|
|
23455
|
+
// `categoryIndex` gives the order when the dataset has it, as for the rows of a structure chart
|
|
23456
|
+
try {
|
|
23457
|
+
const indexRows = this.db.exec(`SELECT [category], MIN(categoryIndex) AS idx FROM ${this.fromExpr} GROUP BY [category]`);
|
|
23458
|
+
const indexOf = new Map(indexRows.map((row) => [row.category == null ? "" : String(row.category), row.idx]));
|
|
23459
|
+
if (order.every((key) => Number.isFinite(indexOf.get(key)))) {
|
|
23460
|
+
order.sort((a, b) => indexOf.get(a) - indexOf.get(b));
|
|
23461
|
+
}
|
|
23462
|
+
}
|
|
23463
|
+
catch (_a) {
|
|
23464
|
+
// no usable index: the order of first appearance stays
|
|
23465
|
+
}
|
|
23466
|
+
const slots = ["scenario1", "scenario2", "scenario3", "scenario4"];
|
|
23467
|
+
for (const entry of dataModel) {
|
|
23468
|
+
const period = byPeriod.get(timeOf(entry.date));
|
|
23469
|
+
entry.series = order.map((key) => {
|
|
23470
|
+
const row = period === null || period === void 0 ? void 0 : period.get(key);
|
|
23471
|
+
const points = {};
|
|
23472
|
+
slots.forEach((slot, index) => {
|
|
23473
|
+
const scenario = selectedScenarios[index];
|
|
23474
|
+
if (scenario == null)
|
|
23475
|
+
return;
|
|
23476
|
+
const raw = row === null || row === void 0 ? void 0 : row[scenario];
|
|
23477
|
+
const value = typeof raw === "number" ? raw : Number.NaN;
|
|
23478
|
+
const point = new DataPoint(value, scenario, this.pixelPerUnit, Scenario.NEU);
|
|
23479
|
+
if (Number.isFinite(value)) {
|
|
23480
|
+
point.key = { date: TimeChart.pointDate(entry.date), scenario, category: key };
|
|
23481
|
+
}
|
|
23482
|
+
points[slot] = point;
|
|
23483
|
+
});
|
|
23484
|
+
return { key, points };
|
|
23485
|
+
});
|
|
23486
|
+
}
|
|
23487
|
+
}
|
|
23111
23488
|
detectNaNCells(scenarios, res) {
|
|
23112
23489
|
res.forEach((row) => {
|
|
23113
23490
|
scenarios.forEach((scenario) => {
|
|
@@ -23485,6 +23862,10 @@ class TimeChart {
|
|
|
23485
23862
|
else if (this.axisLabelsMode === AxisLabelsMode.SHORT) {
|
|
23486
23863
|
datelabel = dateStringFactory.getShortDateString(elements.date, this.dateInterval);
|
|
23487
23864
|
}
|
|
23865
|
+
else if (this.axisLabelsMode === AxisLabelsMode.TWO_ROW && this.dateInterval !== DateDistance.YEAR) {
|
|
23866
|
+
// the parent period stands in the second row
|
|
23867
|
+
datelabel = dateStringFactory.getShortDateString(elements.date, this.dateInterval);
|
|
23868
|
+
}
|
|
23488
23869
|
new Label$1(axisLabelGroup, this.position.getColumnCenterPositionX(index), this.position.getAxisPositionY(isRelative) + offset, "", datelabel, this.styles, hookLocation, HookLocation$1.Center).forceStringTypeDraw();
|
|
23489
23870
|
});
|
|
23490
23871
|
}
|
|
@@ -23516,7 +23897,8 @@ class TimeChart {
|
|
|
23516
23897
|
*/
|
|
23517
23898
|
drawScenarioSwitch(svgContainer) {
|
|
23518
23899
|
const runs = this.switchRuns();
|
|
23519
|
-
|
|
23900
|
+
const entries = this.contextRow();
|
|
23901
|
+
if (runs.length < 2 && entries.length === 0) {
|
|
23520
23902
|
return;
|
|
23521
23903
|
}
|
|
23522
23904
|
const group = svgContainer.group().id("ScenarioSwitch");
|
|
@@ -23534,9 +23916,13 @@ class TimeChart {
|
|
|
23534
23916
|
if (namesHeight === 0) {
|
|
23535
23917
|
return;
|
|
23536
23918
|
}
|
|
23537
|
-
|
|
23538
|
-
|
|
23539
|
-
|
|
23919
|
+
// in two-row mode a text starts at the left edge of its period, like the parent period it carries
|
|
23920
|
+
const leftAligned = this.axisLabelsMode === AxisLabelsMode.TWO_ROW;
|
|
23921
|
+
entries.forEach((entry) => {
|
|
23922
|
+
const x = leftAligned
|
|
23923
|
+
? this.position.getColumnCenterPositionX(entry.from) - this.position.getColumnWidth() / 2
|
|
23924
|
+
: (this.position.getColumnCenterPositionX(entry.from) + this.position.getColumnCenterPositionX(entry.to)) / 2;
|
|
23925
|
+
new Label$1(group, x, bottom - namesHeight, "SWITCH_" + entry.scenario + "_" + entry.from, entry.text, this.styles, HookLocation$1.Top, leftAligned ? HookLocation$1.Left : HookLocation$1.Center).forceStringTypeDraw();
|
|
23540
23926
|
});
|
|
23541
23927
|
}
|
|
23542
23928
|
drawScenarios(dataModel, svgContainer) {
|
|
@@ -23787,14 +24173,52 @@ class TimeChart {
|
|
|
23787
24173
|
* single one. Line mode: the area stacks every scenario in one stack.
|
|
23788
24174
|
*/
|
|
23789
24175
|
stackGroups(row) {
|
|
24176
|
+
var _a;
|
|
23790
24177
|
if (!this.stackConfig)
|
|
23791
24178
|
return [];
|
|
23792
24179
|
const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
|
|
23793
24180
|
const isArea = this.determineEffectiveChartMode() === ChartMode.LINE;
|
|
24181
|
+
const relativeSpan = this.stackConfig.mode === StackMode.RELATIVE ? RELATIVE_STACK_UNITS : 0;
|
|
24182
|
+
// a segment without a value sorts like 0: NaN in the comparison would leave the stack unsorted
|
|
24183
|
+
const sortValue = (segment) => (Number.isFinite(segment.value) ? segment.value : 0);
|
|
24184
|
+
const sortByValue = (list) => {
|
|
24185
|
+
if (this.stackConfig.order === "asc") {
|
|
24186
|
+
list.sort((a, b) => sortValue(a) - sortValue(b));
|
|
24187
|
+
}
|
|
24188
|
+
else if (this.stackConfig.order === "desc") {
|
|
24189
|
+
list.sort((a, b) => sortValue(b) - sortValue(a));
|
|
24190
|
+
}
|
|
24191
|
+
};
|
|
24192
|
+
if (!isScenarioStack && !isArea && row.series) {
|
|
24193
|
+
// one stack of the scenario that is visible in this period
|
|
24194
|
+
const slot = (_a = this.visibleSlot(row, this.followerSlots())) !== null && _a !== void 0 ? _a : "scenario1";
|
|
24195
|
+
const series = [];
|
|
24196
|
+
row.series.forEach((entry, index) => {
|
|
24197
|
+
const dataPoint = entry.points[slot];
|
|
24198
|
+
if (dataPoint) {
|
|
24199
|
+
series.push({
|
|
24200
|
+
value: dataPoint.value,
|
|
24201
|
+
scenario: dataPoint.scenario,
|
|
24202
|
+
dataPoint,
|
|
24203
|
+
colorIndex: index,
|
|
24204
|
+
label: entry.key,
|
|
24205
|
+
});
|
|
24206
|
+
}
|
|
24207
|
+
});
|
|
24208
|
+
if (!series.some((segment) => Number.isFinite(segment.value)))
|
|
24209
|
+
return [];
|
|
24210
|
+
sortByValue(series);
|
|
24211
|
+
return [
|
|
24212
|
+
{
|
|
24213
|
+
prefix: "",
|
|
24214
|
+
segments: series,
|
|
24215
|
+
layout: layoutStack(series.map((segment) => segment.value), relativeSpan),
|
|
24216
|
+
hasValue: true,
|
|
24217
|
+
},
|
|
24218
|
+
];
|
|
24219
|
+
}
|
|
23794
24220
|
const segments = [];
|
|
23795
|
-
for (const key of isScenarioStack
|
|
23796
|
-
? ["scenario1", "scenario2", "scenario3", "scenario4"]
|
|
23797
|
-
: ["scenario1"]) {
|
|
24221
|
+
for (const key of isScenarioStack ? ["scenario1", "scenario2", "scenario3", "scenario4"] : ["scenario1"]) {
|
|
23798
24222
|
const dp = row[key];
|
|
23799
24223
|
if (dp && !dp.isEmpty() && dp.value != null) {
|
|
23800
24224
|
segments.push({ value: dp.value, scenario: dp.scenario, dataPoint: dp });
|
|
@@ -23802,7 +24226,6 @@ class TimeChart {
|
|
|
23802
24226
|
}
|
|
23803
24227
|
if (segments.length === 0)
|
|
23804
24228
|
return [];
|
|
23805
|
-
const relativeSpan = this.stackConfig.mode === StackMode.RELATIVE ? RELATIVE_STACK_UNITS : 0;
|
|
23806
24229
|
const toGroup = (prefix, groupSegments) => ({
|
|
23807
24230
|
prefix,
|
|
23808
24231
|
segments: groupSegments,
|
|
@@ -23838,14 +24261,7 @@ class TimeChart {
|
|
|
23838
24261
|
return groups;
|
|
23839
24262
|
}
|
|
23840
24263
|
}
|
|
23841
|
-
|
|
23842
|
-
const sortValue = (segment) => (Number.isFinite(segment.value) ? segment.value : 0);
|
|
23843
|
-
if (this.stackConfig.order === "asc") {
|
|
23844
|
-
segments.sort((a, b) => sortValue(a) - sortValue(b));
|
|
23845
|
-
}
|
|
23846
|
-
else if (this.stackConfig.order === "desc") {
|
|
23847
|
-
segments.sort((a, b) => sortValue(b) - sortValue(a));
|
|
23848
|
-
}
|
|
24264
|
+
sortByValue(segments);
|
|
23849
24265
|
return [toGroup("", segments)];
|
|
23850
24266
|
}
|
|
23851
24267
|
/**
|
|
@@ -23865,9 +24281,10 @@ class TimeChart {
|
|
|
23865
24281
|
groups.forEach((group, groupIdx) => {
|
|
23866
24282
|
let lastColumn = null;
|
|
23867
24283
|
group.segments.forEach((seg, segIdx) => {
|
|
24284
|
+
var _a;
|
|
23868
24285
|
const column = new StackedColumn(this.position, this.styles, seg.dataPoint, index, group.layout.segments[segIdx], seg.scenario,
|
|
23869
24286
|
// overlay: one colour per group, back=lighter, front=darker
|
|
23870
|
-
groups.length > 1 ? groups.length - 1 - groupIdx : segIdx, this.stackConfig.mode, group.layout, isScenarioStack, stackGroup);
|
|
24287
|
+
groups.length > 1 ? groups.length - 1 - groupIdx : ((_a = seg.colorIndex) !== null && _a !== void 0 ? _a : segIdx), this.stackConfig.mode, group.layout, isScenarioStack, stackGroup, this.stackConfig.notation === "scenario", this.hasPercentMark());
|
|
23871
24288
|
column.draw(this.dataFormatDigits, this.measureScale);
|
|
23872
24289
|
lastColumn = column;
|
|
23873
24290
|
});
|
|
@@ -23886,49 +24303,137 @@ class TimeChart {
|
|
|
23886
24303
|
width: stackBox.width + this.position.spacings.columnWidth,
|
|
23887
24304
|
};
|
|
23888
24305
|
}
|
|
24306
|
+
/** True for a 100 % stack that prints plain shares and one `100%` mark. */
|
|
24307
|
+
hasPercentMark() {
|
|
24308
|
+
var _a;
|
|
24309
|
+
return ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.mode) === StackMode.RELATIVE && this.stackConfig.percentMark === true;
|
|
24310
|
+
}
|
|
24311
|
+
/** The side of the `100%` mark: with the series names, at the left when they stand on both sides or nowhere. */
|
|
24312
|
+
percentMarkSide() {
|
|
24313
|
+
var _a;
|
|
24314
|
+
return ((_a = this.stackConfig) === null || _a === void 0 ? void 0 : _a.legend) === "right" ? "right" : "left";
|
|
24315
|
+
}
|
|
24316
|
+
/** The name of a series of a stack by dimension. A translation of the category wins. */
|
|
24317
|
+
seriesName(key) {
|
|
24318
|
+
return (this.i18n.get(key) || key);
|
|
24319
|
+
}
|
|
24320
|
+
/**
|
|
24321
|
+
* Width of the widest text the stack writes on one side of the columns, 0 when
|
|
24322
|
+
* there is none. The names of a stack by scenario at the left are part of the
|
|
24323
|
+
* left offset the component hands in, so they do not count here.
|
|
24324
|
+
*/
|
|
24325
|
+
legendWidth(side) {
|
|
24326
|
+
var _a, _b;
|
|
24327
|
+
// the stacked area draws no names and no mark
|
|
24328
|
+
if (!this.stackConfig || this.determineEffectiveChartMode() !== ChartMode.BAR)
|
|
24329
|
+
return 0;
|
|
24330
|
+
const legend = (_a = this.stackConfig.legend) !== null && _a !== void 0 ? _a : "left";
|
|
24331
|
+
const texts = [];
|
|
24332
|
+
if (legend === side || legend === "both") {
|
|
24333
|
+
const series = (_b = this.dataModel.find((row) => row.series != null)) === null || _b === void 0 ? void 0 : _b.series;
|
|
24334
|
+
if (series) {
|
|
24335
|
+
texts.push(...series.map((entry) => this.seriesName(entry.key)));
|
|
24336
|
+
}
|
|
24337
|
+
else if (side === "right" && this.stackConfig.by === StackBy.SCENARIOS) {
|
|
24338
|
+
texts.push(...this.lastScenarios.map((scenario) => (this.i18n.get(scenario) || scenario)));
|
|
24339
|
+
}
|
|
24340
|
+
}
|
|
24341
|
+
if (this.hasPercentMark() && this.percentMarkSide() === side) {
|
|
24342
|
+
texts.push("100%");
|
|
24343
|
+
}
|
|
24344
|
+
let width = 0;
|
|
24345
|
+
for (const text of texts) {
|
|
24346
|
+
width = Math.max(width, CalculateSize(text, { font: this.styles.fontStyles.font, fontSize: this.styles.fontStyles.size + "px" }).width);
|
|
24347
|
+
}
|
|
24348
|
+
return width;
|
|
24349
|
+
}
|
|
23889
24350
|
/**
|
|
23890
24351
|
* Draw column headers next to stacked columns showing what each group/segment represents.
|
|
23891
24352
|
* For overlay mode (multiple scenario types): shows one header per group.
|
|
23892
24353
|
* For single-group: shows individual segment headers.
|
|
23893
|
-
* The headers take their place from the first period
|
|
24354
|
+
* The headers at the left take their place from the first period, the ones at
|
|
24355
|
+
* the right from the last period with a value.
|
|
23894
24356
|
*/
|
|
23895
24357
|
drawStackedHeaders(dataModel, svgContainer) {
|
|
24358
|
+
var _a, _b, _c;
|
|
23896
24359
|
if (!this.stackConfig || dataModel.length === 0)
|
|
23897
24360
|
return;
|
|
23898
24361
|
const isScenarioStack = this.stackConfig.by === StackBy.SCENARIOS;
|
|
23899
|
-
|
|
24362
|
+
const hasSeries = dataModel.some((row) => row.series != null);
|
|
24363
|
+
if (!isScenarioStack && !hasSeries)
|
|
23900
24364
|
return;
|
|
23901
24365
|
const headerGroup = svgContainer.group().id("StackedHeaders");
|
|
23902
|
-
const groups = this.stackGroups(dataModel[0]);
|
|
23903
|
-
if (groups.length === 0)
|
|
23904
|
-
return;
|
|
23905
24366
|
const axisY = this.position.getColumnPositionY();
|
|
23906
|
-
const
|
|
23907
|
-
const
|
|
23908
|
-
const
|
|
23909
|
-
|
|
23910
|
-
|
|
23911
|
-
|
|
23912
|
-
|
|
23913
|
-
|
|
23914
|
-
|
|
23915
|
-
|
|
23916
|
-
|
|
23917
|
-
|
|
23918
|
-
|
|
23919
|
-
|
|
23920
|
-
|
|
23921
|
-
|
|
23922
|
-
|
|
24367
|
+
const halfColumn = this.position.getColumnWidth() / 2;
|
|
24368
|
+
const gap = this.position.spacings.labelToColumn;
|
|
24369
|
+
const withValue = dataModel.map((row, index) => (this.stackGroups(row).length > 0 ? index : -1));
|
|
24370
|
+
const filled = withValue.filter((index) => index >= 0);
|
|
24371
|
+
// a stack by scenario keeps the first period, also when it is empty
|
|
24372
|
+
const firstIndex = hasSeries ? ((_a = filled[0]) !== null && _a !== void 0 ? _a : 0) : 0;
|
|
24373
|
+
const lastIndex = (_b = filled[filled.length - 1]) !== null && _b !== void 0 ? _b : dataModel.length - 1;
|
|
24374
|
+
const drawSide = (side) => {
|
|
24375
|
+
const index = side === "left" ? firstIndex : lastIndex;
|
|
24376
|
+
const groups = this.stackGroups(dataModel[index]);
|
|
24377
|
+
if (groups.length === 0)
|
|
24378
|
+
return;
|
|
24379
|
+
const center = this.position.getColumnCenterPositionX(index);
|
|
24380
|
+
const labelX = side === "left" ? center - halfColumn - gap : center + halfColumn + gap;
|
|
24381
|
+
const drawHeader = (centerY, labelText) => {
|
|
24382
|
+
new Label$1(headerGroup, labelX, centerY, "STACK_HEADER", labelText, this.styles, HookLocation$1.Center, side === "left" ? HookLocation$1.Right : HookLocation$1.Left).forceStringTypeDraw();
|
|
24383
|
+
};
|
|
24384
|
+
if (groups.length > 1) {
|
|
24385
|
+
// Overlay mode: one header per group
|
|
24386
|
+
groups.forEach((group, groupIdx) => {
|
|
24387
|
+
const { positive, negative, total } = group.layout;
|
|
24388
|
+
const pixelPerUnit = group.segments[0].dataPoint.pixelPerUnit;
|
|
24389
|
+
// The front-most group (drawn last, e.g. AC) is fully visible, so its
|
|
24390
|
+
// label is centered on the bar. Back groups are mostly hidden behind it
|
|
24391
|
+
// and only peek out at their outer end, so their labels align with that edge.
|
|
24392
|
+
const isFrontGroup = groupIdx === groups.length - 1;
|
|
24393
|
+
const outerEnd = total < 0 ? 0 - negative : positive;
|
|
24394
|
+
const centerY = axisY - (isFrontGroup ? (positive - negative) / 2 : outerEnd) * pixelPerUnit;
|
|
24395
|
+
drawHeader(centerY, (this.i18n.get(group.prefix + "1") || group.prefix.toUpperCase()));
|
|
24396
|
+
});
|
|
24397
|
+
return;
|
|
24398
|
+
}
|
|
24399
|
+
// Single group: one header per segment, centered on the segment
|
|
24400
|
+
const [group] = groups;
|
|
24401
|
+
group.segments.forEach((seg, segIdx) => {
|
|
24402
|
+
// a series without a value in this period has no segment to stand next to
|
|
24403
|
+
if (seg.label != null && !Number.isFinite(seg.value))
|
|
24404
|
+
return;
|
|
24405
|
+
const { start, end } = group.layout.segments[segIdx];
|
|
24406
|
+
drawHeader(axisY - ((start + end) / 2) * seg.dataPoint.pixelPerUnit, seg.label != null ? this.seriesName(seg.label) : (this.i18n.get(seg.scenario) || seg.scenario));
|
|
23923
24407
|
});
|
|
23924
|
-
|
|
23925
|
-
|
|
23926
|
-
|
|
23927
|
-
|
|
23928
|
-
|
|
23929
|
-
|
|
23930
|
-
|
|
23931
|
-
|
|
24408
|
+
};
|
|
24409
|
+
const legend = (_c = this.stackConfig.legend) !== null && _c !== void 0 ? _c : "left";
|
|
24410
|
+
if (legend === "left" || legend === "both")
|
|
24411
|
+
drawSide("left");
|
|
24412
|
+
if (legend === "right" || legend === "both")
|
|
24413
|
+
drawSide("right");
|
|
24414
|
+
if (this.hasPercentMark() && filled.length > 0) {
|
|
24415
|
+
this.drawPercentMark(headerGroup, this.percentMarkSide() === "left" ? firstIndex : lastIndex);
|
|
24416
|
+
}
|
|
24417
|
+
}
|
|
24418
|
+
/** The `100%` label with a pointer at the upper end of a 100 % stack, on the side of the series names. */
|
|
24419
|
+
drawPercentMark(group, index) {
|
|
24420
|
+
const side = this.percentMarkSide();
|
|
24421
|
+
const direction = side === "left" ? -1 : 1;
|
|
24422
|
+
const top = this.position.getColumnPositionY() - RELATIVE_STACK_UNITS * this.pixelPerUnit;
|
|
24423
|
+
const edge = this.position.getColumnCenterPositionX(index) + direction * (this.position.getColumnWidth() / 2);
|
|
24424
|
+
const size = this.styles.fontStyles.size * 0.45;
|
|
24425
|
+
const tip = edge + direction * 1;
|
|
24426
|
+
const base = tip + direction * size;
|
|
24427
|
+
group
|
|
24428
|
+
.polygon([
|
|
24429
|
+
[tip, top],
|
|
24430
|
+
[base, top - size / 2],
|
|
24431
|
+
[base, top + size / 2],
|
|
24432
|
+
])
|
|
24433
|
+
.fill(this.styles.fontStyles.color || "#000000")
|
|
24434
|
+
.addClass("percent-mark");
|
|
24435
|
+
// above the pointer, so the name of the uppermost series keeps its place next to its segment
|
|
24436
|
+
new Label$1(group, base, top - size / 2, "STACK_PERCENT_MARK", "100%", this.styles, HookLocation$1.Bottom, side === "left" ? HookLocation$1.Right : HookLocation$1.Left).forceStringTypeDraw();
|
|
23932
24437
|
}
|
|
23933
24438
|
/**
|
|
23934
24439
|
* Draw stacked area chart (line mode with stack).
|
|
@@ -23951,7 +24456,8 @@ class TimeChart {
|
|
|
23951
24456
|
const layerScenarios = [];
|
|
23952
24457
|
// Identify active layers
|
|
23953
24458
|
const activeLayers = [];
|
|
23954
|
-
|
|
24459
|
+
// a stack by dimensions draws its first scenario only
|
|
24460
|
+
for (const key of isScenarioStack ? scenarioKeys : ["scenario1"]) {
|
|
23955
24461
|
if (dataModel.some((el) => el[key] && !el[key].isEmpty())) {
|
|
23956
24462
|
activeLayers.push(key);
|
|
23957
24463
|
}
|
|
@@ -24398,25 +24904,39 @@ const BnChartTimeRenderer = class {
|
|
|
24398
24904
|
}
|
|
24399
24905
|
/** Reports a failed query as the wrapper's `ERR_sql` item. Without it the chart would only show "No Data". */
|
|
24400
24906
|
syncQueryError() {
|
|
24401
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
24907
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
24402
24908
|
this.queryError = (_a = this.measureScaleError) !== null && _a !== void 0 ? _a : (_b = this.chart) === null || _b === void 0 ? void 0 : _b.getQueryError();
|
|
24403
24909
|
reportQueryError(this.errors, this.queryError);
|
|
24910
|
+
// the renderers of the variance rows share the error store: only the base chart reports
|
|
24911
|
+
if (this.variances.every((variance) => variance === "")) {
|
|
24912
|
+
const ignored = (_d = (_c = this.chart) === null || _c === void 0 ? void 0 : _c.getIgnoredSwitchScenarios()) !== null && _d !== void 0 ? _d : [];
|
|
24913
|
+
if (ignored.length > 0) {
|
|
24914
|
+
(_e = this.errors) === null || _e === void 0 ? void 0 : _e.addOrReplace({
|
|
24915
|
+
id: "WARN_stack_switch_ignored",
|
|
24916
|
+
type: "warning",
|
|
24917
|
+
message: `stack by dimensions with scenarioSwitch: ${ignored.join(", ")} is not drawn. A scenario continues the first one only where the first one has no value, and only in bar mode.`,
|
|
24918
|
+
});
|
|
24919
|
+
}
|
|
24920
|
+
else {
|
|
24921
|
+
(_f = this.errors) === null || _f === void 0 ? void 0 : _f.remove("WARN_stack_switch_ignored");
|
|
24922
|
+
}
|
|
24923
|
+
}
|
|
24404
24924
|
const errId = `WARN_variances_overlap_${this.variances.join("_")}`;
|
|
24405
|
-
const overlaps = (
|
|
24925
|
+
const overlaps = (_h = (_g = this.chart) === null || _g === void 0 ? void 0 : _g.getVarianceOverlaps()) !== null && _h !== void 0 ? _h : 0;
|
|
24406
24926
|
// the row can get other variances: the warning of the old list has to go
|
|
24407
24927
|
if (this.overlapErrId && this.overlapErrId !== errId) {
|
|
24408
|
-
(
|
|
24928
|
+
(_j = this.errors) === null || _j === void 0 ? void 0 : _j.remove(this.overlapErrId);
|
|
24409
24929
|
}
|
|
24410
24930
|
this.overlapErrId = overlaps > 0 ? errId : undefined;
|
|
24411
24931
|
if (overlaps > 0) {
|
|
24412
|
-
(
|
|
24932
|
+
(_k = this.errors) === null || _k === void 0 ? void 0 : _k.addOrReplace({
|
|
24413
24933
|
id: errId,
|
|
24414
24934
|
type: "warning",
|
|
24415
24935
|
message: `scenarioSwitch: the variances ${this.variances.join(", ")} share a row, but ${overlaps} period(s) have more than one value. The first variance wins there.`,
|
|
24416
24936
|
});
|
|
24417
24937
|
}
|
|
24418
24938
|
else {
|
|
24419
|
-
(
|
|
24939
|
+
(_l = this.errors) === null || _l === void 0 ? void 0 : _l.remove(errId);
|
|
24420
24940
|
}
|
|
24421
24941
|
}
|
|
24422
24942
|
async componentWillLoad() {
|
|
@@ -26859,7 +27379,7 @@ const LayoutPage = class {
|
|
|
26859
27379
|
const style = this.getLayoutStyle();
|
|
26860
27380
|
const arrOfSlots = this.extractSlotNames(style["grid-template-areas"]);
|
|
26861
27381
|
const rotation = this.rotation();
|
|
26862
|
-
return (h(Host, { key: '
|
|
27382
|
+
return (h(Host, { key: '290e6e8250c5f8bf53352886a810eeedd7548e57', style: rotation === null || rotation === void 0 ? void 0 : rotation.host }, h("bn-page", { key: '71b472107af79e9581e2097aae33c6b2808decbf', styles: this.styles, "selected-style": this.selectedStyle, format: this.pageFormat, orientation: this.pageOrientation, style: rotation === null || rotation === void 0 ? void 0 : rotation.page }, h("bn-message", { key: '99ac5c760476f95ff296077736849e6ddfd85120', text: this.messageText, image: this.messageImage }), h("bn-title", { key: '3af5ee4a7be905676a927397ff19cf062b291fb6', "i18n-namespace": (_a = this.i18nNamespace) !== null && _a !== void 0 ? _a : this.titleNamespace, ruleset: this.ruleset, "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: 'c91e9c708934499b855fe9e321bebb7aed31ab7c' }, h("div", { key: '92d01a4bad8ae401e570fcee4a9bbdac42b31d81', style: style, "data-bn-fit-content": this.pageFitToContent ? String(this.getRowCount(this.pageLayout)) : null }, this.getSlots(arrOfSlots)), h("slot", { key: 'ac227c5985b827e91d139396915e3a104e44710b', name: "annotations" })), h("bn-footer", { key: '41dfc75b74a158a0e7cdb05456b03ae62cf6d6db', text: this.footerText, "page-number": this.pageNumber, "display-page-number": this.footerDisplayPageNumber }))));
|
|
26863
27383
|
}
|
|
26864
27384
|
get element() { return getElement(this); }
|
|
26865
27385
|
};
|
|
@@ -33340,7 +33860,7 @@ const Title$1 = class Title {
|
|
|
33340
33860
|
}
|
|
33341
33861
|
render() {
|
|
33342
33862
|
const fontStyles = this.getFontStyles();
|
|
33343
|
-
return (h(Host, { key: '
|
|
33863
|
+
return (h(Host, { key: '999f282ecc2901b62f051e0501da7dd41f44a30a', style: fontStyles }, h("bn-title-renderer", { key: '2c58cbb472fc807a83503e7789babce4b17b1081', businessUnit: this.prepareBusinessUnit(), scenarios: this.prepareScenarios(), measures: this.prepareMeasures(), timeperiod: this.prepareTitleTimePeriod(), order: this.prepareTitleOrder(), i18n: this.prepareI18n(), "i18n-mode": this.prepareI18nMode(), locale: this.prepareLocale(), ruleSetConfig: this.ruleSetConfig() })));
|
|
33344
33864
|
}
|
|
33345
33865
|
get element() { return getElement(this); }
|
|
33346
33866
|
static get watchers() { return {
|
|
@@ -33662,7 +34182,7 @@ class TimePeriodAdapter {
|
|
|
33662
34182
|
}
|
|
33663
34183
|
}
|
|
33664
34184
|
|
|
33665
|
-
const bnTitleRendererCss = () => `:host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}
|
|
34185
|
+
const bnTitleRendererCss = () => `:host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}.measure{font-weight:bold}div{background-color:var(--bn-font-background, white);color:var(--bn-font-color, black)}p{margin:0}`;
|
|
33666
34186
|
|
|
33667
34187
|
const BnTitleRenderer = class {
|
|
33668
34188
|
constructor(hostRef) {
|
|
@@ -33693,7 +34213,7 @@ const BnTitleRenderer = class {
|
|
|
33693
34213
|
withComponentStatus(this);
|
|
33694
34214
|
}
|
|
33695
34215
|
render() {
|
|
33696
|
-
return (h("div", { key: '
|
|
34216
|
+
return (h("div", { key: 'ecc33a660538732ceea3e4620afabfcb8ffbce95' }, h("div", { key: 'cb1c3b074817a4c0647419fdc0f2b94c113ebc09', innerHTML: sanitizeHtml(this.title.unit) }), h("div", { key: '92b6ef66f67d33bd3bff6a760d1fc1bee605105d' }, this.title.measures.map((measure, index) => (h("span", null, this.isFirstElement(index) ? this.title.i18n.get("SEPARATOR_WS") : "", h("span", { class: "measure" }, measure.name), " ", measure.unit ? this.title.i18n.get("in") : "", " ", measure.unit)))), h("div", { key: '74cc33e0e63592e5422b3c0e5c7a52715210c486' }, this.title.dimension)));
|
|
33697
34217
|
}
|
|
33698
34218
|
componentWillLoad() {
|
|
33699
34219
|
const config = this.prepareConfig();
|