@worm-print-platform/echarts 1.5.3 → 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.
- package/README.md +40 -0
- package/dist/bind.d.ts +1 -1
- package/dist/browser/executor.iife.d.ts +1 -1
- package/dist/browser-bundle.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/defaults.d.ts +1 -1
- package/dist/echarts.d.ts +1 -1
- package/dist/echarts.js +14 -14
- package/dist/executor.iife.global.d.ts +1 -1
- package/dist/executor.iife.global.js +14 -14
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -12
- package/dist/kinds.d.ts +2 -2
- package/dist/kit.cjs +2 -2
- package/dist/kit.d.ts +3 -1
- package/dist/kit.js +45 -148
- package/dist/label.d.ts +63 -0
- package/dist/marketplace.d.ts +1 -1
- package/dist/marketplace.js +801 -80
- package/dist/node.cjs +48 -21
- package/dist/node.d.ts +1 -1
- package/dist/node.js +48 -21
- package/dist/normalize.d.ts +1 -1
- package/dist/option-utils.d.ts +1 -1
- package/dist/plugin-BWmSrZ3m.cjs +6 -0
- package/dist/plugin-Dvcrcg_Z.js +933 -0
- package/dist/plugin.d.ts +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/type-augmentation.d.ts +1 -1
- package/dist/ui.cjs +1432 -60
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +1410 -57
- package/dist/units.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
- package/dist/plugin-Bf6QDbHO.cjs +0 -6
- package/dist/plugin-CUoE2jMs.js +0 -573
package/dist/node.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/echarts v1.
|
|
2
|
+
* @worm-print-platform/echarts v1.6.0
|
|
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
|
|
@@ -50,7 +50,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
50
50
|
icon: "ChartColumn",
|
|
51
51
|
seriesType: "bar",
|
|
52
52
|
orientation: "vertical",
|
|
53
|
-
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
|
|
53
|
+
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
|
|
54
54
|
requiredOptionKeys: BASE_REQUIRED,
|
|
55
55
|
defaultWidth: 100,
|
|
56
56
|
defaultHeight: 60,
|
|
@@ -62,7 +62,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
62
62
|
icon: "ChartBar",
|
|
63
63
|
seriesType: "bar",
|
|
64
64
|
orientation: "horizontal",
|
|
65
|
-
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
|
|
65
|
+
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
|
|
66
66
|
requiredOptionKeys: BASE_REQUIRED,
|
|
67
67
|
defaultWidth: 100,
|
|
68
68
|
defaultHeight: 60,
|
|
@@ -73,7 +73,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
73
73
|
label: "\u6298\u7EBF\u56FE",
|
|
74
74
|
icon: "ChartLine",
|
|
75
75
|
seriesType: "line",
|
|
76
|
-
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
|
|
76
|
+
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
|
|
77
77
|
requiredOptionKeys: BASE_REQUIRED,
|
|
78
78
|
defaultWidth: 100,
|
|
79
79
|
defaultHeight: 60,
|
|
@@ -84,7 +84,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
84
84
|
label: "\u9762\u79EF\u56FE",
|
|
85
85
|
icon: "ChartArea",
|
|
86
86
|
seriesType: "line",
|
|
87
|
-
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
|
|
87
|
+
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
|
|
88
88
|
requiredOptionKeys: BASE_REQUIRED,
|
|
89
89
|
defaultWidth: 100,
|
|
90
90
|
defaultHeight: 60,
|
|
@@ -95,7 +95,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
95
95
|
label: "\u997C\u56FE",
|
|
96
96
|
icon: "ChartPie",
|
|
97
97
|
seriesType: "pie",
|
|
98
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS],
|
|
98
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "label"],
|
|
99
99
|
requiredOptionKeys: BASE_REQUIRED,
|
|
100
100
|
defaultWidth: 60,
|
|
101
101
|
defaultHeight: 60,
|
|
@@ -106,7 +106,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
106
106
|
label: "\u73AF\u5F62\u56FE",
|
|
107
107
|
icon: "Donut",
|
|
108
108
|
seriesType: "pie",
|
|
109
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "innerRadius"],
|
|
109
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "innerRadius", "label"],
|
|
110
110
|
requiredOptionKeys: BASE_REQUIRED,
|
|
111
111
|
defaultWidth: 60,
|
|
112
112
|
defaultHeight: 60,
|
|
@@ -117,7 +117,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
117
117
|
label: "\u6563\u70B9\u56FE",
|
|
118
118
|
icon: "ChartScatter",
|
|
119
119
|
seriesType: "scatter",
|
|
120
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "bubble"],
|
|
120
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "bubble", "label"],
|
|
121
121
|
requiredOptionKeys: BASE_REQUIRED,
|
|
122
122
|
defaultWidth: 80,
|
|
123
123
|
defaultHeight: 60,
|
|
@@ -128,7 +128,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
128
128
|
label: "\u96F7\u8FBE\u56FE",
|
|
129
129
|
icon: "Radar",
|
|
130
130
|
seriesType: "radar",
|
|
131
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "radius"],
|
|
131
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "radius", "label"],
|
|
132
132
|
requiredOptionKeys: BASE_REQUIRED,
|
|
133
133
|
defaultWidth: 70,
|
|
134
134
|
defaultHeight: 60,
|
|
@@ -139,7 +139,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
139
139
|
label: "\u6F0F\u6597\u56FE",
|
|
140
140
|
icon: "Funnel",
|
|
141
141
|
seriesType: "funnel",
|
|
142
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "padding"],
|
|
142
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "padding", "label"],
|
|
143
143
|
requiredOptionKeys: BASE_REQUIRED,
|
|
144
144
|
defaultWidth: 60,
|
|
145
145
|
defaultHeight: 60,
|
|
@@ -150,7 +150,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
150
150
|
label: "\u4EEA\u8868\u76D8",
|
|
151
151
|
icon: "Gauge",
|
|
152
152
|
seriesType: "gauge",
|
|
153
|
-
fields: ["dataSource", "valueFields", ...STYLE_FIELDS, "gaugeRange"],
|
|
153
|
+
fields: ["dataSource", "valueFields", ...STYLE_FIELDS, "gaugeRange", "label"],
|
|
154
154
|
requiredOptionKeys: BASE_REQUIRED,
|
|
155
155
|
defaultWidth: 60,
|
|
156
156
|
defaultHeight: 60,
|
|
@@ -168,16 +168,18 @@ function chartNumber(value) {
|
|
|
168
168
|
const n = typeof value === "number" ? value : Number(value);
|
|
169
169
|
return Number.isFinite(n) ? n : 0;
|
|
170
170
|
}
|
|
171
|
-
function evaluateChartOption(node, data) {
|
|
171
|
+
function evaluateChartOption(node, data, keepStrings = false) {
|
|
172
172
|
if (typeof node === "string") {
|
|
173
173
|
if (node.startsWith("$data")) return node;
|
|
174
|
+
if (keepStrings) return node;
|
|
174
175
|
return node.includes("{") ? (0, import_core.evaluateTemplate)(node, data) : node;
|
|
175
176
|
}
|
|
176
|
-
if (Array.isArray(node)) return node.map((item) => evaluateChartOption(item, data));
|
|
177
|
+
if (Array.isArray(node)) return node.map((item) => evaluateChartOption(item, data, keepStrings));
|
|
177
178
|
if (node && typeof node === "object") {
|
|
178
179
|
const out = {};
|
|
179
180
|
for (const [key, value] of Object.entries(node)) {
|
|
180
|
-
|
|
181
|
+
const childKeep = keepStrings || key === "label" || key === "detail";
|
|
182
|
+
out[key] = evaluateChartOption(value, data, childKeep);
|
|
181
183
|
}
|
|
182
184
|
return out;
|
|
183
185
|
}
|
|
@@ -468,6 +470,29 @@ function applyExtraComponents() {
|
|
|
468
470
|
for (const item of fresh) appliedComponents.add(item);
|
|
469
471
|
}
|
|
470
472
|
|
|
473
|
+
// src/units.ts
|
|
474
|
+
var PX_PER_MM = 96 / 25.4;
|
|
475
|
+
function mmToChartPx(mm) {
|
|
476
|
+
const value = Number.isFinite(mm) ? mm : 0;
|
|
477
|
+
return Math.max(1, Math.round(value * PX_PER_MM));
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// src/label.ts
|
|
481
|
+
function normalizeLabelOffsetInPlace(target) {
|
|
482
|
+
if (typeof target.offsetX !== "number" && typeof target.offsetY !== "number") return;
|
|
483
|
+
if (!Array.isArray(target.offset)) {
|
|
484
|
+
target.offset = [
|
|
485
|
+
typeof target.offsetX === "number" ? target.offsetX : 0,
|
|
486
|
+
typeof target.offsetY === "number" ? target.offsetY : 0
|
|
487
|
+
];
|
|
488
|
+
}
|
|
489
|
+
delete target.offsetX;
|
|
490
|
+
delete target.offsetY;
|
|
491
|
+
}
|
|
492
|
+
function labelTargetOf(type) {
|
|
493
|
+
return getChartKindDefinition(type)?.seriesType === "gauge" ? "detail" : "label";
|
|
494
|
+
}
|
|
495
|
+
|
|
471
496
|
// src/normalize.ts
|
|
472
497
|
function asArray(value) {
|
|
473
498
|
if (Array.isArray(value)) return value.map((item) => ({ ...item }));
|
|
@@ -496,6 +521,15 @@ function normalizeChartOption(type, option) {
|
|
|
496
521
|
const next = structuredClone(option);
|
|
497
522
|
const series = asArray(next.series);
|
|
498
523
|
if (series.length === 0) return next;
|
|
524
|
+
const labelKey = labelTargetOf(type);
|
|
525
|
+
for (const item of series) {
|
|
526
|
+
const label = item[labelKey];
|
|
527
|
+
if (label && typeof label === "object" && !Array.isArray(label)) {
|
|
528
|
+
const nextLabel = { ...label };
|
|
529
|
+
normalizeLabelOffsetInPlace(nextLabel);
|
|
530
|
+
item[labelKey] = nextLabel;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
499
533
|
if (def.seriesType === "pie") {
|
|
500
534
|
next.series = series.map((item) => ({
|
|
501
535
|
...item,
|
|
@@ -537,13 +571,6 @@ function normalizeChartOption(type, option) {
|
|
|
537
571
|
return next;
|
|
538
572
|
}
|
|
539
573
|
|
|
540
|
-
// src/units.ts
|
|
541
|
-
var PX_PER_MM = 96 / 25.4;
|
|
542
|
-
function mmToChartPx(mm) {
|
|
543
|
-
const value = Number.isFinite(mm) ? mm : 0;
|
|
544
|
-
return Math.max(1, Math.round(value * PX_PER_MM));
|
|
545
|
-
}
|
|
546
|
-
|
|
547
574
|
// src/renderer.ts
|
|
548
575
|
function fitSvgRoot(svg, widthPx, heightPx) {
|
|
549
576
|
const match = /<svg\b[^>]*>/i.exec(svg);
|
package/dist/node.d.ts
CHANGED
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/echarts v1.
|
|
2
|
+
* @worm-print-platform/echarts v1.6.0
|
|
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
|
|
@@ -27,7 +27,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
27
27
|
icon: "ChartColumn",
|
|
28
28
|
seriesType: "bar",
|
|
29
29
|
orientation: "vertical",
|
|
30
|
-
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
|
|
30
|
+
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
|
|
31
31
|
requiredOptionKeys: BASE_REQUIRED,
|
|
32
32
|
defaultWidth: 100,
|
|
33
33
|
defaultHeight: 60,
|
|
@@ -39,7 +39,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
39
39
|
icon: "ChartBar",
|
|
40
40
|
seriesType: "bar",
|
|
41
41
|
orientation: "horizontal",
|
|
42
|
-
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
|
|
42
|
+
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
|
|
43
43
|
requiredOptionKeys: BASE_REQUIRED,
|
|
44
44
|
defaultWidth: 100,
|
|
45
45
|
defaultHeight: 60,
|
|
@@ -50,7 +50,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
50
50
|
label: "\u6298\u7EBF\u56FE",
|
|
51
51
|
icon: "ChartLine",
|
|
52
52
|
seriesType: "line",
|
|
53
|
-
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
|
|
53
|
+
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
|
|
54
54
|
requiredOptionKeys: BASE_REQUIRED,
|
|
55
55
|
defaultWidth: 100,
|
|
56
56
|
defaultHeight: 60,
|
|
@@ -61,7 +61,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
61
61
|
label: "\u9762\u79EF\u56FE",
|
|
62
62
|
icon: "ChartArea",
|
|
63
63
|
seriesType: "line",
|
|
64
|
-
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
|
|
64
|
+
fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
|
|
65
65
|
requiredOptionKeys: BASE_REQUIRED,
|
|
66
66
|
defaultWidth: 100,
|
|
67
67
|
defaultHeight: 60,
|
|
@@ -72,7 +72,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
72
72
|
label: "\u997C\u56FE",
|
|
73
73
|
icon: "ChartPie",
|
|
74
74
|
seriesType: "pie",
|
|
75
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS],
|
|
75
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "label"],
|
|
76
76
|
requiredOptionKeys: BASE_REQUIRED,
|
|
77
77
|
defaultWidth: 60,
|
|
78
78
|
defaultHeight: 60,
|
|
@@ -83,7 +83,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
83
83
|
label: "\u73AF\u5F62\u56FE",
|
|
84
84
|
icon: "Donut",
|
|
85
85
|
seriesType: "pie",
|
|
86
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "innerRadius"],
|
|
86
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "innerRadius", "label"],
|
|
87
87
|
requiredOptionKeys: BASE_REQUIRED,
|
|
88
88
|
defaultWidth: 60,
|
|
89
89
|
defaultHeight: 60,
|
|
@@ -94,7 +94,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
94
94
|
label: "\u6563\u70B9\u56FE",
|
|
95
95
|
icon: "ChartScatter",
|
|
96
96
|
seriesType: "scatter",
|
|
97
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "bubble"],
|
|
97
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "bubble", "label"],
|
|
98
98
|
requiredOptionKeys: BASE_REQUIRED,
|
|
99
99
|
defaultWidth: 80,
|
|
100
100
|
defaultHeight: 60,
|
|
@@ -105,7 +105,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
105
105
|
label: "\u96F7\u8FBE\u56FE",
|
|
106
106
|
icon: "Radar",
|
|
107
107
|
seriesType: "radar",
|
|
108
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "radius"],
|
|
108
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "radius", "label"],
|
|
109
109
|
requiredOptionKeys: BASE_REQUIRED,
|
|
110
110
|
defaultWidth: 70,
|
|
111
111
|
defaultHeight: 60,
|
|
@@ -116,7 +116,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
116
116
|
label: "\u6F0F\u6597\u56FE",
|
|
117
117
|
icon: "Funnel",
|
|
118
118
|
seriesType: "funnel",
|
|
119
|
-
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "padding"],
|
|
119
|
+
fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "padding", "label"],
|
|
120
120
|
requiredOptionKeys: BASE_REQUIRED,
|
|
121
121
|
defaultWidth: 60,
|
|
122
122
|
defaultHeight: 60,
|
|
@@ -127,7 +127,7 @@ var CHART_KIND_DEFINITIONS = [
|
|
|
127
127
|
label: "\u4EEA\u8868\u76D8",
|
|
128
128
|
icon: "Gauge",
|
|
129
129
|
seriesType: "gauge",
|
|
130
|
-
fields: ["dataSource", "valueFields", ...STYLE_FIELDS, "gaugeRange"],
|
|
130
|
+
fields: ["dataSource", "valueFields", ...STYLE_FIELDS, "gaugeRange", "label"],
|
|
131
131
|
requiredOptionKeys: BASE_REQUIRED,
|
|
132
132
|
defaultWidth: 60,
|
|
133
133
|
defaultHeight: 60,
|
|
@@ -145,16 +145,18 @@ function chartNumber(value) {
|
|
|
145
145
|
const n = typeof value === "number" ? value : Number(value);
|
|
146
146
|
return Number.isFinite(n) ? n : 0;
|
|
147
147
|
}
|
|
148
|
-
function evaluateChartOption(node, data) {
|
|
148
|
+
function evaluateChartOption(node, data, keepStrings = false) {
|
|
149
149
|
if (typeof node === "string") {
|
|
150
150
|
if (node.startsWith("$data")) return node;
|
|
151
|
+
if (keepStrings) return node;
|
|
151
152
|
return node.includes("{") ? evaluateTemplate(node, data) : node;
|
|
152
153
|
}
|
|
153
|
-
if (Array.isArray(node)) return node.map((item) => evaluateChartOption(item, data));
|
|
154
|
+
if (Array.isArray(node)) return node.map((item) => evaluateChartOption(item, data, keepStrings));
|
|
154
155
|
if (node && typeof node === "object") {
|
|
155
156
|
const out = {};
|
|
156
157
|
for (const [key, value] of Object.entries(node)) {
|
|
157
|
-
|
|
158
|
+
const childKeep = keepStrings || key === "label" || key === "detail";
|
|
159
|
+
out[key] = evaluateChartOption(value, data, childKeep);
|
|
158
160
|
}
|
|
159
161
|
return out;
|
|
160
162
|
}
|
|
@@ -451,6 +453,29 @@ function applyExtraComponents() {
|
|
|
451
453
|
for (const item of fresh) appliedComponents.add(item);
|
|
452
454
|
}
|
|
453
455
|
|
|
456
|
+
// src/units.ts
|
|
457
|
+
var PX_PER_MM = 96 / 25.4;
|
|
458
|
+
function mmToChartPx(mm) {
|
|
459
|
+
const value = Number.isFinite(mm) ? mm : 0;
|
|
460
|
+
return Math.max(1, Math.round(value * PX_PER_MM));
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
// src/label.ts
|
|
464
|
+
function normalizeLabelOffsetInPlace(target) {
|
|
465
|
+
if (typeof target.offsetX !== "number" && typeof target.offsetY !== "number") return;
|
|
466
|
+
if (!Array.isArray(target.offset)) {
|
|
467
|
+
target.offset = [
|
|
468
|
+
typeof target.offsetX === "number" ? target.offsetX : 0,
|
|
469
|
+
typeof target.offsetY === "number" ? target.offsetY : 0
|
|
470
|
+
];
|
|
471
|
+
}
|
|
472
|
+
delete target.offsetX;
|
|
473
|
+
delete target.offsetY;
|
|
474
|
+
}
|
|
475
|
+
function labelTargetOf(type) {
|
|
476
|
+
return getChartKindDefinition(type)?.seriesType === "gauge" ? "detail" : "label";
|
|
477
|
+
}
|
|
478
|
+
|
|
454
479
|
// src/normalize.ts
|
|
455
480
|
function asArray(value) {
|
|
456
481
|
if (Array.isArray(value)) return value.map((item) => ({ ...item }));
|
|
@@ -479,6 +504,15 @@ function normalizeChartOption(type, option) {
|
|
|
479
504
|
const next = structuredClone(option);
|
|
480
505
|
const series = asArray(next.series);
|
|
481
506
|
if (series.length === 0) return next;
|
|
507
|
+
const labelKey = labelTargetOf(type);
|
|
508
|
+
for (const item of series) {
|
|
509
|
+
const label = item[labelKey];
|
|
510
|
+
if (label && typeof label === "object" && !Array.isArray(label)) {
|
|
511
|
+
const nextLabel = { ...label };
|
|
512
|
+
normalizeLabelOffsetInPlace(nextLabel);
|
|
513
|
+
item[labelKey] = nextLabel;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
482
516
|
if (def.seriesType === "pie") {
|
|
483
517
|
next.series = series.map((item) => ({
|
|
484
518
|
...item,
|
|
@@ -520,13 +554,6 @@ function normalizeChartOption(type, option) {
|
|
|
520
554
|
return next;
|
|
521
555
|
}
|
|
522
556
|
|
|
523
|
-
// src/units.ts
|
|
524
|
-
var PX_PER_MM = 96 / 25.4;
|
|
525
|
-
function mmToChartPx(mm) {
|
|
526
|
-
const value = Number.isFinite(mm) ? mm : 0;
|
|
527
|
-
return Math.max(1, Math.round(value * PX_PER_MM));
|
|
528
|
-
}
|
|
529
|
-
|
|
530
557
|
// src/renderer.ts
|
|
531
558
|
function fitSvgRoot(svg, widthPx, heightPx) {
|
|
532
559
|
const match = /<svg\b[^>]*>/i.exec(svg);
|
package/dist/normalize.d.ts
CHANGED
package/dist/option-utils.d.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
*/"use strict";const C=require("@worm-print-platform/core/designer"),ye=require("@worm-print-platform/core"),A=require("echarts/charts"),v=require("echarts/components"),he=require("echarts/core"),pe=require("echarts/renderers");function be(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const U=be(he),b=["left","top","width","height","chartOption"],P=["dataSource","categoryField","valueFields","seriesField"],g=["title","legend","palette"],I=[{type:"barChart",label:"柱状图",icon:"ChartColumn",seriesType:"bar",orientation:"vertical",fields:[...P,...g,"stack","label"],requiredOptionKeys:b,defaultWidth:100,defaultHeight:60,notes:"柱状图:类目 + 多个数值字段,每字段一个 series;series[].data 写 $data 占位;固定高,禁止 autoHeight"},{type:"barHChart",label:"条形图",icon:"ChartBar",seriesType:"bar",orientation:"horizontal",fields:[...P,...g,"stack","label"],requiredOptionKeys:b,defaultWidth:100,defaultHeight:60,notes:"横向条形图:xAxis 为数值、yAxis 为类目;类目写 yAxis.data 的 $data 占位"},{type:"lineChart",label:"折线图",icon:"ChartLine",seriesType:"line",fields:[...P,...g,"stack","label"],requiredOptionKeys:b,defaultWidth:100,defaultHeight:60,notes:"折线图:类目 + 多个数值字段;不写 areaStyle"},{type:"areaChart",label:"面积图",icon:"ChartArea",seriesType:"line",fields:[...P,...g,"stack","label"],requiredOptionKeys:b,defaultWidth:100,defaultHeight:60,notes:"面积图:折线 + series[].areaStyle;其余同折线图"},{type:"pieChart",label:"饼图",icon:"ChartPie",seriesType:"pie",fields:["dataSource","categoryField","valueFields",...g,"label"],requiredOptionKeys:b,defaultWidth:60,defaultHeight:60,notes:"饼图:类目 + 首个数值字段生成 { name, value };只需一个数值字段"},{type:"doughnutChart",label:"环形图",icon:"Donut",seriesType:"pie",fields:["dataSource","categoryField","valueFields",...g,"innerRadius","label"],requiredOptionKeys:b,defaultWidth:60,defaultHeight:60,notes:"环形图:饼图 + radius:[内径,外径];内径由面板配置"},{type:"scatterChart",label:"散点图",icon:"ChartScatter",seriesType:"scatter",fields:["dataSource","categoryField","valueFields",...g,"bubble","label"],requiredOptionKeys:b,defaultWidth:80,defaultHeight:60,notes:"散点图:类目字段作 x、首个数值字段作 y;chartBubble 开启时用第二个数值字段作点大小"},{type:"radarChart",label:"雷达图",icon:"Radar",seriesType:"radar",fields:["dataSource","categoryField","valueFields",...g,"radius","label"],requiredOptionKeys:b,defaultWidth:70,defaultHeight:60,notes:"雷达图:每个数值字段是一个维度(radar.indicator),每行数据是一个系列(类目字段作系列名);半径由面板写 radar.radius(%,默认 75)"},{type:"funnelChart",label:"漏斗图",icon:"Funnel",seriesType:"funnel",fields:["dataSource","categoryField","valueFields",...g,"padding","label"],requiredOptionKeys:b,defaultWidth:60,defaultHeight:60,notes:"漏斗图:类目 + 首个数值字段,按数值降序;四边内边距由面板写 series.left/right/top/bottom(%,右侧需留外置标签空间)"},{type:"gaugeChart",label:"仪表盘",icon:"Gauge",seriesType:"gauge",fields:["dataSource","valueFields",...g,"gaugeRange","label"],requiredOptionKeys:b,defaultWidth:60,defaultHeight:60,notes:"仪表盘:取首行数据的首个数值字段作指针值;min/max 由面板写入 series[0].min/max"}],ge=I.map(e=>e.type);function h(e){return I.find(t=>t.type===e)}function me(e){return h(e)?.fields??[]}function Ae(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:0}function $(e,t,r=!1){if(typeof e=="string")return e.startsWith("$data")||r?e:e.includes("{")?ye.evaluateTemplate(e,t):e;if(Array.isArray(e))return e.map(a=>$(a,t,r));if(e&&typeof e=="object"){const a={};for(const[n,i]of Object.entries(e)){const s=r||n==="label"||n==="detail";a[n]=$(i,t,s)}return a}return e}function x(e){return Array.isArray(e.data)&&e.data.includes("$data")}function Se(e,t){const r=e.dataSource;if(typeof r=="string"&&Array.isArray(t[r]))return t[r];for(const a of Object.values(t))if(Array.isArray(a))return a;return[]}function V(e){return typeof e=="string"&&e.length>0?e:void 0}function Ce(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function L(e){return Array.isArray(e.series)?e.series:[]}function m(e,t){return t?Ae(e[t]):0}function X(e,t){for(const r of["xAxis","yAxis"]){const a=e[r],n=Array.isArray(a)?a:a?[a]:[];for(const i of n)i&&typeof i=="object"&&Array.isArray(i.data)&&i.data.includes("$data")&&(i.data=[...t])}}function xe(e,t,r,a,n){const i=L(e);if(!i.some(x))return;const s=t.map((c,u)=>r?c[r]:u+1),l=c=>a[Math.min(c,a.length-1)];if(n){const c=i[0],u=new Map;for(const d of t){const y=String(d[n]??""),p=u.get(y)??new Map,G=String(d[r??""]);p.set(G,(p.get(G)??0)+m(d,l(0))),u.set(y,p)}const f=[...new Set(s)];e.series=[...u.entries()].map(([d,y])=>({...c,name:d,data:f.map(p=>y.get(String(p))??null)})),X(e,f);return}const o=i[i.length-1];for(;i.length<a.length;)i.push({...o,data:["$data"]});e.series=i.map((c,u)=>x(c)?{...c,data:t.map(f=>m(f,l(u)))}:c),X(e,s)}function Y(e,t,r,a,n){const i=L(e);if(!i.some(x))return;const s=t.map(l=>({name:r?String(l[r]??""):"",value:m(l,a)}));n&&s.sort((l,o)=>o.value-l.value),e.series=i.map(l=>({...l,data:s}))}function Te(e,t,r,a,n){const i=L(e);if(!i.some(x))return;const s=a[0],l=n?a[1]:void 0,o=l?t.map(d=>m(d,l)):[],c=o.length>0?Math.min(...o):0,u=o.length>0?Math.max(...o):0,f=d=>u===c?12:Math.round(6+(d-c)/(u-c)*18);e.series=i.map(d=>({...d,data:t.map(y=>{const p=[m(y,r),m(y,s)];return l?{value:p,symbolSize:f(m(y,l))}:p})}))}function ve(e){if(e<=0)return 10;const t=10**Math.floor(Math.log10(e)),r=t>=10?t:10;return Math.ceil(e/r)*r}function Ee(e,t,r,a){const n=L(e);if(!n.some(x))return;const i=a.map(s=>Math.max(0,...t.map(l=>m(l,s))));e.radar={...e.radar??{},indicator:a.map((s,l)=>({name:s,max:ve(i[l])}))},e.series=n.map(s=>({...s,data:t.map(l=>({name:r?String(l[r]??""):"",value:a.map(o=>m(l,o))}))}))}function Oe(e,t,r){const a=L(e);if(!a.some(x))return;const n=t[0]??{};e.series=a.map(i=>({...i,data:[{value:m(n,r),name:r}]}))}function ee(e,t,r){const a=t.chartOption;if(!a||typeof a!="object"||Array.isArray(a))return{};const n=$(a,r),i=Ce(t.chartValueFields);if(i.length===0)return{_chartOption:n};const s=Se({...t,dataSource:t.chartDataSource??t.dataSource},r);if(s.length===0)return{_chartOption:n};const l=V(t.chartCategoryField);switch(h(e)?.seriesType){case"radar":Ee(n,s,l,i);break;case"gauge":Oe(n,s,i[0]);break;case"funnel":Y(n,s,l,i[0],!0);break;case"pie":Y(n,s,l,i[0],!1);break;case"scatter":Te(n,s,l,i,t.chartBubble===!0);break;default:xe(n,s,l,i,V(t.chartSeriesField));break}return{_chartOption:n}}const F="@worm-print-platform/echarts",z=[{key:"default",label:"默认蓝",colors:["#5470c6","#91cc75","#fac858","#ee6666","#73c0de"]},{key:"fresh",label:"清新绿",colors:["#2f9e6e","#5cc9a7","#9ad6c1","#f2c94c","#4a90e2"]},{key:"warm",label:"暖橙红",colors:["#f2704e","#f7a35c","#f7d56d","#c54e3f","#8f5a4a"]},{key:"purple",label:"紫灰",colors:["#7b61ff","#9b8cff","#c3baff","#596275","#8d99ae"]}],te=["示例一","示例二","示例三"],re={top:6,right:25,bottom:6,left:5},ae=75,ne=50,E={top:60,right:80,bottom:65,left:80},J={left:"8%",right:"8%",bottom:"12%",top:"18%",containLabel:!0};function _e(e){return{top:`${e.top}%`,right:`${e.right}%`,bottom:`${e.bottom}%`,left:`${e.left}%`}}function ie(e){const t=h(e),r={text:""};switch(t?.seriesType){case"pie":return{title:r,tooltip:{trigger:"item"},series:[{type:"pie",name:"数量",data:["$data"],radius:e==="doughnutChart"?["40%","70%"]:"62%"}]};case"scatter":return{title:r,grid:J,tooltip:{trigger:"axis"},xAxis:{type:"value"},yAxis:{type:"value"},series:[{type:"scatter",name:"数量",data:["$data"],symbolSize:8}]};case"radar":return{title:r,tooltip:{trigger:"item"},radar:{indicator:[],radius:`${ae}%`},series:[{type:"radar",name:"数量",data:["$data"]}]};case"funnel":return{title:r,tooltip:{trigger:"item"},legend:{show:!1},series:[{type:"funnel",name:"数量",data:["$data"],sort:"descending",..._e(re)}]};case"gauge":return{title:r,tooltip:{trigger:"item"},series:[{type:"gauge",name:"数量",min:0,max:100,data:[{value:0,name:"数量"}]}]};default:{const a=t?.orientation==="horizontal",n=t?.seriesType==="line"&&e==="areaChart",i=t?.seriesType==="line"?"line":"bar";return{title:r,grid:J,tooltip:{trigger:"axis"},xAxis:a?{type:"value"}:{type:"category",data:["$data"]},yAxis:a?{type:"category",data:["$data"]}:{type:"value"},series:[{type:i,name:"数量",data:["$data"],...n?{areaStyle:{}}:{}}]}}}}function Le(e){C.configurePlugin(F,e)}function R(){return C.getPluginConfig(F)}function Fe(){const e=R().palettes??{},t=z.map(a=>{const n=e[a.key];return n?{key:a.key,label:n.label??a.label,colors:n.colors}:{key:a.key,label:a.label,colors:a.colors}}),r=Object.entries(e).filter(([a])=>!z.some(n=>n.key===a)).map(([a,n])=>({key:a,label:n.label??a,colors:n.colors}));return[...t,...r]}function oe(){const e=R().sampleCategories;return Array.isArray(e)&&e.length>0?e:te}function se(e,t){const r=R(),a=h(e);return{width:typeof r.defaultWidth=="number"?r.defaultWidth:a?.defaultWidth??100,height:typeof r.defaultHeight=="number"?r.defaultHeight:a?.defaultHeight??60,title:a?.label??"图表",chartOption:ie(e),chartDataSource:"",chartCategoryField:"name",chartValueFields:["value"],chartSeriesField:"",...t}}U.use([A.BarChart,A.LineChart,A.PieChart,A.ScatterChart,A.RadarChart,A.FunnelChart,A.GaugeChart,v.GridComponent,v.TooltipComponent,v.LegendComponent,v.TitleComponent,v.DatasetComponent,pe.SVGRenderer]);const Q=new Set;function Re(){const t=(R().components??[]).filter(r=>r!=null&&!Q.has(r));if(t.length!==0){U.use(t);for(const r of t)Q.add(r)}}const Pe=96/25.4;function S(e){const t=Number.isFinite(e)?e:0;return Math.max(1,Math.round(t*Pe))}const De=[12,20,15];function T(e){try{return JSON.parse(JSON.stringify(e))}catch{return e}}function ke(e,t){if(!t||typeof t!="object"||Array.isArray(t))return{};const r=T(t),a=h(e),n=[...oe()],i=[...De],s=Array.isArray(r.series)?r.series:[],l=c=>{for(const u of s)Array.isArray(u.data)&&u.data.includes("$data")&&(u.data=c(u))},o=()=>{for(const c of["xAxis","yAxis"]){const u=Array.isArray(r[c])?r[c]:r[c]?[r[c]]:[];for(const f of u)f&&Array.isArray(f.data)&&f.data.includes("$data")&&(f.data=[...n])}};switch(a?.seriesType){case"pie":l(()=>n.map((c,u)=>({name:c,value:i[u]??10})));break;case"funnel":l(()=>n.map((c,u)=>({name:c,value:i[u]??10})));break;case"scatter":l(()=>i.map(c=>[c,c+6]));break;case"radar":r.radar={...r.radar??{},indicator:n.map(c=>({name:c,max:30}))},l(()=>[{name:"示例",value:i}]);break;case"gauge":l(()=>[{value:i[0]??40,name:"数量"}]);break;default:l(()=>[...i]),o();break}return r}function we(e,t){const r=Array.isArray(e?.color)?(e?.color).map(String):[];return t.find(n=>n.colors.every((i,s)=>i===r[s])&&r.length===n.colors.length)?.key??"default"}function B(e){return Array.isArray(e)?e[0]&&typeof e[0]=="object"?{...e[0]}:{}:e&&typeof e=="object"?{...e}:{}}function Ne(e,t,r){const a=T(e),n=Array.isArray(a.series)?a.series:[],i=h(r),s=n[0]??{type:i?.seriesType==="line"?"line":"bar",data:["$data"]};return a.series=Array.from({length:Math.max(t,1)},(l,o)=>({...s,...n[o]??{},data:["$data"]})),a}const H=e=>Math.round(e*10)/10;function W(e,t){return t>0?H(e/t*100):0}function D(e,t,r){if(typeof e=="string"&&e.trim().endsWith("%")){const a=Number.parseFloat(e);if(Number.isFinite(a))return H(a)}return typeof e=="number"&&Number.isFinite(e)?W(e,t):W(r,t)}function le(e,t,r){return Math.min(r,Math.max(t,e))}function O(e){return`${le(H(e),0,100)}%`}function Ie(e){const r=(Array.isArray(e.series)?e.series:[])[0];return r&&typeof r=="object"?r:{}}function He(e,t,r){const n=Ie(e&&typeof e=="object"?e:{}),i=S(t),s=S(r);return{top:D(n.top,s,E.top),right:D(n.right,i,E.right),bottom:D(n.bottom,s,E.bottom),left:D(n.left,i,E.left)}}function Me(e,t){const r=T(e),a=Array.isArray(r.series)?r.series:[];a.length===0&&a.push({type:"funnel",data:["$data"]});const n=a[0];return n.top=O(t.top),n.right=O(t.right),n.bottom=O(t.bottom),n.left=O(t.left),r.series=a,r}function je(e,t,r){const n=B((e&&typeof e=="object"?e:{}).radar).radius,i=Array.isArray(n)?n[n.length-1]:n,s=S(t),l=S(r),o=Math.min(s,l)/2;if(typeof i=="string"&&i.trim().endsWith("%")){const c=Number.parseFloat(i);if(Number.isFinite(c))return H(c)}return typeof i=="number"&&Number.isFinite(i)?W(i,o):ne}function $e(e,t){const r=T(e);return r.radar={...B(r.radar),radius:O(le(t,20,100))},r}const ze=[{key:"value",label:"数值",formatter:"{c}"},{key:"name-value",label:"名称: 数值",formatter:"{b}: {c}"},{key:"name",label:"名称",formatter:"{b}"},{key:"percent",label:"百分比",formatter:"{d}%"}],We={bar:[{value:"top",label:"顶部"},{value:"inside",label:"内部"},{value:"insideTop",label:"内部顶端"},{value:"bottom",label:"底部"},{value:"insideBottom",label:"内部底端"},{value:"right",label:"右侧"},{value:"left",label:"左侧"},{value:"middle",label:"居中"}],line:[{value:"top",label:"顶部"},{value:"bottom",label:"底部"},{value:"inside",label:"内部"},{value:"left",label:"左侧"},{value:"right",label:"右侧"}],pie:[{value:"outside",label:"外侧"},{value:"inside",label:"内部"},{value:"center",label:"中心"}],scatter:[{value:"top",label:"顶部"},{value:"bottom",label:"底部"},{value:"left",label:"左侧"},{value:"right",label:"右侧"},{value:"inside",label:"内部"}],radar:[{value:"top",label:"顶部"},{value:"bottom",label:"底部"},{value:"left",label:"左侧"},{value:"right",label:"右侧"},{value:"inside",label:"内部"}],funnel:[{value:"outer",label:"外侧"},{value:"inner",label:"内部"},{value:"left",label:"左侧"},{value:"right",label:"右侧"},{value:"top",label:"顶部"},{value:"bottom",label:"底部"}],gauge:[]},Ke={bar:!1,line:!1,pie:!0,scatter:!1,radar:!1,funnel:!0,gauge:!0},Ue={bar:{position:"top",fontSize:12},line:{position:"top",fontSize:12},pie:{position:"outside",overflow:"none",fontSize:11},scatter:{position:"top",fontSize:11},radar:{position:"top",fontSize:10},funnel:{position:"outer",fontSize:11},gauge:{fontSize:14}},Be={barHChart:{position:"right",fontSize:12}},qe={bar:["formatter","overflow","position","rotate","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding"],line:["formatter","overflow","position","rotate","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding"],pie:["formatter","overflow","position","distance","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding","labelLine.show","labelLine.length","labelLine.length2","labelLine.smooth"],scatter:["formatter","overflow","position","distance","rotate","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding"],radar:["formatter","fontSize","fontWeight","color"],funnel:["formatter","overflow","position","distance","fontSize","fontWeight","color","labelLine.show","labelLine.length","labelLine.smooth"],gauge:["formatter","fontSize","fontWeight","color","offset"]},Ge=["formatter","overflow","position","distance","rotate","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding"];function Ve(e){const t=e?.series;return Array.isArray(t)?t:[]}function w(e){return e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function q(e){typeof e.offsetX!="number"&&typeof e.offsetY!="number"||(Array.isArray(e.offset)||(e.offset=[typeof e.offsetX=="number"?e.offsetX:0,typeof e.offsetY=="number"?e.offsetY:0]),delete e.offsetX,delete e.offsetY)}function M(e){return h(e)?.seriesType==="gauge"?"detail":"label"}function Xe(e){const t=h(e);return t?qe[t.seriesType]:[]}function Ye(e,t){const r=h(t),a=Ve(e),n=w(a[0]?.[M(t)]);q(n);const i={show:typeof n.show=="boolean"?n.show:r?Ke[r.seriesType]:!1,labelLine:w(a[0]?.labelLine)};for(const l of Ge){const o=n[l];l!=="offset"&&(typeof o=="string"||typeof o=="number")&&(i[l]=o)}const s=n.offset;return Array.isArray(s)&&typeof s[0]=="number"&&typeof s[1]=="number"&&(i.offset=[s[0],s[1]]),i}function Je(e){const t=h(e);return t?{...Ue[t.seriesType],...Be[e]}:{}}function Z(e){return e==null||e===""}function Qe(e,t,r){const a=T(e??{}),n=Array.isArray(a.series)?a.series:[];if(!h(t)||n.length===0)return a;const s=M(t),{enabled:l,labelLine:o,...c}=r;for(const u of n){if(!u||typeof u!="object")continue;const f=w(u[s]);q(f),l===!0?Object.assign(f,{...Je(t),...f,show:!0}):l===!1&&(f.show=!1);for(const[d,y]of Object.entries(c))Z(y)?delete f[d]:f[d]=y;if(o){const d=w(u.labelLine);for(const[y,p]of Object.entries(o))Z(p)?delete d[y]:d[y]=p;u.labelLine=d}u[s]=f}return a}function Ze(e){return Array.isArray(e)?e.map(t=>({...t})):[]}function et(e,t){const r={...e,type:t?"value":"category"};return t?delete r.data:Array.isArray(r.data)||(r.data=["$data"]),r}function tt(e,t){const r={...e,type:t?"category":"value"};return t&&!Array.isArray(r.data)&&(r.data=["$data"]),t||delete r.data,r}function k(e,t){return Array.isArray(e)?e.map(r=>t({...r})):t(e&&typeof e=="object"?{...e}:{})}function ce(e,t){const r=h(e);if(!r)return t;const a=structuredClone(t),n=Ze(a.series);if(n.length===0)return a;const i=M(e);for(const o of n){const c=o[i];if(c&&typeof c=="object"&&!Array.isArray(c)){const u={...c};q(u),o[i]=u}}if(r.seriesType==="pie")return a.series=n.map(o=>({...o,type:"pie",...e==="doughnutChart"?{radius:o.radius??["40%","70%"]}:{}})),delete a.xAxis,delete a.yAxis,a;if(r.seriesType==="scatter")return a.series=n.map(o=>({...o,type:"scatter"})),a.xAxis=k(a.xAxis,o=>({...o,type:"value",data:void 0})),a.yAxis=k(a.yAxis,o=>({...o,type:"value",data:void 0})),a;if(r.seriesType==="radar")return a.series=n.map(o=>({...o,type:"radar"})),a;if(r.seriesType==="funnel")return a.series=n.map(o=>({...o,type:"funnel",sort:"descending"})),a;if(r.seriesType==="gauge")return a.series=n.map(o=>({...o,type:"gauge"})),a;const s=r.orientation==="horizontal",l=r.seriesType==="line"?"line":"bar";return a.xAxis=k(a.xAxis,o=>et(o,s)),a.yAxis=k(a.yAxis,o=>tt(o,s)),a.series=n.map(o=>{const c={...o,type:l};return e==="areaChart"?c.areaStyle=o.areaStyle??{}:delete c.areaStyle,c}),a}function ue(e,t,r){const a=/<svg\b[^>]*>/i.exec(e);if(!a)return e;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(";"),o=i.replace(/\s(width|height|style|viewBox)\s*=\s*"[^"]*"/gi,"").trimEnd(),c=["display:block","width:100%","height:100%",l].filter(Boolean).join(";"),u=`<svg${o} width="100%" height="100%" viewBox="0 0 ${t} ${r}" style="${c}">`;return e.slice(0,a.index)+u+e.slice(a.index+n.length)}function fe(e){Re();const t=ce(e.type,e.option);if(!t||typeof t!="object"||Array.isArray(t))throw new Error("图表 option 非法:需要对象");const r=S(e.widthMm),a=S(e.heightMm),n=U.init(null,null,{renderer:"svg",ssr:!0,width:r,height:a});try{const i=t.textStyle&&typeof t.textStyle=="object"&&!Array.isArray(t.textStyle)?t.textStyle:void 0,s={...e.fontFamily?{fontFamily:e.fontFamily}:{},...i??{}};return n.setOption({animation:!1,...t,...Object.keys(s).length>0?{textStyle:s}:{}}),ue(n.renderToSVGString(),r,a)}finally{n.dispose()}}function rt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function K(e){const t=e._chartOption??e.chartOption,r=`<span>${rt(String(e.title??"图表"))}</span>`;if(!t||typeof t!="object"||Array.isArray(t))return r;try{return fe({key:String(e.key??""),type:String(e.type??""),option:t,widthMm:Number(e.widthMm??0),heightMm:Number(e.heightMm??0),fontFamily:typeof e.fontFamily=="string"?e.fontFamily:void 0})}catch{return r}}const at="2",de={chartOption:{kind:"object",label:"图表 option"},chartDataSource:{kind:"text",label:"数据源"},chartCategoryField:{kind:"text",label:"类目字段"},chartValueFields:{kind:"object",label:"数值字段"},chartSeriesField:{kind:"text",label:"系列拆分字段"}},nt={...de,chartBubble:{kind:"bool",label:"气泡大小"}},_=C.defineElementPlugin({id:F,version:at,kinds:I.map(e=>({type:e.type,label:e.label,icon:e.icon,fixedHeight:!0,requiredOptionKeys:e.requiredOptionKeys,notes:e.notes,optionMeta:e.type==="scatterChart"?nt:de,defaultOptions:t=>se(e.type,t),binding:{bind:(t,r)=>ee(e.type,t,r)}})),render:{html:K,createRenderer:()=>({render:K})}});let N;function j(e,t){const r=C.getElementPluginById(F);if(!e&&!t){const i=C.registerElementPlugin(_);return N=i,i}const a={..._,designer:e??r?.designer??_.designer,render:{..._.render,...r?.render,...t}},n=C.registerElementPlugin(a);return N=n,n}function it(e){return j(e)}function ot(e){return j(void 0,{executorBundle:e})}function st(){N?.(),N=void 0}j();exports.CHART_KINDS=ge;exports.CHART_KIND_DEFINITIONS=I;exports.CHART_PALETTES=z;exports.CHART_PLUGIN=_;exports.CHART_PLUGIN_ID=F;exports.ECHARTS_FUNNEL_PADDING_PX=E;exports.ECHARTS_RADAR_RADIUS_DEFAULT=ne;exports.FALLBACK_SAMPLE_CATEGORIES=te;exports.FUNNEL_PADDING_DEFAULTS=re;exports.LABEL_POSITIONS=We;exports.LABEL_PRESETS=ze;exports.RADAR_RADIUS_DEFAULT=ae;exports.asObject=B;exports.bindChartData=ee;exports.chartFactoryDefaults=se;exports.cloneChartOption=T;exports.configureChartPlugin=Le;exports.createDefaultChartOption=ie;exports.fitSvgRoot=ue;exports.getChartKindDefinition=h;exports.getChartPalettes=Fe;exports.getChartPluginConfig=R;exports.getSampleCategories=oe;exports.labelFieldsOf=Xe;exports.labelTargetOf=M;exports.mmToChartPx=S;exports.normalizeChartOption=ce;exports.previewChartOption=ke;exports.readChartLabel=Ye;exports.readFunnelPadding=He;exports.readPaletteKey=we;exports.readRadarRadius=je;exports.registerChartDesigner=it;exports.registerChartExecutorBundle=ot;exports.registerChartPlugin=j;exports.renderChartElement=K;exports.renderChartToSvg=fe;exports.resolveChartPanelFields=me;exports.syncSeriesCount=Ne;exports.uninstallChartPlugin=st;exports.updateChartLabel=Qe;exports.writeFunnelPadding=Me;exports.writeRadarRadius=$e;
|