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