@bino-bi/bn-template-engine 1.0.0-next.42 → 1.0.0-next.44
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-3836531f.entry.js → p-3c4af59a.entry.js} +1 -1
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +190 -64
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.css +74 -2
- package/dist/collection/components/bn-table/bn-table-renderer/bn-table-renderer.js +50 -3
- package/dist/collection/components/bn-table/utils/elements/CellBarChart.js +55 -17
- package/dist/collection/components/bn-table/utils/elements/TableRow.js +15 -5
- package/dist/collection/components/bn-table/utils/elements/WaterfallBar.js +2 -4
- package/dist/collection/components/bn-table/utils/factories/tableDataSetFactory.js +8 -6
- package/dist/collection/components/bn-table/utils/helper/DataQuery.js +50 -28
- package/dist/collection/components/bn-table/utils/helper/barColumnGeometry.js +8 -1
- package/dist/collection/utils/layoutState/baseline.js +5 -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.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/p-AwH1w8Mu.js +1 -0
- package/dist/components/p-B2bvM2Ig.js +1 -0
- package/dist/components/{p-CUSAlS2o.js → p-BfUdaxZ9.js} +1 -1
- package/dist/components/{p-ChaSU4fh.js → p-C2ycO60j.js} +1 -1
- package/dist/components/{p-chnyMHJT.js → p-CyfGkLMh.js} +1 -1
- package/dist/components/{p-DM4Up10X.js → p-DnDL1pPc.js} +1 -1
- package/dist/components/p-JofGXz75.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +190 -64
- package/dist/types/components/bn-table/bn-table-renderer/bn-table-renderer.d.ts +11 -0
- package/dist/types/components/bn-table/utils/helper/DataQuery.d.ts +10 -0
- package/dist/types/components/bn-table/utils/helper/barColumnGeometry.d.ts +6 -1
- package/package.json +1 -1
- package/dist/components/p-B2L2q2Ks.js +0 -1
- package/dist/components/p-Bn7J1pgl.js +0 -1
- package/dist/components/p-XFZYX7DZ.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { Formatter } from "../../../../utils";
|
|
3
3
|
import { VarianceScenario } from "../../../../utils/model/VarianceScenario";
|
|
4
|
-
import { absoluteBarGeometry, BAR_LABEL_FONT_RATIO, labelWidth, PIN_HEAD_SIZE, relativePinGeometry, VARIANCE_AXIS_EM, } from "../helper/barColumnGeometry";
|
|
4
|
+
import { absoluteBarGeometry, BAR_LABEL_FONT_RATIO, barBox, labelWidth, PIN_HEAD_SIZE, relativePinGeometry, VARIANCE_AXIS_EM, } from "../helper/barColumnGeometry";
|
|
5
5
|
/** Matches SYSTEM_STYLE_DEFAULTS.global.fontSizePx; only used when `styles` is omitted. */
|
|
6
6
|
const DEFAULT_EM_PX = 13.3333;
|
|
7
7
|
// Default fallback colors (should come from componentStyle)
|
|
@@ -36,23 +36,57 @@ const PIN_BAND_PAD = 0.2;
|
|
|
36
36
|
function getPatternId(prefix, color) {
|
|
37
37
|
return `pattern-${prefix}-${color.replace("#", "")}`;
|
|
38
38
|
}
|
|
39
|
+
/** The hatching of a pin head: light lines on the dark colour of the scenario, as IBCS draws it. */
|
|
40
|
+
function getHeadPatternId(slot, color) {
|
|
41
|
+
return getPatternId(`head-${slot}`, color);
|
|
42
|
+
}
|
|
39
43
|
/**
|
|
40
44
|
* Renders SVG pattern definitions for hatched fills
|
|
41
45
|
*/
|
|
42
46
|
export const PatternDefs = ({ styles }) => {
|
|
43
47
|
const s = styles.scaleFactor;
|
|
44
|
-
const
|
|
48
|
+
const size = 3 * s;
|
|
45
49
|
const patterns = [
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
{
|
|
51
|
+
id: getPatternId("pos", styles.positive.stroke),
|
|
52
|
+
line: styles.positive.stroke,
|
|
53
|
+
background: "#ffffff",
|
|
54
|
+
lineWidth: 1,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: getPatternId("neg", styles.negative.stroke),
|
|
58
|
+
line: styles.negative.stroke,
|
|
59
|
+
background: "#ffffff",
|
|
60
|
+
lineWidth: 1,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: getPatternId("neu", styles.neutral.stroke),
|
|
64
|
+
line: styles.neutral.stroke,
|
|
65
|
+
background: "#ffffff",
|
|
66
|
+
lineWidth: 1,
|
|
67
|
+
},
|
|
68
|
+
...["ac", "pp", "fc", "pl"].flatMap((type) => [
|
|
69
|
+
{
|
|
70
|
+
id: getPatternId(type, styles.scenarios[type].stroke),
|
|
71
|
+
line: styles.scenarios[type].stroke,
|
|
72
|
+
background: "#ffffff",
|
|
73
|
+
lineWidth: 1,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: getHeadPatternId(type, styles.scenarios[type].stroke),
|
|
77
|
+
line: "#ffffff",
|
|
78
|
+
background: styles.scenarios[type].stroke,
|
|
79
|
+
lineWidth: 0.6,
|
|
80
|
+
},
|
|
81
|
+
]),
|
|
82
|
+
];
|
|
83
|
+
// the diagonal of the tile and its two ends in the next tiles, so the lines join without notches
|
|
84
|
+
const diagonals = [
|
|
85
|
+
[0, size, size, 0],
|
|
86
|
+
[-s, s, s, -s],
|
|
87
|
+
[size - s, size + s, size + s, size - s],
|
|
54
88
|
];
|
|
55
|
-
return (h("defs", null, patterns.map((p) => (h("pattern", { id: p.id, patternUnits: "userSpaceOnUse", width:
|
|
89
|
+
return (h("defs", null, patterns.map((p) => (h("pattern", { id: p.id, patternUnits: "userSpaceOnUse", width: size, height: size }, h("rect", { width: size, height: size, fill: p.background }), diagonals.map(([x1, y1, x2, y2]) => (h("line", { x1: x1, y1: y1, x2: x2, y2: y2, stroke: p.line, "stroke-width": p.lineWidth * s }))))))));
|
|
56
90
|
};
|
|
57
91
|
/** Longest relative label that keeps all percent digits; a longer one drops digits so its gutter does not eat the pins. */
|
|
58
92
|
const PIN_LABEL_CHARS = 7;
|
|
@@ -154,8 +188,10 @@ export const VarianceAxis = ({ x, height, look, styles }) => {
|
|
|
154
188
|
const { reference, referenceSlot } = look;
|
|
155
189
|
let lines;
|
|
156
190
|
if (reference.fillpattern === "outlined") {
|
|
157
|
-
|
|
158
|
-
|
|
191
|
+
// two lines with a gap of their width, together as wide as a solid axis
|
|
192
|
+
const lineWidth = width / 3;
|
|
193
|
+
const offset = (width - lineWidth) / 2;
|
|
194
|
+
lines = [x - offset, x + offset].map((lineX) => (h("line", { x1: lineX, y1: 0, x2: lineX, y2: height, stroke: reference.stroke, "stroke-width": lineWidth })));
|
|
159
195
|
}
|
|
160
196
|
else if (reference.fillpattern === "hatched") {
|
|
161
197
|
lines = (h("line", { x1: x, y1: 0, x2: x, y2: height, stroke: reference.stroke, "stroke-width": width, "stroke-dasharray": `${2 * s}` }));
|
|
@@ -283,9 +319,7 @@ const AbsoluteVarianceBar = (props) => {
|
|
|
283
319
|
const maxOverflow = Math.max(0, maxScaledWidth - cutWidth);
|
|
284
320
|
const overflowAmount = Math.max(0, scaledWidth - cutWidth);
|
|
285
321
|
const overdriveWidth = maxOverflow > 0 ? (overflowAmount / maxOverflow) * overdriveZoneWidth : 0;
|
|
286
|
-
const
|
|
287
|
-
const barHeight = height - padding * 2;
|
|
288
|
-
const barY = padding;
|
|
322
|
+
const { barY, barHeight } = barBox(height);
|
|
289
323
|
// Get style based on column type (scenario vs variance)
|
|
290
324
|
const look = getVarianceLook(scenario, styles);
|
|
291
325
|
const sentimentStyle = getBarStyle(scenario, value, isPositiveGood, styles);
|
|
@@ -367,7 +401,11 @@ const RelativeVariancePin = (props) => {
|
|
|
367
401
|
const labelX = labelOnShaft
|
|
368
402
|
? bandX + bandWidth / 2
|
|
369
403
|
: (isExtreme ? tipX : pinEndX + direction * (headSize / 2)) + direction * labelGap;
|
|
370
|
-
return (h("svg", { width: totalWidth, height: height, class: "cell-bar-chart relative-variance", style: { overflow: "visible" } }, h(PatternDefs, { styles: styles }), isExtreme ? (h("polygon", { points: `${tipX},${centerY} ${arrowBaseX},${centerY - arrowSize / 2} ${arrowBaseX},${centerY + arrowSize / 2}`, fill: barStyle.fill })) : (h("rect", { x: pinEndX - headSize / 2, y: centerY - headSize / 2, width: headSize, height: headSize, fill: headStyle.fillpattern === "outlined"
|
|
404
|
+
return (h("svg", { width: totalWidth, height: height, class: "cell-bar-chart relative-variance", style: { overflow: "visible" } }, h(PatternDefs, { styles: styles }), isExtreme ? (h("polygon", { points: `${tipX},${centerY} ${arrowBaseX},${centerY - arrowSize / 2} ${arrowBaseX},${centerY + arrowSize / 2}`, fill: barStyle.fill })) : (h("rect", { x: pinEndX - headSize / 2, y: centerY - headSize / 2, width: headSize, height: headSize, fill: headStyle.fillpattern === "outlined"
|
|
405
|
+
? "#ffffff"
|
|
406
|
+
: headStyle.fillpattern === "hatched"
|
|
407
|
+
? `url(#${getHeadPatternId((_b = look === null || look === void 0 ? void 0 : look.minuendSlot) !== null && _b !== void 0 ? _b : "ac", headStyle.stroke)})`
|
|
408
|
+
: headStyle.fill, stroke: headStyle.stroke, "stroke-width": 1 * s })), h("line", { x1: axisX, y1: centerY, x2: isExtreme ? arrowBaseX : pinEndX, y2: centerY, stroke: barStyle.fill, "stroke-width": PIN_LINE_WIDTH * s }), labelOnShaft && (h("rect", { class: "pin-label-band", x: bandX, y: centerY - (PIN_LINE_WIDTH * s) / 2, width: bandWidth, height: PIN_LINE_WIDTH * s, fill: "#ffffff", "fill-opacity": "0.5" })), look ? (h(VarianceAxis, { x: axisX, height: height, look: look, styles: styles })) : (h("line", { x1: axisX, y1: 0, x2: axisX, y2: height, stroke: AXIS_COLOR, "stroke-width": 1 * s })), h("text", { x: labelX, y: height / 2, dy: "0.35em", "text-anchor": labelOnShaft ? "middle" : isPositive ? "start" : "end", fill: styles.fontColor, "font-size": fs, "font-style": "italic", "font-family": styles.fontFamily }, displayValue)));
|
|
371
409
|
};
|
|
372
410
|
/**
|
|
373
411
|
* CellBarChart - Renders IBCS-compliant variance bar charts.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TableRowType } from "../model";
|
|
2
2
|
import { Cell } from "./Cell";
|
|
3
3
|
import { NOT_AVAILABLE } from "../../../../utils/relativeVariance";
|
|
4
|
+
import { VarianceScenario } from "../../../../utils/model/VarianceScenario";
|
|
4
5
|
/**
|
|
5
6
|
* Represents a single row in an IBCS table, containing an ordered list of Cells.
|
|
6
7
|
*
|
|
@@ -65,12 +66,21 @@ export class TableRow {
|
|
|
65
66
|
cssStyle = cellStyle !== null && cellStyle !== void 0 ? cellStyle : scenario;
|
|
66
67
|
}
|
|
67
68
|
if (this.type === TableRowType.PARTELEMENT) {
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
const variance = new VarianceScenario(scenario);
|
|
70
|
+
if (variance.isValid && Number.isFinite(value)) {
|
|
71
|
+
// the change of a share: percentage points, or the relative change in percent. It has no sentiment
|
|
72
|
+
cellType = variance.type === "d" ? "percentpoint" : "percent";
|
|
73
|
+
cssStyle = (cellStyle !== null && cellStyle !== void 0 ? cellStyle : "").replace(/^(pos|neg)_\w+/, "$1_neu");
|
|
70
74
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
else {
|
|
76
|
+
// a share without a total has no change either
|
|
77
|
+
if (cellType === "percent" || variance.isValid) {
|
|
78
|
+
value = "-";
|
|
79
|
+
}
|
|
80
|
+
if (scenario !== "category" && scenario !== "operation") {
|
|
81
|
+
cellType = "percent";
|
|
82
|
+
cssStyle = "";
|
|
83
|
+
}
|
|
74
84
|
}
|
|
75
85
|
}
|
|
76
86
|
if (value === "-" || (value === NOT_AVAILABLE && cellType === "percent")) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
2
|
import { AXIS_COLOR, DEFAULT_STYLES, formatValue, getBarFill, getBarStroke, getBarStyle, getScenarioType, getVarianceLook, PatternDefs, VarianceAxis, } from "./CellBarChart";
|
|
3
|
-
import { labelWidth, VARIANCE_AXIS_EM, waterfallGeometry } from "../helper/barColumnGeometry";
|
|
3
|
+
import { barBox, labelWidth, VARIANCE_AXIS_EM, waterfallGeometry, } from "../helper/barColumnGeometry";
|
|
4
4
|
/**
|
|
5
5
|
* Label text of a waterfall bar. Scenario values carry no variance sentiment: unsigned per
|
|
6
6
|
* IBCS. A variance keeps its sign (`signed`).
|
|
@@ -42,9 +42,7 @@ export const WaterfallBar = (props) => {
|
|
|
42
42
|
const { totalWidth, labelAreaLeft, barAreaWidth, labelGap } = geometry !== null && geometry !== void 0 ? geometry : waterfallGeometry(columnWidthEm, styles.emPx);
|
|
43
43
|
const pxPerUnit = barAreaWidth / range;
|
|
44
44
|
const xOf = (coordinate) => labelAreaLeft + (coordinate - waterfall.min) * pxPerUnit;
|
|
45
|
-
const
|
|
46
|
-
const barHeight = height - padding * 2;
|
|
47
|
-
const barY = padding;
|
|
45
|
+
const { barY, barHeight } = barBox(height);
|
|
48
46
|
const axisX = xOf(0);
|
|
49
47
|
const startX = xOf(waterfall.start);
|
|
50
48
|
const endX = xOf(waterfall.end);
|
|
@@ -337,13 +337,15 @@ export class TableDataSetFactory {
|
|
|
337
337
|
scenario.name === scenario.type
|
|
338
338
|
? waterfallResult === null || waterfallResult === void 0 ? void 0 : waterfallResult.get(rawDataRow, scenario.type)
|
|
339
339
|
: undefined;
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
new VarianceScenario(scenario.type).isValid &&
|
|
344
|
-
(waterfallResult === null || waterfallResult === void 0 ? void 0 : waterfallResult.has(scenario.type)));
|
|
340
|
+
const isShareChange = type === TableRowType.PARTELEMENT && new VarianceScenario(scenario.type).isValid;
|
|
341
|
+
// the change of a share is in percentage points, it has no place on the axis of the column
|
|
342
|
+
const isBarChart = isBarColumn && !isShareChange;
|
|
345
343
|
const columnStats = isBarChart ? columnStatsMap === null || columnStatsMap === void 0 ? void 0 : columnStatsMap.get(scenario.type) : undefined;
|
|
346
|
-
detailsRow.createElement(
|
|
344
|
+
detailsRow.createElement(
|
|
345
|
+
// percent values have no share, so there is no change of a share either
|
|
346
|
+
isShareChange && scenariosUnitType === DataFormat.PERCENT
|
|
347
|
+
? "-"
|
|
348
|
+
: this.translateSumCellLabel(i18nMode, i18n, value, groupName, subCategory, type, scenario.type), scenario.type, this.createColumnType(scenario), this.setCellType(scenario.type, scenariosUnitType), moved ? null : this.translateCellPrefix(i18n, type, scenario.type), this.translateScenarioCSS(scenario.type, value, operation), isSecondElement, categoryWidth, measureScale === null || measureScale === void 0 ? void 0 : measureScale.value, isBarChart, columnStats, 1, waterfall);
|
|
347
349
|
const cell = detailsRow.elements[detailsRow.elements.length - 1];
|
|
348
350
|
if (this.dateBuckets && scenario.bucket !== undefined) {
|
|
349
351
|
cell.date = pointDate(scenario.bucket);
|
|
@@ -62,12 +62,8 @@ export class DataQuery {
|
|
|
62
62
|
const queries = [];
|
|
63
63
|
const sumGroupQueries = [];
|
|
64
64
|
const res = [];
|
|
65
|
-
const scenarios = this.
|
|
66
|
-
|
|
67
|
-
.toString();
|
|
68
|
-
const scenariosSUMQuery = this.config.scenarios
|
|
69
|
-
.map((s) => this.translateScenarioSQL(s, true, this.config.type))
|
|
70
|
-
.toString();
|
|
65
|
+
const scenarios = this.scenariosSQL(false);
|
|
66
|
+
const scenariosSUMQuery = this.scenariosSQL(true);
|
|
71
67
|
const relativeScenarios = this.getRelativeScenarios();
|
|
72
68
|
const attributesSQL = this.config.attributes.map((attribute) => this.translateAttributeSQL(attribute)).toString();
|
|
73
69
|
const groups = new QueryGroups(this.config);
|
|
@@ -183,7 +179,8 @@ export class DataQuery {
|
|
|
183
179
|
drillQueries.forEach((query) => {
|
|
184
180
|
resDrill.push(...this.exec(query));
|
|
185
181
|
});
|
|
186
|
-
|
|
182
|
+
// two relative variances on one reference name its dr_* alias twice
|
|
183
|
+
const scenarioNames = [...new Set(this.exctractScenarioNames(scenarios))];
|
|
187
184
|
const rowGroupSumResultRows = [];
|
|
188
185
|
sumGroupQueries.forEach(function (query) {
|
|
189
186
|
rowGroupSumResultRows.push(...db.exec(query, params));
|
|
@@ -191,21 +188,29 @@ export class DataQuery {
|
|
|
191
188
|
const rowGroupSumResultMap = new Map();
|
|
192
189
|
rowGroupSumResultRows.forEach((row) => rowGroupSumResultMap.set(row[QueryColumnNames.ROWGROUP], row));
|
|
193
190
|
resDrill = this.reduceResDrillByCategoryGroups(resDrill, scenarioNames);
|
|
194
|
-
resDrill.forEach(
|
|
195
|
-
|
|
196
|
-
try {
|
|
197
|
-
drillItem[key] =
|
|
198
|
-
drillItem[key] /
|
|
199
|
-
rowGroupSumResultMap.get(drillItem[QueryColumnNames.ROWGROUP])[key];
|
|
200
|
-
}
|
|
201
|
-
catch (err) {
|
|
202
|
-
console.error("DataQuery: partOf drill row calculation failed", key, err);
|
|
203
|
-
drillItem[key] = Number.NaN;
|
|
204
|
-
}
|
|
205
|
-
});
|
|
191
|
+
resDrill.forEach((drillItem) => {
|
|
192
|
+
this.toShares(drillItem, rowGroupSumResultMap.get(drillItem[QueryColumnNames.ROWGROUP]), scenarioNames);
|
|
206
193
|
});
|
|
207
194
|
this.injectDrillRowsToResultRows(resDrill, res);
|
|
208
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Turns the values of a partof row into shares of its total. A variance becomes the change of the
|
|
198
|
+
* share (percentage points), not the share of the variance.
|
|
199
|
+
*/
|
|
200
|
+
toShares(part, totals, names) {
|
|
201
|
+
var _a;
|
|
202
|
+
const share = (key) => part[key] / (totals ? totals[key] : Number.NaN);
|
|
203
|
+
const changes = new Map();
|
|
204
|
+
for (const name of names) {
|
|
205
|
+
const variance = new VarianceScenario(name);
|
|
206
|
+
if (variance.isValid) {
|
|
207
|
+
changes.set(name, share(variance.base) - share(variance.delta));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
for (const name of names) {
|
|
211
|
+
part[name] = (_a = changes.get(name)) !== null && _a !== void 0 ? _a : share(name);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
209
214
|
/**
|
|
210
215
|
* Generates a REST row that aggregates all data rows beyond the configured limit.
|
|
211
216
|
* Only emitted when a limit is set and the group has more rows than the limit.
|
|
@@ -561,12 +566,8 @@ export class DataQuery {
|
|
|
561
566
|
}
|
|
562
567
|
const separator = "##";
|
|
563
568
|
const bucketSource = `(SELECT *, ${intervalBucketSQL(this.config.interval)} as __interval FROM ${this.fromExpr}) as p`;
|
|
564
|
-
const scenarios = this.
|
|
565
|
-
|
|
566
|
-
.toString();
|
|
567
|
-
const scenariosSUMQuery = this.config.scenarios
|
|
568
|
-
.map((s) => this.translateScenarioSQL(s, true, this.config.type))
|
|
569
|
-
.toString();
|
|
569
|
+
const scenarios = this.scenariosSQL(false);
|
|
570
|
+
const scenariosSUMQuery = this.scenariosSQL(true);
|
|
570
571
|
// two relative variances on one reference name its dr_* alias twice, it must be summed once
|
|
571
572
|
const entryAliases = [...new Set(this.exctractScenarioNames(scenarios))];
|
|
572
573
|
const relativeScenarios = this.getRelativeScenarios();
|
|
@@ -792,9 +793,7 @@ export class DataQuery {
|
|
|
792
793
|
const totals = this.config.grouped
|
|
793
794
|
? groupTotalsByKey.get(`${partRow.rowGroup}${separator}${bucketKey}`)
|
|
794
795
|
: sumTotalsByBucket.get(bucketKey);
|
|
795
|
-
|
|
796
|
-
partRow[alias] = partRow[alias] / (totals ? totals[alias] : Number.NaN);
|
|
797
|
-
}
|
|
796
|
+
this.toShares(partRow, totals, entryAliases);
|
|
798
797
|
finalizeBucketRow(partRow);
|
|
799
798
|
for (const segment of res) {
|
|
800
799
|
for (const row of segment) {
|
|
@@ -823,6 +822,29 @@ export class DataQuery {
|
|
|
823
822
|
}
|
|
824
823
|
return whereClause + `)`;
|
|
825
824
|
}
|
|
825
|
+
/**
|
|
826
|
+
* The select list of the scenarios. A partof row needs both sides of every variance, also when they
|
|
827
|
+
* are not shown. Those come without their `_cnt`, so the NaN detection of the other rows does not change.
|
|
828
|
+
*/
|
|
829
|
+
scenariosSQL(isSumRow) {
|
|
830
|
+
const shown = this.config.scenarios;
|
|
831
|
+
const sql = shown.map((s) => this.translateScenarioSQL(s, isSumRow, this.config.type));
|
|
832
|
+
if (this.checkConfigForPartOf() && this.config.type !== TableType.LIST) {
|
|
833
|
+
const hidden = new Set();
|
|
834
|
+
for (const scenario of shown) {
|
|
835
|
+
const variance = new VarianceScenario(scenario);
|
|
836
|
+
if (variance.isValid) {
|
|
837
|
+
hidden.add(variance.base).add(variance.delta);
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
for (const scenario of hidden) {
|
|
841
|
+
if (!shown.includes(scenario)) {
|
|
842
|
+
sql.push(this.translateScenarioSQL(scenario, isSumRow, this.config.type).split(", COUNT(")[0]);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return sql.toString();
|
|
847
|
+
}
|
|
826
848
|
/** Collects all relative variance scenarios and maps each to its denominator column name. */
|
|
827
849
|
getRelativeScenarios() {
|
|
828
850
|
const relativeScenarios = new Map();
|
|
@@ -35,7 +35,14 @@ const OVERDRIVE_FRACTION = 0.15;
|
|
|
35
35
|
/** Width of the axis of a variance bar or pin, in em: near the 0.3em scenario marker in the header. */
|
|
36
36
|
export const VARIANCE_AXIS_EM = 0.25;
|
|
37
37
|
/** Side of the square pin head, in px before scaleFactor. */
|
|
38
|
-
export const PIN_HEAD_SIZE =
|
|
38
|
+
export const PIN_HEAD_SIZE = 8;
|
|
39
|
+
/** Height of a bar in svg heights: IBCS leaves almost half the row free. */
|
|
40
|
+
const BAR_HEIGHT_RATIO = 0.6;
|
|
41
|
+
/** Top edge and height of a bar centred in an svg of the given height. */
|
|
42
|
+
export function barBox(height) {
|
|
43
|
+
const barHeight = height * BAR_HEIGHT_RATIO;
|
|
44
|
+
return { barY: (height - barHeight) / 2, barHeight };
|
|
45
|
+
}
|
|
39
46
|
/**
|
|
40
47
|
* Advance widths in em, the larger of Noto Sans and Arial. The engine ships no font, so a
|
|
41
48
|
* wider fallback (DejaVu Sans, Verdana) is possible: LABEL_WIDTH_MARGIN and the cell
|
|
@@ -62,7 +62,11 @@ export function readTableBaseline(table, host) {
|
|
|
62
62
|
const isRowHeader = (cell) => cell.classList.contains("category") || cell.classList.contains("operation");
|
|
63
63
|
const valueCell = cells.some(isRowHeader) ? cells.find((cell) => !isRowHeader(cell)) : cells[1];
|
|
64
64
|
if (valueCell) {
|
|
65
|
-
|
|
65
|
+
// a block gap is a transparent left border: the column starts after it
|
|
66
|
+
const gap = valueCell.classList.contains("block-start") && typeof getComputedStyle === "function"
|
|
67
|
+
? parseFloat(getComputedStyle(valueCell).borderLeftWidth) || 0
|
|
68
|
+
: 0;
|
|
69
|
+
baseline.x = round2(frame.toLocal(valueCell.getBoundingClientRect()).x + gap);
|
|
66
70
|
}
|
|
67
71
|
return baseline;
|
|
68
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as o,d as p}from"./p-
|
|
1
|
+
import{B as o,d as p}from"./p-DnDL1pPc.js";const s=o,r=p;export{s as BnChartBubbleRenderer,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,w as i,f as s,h as a,a as r,t as n}from"./p-D6YGOYV1.js";import{h as l,a as o}from"./p-DDvWTgk1.js";import{o as h}from"./p-DaOm9YwQ.js";import{c}from"./p-ChaSU4fh.js";import{a as d}from"./p-XFZYX7DZ.js";import{g as u}from"./p-DD1zlev_.js";import{c as p}from"./p-D2Epww9R.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as b,j as y}from"./p-BiSytXUy.js";import{w as g}from"./p-Dq9dG0Kr.js";import{w as x}from"./p-DjPWZfry.js";import{w}from"./p-DJUffGeB.js";import{w as _}from"./p-4vVbchX2.js";import{w as S}from"./p-D40Am1Ap.js";import{w as j}from"./p-DQl2K2Xl.js";import{w as L}from"./p-xIWChKGS.js";import{w as R}from"./p-DwuXVo2h.js";import{r as $,s as z}from"./p-BXXjh6We.js";import{t as A,a as E,b as W,c as D,d as N,e as k,p as F}from"./p-9mUU4itF.js";import{s as O}from"./p-DakXa7Dp.js";import{d as C}from"./p-DM4Up10X.js";const X={rowGroup:0,category:1,subCategory:2},G=["ac","pp","fc","pl"],M=t(class extends e{validateFilter(t){const e="ERR_filter";l(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateMeasureSpec("x",t,!0,(t=>A(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>A(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>E(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>W(t)))}validateCompareWith(t){const e="WARN_compareWith";f(t)||G.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`compare-with: invalid value '${t}' - expected ${G.join("/")}; ignored.`})}validateLevel(t){const e="WARN_level",i=["auto","category","subcategory"];f(t)||i.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${i.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",i=["auto","rowgroup","category","none"];f(t)||i.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${i.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,(t=>D(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>N(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>k(t)))}validateAspect(t){const e="WARN_aspect";f(t)||null!==this.parseAspect(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const e="WARN_limit";b(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const e="WARN_scale";if(f(t))return void this.errors.remove(e);const{mode:i,factor:s}=m(t);"factor"===i&&(void 0===s||s<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.pixelPerUnitGroupMap=new Map,this.chartTitle="",this.filter="",this.share="",this.compareWith="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,e)=>this.t(t,e),R(this),g(this),w(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=_(this),j(this),this.componentStyle=x(this),this.ruleSetConfig=S(this),this.t=L(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateSize(this.size),this.validateShare(this.share),this.validateCompareWith(this.compareWith),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){O(this.element,"bn-chart-bubble-renderer");const{mode:t}=m(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const e=this.element,{width:s}=u(e);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const a=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),r=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(r)||r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const l=Math.max(.3,n*(s-1)/r);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",a*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-bubble-renderer",this.errors)}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,s(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"all",values:!0,max:12}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateSizeScaling(){var t;const e=null===(t=this.prepareSize())||void 0===t?void 0:t.group;this.setBlockingError("ERR_xy_scale_group",void 0===e||this.pixelPerUnitGroupMap.has(e)?null:this.t(".bubble-scale-group-unknown",{group:e}))}validateMeasureSpec(t,e,i,s){var a;const r="ERR_xy_json_"+t,n="ERR_xy_measure_"+t,l="WARN_xy_fields_"+t,{data:o,parseError:h}=F(e,"measure");if(h)return this.setBlockingError(r,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(l);if(this.setBlockingError(r,null),null===o)return this.setBlockingError(n,i?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(l);const c=null!==(a=o.measure)&&void 0!==a?a:"";y(c)?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".xy-measure-invalid",{prop:t,measure:c})),this.reportSpecIssues(l,t,s(o))}validateObjectSpec(t,e,i){const s="ERR_xy_json_"+t,a="WARN_xy_fields_"+t,{data:r,parseError:n}=F(e,null);if(n)return this.setBlockingError(s,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(a);this.setBlockingError(s,null),null!==r?this.reportSpecIssues(a,t,i(r)):this.errors.remove(a)}reportSpecIssues(t,e,i){const s=[];null!==i&&i.invalidFields.length>0&&s.push("invalid: "+i.invalidFields.join(", ")),null!==i&&i.unknownKeys.length>0&&s.push("unknown: "+i.unknownKeys.join(", ")),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:i,parseError:s}=F(e,"measure");if(s||null===i)return null;const{config:a}=A(i);return null!==a&&y(a.measure)?(void 0!==a.min&&void 0!==a.max&&a.min>=a.max?(this.errors.addOrReplace({id:"WARN_xy_domain_"+t,type:"warning",message:t+": min must be smaller than max; the override is ignored."}),a.min=void 0,a.max=void 0):this.errors.remove("WARN_xy_domain_"+t),a):null}prepareSize(){const{data:t,parseError:e}=F(this.size,"measure");if(e||null===t)return null;const{config:i}=E(t);return null!==i&&y(i.measure)?i:null}prepareShare(){const{data:t,parseError:e}=F(this.share,"measure");if(e||null===t)return null;const{config:i}=W(t);return null!==i&&y(i.measure)?i:null}prepareCompareFamily(){var t;const e=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return G.includes(e)?e:null}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:i}=F(this.labels,null);return i||null===e?{points:t.points,values:t.values,max:t.max}:N(e,t).config}prepareLegend(){const{data:t,parseError:e}=F(this.legend,null);return e||null===t?{show:!0,position:"right"}:k(t).config}prepareFacet(){const{data:t,parseError:e}=F(this.facet,null);return e||null===t?null:D(t).config}preparePointLevel(){var t,e;const i=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===i)return"category";if("subcategory"===i)return"subCategory";const s=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===s||"category"===s||"subCategory"===s?s:"category"}prepareSeriesLevel(t){var e;const i=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===i?null:"rowgroup"===i?"rowGroup":"category"===i||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const i=new Set;let s=!1;for(const e of t){if(void 0===e)continue;const t=$(e);null!==t&&("scenario"===t.kind?i.add(z(t.slot)):s=!0)}this.setBlockingError("ERR_xy_family",i.size>1?this.t(".xy-family-mixed",{families:[...i].join(", ")}):null);const a=this.prepareCompareFamily();this.setBlockingError("ERR_xy_compare_variance",null!==a&&s?this.t(".xy-compare-variance"):null),this.setBlockingError("ERR_xy_compare_family",null!==a&&1===i.size&&i.has(a)?`compare-with: '${a}' is already the primary scenario family.`:null);const r=this.preparePointLevel(),n=this.prepareSeriesLevel(r),l=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let o=null;if(null!==n&&X[n]>=X[r]&&(o=`series '${n}' vs point '${r}'`),null!==l){const t=null!=n?n:r;X[l]>=X[t]&&(o=`facet '${l}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==o?this.t(".xy-level-order",{detail:o}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const i=Number(e[1]),s=Number(e[2]);return i<=0||s<=0?null:i/s}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}prepareSizeAreaPerUnit(){var t;const e=null===(t=this.prepareSize())||void 0===t?void 0:t.group;if(void 0===e||!this.pixelPerUnitGroupMap.has(e))return 0;const i=this.pixelPerUnitGroupMap.get(e);if(!(i>0))return 0;const s=this.getEffectiveFontPx();return s*s/i}i18nLocalKeys(){return["no-data","axis.in","legend.title","legend.size","legend.compare"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(o.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{const i=e.global.fontSizePx*t;return{scaleFactors:e["bn-chart-bubble"].scaleFactors,fontStyles:{font:`${i}px ${e.global.fontFamily}`,size:i,color:e.global.fontColor,background:e.global.fontBackgroundColor,leading:1.8},axisStyles:e["bn-chart-bubble"].axisStyles,seriesColors:e["bn-chart-bubble"].seriesColors,padding:e["bn-chart-bubble"].padding}}))}async getBaseline(){return d(this.element,"bn-chart-bubble-renderer")}async getLayoutState(t){var e;const i=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",s=h(this.element),a=this.getEffectiveScaleFactor(),r=Number.isFinite(a)&&a>0?a:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*r;return c(this.element,"bn-chart-bubble-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},s,i)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var i,s,a,r;const n=(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=e.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=e.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=e.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const i of[1,2,3,4])t[`${e}${i}`]={type:"number",isOptional:!0,description:""};const e={x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y),size:this.prepareSize(),share:this.prepareShare()};for(const[i,s]of Object.entries(e)){if(null===s)continue;const e=$(s.measure);null!==e&&("scenario"===e.kind?t[e.slot].description=`${i}: ${void 0!==s.label?s.label:s.measure}`:(t[e.measure.base].description=`${i}: ${s.measure} (base)`,t[e.measure.delta].description=`${i}: ${s.measure} (delta)`))}const i=this.prepareCompareFamily();if(null!==i)for(const[s,a]of Object.entries(e)){if(null===a||"share"===s)continue;const e=$(a.measure);if(null!==e&&"scenario"===e.kind){const a=i+e.slot.replace(/^[a-z]+/,"");""===t[a].description&&(t[a].description=s+": compareWith")}}return{IBubbleChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareAxis("x",this.x),e=this.prepareAxis("y",this.y),i=this.prepareSize(),s=this.prepareShare(),r=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure,null==i?void 0:i.measure,null==s?void 0:s.measure],r),this.validateSizeScaling(),this.hasBlockingErrors()||null===t||null===e||null===i)return null;const n=this.preparePointLevel(),l=this.prepareI18n(),o=this.prepareStyle(),h=u(this.element).width;return a("bn-chart-bubble-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,size:i,share:s,compareFamily:this.prepareCompareFamily(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:r,pointLevel:n,seriesLevel:this.prepareSeriesLevel(n),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,sizeAreaPerUnit:this.prepareSizeAreaPerUnit(),styles:o,i18n:l,containerWidth:h,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"2b15b5b4fc32db48b951e82ecc87f25b0afcc9f8",style:this.getFontStyles()},a("div",{key:"210d8622e1785b8c882f9c9a2fa2072af0e857b6",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}static get style(){return':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}'}},[1,"bn-chart-bubble",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],size:[1],share:[1],compareWith:[1,"compare-with"],level:[1],seriesLevel:[1,"series-level"],facet:[1],labels:[1],legend:[1],aspect:[1],limit:[2],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}]),U=M,B=function(){"undefined"!=typeof customElements&&["bn-chart-bubble","bn-chart-bubble-renderer"].forEach((t=>{switch(t){case"bn-chart-bubble":customElements.get(n(t))||customElements.define(n(t),M);break;case"bn-chart-bubble-renderer":customElements.get(n(t))||C()}}))};export{U as BnChartBubble,B as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,w as i,f as s,h as a,a as r,t as n}from"./p-D6YGOYV1.js";import{h as l,a as o}from"./p-DDvWTgk1.js";import{o as h}from"./p-DaOm9YwQ.js";import{c}from"./p-C2ycO60j.js";import{a as d}from"./p-JofGXz75.js";import{g as u}from"./p-DD1zlev_.js";import{c as p}from"./p-D2Epww9R.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as b,j as y}from"./p-BiSytXUy.js";import{w as g}from"./p-Dq9dG0Kr.js";import{w as x}from"./p-DjPWZfry.js";import{w}from"./p-DJUffGeB.js";import{w as _}from"./p-4vVbchX2.js";import{w as S}from"./p-D40Am1Ap.js";import{w as j}from"./p-DQl2K2Xl.js";import{w as L}from"./p-xIWChKGS.js";import{w as R}from"./p-DwuXVo2h.js";import{r as $,s as z}from"./p-BXXjh6We.js";import{t as A,a as E,b as W,c as D,d as N,e as k,p as O}from"./p-9mUU4itF.js";import{s as F}from"./p-DakXa7Dp.js";import{d as C}from"./p-DnDL1pPc.js";const G={rowGroup:0,category:1,subCategory:2},X=["ac","pp","fc","pl"],M=t(class extends e{validateFilter(t){const e="ERR_filter";l(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateMeasureSpec("x",t,!0,(t=>A(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>A(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>E(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>W(t)))}validateCompareWith(t){const e="WARN_compareWith";f(t)||X.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`compare-with: invalid value '${t}' - expected ${X.join("/")}; ignored.`})}validateLevel(t){const e="WARN_level",i=["auto","category","subcategory"];f(t)||i.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${i.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",i=["auto","rowgroup","category","none"];f(t)||i.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${i.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,(t=>D(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>N(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>k(t)))}validateAspect(t){const e="WARN_aspect";f(t)||null!==this.parseAspect(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`aspect: invalid value '${t}' - expected "w:h" (e.g. "16:9"); using the default.`})}validateLimit(t){const e="WARN_limit";b(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateScale(t){const e="WARN_scale";if(f(t))return void this.errors.remove(e);const{mode:i,factor:s}=m(t);"factor"===i&&(void 0===s||s<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.pixelPerUnitGroupMap=new Map,this.chartTitle="",this.filter="",this.share="",this.compareWith="",this.level="auto",this.seriesLevel="auto",this.facet="",this.labels="",this.legend="",this.aspect="16:9",this.limit=0,this._autoScaleGuard=!1,this._lastObservedWidth=0,this.translateForInner=(t,e)=>this.t(t,e),R(this),g(this),w(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=_(this),j(this),this.componentStyle=x(this),this.ruleSetConfig=S(this),this.t=L(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateSize(this.size),this.validateShare(this.share),this.validateCompareWith(this.compareWith),this.validateLevel(this.level),this.validateSeriesLevel(this.seriesLevel),this.validateFacet(this.facet),this.validateLabels(this.labels),this.validateLegend(this.legend),this.validateAspect(this.aspect),this.validateLimit(this.limit),this.validateScale(this.scale)}componentDidRender(){F(this.element,"bn-chart-bubble-renderer");const{mode:t}=m(this.scale);if("auto"!==t&&"empty"!==t)return this._autoScaleGuard=!1,void this.checkOverflow();if(this._autoScaleGuard)return this._autoScaleGuard=!1,void this.checkOverflow();const e=this.element,{width:s}=u(e);if(s<=0)return void this.checkOverflow();this._lastObservedWidth=s;const a=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),r=e.scrollWidth,n=this.appliedScaleFactor;if(!Number.isFinite(r)||r<=s+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const l=Math.max(.3,n*(s-1)/r);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",a*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-bubble-renderer",this.errors)}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);t>0&&Math.abs(t-this._lastObservedWidth)>2?(this._lastObservedWidth=t,s(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"all",values:!0,max:12}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateSizeScaling(){var t;const e=null===(t=this.prepareSize())||void 0===t?void 0:t.group;this.setBlockingError("ERR_xy_scale_group",void 0===e||this.pixelPerUnitGroupMap.has(e)?null:this.t(".bubble-scale-group-unknown",{group:e}))}validateMeasureSpec(t,e,i,s){var a;const r="ERR_xy_json_"+t,n="ERR_xy_measure_"+t,l="WARN_xy_fields_"+t,{data:o,parseError:h}=O(e,"measure");if(h)return this.setBlockingError(r,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(n,null),void this.errors.remove(l);if(this.setBlockingError(r,null),null===o)return this.setBlockingError(n,i?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(l);const c=null!==(a=o.measure)&&void 0!==a?a:"";y(c)?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".xy-measure-invalid",{prop:t,measure:c})),this.reportSpecIssues(l,t,s(o))}validateObjectSpec(t,e,i){const s="ERR_xy_json_"+t,a="WARN_xy_fields_"+t,{data:r,parseError:n}=O(e,null);if(n)return this.setBlockingError(s,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(a);this.setBlockingError(s,null),null!==r?this.reportSpecIssues(a,t,i(r)):this.errors.remove(a)}reportSpecIssues(t,e,i){const s=[];null!==i&&i.invalidFields.length>0&&s.push("invalid: "+i.invalidFields.join(", ")),null!==i&&i.unknownKeys.length>0&&s.push("unknown: "+i.unknownKeys.join(", ")),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:i,parseError:s}=O(e,"measure");if(s||null===i)return null;const{config:a}=A(i);return null!==a&&y(a.measure)?(void 0!==a.min&&void 0!==a.max&&a.min>=a.max?(this.errors.addOrReplace({id:"WARN_xy_domain_"+t,type:"warning",message:t+": min must be smaller than max; the override is ignored."}),a.min=void 0,a.max=void 0):this.errors.remove("WARN_xy_domain_"+t),a):null}prepareSize(){const{data:t,parseError:e}=O(this.size,"measure");if(e||null===t)return null;const{config:i}=E(t);return null!==i&&y(i.measure)?i:null}prepareShare(){const{data:t,parseError:e}=O(this.share,"measure");if(e||null===t)return null;const{config:i}=W(t);return null!==i&&y(i.measure)?i:null}prepareCompareFamily(){var t;const e=null===(t=this.compareWith)||void 0===t?void 0:t.trim().toLowerCase();return X.includes(e)?e:null}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:i}=O(this.labels,null);return i||null===e?{points:t.points,values:t.values,max:t.max}:N(e,t).config}prepareLegend(){const{data:t,parseError:e}=O(this.legend,null);return e||null===t?{show:!0,position:"right"}:k(t).config}prepareFacet(){const{data:t,parseError:e}=O(this.facet,null);return e||null===t?null:D(t).config}preparePointLevel(){var t,e;const i=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===i)return"category";if("subcategory"===i)return"subCategory";const s=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===s||"category"===s||"subCategory"===s?s:"category"}prepareSeriesLevel(t){var e;const i=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===i?null:"rowgroup"===i?"rowGroup":"category"===i||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const i=new Set;let s=!1;for(const e of t){if(void 0===e)continue;const t=$(e);null!==t&&("scenario"===t.kind?i.add(z(t.slot)):s=!0)}this.setBlockingError("ERR_xy_family",i.size>1?this.t(".xy-family-mixed",{families:[...i].join(", ")}):null);const a=this.prepareCompareFamily();this.setBlockingError("ERR_xy_compare_variance",null!==a&&s?this.t(".xy-compare-variance"):null),this.setBlockingError("ERR_xy_compare_family",null!==a&&1===i.size&&i.has(a)?`compare-with: '${a}' is already the primary scenario family.`:null);const r=this.preparePointLevel(),n=this.prepareSeriesLevel(r),l=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let o=null;if(null!==n&&G[n]>=G[r]&&(o=`series '${n}' vs point '${r}'`),null!==l){const t=null!=n?n:r;G[l]>=G[t]&&(o=`facet '${l}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==o?this.t(".xy-level-order",{detail:o}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const i=Number(e[1]),s=Number(e[2]);return i<=0||s<=0?null:i/s}prepareAspect(){var t;return null!==(t=this.parseAspect(this.aspect))&&void 0!==t?t:16/9}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}prepareSizeAreaPerUnit(){var t;const e=null===(t=this.prepareSize())||void 0===t?void 0:t.group;if(void 0===e||!this.pixelPerUnitGroupMap.has(e))return 0;const i=this.pixelPerUnitGroupMap.get(e);if(!(i>0))return 0;const s=this.getEffectiveFontPx();return s*s/i}i18nLocalKeys(){return["no-data","axis.in","legend.title","legend.size","legend.compare"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(o.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{const i=e.global.fontSizePx*t;return{scaleFactors:e["bn-chart-bubble"].scaleFactors,fontStyles:{font:`${i}px ${e.global.fontFamily}`,size:i,color:e.global.fontColor,background:e.global.fontBackgroundColor,leading:1.8},axisStyles:e["bn-chart-bubble"].axisStyles,seriesColors:e["bn-chart-bubble"].seriesColors,padding:e["bn-chart-bubble"].padding}}))}async getBaseline(){return d(this.element,"bn-chart-bubble-renderer")}async getLayoutState(t){var e;const i=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",s=h(this.element),a=this.getEffectiveScaleFactor(),r=Number.isFinite(a)&&a>0?a:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*r;return c(this.element,"bn-chart-bubble-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},s,i)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getEffectiveFontPx(){return this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*this.getEffectiveScaleFactor()}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var i,s,a,r;const n=(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=e.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(a=e.global)||void 0===a?void 0:a.fontColor)||"#000000","--bn-font-background":(null===(r=e.global)||void 0===r?void 0:r.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const i of[1,2,3,4])t[`${e}${i}`]={type:"number",isOptional:!0,description:""};const e={x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y),size:this.prepareSize(),share:this.prepareShare()};for(const[i,s]of Object.entries(e)){if(null===s)continue;const e=$(s.measure);null!==e&&("scenario"===e.kind?t[e.slot].description=`${i}: ${void 0!==s.label?s.label:s.measure}`:(t[e.measure.base].description=`${i}: ${s.measure} (base)`,t[e.measure.delta].description=`${i}: ${s.measure} (delta)`))}const i=this.prepareCompareFamily();if(null!==i)for(const[s,a]of Object.entries(e)){if(null===a||"share"===s)continue;const e=$(a.measure);if(null!==e&&"scenario"===e.kind){const a=i+e.slot.replace(/^[a-z]+/,"");""===t[a].description&&(t[a].description=s+": compareWith")}}return{IBubbleChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareAxis("x",this.x),e=this.prepareAxis("y",this.y),i=this.prepareSize(),s=this.prepareShare(),r=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure,null==i?void 0:i.measure,null==s?void 0:s.measure],r),this.validateSizeScaling(),this.hasBlockingErrors()||null===t||null===e||null===i)return null;const n=this.preparePointLevel(),l=this.prepareI18n(),o=this.prepareStyle(),h=u(this.element).width;return a("bn-chart-bubble-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,size:i,share:s,compareFamily:this.prepareCompareFamily(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:r,pointLevel:n,seriesLevel:this.prepareSeriesLevel(n),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,sizeAreaPerUnit:this.prepareSizeAreaPerUnit(),styles:o,i18n:l,containerWidth:h,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"2b15b5b4fc32db48b951e82ecc87f25b0afcc9f8",style:this.getFontStyles()},a("div",{key:"210d8622e1785b8c882f9c9a2fa2072af0e857b6",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}}static get style(){return':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}'}},[1,"bn-chart-bubble",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],size:[1],share:[1],compareWith:[1,"compare-with"],level:[1],seriesLevel:[1,"series-level"],facet:[1],labels:[1],legend:[1],aspect:[1],limit:[2],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],size:[{validateSize:0}],share:[{validateShare:0}],compareWith:[{validateCompareWith:0}],level:[{validateLevel:0}],seriesLevel:[{validateSeriesLevel:0}],facet:[{validateFacet:0}],labels:[{validateLabels:0}],legend:[{validateLegend:0}],aspect:[{validateAspect:0}],limit:[{validateLimit:0}],scale:[{validateScale:0}]}]),B=M,U=function(){"undefined"!=typeof customElements&&["bn-chart-bubble","bn-chart-bubble-renderer"].forEach((t=>{switch(t){case"bn-chart-bubble":customElements.get(n(t))||customElements.define(n(t),M);break;case"bn-chart-bubble-renderer":customElements.get(n(t))||C()}}))};export{B as BnChartBubble,U as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as o,d as s}from"./p-
|
|
1
|
+
import{B as o,d as s}from"./p-CyfGkLMh.js";const p=o,r=s;export{p as BnChartBulletRenderer,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,w as i,f as s,h as r,a,t as n}from"./p-D6YGOYV1.js";import{h as l,a as o}from"./p-DDvWTgk1.js";import{o as h}from"./p-DaOm9YwQ.js";import{c as u}from"./p-ChaSU4fh.js";import{a as d}from"./p-XFZYX7DZ.js";import{C as c,A as p}from"./p-B5tixDPM.js";import{o as v}from"./p-B6kka9sT.js";import{a as m,b as f,O as g}from"./p-16rjcQ0t.js";import{g as b}from"./p-DD1zlev_.js";import{p as y}from"./p-Xb6Ilq8u.js";import{b as _,i as w,c as A,h as j}from"./p-BiSytXUy.js";import{w as O}from"./p-Dq9dG0Kr.js";import{w as R}from"./p-DjPWZfry.js";import{w as N}from"./p-DJUffGeB.js";import{w as S}from"./p-4vVbchX2.js";import{r as x}from"./p-CniN8ALm.js";import{w as D}from"./p-D40Am1Ap.js";import{w as E}from"./p-xIWChKGS.js";import{w as T}from"./p-DwuXVo2h.js";import{r as z}from"./p-BXXjh6We.js";import{p as W}from"./p-9mUU4itF.js";import{s as k}from"./p-DakXa7Dp.js";import{d as U}from"./p-chnyMHJT.js";const L=["measure","label","unit"];function $(t){const e=[],i=V(t,"measure",e);if(void 0===i||""===i.trim())return e.push("measure"),{config:null,unknownKeys:C(t,L),invalidFields:e};const s={measure:i.trim()};return s.label=V(t,"label",e),s.unit=V(t,"unit",e),{config:s,unknownKeys:C(t,L),invalidFields:e}}const F=["show","decimals"];function M(t,e){const i=[],s={show:e.show,decimals:e.decimals};return c.isExisting(t.show)&&("auto"===t.show||"none"===t.show?s.show=t.show:i.push("show")),c.isExisting(t.decimals)&&(c.isNumber(t.decimals)&&t.decimals>=0&&t.decimals<=4?s.decimals=Math.floor(t.decimals):i.push("decimals")),{config:s,unknownKeys:C(t,F),invalidFields:i}}function B(t){var e;const i=null!==(e=null==t?void 0:t.trim())&&void 0!==e?e:"";if(""===i||"null"===i)return{ranges:[],parseError:!1,issues:[]};let s;try{s=JSON.parse(i)}catch(t){return{ranges:[],parseError:!0,issues:[]}}if(!Array.isArray(s)||0===s.length)return{ranges:[],parseError:!0,issues:[]};if(!s.every((t=>c.isNumber(t)&&isFinite(t)&&t>0)))return{ranges:[],parseError:!0,issues:[]};const r=[];let a=s;const n=[...a].sort(((t,e)=>t-e));return n.some(((t,e)=>t!==a[e]))&&r.push("not ascending, sorted"),a=n,a.length>2&&(r.push(a.length+" entries, first 2 kept"),a=a.slice(0,2)),{ranges:a,parseError:!1,issues:r}}function C(t,e){return Object.keys(t).filter((t=>!e.includes(t)))}function V(t,e,i){if(c.isExisting(t[e]))return c.isString(t[e])?t[e]:void i.push(e)}const X=["pl1","pp1","fc1"],I=t(class extends e{validateFilter(t){const e="ERR_filter";l(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateActual(t){this.validateMeasureSpec("actual",t)}validateTarget(t){this.validateMeasureSpec("target",t)}validateRanges(t){const e="ERR_bullet_json_ranges",i="WARN_bullet_ranges",s=B(t);if(s.parseError)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:"ranges"})),void this.errors.remove(i);this.setBlockingError(e,null),s.issues.length>0?this.errors.addOrReplace({id:i,type:"warning",message:this.t(".bullet-ranges-invalid",{detail:s.issues.join("; ")})}):this.errors.remove(i)}validateNormalize(t){this.validateEnum("normalize","WARN_normalize",t,["target","none"],"target")}validateVariances(t){this.validateEnum("variances","WARN_variances",t,["auto","none"],"auto")}validateLevel(t){this.validateEnum("level","WARN_level",t,["auto","rowgroup","category","subcategory"],"auto")}validateOrder(t){const e="WARN_order",i=_(t).filter((t=>""!==t));0===i.length?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`order: invalid value(s) '${i.join(", ")}'; using the dataset order.`})}validateOrderDirection(t){const e="WARN_orderDirection";w(t)||A(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`order-direction: invalid value '${t}' - expected asc/desc; using asc.`})}validateLimit(t){const e="WARN_limit";j(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateLabels(t){const e="ERR_bullet_json_labels",i="WARN_bullet_fields_labels",{data:s,parseError:r}=W(t,null);if(r)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:"labels"})),void this.errors.remove(i);this.setBlockingError(e,null),null!==s?this.reportSpecIssues(i,"labels",M(s,this.labelDefaults())):this.errors.remove(i)}validateScale(t){const e="WARN_scale";if(w(t))return void this.errors.remove(e);const{mode:i,factor:s}=y(t);"factor"===i&&(void 0===s||s<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.actual="",this.target="",this.ranges="",this.normalizeMode="target",this.variances="auto",this.level="auto",this.order="",this.orderDirection="",this.limit=0,this.labels="",this._autoScaleGuard=!1,this._lastScaledParentHeight=0,this.translateForInner=(t,e)=>this.t(t,e),T(this),O(this),N(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=S(this),this.componentStyle=R(this),this.ruleSetConfig=D(this),this.t=E(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateActual(this.actual),this.validateTarget(this.target),this.validateRanges(this.ranges),this.validateNormalize(this.normalizeMode),this.validateVariances(this.variances),this.validateLevel(this.level),this.validateOrder(this.order),this.validateOrderDirection(this.orderDirection),this.validateLimit(this.limit),this.validateLabels(this.labels),this.validateScale(this.scale)}componentDidRender(){k(this.element,"bn-chart-bullet-renderer");const{mode:t}=y(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const e=this.element,{height:s}=b(e);if(s<=0)return;this._lastScaledParentHeight=s;const r=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),a=e.scrollHeight,n=this.appliedScaleFactor;if(a<=s+1)return void this.errors.remove("AUTO_scale");const l=Math.max(.3,n*(s-1)/a);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",r*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l})))}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=b(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=b(this.element);this._lastScaledParentHeight=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{show:"auto",decimals:1}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateMeasureSpec(t,e){var i;const s="ERR_bullet_json_"+t,r="ERR_bullet_measure_"+t,a="WARN_bullet_fields_"+t,{data:n,parseError:l}=W(e,"measure");if(l)return this.setBlockingError(s,this.t(".bullet-prop-json",{prop:t})),this.setBlockingError(r,null),void this.errors.remove(a);if(this.setBlockingError(s,null),null===n)return this.setBlockingError(r,null),void this.errors.remove(a);const o=(null!==(i=n.measure)&&void 0!==i?i:"").trim(),h=z(o);"auto"===o.toLowerCase()||null!==h&&"scenario"===h.kind?this.setBlockingError(r,null):this.setBlockingError(r,this.t(".bullet-measure-invalid",{prop:t,measure:o})),this.reportSpecIssues(a,t,$(n))}validateEnum(t,e,i,s,r){w(i)||s.includes(i.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`${t}: invalid value '${i}' - expected ${s.join("/")}; using '${r}'.`})}reportSpecIssues(t,e,i){const s=[];null!==i&&i.invalidFields.length>0&&s.push("invalid: "+i.invalidFields.join(", ")),null!==i&&i.unknownKeys.length>0&&s.push("unknown: "+i.unknownKeys.join(", ")),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareActual(){var t,e,i,s,r;const{data:a,parseError:n}=W(this.actual,"measure");if(n)return null;const l=null!==a?$(a).config:null;if(null===l||"auto"===l.measure.toLowerCase()){const r=null!==l,a=null!==(e=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==e?e:[],n=null!==(s=a.includes("ac1")?"ac1":null!==(i=a.find((t=>t.startsWith("ac"))))&&void 0!==i?i:a[0])&&void 0!==s?s:"ac1";return r||null===this.datasetMeta?this.errors.remove("AUTO_actual"):this.errors.addOrReplace({id:"AUTO_actual",type:"warning",message:"actual: not set, auto-detected: "+n}),null===l?{measure:n}:Object.assign(Object.assign({},l),{measure:n})}return this.errors.remove("AUTO_actual"),"scenario"===(null===(r=z(l.measure))||void 0===r?void 0:r.kind)?l:null}prepareTarget(){var t,e,i;const{data:s,parseError:r}=W(this.target,"measure");if(r)return null;const a=null!==s?$(s).config:null;if(null===a||"auto"===a.measure.toLowerCase()){const i=null!==a,s=null!==(e=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==e?e:[],r=X.find((t=>s.includes(t)));return void 0===r?(this.errors.remove("AUTO_target"),null!==this.datasetMeta?this.errors.addOrReplace({id:"WARN_bullet_target_unavailable",type:"warning",message:this.t(".bullet-target-none")}):this.errors.remove("WARN_bullet_target_unavailable"),null):(this.errors.remove("WARN_bullet_target_unavailable"),i||null===this.datasetMeta?this.errors.remove("AUTO_target"):this.errors.addOrReplace({id:"AUTO_target",type:"warning",message:"target: not set, auto-detected: "+r}),null===a?{measure:r}:Object.assign(Object.assign({},a),{measure:r}))}return this.errors.remove("AUTO_target"),this.errors.remove("WARN_bullet_target_unavailable"),"scenario"===(null===(i=z(a.measure))||void 0===i?void 0:i.kind)?a:null}prepareNormalize(){var t;return"none"===(null===(t=this.normalizeMode)||void 0===t?void 0:t.trim().toLowerCase())?"none":"target"}prepareShowVariances(){var t;return"none"!==(null===(t=this.variances)||void 0===t?void 0:t.trim().toLowerCase())}prepareLevel(){var t,e;const i=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("rowgroup"===i)return p.ROWGROUP;if("category"===i)return p.CATEGORY;if("subcategory"===i)return p.SUBCATEGORY;const s=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;if(void 0!==s&&""!==s){const t=p[s.toUpperCase()];if(void 0!==t)return t}return p.CATEGORY}prepareOrder(){var t,e,i,s;const r="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let a;w(this.order)||r?(null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),a=this.datasetMeta.suggestedOrder):(this.errors.remove("AUTO_order"),a=""):(this.errors.remove("AUTO_order"),a=this.order);const n=null!==(s=m[null===(i=this.orderDirection)||void 0===i?void 0:i.toUpperCase()])&&void 0!==s?s:m.ASC;if(w(a))return new f([g.CATEGORYINDEX],n);const l=a.split(",").map((t=>g[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new f(l.length>0?l:[g.CATEGORYINDEX],n)}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:i}=W(this.labels,null);return i||null===e?{show:t.show,decimals:t.decimals}:M(e,t).config}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","target","axis.in"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(o.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries(),...x(this.ruleSetConfig("user"))])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{const i=e.global.fontSizePx*t;return{scaleFactors:e["bn-chart-bullet"].scaleFactors,fontStyles:{font:`${i}px ${e.global.fontFamily}`,size:i,color:e.global.fontColor,background:e.global.fontBackgroundColor,leading:1.8},axisStyles:e["bn-chart-bullet"].axisStyles,barStyles:e["bn-chart-bullet"].barStyles,varianceStyles:e["bn-chart-bullet"].varianceStyles,rangeColors:e["bn-chart-bullet"].rangeColors,padding:e["bn-chart-bullet"].padding}}))}async getBaseline(){return d(this.element,"bn-chart-bullet-renderer")}async getLayoutState(t){var e;const i=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",s=h(this.element),r=this.getEffectiveScaleFactor(),a=Number.isFinite(r)&&r>0?r:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*a;return u(this.element,"bn-chart-bullet-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:a},s,i)}getEffectiveScaleFactor(){const{mode:t,factor:e}=y(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var i,s,r,a;const n=(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=e.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(r=e.global)||void 0===r?void 0:r.fontColor)||"#000000","--bn-font-background":(null===(a=e.global)||void 0===a?void 0:a.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const i of[1,2,3,4])t[`${e}${i}`]={type:"number",isOptional:!0,description:""};const e={actual:this.prepareActual(),target:this.prepareTarget()};for(const[i,s]of Object.entries(e))null!==s&&void 0!==t[s.measure]&&(t[s.measure].description=`${i}: ${void 0!==s.label?s.label:s.measure}`);return{IBulletChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareActual(),e=this.prepareTarget(),i=B(this.ranges).ranges,s=this.prepareNormalize();return this.setBlockingError("ERR_bullet_measure_same",null!==t&&null!==e&&t.measure===e.measure?this.t(".bullet-measure-same",{measure:t.measure}):null),i.length>0&&"target"===s?this.errors.addOrReplace({id:"WARN_bullet_ranges_ignored",type:"warning",message:this.t(".bullet-ranges-ignored")}):this.errors.remove("WARN_bullet_ranges_ignored"),this.hasBlockingErrors()||null===t?null:r("bn-chart-bullet-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,actual:t,target:e,ranges:i,normalizeMode:s,showVariances:this.prepareShowVariances(),level:this.prepareLevel(),order:this.prepareOrder(),limit:this.prepareLimit(),labels:this.prepareLabels(),filter:this.filter,styles:this.prepareStyle(),i18n:this.prepareI18n(),containerWidth:b(this.element).width,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return r(a,{key:"cdd2404977255a330652806671d1bea76c796769",style:this.getFontStyles()},r("div",{key:"0b8cfeb6209083f9144c5824bceecb9b02578f02",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}}static get style(){return':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}'}},[1,"bn-chart-bullet",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],actual:[1],target:[1],ranges:[1],normalizeMode:[1,"normalize"],variances:[1],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],labels:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}]),G=I,K=function(){"undefined"!=typeof customElements&&["bn-chart-bullet","bn-chart-bullet-renderer"].forEach((t=>{switch(t){case"bn-chart-bullet":customElements.get(n(t))||customElements.define(n(t),I);break;case"bn-chart-bullet-renderer":customElements.get(n(t))||U()}}))};export{G as BnChartBullet,K as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,w as i,f as s,h as r,a,t as n}from"./p-D6YGOYV1.js";import{h as l,a as o}from"./p-DDvWTgk1.js";import{o as h}from"./p-DaOm9YwQ.js";import{c as u}from"./p-C2ycO60j.js";import{a as d}from"./p-JofGXz75.js";import{C as c,A as p}from"./p-B5tixDPM.js";import{o as v}from"./p-B6kka9sT.js";import{a as m,b as f,O as g}from"./p-16rjcQ0t.js";import{g as b}from"./p-DD1zlev_.js";import{p as y}from"./p-Xb6Ilq8u.js";import{b as _,i as w,c as A,h as j}from"./p-BiSytXUy.js";import{w as O}from"./p-Dq9dG0Kr.js";import{w as R}from"./p-DjPWZfry.js";import{w as N}from"./p-DJUffGeB.js";import{w as S}from"./p-4vVbchX2.js";import{r as x}from"./p-CniN8ALm.js";import{w as D}from"./p-D40Am1Ap.js";import{w as E}from"./p-xIWChKGS.js";import{w as z}from"./p-DwuXVo2h.js";import{r as T}from"./p-BXXjh6We.js";import{p as k}from"./p-9mUU4itF.js";import{s as W}from"./p-DakXa7Dp.js";import{d as L}from"./p-CyfGkLMh.js";const U=["measure","label","unit"];function $(t){const e=[],i=V(t,"measure",e);if(void 0===i||""===i.trim())return e.push("measure"),{config:null,unknownKeys:B(t,U),invalidFields:e};const s={measure:i.trim()};return s.label=V(t,"label",e),s.unit=V(t,"unit",e),{config:s,unknownKeys:B(t,U),invalidFields:e}}const M=["show","decimals"];function F(t,e){const i=[],s={show:e.show,decimals:e.decimals};return c.isExisting(t.show)&&("auto"===t.show||"none"===t.show?s.show=t.show:i.push("show")),c.isExisting(t.decimals)&&(c.isNumber(t.decimals)&&t.decimals>=0&&t.decimals<=4?s.decimals=Math.floor(t.decimals):i.push("decimals")),{config:s,unknownKeys:B(t,M),invalidFields:i}}function C(t){var e;const i=null!==(e=null==t?void 0:t.trim())&&void 0!==e?e:"";if(""===i||"null"===i)return{ranges:[],parseError:!1,issues:[]};let s;try{s=JSON.parse(i)}catch(t){return{ranges:[],parseError:!0,issues:[]}}if(!Array.isArray(s)||0===s.length)return{ranges:[],parseError:!0,issues:[]};if(!s.every((t=>c.isNumber(t)&&isFinite(t)&&t>0)))return{ranges:[],parseError:!0,issues:[]};const r=[];let a=s;const n=[...a].sort(((t,e)=>t-e));return n.some(((t,e)=>t!==a[e]))&&r.push("not ascending, sorted"),a=n,a.length>2&&(r.push(a.length+" entries, first 2 kept"),a=a.slice(0,2)),{ranges:a,parseError:!1,issues:r}}function B(t,e){return Object.keys(t).filter((t=>!e.includes(t)))}function V(t,e,i){if(c.isExisting(t[e]))return c.isString(t[e])?t[e]:void i.push(e)}const G=["pl1","pp1","fc1"],I=t(class extends e{validateFilter(t){const e="ERR_filter";l(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateActual(t){this.validateMeasureSpec("actual",t)}validateTarget(t){this.validateMeasureSpec("target",t)}validateRanges(t){const e="ERR_bullet_json_ranges",i="WARN_bullet_ranges",s=C(t);if(s.parseError)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:"ranges"})),void this.errors.remove(i);this.setBlockingError(e,null),s.issues.length>0?this.errors.addOrReplace({id:i,type:"warning",message:this.t(".bullet-ranges-invalid",{detail:s.issues.join("; ")})}):this.errors.remove(i)}validateNormalize(t){this.validateEnum("normalize","WARN_normalize",t,["target","none"],"target")}validateVariances(t){this.validateEnum("variances","WARN_variances",t,["auto","none"],"auto")}validateLevel(t){this.validateEnum("level","WARN_level",t,["auto","rowgroup","category","subcategory"],"auto")}validateOrder(t){const e="WARN_order",i=_(t).filter((t=>""!==t));0===i.length?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`order: invalid value(s) '${i.join(", ")}'; using the dataset order.`})}validateOrderDirection(t){const e="WARN_orderDirection";w(t)||A(t)?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`order-direction: invalid value '${t}' - expected asc/desc; using asc.`})}validateLimit(t){const e="WARN_limit";j(t)&&Number(t)>=0?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`limit: invalid value '${t}' - expected a non-negative integer; using 0.`})}validateLabels(t){const e="ERR_bullet_json_labels",i="WARN_bullet_fields_labels",{data:s,parseError:r}=k(t,null);if(r)return this.setBlockingError(e,this.t(".bullet-prop-json",{prop:"labels"})),void this.errors.remove(i);this.setBlockingError(e,null),null!==s?this.reportSpecIssues(i,"labels",F(s,this.labelDefaults())):this.errors.remove(i)}validateScale(t){const e="WARN_scale";if(w(t))return void this.errors.remove(e);const{mode:i,factor:s}=y(t);"factor"===i&&(void 0===s||s<=0)?this.errors.addOrReplace({id:e,type:"warning",message:`scale: invalid value '${t}' - expected none/auto or a positive number.`}):this.errors.remove(e)}constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.datasetName="",this.dataVersion=0,this.datasetMeta=null,this.appliedScaleFactor=1,this.layoutObserver=null,this.activeErrors=new Set,this.chartTitle="",this.filter="",this.actual="",this.target="",this.ranges="",this.normalizeMode="target",this.variances="auto",this.level="auto",this.order="",this.orderDirection="",this.limit=0,this.labels="",this._autoScaleGuard=!1,this._lastScaledParentHeight=0,this.translateForInner=(t,e)=>this.t(t,e),z(this),O(this),N(this,(t=>{this.datasetName=(null==t?void 0:t.startsWith("$"))?t.substring(1):t||"",this.dataVersion=this.dataVersion+1}),((t,e)=>{this.datasetMeta=e})),this.errors=S(this),this.componentStyle=R(this),this.ruleSetConfig=D(this),this.t=E(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateActual(this.actual),this.validateTarget(this.target),this.validateRanges(this.ranges),this.validateNormalize(this.normalizeMode),this.validateVariances(this.variances),this.validateLevel(this.level),this.validateOrder(this.order),this.validateOrderDirection(this.orderDirection),this.validateLimit(this.limit),this.validateLabels(this.labels),this.validateScale(this.scale)}componentDidRender(){W(this.element,"bn-chart-bullet-renderer");const{mode:t}=y(this.scale);if("auto"!==t&&"empty"!==t)return void(this._autoScaleGuard=!1);if(this._autoScaleGuard)return void(this._autoScaleGuard=!1);const e=this.element,{height:s}=b(e);if(s<=0)return;this._lastScaledParentHeight=s;const r=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333})),a=e.scrollHeight,n=this.appliedScaleFactor;if(a<=s+1)return void this.errors.remove("AUTO_scale");const l=Math.max(.3,n*(s-1)/a);Math.abs(l-n)<.01||(e.style.setProperty("--bn-font-size",r*l+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+l.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,i((()=>{this.appliedScaleFactor=l})))}componentDidLoad(){this.layoutObserver=v(this.element,(()=>{if(this._autoScaleGuard)return;const{height:t}=b(this.element);t>0&&Math.abs(t-this._lastScaledParentHeight)>2&&(this._lastScaledParentHeight=t,s(this))})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{height:t}=b(this.element);this._lastScaledParentHeight=t,s(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{show:"auto",decimals:1}}setBlockingError(t,e){null===e?(this.errors.remove(t),this.activeErrors.delete(t)):(this.errors.addOrReplace({id:t,type:"error",message:e}),this.activeErrors.add(t))}hasBlockingErrors(){return this.activeErrors.size>0}validateMeasureSpec(t,e){var i;const s="ERR_bullet_json_"+t,r="ERR_bullet_measure_"+t,a="WARN_bullet_fields_"+t,{data:n,parseError:l}=k(e,"measure");if(l)return this.setBlockingError(s,this.t(".bullet-prop-json",{prop:t})),this.setBlockingError(r,null),void this.errors.remove(a);if(this.setBlockingError(s,null),null===n)return this.setBlockingError(r,null),void this.errors.remove(a);const o=(null!==(i=n.measure)&&void 0!==i?i:"").trim(),h=T(o);"auto"===o.toLowerCase()||null!==h&&"scenario"===h.kind?this.setBlockingError(r,null):this.setBlockingError(r,this.t(".bullet-measure-invalid",{prop:t,measure:o})),this.reportSpecIssues(a,t,$(n))}validateEnum(t,e,i,s,r){w(i)||s.includes(i.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`${t}: invalid value '${i}' - expected ${s.join("/")}; using '${r}'.`})}reportSpecIssues(t,e,i){const s=[];null!==i&&i.invalidFields.length>0&&s.push("invalid: "+i.invalidFields.join(", ")),null!==i&&i.unknownKeys.length>0&&s.push("unknown: "+i.unknownKeys.join(", ")),s.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${s.join("; ")}).`}):this.errors.remove(t)}prepareActual(){var t,e,i,s,r;const{data:a,parseError:n}=k(this.actual,"measure");if(n)return null;const l=null!==a?$(a).config:null;if(null===l||"auto"===l.measure.toLowerCase()){const r=null!==l,a=null!==(e=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==e?e:[],n=null!==(s=a.includes("ac1")?"ac1":null!==(i=a.find((t=>t.startsWith("ac"))))&&void 0!==i?i:a[0])&&void 0!==s?s:"ac1";return r||null===this.datasetMeta?this.errors.remove("AUTO_actual"):this.errors.addOrReplace({id:"AUTO_actual",type:"warning",message:"actual: not set, auto-detected: "+n}),null===l?{measure:n}:Object.assign(Object.assign({},l),{measure:n})}return this.errors.remove("AUTO_actual"),"scenario"===(null===(r=T(l.measure))||void 0===r?void 0:r.kind)?l:null}prepareTarget(){var t,e,i;const{data:s,parseError:r}=k(this.target,"measure");if(r)return null;const a=null!==s?$(s).config:null;if(null===a||"auto"===a.measure.toLowerCase()){const i=null!==a,s=null!==(e=null===(t=this.datasetMeta)||void 0===t?void 0:t.availableScenarios)&&void 0!==e?e:[],r=G.find((t=>s.includes(t)));return void 0===r?(this.errors.remove("AUTO_target"),null!==this.datasetMeta?this.errors.addOrReplace({id:"WARN_bullet_target_unavailable",type:"warning",message:this.t(".bullet-target-none")}):this.errors.remove("WARN_bullet_target_unavailable"),null):(this.errors.remove("WARN_bullet_target_unavailable"),i||null===this.datasetMeta?this.errors.remove("AUTO_target"):this.errors.addOrReplace({id:"AUTO_target",type:"warning",message:"target: not set, auto-detected: "+r}),null===a?{measure:r}:Object.assign(Object.assign({},a),{measure:r}))}return this.errors.remove("AUTO_target"),this.errors.remove("WARN_bullet_target_unavailable"),"scenario"===(null===(i=T(a.measure))||void 0===i?void 0:i.kind)?a:null}prepareNormalize(){var t;return"none"===(null===(t=this.normalizeMode)||void 0===t?void 0:t.trim().toLowerCase())?"none":"target"}prepareShowVariances(){var t;return"none"!==(null===(t=this.variances)||void 0===t?void 0:t.trim().toLowerCase())}prepareLevel(){var t,e;const i=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("rowgroup"===i)return p.ROWGROUP;if("category"===i)return p.CATEGORY;if("subcategory"===i)return p.SUBCATEGORY;const s=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;if(void 0!==s&&""!==s){const t=p[s.toUpperCase()];if(void 0!==t)return t}return p.CATEGORY}prepareOrder(){var t,e,i,s;const r="auto"===(null===(t=this.order)||void 0===t?void 0:t.trim().toLowerCase());let a;w(this.order)||r?(null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedOrder)?(r?this.errors.remove("AUTO_order"):this.errors.addOrReplace({id:"AUTO_order",type:"warning",message:"order: not set, auto-detected: "+this.datasetMeta.suggestedOrder}),a=this.datasetMeta.suggestedOrder):(this.errors.remove("AUTO_order"),a=""):(this.errors.remove("AUTO_order"),a=this.order);const n=null!==(s=m[null===(i=this.orderDirection)||void 0===i?void 0:i.toUpperCase()])&&void 0!==s?s:m.ASC;if(w(a))return new f([g.CATEGORYINDEX],n);const l=a.split(",").map((t=>g[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new f(l.length>0?l:[g.CATEGORYINDEX],n)}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:i}=k(this.labels,null);return i||null===e?{show:t.show,decimals:t.decimals}:F(e,t).config}prepareLimit(){const t=Math.floor(Number(this.limit)||0);return t>0?t:0}i18nLocalKeys(){return["no-data","target","axis.in"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(o.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries(),...x(this.ruleSetConfig("user"))])}prepareStyle(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{const i=e.global.fontSizePx*t;return{scaleFactors:e["bn-chart-bullet"].scaleFactors,fontStyles:{font:`${i}px ${e.global.fontFamily}`,size:i,color:e.global.fontColor,background:e.global.fontBackgroundColor,leading:1.8},axisStyles:e["bn-chart-bullet"].axisStyles,barStyles:e["bn-chart-bullet"].barStyles,varianceStyles:e["bn-chart-bullet"].varianceStyles,rangeColors:e["bn-chart-bullet"].rangeColors,padding:e["bn-chart-bullet"].padding}}))}async getBaseline(){return d(this.element,"bn-chart-bullet-renderer")}async getLayoutState(t){var e;const i=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",s=h(this.element),r=this.getEffectiveScaleFactor(),a=Number.isFinite(r)&&r>0?r:1,n=this.componentStyle((t=>{var e;return(null===(e=t.global)||void 0===e?void 0:e.fontSizePx)||13.3333}))*a;return u(this.element,"bn-chart-bullet-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:a},s,i)}getEffectiveScaleFactor(){const{mode:t,factor:e}=y(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var i,s,r,a;const n=(null===(i=e.global)||void 0===i?void 0:i.fontSizePx)||13.3333;return{"--bn-font-family":(null===(s=e.global)||void 0===s?void 0:s.fontFamily)||"'Noto Sans', sans-serif","--bn-font-size":n*t+"px","--bn-font-color":(null===(r=e.global)||void 0===r?void 0:r.fontColor)||"#000000","--bn-font-background":(null===(a=e.global)||void 0===a?void 0:a.fontBackgroundColor)||"#ffffff"}}))}getDataStructure(){const t={};for(const e of["ac","pp","fc","pl"])for(const i of[1,2,3,4])t[`${e}${i}`]={type:"number",isOptional:!0,description:""};const e={actual:this.prepareActual(),target:this.prepareTarget()};for(const[i,s]of Object.entries(e))null!==s&&void 0!==t[s.measure]&&(t[s.measure].description=`${i}: ${void 0!==s.label?s.label:s.measure}`);return{IBulletChartDataRow:Object.assign({operation:{type:"string",isOptional:!1,description:""},rowGroup:{type:"string",isOptional:!0,description:""},rowGroupIndex:{type:"number",isOptional:!0,description:""},category:{type:"string",isOptional:!1,description:""},categoryIndex:{type:"number",isOptional:!1,description:""},subCategory:{type:"string",isOptional:!0,description:""},subCategoryIndex:{type:"number",isOptional:!0,description:""}},t)}}chartTemplate(){const t=this.prepareActual(),e=this.prepareTarget(),i=C(this.ranges).ranges,s=this.prepareNormalize();return this.setBlockingError("ERR_bullet_measure_same",null!==t&&null!==e&&t.measure===e.measure?this.t(".bullet-measure-same",{measure:t.measure}):null),i.length>0&&"target"===s?this.errors.addOrReplace({id:"WARN_bullet_ranges_ignored",type:"warning",message:this.t(".bullet-ranges-ignored")}):this.errors.remove("WARN_bullet_ranges_ignored"),this.hasBlockingErrors()||null===t?null:r("bn-chart-bullet-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,actual:t,target:e,ranges:i,normalizeMode:s,showVariances:this.prepareShowVariances(),level:this.prepareLevel(),order:this.prepareOrder(),limit:this.prepareLimit(),labels:this.prepareLabels(),filter:this.filter,styles:this.prepareStyle(),i18n:this.prepareI18n(),containerWidth:b(this.element).width,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return r(a,{key:"cdd2404977255a330652806671d1bea76c796769",style:this.getFontStyles()},r("div",{key:"0b8cfeb6209083f9144c5824bceecb9b02578f02",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}}static get style(){return':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}'}},[1,"bn-chart-bullet",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],actual:[1],target:[1],ranges:[1],normalizeMode:[1,"normalize"],variances:[1],level:[1],order:[1],orderDirection:[1,"order-direction"],limit:[2],labels:[1],scale:[1],datasetName:[32],dataVersion:[32],datasetMeta:[32],appliedScaleFactor:[32],getBaseline:[64],getLayoutState:[64]},void 0,{filter:[{validateFilter:0}],actual:[{validateActual:0}],target:[{validateTarget:0}],ranges:[{validateRanges:0}],normalizeMode:[{validateNormalize:0}],variances:[{validateVariances:0}],level:[{validateLevel:0}],order:[{validateOrder:0}],orderDirection:[{validateOrderDirection:0}],limit:[{validateLimit:0}],labels:[{validateLabels:0}],scale:[{validateScale:0}]}]),X=I,K=function(){"undefined"!=typeof customElements&&["bn-chart-bullet","bn-chart-bullet-renderer"].forEach((t=>{switch(t){case"bn-chart-bullet":customElements.get(n(t))||customElements.define(n(t),I);break;case"bn-chart-bullet-renderer":customElements.get(n(t))||L()}}))};export{X as BnChartBullet,K as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as o,d as
|
|
1
|
+
import{B as o,d as s}from"./p-AwH1w8Mu.js";const p=o,r=s;export{p as BnChartScatterRenderer,r as defineCustomElement}
|