@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/node.cjs CHANGED
@@ -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
@@ -37,6 +37,7 @@ var import_node_fs = require("fs");
37
37
  var import_node_url = require("url");
38
38
 
39
39
  // src/plugin.ts
40
+ var import_i18n = require("@worm-print-platform/core/i18n");
40
41
  var import_designer2 = require("@worm-print-platform/core/designer");
41
42
 
42
43
  // src/kinds.ts
@@ -47,114 +48,134 @@ var CHART_KIND_DEFINITIONS = [
47
48
  {
48
49
  type: "barChart",
49
50
  label: "\u67F1\u72B6\u56FE",
51
+ labelKey: "echarts.series.typeNames.bar",
50
52
  icon: "ChartColumn",
51
53
  seriesType: "bar",
52
54
  orientation: "vertical",
53
- fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
55
+ fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
54
56
  requiredOptionKeys: BASE_REQUIRED,
55
57
  defaultWidth: 100,
56
58
  defaultHeight: 60,
57
- notes: "\u67F1\u72B6\u56FE\uFF1A\u7C7B\u76EE + \u591A\u4E2A\u6570\u503C\u5B57\u6BB5\uFF0C\u6BCF\u5B57\u6BB5\u4E00\u4E2A series\uFF1Bseries[].data \u5199 $data \u5360\u4F4D\uFF1B\u56FA\u5B9A\u9AD8\uFF0C\u7981\u6B62 autoHeight"
59
+ notes: "\u67F1\u72B6\u56FE\uFF1A\u7C7B\u76EE + \u591A\u4E2A\u6570\u503C\u5B57\u6BB5\uFF0C\u6BCF\u5B57\u6BB5\u4E00\u4E2A series\uFF1Bseries[].data \u5199 $data \u5360\u4F4D\uFF1B\u56FA\u5B9A\u9AD8\uFF0C\u7981\u6B62 autoHeight",
60
+ notesKey: "echarts.notes.bar"
58
61
  },
59
62
  {
60
63
  type: "barHChart",
61
64
  label: "\u6761\u5F62\u56FE",
65
+ labelKey: "echarts.series.typeNames.barH",
62
66
  icon: "ChartBar",
63
67
  seriesType: "bar",
64
68
  orientation: "horizontal",
65
- fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
69
+ fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
66
70
  requiredOptionKeys: BASE_REQUIRED,
67
71
  defaultWidth: 100,
68
72
  defaultHeight: 60,
69
- notes: "\u6A2A\u5411\u6761\u5F62\u56FE\uFF1AxAxis \u4E3A\u6570\u503C\u3001yAxis \u4E3A\u7C7B\u76EE\uFF1B\u7C7B\u76EE\u5199 yAxis.data \u7684 $data \u5360\u4F4D"
73
+ notes: "\u6A2A\u5411\u6761\u5F62\u56FE\uFF1AxAxis \u4E3A\u6570\u503C\u3001yAxis \u4E3A\u7C7B\u76EE\uFF1B\u7C7B\u76EE\u5199 yAxis.data \u7684 $data \u5360\u4F4D",
74
+ notesKey: "echarts.notes.barH"
70
75
  },
71
76
  {
72
77
  type: "lineChart",
73
78
  label: "\u6298\u7EBF\u56FE",
79
+ labelKey: "echarts.series.typeNames.line",
74
80
  icon: "ChartLine",
75
81
  seriesType: "line",
76
- fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
82
+ fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
77
83
  requiredOptionKeys: BASE_REQUIRED,
78
84
  defaultWidth: 100,
79
85
  defaultHeight: 60,
80
- notes: "\u6298\u7EBF\u56FE\uFF1A\u7C7B\u76EE + \u591A\u4E2A\u6570\u503C\u5B57\u6BB5\uFF1B\u4E0D\u5199 areaStyle"
86
+ notes: "\u6298\u7EBF\u56FE\uFF1A\u7C7B\u76EE + \u591A\u4E2A\u6570\u503C\u5B57\u6BB5\uFF1B\u4E0D\u5199 areaStyle",
87
+ notesKey: "echarts.notes.line"
81
88
  },
82
89
  {
83
90
  type: "areaChart",
84
91
  label: "\u9762\u79EF\u56FE",
92
+ labelKey: "echarts.series.typeNames.area",
85
93
  icon: "ChartArea",
86
94
  seriesType: "line",
87
- fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
95
+ fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
88
96
  requiredOptionKeys: BASE_REQUIRED,
89
97
  defaultWidth: 100,
90
98
  defaultHeight: 60,
91
- notes: "\u9762\u79EF\u56FE\uFF1A\u6298\u7EBF + series[].areaStyle\uFF1B\u5176\u4F59\u540C\u6298\u7EBF\u56FE"
99
+ notes: "\u9762\u79EF\u56FE\uFF1A\u6298\u7EBF + series[].areaStyle\uFF1B\u5176\u4F59\u540C\u6298\u7EBF\u56FE",
100
+ notesKey: "echarts.notes.area"
92
101
  },
93
102
  {
94
103
  type: "pieChart",
95
104
  label: "\u997C\u56FE",
105
+ labelKey: "echarts.series.typeNames.pie",
96
106
  icon: "ChartPie",
97
107
  seriesType: "pie",
98
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS],
108
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "label"],
99
109
  requiredOptionKeys: BASE_REQUIRED,
100
110
  defaultWidth: 60,
101
111
  defaultHeight: 60,
102
- notes: "\u997C\u56FE\uFF1A\u7C7B\u76EE + \u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u751F\u6210 { name, value }\uFF1B\u53EA\u9700\u4E00\u4E2A\u6570\u503C\u5B57\u6BB5"
112
+ notes: "\u997C\u56FE\uFF1A\u7C7B\u76EE + \u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u751F\u6210 { name, value }\uFF1B\u53EA\u9700\u4E00\u4E2A\u6570\u503C\u5B57\u6BB5",
113
+ notesKey: "echarts.notes.pie"
103
114
  },
104
115
  {
105
116
  type: "doughnutChart",
106
117
  label: "\u73AF\u5F62\u56FE",
118
+ labelKey: "echarts.series.typeNames.doughnut",
107
119
  icon: "Donut",
108
120
  seriesType: "pie",
109
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "innerRadius"],
121
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "innerRadius", "label"],
110
122
  requiredOptionKeys: BASE_REQUIRED,
111
123
  defaultWidth: 60,
112
124
  defaultHeight: 60,
113
- notes: "\u73AF\u5F62\u56FE\uFF1A\u997C\u56FE + radius:[\u5185\u5F84,\u5916\u5F84]\uFF1B\u5185\u5F84\u7531\u9762\u677F\u914D\u7F6E"
125
+ notes: "\u73AF\u5F62\u56FE\uFF1A\u997C\u56FE + radius:[\u5185\u5F84,\u5916\u5F84]\uFF1B\u5185\u5F84\u7531\u9762\u677F\u914D\u7F6E",
126
+ notesKey: "echarts.notes.doughnut"
114
127
  },
115
128
  {
116
129
  type: "scatterChart",
117
130
  label: "\u6563\u70B9\u56FE",
131
+ labelKey: "echarts.series.typeNames.scatter",
118
132
  icon: "ChartScatter",
119
133
  seriesType: "scatter",
120
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "bubble"],
134
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "bubble", "label"],
121
135
  requiredOptionKeys: BASE_REQUIRED,
122
136
  defaultWidth: 80,
123
137
  defaultHeight: 60,
124
- notes: "\u6563\u70B9\u56FE\uFF1A\u7C7B\u76EE\u5B57\u6BB5\u4F5C x\u3001\u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C y\uFF1BchartBubble \u5F00\u542F\u65F6\u7528\u7B2C\u4E8C\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C\u70B9\u5927\u5C0F"
138
+ notes: "\u6563\u70B9\u56FE\uFF1A\u7C7B\u76EE\u5B57\u6BB5\u4F5C x\u3001\u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C y\uFF1BchartBubble \u5F00\u542F\u65F6\u7528\u7B2C\u4E8C\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C\u70B9\u5927\u5C0F",
139
+ notesKey: "echarts.notes.scatter"
125
140
  },
126
141
  {
127
142
  type: "radarChart",
128
143
  label: "\u96F7\u8FBE\u56FE",
144
+ labelKey: "echarts.series.typeNames.radar",
129
145
  icon: "Radar",
130
146
  seriesType: "radar",
131
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "radius"],
147
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "radius", "label"],
132
148
  requiredOptionKeys: BASE_REQUIRED,
133
149
  defaultWidth: 70,
134
150
  defaultHeight: 60,
135
- notes: "\u96F7\u8FBE\u56FE\uFF1A\u6BCF\u4E2A\u6570\u503C\u5B57\u6BB5\u662F\u4E00\u4E2A\u7EF4\u5EA6\uFF08radar.indicator\uFF09\uFF0C\u6BCF\u884C\u6570\u636E\u662F\u4E00\u4E2A\u7CFB\u5217\uFF08\u7C7B\u76EE\u5B57\u6BB5\u4F5C\u7CFB\u5217\u540D\uFF09\uFF1B\u534A\u5F84\u7531\u9762\u677F\u5199 radar.radius\uFF08%\uFF0C\u9ED8\u8BA4 75\uFF09"
151
+ notes: "\u96F7\u8FBE\u56FE\uFF1A\u6BCF\u4E2A\u6570\u503C\u5B57\u6BB5\u662F\u4E00\u4E2A\u7EF4\u5EA6\uFF08radar.indicator\uFF09\uFF0C\u6BCF\u884C\u6570\u636E\u662F\u4E00\u4E2A\u7CFB\u5217\uFF08\u7C7B\u76EE\u5B57\u6BB5\u4F5C\u7CFB\u5217\u540D\uFF09\uFF1B\u534A\u5F84\u7531\u9762\u677F\u5199 radar.radius\uFF08%\uFF0C\u9ED8\u8BA4 75\uFF09",
152
+ notesKey: "echarts.notes.radar"
136
153
  },
137
154
  {
138
155
  type: "funnelChart",
139
156
  label: "\u6F0F\u6597\u56FE",
157
+ labelKey: "echarts.series.typeNames.funnel",
140
158
  icon: "Funnel",
141
159
  seriesType: "funnel",
142
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "padding"],
160
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "padding", "label"],
143
161
  requiredOptionKeys: BASE_REQUIRED,
144
162
  defaultWidth: 60,
145
163
  defaultHeight: 60,
146
- notes: "\u6F0F\u6597\u56FE\uFF1A\u7C7B\u76EE + \u9996\u4E2A\u6570\u503C\u5B57\u6BB5\uFF0C\u6309\u6570\u503C\u964D\u5E8F\uFF1B\u56DB\u8FB9\u5185\u8FB9\u8DDD\u7531\u9762\u677F\u5199 series.left/right/top/bottom\uFF08%\uFF0C\u53F3\u4FA7\u9700\u7559\u5916\u7F6E\u6807\u7B7E\u7A7A\u95F4\uFF09"
164
+ notes: "\u6F0F\u6597\u56FE\uFF1A\u7C7B\u76EE + \u9996\u4E2A\u6570\u503C\u5B57\u6BB5\uFF0C\u6309\u6570\u503C\u964D\u5E8F\uFF1B\u56DB\u8FB9\u5185\u8FB9\u8DDD\u7531\u9762\u677F\u5199 series.left/right/top/bottom\uFF08%\uFF0C\u53F3\u4FA7\u9700\u7559\u5916\u7F6E\u6807\u7B7E\u7A7A\u95F4\uFF09",
165
+ notesKey: "echarts.notes.funnel"
147
166
  },
148
167
  {
149
168
  type: "gaugeChart",
150
169
  label: "\u4EEA\u8868\u76D8",
170
+ labelKey: "echarts.series.typeNames.gauge",
151
171
  icon: "Gauge",
152
172
  seriesType: "gauge",
153
- fields: ["dataSource", "valueFields", ...STYLE_FIELDS, "gaugeRange"],
173
+ fields: ["dataSource", "valueFields", ...STYLE_FIELDS, "gaugeRange", "label"],
154
174
  requiredOptionKeys: BASE_REQUIRED,
155
175
  defaultWidth: 60,
156
176
  defaultHeight: 60,
157
- notes: "\u4EEA\u8868\u76D8\uFF1A\u53D6\u9996\u884C\u6570\u636E\u7684\u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C\u6307\u9488\u503C\uFF1Bmin/max \u7531\u9762\u677F\u5199\u5165 series[0].min/max"
177
+ notes: "\u4EEA\u8868\u76D8\uFF1A\u53D6\u9996\u884C\u6570\u636E\u7684\u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C\u6307\u9488\u503C\uFF1Bmin/max \u7531\u9762\u677F\u5199\u5165 series[0].min/max",
178
+ notesKey: "echarts.notes.gauge"
158
179
  }
159
180
  ];
160
181
  var CHART_KINDS = CHART_KIND_DEFINITIONS.map((def) => def.type);
@@ -168,16 +189,18 @@ function chartNumber(value) {
168
189
  const n = typeof value === "number" ? value : Number(value);
169
190
  return Number.isFinite(n) ? n : 0;
170
191
  }
171
- function evaluateChartOption(node, data) {
192
+ function evaluateChartOption(node, data, keepStrings = false) {
172
193
  if (typeof node === "string") {
173
194
  if (node.startsWith("$data")) return node;
195
+ if (keepStrings) return node;
174
196
  return node.includes("{") ? (0, import_core.evaluateTemplate)(node, data) : node;
175
197
  }
176
- if (Array.isArray(node)) return node.map((item) => evaluateChartOption(item, data));
198
+ if (Array.isArray(node)) return node.map((item) => evaluateChartOption(item, data, keepStrings));
177
199
  if (node && typeof node === "object") {
178
200
  const out = {};
179
201
  for (const [key, value] of Object.entries(node)) {
180
- out[key] = evaluateChartOption(value, data);
202
+ const childKeep = keepStrings || key === "label" || key === "detail";
203
+ out[key] = evaluateChartOption(value, data, childKeep);
181
204
  }
182
205
  return out;
183
206
  }
@@ -468,6 +491,29 @@ function applyExtraComponents() {
468
491
  for (const item of fresh) appliedComponents.add(item);
469
492
  }
470
493
 
494
+ // src/units.ts
495
+ var PX_PER_MM = 96 / 25.4;
496
+ function mmToChartPx(mm) {
497
+ const value = Number.isFinite(mm) ? mm : 0;
498
+ return Math.max(1, Math.round(value * PX_PER_MM));
499
+ }
500
+
501
+ // src/label.ts
502
+ function normalizeLabelOffsetInPlace(target) {
503
+ if (typeof target.offsetX !== "number" && typeof target.offsetY !== "number") return;
504
+ if (!Array.isArray(target.offset)) {
505
+ target.offset = [
506
+ typeof target.offsetX === "number" ? target.offsetX : 0,
507
+ typeof target.offsetY === "number" ? target.offsetY : 0
508
+ ];
509
+ }
510
+ delete target.offsetX;
511
+ delete target.offsetY;
512
+ }
513
+ function labelTargetOf(type) {
514
+ return getChartKindDefinition(type)?.seriesType === "gauge" ? "detail" : "label";
515
+ }
516
+
471
517
  // src/normalize.ts
472
518
  function asArray(value) {
473
519
  if (Array.isArray(value)) return value.map((item) => ({ ...item }));
@@ -496,6 +542,15 @@ function normalizeChartOption(type, option) {
496
542
  const next = structuredClone(option);
497
543
  const series = asArray(next.series);
498
544
  if (series.length === 0) return next;
545
+ const labelKey = labelTargetOf(type);
546
+ for (const item of series) {
547
+ const label = item[labelKey];
548
+ if (label && typeof label === "object" && !Array.isArray(label)) {
549
+ const nextLabel = { ...label };
550
+ normalizeLabelOffsetInPlace(nextLabel);
551
+ item[labelKey] = nextLabel;
552
+ }
553
+ }
499
554
  if (def.seriesType === "pie") {
500
555
  next.series = series.map((item) => ({
501
556
  ...item,
@@ -537,13 +592,6 @@ function normalizeChartOption(type, option) {
537
592
  return next;
538
593
  }
539
594
 
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
595
  // src/renderer.ts
548
596
  function fitSvgRoot(svg, widthPx, heightPx) {
549
597
  const match = /<svg\b[^>]*>/i.exec(svg);
@@ -608,26 +656,32 @@ var CHART_EXECUTOR_VERSION = "2";
608
656
 
609
657
  // src/plugin.ts
610
658
  var CHART_OPTION_META = {
611
- chartOption: { kind: "object", label: "\u56FE\u8868 option" },
612
- chartDataSource: { kind: "text", label: "\u6570\u636E\u6E90" },
613
- chartCategoryField: { kind: "text", label: "\u7C7B\u76EE\u5B57\u6BB5" },
614
- chartValueFields: { kind: "object", label: "\u6570\u503C\u5B57\u6BB5" },
615
- chartSeriesField: { kind: "text", label: "\u7CFB\u5217\u62C6\u5206\u5B57\u6BB5" }
659
+ chartOption: { kind: "object", label: (0, import_i18n.t)("echarts.meta.chartOption") },
660
+ chartDataSource: { kind: "text", label: (0, import_i18n.t)("echarts.meta.dataSource") },
661
+ chartCategoryField: { kind: "text", label: (0, import_i18n.t)("echarts.meta.categoryField") },
662
+ chartValueFields: { kind: "object", label: (0, import_i18n.t)("echarts.meta.valueFields") },
663
+ chartSeriesField: { kind: "text", label: (0, import_i18n.t)("echarts.meta.seriesField") }
616
664
  };
617
665
  var SCATTER_OPTION_META = {
618
666
  ...CHART_OPTION_META,
619
- chartBubble: { kind: "bool", label: "\u6C14\u6CE1\u5927\u5C0F" }
667
+ chartBubble: { kind: "bool", label: (0, import_i18n.t)("echarts.meta.bubbleSize") }
620
668
  };
621
669
  var CHART_PLUGIN = (0, import_designer2.defineElementPlugin)({
622
670
  id: CHART_PLUGIN_ID,
623
671
  version: CHART_EXECUTOR_VERSION,
624
672
  kinds: CHART_KIND_DEFINITIONS.map((def) => ({
625
673
  type: def.type,
626
- label: def.label,
674
+ // getter:每次读取按当前实例语言取词,避免模块加载期冻结为单一语言
675
+ get label() {
676
+ return (0, import_i18n.t)(def.labelKey);
677
+ },
627
678
  icon: def.icon,
628
679
  fixedHeight: true,
629
680
  requiredOptionKeys: def.requiredOptionKeys,
630
- notes: def.notes,
681
+ // getter:每次读取按当前实例语言取词,避免模块加载期冻结为单一语言
682
+ get notes() {
683
+ return (0, import_i18n.t)(def.notesKey);
684
+ },
631
685
  optionMeta: def.type === "scatterChart" ? SCATTER_OPTION_META : CHART_OPTION_META,
632
686
  defaultOptions: (partial) => chartFactoryDefaults(def.type, partial),
633
687
  binding: { bind: (options, data) => bindChartData(def.type, options, data) }
package/dist/node.d.ts CHANGED
@@ -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
package/dist/node.js CHANGED
@@ -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
@@ -10,6 +10,7 @@ import { readFileSync } from "fs";
10
10
  import { fileURLToPath } from "url";
11
11
 
12
12
  // src/plugin.ts
13
+ import { t } from "@worm-print-platform/core/i18n";
13
14
  import {
14
15
  defineElementPlugin,
15
16
  getElementPluginById,
@@ -24,114 +25,134 @@ var CHART_KIND_DEFINITIONS = [
24
25
  {
25
26
  type: "barChart",
26
27
  label: "\u67F1\u72B6\u56FE",
28
+ labelKey: "echarts.series.typeNames.bar",
27
29
  icon: "ChartColumn",
28
30
  seriesType: "bar",
29
31
  orientation: "vertical",
30
- fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
32
+ fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
31
33
  requiredOptionKeys: BASE_REQUIRED,
32
34
  defaultWidth: 100,
33
35
  defaultHeight: 60,
34
- notes: "\u67F1\u72B6\u56FE\uFF1A\u7C7B\u76EE + \u591A\u4E2A\u6570\u503C\u5B57\u6BB5\uFF0C\u6BCF\u5B57\u6BB5\u4E00\u4E2A series\uFF1Bseries[].data \u5199 $data \u5360\u4F4D\uFF1B\u56FA\u5B9A\u9AD8\uFF0C\u7981\u6B62 autoHeight"
36
+ notes: "\u67F1\u72B6\u56FE\uFF1A\u7C7B\u76EE + \u591A\u4E2A\u6570\u503C\u5B57\u6BB5\uFF0C\u6BCF\u5B57\u6BB5\u4E00\u4E2A series\uFF1Bseries[].data \u5199 $data \u5360\u4F4D\uFF1B\u56FA\u5B9A\u9AD8\uFF0C\u7981\u6B62 autoHeight",
37
+ notesKey: "echarts.notes.bar"
35
38
  },
36
39
  {
37
40
  type: "barHChart",
38
41
  label: "\u6761\u5F62\u56FE",
42
+ labelKey: "echarts.series.typeNames.barH",
39
43
  icon: "ChartBar",
40
44
  seriesType: "bar",
41
45
  orientation: "horizontal",
42
- fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
46
+ fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
43
47
  requiredOptionKeys: BASE_REQUIRED,
44
48
  defaultWidth: 100,
45
49
  defaultHeight: 60,
46
- notes: "\u6A2A\u5411\u6761\u5F62\u56FE\uFF1AxAxis \u4E3A\u6570\u503C\u3001yAxis \u4E3A\u7C7B\u76EE\uFF1B\u7C7B\u76EE\u5199 yAxis.data \u7684 $data \u5360\u4F4D"
50
+ notes: "\u6A2A\u5411\u6761\u5F62\u56FE\uFF1AxAxis \u4E3A\u6570\u503C\u3001yAxis \u4E3A\u7C7B\u76EE\uFF1B\u7C7B\u76EE\u5199 yAxis.data \u7684 $data \u5360\u4F4D",
51
+ notesKey: "echarts.notes.barH"
47
52
  },
48
53
  {
49
54
  type: "lineChart",
50
55
  label: "\u6298\u7EBF\u56FE",
56
+ labelKey: "echarts.series.typeNames.line",
51
57
  icon: "ChartLine",
52
58
  seriesType: "line",
53
- fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
59
+ fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
54
60
  requiredOptionKeys: BASE_REQUIRED,
55
61
  defaultWidth: 100,
56
62
  defaultHeight: 60,
57
- notes: "\u6298\u7EBF\u56FE\uFF1A\u7C7B\u76EE + \u591A\u4E2A\u6570\u503C\u5B57\u6BB5\uFF1B\u4E0D\u5199 areaStyle"
63
+ notes: "\u6298\u7EBF\u56FE\uFF1A\u7C7B\u76EE + \u591A\u4E2A\u6570\u503C\u5B57\u6BB5\uFF1B\u4E0D\u5199 areaStyle",
64
+ notesKey: "echarts.notes.line"
58
65
  },
59
66
  {
60
67
  type: "areaChart",
61
68
  label: "\u9762\u79EF\u56FE",
69
+ labelKey: "echarts.series.typeNames.area",
62
70
  icon: "ChartArea",
63
71
  seriesType: "line",
64
- fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack"],
72
+ fields: [...DATA_FIELDS, ...STYLE_FIELDS, "stack", "label"],
65
73
  requiredOptionKeys: BASE_REQUIRED,
66
74
  defaultWidth: 100,
67
75
  defaultHeight: 60,
68
- notes: "\u9762\u79EF\u56FE\uFF1A\u6298\u7EBF + series[].areaStyle\uFF1B\u5176\u4F59\u540C\u6298\u7EBF\u56FE"
76
+ notes: "\u9762\u79EF\u56FE\uFF1A\u6298\u7EBF + series[].areaStyle\uFF1B\u5176\u4F59\u540C\u6298\u7EBF\u56FE",
77
+ notesKey: "echarts.notes.area"
69
78
  },
70
79
  {
71
80
  type: "pieChart",
72
81
  label: "\u997C\u56FE",
82
+ labelKey: "echarts.series.typeNames.pie",
73
83
  icon: "ChartPie",
74
84
  seriesType: "pie",
75
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS],
85
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "label"],
76
86
  requiredOptionKeys: BASE_REQUIRED,
77
87
  defaultWidth: 60,
78
88
  defaultHeight: 60,
79
- notes: "\u997C\u56FE\uFF1A\u7C7B\u76EE + \u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u751F\u6210 { name, value }\uFF1B\u53EA\u9700\u4E00\u4E2A\u6570\u503C\u5B57\u6BB5"
89
+ notes: "\u997C\u56FE\uFF1A\u7C7B\u76EE + \u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u751F\u6210 { name, value }\uFF1B\u53EA\u9700\u4E00\u4E2A\u6570\u503C\u5B57\u6BB5",
90
+ notesKey: "echarts.notes.pie"
80
91
  },
81
92
  {
82
93
  type: "doughnutChart",
83
94
  label: "\u73AF\u5F62\u56FE",
95
+ labelKey: "echarts.series.typeNames.doughnut",
84
96
  icon: "Donut",
85
97
  seriesType: "pie",
86
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "innerRadius"],
98
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "innerRadius", "label"],
87
99
  requiredOptionKeys: BASE_REQUIRED,
88
100
  defaultWidth: 60,
89
101
  defaultHeight: 60,
90
- notes: "\u73AF\u5F62\u56FE\uFF1A\u997C\u56FE + radius:[\u5185\u5F84,\u5916\u5F84]\uFF1B\u5185\u5F84\u7531\u9762\u677F\u914D\u7F6E"
102
+ notes: "\u73AF\u5F62\u56FE\uFF1A\u997C\u56FE + radius:[\u5185\u5F84,\u5916\u5F84]\uFF1B\u5185\u5F84\u7531\u9762\u677F\u914D\u7F6E",
103
+ notesKey: "echarts.notes.doughnut"
91
104
  },
92
105
  {
93
106
  type: "scatterChart",
94
107
  label: "\u6563\u70B9\u56FE",
108
+ labelKey: "echarts.series.typeNames.scatter",
95
109
  icon: "ChartScatter",
96
110
  seriesType: "scatter",
97
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "bubble"],
111
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "bubble", "label"],
98
112
  requiredOptionKeys: BASE_REQUIRED,
99
113
  defaultWidth: 80,
100
114
  defaultHeight: 60,
101
- notes: "\u6563\u70B9\u56FE\uFF1A\u7C7B\u76EE\u5B57\u6BB5\u4F5C x\u3001\u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C y\uFF1BchartBubble \u5F00\u542F\u65F6\u7528\u7B2C\u4E8C\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C\u70B9\u5927\u5C0F"
115
+ notes: "\u6563\u70B9\u56FE\uFF1A\u7C7B\u76EE\u5B57\u6BB5\u4F5C x\u3001\u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C y\uFF1BchartBubble \u5F00\u542F\u65F6\u7528\u7B2C\u4E8C\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C\u70B9\u5927\u5C0F",
116
+ notesKey: "echarts.notes.scatter"
102
117
  },
103
118
  {
104
119
  type: "radarChart",
105
120
  label: "\u96F7\u8FBE\u56FE",
121
+ labelKey: "echarts.series.typeNames.radar",
106
122
  icon: "Radar",
107
123
  seriesType: "radar",
108
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "radius"],
124
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "radius", "label"],
109
125
  requiredOptionKeys: BASE_REQUIRED,
110
126
  defaultWidth: 70,
111
127
  defaultHeight: 60,
112
- notes: "\u96F7\u8FBE\u56FE\uFF1A\u6BCF\u4E2A\u6570\u503C\u5B57\u6BB5\u662F\u4E00\u4E2A\u7EF4\u5EA6\uFF08radar.indicator\uFF09\uFF0C\u6BCF\u884C\u6570\u636E\u662F\u4E00\u4E2A\u7CFB\u5217\uFF08\u7C7B\u76EE\u5B57\u6BB5\u4F5C\u7CFB\u5217\u540D\uFF09\uFF1B\u534A\u5F84\u7531\u9762\u677F\u5199 radar.radius\uFF08%\uFF0C\u9ED8\u8BA4 75\uFF09"
128
+ notes: "\u96F7\u8FBE\u56FE\uFF1A\u6BCF\u4E2A\u6570\u503C\u5B57\u6BB5\u662F\u4E00\u4E2A\u7EF4\u5EA6\uFF08radar.indicator\uFF09\uFF0C\u6BCF\u884C\u6570\u636E\u662F\u4E00\u4E2A\u7CFB\u5217\uFF08\u7C7B\u76EE\u5B57\u6BB5\u4F5C\u7CFB\u5217\u540D\uFF09\uFF1B\u534A\u5F84\u7531\u9762\u677F\u5199 radar.radius\uFF08%\uFF0C\u9ED8\u8BA4 75\uFF09",
129
+ notesKey: "echarts.notes.radar"
113
130
  },
114
131
  {
115
132
  type: "funnelChart",
116
133
  label: "\u6F0F\u6597\u56FE",
134
+ labelKey: "echarts.series.typeNames.funnel",
117
135
  icon: "Funnel",
118
136
  seriesType: "funnel",
119
- fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "padding"],
137
+ fields: ["dataSource", "categoryField", "valueFields", ...STYLE_FIELDS, "padding", "label"],
120
138
  requiredOptionKeys: BASE_REQUIRED,
121
139
  defaultWidth: 60,
122
140
  defaultHeight: 60,
123
- notes: "\u6F0F\u6597\u56FE\uFF1A\u7C7B\u76EE + \u9996\u4E2A\u6570\u503C\u5B57\u6BB5\uFF0C\u6309\u6570\u503C\u964D\u5E8F\uFF1B\u56DB\u8FB9\u5185\u8FB9\u8DDD\u7531\u9762\u677F\u5199 series.left/right/top/bottom\uFF08%\uFF0C\u53F3\u4FA7\u9700\u7559\u5916\u7F6E\u6807\u7B7E\u7A7A\u95F4\uFF09"
141
+ notes: "\u6F0F\u6597\u56FE\uFF1A\u7C7B\u76EE + \u9996\u4E2A\u6570\u503C\u5B57\u6BB5\uFF0C\u6309\u6570\u503C\u964D\u5E8F\uFF1B\u56DB\u8FB9\u5185\u8FB9\u8DDD\u7531\u9762\u677F\u5199 series.left/right/top/bottom\uFF08%\uFF0C\u53F3\u4FA7\u9700\u7559\u5916\u7F6E\u6807\u7B7E\u7A7A\u95F4\uFF09",
142
+ notesKey: "echarts.notes.funnel"
124
143
  },
125
144
  {
126
145
  type: "gaugeChart",
127
146
  label: "\u4EEA\u8868\u76D8",
147
+ labelKey: "echarts.series.typeNames.gauge",
128
148
  icon: "Gauge",
129
149
  seriesType: "gauge",
130
- fields: ["dataSource", "valueFields", ...STYLE_FIELDS, "gaugeRange"],
150
+ fields: ["dataSource", "valueFields", ...STYLE_FIELDS, "gaugeRange", "label"],
131
151
  requiredOptionKeys: BASE_REQUIRED,
132
152
  defaultWidth: 60,
133
153
  defaultHeight: 60,
134
- notes: "\u4EEA\u8868\u76D8\uFF1A\u53D6\u9996\u884C\u6570\u636E\u7684\u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C\u6307\u9488\u503C\uFF1Bmin/max \u7531\u9762\u677F\u5199\u5165 series[0].min/max"
154
+ notes: "\u4EEA\u8868\u76D8\uFF1A\u53D6\u9996\u884C\u6570\u636E\u7684\u9996\u4E2A\u6570\u503C\u5B57\u6BB5\u4F5C\u6307\u9488\u503C\uFF1Bmin/max \u7531\u9762\u677F\u5199\u5165 series[0].min/max",
155
+ notesKey: "echarts.notes.gauge"
135
156
  }
136
157
  ];
137
158
  var CHART_KINDS = CHART_KIND_DEFINITIONS.map((def) => def.type);
@@ -145,16 +166,18 @@ function chartNumber(value) {
145
166
  const n = typeof value === "number" ? value : Number(value);
146
167
  return Number.isFinite(n) ? n : 0;
147
168
  }
148
- function evaluateChartOption(node, data) {
169
+ function evaluateChartOption(node, data, keepStrings = false) {
149
170
  if (typeof node === "string") {
150
171
  if (node.startsWith("$data")) return node;
172
+ if (keepStrings) return node;
151
173
  return node.includes("{") ? evaluateTemplate(node, data) : node;
152
174
  }
153
- if (Array.isArray(node)) return node.map((item) => evaluateChartOption(item, data));
175
+ if (Array.isArray(node)) return node.map((item) => evaluateChartOption(item, data, keepStrings));
154
176
  if (node && typeof node === "object") {
155
177
  const out = {};
156
178
  for (const [key, value] of Object.entries(node)) {
157
- out[key] = evaluateChartOption(value, data);
179
+ const childKeep = keepStrings || key === "label" || key === "detail";
180
+ out[key] = evaluateChartOption(value, data, childKeep);
158
181
  }
159
182
  return out;
160
183
  }
@@ -451,6 +474,29 @@ function applyExtraComponents() {
451
474
  for (const item of fresh) appliedComponents.add(item);
452
475
  }
453
476
 
477
+ // src/units.ts
478
+ var PX_PER_MM = 96 / 25.4;
479
+ function mmToChartPx(mm) {
480
+ const value = Number.isFinite(mm) ? mm : 0;
481
+ return Math.max(1, Math.round(value * PX_PER_MM));
482
+ }
483
+
484
+ // src/label.ts
485
+ function normalizeLabelOffsetInPlace(target) {
486
+ if (typeof target.offsetX !== "number" && typeof target.offsetY !== "number") return;
487
+ if (!Array.isArray(target.offset)) {
488
+ target.offset = [
489
+ typeof target.offsetX === "number" ? target.offsetX : 0,
490
+ typeof target.offsetY === "number" ? target.offsetY : 0
491
+ ];
492
+ }
493
+ delete target.offsetX;
494
+ delete target.offsetY;
495
+ }
496
+ function labelTargetOf(type) {
497
+ return getChartKindDefinition(type)?.seriesType === "gauge" ? "detail" : "label";
498
+ }
499
+
454
500
  // src/normalize.ts
455
501
  function asArray(value) {
456
502
  if (Array.isArray(value)) return value.map((item) => ({ ...item }));
@@ -479,6 +525,15 @@ function normalizeChartOption(type, option) {
479
525
  const next = structuredClone(option);
480
526
  const series = asArray(next.series);
481
527
  if (series.length === 0) return next;
528
+ const labelKey = labelTargetOf(type);
529
+ for (const item of series) {
530
+ const label = item[labelKey];
531
+ if (label && typeof label === "object" && !Array.isArray(label)) {
532
+ const nextLabel = { ...label };
533
+ normalizeLabelOffsetInPlace(nextLabel);
534
+ item[labelKey] = nextLabel;
535
+ }
536
+ }
482
537
  if (def.seriesType === "pie") {
483
538
  next.series = series.map((item) => ({
484
539
  ...item,
@@ -520,13 +575,6 @@ function normalizeChartOption(type, option) {
520
575
  return next;
521
576
  }
522
577
 
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
578
  // src/renderer.ts
531
579
  function fitSvgRoot(svg, widthPx, heightPx) {
532
580
  const match = /<svg\b[^>]*>/i.exec(svg);
@@ -591,26 +639,32 @@ var CHART_EXECUTOR_VERSION = "2";
591
639
 
592
640
  // src/plugin.ts
593
641
  var CHART_OPTION_META = {
594
- chartOption: { kind: "object", label: "\u56FE\u8868 option" },
595
- chartDataSource: { kind: "text", label: "\u6570\u636E\u6E90" },
596
- chartCategoryField: { kind: "text", label: "\u7C7B\u76EE\u5B57\u6BB5" },
597
- chartValueFields: { kind: "object", label: "\u6570\u503C\u5B57\u6BB5" },
598
- chartSeriesField: { kind: "text", label: "\u7CFB\u5217\u62C6\u5206\u5B57\u6BB5" }
642
+ chartOption: { kind: "object", label: t("echarts.meta.chartOption") },
643
+ chartDataSource: { kind: "text", label: t("echarts.meta.dataSource") },
644
+ chartCategoryField: { kind: "text", label: t("echarts.meta.categoryField") },
645
+ chartValueFields: { kind: "object", label: t("echarts.meta.valueFields") },
646
+ chartSeriesField: { kind: "text", label: t("echarts.meta.seriesField") }
599
647
  };
600
648
  var SCATTER_OPTION_META = {
601
649
  ...CHART_OPTION_META,
602
- chartBubble: { kind: "bool", label: "\u6C14\u6CE1\u5927\u5C0F" }
650
+ chartBubble: { kind: "bool", label: t("echarts.meta.bubbleSize") }
603
651
  };
604
652
  var CHART_PLUGIN = defineElementPlugin({
605
653
  id: CHART_PLUGIN_ID,
606
654
  version: CHART_EXECUTOR_VERSION,
607
655
  kinds: CHART_KIND_DEFINITIONS.map((def) => ({
608
656
  type: def.type,
609
- label: def.label,
657
+ // getter:每次读取按当前实例语言取词,避免模块加载期冻结为单一语言
658
+ get label() {
659
+ return t(def.labelKey);
660
+ },
610
661
  icon: def.icon,
611
662
  fixedHeight: true,
612
663
  requiredOptionKeys: def.requiredOptionKeys,
613
- notes: def.notes,
664
+ // getter:每次读取按当前实例语言取词,避免模块加载期冻结为单一语言
665
+ get notes() {
666
+ return t(def.notesKey);
667
+ },
614
668
  optionMeta: def.type === "scatterChart" ? SCATTER_OPTION_META : CHART_OPTION_META,
615
669
  defaultOptions: (partial) => chartFactoryDefaults(def.type, partial),
616
670
  binding: { bind: (options, data) => bindChartData(def.type, options, data) }
@@ -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
@@ -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