@iyulab/u-widgets 0.7.1 → 0.8.1
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/{tokens-x1kDxgG8.js → tokens-D5aWvczs.js} +16 -5
- package/dist/tokens-D5aWvczs.js.map +1 -0
- package/dist/u-widgets-charts.js +303 -227
- package/dist/u-widgets-charts.js.map +1 -1
- package/dist/u-widgets-tools.js +110 -85
- package/dist/u-widgets-tools.js.map +1 -1
- package/dist/u-widgets.d.ts +1 -1
- package/dist/u-widgets.js +46 -20
- package/dist/u-widgets.js.map +1 -1
- package/package.json +1 -1
- package/schema/u-widget.schema.json +1 -1
- package/dist/tokens-x1kDxgG8.js.map +0 -1
package/dist/u-widgets-charts.js
CHANGED
|
@@ -1,204 +1,239 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as
|
|
3
|
-
import { a as
|
|
4
|
-
import * as
|
|
5
|
-
import { BarChart as
|
|
6
|
-
import { GridComponent as
|
|
7
|
-
import { CanvasRenderer as
|
|
8
|
-
function
|
|
9
|
-
const
|
|
1
|
+
import { css as P, LitElement as E, nothing as R, html as T } from "lit";
|
|
2
|
+
import { property as D, customElement as $ } from "lit/decorators.js";
|
|
3
|
+
import { a as B, t as W } from "./tokens-D5aWvczs.js";
|
|
4
|
+
import * as O from "echarts/core";
|
|
5
|
+
import { BarChart as q, LineChart as G, PieChart as H, ScatterChart as K, RadarChart as U, HeatmapChart as Y, BoxplotChart as J, FunnelChart as Q, TreemapChart as X } from "echarts/charts";
|
|
6
|
+
import { GridComponent as Z, TooltipComponent as ee, LegendComponent as te, RadarComponent as re, MarkLineComponent as ie, VisualMapComponent as se } from "echarts/components";
|
|
7
|
+
import { CanvasRenderer as ne } from "echarts/renderers";
|
|
8
|
+
function L(e, r) {
|
|
9
|
+
for (const i of r) {
|
|
10
|
+
const t = e[i.field];
|
|
11
|
+
if (t == null) continue;
|
|
12
|
+
const n = Number(t);
|
|
13
|
+
if (Number.isNaN(n)) continue;
|
|
14
|
+
const s = i.above === void 0 || n > i.above, d = i.below === void 0 || n < i.below;
|
|
15
|
+
if (s && d) return i;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function ae(e) {
|
|
19
|
+
const r = e.widget, i = e.data, t = e.mapping ? B(e.mapping) : void 0, n = e.options ?? {};
|
|
10
20
|
if (!i) return {};
|
|
11
21
|
let s;
|
|
12
|
-
switch (
|
|
22
|
+
switch (r) {
|
|
13
23
|
case "chart.bar":
|
|
14
|
-
s =
|
|
24
|
+
s = z(i, t, "bar", n);
|
|
15
25
|
break;
|
|
16
26
|
case "chart.line":
|
|
17
|
-
s =
|
|
27
|
+
s = z(i, t, "line", n);
|
|
18
28
|
break;
|
|
19
29
|
case "chart.area":
|
|
20
|
-
s =
|
|
30
|
+
s = z(i, t, "line", { ...n, _area: !0 });
|
|
21
31
|
break;
|
|
22
32
|
case "chart.pie":
|
|
23
|
-
s =
|
|
33
|
+
s = le(i, t, n);
|
|
24
34
|
break;
|
|
25
35
|
case "chart.scatter":
|
|
26
|
-
s =
|
|
36
|
+
s = oe(i, t, n);
|
|
27
37
|
break;
|
|
28
38
|
case "chart.radar":
|
|
29
|
-
s =
|
|
39
|
+
s = ce(i, t);
|
|
30
40
|
break;
|
|
31
41
|
case "chart.heatmap":
|
|
32
|
-
s =
|
|
42
|
+
s = ue(i, t, n);
|
|
33
43
|
break;
|
|
34
44
|
case "chart.box":
|
|
35
|
-
s =
|
|
45
|
+
s = fe(i, t);
|
|
36
46
|
break;
|
|
37
47
|
case "chart.funnel":
|
|
38
|
-
s =
|
|
48
|
+
s = ye(i, t);
|
|
39
49
|
break;
|
|
40
50
|
case "chart.waterfall":
|
|
41
|
-
s =
|
|
51
|
+
s = he(i, t);
|
|
42
52
|
break;
|
|
43
53
|
case "chart.treemap":
|
|
44
|
-
s =
|
|
54
|
+
s = de(i);
|
|
55
|
+
break;
|
|
56
|
+
case "chart.histogram":
|
|
57
|
+
s = me(i, t, n);
|
|
45
58
|
break;
|
|
46
59
|
default:
|
|
47
60
|
return {};
|
|
48
61
|
}
|
|
49
62
|
n.legend === !1 && s.legend && (s.legend = { ...s.legend, show: !1 }), n.grid === !1 && (s.xAxis && typeof s.xAxis == "object" && !Array.isArray(s.xAxis) && (s.xAxis = { ...s.xAxis, splitLine: { show: !1 } }), s.yAxis && typeof s.yAxis == "object" && !Array.isArray(s.yAxis) && (s.yAxis = { ...s.yAxis, splitLine: { show: !1 } })), n.animate === !1 && (s.animation = !1), Array.isArray(n.colors) && n.colors.length > 0 && (s.color = n.colors);
|
|
50
|
-
const
|
|
51
|
-
return
|
|
63
|
+
const d = n.echarts;
|
|
64
|
+
return d && typeof d == "object" && (s = I(s, d)), s;
|
|
52
65
|
}
|
|
53
|
-
function
|
|
66
|
+
function z(e, r, i, t) {
|
|
54
67
|
if (!Array.isArray(e)) return {};
|
|
55
|
-
const n =
|
|
68
|
+
const n = r?.x ?? C(e), s = r?.y ?? [_(e)].filter(Boolean);
|
|
56
69
|
if (!n || s.length === 0) return {};
|
|
57
|
-
const
|
|
58
|
-
const
|
|
70
|
+
const d = e.map((a) => String(a[n] ?? "")), m = !!t.horizontal, h = Array.isArray(t.series) ? t.series : [], y = t.conditionalStyles, u = s.map((a, l) => {
|
|
71
|
+
const c = {
|
|
59
72
|
name: a,
|
|
60
73
|
type: i,
|
|
61
|
-
data: e.map((p) =>
|
|
74
|
+
data: e.map((p) => {
|
|
75
|
+
const w = p[a] ?? null;
|
|
76
|
+
if (y?.length) {
|
|
77
|
+
const S = L(p, y);
|
|
78
|
+
if (S) {
|
|
79
|
+
const F = { value: w, itemStyle: { color: S.color } };
|
|
80
|
+
return S.symbol && (F.symbol = S.symbol), S.symbolSize && (F.symbolSize = S.symbolSize), F;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return w;
|
|
84
|
+
})
|
|
62
85
|
};
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
return
|
|
66
|
-
}),
|
|
67
|
-
|
|
86
|
+
t._area && (c.areaStyle = {}), t.smooth && (c.smooth = !0), t.step && (c.step = t.step === !0 ? "end" : t.step);
|
|
87
|
+
const o = h[l];
|
|
88
|
+
return o && (o.color && (c.itemStyle = { color: o.color }, c.lineStyle = { ...c.lineStyle ?? {}, color: o.color }), o.lineStyle && (c.lineStyle = { ...c.lineStyle ?? {}, ...o.lineStyle }), o.symbol !== void 0 && (c.symbol = o.symbol), o.label && (c.name = o.label), o.type && (c.type = o.type), o.yAxisIndex !== void 0 && (c.yAxisIndex = o.yAxisIndex)), c;
|
|
89
|
+
}), x = { type: "category", data: d }, g = { type: "value" };
|
|
90
|
+
t.histogram && (x.axisTick = { alignWithLabel: !0 }, u.forEach((a) => {
|
|
68
91
|
a.barCategoryGap = "0%";
|
|
69
92
|
}));
|
|
70
|
-
const
|
|
71
|
-
let
|
|
72
|
-
if (
|
|
73
|
-
const a = Array.isArray(
|
|
74
|
-
|
|
93
|
+
const A = !m && u.some((a) => a.yAxisIndex >= 1);
|
|
94
|
+
let f;
|
|
95
|
+
if (A) {
|
|
96
|
+
const a = Array.isArray(t.yAxis) && t.yAxis.length >= 2 ? t.yAxis[1] : { type: "value" };
|
|
97
|
+
f = [g, a];
|
|
75
98
|
} else
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
xAxis:
|
|
79
|
-
yAxis:
|
|
80
|
-
series:
|
|
99
|
+
f = m ? x : g;
|
|
100
|
+
const b = {
|
|
101
|
+
xAxis: m ? g : x,
|
|
102
|
+
yAxis: f,
|
|
103
|
+
series: u,
|
|
81
104
|
tooltip: { trigger: "axis" }
|
|
82
105
|
};
|
|
83
106
|
if (s.length > 1) {
|
|
84
|
-
const a =
|
|
85
|
-
|
|
107
|
+
const a = u.map((l) => l.name);
|
|
108
|
+
b.legend = { data: a };
|
|
86
109
|
}
|
|
87
|
-
|
|
110
|
+
t.stack && b.series.forEach((a) => {
|
|
88
111
|
a.stack = "total";
|
|
89
112
|
});
|
|
90
|
-
const v =
|
|
91
|
-
return Array.isArray(v) && v.length > 0 &&
|
|
113
|
+
const v = t.referenceLines;
|
|
114
|
+
return Array.isArray(v) && v.length > 0 && u.length > 0 && (u[0].markLine = {
|
|
92
115
|
silent: !0,
|
|
93
116
|
symbol: "none",
|
|
94
117
|
data: v.map((a) => {
|
|
95
|
-
const o = {};
|
|
96
|
-
a.axis === "x" ? o.xAxis = a.value : o.yAxis = a.value, a.label && (o.name = a.label);
|
|
97
118
|
const l = {};
|
|
98
|
-
|
|
119
|
+
a.axis === "x" ? l.xAxis = a.value : l.yAxis = a.value, a.label && (l.name = a.label);
|
|
120
|
+
const c = {};
|
|
121
|
+
return a.color && (c.color = a.color), a.style && (c.type = a.style), Object.keys(c).length > 0 && (l.lineStyle = c), a.label && (l.label = { formatter: a.label, position: "end" }), l;
|
|
99
122
|
})
|
|
100
|
-
}),
|
|
123
|
+
}), b;
|
|
101
124
|
}
|
|
102
|
-
function
|
|
125
|
+
function oe(e, r, i) {
|
|
103
126
|
if (!Array.isArray(e)) return {};
|
|
104
|
-
const
|
|
127
|
+
const t = j(e), n = r?.x ?? t[0], s = (r?.y ?? [t[1]])[0], d = r?.color, m = r?.size, h = r?.opacity;
|
|
105
128
|
if (!n || !s) return {};
|
|
106
|
-
const
|
|
129
|
+
const y = {
|
|
107
130
|
xAxis: { type: "value" },
|
|
108
131
|
yAxis: { type: "value" },
|
|
109
132
|
tooltip: { trigger: "item" }
|
|
110
133
|
};
|
|
111
|
-
let
|
|
112
|
-
if (
|
|
134
|
+
let u = 1 / 0, x = -1 / 0;
|
|
135
|
+
if (h)
|
|
113
136
|
for (const a of e) {
|
|
114
|
-
const
|
|
115
|
-
|
|
137
|
+
const l = Number(a[h] ?? 0);
|
|
138
|
+
l < u && (u = l), l > x && (x = l);
|
|
139
|
+
}
|
|
140
|
+
const g = x - u || 1, A = i.conditionalStyles, f = (a) => {
|
|
141
|
+
const l = [Number(a[n] ?? 0), Number(a[s] ?? 0)];
|
|
142
|
+
if (m && l.push(Number(a[m] ?? 0)), A?.length) {
|
|
143
|
+
const c = L(a, A);
|
|
144
|
+
if (c) {
|
|
145
|
+
const o = { color: c.color };
|
|
146
|
+
if (h) {
|
|
147
|
+
const w = Number(a[h] ?? 0);
|
|
148
|
+
o.opacity = Math.round((0.1 + 0.9 * ((w - u) / g)) * 100) / 100;
|
|
149
|
+
}
|
|
150
|
+
const p = { value: l, itemStyle: o };
|
|
151
|
+
return c.symbol && (p.symbol = c.symbol), c.symbolSize && (p.symbolSize = c.symbolSize), p;
|
|
152
|
+
}
|
|
116
153
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const u = 0.1 + 0.9 * ((Number(a[d] ?? 0) - h) / x);
|
|
121
|
-
return { value: o, itemStyle: { opacity: Math.round(u * 100) / 100 } };
|
|
154
|
+
if (h) {
|
|
155
|
+
const o = 0.1 + 0.9 * ((Number(a[h] ?? 0) - u) / g);
|
|
156
|
+
return { value: l, itemStyle: { opacity: Math.round(o * 100) / 100 } };
|
|
122
157
|
}
|
|
123
|
-
return
|
|
124
|
-
},
|
|
125
|
-
const
|
|
126
|
-
return Math.max(4, Math.min(60, Math.sqrt(
|
|
158
|
+
return l;
|
|
159
|
+
}, b = m ? (a) => {
|
|
160
|
+
const c = (Array.isArray(a) ? a : a.value)[2] ?? 0;
|
|
161
|
+
return Math.max(4, Math.min(60, Math.sqrt(c) * 4));
|
|
127
162
|
} : void 0;
|
|
128
|
-
if (
|
|
163
|
+
if (d) {
|
|
129
164
|
const a = /* @__PURE__ */ new Map();
|
|
130
|
-
for (const
|
|
131
|
-
const
|
|
132
|
-
a.has(
|
|
165
|
+
for (const c of e) {
|
|
166
|
+
const o = String(c[d] ?? "unknown");
|
|
167
|
+
a.has(o) || a.set(o, []), a.get(o).push(f(c));
|
|
133
168
|
}
|
|
134
|
-
const
|
|
135
|
-
for (const [
|
|
136
|
-
const p = { name:
|
|
137
|
-
|
|
169
|
+
const l = [];
|
|
170
|
+
for (const [c, o] of a) {
|
|
171
|
+
const p = { name: c, type: "scatter", data: o };
|
|
172
|
+
b && (p.symbolSize = b), l.push(p);
|
|
138
173
|
}
|
|
139
|
-
|
|
174
|
+
y.series = l, y.legend = { data: Array.from(a.keys()) };
|
|
140
175
|
} else {
|
|
141
|
-
const
|
|
142
|
-
|
|
176
|
+
const l = { type: "scatter", data: e.map((c) => f(c)) };
|
|
177
|
+
b && (l.symbolSize = b), y.series = [l];
|
|
143
178
|
}
|
|
144
179
|
const v = i.referenceLines;
|
|
145
180
|
if (Array.isArray(v) && v.length > 0) {
|
|
146
|
-
const a =
|
|
181
|
+
const a = y.series[0];
|
|
147
182
|
a.markLine = {
|
|
148
183
|
silent: !0,
|
|
149
184
|
symbol: "none",
|
|
150
|
-
data: v.map((
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
return
|
|
185
|
+
data: v.map((l) => {
|
|
186
|
+
const c = {};
|
|
187
|
+
l.axis === "x" ? c.xAxis = l.value : c.yAxis = l.value, l.label && (c.name = l.label);
|
|
188
|
+
const o = {};
|
|
189
|
+
return l.color && (o.color = l.color), l.style && (o.type = l.style), Object.keys(o).length > 0 && (c.lineStyle = o), l.label && (c.label = { formatter: l.label, position: "end" }), c;
|
|
155
190
|
})
|
|
156
191
|
};
|
|
157
192
|
}
|
|
158
|
-
return
|
|
193
|
+
return y;
|
|
159
194
|
}
|
|
160
|
-
function
|
|
195
|
+
function le(e, r, i) {
|
|
161
196
|
if (!Array.isArray(e)) return {};
|
|
162
|
-
const
|
|
163
|
-
if (!
|
|
164
|
-
const s = e.map((
|
|
165
|
-
name: String(
|
|
166
|
-
value: Number(
|
|
167
|
-
})),
|
|
197
|
+
const t = r?.label ?? C(e), n = r?.value ?? _(e);
|
|
198
|
+
if (!t || !n) return {};
|
|
199
|
+
const s = e.map((u) => ({
|
|
200
|
+
name: String(u[t] ?? ""),
|
|
201
|
+
value: Number(u[n] ?? 0)
|
|
202
|
+
})), m = {
|
|
168
203
|
type: "pie",
|
|
169
204
|
radius: i.donut ? ["40%", "70%"] : "50%",
|
|
170
205
|
data: s,
|
|
171
206
|
label: { overflow: "truncate", width: 80 }
|
|
172
207
|
};
|
|
173
|
-
i.showLabel === !1 && (
|
|
174
|
-
const
|
|
208
|
+
i.showLabel === !1 && (m.label = { show: !1 });
|
|
209
|
+
const h = {
|
|
175
210
|
tooltip: { trigger: "item" },
|
|
176
211
|
legend: { orient: "vertical", left: "left" },
|
|
177
|
-
series: [
|
|
178
|
-
},
|
|
179
|
-
if (i.donut &&
|
|
180
|
-
const
|
|
181
|
-
|
|
212
|
+
series: [m]
|
|
213
|
+
}, y = i.center;
|
|
214
|
+
if (i.donut && y && (y.label || y.value)) {
|
|
215
|
+
const u = [];
|
|
216
|
+
y.label && u.push({
|
|
182
217
|
type: "text",
|
|
183
|
-
top:
|
|
184
|
-
style: { text:
|
|
185
|
-
}),
|
|
218
|
+
top: y.value ? -16 : 0,
|
|
219
|
+
style: { text: y.label, fontSize: 13, fill: "#999", textAlign: "center" }
|
|
220
|
+
}), y.value && u.push({
|
|
186
221
|
type: "text",
|
|
187
|
-
top:
|
|
188
|
-
style: { text:
|
|
189
|
-
}),
|
|
222
|
+
top: y.label ? 8 : 0,
|
|
223
|
+
style: { text: y.value, fontSize: 20, fontWeight: "bold", fill: "#333", textAlign: "center" }
|
|
224
|
+
}), h.graphic = [{ type: "group", left: "center", top: "middle", children: u }];
|
|
190
225
|
}
|
|
191
|
-
return
|
|
226
|
+
return h;
|
|
192
227
|
}
|
|
193
|
-
function
|
|
228
|
+
function ce(e, r, i) {
|
|
194
229
|
if (!Array.isArray(e)) return {};
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
197
|
-
const s = e.map((
|
|
198
|
-
name: String(
|
|
199
|
-
})),
|
|
200
|
-
name:
|
|
201
|
-
value: e.map((
|
|
230
|
+
const t = r?.axis ?? C(e), n = r?.y ?? j(e);
|
|
231
|
+
if (!t || n.length === 0) return {};
|
|
232
|
+
const s = e.map((m) => ({
|
|
233
|
+
name: String(m[t] ?? "")
|
|
234
|
+
})), d = n.map((m) => ({
|
|
235
|
+
name: m,
|
|
236
|
+
value: e.map((h) => Number(h[m] ?? 0))
|
|
202
237
|
}));
|
|
203
238
|
return {
|
|
204
239
|
tooltip: {},
|
|
@@ -207,98 +242,98 @@ function oe(e, t, i) {
|
|
|
207
242
|
series: [
|
|
208
243
|
{
|
|
209
244
|
type: "radar",
|
|
210
|
-
data:
|
|
245
|
+
data: d
|
|
211
246
|
}
|
|
212
247
|
]
|
|
213
248
|
};
|
|
214
249
|
}
|
|
215
|
-
function
|
|
250
|
+
function ue(e, r, i) {
|
|
216
251
|
if (!Array.isArray(e)) return {};
|
|
217
|
-
const
|
|
218
|
-
if (!
|
|
219
|
-
const
|
|
220
|
-
for (const
|
|
221
|
-
const
|
|
222
|
-
|
|
252
|
+
const t = e[0] ?? {}, n = Object.keys(t), s = n.filter((o) => typeof t[o] == "string"), d = n.filter((o) => typeof t[o] == "number"), m = r?.x ?? s[0], h = r?.y?.[0] ?? s.find((o) => o !== m), y = r?.value ?? d[0];
|
|
253
|
+
if (!m || !h || !y) return {};
|
|
254
|
+
const u = [], x = [], g = /* @__PURE__ */ new Set(), A = /* @__PURE__ */ new Set();
|
|
255
|
+
for (const o of e) {
|
|
256
|
+
const p = String(o[m] ?? ""), w = String(o[h] ?? "");
|
|
257
|
+
g.has(p) || (g.add(p), u.push(p)), A.has(w) || (A.add(w), x.push(w));
|
|
223
258
|
}
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
let
|
|
230
|
-
for (const
|
|
231
|
-
const
|
|
232
|
-
|
|
259
|
+
const f = /* @__PURE__ */ new Map();
|
|
260
|
+
u.forEach((o, p) => f.set(o, p));
|
|
261
|
+
const b = /* @__PURE__ */ new Map();
|
|
262
|
+
x.forEach((o, p) => b.set(o, p));
|
|
263
|
+
const v = [];
|
|
264
|
+
let a = 1 / 0, l = -1 / 0;
|
|
265
|
+
for (const o of e) {
|
|
266
|
+
const p = f.get(String(o[m] ?? "")) ?? 0, w = b.get(String(o[h] ?? "")) ?? 0, S = o[y] != null ? Number(o[y]) : null;
|
|
267
|
+
v.push([p, w, S]), S != null && (S < a && (a = S), S > l && (l = S));
|
|
233
268
|
}
|
|
234
|
-
isFinite(
|
|
235
|
-
const
|
|
269
|
+
isFinite(a) || (a = 0, l = 1);
|
|
270
|
+
const c = i.colorRange ?? ["#313695", "#4575b4", "#74add1", "#abd9e9", "#fee090", "#fdae61", "#f46d43", "#d73027"];
|
|
236
271
|
return {
|
|
237
|
-
xAxis: { type: "category", data:
|
|
238
|
-
yAxis: { type: "category", data:
|
|
272
|
+
xAxis: { type: "category", data: u, splitArea: { show: !0 } },
|
|
273
|
+
yAxis: { type: "category", data: x, splitArea: { show: !0 } },
|
|
239
274
|
visualMap: {
|
|
240
|
-
min: i.min != null ? Number(i.min) :
|
|
275
|
+
min: i.min != null ? Number(i.min) : a,
|
|
241
276
|
max: i.max != null ? Number(i.max) : l,
|
|
242
277
|
calculable: !0,
|
|
243
278
|
orient: "horizontal",
|
|
244
279
|
left: "center",
|
|
245
280
|
bottom: 0,
|
|
246
|
-
inRange: { color:
|
|
281
|
+
inRange: { color: c }
|
|
247
282
|
},
|
|
248
283
|
tooltip: {
|
|
249
284
|
trigger: "item",
|
|
250
|
-
formatter: (
|
|
251
|
-
const
|
|
252
|
-
return
|
|
285
|
+
formatter: (o) => {
|
|
286
|
+
const p = o.data;
|
|
287
|
+
return p ? `${u[p[0]]} × ${x[p[1]]}: ${p[2] != null ? p[2] : "-"}` : "";
|
|
253
288
|
}
|
|
254
289
|
},
|
|
255
290
|
grid: { bottom: 60 },
|
|
256
291
|
series: [{
|
|
257
292
|
type: "heatmap",
|
|
258
|
-
data:
|
|
293
|
+
data: v,
|
|
259
294
|
label: { show: i.showLabel !== !1 }
|
|
260
295
|
}]
|
|
261
296
|
};
|
|
262
297
|
}
|
|
263
|
-
function
|
|
298
|
+
function fe(e, r, i) {
|
|
264
299
|
if (!Array.isArray(e) || e.length === 0) return {};
|
|
265
|
-
const
|
|
266
|
-
let
|
|
267
|
-
if (
|
|
268
|
-
|
|
300
|
+
const t = e[0] ?? {}, n = Object.keys(t), s = n.filter((g) => typeof t[g] == "string"), d = n.filter((g) => typeof t[g] == "number"), m = r?.x ?? s[0];
|
|
301
|
+
let h;
|
|
302
|
+
if (r?.y && r.y.length >= 5)
|
|
303
|
+
h = r.y.slice(0, 5);
|
|
269
304
|
else {
|
|
270
|
-
const
|
|
271
|
-
|
|
305
|
+
const A = ["min", "q1", "median", "q3", "max"].filter((f) => d.includes(f));
|
|
306
|
+
h = A.length === 5 ? A : d.slice(0, 5);
|
|
272
307
|
}
|
|
273
|
-
if (
|
|
274
|
-
const
|
|
275
|
-
(
|
|
276
|
-
),
|
|
308
|
+
if (h.length < 5) return {};
|
|
309
|
+
const y = m ? e.map((g) => String(g[m] ?? "")) : void 0, u = e.map(
|
|
310
|
+
(g) => h.map((A) => Number(g[A] ?? 0))
|
|
311
|
+
), x = {
|
|
277
312
|
tooltip: { trigger: "item" },
|
|
278
313
|
series: [{
|
|
279
314
|
type: "boxplot",
|
|
280
|
-
data:
|
|
315
|
+
data: u
|
|
281
316
|
}]
|
|
282
317
|
};
|
|
283
|
-
return
|
|
318
|
+
return y ? (x.xAxis = { type: "category", data: y }, x.yAxis = { type: "value" }) : (x.xAxis = { type: "category" }, x.yAxis = { type: "value" }), x;
|
|
284
319
|
}
|
|
285
320
|
function C(e) {
|
|
286
321
|
if (e.length === 0) return;
|
|
287
|
-
const
|
|
288
|
-
return Object.keys(
|
|
322
|
+
const r = e[0];
|
|
323
|
+
return Object.keys(r).find((i) => typeof r[i] == "string");
|
|
289
324
|
}
|
|
290
|
-
function
|
|
325
|
+
function _(e) {
|
|
291
326
|
if (e.length === 0) return;
|
|
292
|
-
const
|
|
293
|
-
return Object.keys(
|
|
327
|
+
const r = e[0];
|
|
328
|
+
return Object.keys(r).find((i) => typeof r[i] == "number");
|
|
294
329
|
}
|
|
295
|
-
function
|
|
330
|
+
function ye(e, r, i) {
|
|
296
331
|
if (!Array.isArray(e)) return {};
|
|
297
|
-
const
|
|
298
|
-
if (!
|
|
299
|
-
const s = e.map((
|
|
300
|
-
name: String(
|
|
301
|
-
value: Number(
|
|
332
|
+
const t = r?.label ?? C(e), n = r?.value ?? _(e);
|
|
333
|
+
if (!t || !n) return {};
|
|
334
|
+
const s = e.map((d) => ({
|
|
335
|
+
name: String(d[t] ?? ""),
|
|
336
|
+
value: Number(d[n] ?? 0)
|
|
302
337
|
}));
|
|
303
338
|
return {
|
|
304
339
|
tooltip: { trigger: "item", formatter: "{b}: {c} ({d}%)" },
|
|
@@ -312,19 +347,19 @@ function ue(e, t, i) {
|
|
|
312
347
|
}]
|
|
313
348
|
};
|
|
314
349
|
}
|
|
315
|
-
function
|
|
350
|
+
function he(e, r, i) {
|
|
316
351
|
if (!Array.isArray(e)) return {};
|
|
317
|
-
const
|
|
352
|
+
const t = e, n = r?.x ?? C(t), s = (r?.y ?? [_(t)])[0];
|
|
318
353
|
if (!n || !s) return {};
|
|
319
|
-
const
|
|
320
|
-
let
|
|
321
|
-
for (const
|
|
322
|
-
const
|
|
323
|
-
|
|
354
|
+
const d = [], m = [], h = [], y = [];
|
|
355
|
+
let u = 0;
|
|
356
|
+
for (const x of t) {
|
|
357
|
+
const g = String(x[n] ?? ""), A = Number(x[s] ?? 0);
|
|
358
|
+
d.push(g), A >= 0 ? (m.push(u), h.push(A), y.push(null)) : (m.push(u + A), h.push(null), y.push(Math.abs(A))), u += A;
|
|
324
359
|
}
|
|
325
360
|
return {
|
|
326
361
|
tooltip: { trigger: "axis", axisPointer: { type: "shadow" } },
|
|
327
|
-
xAxis: { type: "category", data:
|
|
362
|
+
xAxis: { type: "category", data: d },
|
|
328
363
|
yAxis: { type: "value" },
|
|
329
364
|
series: [
|
|
330
365
|
{
|
|
@@ -333,26 +368,26 @@ function fe(e, t, i) {
|
|
|
333
368
|
stack: "waterfall",
|
|
334
369
|
itemStyle: { borderColor: "transparent", color: "transparent" },
|
|
335
370
|
emphasis: { itemStyle: { borderColor: "transparent", color: "transparent" } },
|
|
336
|
-
data:
|
|
371
|
+
data: m
|
|
337
372
|
},
|
|
338
373
|
{
|
|
339
374
|
name: "Positive",
|
|
340
375
|
type: "bar",
|
|
341
376
|
stack: "waterfall",
|
|
342
|
-
data:
|
|
377
|
+
data: h
|
|
343
378
|
},
|
|
344
379
|
{
|
|
345
380
|
name: "Negative",
|
|
346
381
|
type: "bar",
|
|
347
382
|
stack: "waterfall",
|
|
348
|
-
data:
|
|
383
|
+
data: y
|
|
349
384
|
}
|
|
350
385
|
]
|
|
351
386
|
};
|
|
352
387
|
}
|
|
353
|
-
function
|
|
388
|
+
function de(e, r) {
|
|
354
389
|
if (!Array.isArray(e)) return {};
|
|
355
|
-
const i = e.map((
|
|
390
|
+
const i = e.map((t) => M(t));
|
|
356
391
|
return {
|
|
357
392
|
tooltip: { trigger: "item" },
|
|
358
393
|
series: [{
|
|
@@ -364,38 +399,77 @@ function ye(e, t) {
|
|
|
364
399
|
}]
|
|
365
400
|
};
|
|
366
401
|
}
|
|
367
|
-
function
|
|
368
|
-
const
|
|
402
|
+
function M(e) {
|
|
403
|
+
const r = {
|
|
369
404
|
name: String(e.name ?? ""),
|
|
370
405
|
value: Number(e.value ?? 0)
|
|
371
406
|
};
|
|
372
|
-
return Array.isArray(e.children) && (
|
|
407
|
+
return Array.isArray(e.children) && (r.children = e.children.map((i) => M(i))), r;
|
|
408
|
+
}
|
|
409
|
+
function me(e, r, i) {
|
|
410
|
+
let t;
|
|
411
|
+
if (!Array.isArray(e) || e.length === 0) return {};
|
|
412
|
+
if (typeof e[0] == "number")
|
|
413
|
+
t = e;
|
|
414
|
+
else {
|
|
415
|
+
const f = r?.value ?? _(e);
|
|
416
|
+
if (!f) return {};
|
|
417
|
+
t = e.map((b) => Number(b[f] ?? 0));
|
|
418
|
+
}
|
|
419
|
+
if (t.length === 0) return {};
|
|
420
|
+
const n = typeof i.bins == "number" ? i.bins : Math.ceil(Math.log2(t.length) + 1), s = Math.min(...t), h = (Math.max(...t) - s) / n || 1, y = new Array(n).fill(0), u = [];
|
|
421
|
+
for (let f = 0; f < n; f++) {
|
|
422
|
+
const b = s + f * h, v = s + (f + 1) * h, a = (l) => Number.isInteger(l) ? String(l) : l.toFixed(1);
|
|
423
|
+
u.push(`${a(b)}–${a(v)}`);
|
|
424
|
+
}
|
|
425
|
+
for (const f of t) {
|
|
426
|
+
let b = Math.floor((f - s) / h);
|
|
427
|
+
b >= n && (b = n - 1), y[b]++;
|
|
428
|
+
}
|
|
429
|
+
const x = {
|
|
430
|
+
type: "bar",
|
|
431
|
+
data: y,
|
|
432
|
+
barCategoryGap: "0%"
|
|
433
|
+
}, g = {
|
|
434
|
+
xAxis: { type: "category", data: u, axisTick: { alignWithLabel: !0 } },
|
|
435
|
+
yAxis: { type: "value" },
|
|
436
|
+
series: [x],
|
|
437
|
+
tooltip: { trigger: "axis" }
|
|
438
|
+
}, A = i.referenceLines;
|
|
439
|
+
return Array.isArray(A) && A.length > 0 && (x.markLine = {
|
|
440
|
+
silent: !0,
|
|
441
|
+
symbol: "none",
|
|
442
|
+
data: A.map((f) => {
|
|
443
|
+
const b = {};
|
|
444
|
+
f.axis === "x" ? b.xAxis = f.value : b.yAxis = f.value, f.label && (b.name = f.label);
|
|
445
|
+
const v = {};
|
|
446
|
+
return f.color && (v.color = f.color), f.style && (v.type = f.style), Object.keys(v).length > 0 && (b.lineStyle = v), f.label && (b.label = { formatter: f.label, position: "end" }), b;
|
|
447
|
+
})
|
|
448
|
+
}), g;
|
|
373
449
|
}
|
|
374
450
|
function j(e) {
|
|
375
451
|
if (e.length === 0) return [];
|
|
376
|
-
const
|
|
377
|
-
return Object.keys(
|
|
452
|
+
const r = e[0];
|
|
453
|
+
return Object.keys(r).filter((i) => typeof r[i] == "number");
|
|
378
454
|
}
|
|
379
|
-
function
|
|
455
|
+
function I(e, r) {
|
|
380
456
|
const i = { ...e };
|
|
381
|
-
for (const
|
|
382
|
-
const n = e[
|
|
383
|
-
|
|
457
|
+
for (const t of Object.keys(r)) {
|
|
458
|
+
const n = e[t], s = r[t];
|
|
459
|
+
N(n) && N(s) ? i[t] = I(n, s) : i[t] = s;
|
|
384
460
|
}
|
|
385
461
|
return i;
|
|
386
462
|
}
|
|
387
|
-
function
|
|
463
|
+
function N(e) {
|
|
388
464
|
return e != null && typeof e == "object" && !Array.isArray(e);
|
|
389
465
|
}
|
|
390
|
-
var
|
|
391
|
-
for (var n =
|
|
392
|
-
(
|
|
393
|
-
return
|
|
466
|
+
var be = Object.defineProperty, pe = Object.getOwnPropertyDescriptor, V = (e, r, i, t) => {
|
|
467
|
+
for (var n = t > 1 ? void 0 : t ? pe(r, i) : r, s = e.length - 1, d; s >= 0; s--)
|
|
468
|
+
(d = e[s]) && (n = (t ? d(r, i, n) : d(n)) || n);
|
|
469
|
+
return t && n && be(r, i, n), n;
|
|
394
470
|
};
|
|
395
|
-
|
|
396
|
-
B,
|
|
471
|
+
O.use([
|
|
397
472
|
q,
|
|
398
|
-
W,
|
|
399
473
|
G,
|
|
400
474
|
H,
|
|
401
475
|
K,
|
|
@@ -408,16 +482,18 @@ z.use([
|
|
|
408
482
|
ee,
|
|
409
483
|
te,
|
|
410
484
|
re,
|
|
411
|
-
|
|
485
|
+
ie,
|
|
486
|
+
se,
|
|
487
|
+
ne
|
|
412
488
|
]);
|
|
413
|
-
let
|
|
489
|
+
let k = class extends E {
|
|
414
490
|
constructor() {
|
|
415
491
|
super(...arguments), this.spec = null, this._chart = null, this._container = null, this._resizeObserver = null;
|
|
416
492
|
}
|
|
417
493
|
render() {
|
|
418
|
-
if (!this.spec) return
|
|
494
|
+
if (!this.spec) return R;
|
|
419
495
|
const e = this.spec.title ?? `${this.spec.widget} chart`;
|
|
420
|
-
return
|
|
496
|
+
return T`<div class="chart-container" part="chart" role="img" aria-label=${e}></div>`;
|
|
421
497
|
}
|
|
422
498
|
firstUpdated() {
|
|
423
499
|
this._container = this.shadowRoot?.querySelector(".chart-container"), this._initChart(), this._container && (this._resizeObserver = new ResizeObserver(() => this._chart?.resize()), this._resizeObserver.observe(this._container));
|
|
@@ -428,7 +504,7 @@ let _ = class extends V {
|
|
|
428
504
|
_initChart() {
|
|
429
505
|
if (!(!this._container || !this.spec))
|
|
430
506
|
try {
|
|
431
|
-
this._chart =
|
|
507
|
+
this._chart = O.init(this._container), this._chart.on("click", (e) => {
|
|
432
508
|
this._onChartClick(e);
|
|
433
509
|
}), this._updateChart();
|
|
434
510
|
} catch (e) {
|
|
@@ -437,7 +513,7 @@ let _ = class extends V {
|
|
|
437
513
|
}
|
|
438
514
|
_onChartClick(e) {
|
|
439
515
|
if (!this.spec) return;
|
|
440
|
-
const
|
|
516
|
+
const r = {
|
|
441
517
|
type: "select",
|
|
442
518
|
widget: this.spec.widget,
|
|
443
519
|
id: this.spec.id,
|
|
@@ -450,7 +526,7 @@ let _ = class extends V {
|
|
|
450
526
|
};
|
|
451
527
|
this.dispatchEvent(
|
|
452
528
|
new CustomEvent("u-widget-internal", {
|
|
453
|
-
detail:
|
|
529
|
+
detail: r,
|
|
454
530
|
bubbles: !0,
|
|
455
531
|
composed: !0
|
|
456
532
|
})
|
|
@@ -458,30 +534,30 @@ let _ = class extends V {
|
|
|
458
534
|
}
|
|
459
535
|
_updateChart() {
|
|
460
536
|
if (!this._chart || !this.spec) return;
|
|
461
|
-
const e =
|
|
462
|
-
|
|
537
|
+
const e = ae(this.spec), r = this._readThemeColors();
|
|
538
|
+
r.length > 0 && (e.color = r), this._readCSSVar("--u-widget-bg") && (e.backgroundColor = "transparent"), this._applyThemeStyle(e), this._chart.setOption(e, !0);
|
|
463
539
|
}
|
|
464
540
|
_applyThemeStyle(e) {
|
|
465
|
-
const
|
|
466
|
-
if (!
|
|
467
|
-
e.textStyle = { ...e.textStyle, color:
|
|
541
|
+
const r = this._readCSSVar("--u-widget-text"), i = this._readCSSVar("--u-widget-text-secondary"), t = this._readCSSVar("--u-widget-border");
|
|
542
|
+
if (!r) return;
|
|
543
|
+
e.textStyle = { ...e.textStyle, color: r };
|
|
468
544
|
const n = {
|
|
469
|
-
axisLabel: { color: i ||
|
|
470
|
-
axisLine: { lineStyle: { color:
|
|
471
|
-
splitLine: { lineStyle: { color:
|
|
545
|
+
axisLabel: { color: i || r },
|
|
546
|
+
axisLine: { lineStyle: { color: t || i } },
|
|
547
|
+
splitLine: { lineStyle: { color: t } }
|
|
472
548
|
};
|
|
473
|
-
e.xAxis && typeof e.xAxis == "object" && (e.xAxis = { ...e.xAxis, ...n }), e.yAxis && typeof e.yAxis == "object" && (e.yAxis = { ...e.yAxis, ...n }), e.legend && typeof e.legend == "object" && (e.legend = { ...e.legend, textStyle: { color:
|
|
549
|
+
e.xAxis && typeof e.xAxis == "object" && (e.xAxis = { ...e.xAxis, ...n }), e.yAxis && typeof e.yAxis == "object" && (e.yAxis = { ...e.yAxis, ...n }), e.legend && typeof e.legend == "object" && (e.legend = { ...e.legend, textStyle: { color: r } });
|
|
474
550
|
}
|
|
475
551
|
_readThemeColors() {
|
|
476
552
|
const e = [];
|
|
477
|
-
for (let
|
|
478
|
-
const i = this._readCSSVar(`--u-widget-chart-color-${
|
|
553
|
+
for (let r = 1; r <= 10; r++) {
|
|
554
|
+
const i = this._readCSSVar(`--u-widget-chart-color-${r}`);
|
|
479
555
|
if (i) e.push(i);
|
|
480
556
|
else break;
|
|
481
557
|
}
|
|
482
558
|
if (e.length === 0) {
|
|
483
|
-
const
|
|
484
|
-
|
|
559
|
+
const r = this._readCSSVar("--u-widget-primary");
|
|
560
|
+
r && e.push(r);
|
|
485
561
|
}
|
|
486
562
|
return e;
|
|
487
563
|
}
|
|
@@ -496,9 +572,9 @@ let _ = class extends V {
|
|
|
496
572
|
this._chart?.resize();
|
|
497
573
|
}
|
|
498
574
|
};
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
575
|
+
k.styles = [
|
|
576
|
+
W,
|
|
577
|
+
P`
|
|
502
578
|
:host {
|
|
503
579
|
display: block;
|
|
504
580
|
container: uw-chart / inline-size;
|
|
@@ -516,14 +592,14 @@ _.styles = [
|
|
|
516
592
|
}
|
|
517
593
|
`
|
|
518
594
|
];
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
],
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
],
|
|
595
|
+
V([
|
|
596
|
+
D({ type: Object })
|
|
597
|
+
], k.prototype, "spec", 2);
|
|
598
|
+
k = V([
|
|
599
|
+
$("uw-chart")
|
|
600
|
+
], k);
|
|
525
601
|
export {
|
|
526
|
-
|
|
527
|
-
|
|
602
|
+
k as UwChart,
|
|
603
|
+
ae as toEChartsOption
|
|
528
604
|
};
|
|
529
605
|
//# sourceMappingURL=u-widgets-charts.js.map
|