@bino-bi/bn-template-engine 1.0.0-next.48 → 1.0.0-next.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bn-template-engine/bn-template-engine.esm.js +1 -1
- package/dist/bn-template-engine/{p-b3f5eba0.entry.js → p-2de524d0.entry.js} +1 -1
- package/dist/bn-template-engine/{p-a6017fce.entry.js → p-510d2ee6.entry.js} +1 -1
- package/dist/bn-template-engine/{p-6ab684a9.entry.js → p-8fc90dc8.entry.js} +1 -1
- package/dist/bn-template-engine/p-BFl7OwcC.js +1 -0
- package/dist/bn-template-engine/{p-3ktFZb1x.js → p-Bxa4pX1M.js} +1 -1
- package/dist/bn-template-engine/p-c1d679af.entry.js +1 -0
- package/dist/cjs/bn-annotation-layer_30.cjs.entry.js +628 -108
- package/dist/cjs/bn-grid.cjs.entry.js +1 -1
- package/dist/cjs/bn-image.cjs.entry.js +1 -1
- package/dist/cjs/bn-text.cjs.entry.js +2 -2
- package/dist/cjs/{withStyled-DHKHBdRb.js → withStyled-pkdctrK9.js} +18 -1
- package/dist/cjs/{withTranslation-CLwC9a8V.js → withTranslation-BIzTNYZM.js} +1 -1
- package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.css +19 -0
- package/dist/collection/components/bn-annotation-layer/bn-annotation-layer.js +65 -8
- package/dist/collection/components/bn-annotation-layer/utils/marks.js +85 -5
- package/dist/collection/components/bn-annotation-layer/utils/matchPoint.js +7 -1
- package/dist/collection/components/bn-chart-time/bn-chart-time-renderer/bn-chart-time-renderer.js +20 -6
- package/dist/collection/components/bn-chart-time/bn-chart-time.js +55 -23
- package/dist/collection/components/bn-chart-time/utils/TimeChart.js +329 -53
- package/dist/collection/components/bn-chart-time/utils/elements/Column.js +4 -1
- package/dist/collection/components/bn-chart-time/utils/elements/Label.js +2 -1
- package/dist/collection/components/bn-chart-time/utils/elements/StackedColumn.js +53 -11
- package/dist/collection/utils/annotations.js +1 -1
- package/dist/collection/utils/constants.js +2 -0
- package/dist/collection/utils/layoutState/svgChartElements.js +10 -0
- package/dist/collection/utils/validate.js +16 -1
- package/dist/components/bn-annotation-layer.js +1 -1
- package/dist/components/bn-annotation-list.js +1 -1
- package/dist/components/bn-chart-bubble-renderer.js +1 -1
- package/dist/components/bn-chart-bubble.js +1 -1
- package/dist/components/bn-chart-bullet-renderer.js +1 -1
- package/dist/components/bn-chart-bullet.js +1 -1
- package/dist/components/bn-chart-scatter-renderer.js +1 -1
- package/dist/components/bn-chart-scatter.js +1 -1
- package/dist/components/bn-chart-structure-renderer.js +1 -1
- package/dist/components/bn-chart-structure.js +1 -1
- package/dist/components/bn-chart-time-renderer.js +1 -1
- package/dist/components/bn-chart-time.js +1 -1
- package/dist/components/bn-grid.js +1 -1
- package/dist/components/bn-image.js +1 -1
- package/dist/components/bn-layout-card.js +1 -1
- package/dist/components/bn-layout-page.js +1 -1
- package/dist/components/bn-page.js +1 -1
- package/dist/components/bn-table-renderer.js +1 -1
- package/dist/components/bn-table.js +1 -1
- package/dist/components/bn-text.js +1 -1
- package/dist/components/bn-title-renderer.js +1 -1
- package/dist/components/bn-title.js +1 -1
- package/dist/components/bn-tree.js +1 -1
- package/dist/components/{p-CLjuZoiT.js → p-B11cXOLy.js} +1 -1
- package/dist/components/p-BBdzTx8V.js +1 -0
- package/dist/components/{p-B1_wkOLx.js → p-BVNOmHh4.js} +1 -1
- package/dist/components/p-BXP6aagM.js +1 -0
- package/dist/components/{p-CG-iY7pQ.js → p-Blre9f28.js} +1 -1
- package/dist/components/p-CHJ6WE0l.js +1 -0
- package/dist/components/{p-Do4GqlMV.js → p-CHhxQoF9.js} +1 -1
- package/dist/components/{p-C-3TOa6K.js → p-CJ0-xdfZ.js} +1 -1
- package/dist/components/{p-BFoRIqDi.js → p-CO6bgquz.js} +1 -1
- package/dist/components/{p-CytMTBFu.js → p-CSJCkHEL.js} +1 -1
- package/dist/components/p-CVfmhtEW.js +1 -0
- package/dist/components/{p-Zuxd3z0q.js → p-Cc0gaLwp.js} +1 -1
- package/dist/components/p-CuUfiEu0.js +1 -0
- package/dist/components/{p-DUZCLRVu.js → p-D362XOg2.js} +1 -1
- package/dist/components/p-DBj1Yd3M.js +1 -0
- package/dist/components/{p-BjgkgCAQ.js → p-DHX92KDP.js} +1 -1
- package/dist/components/p-DHloMyxV.js +1 -0
- package/dist/components/{p-Uc0zvXcQ.js → p-Dd1QOWDV.js} +1 -1
- package/dist/components/p-DguYWLBj.js +1 -0
- package/dist/components/p-Do-IGHJk.js +1 -0
- package/dist/components/{p-DDo-fu3v.js → p-DsC0ew4j.js} +1 -1
- package/dist/components/p-HVN8BNWN.js +1 -0
- package/dist/components/{p-Dyzb4ika.js → p-YSRTB0jS.js} +1 -1
- package/dist/components/{p-CrZ_O3DT.js → p-k7heRDPP.js} +1 -1
- package/dist/components/{p-dO0utE8m.js → p-keKnrAVS.js} +1 -1
- package/dist/components/p-x0W2_FAX.js +1 -0
- package/dist/components/p-y12CmIFS.js +1 -0
- package/dist/esm/bn-annotation-layer_30.entry.js +628 -108
- package/dist/esm/bn-grid.entry.js +1 -1
- package/dist/esm/bn-image.entry.js +1 -1
- package/dist/esm/bn-text.entry.js +2 -2
- package/dist/esm/{withStyled-CTZFjg4L.js → withStyled-B62R20Zx.js} +18 -1
- package/dist/esm/{withTranslation-BESW5BNq.js → withTranslation-BEseMLQ6.js} +1 -1
- package/dist/types/components/bn-annotation-layer/utils/marks.d.ts +48 -0
- package/dist/types/components/bn-annotation-layer/utils/matchPoint.d.ts +4 -0
- package/dist/types/components/bn-chart-time/bn-chart-time.d.ts +29 -6
- package/dist/types/components/bn-chart-time/utils/TimeChart.d.ts +51 -2
- package/dist/types/components/bn-chart-time/utils/elements/StackedColumn.d.ts +5 -1
- package/dist/types/components/bn-chart-time/utils/model/TimeChartComponentConfig.d.ts +6 -0
- package/dist/types/components.d.ts +6 -6
- package/dist/types/utils/annotations.d.ts +11 -1
- package/dist/types/utils/constants.d.ts +3 -1
- package/dist/types/utils/layoutState/types.d.ts +2 -0
- package/package.json +1 -1
- package/dist/bn-template-engine/p-203e7d6a.entry.js +0 -1
- package/dist/bn-template-engine/p-DXtYQE4s.js +0 -1
- package/dist/components/p-6gET6YXc.js +0 -1
- package/dist/components/p-BFWvVe7v.js +0 -1
- package/dist/components/p-C8rpOS5t.js +0 -1
- package/dist/components/p-CUoPUIej.js +0 -1
- package/dist/components/p-ChpAMqbN.js +0 -1
- package/dist/components/p-D3hr9wra.js +0 -1
- package/dist/components/p-DFybNETX.js +0 -1
- package/dist/components/p-DRmphEA0.js +0 -1
- package/dist/components/p-D_K7tYhY.js +0 -1
- package/dist/components/p-Dw3rv_Y9.js +0 -1
- package/dist/components/p-TNX3alPU.js +0 -1
- package/dist/components/p-j42D1yrQ.js +0 -1
|
@@ -3,6 +3,7 @@ import { SiPrefix } from "../../../../utils/model/SiPrefix";
|
|
|
3
3
|
import { StackMode } from "../../../../utils/constants";
|
|
4
4
|
import { Formatter } from "../../../../utils/formatter";
|
|
5
5
|
import { dataPointAttributes } from "../../../../utils/layoutState/dataPoint";
|
|
6
|
+
import { getScenarioPrefix } from "../../../../utils/stackColors";
|
|
6
7
|
/**
|
|
7
8
|
* Renders a single segment within a stacked bar column in a time chart.
|
|
8
9
|
*
|
|
@@ -18,7 +19,9 @@ import { dataPointAttributes } from "../../../../utils/layoutState/dataPoint";
|
|
|
18
19
|
* The last segment can draw the total label of the full stack via drawTotalLabel().
|
|
19
20
|
*/
|
|
20
21
|
export class StackedColumn {
|
|
21
|
-
constructor(position, styles, dataPoint, index, segment, _segmentLabel, segmentIndex, stackMode, stack, _isScenarioStack, parentGroup) {
|
|
22
|
+
constructor(position, styles, dataPoint, index, segment, _segmentLabel, segmentIndex, stackMode, stack, _isScenarioStack, parentGroup, notation = false, plainShares = false) {
|
|
23
|
+
this.notation = notation;
|
|
24
|
+
this.plainShares = plainShares;
|
|
22
25
|
this.hasData = false;
|
|
23
26
|
this.position = position;
|
|
24
27
|
this.styles = styles;
|
|
@@ -35,6 +38,7 @@ export class StackedColumn {
|
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
draw(dataFormatDigits = { percent: 2, decimal: 1 }, measureScale = new SiPrefix()) {
|
|
41
|
+
var _a, _b;
|
|
38
42
|
// a segment without a value (NaN) keeps its place in the stack, so the colours stay, but draws nothing
|
|
39
43
|
if (!this.hasData || !Number.isFinite(this.dataPoint.value)) {
|
|
40
44
|
return;
|
|
@@ -48,10 +52,28 @@ export class StackedColumn {
|
|
|
48
52
|
const xPos = this.position.getColumnCenterPositionX(this.index);
|
|
49
53
|
const columnWidth = this.position.getColumnWidth();
|
|
50
54
|
const colors = this.styles.stackColors;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
let fillColor = colors[this.segmentIndex % colors.length];
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
let fillStyle = { color: fillColor };
|
|
58
|
+
let strokeStyle = { color: fillColor, width: 0.5 };
|
|
59
|
+
let hatched = false;
|
|
60
|
+
// FC and PL: the series keeps its shade, the scenario adds the hatching or the outline.
|
|
61
|
+
// The first series is the darkest: it takes the fill of the scenario, as a plain column does.
|
|
62
|
+
const family = getScenarioPrefix((_a = this.dataPoint.scenario) !== null && _a !== void 0 ? _a : "");
|
|
63
|
+
if (this.notation && (family === "fc" || family === "pl")) {
|
|
64
|
+
const look = this.styles.barStyles.getSVGStyle(family);
|
|
65
|
+
if (this.segmentIndex === 0) {
|
|
66
|
+
fillColor = look.fill;
|
|
67
|
+
}
|
|
68
|
+
fillStyle = { color: fillColor };
|
|
69
|
+
strokeStyle = { color: look.stroke, width: 1 };
|
|
70
|
+
if (look.fillpattern === "hatched") {
|
|
71
|
+
hatched = true;
|
|
72
|
+
fillStyle = (_b = this.hatchPattern(fillColor, look.stroke)) !== null && _b !== void 0 ? _b : fillStyle;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
54
75
|
this.columnGroup.attr(dataPointAttributes(this.dataPoint.key, "element"));
|
|
76
|
+
this.columnGroup.attr("data-bn-value", value);
|
|
55
77
|
// Draw rectangle
|
|
56
78
|
this.columnGroup
|
|
57
79
|
.rect(columnWidth, Math.max(segmentHeight, 0.5))
|
|
@@ -59,26 +81,46 @@ export class StackedColumn {
|
|
|
59
81
|
.stroke(strokeStyle)
|
|
60
82
|
.y(yPos)
|
|
61
83
|
.cx(xPos);
|
|
62
|
-
// Draw segment value label if segment is tall enough
|
|
63
|
-
const MIN_SEGMENT_HEIGHT_FOR_LABEL = 18;
|
|
84
|
+
// Draw segment value label if the segment is tall enough: 18px, less for a font that is smaller than that
|
|
85
|
+
const MIN_SEGMENT_HEIGHT_FOR_LABEL = Math.min(18, (this.styles.fontStyles.size || 18) * 1.15);
|
|
64
86
|
if (segmentHeight >= MIN_SEGMENT_HEIGHT_FOR_LABEL) {
|
|
65
87
|
const labelY = yPos + segmentHeight / 2;
|
|
88
|
+
// a label on a hatching keeps the background of a plain label
|
|
89
|
+
const onFill = (label) => (hatched ? label : label.setSegmentFill(fillColor));
|
|
66
90
|
if (this.stackMode === StackMode.RELATIVE || this.stackMode === StackMode.ABSOLUTE_RELATIVE) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.
|
|
91
|
+
// with the 100 % mark the unit stands there once, and the shares are plain numbers
|
|
92
|
+
const labelValue = this.plainShares
|
|
93
|
+
? Formatter.number(this.segment.share * 100, "decimal", dataFormatDigits.percent, dataFormatDigits.percent, 1, this.styles.locale)
|
|
94
|
+
: Formatter.number(this.segment.share, "percent", dataFormatDigits.percent, dataFormatDigits.percent, 1, this.styles.locale);
|
|
95
|
+
onFill(new Label(this.group, xPos, labelY, "STACK_SEG", labelValue, this.styles, HookLocation.Center, HookLocation.Center))
|
|
70
96
|
.setPoint(this.dataPoint.key)
|
|
71
97
|
.forceStringTypeDraw();
|
|
72
98
|
}
|
|
73
99
|
else {
|
|
74
100
|
// Pass raw numeric value - Label.draw() formats with measureScale
|
|
75
|
-
new Label(this.group, xPos, labelY, "STACK_SEG", value, this.styles, HookLocation.Center, HookLocation.Center)
|
|
76
|
-
.setSegmentFill(fillColor)
|
|
101
|
+
onFill(new Label(this.group, xPos, labelY, "STACK_SEG", value, this.styles, HookLocation.Center, HookLocation.Center))
|
|
77
102
|
.setPoint(this.dataPoint.key)
|
|
78
103
|
.draw(true, dataFormatDigits, measureScale);
|
|
79
104
|
}
|
|
80
105
|
}
|
|
81
106
|
}
|
|
107
|
+
/** The hatching of a forecast over the shade of the series. One pattern per shade in the SVG. */
|
|
108
|
+
hatchPattern(background, color) {
|
|
109
|
+
const root = this.group.root();
|
|
110
|
+
if (!root)
|
|
111
|
+
return null;
|
|
112
|
+
const id = `pattern-stack-fc-${this.segmentIndex}`;
|
|
113
|
+
const existing = root.findOne(`#${id}`);
|
|
114
|
+
if (existing)
|
|
115
|
+
return existing;
|
|
116
|
+
return root
|
|
117
|
+
.pattern(10, 10, (add) => {
|
|
118
|
+
add.rect(10, 10).fill(background);
|
|
119
|
+
add.line(0, 5, 5, 0).stroke({ width: 1, color, linecap: "square" });
|
|
120
|
+
add.line(5, 10, 10, 5).stroke({ width: 1, color, linecap: "square" });
|
|
121
|
+
})
|
|
122
|
+
.id(id);
|
|
123
|
+
}
|
|
82
124
|
/**
|
|
83
125
|
* Draw the signed total of the stack: above the positive side, or below the negative side for a negative total.
|
|
84
126
|
*/
|
|
@@ -24,7 +24,7 @@ export function parseLayerItems(json) {
|
|
|
24
24
|
var _a;
|
|
25
25
|
return (_a = parseItems(json)) === null || _a === void 0 ? void 0 : _a.map((item) => {
|
|
26
26
|
var _a;
|
|
27
|
-
return (Object.assign(Object.assign({}, item), { label: text(item.label), color: text(item.color), target: (_a = text(item.target)) !== null && _a !== void 0 ? _a : "", to: text(item.to) }));
|
|
27
|
+
return (Object.assign(Object.assign({}, item), { label: text(item.label), color: text(item.color), target: (_a = text(item.target)) !== null && _a !== void 0 ? _a : "", to: text(item.to), text: text(item.text) }));
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
/** The `items` of a list. `undefined` when it is not a JSON array of objects. */
|
|
@@ -133,12 +133,14 @@ export var AggregationLevel;
|
|
|
133
133
|
* - SMART: abbreviated labels with parent period shown at boundary crossings (e.g. "Jan" normally, "Jan 2024" at year boundary)
|
|
134
134
|
* - LONG: full date format for every label
|
|
135
135
|
* - SHORT: abbreviated format for every label
|
|
136
|
+
* - TWO_ROW: abbreviated labels, and the parent period (the year of a month) in a second row where it starts
|
|
136
137
|
*/
|
|
137
138
|
export var AxisLabelsMode;
|
|
138
139
|
(function (AxisLabelsMode) {
|
|
139
140
|
AxisLabelsMode["SMART"] = "smart";
|
|
140
141
|
AxisLabelsMode["LONG"] = "long";
|
|
141
142
|
AxisLabelsMode["SHORT"] = "short";
|
|
143
|
+
AxisLabelsMode["TWO_ROW"] = "two-row";
|
|
142
144
|
})(AxisLabelsMode || (AxisLabelsMode = {}));
|
|
143
145
|
/**
|
|
144
146
|
* Visual representation type for chart series.
|
|
@@ -7,6 +7,14 @@ import { LAYOUT_STATE_VERSION, } from "./types";
|
|
|
7
7
|
const SCENARIO_GROUP_RE = /^Scenario([1-4])$/;
|
|
8
8
|
const STACK_SEGMENT_RE = /^stacked_(?:col|bar)_(\d+)_seg_\d+$/;
|
|
9
9
|
const STACK_SEGMENTS = 'g[id^="stacked_col_"], g[id^="stacked_bar_"]';
|
|
10
|
+
/** The value a bar group carries in `data-bn-value`. */
|
|
11
|
+
function readValue(group) {
|
|
12
|
+
const raw = group.getAttribute("data-bn-value");
|
|
13
|
+
if (raw == null || raw === "")
|
|
14
|
+
return undefined;
|
|
15
|
+
const value = Number(raw);
|
|
16
|
+
return Number.isFinite(value) ? value : undefined;
|
|
17
|
+
}
|
|
10
18
|
/** Nearest `#Scenario1..4` ancestor of an element, as "scenario1".."scenario4". */
|
|
11
19
|
function scenarioOf(el, root) {
|
|
12
20
|
var _a;
|
|
@@ -79,6 +87,7 @@ export function collectChartSegmentElements(svgRoot, segment, origins) {
|
|
|
79
87
|
index: (_a = indexOfGroup(group.id)) !== null && _a !== void 0 ? _a : walkIndex,
|
|
80
88
|
rect: measure(group, origins),
|
|
81
89
|
point: readLayoutPoint(group),
|
|
90
|
+
value: readValue(group),
|
|
82
91
|
};
|
|
83
92
|
elements.push(bar);
|
|
84
93
|
});
|
|
@@ -98,6 +107,7 @@ export function collectChartSegmentElements(svgRoot, segment, origins) {
|
|
|
98
107
|
index: Number(match[1]),
|
|
99
108
|
rect: measure(group, origins),
|
|
100
109
|
point,
|
|
110
|
+
value: readValue(group),
|
|
101
111
|
};
|
|
102
112
|
elements.push(bar);
|
|
103
113
|
});
|
|
@@ -191,7 +191,7 @@ export function isValidDateFormat(value) {
|
|
|
191
191
|
return (value === null || value === void 0 ? void 0 : value.toUpperCase()) in DateDistance;
|
|
192
192
|
}
|
|
193
193
|
export function isValidAxisLabelsMode(value) {
|
|
194
|
-
return (value === null || value === void 0 ? void 0 : value.toUpperCase()) in AxisLabelsMode;
|
|
194
|
+
return (value === null || value === void 0 ? void 0 : value.toUpperCase().replace("-", "_")) in AxisLabelsMode;
|
|
195
195
|
}
|
|
196
196
|
export function isValidDataFormat(value) {
|
|
197
197
|
if (isBlankInput(value)) {
|
|
@@ -358,6 +358,21 @@ export function validateStackConfig(value) {
|
|
|
358
358
|
errors.push(`stack: 'order' must be one of: ${validOrders.join(", ")}`);
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
+
if (config.hasOwnProperty("notation")) {
|
|
362
|
+
const validNotations = ["none", "scenario"];
|
|
363
|
+
if (!validNotations.includes(config.notation)) {
|
|
364
|
+
errors.push(`stack: 'notation' must be one of: ${validNotations.join(", ")}`);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (config.hasOwnProperty("legend")) {
|
|
368
|
+
const validLegends = ["left", "right", "both", "none"];
|
|
369
|
+
if (!validLegends.includes(config.legend)) {
|
|
370
|
+
errors.push(`stack: 'legend' must be one of: ${validLegends.join(", ")}`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
if (config.hasOwnProperty("percentMark") && typeof config.percentMark !== "boolean") {
|
|
374
|
+
errors.push("stack: 'percentMark' must be true or false");
|
|
375
|
+
}
|
|
361
376
|
return errors;
|
|
362
377
|
}
|
|
363
378
|
catch (_e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,t as e,H as n,h as i,d as o}from"./p-BnmylmXF.js";import{g as s}from"./p-6242qMx1.js";import{a as r,c as a,b as l}from"./p-C8rpOS5t.js";import{w as h,C as c}from"./p-BrQCbmG0.js";import{w as u}from"./p-JG4Sx1lE.js";import{w as d}from"./p-D32TsLzd.js";const b=t=>({x:t.x+t.width/2,y:t.y+t.height/2});function f(t,e){const n=b(t),i=e.x-n.x,o=e.y-n.y,s=Math.min(0===i?1/0:t.width/2/Math.abs(i),0===o?1/0:t.height/2/Math.abs(o));return Number.isFinite(s)?{x:n.x+i*s,y:n.y+o*s}:n}function m(t,e){return e?Object.assign(Object.assign({},t),{cx:Math.max(t.r,Math.min(t.cx,e.width-t.r)),cy:Math.max(t.r,Math.min(t.cy,e.height-t.r))}):t}const v=(t,e)=>t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height;function y(t,e,n,i){var o,s,r;const a=.25*n,l=t.y+t.height/2,h=null!==(o=i.obstacles)&&void 0!==o?o:[],c=t=>{const n={x:t-e,y:l-e,width:2*e,height:2*e},o=i.area;return(!o||n.x>=0&&n.x+n.width<=o.width)&&!h.some((t=>v(n,t)))},u=t.x+t.width,d=t.x-a-e,b=u+a+e;if(c(d))return{x:d,y:l,r:e};if(c(b))return{x:b,y:l,r:e};const f=2*(e+a),m=h.filter((t=>t.y<l&&t.y+t.height>l)),y=Math.max(0,t.x-f,...m.filter((e=>e.x+e.width<=t.x)).map((t=>t.x+t.width))),p=Math.min(null!==(r=null===(s=i.area)||void 0===s?void 0:s.width)&&void 0!==r?r:1/0,u+f,...m.filter((t=>t.x>=u)).map((t=>t.x))),g=t.x-y,w=p-u;return{x:w>=g?u+w/2:t.x-g/2,y:l,r:Math.min(e,Math.max(Math.max(g,w)/2,.3*n))}}function p(t,e,n,i,o={}){var s;const{label:r,color:a}=t,{whole:l,area:h,text:c}=o,u=!l&&!c&&null!=o.obstacles,d=((t,e)=>t?Math.min(e,t.height/1.3):e)(null!=c?c:u?e:void 0,i);if("arrow"===t.mark){if(!n)return;const t=b(e),o=b(n);if(t.x===o.x&&t.y===o.y)return;let s=f(e,o),l=f(n,t);(l.x-s.x)*(o.x-t.x)+(l.y-s.y)*(o.y-t.y)<=0&&(s=t,l=o);const c=Math.hypot(l.x-s.x,l.y-s.y),u=Math.min(.8*i,c),d=(l.x-s.x)/c,v=(l.y-s.y)/c,y=l.x-d*u,p=l.y-v*u,g=.35*i;return{kind:"arrow",color:a,x1:s.x,y1:s.y,x2:y,y2:p,head:[`${l.x},${l.y}`,`${y-v*g},${p+d*g}`,`${y+v*g},${p-d*g}`].join(" "),badge:null!=r?m({cx:s.x,cy:s.y,r:.65*i,label:r},h):void 0}}if("frame"===t.mark){const n=null!=c?c:e,o=null===(s=t.point)||void 0===s?void 0:s.part,u=!l&&(null!=c||"label"===o||"total"===o),b=(u?.45:.2)*d,f=(u?.1:.2)*d,v=u?Math.max(n.width,n.height):n.width,y=n.x+n.width/2,p=1,g=Math.max(h?p:-1/0,y-v/2-b),w=Math.max(h?p:-1/0,n.y-f),x=Math.min(h?h.width-p:1/0,y+v/2+b),M=Math.min(h?h.height-p:1/0,n.y+n.height+f),k=Math.min(x-g,M-w)/2,S=l?.25*i:k,$=l?.25*i:u?Math.min((x-g)/2,1.6*k):k,O=1-Math.SQRT1_2,j=.65*d,C=u?.6*j:0;return{kind:"frame",color:a,x:g,y:w,width:x-g,height:M-w,rx:$,ry:S,badge:null!=r?m({cx:x-$*O+C,cy:w+S*O-C,r:j,label:r},h):void 0}}if(c&&!l){const t=y(c,(null==r?.4:.65)*d,d,o);return{kind:"marker",color:a,badge:m({cx:t.x,cy:t.y,r:t.r,label:r},h)}}const p=(null==r?.4:.75)*d,g=u?Math.min(p,e.height/2):p,w=l?{x:e.x+e.width-g,y:e.y+g}:b(e);if(u){const t={x:w.x-g,y:w.y-g,width:2*g,height:2*g},e=o.obstacles.find((e=>v(t,e)));if(e){const t=y(e,g,d,o);return{kind:"marker",color:a,badge:m({cx:t.x,cy:t.y,r:t.r,label:r},h)}}}return{kind:"marker",color:a,badge:m({cx:w.x,cy:w.y,r:g,label:r},h)}}const g=["rowGroup","category","subCategory","date","scenario","row"];function w(t,e){const n=e.getBoundingClientRect();if(0===n.width||0===n.height)return!0;const i=t.x+t.width/2,o=t.y+t.height/2;return i>=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom}const x=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]);function M(t,e){const n=e.getBoundingClientRect();return 0===n.width||0===n.height||t.x<n.right&&t.x+t.width>n.left&&t.y<n.bottom&&t.y+t.height>n.top}const k=t(class extends n{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.marks=[],this.pageKey="",this.parsedItems=[],this.scheduled=!1,this.run=0,this.observed=new WeakSet,this.observedAround=new WeakSet,this.reported=new Set,this.schedule=()=>{this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.place().catch((t=>console.error("bn-annotation-layer: placing the marks failed",t))).finally(t)}))}))))},this.holdStatus=h(this),this.errors=d(this),this.componentStyle=u(this)}connectedCallback(){var t;this.stores=s(this.element),this.pageKey=r(this.element),this.observed=new WeakSet,this.observedAround=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver(this.schedule),this.observeSize(this.element);const e=this.element.closest("bn-layout-page");e&&this.mutationObserver.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot","data-bino-annotation-target"]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule)}disconnectedCallback(){var t,e,n,i;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(e=this.mutationObserver)||void 0===e||e.disconnect(),null===(n=document.fonts)||void 0===n||n.removeEventListener("loadingdone",this.schedule),this.run++,(null===(i=this.stores)||void 0===i?void 0:i.annotationsUnplaced.state[this.pageKey])&&this.stores.annotationsUnplaced.set(this.pageKey,void 0)}componentWillLoad(){this.parseItems()}componentDidLoad(){this.schedule()}onItemsChange(){this.parseItems(),this.schedule()}parseItems(){const t=a(this.items);t?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."}),this.parsedItems=null!=t?t:[]}async place(){var t;const e=++this.run;if(!this.element.isConnected||!this.svg)return;const n=this.element.closest("bn-layout-page"),i=new Map,o=new Map;null==n||n.querySelectorAll("[data-bino-annotation-target]").forEach((t=>{const e=Array.from(t.querySelectorAll("*")).find((t=>t.localName.startsWith("bn-")&&!x.has(t.localName))),n=null!=e?e:t;i.set(t.getAttribute("data-bino-annotation-target"),n),o.set(n,t)})),null==n||n.querySelectorAll("[slot]").forEach((t=>this.observeSize(t)));const s=new Set(this.parsedItems.flatMap((t=>[t.target,t.to]))),r=[...i].filter((([t])=>s.has(t))).map((([,t])=>t));if(await Promise.all(r.map((t=>{var e;return null===(e=t.componentOnReady)||void 0===e?void 0:e.call(t)}))),e!==this.run)return;r.forEach((t=>{this.observe(t),this.observeAround(t,n)}));const a=new Map;if(await Promise.all(r.map((async t=>{var e;a.set(t,await(null===(e=t.getLayoutState)||void 0===e?void 0:e.call(t,{detail:"full"}).catch((()=>{}))))}))),e!==this.run)return;const l=(t,e)=>{var n;const s=null!=t?i.get(t):void 0;if(!s)return{problem:`no target "${t}" on this page`};const r=s.getBoundingClientRect();if(function(t){return!t||g.every((e=>null==t[e]))&&null==t.part}(e)){const e={x:r.left,y:r.top,width:r.width,height:r.height};return function(t,e,n){if(0===t.width||0===t.height||!M(t,n))return!0;for(let n=e;n&&"bn-layout-page"!==n.localName;n=n.parentElement)if(!M(t,n))return!0;return!1}(e,o.get(s),this.element)?{problem:`"${t}" cannot be seen`}:{box:e,whole:!0}}const l=a.get(s),h=l?function(t,e){var n;const i=t.table&&null==e.scenario?t.table.rows:null!==(n=t.elements)&&void 0!==n?n:[],o=null!=t.table&&null==e.subCategory;return i.filter((t=>function(t,e){var n;return!(!t||t.part!==(null!==(n=e.part)&&void 0!==n?n:"element"))&&g.every((n=>null==e[n]||e[n]+""===t[n]))}(t.point,e)&&!(o&&null!=t.point.subCategory))).map((({rect:t,content:e,contentSign:n})=>({rect:t,content:e,contentSign:n})))}(l,e):[];if(1!==h.length)return{problem:`${h.length} elements match the point ${JSON.stringify(e)} in "${t}"`};const c=({component:{x:t,y:e,width:n,height:i}})=>({x:r.left+t,y:r.top+e,width:n,height:i}),u=c(h[0].rect);if(function(t,e){for(let n=e;n&&"bn-layout-page"!==n.localName;n=n.parentElement)if(!w(t,n))return!0;return!1}(u,o.get(s))||!w(u,this.element))return{problem:`the point ${JSON.stringify(e)} in "${t}" is cut off`};const d=h[0].content;if(!l.table)return{box:u,whole:!1};const b=(null!==(n=l.elements)&&void 0!==n?n:[]).flatMap((t=>"cell"===t.kind&&t.content?[{box:c(t.content),sign:t.contentSign}]:[]));return{box:u,whole:!1,text:d&&{box:c(d),sign:h[0].contentSign},obstacles:b}},h=this.toLocalSpace(),c=({box:t,sign:e=0})=>{const n=h(t);return Object.assign(Object.assign({},n),{x:n.x-e,width:n.width+e})},u=parseFloat(getComputedStyle(this.svg).fontSize)||13.3333,d={width:this.element.clientWidth,height:this.element.clientHeight},b=[],f=[];for(const e of this.parsedItems){const n=l(e.target,e.point),i="arrow"===e.mark?l(e.to,e.toPoint):void 0,o="problem"in n?n:i&&"problem"in i?i:void 0;if(o){f.push({item:e,problem:o.problem});continue}const s=n,r=i,a=p(e,h(s.box),r&&h(r.box),u,{whole:s.whole,area:d,text:s.text&&c(s.text),obstacles:null===(t=s.obstacles)||void 0===t?void 0:t.map(c)});a?b.push(a):f.push({item:e,problem:"an arrow needs two ends at different places"})}this.marks=b,this.storeUnplaced(f.flatMap((({item:t})=>null!=t.label?[t.label]:[]))),f.length>0&&this.reportWhenQuiet(e,f)}async reportWhenQuiet(t,e){let n=0;for(let e=0;e<50&&n<2;e++){if(await new Promise((t=>window.setTimeout(t,200))),t!==this.run)return;n=0===c.componentRegisterStatus().running?n+1:0}this.report(e)}report(t){var e,n;for(const{item:i,problem:o}of t){const t=`bn-annotation-layer: ${null!==(e=i.mark)&&void 0!==e?e:"marker"} ${null!==(n=i.label)&&void 0!==n?n:"without a number"} is not drawn: ${o}.`;this.reported.has(t)||(this.reported.add(t),console.warn(t))}}toLocalSpace(){var t;const e=null===(t=this.svg.getScreenCTM())||void 0===t?void 0:t.inverse();return t=>{if(!e)return t;const n=[[t.x,t.y],[t.x+t.width,t.y+t.height]].map((([t,n])=>new DOMPoint(t,n).matrixTransform(e)));return{x:Math.min(n[0].x,n[1].x),y:Math.min(n[0].y,n[1].y),width:Math.abs(n[1].x-n[0].x),height:Math.abs(n[1].y-n[0].y)}}}storeUnplaced(t){var e,n;const i=null===(e=this.stores)||void 0===e?void 0:e.annotationsUnplaced,o=null!==(n=null==i?void 0:i.state[this.pageKey])&&void 0!==n?n:[];i&&JSON.stringify(o)!==JSON.stringify(t)&&i.set(this.pageKey,t)}observe(t){this.observeSize(t);const e=t=>{var n;t&&(this.observed.has(t)||(this.observed.add(t),null===(n=this.mutationObserver)||void 0===n||n.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>e(t.shadowRoot))))};e(t.shadowRoot)}observeAround(t,e){var n,i;for(let o=t.parentElement;o&&o!==e;o=o.parentElement)this.observedAround.has(o)||(this.observedAround.add(o),null===(n=this.mutationObserver)||void 0===n||n.observe(o,{attributes:!0,attributeFilter:["style"]}),o.shadowRoot&&(null===(i=this.mutationObserver)||void 0===i||i.observe(o.shadowRoot,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]})))}observeSize(t){var e;this.observed.has(t)||(this.observed.add(t),null===(e=this.resizeObserver)||void 0===e||e.observe(t))}renderBadge(t,e){return t?i("g",null,i("circle",{cx:t.cx,cy:t.cy,r:t.r,style:{fill:e}}),null!=t.label?i("text",{class:"badge-text",x:t.cx,y:t.cy,style:{fontSize:1.1*t.r+"px"}},t.label):null):null}renderMark(t){var e,n;const o=l(t.color,this.componentStyle((t=>t["bn-annotation"])));return"marker"===t.kind?i("g",{class:"mark marker","data-label":t.badge.label},this.renderBadge(t.badge,o)):"frame"===t.kind?i("g",{class:"mark frame","data-label":null===(e=t.badge)||void 0===e?void 0:e.label},i("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:t.rx,ry:t.ry,style:{fill:"none",stroke:o,strokeWidth:"1.5"}}),this.renderBadge(t.badge,o)):i("g",{class:"mark arrow","data-label":null===(n=t.badge)||void 0===n?void 0:n.label},i("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,style:{stroke:o,strokeWidth:"1.5"}}),i("polygon",{points:t.head,style:{fill:o}}),this.renderBadge(t.badge,o))}render(){return i(o,{key:"d4d027728ae578a5ced829a3f86f0137530551fc"},i("svg",{key:"a3813930e420db9fdd618bc38c38941295cf4c22",ref:t=>this.svg=t},this.marks.map((t=>this.renderMark(t)))))}get element(){return this}static get watchers(){return{items:[{onItemsChange:0}]}}static get style(){return':host{position:absolute;inset:0;z-index:1;display:block;pointer-events:none;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px)}svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}.badge-text{fill:#ffffff;font-weight:bold;text-anchor:middle;dominant-baseline:central}'}},[1,"bn-annotation-layer",{items:[1],selectedStyle:[513,"selected-style"],marks:[32]},void 0,{items:[{onItemsChange:0}]}]),S=k,$=function(){"undefined"!=typeof customElements&&["bn-annotation-layer"].forEach((t=>{"bn-annotation-layer"===t&&(customElements.get(e(t))||customElements.define(e(t),k))}))};export{S as BnAnnotationLayer,$ as defineCustomElement}
|
|
1
|
+
import{p as t,t as e,H as n,h as i,d as o}from"./p-BnmylmXF.js";import{g as r}from"./p-6242qMx1.js";import{a as s,c as l,b as a}from"./p-CHJ6WE0l.js";import{w as h,C as c}from"./p-BrQCbmG0.js";import{w as u}from"./p-JG4Sx1lE.js";import{w as d}from"./p-D32TsLzd.js";const f=t=>({x:t.x+t.width/2,y:t.y+t.height/2});function b(t,e){const n=f(t),i=e.x-n.x,o=e.y-n.y,r=Math.min(0===i?1/0:t.width/2/Math.abs(i),0===o?1/0:t.height/2/Math.abs(o));return Number.isFinite(r)?{x:n.x+i*r,y:n.y+o*r}:n}function m(t,e){return e?Object.assign(Object.assign({},t),{cx:Math.max(t.r,Math.min(t.cx,e.width-t.r)),cy:Math.max(t.r,Math.min(t.cy,e.height-t.r))}):t}const v=(t,e)=>t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height;function y(t,e,n,i){var o,r,s;const l=.25*n,a=t.y+t.height/2,h=null!==(o=i.obstacles)&&void 0!==o?o:[],c=t=>{const n={x:t-e,y:a-e,width:2*e,height:2*e},o=i.area;return(!o||n.x>=0&&n.x+n.width<=o.width)&&!h.some((t=>v(n,t)))},u=t.x+t.width,d=t.x-l-e,f=u+l+e;if(c(d))return{x:d,y:a,r:e};if(c(f))return{x:f,y:a,r:e};const b=2*(e+l),m=h.filter((t=>t.y<a&&t.y+t.height>a)),y=Math.max(0,t.x-b,...m.filter((e=>e.x+e.width<=t.x)).map((t=>t.x+t.width))),x=Math.min(null!==(s=null===(r=i.area)||void 0===r?void 0:r.width)&&void 0!==s?s:1/0,u+b,...m.filter((t=>t.x>=u)).map((t=>t.x))),p=t.x-y,g=x-u;return{x:g>=p?u+g/2:t.x-p/2,y:a,r:Math.min(e,Math.max(Math.max(p,g)/2,.3*n))}}const x=(t,e)=>.6*t.length*e,p=(t,e)=>(t<0?"-":"+")+Math.abs(t).toFixed(e);function g(t,e,n,i,o,r,s){var l,a,h;if(null==i||null==o)return;const c=o-i,u=Number.isInteger(t.digits)&&t.digits>=0?t.digits:1,d="good-down"===t.sentiment?c<=0:c>=0,f=n.x+n.width/2>=e.x+e.width/2?1:-1,b=t=>1===f?t.x+t.width:t.x,m=b(n)+.9*f*r,v=m+.125*f*r,y=null!==(l=null==s?void 0:s.from)&&void 0!==l?l:e.y,g=null!==(a=null==s?void 0:s.to)&&void 0!==a?a:n.y,w=.25*r,M=t.percent&&0!==i?`(${p(c/Math.abs(i)*100,0)}%)`:void 0,k=p(c,u),S=m+.6*f*r,$=(y+g)/2,O=M?x(M,.85*r):0,j=1===f?S+.5*k.length*r+.35*r:S-O;return{kind:"difference",color:null!==(h=t.color)&&void 0!==h?h:d?"positive":"negative",lines:[{x1:b(e),y1:y,x2:v,y2:y},{x1:b(n),y1:g,x2:v,y2:g}],bar:{x:m-w/2,y:Math.min(y,g),width:w,height:Math.max(Math.abs(g-y),1)},text:{x:S,y:$,anchor:1===f?"start":"end",value:k,percent:M},frame:M&&t.highlight?{x:j-.25*r,y:$-.65*r,width:O+.5*r,height:1.3*r,r:.65*r}:void 0,badge:null!=t.label?{cx:m,cy:Math.min(y,g)-.9*r,r:.65*r,label:t.label}:void 0}}function w(t,e,n,i,o={}){var r,s,l,a;const{label:h,color:c}=t,{whole:u,area:d,text:p}=o,g=!u&&!p&&null!=o.obstacles,w=((t,e)=>t?Math.min(e,t.height/1.3):e)(null!=p?p:g?e:void 0,i);if("arrow"===t.mark){if(!n)return;const t=f(e),o=f(n);if(t.x===o.x&&t.y===o.y)return;let r=b(e,o),s=b(n,t);(s.x-r.x)*(o.x-t.x)+(s.y-r.y)*(o.y-t.y)<=0&&(r=t,s=o);const l=Math.hypot(s.x-r.x,s.y-r.y),a=Math.min(.8*i,l),u=(s.x-r.x)/l,v=(s.y-r.y)/l,y=s.x-u*a,x=s.y-v*a,p=.35*i;return{kind:"arrow",color:c,x1:r.x,y1:r.y,x2:y,y2:x,head:[`${s.x},${s.y}`,`${y-v*p},${x+u*p}`,`${y+v*p},${x-u*p}`].join(" "),badge:null!=h?m({cx:r.x,cy:r.y,r:.65*i,label:h},d):void 0}}if("frame"===t.mark){const n=null==t.text||u?void 0:{x:e.x+e.width/2,y:e.y+Math.min(e.height/2,Math.max(.9*i,.3*e.height))},o=n&&{x:n.x-x(t.text,i)/2,y:n.y-.6*i,width:x(t.text,i),height:1.2*i},l=null!==(r=null!=o?o:p)&&void 0!==r?r:e,a=null===(s=t.point)||void 0===s?void 0:s.part,f=!u&&(null!=o||null!=p||"label"===a||"total"===a),b=(f?.45:.2)*w,v=(f?.1:.2)*w,y=f?Math.max(l.width,l.height):l.width,g=l.x+l.width/2,M=1,k=Math.max(d?M:-1/0,g-y/2-b),S=Math.max(d?M:-1/0,l.y-v),$=Math.min(d?d.width-M:1/0,g+y/2+b),O=Math.min(d?d.height-M:1/0,l.y+l.height+v),j=Math.min($-k,O-S)/2,z=u?.25*i:j,C=u?.25*i:f?Math.min(($-k)/2,1.6*j):j,N=1-Math.SQRT1_2,W=.65*w,J=f?.6*W:0;return{kind:"frame",color:c,x:k,y:S,width:$-k,height:O-S,rx:C,ry:z,badge:null!=h?m({cx:$-C*N+J,cy:S+z*N-J,r:W,label:h},d):void 0,caption:n&&Object.assign(Object.assign({},n),{text:t.text})}}if(p&&!u){const t=y(p,(null==h?.4:.65)*w,w,o);return{kind:"marker",color:c,badge:m({cx:t.x,cy:t.y,r:t.r,label:h},d)}}const M=(null==h?.4:.75)*w,k=g?Math.min(M,e.height/2):M;let S=u?{x:e.x+e.width-k,y:e.y+k}:f(e);if(!u&&o.stacked&&"label"!==(null===(l=t.point)||void 0===l?void 0:l.part)&&"total"!==(null===(a=t.point)||void 0===a?void 0:a.part)&&(S={x:e.x+e.width,y:e.y+Math.min(.5*k,e.height/2)}),g){const t={x:S.x-k,y:S.y-k,width:2*k,height:2*k},e=o.obstacles.find((e=>v(t,e)));if(e){const t=y(e,k,w,o);return{kind:"marker",color:c,badge:m({cx:t.x,cy:t.y,r:t.r,label:h},d)}}}return{kind:"marker",color:c,badge:m({cx:S.x,cy:S.y,r:k,label:h},d)}}const M=["rowGroup","category","subCategory","date","scenario","row"];function k(t,e){var n;const i=t.table&&null==e.scenario?t.table.rows:null!==(n=t.elements)&&void 0!==n?n:[],o=null!=t.table&&null==e.subCategory;return i.filter((t=>function(t,e){var n;return!(!t||t.part!==(null!==(n=e.part)&&void 0!==n?n:"element"))&&M.every((n=>null==e[n]||e[n]+""===t[n]))}(t.point,e)&&!(o&&null!=t.point.subCategory))).map((({rect:t,content:e,contentSign:n,value:i,scenario:o})=>({rect:t,content:e,contentSign:n,value:i,stacked:"string"==typeof o&&o.startsWith("stack:")})))}function S(t,e){const n=e.getBoundingClientRect();if(0===n.width||0===n.height)return!0;const i=t.x+t.width/2,o=t.y+t.height/2;return i>=n.left&&i<=n.right&&o>=n.top&&o<=n.bottom}const $=new Set(["bn-asset","bn-component-style","bn-dataset","bn-datasource","bn-internationalization","bn-ruleset","bn-scaling-group"]);function O(t,e){const n=e.getBoundingClientRect();return 0===n.width||0===n.height||t.x<n.right&&t.x+t.width>n.left&&t.y<n.bottom&&t.y+t.height>n.top}const j=t(class extends n{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.marks=[],this.pageKey="",this.parsedItems=[],this.scheduled=!1,this.run=0,this.observed=new WeakSet,this.observedAround=new WeakSet,this.reported=new Set,this.schedule=()=>{this.scheduled||(this.scheduled=!0,this.holdStatus(new Promise((t=>{requestAnimationFrame((()=>{this.scheduled=!1,this.place().catch((t=>console.error("bn-annotation-layer: placing the marks failed",t))).finally(t)}))}))))},this.holdStatus=h(this),this.errors=d(this),this.componentStyle=u(this)}connectedCallback(){var t;this.stores=r(this.element),this.pageKey=s(this.element),this.observed=new WeakSet,this.observedAround=new WeakSet,this.resizeObserver=new ResizeObserver(this.schedule),this.mutationObserver=new MutationObserver(this.schedule),this.observeSize(this.element);const e=this.element.closest("bn-layout-page");e&&this.mutationObserver.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot","data-bino-annotation-target"]}),null===(t=document.fonts)||void 0===t||t.addEventListener("loadingdone",this.schedule)}disconnectedCallback(){var t,e,n,i;null===(t=this.resizeObserver)||void 0===t||t.disconnect(),null===(e=this.mutationObserver)||void 0===e||e.disconnect(),null===(n=document.fonts)||void 0===n||n.removeEventListener("loadingdone",this.schedule),this.run++,(null===(i=this.stores)||void 0===i?void 0:i.annotationsUnplaced.state[this.pageKey])&&this.stores.annotationsUnplaced.set(this.pageKey,void 0)}componentWillLoad(){this.parseItems()}componentDidLoad(){this.schedule()}onItemsChange(){this.parseItems(),this.schedule()}parseItems(){const t=l(this.items);t?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."}),this.parsedItems=null!=t?t:[]}async place(){var t,e;const n=++this.run;if(!this.element.isConnected||!this.svg)return;const i=this.element.closest("bn-layout-page"),o=new Map,r=new Map;null==i||i.querySelectorAll("[data-bino-annotation-target]").forEach((t=>{const e=Array.from(t.querySelectorAll("*")).find((t=>t.localName.startsWith("bn-")&&!$.has(t.localName))),n=null!=e?e:t;o.set(t.getAttribute("data-bino-annotation-target"),n),r.set(n,t)})),null==i||i.querySelectorAll("[slot]").forEach((t=>this.observeSize(t)));const s=new Set(this.parsedItems.flatMap((t=>[t.target,t.to]))),l=[...o].filter((([t])=>s.has(t))).map((([,t])=>t));if(await Promise.all(l.map((t=>{var e;return null===(e=t.componentOnReady)||void 0===e?void 0:e.call(t)}))),n!==this.run)return;l.forEach((t=>{this.observe(t),this.observeAround(t,i)}));const a=new Map;if(await Promise.all(l.map((async t=>{var e;a.set(t,await(null===(e=t.getLayoutState)||void 0===e?void 0:e.call(t,{detail:"full"}).catch((()=>{}))))}))),n!==this.run)return;const h=(t,e)=>{var n;const i=null!=t?o.get(t):void 0;if(!i)return{problem:`no target "${t}" on this page`};const s=i.getBoundingClientRect();if(function(t){return!t||M.every((e=>null==t[e]))&&null==t.part}(e)){const e={x:s.left,y:s.top,width:s.width,height:s.height};return function(t,e,n){if(0===t.width||0===t.height||!O(t,n))return!0;for(let n=e;n&&"bn-layout-page"!==n.localName;n=n.parentElement)if(!O(t,n))return!0;return!1}(e,r.get(i),this.element)?{problem:`"${t}" cannot be seen`}:{box:e,whole:!0}}const l=a.get(i),h=l?k(l,e):[];if(1!==h.length)return{problem:`${h.length} elements match the point ${JSON.stringify(e)} in "${t}"`};const c=({component:{x:t,y:e,width:n,height:i}})=>({x:s.left+t,y:s.top+e,width:n,height:i}),u=c(h[0].rect);if(function(t,e){for(let n=e;n&&"bn-layout-page"!==n.localName;n=n.parentElement)if(!S(t,n))return!0;return!1}(u,r.get(i))||!S(u,this.element))return{problem:`the point ${JSON.stringify(e)} in "${t}" is cut off`};const d=h[0].content;if(!l.table)return{box:u,whole:!1,stacked:h[0].stacked};const f=(null!==(n=l.elements)&&void 0!==n?n:[]).flatMap((t=>"cell"===t.kind&&t.content?[{box:c(t.content),sign:t.contentSign}]:[]));return{box:u,whole:!1,text:d&&{box:c(d),sign:h[0].contentSign},obstacles:f}},c=(t,e)=>{const n=null!=t?o.get(t):void 0;if(!n)return{problem:`no target "${t}" on this page`};const i=a.get(n),r=(i&&e?k(i,Object.assign(Object.assign({},e),{part:"element"})):[]).filter((t=>null!=t.value));if(0===r.length)return{problem:`no bar with a value matches the point ${JSON.stringify(e)} in "${t}"`};if(r.length>1&&!r.every((t=>t.stacked)))return{problem:`${r.length} elements match the point ${JSON.stringify(e)} in "${t}"`};const s=n.getBoundingClientRect(),l=Math.min(...r.map((t=>t.rect.component.x))),h=Math.min(...r.map((t=>t.rect.component.y))),c=Math.max(...r.map((t=>t.rect.component.x+t.rect.component.width))),u=Math.max(...r.map((t=>t.rect.component.y+t.rect.component.height)));return{box:{x:s.left+l,y:s.top+h,width:c-l,height:u-h},negatives:r.filter((t=>t.value<0)).map((t=>(t=>({x:s.left+t.x,y:s.top+t.y,width:t.width,height:t.height}))(t.rect.component))),value:r.reduce(((t,e)=>t+e.value),0)}},u=this.toLocalSpace(),d=({box:t,sign:e=0})=>{const n=u(t);return Object.assign(Object.assign({},n),{x:n.x-e,width:n.width+e})},f=parseFloat(getComputedStyle(this.svg).fontSize)||13.3333,b={width:this.element.clientWidth,height:this.element.clientHeight},m=[],v=[];for(const n of this.parsedItems){if("difference"===n.mark){const e=c(n.target,n.point),i=c(null!==(t=n.to)&&void 0!==t?t:n.target,n.toPoint),o="problem"in e?e:"problem"in i?i:void 0;if(o){v.push({item:n,problem:o.problem});continue}const[r,s]=[e,i],l=t=>u(t.box).y+t.negatives.reduce(((t,e)=>t+u(e).height),0),a=g(n,u(r.box),u(s.box),r.value,s.value,f,{from:l(r),to:l(s)});a&&m.push(a);continue}const i=h(n.target,n.point),o="arrow"===n.mark?h(n.to,n.toPoint):void 0,r="problem"in i?i:o&&"problem"in o?o:void 0;if(r){v.push({item:n,problem:r.problem});continue}const s=i,l=o,a=w(n,u(s.box),l&&u(l.box),f,{whole:s.whole,area:b,text:s.text&&d(s.text),obstacles:null===(e=s.obstacles)||void 0===e?void 0:e.map(d),stacked:s.stacked});a?m.push(a):v.push({item:n,problem:"an arrow needs two ends at different places"})}this.marks=m,this.storeUnplaced(v.flatMap((({item:t})=>null!=t.label?[t.label]:[]))),v.length>0&&this.reportWhenQuiet(n,v)}async reportWhenQuiet(t,e){let n=0;for(let e=0;e<50&&n<2;e++){if(await new Promise((t=>window.setTimeout(t,200))),t!==this.run)return;n=0===c.componentRegisterStatus().running?n+1:0}this.report(e)}report(t){var e,n;for(const{item:i,problem:o}of t){const t=`bn-annotation-layer: ${null!==(e=i.mark)&&void 0!==e?e:"marker"} ${null!==(n=i.label)&&void 0!==n?n:"without a number"} is not drawn: ${o}.`;this.reported.has(t)||(this.reported.add(t),console.warn(t))}}toLocalSpace(){var t;const e=null===(t=this.svg.getScreenCTM())||void 0===t?void 0:t.inverse();return t=>{if(!e)return t;const n=[[t.x,t.y],[t.x+t.width,t.y+t.height]].map((([t,n])=>new DOMPoint(t,n).matrixTransform(e)));return{x:Math.min(n[0].x,n[1].x),y:Math.min(n[0].y,n[1].y),width:Math.abs(n[1].x-n[0].x),height:Math.abs(n[1].y-n[0].y)}}}storeUnplaced(t){var e,n;const i=null===(e=this.stores)||void 0===e?void 0:e.annotationsUnplaced,o=null!==(n=null==i?void 0:i.state[this.pageKey])&&void 0!==n?n:[];i&&JSON.stringify(o)!==JSON.stringify(t)&&i.set(this.pageKey,t)}observe(t){this.observeSize(t);const e=t=>{var n;t&&(this.observed.has(t)||(this.observed.add(t),null===(n=this.mutationObserver)||void 0===n||n.observe(t,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["x","y","width","height","transform","style","class"]})),t.querySelectorAll("*").forEach((t=>e(t.shadowRoot))))};e(t.shadowRoot)}observeAround(t,e){var n,i;for(let o=t.parentElement;o&&o!==e;o=o.parentElement)this.observedAround.has(o)||(this.observedAround.add(o),null===(n=this.mutationObserver)||void 0===n||n.observe(o,{attributes:!0,attributeFilter:["style"]}),o.shadowRoot&&(null===(i=this.mutationObserver)||void 0===i||i.observe(o.shadowRoot,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"]})))}observeSize(t){var e;this.observed.has(t)||(this.observed.add(t),null===(e=this.resizeObserver)||void 0===e||e.observe(t))}renderBadge(t,e){return t?i("g",null,i("circle",{cx:t.cx,cy:t.cy,r:t.r,style:{fill:e}}),null!=t.label?i("text",{class:"badge-text",x:t.cx,y:t.cy,style:{fontSize:1.1*t.r+"px"}},t.label):null):null}renderMark(t){var e,n,o;const r=a(t.color,this.componentStyle((t=>t["bn-annotation"])));if("marker"===t.kind)return i("g",{class:"mark marker","data-label":t.badge.label},this.renderBadge(t.badge,r));if("frame"===t.kind)return i("g",{class:"mark frame","data-label":null===(e=t.badge)||void 0===e?void 0:e.label},i("rect",{x:t.x,y:t.y,width:t.width,height:t.height,rx:t.rx,ry:t.ry,style:{fill:t.caption?"#ffffff":"none",stroke:r,strokeWidth:"1.5"}}),t.caption?i("text",{class:"mark-text caption",x:t.caption.x,y:t.caption.y},t.caption.text):null,this.renderBadge(t.badge,r));if("difference"===t.kind){const e=a(void 0,this.componentStyle((t=>t["bn-annotation"])));return i("g",{class:"mark difference","data-label":null===(n=t.badge)||void 0===n?void 0:n.label},t.lines.map((t=>i("line",{class:"difference-line",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2}))),i("rect",{x:t.bar.x,y:t.bar.y,width:t.bar.width,height:t.bar.height,style:{fill:r}}),i("text",{class:"mark-text",x:t.text.x,y:t.text.y,style:{textAnchor:t.text.anchor}},t.text.value,t.text.percent?i("tspan",{class:"percent",dx:"0.35em"},t.text.percent):null),t.frame?i("rect",{x:t.frame.x,y:t.frame.y,width:t.frame.width,height:t.frame.height,rx:t.frame.r,ry:t.frame.r,style:{fill:"none",stroke:e,strokeWidth:"1.5"}}):null,this.renderBadge(t.badge,e))}return i("g",{class:"mark arrow","data-label":null===(o=t.badge)||void 0===o?void 0:o.label},i("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,style:{stroke:r,strokeWidth:"1.5"}}),i("polygon",{points:t.head,style:{fill:r}}),this.renderBadge(t.badge,r))}render(){return i(o,{key:"f2864246b86078e97a15f58cab7f46a792e6d300"},i("svg",{key:"52f932a7f8dff3e00773f8f827c82ec62848cb34",ref:t=>this.svg=t},this.marks.map((t=>this.renderMark(t)))))}get element(){return this}static get watchers(){return{items:[{onItemsChange:0}]}}static get style(){return':host{position:absolute;inset:0;z-index:1;display:block;pointer-events:none;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px)}svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}.badge-text{fill:#ffffff;font-weight:bold;text-anchor:middle;dominant-baseline:central}.mark-text{fill:#000000;dominant-baseline:central}.mark-text.caption{text-anchor:middle;font-size:0.9em}.mark-text .percent{font-size:0.85em}.difference-line{stroke:#000000;stroke-width:0.75}'}},[1,"bn-annotation-layer",{items:[1],selectedStyle:[513,"selected-style"],marks:[32]},void 0,{items:[{onItemsChange:0}]}]),z=j,C=function(){"undefined"!=typeof customElements&&["bn-annotation-layer"].forEach((t=>{"bn-annotation-layer"===t&&(customElements.get(e(t))||customElements.define(e(t),j))}))};export{z as BnAnnotationLayer,C as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as s,f as e,h as i,d as n,t as l}from"./p-BnmylmXF.js";import{g as o}from"./p-6242qMx1.js";import{a,p as r,b as d}from"./p-
|
|
1
|
+
import{p as t,H as s,f as e,h as i,d as n,t as l}from"./p-BnmylmXF.js";import{g as o}from"./p-6242qMx1.js";import{a,p as r,b as d}from"./p-CHJ6WE0l.js";import{s as m}from"./p-CyUmrWfW.js";import{w as c}from"./p-BrQCbmG0.js";import{w as f}from"./p-JG4Sx1lE.js";import{w as h}from"./p-D32TsLzd.js";const p=t(class extends s{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.pageKey="",c(this),this.errors=h(this),this.componentStyle=f(this)}connectedCallback(){this.stores=o(this.element),this.pageKey=a(this.element),this.unsubscribe=this.stores.annotationsUnplaced.on("set",(t=>{t===this.pageKey&&e(this.element)})),e(this.element)}disconnectedCallback(){var t;null===(t=this.unsubscribe)||void 0===t||t.call(this)}render(){var t,s;const e=r(this.items);e?this.errors.remove("ERR_items"):this.errors.addOrReplace({id:"ERR_items",type:"error",message:"items: not a JSON array of objects."});const l=d(void 0,this.componentStyle((t=>t["bn-annotation"]))),o=null!==(s=null===(t=this.stores)||void 0===t?void 0:t.annotationsUnplaced.state[this.pageKey])&&void 0!==s?s:[];return i(n,{key:"69a1cb7ec4623dd722328638b93fa2ac05775dcf"},i("ol",{key:"cc7925db54a9015cd774242487967e25d0eb1dc0"},(null!=e?e:[]).map((t=>i("li",null,null==t.label||o.includes(t.label)?null!=t.label?i("div",{class:"badge-space"}):null:i("div",{class:"badge",style:{background:l}},i("span",null,t.label)),i("div",{class:"text"},t.title?i("span",{class:"title"},t.title," "):null,t.html?i("span",{innerHTML:m(t.html)}):null))))))}get element(){return this}static get style(){return':host{display:block;font-family:var(--bn-font-family, "Noto Sans", sans-serif);font-size:var(--bn-font-size, 13.3333px);color:var(--bn-font-color, #000000)}ol{margin:0;padding:0;list-style:none}li{display:flex;gap:0.5em;margin-bottom:0.6em;align-items:flex-start}.badge-space{flex:none;width:1.5em;height:1.5em}.badge{flex:none;display:flex;align-items:center;justify-content:center;width:1.5em;height:1.5em;border-radius:50%;color:#ffffff;font-weight:bold;line-height:1}.badge span{font-size:0.825em}.title{font-weight:bold}'}},[1,"bn-annotation-list",{items:[1],selectedStyle:[513,"selected-style"]}]),b=p,u=function(){"undefined"!=typeof customElements&&["bn-annotation-list"].forEach((t=>{"bn-annotation-list"===t&&(customElements.get(l(t))||customElements.define(l(t),p))}))};export{b as BnAnnotationList,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-Dd1QOWDV.js";const p=o,r=s;export{p as BnChartBubbleRenderer,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,w as i,f as s,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as l,a as o}from"./p-6242qMx1.js";import{o as h}from"./p-DdvG1D18.js";import{c}from"./p-TNX3alPU.js";import{a as d}from"./p-JofGXz75.js";import{g as u}from"./p-Dsvjkuy3.js";import{c as p}from"./p-C50Ge-4H.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-Dw3rv_Y9.js";import{w as g}from"./p-BrQCbmG0.js";import{w as x}from"./p-JG4Sx1lE.js";import{w}from"./p-CZzlLTQc.js";import{w as _}from"./p-D32TsLzd.js";import{w as S}from"./p-DRmphEA0.js";import{w as j}from"./p-Bp5Xj4-s.js";import{w as L}from"./p-CUoPUIej.js";import{w as R}from"./p-D_K7tYhY.js";import{r as z,s as $}from"./p-Dyzb4ika.js";import{t as E,a as A,b as N,c as k,d as C,e as W,p as F}from"./p-DUZCLRVu.js";import{s as D}from"./p-DakXa7Dp.js";import{d as O}from"./p-Uc0zvXcQ.js";const G={rowGroup:0,category:1,subCategory:2},M=["ac","pp","fc","pl"],T=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=>E(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>E(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>A(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>N(t)))}validateCompareWith(t){const e="WARN_compareWith";f(t)||M.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`compare-with: invalid value '${t}' - expected ${M.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=>k(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>C(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>W(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(){D(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}=E(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}=A(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}=N(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 M.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}:C(e,t).config}prepareLegend(){const{data:t,parseError:e}=F(this.legend,null);return e||null===t?{show:!0,position:"right"}:W(t).config}prepareFacet(){const{data:t,parseError:e}=F(this.facet,null);return e||null===t?null:k(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=z(e);null!==t&&("scenario"===t.kind?i.add($(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=z(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=z(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=T,X=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),T);break;case"bn-chart-bubble-renderer":customElements.get(n(t))||O()}}))};export{U as BnChartBubble,X as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,w as i,f as s,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as l,a as o}from"./p-6242qMx1.js";import{o as h}from"./p-DdvG1D18.js";import{c as d}from"./p-BXP6aagM.js";import{a as c}from"./p-JofGXz75.js";import{g as u}from"./p-Dsvjkuy3.js";import{c as p}from"./p-C50Ge-4H.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-HVN8BNWN.js";import{w as g}from"./p-BrQCbmG0.js";import{w as x}from"./p-JG4Sx1lE.js";import{w}from"./p-CZzlLTQc.js";import{w as _}from"./p-D32TsLzd.js";import{w as S}from"./p-x0W2_FAX.js";import{w as j}from"./p-Bp5Xj4-s.js";import{w as L}from"./p-DBj1Yd3M.js";import{w as R}from"./p-CVfmhtEW.js";import{r as z,s as $}from"./p-YSRTB0jS.js";import{t as E,a as A,b as N,c as W,d as k,e as C,p as F}from"./p-D362XOg2.js";import{s as O}from"./p-DakXa7Dp.js";import{d as D}from"./p-Dd1QOWDV.js";const B={rowGroup:0,category:1,subCategory:2},M=["ac","pp","fc","pl"],G=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=>E(t)))}validateY(t){this.validateMeasureSpec("y",t,!0,(t=>E(t)))}validateSize(t){this.validateMeasureSpec("size",t,!0,(t=>A(t))),this.validateSizeScaling()}validateShare(t){this.validateMeasureSpec("share",t,!1,(t=>N(t)))}validateCompareWith(t){const e="WARN_compareWith";f(t)||M.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`compare-with: invalid value '${t}' - expected ${M.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=>W(t)))}validateLabels(t){this.validateObjectSpec("labels",t,(t=>k(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,(t=>C(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 d=null!==(a=o.measure)&&void 0!==a?a:"";y(d)?this.setBlockingError(n,null):this.setBlockingError(n,this.t(".xy-measure-invalid",{prop:t,measure:d})),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}=E(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}=A(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}=N(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 M.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}:k(e,t).config}prepareLegend(){const{data:t,parseError:e}=F(this.legend,null);return e||null===t?{show:!0,position:"right"}:C(t).config}prepareFacet(){const{data:t,parseError:e}=F(this.facet,null);return e||null===t?null:W(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=z(e);null!==t&&("scenario"===t.kind?i.add($(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&&B[n]>=B[r]&&(o=`series '${n}' vs point '${r}'`),null!==l){const t=null!=n?n:r;B[l]>=B[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 c(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 d(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=z(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=z(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}]}]),X=G,T=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),G);break;case"bn-chart-bubble-renderer":customElements.get(n(t))||D()}}))};export{X as BnChartBubble,T as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as o,d as s}from"./p-
|
|
1
|
+
import{B as o,d as s}from"./p-CO6bgquz.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,d as a,t as n}from"./p-BnmylmXF.js";import{h as l,a as o}from"./p-6242qMx1.js";import{o as u}from"./p-DdvG1D18.js";import{c as h}from"./p-TNX3alPU.js";import{a as d}from"./p-JofGXz75.js";import{C as c,A as p}from"./p-DFybNETX.js";import{o as v}from"./p-B6kka9sT.js";import{a as m,b as g,O as f}from"./p-j42D1yrQ.js";import{g as b}from"./p-Dsvjkuy3.js";import{p as y}from"./p-Xb6Ilq8u.js";import{b as _,i as w,c as j,h as A}from"./p-Dw3rv_Y9.js";import{w as O}from"./p-BrQCbmG0.js";import{w as R}from"./p-JG4Sx1lE.js";import{w as N}from"./p-CZzlLTQc.js";import{w as x}from"./p-D32TsLzd.js";import{r as E}from"./p-CmvpJzLd.js";import{w as S}from"./p-DRmphEA0.js";import{w as z}from"./p-CUoPUIej.js";import{w as D}from"./p-D_K7tYhY.js";import{r as T}from"./p-Dyzb4ika.js";import{p as k}from"./p-DUZCLRVu.js";import{s as L}from"./p-DakXa7Dp.js";import{d as U}from"./p-BFoRIqDi.js";const W=["measure","label","unit"];function F(t){const e=[],i=I(t,"measure",e);if(void 0===i||""===i.trim())return e.push("measure"),{config:null,unknownKeys:B(t,W),invalidFields:e};const s={measure:i.trim()};return s.label=I(t,"label",e),s.unit=I(t,"unit",e),{config:s,unknownKeys:B(t,W),invalidFields:e}}const $=["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:B(t,$),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 I(t,e,i){if(c.isExisting(t[e]))return c.isString(t[e])?t[e]:void i.push(e)}const V=["pl1","pp1","fc1"],G=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)||j(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";A(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",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),D(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=x(this),this.componentStyle=R(this),this.ruleSetConfig=S(this),this.t=z(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(){L(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(),u=T(o);"auto"===o.toLowerCase()||null!==u&&"scenario"===u.kind?this.setBlockingError(r,null):this.setBlockingError(r,this.t(".bullet-measure-invalid",{prop:t,measure:o})),this.reportSpecIssues(a,t,F(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?F(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?F(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=V.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 g([f.CATEGORYINDEX],n);const l=a.split(",").map((t=>f[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new g(l.length>0?l:[f.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}: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(),...E(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=u(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 h(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=G,q=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),G);break;case"bn-chart-bullet-renderer":customElements.get(n(t))||U()}}))};export{X as BnChartBullet,q as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,w as i,f as s,h as r,d as a,t as n}from"./p-BnmylmXF.js";import{h as l,a as o}from"./p-6242qMx1.js";import{o as u}from"./p-DdvG1D18.js";import{c as d}from"./p-BXP6aagM.js";import{a as h}from"./p-JofGXz75.js";import{C as c,A as p}from"./p-DguYWLBj.js";import{o as v}from"./p-B6kka9sT.js";import{a as m,b as g,O as f}from"./p-BBdzTx8V.js";import{g as b}from"./p-Dsvjkuy3.js";import{p as y}from"./p-Xb6Ilq8u.js";import{b as _,i as w,c as j,h as A}from"./p-HVN8BNWN.js";import{w as O}from"./p-BrQCbmG0.js";import{w as R}from"./p-JG4Sx1lE.js";import{w as N}from"./p-CZzlLTQc.js";import{w as x}from"./p-D32TsLzd.js";import{r as S}from"./p-CmvpJzLd.js";import{w as z}from"./p-x0W2_FAX.js";import{w as E}from"./p-DBj1Yd3M.js";import{w as T}from"./p-CVfmhtEW.js";import{r as W}from"./p-YSRTB0jS.js";import{p as k}from"./p-D362XOg2.js";import{s as D}from"./p-DakXa7Dp.js";import{d as L}from"./p-CO6bgquz.js";const M=["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,M),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,M),invalidFields:e}}const F=["show","decimals"];function B(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 U(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 I=["pl1","pp1","fc1"],X=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=U(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)||j(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";A(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",B(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=x(this),this.componentStyle=R(this),this.ruleSetConfig=z(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(){D(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(),u=W(o);"auto"===o.toLowerCase()||null!==u&&"scenario"===u.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=W(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=I.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=W(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 g([f.CATEGORYINDEX],n);const l=a.split(",").map((t=>f[t.trim().toUpperCase()])).filter((t=>void 0!==t));return new g(l.length>0?l:[f.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}:B(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(),...S(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 h(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=u(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 d(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=U(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=X,q=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),X);break;case"bn-chart-bullet-renderer":customElements.get(n(t))||L()}}))};export{G as BnChartBullet,q as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as
|
|
1
|
+
import{B as o,d as s}from"./p-CuUfiEu0.js";const p=o,r=s;export{p as BnChartScatterRenderer,r as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,w as s,f as i,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-6242qMx1.js";import{o as h}from"./p-DdvG1D18.js";import{c as d}from"./p-TNX3alPU.js";import{a as c}from"./p-JofGXz75.js";import{g as u}from"./p-Dsvjkuy3.js";import{c as p}from"./p-C50Ge-4H.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as y,j as g}from"./p-Dw3rv_Y9.js";import{w as b}from"./p-BrQCbmG0.js";import{w as x}from"./p-JG4Sx1lE.js";import{w}from"./p-CZzlLTQc.js";import{w as _}from"./p-D32TsLzd.js";import{w as L}from"./p-DRmphEA0.js";import{w as j}from"./p-CUoPUIej.js";import{w as S}from"./p-D_K7tYhY.js";import{r as R,s as $}from"./p-Dyzb4ika.js";import{f as A,c as N,d as E,e as k,p as D,t as C}from"./p-DUZCLRVu.js";import{s as z}from"./p-DakXa7Dp.js";import{d as F}from"./p-D3hr9wra.js";const O={rowGroup:0,category:1,subCategory:2},G=t(class extends e{validateFilter(t){const e="ERR_filter";o(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateAxisSpec("x",t)}validateY(t){this.validateAxisSpec("y",t)}validateIso(t){this.validateObjectSpec("iso",t,null,(t=>A(t)))}validateLevel(t){const e="WARN_level",s=["auto","category","subcategory"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",s=["auto","rowgroup","category","none"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,null,(t=>N(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>E(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(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";y(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:s,factor:i}=m(t);"factor"===s&&(void 0===i||i<=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.iso="",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),S(this),b(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),this.componentStyle=x(this),this.ruleSetConfig=L(this),this.t=j(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateIso(this.iso),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(){z(this.element,"bn-chart-scatter-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:i}=u(e);if(i<=0)return void this.checkOverflow();this._lastObservedWidth=i;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<=i+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(i-1)/r);Math.abs(o-n)<.01||(e.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,s((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-scatter-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,i(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,i(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"auto",values:!1,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}validateAxisSpec(t,e){var s;const i="ERR_xy_json_"+t,a="ERR_xy_measure_"+t,r="WARN_xy_fields_"+t,n="x"===t||"y"===t||"size"===t,{data:o,parseError:l}=D(e,"measure");if(l)return this.setBlockingError(i,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(a,null),void this.errors.remove(r);if(this.setBlockingError(i,null),null===o)return this.setBlockingError(a,n?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(r);const h="share"===t?null:C(o),d=null!==(s=o.measure)&&void 0!==s?s:"";g(d)?this.setBlockingError(a,null):this.setBlockingError(a,this.t(".xy-measure-invalid",{prop:t,measure:d})),this.reportSpecIssues(r,t,h)}validateObjectSpec(t,e,s,i){const a="ERR_xy_json_"+t,r="WARN_xy_fields_"+t,{data:n,parseError:o}=D(e,s);if(o)return this.setBlockingError(a,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(a,null),null!==n?this.reportSpecIssues(r,t,i(n)):this.errors.remove(r)}reportSpecIssues(t,e,s){const i=[];null!==s&&s.invalidFields.length>0&&i.push("invalid: "+s.invalidFields.join(", ")),null!==s&&s.unknownKeys.length>0&&i.push("unknown: "+s.unknownKeys.join(", ")),i.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${i.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:s,parseError:i}=D(e,"measure");if(i||null===s)return null;const{config:a}=C(s);return null!==a&&g(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}prepareIso(){const{data:t,parseError:e}=D(this.iso,null);return e||null===t?null:A(t).config}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:s}=D(this.labels,null);return s||null===e?{points:t.points,values:t.values,max:t.max}:E(e,t).config}prepareLegend(){const{data:t,parseError:e}=D(this.legend,null);return e||null===t?{show:!0,position:"right"}:k(t).config}prepareFacet(){const{data:t,parseError:e}=D(this.facet,null);return e||null===t?null:N(t).config}preparePointLevel(){var t,e;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===s)return"category";if("subcategory"===s)return"subCategory";const i=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===i||"category"===i||"subCategory"===i?i:"category"}prepareSeriesLevel(t){var e;const s=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const s=new Set;for(const e of t){if(void 0===e)continue;const t=R(e);null!==t&&"scenario"===t.kind&&s.add($(t.slot))}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const i=this.preparePointLevel(),a=this.prepareSeriesLevel(i),r=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let n=null;if(null!==a&&O[a]>=O[i]&&(n=`series '${a}' vs point '${i}'`),null!==r){const t=null!=a?a:i;O[r]>=O[t]&&(n=`facet '${r}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==n?this.t(".xy-level-order",{detail:n}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const s=Number(e[1]),i=Number(e[2]);return s<=0||i<=0?null:s/i}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}i18nLocalKeys(){return["no-data","axis.in","legend.title"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(l.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor(),e=this.element.localName;return this.componentStyle((s=>{const i=s.global.fontSizePx*t;return{scaleFactors:s[e].scaleFactors,fontStyles:{font:`${i}px ${s.global.fontFamily}`,size:i,color:s.global.fontColor,background:s.global.fontBackgroundColor,leading:1.8},axisStyles:s[e].axisStyles,seriesColors:s[e].seriesColors,padding:s[e].padding}}))}async getBaseline(){return c(this.element,"bn-chart-scatter-renderer")}async getLayoutState(t){var e;const s=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",i=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 d(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},i,s)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var s,i,a,r;const n=(null===(s=e.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(i=e.global)||void 0===i?void 0:i.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 s of[1,2,3,4])t[`${e}${s}`]={type:"number",isOptional:!0,description:""};for(const[e,s]of Object.entries(this.mappedAxes())){if(null===s)continue;const i=R(s.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${e}: ${"label"in s&&void 0!==s.label?s.label:s.measure}`:(t[i.measure.base].description=`${e}: ${s.measure} (base)`,t[i.measure.delta].description=`${e}: ${s.measure} (delta)`))}return{[this.dataStructureName()]: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)}}mappedAxes(){return{x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y)}}dataStructureName(){return"IScatterChartDataRow"}chartTemplate(){const t=this.prepareAxis("x",this.x),e=this.prepareAxis("y",this.y),s=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure],s),this.hasBlockingErrors()||null===t||null===e)return null;const i=this.preparePointLevel(),r=this.prepareI18n(),n=this.prepareStyle(),o=u(this.element).width;return a("bn-chart-scatter-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,iso:this.prepareIso(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:s,pointLevel:i,seriesLevel:this.prepareSeriesLevel(i),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,styles:n,i18n:r,containerWidth:o,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"4947af836a9c76b089bc07fb1f4df8c248aa4f62",style:this.getFontStyles()},a("div",{key:"16abbc30d255d224aefecf9e337d3b23d449828a",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],iso:[{validateIso: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-scatter",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],iso:[1],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}],iso:[{validateIso: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}]}]),I=G,W=function(){"undefined"!=typeof customElements&&["bn-chart-scatter","bn-chart-scatter-renderer"].forEach((t=>{switch(t){case"bn-chart-scatter":customElements.get(n(t))||customElements.define(n(t),G);break;case"bn-chart-scatter-renderer":customElements.get(n(t))||F()}}))};export{I as BnChartScatter,W as defineCustomElement}
|
|
1
|
+
import{p as t,H as e,w as s,f as i,h as a,d as r,t as n}from"./p-BnmylmXF.js";import{h as o,a as l}from"./p-6242qMx1.js";import{o as h}from"./p-DdvG1D18.js";import{c as d}from"./p-BXP6aagM.js";import{a as c}from"./p-JofGXz75.js";import{g as u}from"./p-Dsvjkuy3.js";import{c as p}from"./p-C50Ge-4H.js";import{o as v}from"./p-B6kka9sT.js";import{p as m}from"./p-Xb6Ilq8u.js";import{i as f,h as y,j as g}from"./p-HVN8BNWN.js";import{w as b}from"./p-BrQCbmG0.js";import{w as x}from"./p-JG4Sx1lE.js";import{w}from"./p-CZzlLTQc.js";import{w as _}from"./p-D32TsLzd.js";import{w as j}from"./p-x0W2_FAX.js";import{w as L}from"./p-DBj1Yd3M.js";import{w as S}from"./p-CVfmhtEW.js";import{r as N,s as $}from"./p-YSRTB0jS.js";import{f as A,c as R,d as E,e as k,p as C,t as F}from"./p-D362XOg2.js";import{s as O}from"./p-DakXa7Dp.js";import{d as z}from"./p-CuUfiEu0.js";const W={rowGroup:0,category:1,subCategory:2},D=t(class extends e{validateFilter(t){const e="ERR_filter";o(t)?this.errors.addOrReplace({id:e,type:"error",message:"filter: double backticks are not allowed."}):this.errors.remove(e)}validateX(t){this.validateAxisSpec("x",t)}validateY(t){this.validateAxisSpec("y",t)}validateIso(t){this.validateObjectSpec("iso",t,null,(t=>A(t)))}validateLevel(t){const e="WARN_level",s=["auto","category","subcategory"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateSeriesLevel(t){const e="WARN_seriesLevel",s=["auto","rowgroup","category","none"];f(t)||s.includes(t.trim().toLowerCase())?this.errors.remove(e):this.errors.addOrReplace({id:e,type:"warning",message:`series-level: invalid value '${t}' - expected ${s.join("/")}; using 'auto'.`})}validateFacet(t){this.validateObjectSpec("facet",t,null,(t=>R(t)))}validateLabels(t){this.validateObjectSpec("labels",t,null,(t=>E(t,this.labelDefaults())))}validateLegend(t){this.validateObjectSpec("legend",t,null,(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";y(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:s,factor:i}=m(t);"factor"===s&&(void 0===i||i<=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.iso="",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),S(this),b(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),this.componentStyle=x(this),this.ruleSetConfig=j(this),this.t=L(this).t}componentWillLoad(){this.validateFilter(this.filter),this.validateX(this.x),this.validateY(this.y),this.validateIso(this.iso),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-scatter-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:i}=u(e);if(i<=0)return void this.checkOverflow();this._lastObservedWidth=i;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<=i+1)return this.errors.remove("AUTO_scale"),void this.checkOverflow();const o=Math.max(.3,n*(i-1)/r);Math.abs(o-n)<.01||(e.style.setProperty("--bn-font-size",a*o+"px"),"empty"===t?this.errors.addOrReplace({id:"AUTO_scale",type:"warning",message:"Auto-scaled chart by factor "+o.toFixed(3)}):this.errors.remove("AUTO_scale"),this._autoScaleGuard=!0,s((()=>{this.appliedScaleFactor=o}))),this.checkOverflow()}checkOverflow(){p(this.element,"bn-chart-scatter-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,i(this)):this.checkOverflow()})),requestAnimationFrame((()=>{requestAnimationFrame((()=>{if(this._autoScaleGuard)return;const{width:t}=u(this.element);this._lastObservedWidth=t,i(this)}))}))}disconnectedCallback(){var t;null===(t=this.layoutObserver)||void 0===t||t.disconnect(),this.layoutObserver=null}labelDefaults(){return{points:"auto",values:!1,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}validateAxisSpec(t,e){var s;const i="ERR_xy_json_"+t,a="ERR_xy_measure_"+t,r="WARN_xy_fields_"+t,n="x"===t||"y"===t||"size"===t,{data:o,parseError:l}=C(e,"measure");if(l)return this.setBlockingError(i,this.t(".xy-prop-json",{prop:t})),this.setBlockingError(a,null),void this.errors.remove(r);if(this.setBlockingError(i,null),null===o)return this.setBlockingError(a,n?this.t(".xy-measure-invalid",{prop:t,measure:""}):null),void this.errors.remove(r);const h="share"===t?null:F(o),d=null!==(s=o.measure)&&void 0!==s?s:"";g(d)?this.setBlockingError(a,null):this.setBlockingError(a,this.t(".xy-measure-invalid",{prop:t,measure:d})),this.reportSpecIssues(r,t,h)}validateObjectSpec(t,e,s,i){const a="ERR_xy_json_"+t,r="WARN_xy_fields_"+t,{data:n,parseError:o}=C(e,s);if(o)return this.setBlockingError(a,this.t(".xy-prop-json",{prop:t})),void this.errors.remove(r);this.setBlockingError(a,null),null!==n?this.reportSpecIssues(r,t,i(n)):this.errors.remove(r)}reportSpecIssues(t,e,s){const i=[];null!==s&&s.invalidFields.length>0&&i.push("invalid: "+s.invalidFields.join(", ")),null!==s&&s.unknownKeys.length>0&&i.push("unknown: "+s.unknownKeys.join(", ")),i.length>0?this.errors.addOrReplace({id:t,type:"warning",message:`${e}: ignored sub-fields (${i.join("; ")}).`}):this.errors.remove(t)}prepareAxis(t,e){const{data:s,parseError:i}=C(e,"measure");if(i||null===s)return null;const{config:a}=F(s);return null!==a&&g(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}prepareIso(){const{data:t,parseError:e}=C(this.iso,null);return e||null===t?null:A(t).config}prepareLabels(){const t=this.labelDefaults(),{data:e,parseError:s}=C(this.labels,null);return s||null===e?{points:t.points,values:t.values,max:t.max}:E(e,t).config}prepareLegend(){const{data:t,parseError:e}=C(this.legend,null);return e||null===t?{show:!0,position:"right"}:k(t).config}prepareFacet(){const{data:t,parseError:e}=C(this.facet,null);return e||null===t?null:R(t).config}preparePointLevel(){var t,e;const s=null===(t=this.level)||void 0===t?void 0:t.trim().toLowerCase();if("category"===s)return"category";if("subcategory"===s)return"subCategory";const i=null===(e=this.datasetMeta)||void 0===e?void 0:e.suggestedLevel;return"rowGroup"===i||"category"===i||"subCategory"===i?i:"category"}prepareSeriesLevel(t){var e;const s=null===(e=this.seriesLevel)||void 0===e?void 0:e.trim().toLowerCase();return"none"===s?null:"rowgroup"===s?"rowGroup":"category"===s||"subCategory"===t?"category":"category"===t?"rowGroup":null}validateCrossProp(t,e){const s=new Set;for(const e of t){if(void 0===e)continue;const t=N(e);null!==t&&"scenario"===t.kind&&s.add($(t.slot))}this.setBlockingError("ERR_xy_family",s.size>1?this.t(".xy-family-mixed",{families:[...s].join(", ")}):null);const i=this.preparePointLevel(),a=this.prepareSeriesLevel(i),r=null!==e?"rowgroup"===e.level?"rowGroup":"category":null;let n=null;if(null!==a&&W[a]>=W[i]&&(n=`series '${a}' vs point '${i}'`),null!==r){const t=null!=a?a:i;W[r]>=W[t]&&(n=`facet '${r}' vs '${t}'`)}this.setBlockingError("ERR_xy_level_order",null!==n?this.t(".xy-level-order",{detail:n}):null)}parseAspect(t){const e=/^\s*(\d+(?:\.\d+)?)\s*:\s*(\d+(?:\.\d+)?)\s*$/.exec(null!=t?t:"");if(null===e)return null;const s=Number(e[1]),i=Number(e[2]);return s<=0||i<=0?null:s/i}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}i18nLocalKeys(){return["no-data","axis.in","legend.title"]}prepareI18n(){const t=new Map(this.i18nLocalKeys().map((t=>[t,this.t(".".concat(t))]))),e=new Map(l.map((t=>[t,this.t("global.".concat(t))])));return new Map([...e.entries(),...t.entries()])}prepareStyle(){const t=this.getEffectiveScaleFactor(),e=this.element.localName;return this.componentStyle((s=>{const i=s.global.fontSizePx*t;return{scaleFactors:s[e].scaleFactors,fontStyles:{font:`${i}px ${s.global.fontFamily}`,size:i,color:s.global.fontColor,background:s.global.fontBackgroundColor,leading:1.8},axisStyles:s[e].axisStyles,seriesColors:s[e].seriesColors,padding:s[e].padding}}))}async getBaseline(){return c(this.element,"bn-chart-scatter-renderer")}async getLayoutState(t){var e;const s=null!==(e=null==t?void 0:t.detail)&&void 0!==e?e:"summary",i=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 d(this.element,"bn-chart-scatter-renderer",this.chartTitle||void 0,{fontSizePx:n,appliedScaleFactor:r},i,s)}getEffectiveScaleFactor(){const{mode:t,factor:e}=m(this.scale);return"factor"===t?e:"auto"===t||"empty"===t?this.appliedScaleFactor:1}getFontStyles(){const t=this.getEffectiveScaleFactor();return this.componentStyle((e=>{var s,i,a,r;const n=(null===(s=e.global)||void 0===s?void 0:s.fontSizePx)||13.3333;return{"--bn-font-family":(null===(i=e.global)||void 0===i?void 0:i.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 s of[1,2,3,4])t[`${e}${s}`]={type:"number",isOptional:!0,description:""};for(const[e,s]of Object.entries(this.mappedAxes())){if(null===s)continue;const i=N(s.measure);null!==i&&("scenario"===i.kind?t[i.slot].description=`${e}: ${"label"in s&&void 0!==s.label?s.label:s.measure}`:(t[i.measure.base].description=`${e}: ${s.measure} (base)`,t[i.measure.delta].description=`${e}: ${s.measure} (delta)`))}return{[this.dataStructureName()]: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)}}mappedAxes(){return{x:this.prepareAxis("x",this.x),y:this.prepareAxis("y",this.y)}}dataStructureName(){return"IScatterChartDataRow"}chartTemplate(){const t=this.prepareAxis("x",this.x),e=this.prepareAxis("y",this.y),s=this.prepareFacet();if(this.validateCrossProp([null==t?void 0:t.measure,null==e?void 0:e.measure],s),this.hasBlockingErrors()||null===t||null===e)return null;const i=this.preparePointLevel(),r=this.prepareI18n(),n=this.prepareStyle(),o=u(this.element).width;return a("bn-chart-scatter-renderer",{tableName:this.datasetName,dataVersion:this.dataVersion,chartTitle:this.chartTitle,x:t,y:e,iso:this.prepareIso(),labels:this.prepareLabels(),legend:this.prepareLegend(),facet:s,pointLevel:i,seriesLevel:this.prepareSeriesLevel(i),aspect:this.prepareAspect(),limit:this.prepareLimit(),filter:this.filter,styles:n,i18n:r,containerWidth:o,ruleSetConfig:this.ruleSetConfig(),errors:this.errors,translator:this.translateForInner})}render(){return a(r,{key:"4947af836a9c76b089bc07fb1f4df8c248aa4f62",style:this.getFontStyles()},a("div",{key:"16abbc30d255d224aefecf9e337d3b23d449828a",class:"container"},this.chartTemplate()))}get element(){return this}static get watchers(){return{filter:[{validateFilter:0}],x:[{validateX:0}],y:[{validateY:0}],iso:[{validateIso: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-scatter",{datasets:[513],selectedStyle:[513,"selected-style"],i18nNamespace:[513,"i18n-namespace"],ruleset:[513],chartTitle:[1,"chart-title"],filter:[1],x:[1],y:[1],iso:[1],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}],iso:[{validateIso: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}]}]),G=D,B=function(){"undefined"!=typeof customElements&&["bn-chart-scatter","bn-chart-scatter-renderer"].forEach((t=>{switch(t){case"bn-chart-scatter":customElements.get(n(t))||customElements.define(n(t),D);break;case"bn-chart-scatter-renderer":customElements.get(n(t))||z()}}))};export{G as BnChartScatter,B as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as o,d as s}from"./p-
|
|
1
|
+
import{B as o,d as s}from"./p-CHhxQoF9.js";const p=o,r=s;export{p as BnChartStructureRenderer,r as defineCustomElement}
|