@worm-print-platform/echarts 1.5.2 → 1.6.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.
@@ -0,0 +1,933 @@
1
+ /*!
2
+ * @worm-print-platform/echarts v1.6.0
3
+ * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
+ * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
+ * SPDX-License-Identifier: MIT
6
+ */import { getPluginConfig as ee, configurePlugin as te, defineElementPlugin as re, getElementPluginById as ae, registerElementPlugin as z } from "@worm-print-platform/core/designer";
7
+ import { evaluateTemplate as ne } from "@worm-print-platform/core";
8
+ import { BarChart as ie, LineChart as se, PieChart as oe, ScatterChart as le, RadarChart as ce, FunnelChart as ue, GaugeChart as fe } from "echarts/charts";
9
+ import { GridComponent as de, TooltipComponent as ye, LegendComponent as pe, TitleComponent as he, DatasetComponent as be } from "echarts/components";
10
+ import * as N from "echarts/core";
11
+ import { SVGRenderer as ge } from "echarts/renderers";
12
+ const b = ["left", "top", "width", "height", "chartOption"], T = ["dataSource", "categoryField", "valueFields", "seriesField"], g = ["title", "legend", "palette"], $ = [
13
+ {
14
+ type: "barChart",
15
+ label: "柱状图",
16
+ icon: "ChartColumn",
17
+ seriesType: "bar",
18
+ orientation: "vertical",
19
+ fields: [...T, ...g, "stack", "label"],
20
+ requiredOptionKeys: b,
21
+ defaultWidth: 100,
22
+ defaultHeight: 60,
23
+ notes: "柱状图:类目 + 多个数值字段,每字段一个 series;series[].data 写 $data 占位;固定高,禁止 autoHeight"
24
+ },
25
+ {
26
+ type: "barHChart",
27
+ label: "条形图",
28
+ icon: "ChartBar",
29
+ seriesType: "bar",
30
+ orientation: "horizontal",
31
+ fields: [...T, ...g, "stack", "label"],
32
+ requiredOptionKeys: b,
33
+ defaultWidth: 100,
34
+ defaultHeight: 60,
35
+ notes: "横向条形图:xAxis 为数值、yAxis 为类目;类目写 yAxis.data 的 $data 占位"
36
+ },
37
+ {
38
+ type: "lineChart",
39
+ label: "折线图",
40
+ icon: "ChartLine",
41
+ seriesType: "line",
42
+ fields: [...T, ...g, "stack", "label"],
43
+ requiredOptionKeys: b,
44
+ defaultWidth: 100,
45
+ defaultHeight: 60,
46
+ notes: "折线图:类目 + 多个数值字段;不写 areaStyle"
47
+ },
48
+ {
49
+ type: "areaChart",
50
+ label: "面积图",
51
+ icon: "ChartArea",
52
+ seriesType: "line",
53
+ fields: [...T, ...g, "stack", "label"],
54
+ requiredOptionKeys: b,
55
+ defaultWidth: 100,
56
+ defaultHeight: 60,
57
+ notes: "面积图:折线 + series[].areaStyle;其余同折线图"
58
+ },
59
+ {
60
+ type: "pieChart",
61
+ label: "饼图",
62
+ icon: "ChartPie",
63
+ seriesType: "pie",
64
+ fields: ["dataSource", "categoryField", "valueFields", ...g, "label"],
65
+ requiredOptionKeys: b,
66
+ defaultWidth: 60,
67
+ defaultHeight: 60,
68
+ notes: "饼图:类目 + 首个数值字段生成 { name, value };只需一个数值字段"
69
+ },
70
+ {
71
+ type: "doughnutChart",
72
+ label: "环形图",
73
+ icon: "Donut",
74
+ seriesType: "pie",
75
+ fields: ["dataSource", "categoryField", "valueFields", ...g, "innerRadius", "label"],
76
+ requiredOptionKeys: b,
77
+ defaultWidth: 60,
78
+ defaultHeight: 60,
79
+ notes: "环形图:饼图 + radius:[内径,外径];内径由面板配置"
80
+ },
81
+ {
82
+ type: "scatterChart",
83
+ label: "散点图",
84
+ icon: "ChartScatter",
85
+ seriesType: "scatter",
86
+ fields: ["dataSource", "categoryField", "valueFields", ...g, "bubble", "label"],
87
+ requiredOptionKeys: b,
88
+ defaultWidth: 80,
89
+ defaultHeight: 60,
90
+ notes: "散点图:类目字段作 x、首个数值字段作 y;chartBubble 开启时用第二个数值字段作点大小"
91
+ },
92
+ {
93
+ type: "radarChart",
94
+ label: "雷达图",
95
+ icon: "Radar",
96
+ seriesType: "radar",
97
+ fields: ["dataSource", "categoryField", "valueFields", ...g, "radius", "label"],
98
+ requiredOptionKeys: b,
99
+ defaultWidth: 70,
100
+ defaultHeight: 60,
101
+ notes: "雷达图:每个数值字段是一个维度(radar.indicator),每行数据是一个系列(类目字段作系列名);半径由面板写 radar.radius(%,默认 75)"
102
+ },
103
+ {
104
+ type: "funnelChart",
105
+ label: "漏斗图",
106
+ icon: "Funnel",
107
+ seriesType: "funnel",
108
+ fields: ["dataSource", "categoryField", "valueFields", ...g, "padding", "label"],
109
+ requiredOptionKeys: b,
110
+ defaultWidth: 60,
111
+ defaultHeight: 60,
112
+ notes: "漏斗图:类目 + 首个数值字段,按数值降序;四边内边距由面板写 series.left/right/top/bottom(%,右侧需留外置标签空间)"
113
+ },
114
+ {
115
+ type: "gaugeChart",
116
+ label: "仪表盘",
117
+ icon: "Gauge",
118
+ seriesType: "gauge",
119
+ fields: ["dataSource", "valueFields", ...g, "gaugeRange", "label"],
120
+ requiredOptionKeys: b,
121
+ defaultWidth: 60,
122
+ defaultHeight: 60,
123
+ notes: "仪表盘:取首行数据的首个数值字段作指针值;min/max 由面板写入 series[0].min/max"
124
+ }
125
+ ], st = $.map((e) => e.type);
126
+ function p(e) {
127
+ return $.find((t) => t.type === e);
128
+ }
129
+ function ot(e) {
130
+ return p(e)?.fields ?? [];
131
+ }
132
+ function me(e) {
133
+ const t = typeof e == "number" ? e : Number(e);
134
+ return Number.isFinite(t) ? t : 0;
135
+ }
136
+ function D(e, t, r = !1) {
137
+ if (typeof e == "string")
138
+ return e.startsWith("$data") || r ? e : e.includes("{") ? ne(e, t) : e;
139
+ if (Array.isArray(e)) return e.map((a) => D(a, t, r));
140
+ if (e && typeof e == "object") {
141
+ const a = {};
142
+ for (const [n, i] of Object.entries(e)) {
143
+ const o = r || n === "label" || n === "detail";
144
+ a[n] = D(i, t, o);
145
+ }
146
+ return a;
147
+ }
148
+ return e;
149
+ }
150
+ function A(e) {
151
+ return Array.isArray(e.data) && e.data.includes("$data");
152
+ }
153
+ function Ae(e, t) {
154
+ const r = e.dataSource;
155
+ if (typeof r == "string" && Array.isArray(t[r])) return t[r];
156
+ for (const a of Object.values(t))
157
+ if (Array.isArray(a)) return a;
158
+ return [];
159
+ }
160
+ function K(e) {
161
+ return typeof e == "string" && e.length > 0 ? e : void 0;
162
+ }
163
+ function Se(e) {
164
+ return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.length > 0) : [];
165
+ }
166
+ function C(e) {
167
+ return Array.isArray(e.series) ? e.series : [];
168
+ }
169
+ function m(e, t) {
170
+ return t ? me(e[t]) : 0;
171
+ }
172
+ function B(e, t) {
173
+ for (const r of ["xAxis", "yAxis"]) {
174
+ const a = e[r], n = Array.isArray(a) ? a : a ? [a] : [];
175
+ for (const i of n)
176
+ i && typeof i == "object" && Array.isArray(i.data) && i.data.includes("$data") && (i.data = [...t]);
177
+ }
178
+ }
179
+ function xe(e, t, r, a, n) {
180
+ const i = C(e);
181
+ if (!i.some(A)) return;
182
+ const o = t.map((c, u) => r ? c[r] : u + 1), l = (c) => a[Math.min(c, a.length - 1)];
183
+ if (n) {
184
+ const c = i[0], u = /* @__PURE__ */ new Map();
185
+ for (const d of t) {
186
+ const y = String(d[n] ?? ""), h = u.get(y) ?? /* @__PURE__ */ new Map(), j = String(d[r ?? ""]);
187
+ h.set(j, (h.get(j) ?? 0) + m(d, l(0))), u.set(y, h);
188
+ }
189
+ const f = [...new Set(o)];
190
+ e.series = [...u.entries()].map(([d, y]) => ({
191
+ ...c,
192
+ name: d,
193
+ data: f.map((h) => y.get(String(h)) ?? null)
194
+ })), B(e, f);
195
+ return;
196
+ }
197
+ const s = i[i.length - 1];
198
+ for (; i.length < a.length; ) i.push({ ...s, data: ["$data"] });
199
+ e.series = i.map((c, u) => A(c) ? { ...c, data: t.map((f) => m(f, l(u))) } : c), B(e, o);
200
+ }
201
+ function U(e, t, r, a, n) {
202
+ const i = C(e);
203
+ if (!i.some(A)) return;
204
+ const o = t.map((l) => ({
205
+ name: r ? String(l[r] ?? "") : "",
206
+ value: m(l, a)
207
+ }));
208
+ n && o.sort((l, s) => s.value - l.value), e.series = i.map((l) => ({ ...l, data: o }));
209
+ }
210
+ function Ce(e, t, r, a, n) {
211
+ const i = C(e);
212
+ if (!i.some(A)) return;
213
+ const o = a[0], l = n ? a[1] : void 0, s = l ? t.map((d) => m(d, l)) : [], c = s.length > 0 ? Math.min(...s) : 0, u = s.length > 0 ? Math.max(...s) : 0, f = (d) => u === c ? 12 : Math.round(6 + (d - c) / (u - c) * 18);
214
+ e.series = i.map((d) => ({
215
+ ...d,
216
+ data: t.map((y) => {
217
+ const h = [m(y, r), m(y, o)];
218
+ return l ? { value: h, symbolSize: f(m(y, l)) } : h;
219
+ })
220
+ }));
221
+ }
222
+ function ve(e) {
223
+ if (e <= 0) return 10;
224
+ const t = 10 ** Math.floor(Math.log10(e)), r = t >= 10 ? t : 10;
225
+ return Math.ceil(e / r) * r;
226
+ }
227
+ function Te(e, t, r, a) {
228
+ const n = C(e);
229
+ if (!n.some(A)) return;
230
+ const i = a.map((o) => Math.max(0, ...t.map((l) => m(l, o))));
231
+ e.radar = {
232
+ ...e.radar ?? {},
233
+ // 维度 = 数值字段;max 取该列最大值上浮取整
234
+ indicator: a.map((o, l) => ({ name: o, max: ve(i[l]) }))
235
+ }, e.series = n.map((o) => ({
236
+ ...o,
237
+ data: t.map((l) => ({
238
+ name: r ? String(l[r] ?? "") : "",
239
+ value: a.map((s) => m(l, s))
240
+ }))
241
+ }));
242
+ }
243
+ function Oe(e, t, r) {
244
+ const a = C(e);
245
+ if (!a.some(A)) return;
246
+ const n = t[0] ?? {};
247
+ e.series = a.map((i) => ({ ...i, data: [{ value: m(n, r), name: r }] }));
248
+ }
249
+ function ke(e, t, r) {
250
+ const a = t.chartOption;
251
+ if (!a || typeof a != "object" || Array.isArray(a)) return {};
252
+ const n = D(a, r), i = Se(t.chartValueFields);
253
+ if (i.length === 0) return { _chartOption: n };
254
+ const o = Ae({ ...t, dataSource: t.chartDataSource ?? t.dataSource }, r);
255
+ if (o.length === 0) return { _chartOption: n };
256
+ const l = K(t.chartCategoryField);
257
+ switch (p(e)?.seriesType) {
258
+ case "radar":
259
+ Te(n, o, l, i);
260
+ break;
261
+ case "gauge":
262
+ Oe(n, o, i[0]);
263
+ break;
264
+ case "funnel":
265
+ U(n, o, l, i[0], !0);
266
+ break;
267
+ case "pie":
268
+ U(n, o, l, i[0], !1);
269
+ break;
270
+ case "scatter":
271
+ Ce(n, o, l, i, t.chartBubble === !0);
272
+ break;
273
+ default:
274
+ xe(n, o, l, i, K(t.chartSeriesField));
275
+ break;
276
+ }
277
+ return { _chartOption: n };
278
+ }
279
+ const _ = "@worm-print-platform/echarts", q = [
280
+ { key: "default", label: "默认蓝", colors: ["#5470c6", "#91cc75", "#fac858", "#ee6666", "#73c0de"] },
281
+ { key: "fresh", label: "清新绿", colors: ["#2f9e6e", "#5cc9a7", "#9ad6c1", "#f2c94c", "#4a90e2"] },
282
+ { key: "warm", label: "暖橙红", colors: ["#f2704e", "#f7a35c", "#f7d56d", "#c54e3f", "#8f5a4a"] },
283
+ { key: "purple", label: "紫灰", colors: ["#7b61ff", "#9b8cff", "#c3baff", "#596275", "#8d99ae"] }
284
+ ], Ee = ["示例一", "示例二", "示例三"], Fe = { top: 6, right: 25, bottom: 6, left: 5 }, Le = 75, we = 50, O = { top: 60, right: 80, bottom: 65, left: 80 }, G = { left: "8%", right: "8%", bottom: "12%", top: "18%", containLabel: !0 };
285
+ function _e(e) {
286
+ return {
287
+ top: `${e.top}%`,
288
+ right: `${e.right}%`,
289
+ bottom: `${e.bottom}%`,
290
+ left: `${e.left}%`
291
+ };
292
+ }
293
+ function Re(e) {
294
+ const t = p(e), r = { text: "" };
295
+ switch (t?.seriesType) {
296
+ case "pie":
297
+ return {
298
+ title: r,
299
+ tooltip: { trigger: "item" },
300
+ series: [{
301
+ type: "pie",
302
+ name: "数量",
303
+ data: ["$data"],
304
+ radius: e === "doughnutChart" ? ["40%", "70%"] : "62%"
305
+ }]
306
+ };
307
+ case "scatter":
308
+ return {
309
+ title: r,
310
+ grid: G,
311
+ tooltip: { trigger: "axis" },
312
+ xAxis: { type: "value" },
313
+ yAxis: { type: "value" },
314
+ series: [{ type: "scatter", name: "数量", data: ["$data"], symbolSize: 8 }]
315
+ };
316
+ case "radar":
317
+ return {
318
+ title: r,
319
+ tooltip: { trigger: "item" },
320
+ // indicator 由绑定阶段按 chartValueFields 生成;设计态预览见 previewChartOption
321
+ radar: { indicator: [], radius: `${Le}%` },
322
+ series: [{ type: "radar", name: "数量", data: ["$data"] }]
323
+ };
324
+ case "funnel":
325
+ return {
326
+ title: r,
327
+ tooltip: { trigger: "item" },
328
+ legend: { show: !1 },
329
+ // 不写内边距会吃 ECharts 的 px 默认(左右 80/上下 60~65),小框里图形只占一半不到
330
+ series: [{ type: "funnel", name: "数量", data: ["$data"], sort: "descending", ..._e(Fe) }]
331
+ };
332
+ case "gauge":
333
+ return {
334
+ title: r,
335
+ tooltip: { trigger: "item" },
336
+ series: [{ type: "gauge", name: "数量", min: 0, max: 100, data: [{ value: 0, name: "数量" }] }]
337
+ };
338
+ default: {
339
+ const a = t?.orientation === "horizontal", n = t?.seriesType === "line" && e === "areaChart", i = t?.seriesType === "line" ? "line" : "bar";
340
+ return {
341
+ title: r,
342
+ grid: G,
343
+ tooltip: { trigger: "axis" },
344
+ xAxis: a ? { type: "value" } : { type: "category", data: ["$data"] },
345
+ yAxis: a ? { type: "category", data: ["$data"] } : { type: "value" },
346
+ series: [{ type: i, name: "数量", data: ["$data"], ...n ? { areaStyle: {} } : {} }]
347
+ };
348
+ }
349
+ }
350
+ }
351
+ function lt(e) {
352
+ te(_, e);
353
+ }
354
+ function R() {
355
+ return ee(_);
356
+ }
357
+ function ct() {
358
+ const e = R().palettes ?? {}, t = q.map((a) => {
359
+ const n = e[a.key];
360
+ return n ? { key: a.key, label: n.label ?? a.label, colors: n.colors } : { key: a.key, label: a.label, colors: a.colors };
361
+ }), r = Object.entries(e).filter(([a]) => !q.some((n) => n.key === a)).map(([a, n]) => ({ key: a, label: n.label ?? a, colors: n.colors }));
362
+ return [...t, ...r];
363
+ }
364
+ function Pe() {
365
+ const e = R().sampleCategories;
366
+ return Array.isArray(e) && e.length > 0 ? e : Ee;
367
+ }
368
+ function De(e, t) {
369
+ const r = R(), a = p(e);
370
+ return {
371
+ width: typeof r.defaultWidth == "number" ? r.defaultWidth : a?.defaultWidth ?? 100,
372
+ height: typeof r.defaultHeight == "number" ? r.defaultHeight : a?.defaultHeight ?? 60,
373
+ title: a?.label ?? "图表",
374
+ chartOption: Re(e),
375
+ chartDataSource: "",
376
+ chartCategoryField: "name",
377
+ chartValueFields: ["value"],
378
+ chartSeriesField: "",
379
+ ...t
380
+ };
381
+ }
382
+ N.use([
383
+ ie,
384
+ se,
385
+ oe,
386
+ le,
387
+ ce,
388
+ ue,
389
+ fe,
390
+ de,
391
+ ye,
392
+ pe,
393
+ he,
394
+ be,
395
+ ge
396
+ ]);
397
+ const V = /* @__PURE__ */ new Set();
398
+ function Me() {
399
+ const t = (R().components ?? []).filter((r) => r != null && !V.has(r));
400
+ if (t.length !== 0) {
401
+ N.use(t);
402
+ for (const r of t) V.add(r);
403
+ }
404
+ }
405
+ const Ne = 96 / 25.4;
406
+ function S(e) {
407
+ const t = Number.isFinite(e) ? e : 0;
408
+ return Math.max(1, Math.round(t * Ne));
409
+ }
410
+ const $e = [12, 20, 15];
411
+ function v(e) {
412
+ try {
413
+ return JSON.parse(JSON.stringify(e));
414
+ } catch {
415
+ return e;
416
+ }
417
+ }
418
+ function ut(e, t) {
419
+ if (!t || typeof t != "object" || Array.isArray(t)) return {};
420
+ const r = v(t), a = p(e), n = [...Pe()], i = [...$e], o = Array.isArray(r.series) ? r.series : [], l = (c) => {
421
+ for (const u of o)
422
+ Array.isArray(u.data) && u.data.includes("$data") && (u.data = c(u));
423
+ }, s = () => {
424
+ for (const c of ["xAxis", "yAxis"]) {
425
+ const u = Array.isArray(r[c]) ? r[c] : r[c] ? [r[c]] : [];
426
+ for (const f of u)
427
+ f && Array.isArray(f.data) && f.data.includes("$data") && (f.data = [...n]);
428
+ }
429
+ };
430
+ switch (a?.seriesType) {
431
+ case "pie":
432
+ l(() => n.map((c, u) => ({ name: c, value: i[u] ?? 10 })));
433
+ break;
434
+ case "funnel":
435
+ l(() => n.map((c, u) => ({ name: c, value: i[u] ?? 10 })));
436
+ break;
437
+ case "scatter":
438
+ l(() => i.map((c) => [c, c + 6]));
439
+ break;
440
+ case "radar":
441
+ r.radar = {
442
+ ...r.radar ?? {},
443
+ indicator: n.map((c) => ({ name: c, max: 30 }))
444
+ }, l(() => [{ name: "示例", value: i }]);
445
+ break;
446
+ case "gauge":
447
+ l(() => [{ value: i[0] ?? 40, name: "数量" }]);
448
+ break;
449
+ default:
450
+ l(() => [...i]), s();
451
+ break;
452
+ }
453
+ return r;
454
+ }
455
+ function ft(e, t) {
456
+ const r = Array.isArray(e?.color) ? (e?.color).map(String) : [];
457
+ return t.find((n) => n.colors.every((i, o) => i === r[o]) && r.length === n.colors.length)?.key ?? "default";
458
+ }
459
+ function J(e) {
460
+ return Array.isArray(e) ? e[0] && typeof e[0] == "object" ? { ...e[0] } : {} : e && typeof e == "object" ? { ...e } : {};
461
+ }
462
+ function dt(e, t, r) {
463
+ const a = v(e), n = Array.isArray(a.series) ? a.series : [], i = p(r), o = n[0] ?? { type: i?.seriesType === "line" ? "line" : "bar", data: ["$data"] };
464
+ return a.series = Array.from({ length: Math.max(t, 1) }, (l, s) => ({
465
+ ...o,
466
+ ...n[s] ?? {},
467
+ data: ["$data"]
468
+ })), a;
469
+ }
470
+ const P = (e) => Math.round(e * 10) / 10;
471
+ function M(e, t) {
472
+ return t > 0 ? P(e / t * 100) : 0;
473
+ }
474
+ function k(e, t, r) {
475
+ if (typeof e == "string" && e.trim().endsWith("%")) {
476
+ const a = Number.parseFloat(e);
477
+ if (Number.isFinite(a)) return P(a);
478
+ }
479
+ return typeof e == "number" && Number.isFinite(e) ? M(e, t) : M(r, t);
480
+ }
481
+ function Q(e, t, r) {
482
+ return Math.min(r, Math.max(t, e));
483
+ }
484
+ function x(e) {
485
+ return `${Q(P(e), 0, 100)}%`;
486
+ }
487
+ function He(e) {
488
+ const r = (Array.isArray(e.series) ? e.series : [])[0];
489
+ return r && typeof r == "object" ? r : {};
490
+ }
491
+ function yt(e, t, r) {
492
+ const n = He(e && typeof e == "object" ? e : {}), i = S(t), o = S(r);
493
+ return {
494
+ top: k(n.top, o, O.top),
495
+ right: k(n.right, i, O.right),
496
+ bottom: k(n.bottom, o, O.bottom),
497
+ left: k(n.left, i, O.left)
498
+ };
499
+ }
500
+ function pt(e, t) {
501
+ const r = v(e), a = Array.isArray(r.series) ? r.series : [];
502
+ a.length === 0 && a.push({ type: "funnel", data: ["$data"] });
503
+ const n = a[0];
504
+ return n.top = x(t.top), n.right = x(t.right), n.bottom = x(t.bottom), n.left = x(t.left), r.series = a, r;
505
+ }
506
+ function ht(e, t, r) {
507
+ const n = J((e && typeof e == "object" ? e : {}).radar).radius, i = Array.isArray(n) ? n[n.length - 1] : n, o = S(t), l = S(r), s = Math.min(o, l) / 2;
508
+ if (typeof i == "string" && i.trim().endsWith("%")) {
509
+ const c = Number.parseFloat(i);
510
+ if (Number.isFinite(c)) return P(c);
511
+ }
512
+ return typeof i == "number" && Number.isFinite(i) ? M(i, s) : we;
513
+ }
514
+ function bt(e, t) {
515
+ const r = v(e);
516
+ return r.radar = { ...J(r.radar), radius: x(Q(t, 20, 100)) }, r;
517
+ }
518
+ const gt = [
519
+ { key: "value", label: "数值", formatter: "{c}" },
520
+ { key: "name-value", label: "名称: 数值", formatter: "{b}: {c}" },
521
+ { key: "name", label: "名称", formatter: "{b}" },
522
+ { key: "percent", label: "百分比", formatter: "{d}%" }
523
+ ], mt = {
524
+ bar: [
525
+ { value: "top", label: "顶部" },
526
+ { value: "inside", label: "内部" },
527
+ { value: "insideTop", label: "内部顶端" },
528
+ { value: "bottom", label: "底部" },
529
+ { value: "insideBottom", label: "内部底端" },
530
+ { value: "right", label: "右侧" },
531
+ { value: "left", label: "左侧" },
532
+ { value: "middle", label: "居中" }
533
+ ],
534
+ line: [
535
+ { value: "top", label: "顶部" },
536
+ { value: "bottom", label: "底部" },
537
+ { value: "inside", label: "内部" },
538
+ { value: "left", label: "左侧" },
539
+ { value: "right", label: "右侧" }
540
+ ],
541
+ pie: [
542
+ { value: "outside", label: "外侧" },
543
+ { value: "inside", label: "内部" },
544
+ { value: "center", label: "中心" }
545
+ ],
546
+ scatter: [
547
+ { value: "top", label: "顶部" },
548
+ { value: "bottom", label: "底部" },
549
+ { value: "left", label: "左侧" },
550
+ { value: "right", label: "右侧" },
551
+ { value: "inside", label: "内部" }
552
+ ],
553
+ radar: [
554
+ { value: "top", label: "顶部" },
555
+ { value: "bottom", label: "底部" },
556
+ { value: "left", label: "左侧" },
557
+ { value: "right", label: "右侧" },
558
+ { value: "inside", label: "内部" }
559
+ ],
560
+ funnel: [
561
+ { value: "outer", label: "外侧" },
562
+ { value: "inner", label: "内部" },
563
+ { value: "left", label: "左侧" },
564
+ { value: "right", label: "右侧" },
565
+ { value: "top", label: "顶部" },
566
+ { value: "bottom", label: "底部" }
567
+ ],
568
+ gauge: []
569
+ }, Ie = {
570
+ bar: !1,
571
+ line: !1,
572
+ pie: !0,
573
+ scatter: !1,
574
+ radar: !1,
575
+ funnel: !0,
576
+ gauge: !0
577
+ }, We = {
578
+ bar: { position: "top", fontSize: 12 },
579
+ line: { position: "top", fontSize: 12 },
580
+ pie: { position: "outside", overflow: "none", fontSize: 11 },
581
+ scatter: { position: "top", fontSize: 11 },
582
+ radar: { position: "top", fontSize: 10 },
583
+ funnel: { position: "outer", fontSize: 11 },
584
+ gauge: { fontSize: 14 }
585
+ }, je = {
586
+ barHChart: { position: "right", fontSize: 12 }
587
+ }, ze = {
588
+ bar: [
589
+ "formatter",
590
+ "overflow",
591
+ "position",
592
+ "rotate",
593
+ "offset",
594
+ "fontSize",
595
+ "fontWeight",
596
+ "color",
597
+ "backgroundColor",
598
+ "borderColor",
599
+ "borderWidth",
600
+ "borderRadius",
601
+ "padding"
602
+ ],
603
+ line: [
604
+ "formatter",
605
+ "overflow",
606
+ "position",
607
+ "rotate",
608
+ "offset",
609
+ "fontSize",
610
+ "fontWeight",
611
+ "color",
612
+ "backgroundColor",
613
+ "borderColor",
614
+ "borderWidth",
615
+ "borderRadius",
616
+ "padding"
617
+ ],
618
+ pie: [
619
+ "formatter",
620
+ "overflow",
621
+ "position",
622
+ "distance",
623
+ "offset",
624
+ "fontSize",
625
+ "fontWeight",
626
+ "color",
627
+ "backgroundColor",
628
+ "borderColor",
629
+ "borderWidth",
630
+ "borderRadius",
631
+ "padding",
632
+ "labelLine.show",
633
+ "labelLine.length",
634
+ "labelLine.length2",
635
+ "labelLine.smooth"
636
+ ],
637
+ scatter: [
638
+ "formatter",
639
+ "overflow",
640
+ "position",
641
+ "distance",
642
+ "rotate",
643
+ "offset",
644
+ "fontSize",
645
+ "fontWeight",
646
+ "color",
647
+ "backgroundColor",
648
+ "borderColor",
649
+ "borderWidth",
650
+ "borderRadius",
651
+ "padding"
652
+ ],
653
+ radar: ["formatter", "fontSize", "fontWeight", "color"],
654
+ funnel: [
655
+ "formatter",
656
+ "overflow",
657
+ "position",
658
+ "distance",
659
+ "fontSize",
660
+ "fontWeight",
661
+ "color",
662
+ "labelLine.show",
663
+ "labelLine.length",
664
+ "labelLine.smooth"
665
+ ],
666
+ gauge: ["formatter", "fontSize", "fontWeight", "color", "offset"]
667
+ }, Ke = [
668
+ "formatter",
669
+ "overflow",
670
+ "position",
671
+ "distance",
672
+ "rotate",
673
+ "offset",
674
+ "fontSize",
675
+ "fontWeight",
676
+ "color",
677
+ "backgroundColor",
678
+ "borderColor",
679
+ "borderWidth",
680
+ "borderRadius",
681
+ "padding"
682
+ ];
683
+ function Be(e) {
684
+ const t = e?.series;
685
+ return Array.isArray(t) ? t : [];
686
+ }
687
+ function L(e) {
688
+ return e && typeof e == "object" && !Array.isArray(e) ? { ...e } : {};
689
+ }
690
+ function H(e) {
691
+ typeof e.offsetX != "number" && typeof e.offsetY != "number" || (Array.isArray(e.offset) || (e.offset = [
692
+ typeof e.offsetX == "number" ? e.offsetX : 0,
693
+ typeof e.offsetY == "number" ? e.offsetY : 0
694
+ ]), delete e.offsetX, delete e.offsetY);
695
+ }
696
+ function I(e) {
697
+ return p(e)?.seriesType === "gauge" ? "detail" : "label";
698
+ }
699
+ function At(e) {
700
+ const t = p(e);
701
+ return t ? ze[t.seriesType] : [];
702
+ }
703
+ function St(e, t) {
704
+ const r = p(t), a = Be(e), n = L(a[0]?.[I(t)]);
705
+ H(n);
706
+ const i = {
707
+ show: typeof n.show == "boolean" ? n.show : r ? Ie[r.seriesType] : !1,
708
+ // labelLine 在 ECharts 里是 series 顶层键(与 label 平级),不是 label 的子键
709
+ labelLine: L(a[0]?.labelLine)
710
+ };
711
+ for (const l of Ke) {
712
+ const s = n[l];
713
+ l !== "offset" && (typeof s == "string" || typeof s == "number") && (i[l] = s);
714
+ }
715
+ const o = n.offset;
716
+ return Array.isArray(o) && typeof o[0] == "number" && typeof o[1] == "number" && (i.offset = [o[0], o[1]]), i;
717
+ }
718
+ function Ue(e) {
719
+ const t = p(e);
720
+ return t ? { ...We[t.seriesType], ...je[e] } : {};
721
+ }
722
+ function Y(e) {
723
+ return e == null || e === "";
724
+ }
725
+ function xt(e, t, r) {
726
+ const a = v(e ?? {}), n = Array.isArray(a.series) ? a.series : [];
727
+ if (!p(t) || n.length === 0) return a;
728
+ const o = I(t), { enabled: l, labelLine: s, ...c } = r;
729
+ for (const u of n) {
730
+ if (!u || typeof u != "object") continue;
731
+ const f = L(u[o]);
732
+ H(f), l === !0 ? Object.assign(f, { ...Ue(t), ...f, show: !0 }) : l === !1 && (f.show = !1);
733
+ for (const [d, y] of Object.entries(c))
734
+ Y(y) ? delete f[d] : f[d] = y;
735
+ if (s) {
736
+ const d = L(u.labelLine);
737
+ for (const [y, h] of Object.entries(s))
738
+ Y(h) ? delete d[y] : d[y] = h;
739
+ u.labelLine = d;
740
+ }
741
+ u[o] = f;
742
+ }
743
+ return a;
744
+ }
745
+ function qe(e) {
746
+ return Array.isArray(e) ? e.map((t) => ({ ...t })) : [];
747
+ }
748
+ function Ge(e, t) {
749
+ const r = { ...e, type: t ? "value" : "category" };
750
+ return t ? delete r.data : Array.isArray(r.data) || (r.data = ["$data"]), r;
751
+ }
752
+ function Ve(e, t) {
753
+ const r = { ...e, type: t ? "category" : "value" };
754
+ return t && !Array.isArray(r.data) && (r.data = ["$data"]), t || delete r.data, r;
755
+ }
756
+ function E(e, t) {
757
+ return Array.isArray(e) ? e.map((r) => t({ ...r })) : t(e && typeof e == "object" ? { ...e } : {});
758
+ }
759
+ function Ye(e, t) {
760
+ const r = p(e);
761
+ if (!r) return t;
762
+ const a = structuredClone(t), n = qe(a.series);
763
+ if (n.length === 0) return a;
764
+ const i = I(e);
765
+ for (const s of n) {
766
+ const c = s[i];
767
+ if (c && typeof c == "object" && !Array.isArray(c)) {
768
+ const u = { ...c };
769
+ H(u), s[i] = u;
770
+ }
771
+ }
772
+ if (r.seriesType === "pie")
773
+ return a.series = n.map((s) => ({
774
+ ...s,
775
+ type: "pie",
776
+ ...e === "doughnutChart" ? { radius: s.radius ?? ["40%", "70%"] } : {}
777
+ })), delete a.xAxis, delete a.yAxis, a;
778
+ if (r.seriesType === "scatter")
779
+ return a.series = n.map((s) => ({ ...s, type: "scatter" })), a.xAxis = E(a.xAxis, (s) => ({ ...s, type: "value", data: void 0 })), a.yAxis = E(a.yAxis, (s) => ({ ...s, type: "value", data: void 0 })), a;
780
+ if (r.seriesType === "radar")
781
+ return a.series = n.map((s) => ({ ...s, type: "radar" })), a;
782
+ if (r.seriesType === "funnel")
783
+ return a.series = n.map((s) => ({ ...s, type: "funnel", sort: "descending" })), a;
784
+ if (r.seriesType === "gauge")
785
+ return a.series = n.map((s) => ({ ...s, type: "gauge" })), a;
786
+ const o = r.orientation === "horizontal", l = r.seriesType === "line" ? "line" : "bar";
787
+ return a.xAxis = E(a.xAxis, (s) => Ge(s, o)), a.yAxis = E(a.yAxis, (s) => Ve(s, o)), a.series = n.map((s) => {
788
+ const c = { ...s, type: l };
789
+ return e === "areaChart" ? c.areaStyle = s.areaStyle ?? {} : delete c.areaStyle, c;
790
+ }), a;
791
+ }
792
+ function Xe(e, t, r) {
793
+ const a = /<svg\b[^>]*>/i.exec(e);
794
+ if (!a) return e;
795
+ const n = a[0], i = n.slice(4, -1), l = (/\sstyle\s*=\s*"([^"]*)"/i.exec(i)?.[1] ?? "").split(";").map((f) => f.trim()).filter((f) => f && !/^(width|height|display)\s*:/i.test(f)).join(";"), s = i.replace(/\s(width|height|style|viewBox)\s*=\s*"[^"]*"/gi, "").trimEnd(), c = ["display:block", "width:100%", "height:100%", l].filter(Boolean).join(";"), u = `<svg${s} width="100%" height="100%" viewBox="0 0 ${t} ${r}" style="${c}">`;
796
+ return e.slice(0, a.index) + u + e.slice(a.index + n.length);
797
+ }
798
+ function Je(e) {
799
+ Me();
800
+ const t = Ye(e.type, e.option);
801
+ if (!t || typeof t != "object" || Array.isArray(t))
802
+ throw new Error("图表 option 非法:需要对象");
803
+ const r = S(e.widthMm), a = S(e.heightMm), n = N.init(null, null, { renderer: "svg", ssr: !0, width: r, height: a });
804
+ try {
805
+ const i = t.textStyle && typeof t.textStyle == "object" && !Array.isArray(t.textStyle) ? t.textStyle : void 0, o = {
806
+ ...e.fontFamily ? { fontFamily: e.fontFamily } : {},
807
+ ...i ?? {}
808
+ };
809
+ return n.setOption({
810
+ animation: !1,
811
+ ...t,
812
+ ...Object.keys(o).length > 0 ? { textStyle: o } : {}
813
+ }), Xe(n.renderToSVGString(), r, a);
814
+ } finally {
815
+ n.dispose();
816
+ }
817
+ }
818
+ function Qe(e) {
819
+ return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
820
+ }
821
+ function X(e) {
822
+ const t = e._chartOption ?? e.chartOption, r = `<span>${Qe(String(e.title ?? "图表"))}</span>`;
823
+ if (!t || typeof t != "object" || Array.isArray(t)) return r;
824
+ try {
825
+ return Je({
826
+ key: String(e.key ?? ""),
827
+ type: String(e.type ?? ""),
828
+ option: t,
829
+ widthMm: Number(e.widthMm ?? 0),
830
+ heightMm: Number(e.heightMm ?? 0),
831
+ fontFamily: typeof e.fontFamily == "string" ? e.fontFamily : void 0
832
+ });
833
+ } catch {
834
+ return r;
835
+ }
836
+ }
837
+ const Ze = "2", Z = {
838
+ chartOption: { kind: "object", label: "图表 option" },
839
+ chartDataSource: { kind: "text", label: "数据源" },
840
+ chartCategoryField: { kind: "text", label: "类目字段" },
841
+ chartValueFields: { kind: "object", label: "数值字段" },
842
+ chartSeriesField: { kind: "text", label: "系列拆分字段" }
843
+ }, et = {
844
+ ...Z,
845
+ chartBubble: { kind: "bool", label: "气泡大小" }
846
+ }, F = re({
847
+ id: _,
848
+ version: Ze,
849
+ kinds: $.map((e) => ({
850
+ type: e.type,
851
+ label: e.label,
852
+ icon: e.icon,
853
+ fixedHeight: !0,
854
+ requiredOptionKeys: e.requiredOptionKeys,
855
+ notes: e.notes,
856
+ optionMeta: e.type === "scatterChart" ? et : Z,
857
+ defaultOptions: (t) => De(e.type, t),
858
+ binding: { bind: (t, r) => ke(e.type, t, r) }
859
+ })),
860
+ render: {
861
+ html: X,
862
+ createRenderer: () => ({ render: X })
863
+ }
864
+ });
865
+ let w;
866
+ function W(e, t) {
867
+ const r = ae(_);
868
+ if (!e && !t) {
869
+ const i = z(F);
870
+ return w = i, i;
871
+ }
872
+ const a = {
873
+ ...F,
874
+ designer: e ?? r?.designer ?? F.designer,
875
+ render: { ...F.render, ...r?.render, ...t }
876
+ }, n = z(a);
877
+ return w = n, n;
878
+ }
879
+ function Ct(e) {
880
+ return W(e);
881
+ }
882
+ function vt(e) {
883
+ return W(void 0, { executorBundle: e });
884
+ }
885
+ function Tt() {
886
+ w?.(), w = void 0;
887
+ }
888
+ W();
889
+ export {
890
+ ht as A,
891
+ Ct as B,
892
+ st as C,
893
+ vt as D,
894
+ O as E,
895
+ Ee as F,
896
+ W as G,
897
+ X as H,
898
+ Je as I,
899
+ ot as J,
900
+ dt as K,
901
+ mt as L,
902
+ Tt as M,
903
+ xt as N,
904
+ pt as O,
905
+ bt as P,
906
+ Le as R,
907
+ $ as a,
908
+ q as b,
909
+ F as c,
910
+ _ as d,
911
+ we as e,
912
+ Fe as f,
913
+ gt as g,
914
+ J as h,
915
+ ke as i,
916
+ De as j,
917
+ v as k,
918
+ lt as l,
919
+ Re as m,
920
+ Xe as n,
921
+ p as o,
922
+ ct as p,
923
+ R as q,
924
+ Pe as r,
925
+ At as s,
926
+ I as t,
927
+ S as u,
928
+ Ye as v,
929
+ ut as w,
930
+ St as x,
931
+ yt as y,
932
+ ft as z
933
+ };