@worm-print-platform/echarts 1.5.3 → 1.6.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/kit.js CHANGED
@@ -1,154 +1,51 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.5.3
2
+ * @worm-print-platform/echarts v1.6.1
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
6
- */import { j as C, m as D, E as l, w as P, n as d } from "./plugin-CUoE2jMs.js";
7
- import { C as O, a as j, b as H, c as M, d as v, F as $, x as G, R as K, e as z, f as B, g as J, h as W, i as q, k as V, l as X, o as Q, p as Y, q as Z, r as rr, s as tr, t as er, u as ar, v as sr } from "./plugin-CUoE2jMs.js";
8
- const x = [12, 20, 15];
9
- function m(r) {
10
- try {
11
- return JSON.parse(JSON.stringify(r));
12
- } catch {
13
- return r;
14
- }
15
- }
16
- function R(r, e) {
17
- if (!e || typeof e != "object" || Array.isArray(e)) return {};
18
- const t = m(e), i = C(r), a = [...D()], s = [...x], o = Array.isArray(t.series) ? t.series : [], u = (n) => {
19
- for (const c of o)
20
- Array.isArray(c.data) && c.data.includes("$data") && (c.data = n(c));
21
- }, f = () => {
22
- for (const n of ["xAxis", "yAxis"]) {
23
- const c = Array.isArray(t[n]) ? t[n] : t[n] ? [t[n]] : [];
24
- for (const h of c)
25
- h && Array.isArray(h.data) && h.data.includes("$data") && (h.data = [...a]);
26
- }
27
- };
28
- switch (i?.seriesType) {
29
- case "pie":
30
- u(() => a.map((n, c) => ({ name: n, value: s[c] ?? 10 })));
31
- break;
32
- case "funnel":
33
- u(() => a.map((n, c) => ({ name: n, value: s[c] ?? 10 })));
34
- break;
35
- case "scatter":
36
- u(() => s.map((n) => [n, n + 6]));
37
- break;
38
- case "radar":
39
- t.radar = {
40
- ...t.radar ?? {},
41
- indicator: a.map((n) => ({ name: n, max: 30 }))
42
- }, u(() => [{ name: "示例", value: s }]);
43
- break;
44
- case "gauge":
45
- u(() => [{ value: s[0] ?? 40, name: "数量" }]);
46
- break;
47
- default:
48
- u(() => [...s]), f();
49
- break;
50
- }
51
- return t;
52
- }
53
- function T(r, e) {
54
- const t = Array.isArray(r?.color) ? (r?.color).map(String) : [];
55
- return e.find((a) => a.colors.every((s, o) => s === t[o]) && t.length === a.colors.length)?.key ?? "default";
56
- }
57
- function b(r) {
58
- return Array.isArray(r) ? r[0] && typeof r[0] == "object" ? { ...r[0] } : {} : r && typeof r == "object" ? { ...r } : {};
59
- }
60
- function E(r, e, t) {
61
- const i = m(r), a = Array.isArray(i.series) ? i.series : [], s = C(t), o = a[0] ?? { type: s?.seriesType === "line" ? "line" : "bar", data: ["$data"] };
62
- return i.series = Array.from({ length: Math.max(e, 1) }, (u, f) => ({
63
- ...o,
64
- ...a[f] ?? {},
65
- data: ["$data"]
66
- })), i;
67
- }
68
- const g = (r) => Math.round(r * 10) / 10;
69
- function p(r, e) {
70
- return e > 0 ? g(r / e * 100) : 0;
71
- }
72
- function y(r, e, t) {
73
- if (typeof r == "string" && r.trim().endsWith("%")) {
74
- const i = Number.parseFloat(r);
75
- if (Number.isFinite(i)) return g(i);
76
- }
77
- return typeof r == "number" && Number.isFinite(r) ? p(r, e) : p(t, e);
78
- }
79
- function S(r, e, t) {
80
- return Math.min(t, Math.max(e, r));
81
- }
82
- function A(r) {
83
- return `${S(g(r), 0, 100)}%`;
84
- }
85
- function _(r) {
86
- const t = (Array.isArray(r.series) ? r.series : [])[0];
87
- return t && typeof t == "object" ? t : {};
88
- }
89
- function F(r, e, t) {
90
- const a = _(r && typeof r == "object" ? r : {}), s = d(e), o = d(t);
91
- return {
92
- top: y(a.top, o, l.top),
93
- right: y(a.right, s, l.right),
94
- bottom: y(a.bottom, o, l.bottom),
95
- left: y(a.left, s, l.left)
96
- };
97
- }
98
- function I(r, e) {
99
- const t = m(r), i = Array.isArray(t.series) ? t.series : [];
100
- i.length === 0 && i.push({ type: "funnel", data: ["$data"] });
101
- const a = i[0];
102
- return a.top = A(e.top), a.right = A(e.right), a.bottom = A(e.bottom), a.left = A(e.left), t.series = i, t;
103
- }
104
- function L(r, e, t) {
105
- const a = b((r && typeof r == "object" ? r : {}).radar).radius, s = Array.isArray(a) ? a[a.length - 1] : a, o = d(e), u = d(t), f = Math.min(o, u) / 2;
106
- if (typeof s == "string" && s.trim().endsWith("%")) {
107
- const n = Number.parseFloat(s);
108
- if (Number.isFinite(n)) return g(n);
109
- }
110
- return typeof s == "number" && Number.isFinite(s) ? p(s, f) : P;
111
- }
112
- function w(r, e) {
113
- const t = m(r);
114
- return t.radar = { ...b(t.radar), radius: A(S(e, 20, 100)) }, t;
115
- }
6
+ */import { C as s, a as t, b as r, c as i, d as n, E as C, e as l, F as A, f as d, L as g, g as h, R as o, h as D, i as R, j as _, k as E, l as P, m as T, n as L, o as S, p as u, q as I, r as N, s as F, t as O, u as f, v as c, w as p, x as U, y as H, z as b, A as m, B as G, D as K, G as v, H as B, I as w, J as x, K as y, M as j, N as z, O as M, P as k } from "./plugin-CKyaiHYF.js";
116
7
  export {
117
- O as CHART_KINDS,
118
- j as CHART_KIND_DEFINITIONS,
119
- H as CHART_PALETTES,
120
- M as CHART_PLUGIN,
121
- v as CHART_PLUGIN_ID,
122
- l as ECHARTS_FUNNEL_PADDING_PX,
123
- P as ECHARTS_RADAR_RADIUS_DEFAULT,
124
- $ as FALLBACK_SAMPLE_CATEGORIES,
125
- G as FUNNEL_PADDING_DEFAULTS,
126
- K as RADAR_RADIUS_DEFAULT,
127
- b as asObject,
128
- z as bindChartData,
129
- B as chartFactoryDefaults,
130
- m as cloneChartOption,
131
- J as configureChartPlugin,
132
- W as createDefaultChartOption,
133
- q as fitSvgRoot,
134
- C as getChartKindDefinition,
135
- V as getChartPalettes,
136
- X as getChartPluginConfig,
137
- D as getSampleCategories,
138
- d as mmToChartPx,
139
- Q as normalizeChartOption,
140
- R as previewChartOption,
141
- F as readFunnelPadding,
142
- T as readPaletteKey,
143
- L as readRadarRadius,
144
- Y as registerChartDesigner,
145
- Z as registerChartExecutorBundle,
146
- rr as registerChartPlugin,
147
- tr as renderChartElement,
148
- er as renderChartToSvg,
149
- ar as resolveChartPanelFields,
150
- E as syncSeriesCount,
151
- sr as uninstallChartPlugin,
152
- I as writeFunnelPadding,
153
- w as writeRadarRadius
8
+ s as CHART_KINDS,
9
+ t as CHART_KIND_DEFINITIONS,
10
+ r as CHART_PALETTES,
11
+ i as CHART_PLUGIN,
12
+ n as CHART_PLUGIN_ID,
13
+ C as ECHARTS_FUNNEL_PADDING_PX,
14
+ l as ECHARTS_RADAR_RADIUS_DEFAULT,
15
+ A as FALLBACK_SAMPLE_CATEGORIES,
16
+ d as FUNNEL_PADDING_DEFAULTS,
17
+ g as LABEL_POSITIONS,
18
+ h as LABEL_PRESETS,
19
+ o as RADAR_RADIUS_DEFAULT,
20
+ D as asObject,
21
+ R as bindChartData,
22
+ _ as chartFactoryDefaults,
23
+ E as cloneChartOption,
24
+ P as configureChartPlugin,
25
+ T as createDefaultChartOption,
26
+ L as fitSvgRoot,
27
+ S as getChartKindDefinition,
28
+ u as getChartPalettes,
29
+ I as getChartPluginConfig,
30
+ N as getSampleCategories,
31
+ F as labelFieldsOf,
32
+ O as labelTargetOf,
33
+ f as mmToChartPx,
34
+ c as normalizeChartOption,
35
+ p as previewChartOption,
36
+ U as readChartLabel,
37
+ H as readFunnelPadding,
38
+ b as readPaletteKey,
39
+ m as readRadarRadius,
40
+ G as registerChartDesigner,
41
+ K as registerChartExecutorBundle,
42
+ v as registerChartPlugin,
43
+ B as renderChartElement,
44
+ w as renderChartToSvg,
45
+ x as resolveChartPanelFields,
46
+ y as syncSeriesCount,
47
+ j as uninstallChartPlugin,
48
+ z as updateChartLabel,
49
+ M as writeFunnelPadding,
50
+ k as writeRadarRadius
154
51
  };
@@ -0,0 +1,65 @@
1
+ /*!
2
+ * @worm-print-platform/echarts v1.6.1
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
+ */
7
+ import type { ChartSeriesType } from './kinds.js';
8
+ export type LabelFieldKey = 'formatter' | 'overflow' | 'position' | 'distance' | 'rotate' | 'offset' | 'fontSize' | 'fontWeight' | 'color' | 'backgroundColor' | 'borderColor' | 'borderWidth' | 'borderRadius' | 'padding' | 'labelLine.show' | 'labelLine.length' | 'labelLine.length2' | 'labelLine.smooth';
9
+ export interface ChartLabelState {
10
+ show: boolean;
11
+ formatter?: string;
12
+ overflow?: string;
13
+ position?: string;
14
+ distance?: number;
15
+ rotate?: number;
16
+ /** ECharts 原生标签偏移 [x, y];旧模板的 offsetX / offsetY 在读取时迁移至此 */
17
+ offset?: [number, number];
18
+ fontSize?: number;
19
+ fontWeight?: string;
20
+ color?: string;
21
+ backgroundColor?: string;
22
+ borderColor?: string;
23
+ borderWidth?: number;
24
+ borderRadius?: number;
25
+ padding?: number;
26
+ labelLine: {
27
+ show?: boolean;
28
+ length?: number;
29
+ length2?: number;
30
+ smooth?: boolean;
31
+ };
32
+ }
33
+ export interface ChartLabelPatch extends Partial<Omit<ChartLabelState, 'labelLine'>> {
34
+ /** 总开关:true 写默认集(只补缺失键),false 只写 show:false */
35
+ enabled?: boolean;
36
+ labelLine?: {
37
+ show?: boolean;
38
+ length?: number | null;
39
+ length2?: number | null;
40
+ smooth?: boolean;
41
+ };
42
+ }
43
+ /** formatter 预设:底层仍是 ECharts 字符串模板,选中即写入 formatter */
44
+ export declare const LABEL_PRESETS: readonly {
45
+ key: string;
46
+ label: string;
47
+ labelKey: string;
48
+ formatter: string;
49
+ }[];
50
+ /** 标签位置候选:按 seriesType 给,ECharts 对不适用项会忽略,面板只做引导 */
51
+ export declare const LABEL_POSITIONS: Readonly<Record<ChartSeriesType, readonly {
52
+ value: string;
53
+ label: string;
54
+ labelKey: string;
55
+ }[]>>;
56
+ /**
57
+ * 把单个 label / detail 上的旧 offsetX / offsetY 迁成 ECharts 原生 offset: [x, y](原地修改)。
58
+ * 旧键来自早期面板误写,ECharts 不识别,必须在读取、写入与出图归一三处统一迁移。
59
+ */
60
+ export declare function normalizeLabelOffsetInPlace(target: Record<string, any>): void;
61
+ /** 仪表盘的数值文本走 series[].detail,其余走 series[].label */
62
+ export declare function labelTargetOf(type: string): 'label' | 'detail';
63
+ export declare function labelFieldsOf(type: string): readonly LabelFieldKey[];
64
+ export declare function readChartLabel(option: Record<string, unknown> | undefined, type: string): ChartLabelState;
65
+ export declare function updateChartLabel(option: Record<string, unknown> | undefined, type: string, patch: ChartLabelPatch): Record<string, unknown>;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.5.3
2
+ * @worm-print-platform/echarts v1.6.1
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT