@iyulab/u-widgets 0.8.1 → 0.9.0

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.
@@ -1,120 +1,122 @@
1
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";
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 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) {
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, r) {
9
9
  for (const i of r) {
10
10
  const t = e[i.field];
11
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;
12
+ const s = Number(t);
13
+ if (Number.isNaN(s)) continue;
14
+ const n = i.above === void 0 || s > i.above, u = i.below === void 0 || s < i.below;
15
+ if (n && u) return i;
16
16
  }
17
17
  }
18
- function ae(e) {
19
- const r = e.widget, i = e.data, t = e.mapping ? B(e.mapping) : void 0, n = e.options ?? {};
18
+ function le(e) {
19
+ const r = e.widget, i = e.data, t = e.mapping ? W(e.mapping) : void 0, s = e.options ?? {};
20
20
  if (!i) return {};
21
- let s;
21
+ let n;
22
22
  switch (r) {
23
23
  case "chart.bar":
24
- s = z(i, t, "bar", n);
24
+ n = N(i, t, "bar", s);
25
25
  break;
26
26
  case "chart.line":
27
- s = z(i, t, "line", n);
27
+ n = N(i, t, "line", s);
28
28
  break;
29
29
  case "chart.area":
30
- s = z(i, t, "line", { ...n, _area: !0 });
30
+ n = N(i, t, "line", { ...s, _area: !0 });
31
31
  break;
32
32
  case "chart.pie":
33
- s = le(i, t, n);
33
+ n = ue(i, t, s);
34
34
  break;
35
35
  case "chart.scatter":
36
- s = oe(i, t, n);
36
+ n = ce(i, t, s);
37
37
  break;
38
38
  case "chart.radar":
39
- s = ce(i, t);
39
+ n = fe(i, t);
40
40
  break;
41
41
  case "chart.heatmap":
42
- s = ue(i, t, n);
42
+ n = ye(i, t, s);
43
43
  break;
44
44
  case "chart.box":
45
- s = fe(i, t);
45
+ n = he(i, t);
46
46
  break;
47
47
  case "chart.funnel":
48
- s = ye(i, t);
48
+ n = me(i, t);
49
49
  break;
50
50
  case "chart.waterfall":
51
- s = he(i, t);
51
+ n = de(i, t);
52
52
  break;
53
53
  case "chart.treemap":
54
- s = de(i);
54
+ n = be(i);
55
55
  break;
56
56
  case "chart.histogram":
57
- s = me(i, t, n);
57
+ n = pe(i, t, s);
58
58
  break;
59
59
  default:
60
60
  return {};
61
61
  }
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 d = n.echarts;
64
- return d && typeof d == "object" && (s = I(s, d)), s;
62
+ s.legend === !1 && n.legend && (n.legend = { ...n.legend, show: !1 }), s.grid === !1 && (n.xAxis && typeof n.xAxis == "object" && !Array.isArray(n.xAxis) && (n.xAxis = { ...n.xAxis, splitLine: { show: !1 } }), n.yAxis && typeof n.yAxis == "object" && !Array.isArray(n.yAxis) && (n.yAxis = { ...n.yAxis, splitLine: { show: !1 } })), s.animate === !1 && (n.animation = !1), Array.isArray(s.colors) && s.colors.length > 0 && (n.color = s.colors);
63
+ const u = s.locale;
64
+ L(n, "xAxis", s.xFormat, u), L(n, "yAxis", s.yFormat, u);
65
+ const h = s.echarts;
66
+ return h && typeof h == "object" && (n = V(n, h)), n;
65
67
  }
66
- function z(e, r, i, t) {
68
+ function N(e, r, i, t) {
67
69
  if (!Array.isArray(e)) return {};
68
- const n = r?.x ?? C(e), s = r?.y ?? [_(e)].filter(Boolean);
69
- if (!n || s.length === 0) return {};
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) => {
70
+ const s = r?.x ?? C(e), n = r?.y ?? [_(e)].filter(Boolean);
71
+ if (!s || n.length === 0) return {};
72
+ const u = e.map((a) => String(a[s] ?? "")), h = !!t.horizontal, d = Array.isArray(t.series) ? t.series : [], m = t.conditionalStyles, f = n.map((a, l) => {
71
73
  const c = {
72
74
  name: a,
73
75
  type: i,
74
76
  data: e.map((p) => {
75
77
  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;
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 = h[l];
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: d }, g = { type: "value" };
90
- t.histogram && (x.axisTick = { alignWithLabel: !0 }, u.forEach((a) => {
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 = !m && u.some((a) => a.yAxisIndex >= 1);
94
- let f;
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
- f = [g, a];
99
+ y = [g, a];
98
100
  } else
99
- f = m ? x : g;
101
+ y = h ? x : g;
100
102
  const b = {
101
- xAxis: m ? g : x,
102
- yAxis: f,
103
- series: u,
103
+ xAxis: h ? g : x,
104
+ yAxis: y,
105
+ series: f,
104
106
  tooltip: { trigger: "axis" }
105
107
  };
106
- if (s.length > 1) {
107
- const a = u.map((l) => l.name);
108
+ if (n.length > 1) {
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 v = t.referenceLines;
114
- return Array.isArray(v) && v.length > 0 && u.length > 0 && (u[0].markLine = {
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: v.map((a) => {
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 oe(e, r, i) {
127
+ function ce(e, r, i) {
126
128
  if (!Array.isArray(e)) return {};
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;
128
- if (!n || !s) return {};
129
- const y = {
129
+ const t = I(e), s = r?.x ?? t[0], n = (r?.y ?? [t[1]])[0], u = r?.color, h = r?.size, d = r?.opacity;
130
+ if (!s || !n) return {};
131
+ const m = {
130
132
  xAxis: { type: "value" },
131
133
  yAxis: { type: "value" },
132
134
  tooltip: { trigger: "item" }
133
135
  };
134
- let u = 1 / 0, x = -1 / 0;
135
- if (h)
136
+ let f = 1 / 0, x = -1 / 0;
137
+ if (d)
136
138
  for (const a of e) {
137
- const l = Number(a[h] ?? 0);
138
- l < u && (u = l), l > x && (x = l);
139
+ const l = Number(a[d] ?? 0);
140
+ l < f && (f = l), l > x && (x = l);
139
141
  }
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);
142
+ const g = x - f || 1, A = i.conditionalStyles, y = (a) => {
143
+ const l = [Number(a[s] ?? 0), Number(a[n] ?? 0)];
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 (h) {
147
- const w = Number(a[h] ?? 0);
148
- o.opacity = Math.round((0.1 + 0.9 * ((w - u) / g)) * 100) / 100;
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 (h) {
155
- const o = 0.1 + 0.9 * ((Number(a[h] ?? 0) - u) / g);
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 = m ? (a) => {
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 (d) {
165
+ if (u) {
164
166
  const a = /* @__PURE__ */ new Map();
165
167
  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));
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
- y.series = l, y.legend = { data: Array.from(a.keys()) };
176
+ m.series = l, m.legend = { data: Array.from(a.keys()) };
175
177
  } else {
176
- const l = { type: "scatter", data: e.map((c) => f(c)) };
177
- b && (l.symbolSize = b), y.series = [l];
178
+ const l = { type: "scatter", data: e.map((c) => y(c)) };
179
+ b && (l.symbolSize = b), m.series = [l];
178
180
  }
179
- const v = i.referenceLines;
180
- if (Array.isArray(v) && v.length > 0) {
181
- const a = y.series[0];
181
+ const S = i.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: v.map((l) => {
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,86 +192,86 @@ function oe(e, r, i) {
190
192
  })
191
193
  };
192
194
  }
193
- return y;
195
+ return m;
194
196
  }
195
- function le(e, r, i) {
197
+ function ue(e, r, i) {
196
198
  if (!Array.isArray(e)) return {};
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 = {
199
+ const t = r?.label ?? C(e), s = r?.value ?? _(e);
200
+ if (!t || !s) return {};
201
+ const n = e.map((f) => ({
202
+ name: String(f[t] ?? ""),
203
+ value: Number(f[s] ?? 0)
204
+ })), h = {
203
205
  type: "pie",
204
206
  radius: i.donut ? ["40%", "70%"] : "50%",
205
- data: s,
207
+ data: n,
206
208
  label: { overflow: "truncate", width: 80 }
207
209
  };
208
- i.showLabel === !1 && (m.label = { show: !1 });
209
- const h = {
210
+ i.showLabel === !1 && (h.label = { show: !1 });
211
+ const d = {
210
212
  tooltip: { trigger: "item" },
211
213
  legend: { orient: "vertical", left: "left" },
212
- series: [m]
213
- }, y = i.center;
214
- if (i.donut && y && (y.label || y.value)) {
215
- const u = [];
216
- y.label && u.push({
214
+ series: [h]
215
+ }, m = i.center;
216
+ if (i.donut && m && (m.label || m.value)) {
217
+ const f = [];
218
+ m.label && f.push({
217
219
  type: "text",
218
- top: y.value ? -16 : 0,
219
- style: { text: y.label, fontSize: 13, fill: "#999", textAlign: "center" }
220
- }), y.value && u.push({
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: 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 }];
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 h;
228
+ return d;
227
229
  }
228
- function ce(e, r, i) {
230
+ function fe(e, r, i) {
229
231
  if (!Array.isArray(e)) return {};
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))
232
+ const t = r?.axis ?? C(e), s = r?.y ?? I(e);
233
+ if (!t || s.length === 0) return {};
234
+ const n = e.map((h) => ({
235
+ name: String(h[t] ?? "")
236
+ })), u = s.map((h) => ({
237
+ name: h,
238
+ value: e.map((d) => Number(d[h] ?? 0))
237
239
  }));
238
240
  return {
239
241
  tooltip: {},
240
- legend: { data: n },
241
- radar: { indicator: s },
242
+ legend: { data: s },
243
+ radar: { indicator: n },
242
244
  series: [
243
245
  {
244
246
  type: "radar",
245
- data: d
247
+ data: u
246
248
  }
247
249
  ]
248
250
  };
249
251
  }
250
- function ue(e, r, i) {
252
+ function ye(e, r, i) {
251
253
  if (!Array.isArray(e)) return {};
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();
254
+ const t = e[0] ?? {}, s = Object.keys(t), n = s.filter((o) => typeof t[o] == "string"), u = s.filter((o) => typeof t[o] == "number"), h = r?.x ?? n[0], d = r?.y?.[0] ?? n.find((o) => o !== h), m = r?.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[m] ?? ""), w = String(o[h] ?? "");
257
- g.has(p) || (g.add(p), u.push(p)), A.has(w) || (A.add(w), x.push(w));
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 f = /* @__PURE__ */ new Map();
260
- u.forEach((o, p) => f.set(o, p));
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 v = [];
265
+ const S = [];
264
266
  let a = 1 / 0, l = -1 / 0;
265
267
  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));
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
272
  const c = i.colorRange ?? ["#313695", "#4575b4", "#74add1", "#abd9e9", "#fee090", "#fdae61", "#f46d43", "#d73027"];
271
273
  return {
272
- xAxis: { type: "category", data: u, splitArea: { show: !0 } },
274
+ xAxis: { type: "category", data: f, splitArea: { show: !0 } },
273
275
  yAxis: { type: "category", data: x, splitArea: { show: !0 } },
274
276
  visualMap: {
275
277
  min: i.min != null ? Number(i.min) : a,
@@ -284,38 +286,38 @@ function ue(e, r, i) {
284
286
  trigger: "item",
285
287
  formatter: (o) => {
286
288
  const p = o.data;
287
- return p ? `${u[p[0]]} × ${x[p[1]]}: ${p[2] != null ? p[2] : "-"}` : "";
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: v,
295
+ data: S,
294
296
  label: { show: i.showLabel !== !1 }
295
297
  }]
296
298
  };
297
299
  }
298
- function fe(e, r, i) {
300
+ function he(e, r, i) {
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"), d = n.filter((g) => typeof t[g] == "number"), m = r?.x ?? s[0];
301
- let h;
302
+ const t = e[0] ?? {}, s = Object.keys(t), n = s.filter((g) => typeof t[g] == "string"), u = s.filter((g) => typeof t[g] == "number"), h = r?.x ?? n[0];
303
+ let d;
302
304
  if (r?.y && r.y.length >= 5)
303
- h = r.y.slice(0, 5);
305
+ d = r.y.slice(0, 5);
304
306
  else {
305
- const A = ["min", "q1", "median", "q3", "max"].filter((f) => d.includes(f));
306
- h = A.length === 5 ? A : d.slice(0, 5);
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 (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))
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: u
317
+ data: f
316
318
  }]
317
319
  };
318
- return y ? (x.xAxis = { type: "category", data: y }, x.yAxis = { type: "value" }) : (x.xAxis = { type: "category" }, x.yAxis = { type: "value" }), x;
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;
@@ -327,39 +329,39 @@ function _(e) {
327
329
  const r = e[0];
328
330
  return Object.keys(r).find((i) => typeof r[i] == "number");
329
331
  }
330
- function ye(e, r, i) {
332
+ function me(e, r, i) {
331
333
  if (!Array.isArray(e)) return {};
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)
334
+ const t = r?.label ?? C(e), s = r?.value ?? _(e);
335
+ if (!t || !s) return {};
336
+ const n = e.map((u) => ({
337
+ name: String(u[t] ?? ""),
338
+ value: Number(u[s] ?? 0)
337
339
  }));
338
340
  return {
339
341
  tooltip: { trigger: "item", formatter: "{b}: {c} ({d}%)" },
340
342
  legend: { orient: "vertical", left: "left" },
341
343
  series: [{
342
344
  type: "funnel",
343
- data: s,
345
+ data: n,
344
346
  sort: "descending",
345
347
  gap: 2,
346
348
  label: { show: !0, position: "inside" }
347
349
  }]
348
350
  };
349
351
  }
350
- function he(e, r, i) {
352
+ function de(e, r, i) {
351
353
  if (!Array.isArray(e)) return {};
352
- const t = e, n = r?.x ?? C(t), s = (r?.y ?? [_(t)])[0];
353
- if (!n || !s) return {};
354
- const d = [], m = [], h = [], y = [];
355
- let u = 0;
354
+ const t = e, s = r?.x ?? C(t), n = (r?.y ?? [_(t)])[0];
355
+ if (!s || !n) return {};
356
+ const u = [], h = [], d = [], m = [];
357
+ let f = 0;
356
358
  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;
359
+ const g = String(x[s] ?? ""), A = Number(x[n] ?? 0);
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: d },
364
+ xAxis: { type: "category", data: u },
363
365
  yAxis: { type: "value" },
364
366
  series: [
365
367
  {
@@ -368,26 +370,26 @@ 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: m
373
+ data: h
372
374
  },
373
375
  {
374
376
  name: "Positive",
375
377
  type: "bar",
376
378
  stack: "waterfall",
377
- data: h
379
+ data: d
378
380
  },
379
381
  {
380
382
  name: "Negative",
381
383
  type: "bar",
382
384
  stack: "waterfall",
383
- data: y
385
+ data: m
384
386
  }
385
387
  ]
386
388
  };
387
389
  }
388
- function de(e, r) {
390
+ function be(e, r) {
389
391
  if (!Array.isArray(e)) return {};
390
- const i = e.map((t) => M(t));
392
+ const i = e.map((t) => j(t));
391
393
  return {
392
394
  tooltip: { trigger: "item" },
393
395
  series: [{
@@ -399,39 +401,39 @@ function de(e, r) {
399
401
  }]
400
402
  };
401
403
  }
402
- function M(e) {
404
+ function j(e) {
403
405
  const r = {
404
406
  name: String(e.name ?? ""),
405
407
  value: Number(e.value ?? 0)
406
408
  };
407
- return Array.isArray(e.children) && (r.children = e.children.map((i) => M(i))), r;
409
+ return Array.isArray(e.children) && (r.children = e.children.map((i) => j(i))), r;
408
410
  }
409
- function me(e, r, i) {
411
+ function pe(e, r, i) {
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 f = r?.value ?? _(e);
416
- if (!f) return {};
417
- t = e.map((b) => Number(b[f] ?? 0));
417
+ const y = r?.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 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)}`);
422
+ const s = typeof i.bins == "number" ? i.bins : Math.ceil(Math.log2(t.length) + 1), n = Math.min(...t), d = (Math.max(...t) - n) / s || 1, m = new Array(s).fill(0), f = [];
423
+ for (let y = 0; y < s; y++) {
424
+ const b = n + y * d, S = n + (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 f of t) {
426
- let b = Math.floor((f - s) / h);
427
- b >= n && (b = n - 1), y[b]++;
427
+ for (const y of t) {
428
+ let b = Math.floor((y - n) / d);
429
+ b >= s && (b = s - 1), m[b]++;
428
430
  }
429
431
  const x = {
430
432
  type: "bar",
431
- data: y,
433
+ data: m,
432
434
  barCategoryGap: "0%"
433
435
  }, g = {
434
- xAxis: { type: "category", data: u, axisTick: { alignWithLabel: !0 } },
436
+ xAxis: { type: "category", data: f, axisTick: { alignWithLabel: !0 } },
435
437
  yAxis: { type: "value" },
436
438
  series: [x],
437
439
  tooltip: { trigger: "axis" }
@@ -439,52 +441,80 @@ function me(e, r, i) {
439
441
  return Array.isArray(A) && A.length > 0 && (x.markLine = {
440
442
  silent: !0,
441
443
  symbol: "none",
442
- data: A.map((f) => {
444
+ data: A.map((y) => {
443
445
  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;
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 j(e) {
452
+ function I(e) {
451
453
  if (e.length === 0) return [];
452
454
  const r = e[0];
453
455
  return Object.keys(r).filter((i) => typeof r[i] == "number");
454
456
  }
455
- function I(e, r) {
457
+ function V(e, r) {
456
458
  const i = { ...e };
457
459
  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;
460
+ const s = e[t], n = r[t];
461
+ z(s) && z(n) ? i[t] = V(s, n) : i[t] = n;
460
462
  }
461
463
  return i;
462
464
  }
463
- function N(e) {
465
+ function z(e) {
464
466
  return e != null && typeof e == "object" && !Array.isArray(e);
465
467
  }
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;
468
+ function xe(e, r) {
469
+ return (i) => {
470
+ let t;
471
+ if (e.type) {
472
+ const s = e.type === "currency" && e.currency ? `currency:${e.currency}` : e.type;
473
+ t = q(i, s, r), e.type === "percent" && (t = typeof i == "number" ? new Intl.NumberFormat(r, { maximumFractionDigits: e.decimals ?? 2 }).format(i) + "%" : String(i) + "%");
474
+ } else
475
+ t = String(i);
476
+ if (e.decimals !== void 0 && e.type === "number") {
477
+ const s = Number(i);
478
+ isNaN(s) || (t = new Intl.NumberFormat(r, {
479
+ minimumFractionDigits: e.decimals,
480
+ maximumFractionDigits: e.decimals
481
+ }).format(s));
482
+ }
483
+ return e.prefix && (t = e.prefix + t), e.suffix && (t = t + e.suffix), t;
484
+ };
485
+ }
486
+ function L(e, r, i, t) {
487
+ if (!i || !e[r]) return;
488
+ const s = xe(i, t), n = e[r];
489
+ if (Array.isArray(n))
490
+ e[r] = n.map((u) => u.type === "value" ? { ...u, axisLabel: { ...u.axisLabel ?? {}, formatter: s } } : u);
491
+ else if (z(n)) {
492
+ const u = n;
493
+ e[r] = { ...u, axisLabel: { ...u.axisLabel ?? {}, formatter: s } };
494
+ }
495
+ }
496
+ var ge = Object.defineProperty, Ae = Object.getOwnPropertyDescriptor, D = (e, r, i, t) => {
497
+ for (var s = t > 1 ? void 0 : t ? Ae(r, i) : r, n = e.length - 1, u; n >= 0; n--)
498
+ (u = e[n]) && (s = (t ? u(r, i, s) : u(s)) || s);
499
+ return t && s && ge(r, i, s), s;
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
519
  let k = class extends E {
490
520
  constructor() {
@@ -534,19 +564,19 @@ let k = class extends E {
534
564
  }
535
565
  _updateChart() {
536
566
  if (!this._chart || !this.spec) return;
537
- const e = ae(this.spec), r = this._readThemeColors();
567
+ const e = le(this.spec), r = this._readThemeColors();
538
568
  r.length > 0 && (e.color = r), this._readCSSVar("--u-widget-bg") && (e.backgroundColor = "transparent"), this._applyThemeStyle(e), this._chart.setOption(e, !0);
539
569
  }
540
570
  _applyThemeStyle(e) {
541
571
  const r = this._readCSSVar("--u-widget-text"), i = this._readCSSVar("--u-widget-text-secondary"), t = this._readCSSVar("--u-widget-border");
542
572
  if (!r) return;
543
573
  e.textStyle = { ...e.textStyle, color: r };
544
- const n = {
574
+ const s = {
545
575
  axisLabel: { color: i || r },
546
576
  axisLine: { lineStyle: { color: t || i } },
547
577
  splitLine: { lineStyle: { color: t } }
548
578
  };
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 } });
579
+ e.xAxis && typeof e.xAxis == "object" && (e.xAxis = { ...e.xAxis, ...s }), e.yAxis && typeof e.yAxis == "object" && (e.yAxis = { ...e.yAxis, ...s }), e.legend && typeof e.legend == "object" && (e.legend = { ...e.legend, textStyle: { color: r } });
550
580
  }
551
581
  _readThemeColors() {
552
582
  const e = [];
@@ -573,7 +603,7 @@ let k = class extends E {
573
603
  }
574
604
  };
575
605
  k.styles = [
576
- W,
606
+ G,
577
607
  P`
578
608
  :host {
579
609
  display: block;
@@ -592,14 +622,14 @@ k.styles = [
592
622
  }
593
623
  `
594
624
  ];
595
- V([
596
- D({ type: Object })
625
+ D([
626
+ $({ type: Object })
597
627
  ], k.prototype, "spec", 2);
598
- k = V([
599
- $("uw-chart")
628
+ k = D([
629
+ B("uw-chart")
600
630
  ], k);
601
631
  export {
602
632
  k as UwChart,
603
- ae as toEChartsOption
633
+ le as toEChartsOption
604
634
  };
605
635
  //# sourceMappingURL=u-widgets-charts.js.map