@worm-print-platform/echarts 1.6.3 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.3
2
+ * @worm-print-platform/echarts v1.6.5
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
@@ -455,8 +455,8 @@ function chartFactoryDefaults(type, partial) {
455
455
  title: def?.label ?? "\u56FE\u8868",
456
456
  chartOption: createDefaultChartOption(type),
457
457
  chartDataSource: "",
458
- chartCategoryField: "name",
459
- chartValueFields: ["value"],
458
+ chartCategoryField: "",
459
+ chartValueFields: [],
460
460
  chartSeriesField: "",
461
461
  ...partial
462
462
  };
@@ -1048,17 +1048,30 @@ function renderChartElement(spec) {
1048
1048
  var CHART_EXECUTOR_VERSION = "2";
1049
1049
 
1050
1050
  // src/plugin.ts
1051
- var CHART_OPTION_META = {
1052
- chartOption: { kind: "object", label: t("echarts.meta.chartOption") },
1053
- chartDataSource: { kind: "text", label: t("echarts.meta.dataSource") },
1054
- chartCategoryField: { kind: "text", label: t("echarts.meta.categoryField") },
1055
- chartValueFields: { kind: "object", label: t("echarts.meta.valueFields") },
1056
- chartSeriesField: { kind: "text", label: t("echarts.meta.seriesField") }
1057
- };
1058
- var SCATTER_OPTION_META = {
1059
- ...CHART_OPTION_META,
1060
- chartBubble: { kind: "bool", label: t("echarts.meta.bubbleSize") }
1061
- };
1051
+ function createChartOptionMeta(includeBubble = false) {
1052
+ return {
1053
+ chartOption: { kind: "object", get label() {
1054
+ return t("echarts.meta.chartOption");
1055
+ } },
1056
+ chartDataSource: { kind: "text", get label() {
1057
+ return t("echarts.meta.dataSource");
1058
+ } },
1059
+ chartCategoryField: { kind: "text", get label() {
1060
+ return t("echarts.meta.categoryField");
1061
+ } },
1062
+ chartValueFields: { kind: "object", get label() {
1063
+ return t("echarts.meta.valueFields");
1064
+ } },
1065
+ chartSeriesField: { kind: "text", get label() {
1066
+ return t("echarts.meta.seriesField");
1067
+ } },
1068
+ ...includeBubble ? { chartBubble: { kind: "bool", get label() {
1069
+ return t("echarts.meta.bubbleSize");
1070
+ } } } : {}
1071
+ };
1072
+ }
1073
+ var CHART_OPTION_META = createChartOptionMeta();
1074
+ var SCATTER_OPTION_META = createChartOptionMeta(true);
1062
1075
  var CHART_PLUGIN = defineElementPlugin({
1063
1076
  id: CHART_PLUGIN_ID,
1064
1077
  version: CHART_EXECUTOR_VERSION,
@@ -1175,6 +1188,8 @@ var zh_CN_default = {
1175
1188
  "echarts.panel.labelLine.length2": "\u7B2C\u4E8C\u6BB5\u957F\u5EA6",
1176
1189
  "echarts.panel.labelLine.smooth": "\u5E73\u6ED1\u5F15\u5BFC\u7EBF",
1177
1190
  "echarts.panel.dataSourceTitle": "\u6570\u636E\u6E90",
1191
+ "echarts.panel.selectField": "\u9009\u62E9\u5B57\u6BB5",
1192
+ "echarts.panel.autoSource": "\u81EA\u52A8",
1178
1193
  "echarts.panel.categoryField": "\u7C7B\u76EE\u5B57\u6BB5",
1179
1194
  "echarts.panel.removeField": "\u5220\u9664\u8BE5\u5B57\u6BB5",
1180
1195
  "echarts.panel.addField": "+ \u6DFB\u52A0\u5B57\u6BB5",
@@ -1330,6 +1345,8 @@ var en_US_default = {
1330
1345
  "echarts.panel.labelLine.length2": "Second segment length",
1331
1346
  "echarts.panel.labelLine.smooth": "Smooth label line",
1332
1347
  "echarts.panel.dataSourceTitle": "Data source",
1348
+ "echarts.panel.selectField": "Select field",
1349
+ "echarts.panel.autoSource": "Auto",
1333
1350
  "echarts.panel.categoryField": "Category field",
1334
1351
  "echarts.panel.removeField": "Remove this field",
1335
1352
  "echarts.panel.addField": "+ Add field",
@@ -1485,6 +1502,8 @@ var th_TH_default = {
1485
1502
  "echarts.panel.labelLine.length2": "\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E17\u0E48\u0E2D\u0E19\u0E17\u0E35\u0E48\u0E2A\u0E2D\u0E07",
1486
1503
  "echarts.panel.labelLine.smooth": "\u0E40\u0E2A\u0E49\u0E19\u0E1B\u0E49\u0E32\u0E22\u0E42\u0E04\u0E49\u0E07",
1487
1504
  "echarts.panel.dataSourceTitle": "\u0E41\u0E2B\u0E25\u0E48\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
1505
+ "echarts.panel.selectField": "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E1F\u0E34\u0E25\u0E14\u0E4C",
1506
+ "echarts.panel.autoSource": "\u0E2D\u0E31\u0E15\u0E42\u0E19\u0E21\u0E31\u0E15\u0E34",
1488
1507
  "echarts.panel.categoryField": "\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E2B\u0E21\u0E27\u0E14\u0E2B\u0E21\u0E39\u0E48",
1489
1508
  "echarts.panel.removeField": "\u0E25\u0E1A\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E19\u0E35\u0E49",
1490
1509
  "echarts.panel.addField": "+ \u0E40\u0E1E\u0E34\u0E48\u0E21\u0E1F\u0E34\u0E25\u0E14\u0E4C",
@@ -1593,18 +1612,9 @@ var CANVAS_STYLE = "width:100%;height:100%;min-width:0;min-height:0;pointer-even
1593
1612
  var STYLES = [
1594
1613
  ".echarts-canvas-element{overflow:hidden}",
1595
1614
  ".echarts-field-row{display:flex;gap:6px;align-items:center}",
1615
+ ".echarts-field-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text-secondary,#6b7280)}",
1596
1616
  ".echarts-field-row>.pd-input{flex:1;min-width:0}",
1597
1617
  ".echarts-field-row>.pd-button{flex:none}",
1598
- ".echarts-dropdown-trigger{display:flex;align-items:center;justify-content:space-between;gap:6px;width:100%;height:26px;min-height:26px;padding:3px 6px;border:1px solid var(--pd-border,#d9dde6);border-radius:6px;background:var(--pd-input-bg,#fff);color:inherit;font:inherit;box-sizing:border-box;cursor:pointer;text-align:left}",
1599
- ".echarts-dropdown-trigger:hover{border-color:var(--pd-text-faint,#b4b9c4)}",
1600
- '.echarts-dropdown-trigger[aria-expanded="true"]{border-color:var(--pd-accent,#165dff);box-shadow:0 0 0 2px rgb(22 93 255 / 12%)}',
1601
- ".echarts-dropdown-value{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
1602
- ".echarts-dropdown-arrow{flex:none;color:var(--pd-text-muted,#909399);font-size:10px;transition:transform .14s}",
1603
- '.echarts-dropdown-trigger[aria-expanded="true"] .echarts-dropdown-arrow{transform:rotate(180deg)}',
1604
- ".echarts-dropdown-panel{position:fixed;z-index:1200;max-height:240px;overflow:auto;padding:3px;border:1px solid var(--pd-border,#d9dde6);border-radius:6px;background:var(--pd-input-bg,#fff);box-shadow:0 6px 18px rgb(0 0 0 / 14%);box-sizing:border-box}",
1605
- ".echarts-dropdown-option{padding:5px 8px;border-radius:4px;cursor:pointer;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",
1606
- ".echarts-dropdown-option:hover{background:var(--pd-accent-soft,rgb(22 93 255 / 9%))}",
1607
- ".echarts-dropdown-option.is-active{background:var(--pd-accent-soft,rgb(22 93 255 / 9%));color:var(--pd-accent,#165dff)}",
1608
1618
  ".echarts-label-group{margin-top:8px;border-top:1px solid var(--pd-border,#e5e7eb);padding-top:8px}",
1609
1619
  ".echarts-label-group>summary{display:flex;align-items:center;cursor:pointer;list-style:none;font-size:12px;font-weight:600}",
1610
1620
  ".echarts-label-summary>.pd-field{flex:1;margin:0;font-weight:400}",
@@ -1685,22 +1695,6 @@ function valueFieldsLabel(def, limit) {
1685
1695
  if (def?.seriesType === "radar") return t2("echarts.panel.field.dimension");
1686
1696
  return limit === 1 ? t2("echarts.panel.field.value") : t2("echarts.panel.field.valueMulti");
1687
1697
  }
1688
- function dataSourceCandidates(data, fields) {
1689
- const first = data?.[0];
1690
- const keys = first ? Object.keys(first).filter((key) => Array.isArray(first[key])) : [];
1691
- for (const field2 of fields ?? []) {
1692
- if (field2.fieldType === "list" && field2.fieldKey && !keys.includes(field2.fieldKey)) keys.push(field2.fieldKey);
1693
- }
1694
- return keys;
1695
- }
1696
- function dataRowFields(data, dataSource) {
1697
- const first = data?.[0];
1698
- if (!first) return [];
1699
- const key = dataSource ? Array.isArray(first[dataSource]) ? dataSource : "" : Object.keys(first).find((k) => Array.isArray(first[k]));
1700
- if (!key) return [];
1701
- const rows = first[key];
1702
- return rows.length > 0 && typeof rows[0] === "object" && rows[0] !== null ? Object.keys(rows[0]) : [];
1703
- }
1704
1698
  function fieldLabelMap(fields) {
1705
1699
  const map = /* @__PURE__ */ new Map();
1706
1700
  for (const field2 of fields ?? []) {
@@ -1708,17 +1702,41 @@ function fieldLabelMap(fields) {
1708
1702
  }
1709
1703
  return map;
1710
1704
  }
1711
- function optionLabel(value, labels, fallbackSuffix) {
1712
- if (!value) return fallbackSuffix ?? t2("echarts.panel.default");
1705
+ function optionLabel(value, labels) {
1706
+ if (!value) return t2("echarts.panel.default");
1713
1707
  const name = labels.get(value);
1714
- const base = name ? `${name}\uFF08${value}\uFF09` : value;
1715
- return fallbackSuffix ? `${base}${fallbackSuffix}` : base;
1716
- }
1717
- function dropdownOptions(candidates, current, labels = /* @__PURE__ */ new Map()) {
1718
- const opts = candidates.map((value) => ({ value, label: optionLabel(value, labels) }));
1719
- if (current && !candidates.includes(current)) opts.unshift({ value: current, label: optionLabel(current, labels, t2("echarts.panel.current")) });
1720
- if (!current) opts.unshift({ value: "", label: t2("echarts.panel.defaultFirstArray") });
1721
- return opts;
1708
+ return name ? `${name}\uFF08${value}\uFF09` : value;
1709
+ }
1710
+ function fieldBindingKey(next) {
1711
+ if (next.binding) return next.binding;
1712
+ const matched = /^\{\s*([^{}]+?)\s*\}$/.exec(next.formatter?.trim() ?? "");
1713
+ return matched?.[1]?.trim() ?? "";
1714
+ }
1715
+ function fieldPicker(ctx, current, targetPath, fields, labels, onSelect, allowAuto = false) {
1716
+ const row = el("div", "echarts-field-row");
1717
+ const display = el(
1718
+ "span",
1719
+ "echarts-field-current",
1720
+ current ? optionLabel(current, labels) : allowAuto ? t2("echarts.panel.autoSource") : t2("echarts.panel.default")
1721
+ );
1722
+ const picker = el("button", "pd-button small echarts-field-picker", t2("echarts.panel.selectField"));
1723
+ picker.type = "button";
1724
+ picker.addEventListener("click", () => ctx.openExpression({
1725
+ elementId: ctx.element.id,
1726
+ targetPath,
1727
+ value: current ? `{${current}}` : "",
1728
+ binding: current || void 0,
1729
+ fieldOnly: true,
1730
+ fields
1731
+ }, (next) => onSelect(fieldBindingKey(next))));
1732
+ row.append(display, picker);
1733
+ if (allowAuto) {
1734
+ const auto = el("button", "pd-button small echarts-auto-source", t2("echarts.panel.autoSource"));
1735
+ auto.type = "button";
1736
+ auto.addEventListener("click", () => onSelect(""));
1737
+ row.appendChild(auto);
1738
+ }
1739
+ return row;
1722
1740
  }
1723
1741
  function seriesList(option) {
1724
1742
  return Array.isArray(option.series) ? option.series : [];
@@ -1798,84 +1816,6 @@ function selectInput(options, value, onCommit) {
1798
1816
  select.addEventListener("change", () => onCommit(select.value));
1799
1817
  return select;
1800
1818
  }
1801
- var activeDropdown = null;
1802
- function composedPathOf(ev) {
1803
- const composed = typeof ev.composedPath === "function" ? ev.composedPath() : [];
1804
- return composed.length ? composed : [ev.target];
1805
- }
1806
- function dropdownSelect(options, value, onCommit) {
1807
- const current = options.find((item) => item.value === value) ?? { value, label: value || t2("echarts.panel.optionDefault") };
1808
- const trigger = el("button", "echarts-dropdown-trigger");
1809
- trigger.type = "button";
1810
- trigger.setAttribute("aria-haspopup", "listbox");
1811
- trigger.setAttribute("aria-expanded", "false");
1812
- const valueEl = el("span", "echarts-dropdown-value", current.label);
1813
- const arrow = el("span", "echarts-dropdown-arrow", "\u25BE");
1814
- trigger.appendChild(valueEl);
1815
- trigger.appendChild(arrow);
1816
- let panel = null;
1817
- let off = [];
1818
- const close = () => {
1819
- off.forEach((fn) => fn());
1820
- off = [];
1821
- panel?.remove();
1822
- panel = null;
1823
- trigger.setAttribute("aria-expanded", "false");
1824
- if (activeDropdown?.close === close) activeDropdown = null;
1825
- };
1826
- const open = () => {
1827
- activeDropdown?.close();
1828
- const root = trigger.getRootNode();
1829
- const mount = root instanceof ShadowRoot ? root : document.body;
1830
- panel = el("div", "echarts-dropdown-panel");
1831
- panel.setAttribute("role", "listbox");
1832
- for (const item of options) {
1833
- const optionEl = el("div", `echarts-dropdown-option${item.value === value ? " is-active" : ""}`, item.label);
1834
- optionEl.setAttribute("role", "option");
1835
- optionEl.setAttribute("aria-selected", item.value === value ? "true" : "false");
1836
- optionEl.addEventListener("click", (ev) => {
1837
- ev.stopPropagation();
1838
- close();
1839
- onCommit(item.value);
1840
- });
1841
- panel.appendChild(optionEl);
1842
- }
1843
- mount.appendChild(panel);
1844
- const rect = trigger.getBoundingClientRect();
1845
- panel.style.left = `${rect.left}px`;
1846
- panel.style.top = `${rect.bottom + 4}px`;
1847
- panel.style.minWidth = `${rect.width}px`;
1848
- trigger.setAttribute("aria-expanded", "true");
1849
- activeDropdown = { close };
1850
- const onPointerDown = (ev) => {
1851
- const path = composedPathOf(ev);
1852
- if (path.includes(trigger) || path.includes(panel)) return;
1853
- close();
1854
- };
1855
- const onKeydown = (ev) => {
1856
- if (ev.key === "Escape") close();
1857
- };
1858
- const onScroll = () => close();
1859
- document.addEventListener("pointerdown", onPointerDown, true);
1860
- document.addEventListener("keydown", onKeydown);
1861
- window.addEventListener("scroll", onScroll, true);
1862
- window.addEventListener("resize", onScroll);
1863
- root.addEventListener("scroll", onScroll, true);
1864
- off.push(
1865
- () => document.removeEventListener("pointerdown", onPointerDown, true),
1866
- () => document.removeEventListener("keydown", onKeydown),
1867
- () => window.removeEventListener("scroll", onScroll, true),
1868
- () => window.removeEventListener("resize", onScroll),
1869
- () => root.removeEventListener("scroll", onScroll, true)
1870
- );
1871
- };
1872
- trigger.addEventListener("click", (ev) => {
1873
- ev.stopPropagation();
1874
- if (panel) close();
1875
- else open();
1876
- });
1877
- return trigger;
1878
- }
1879
1819
  var overflowOptions = () => [
1880
1820
  { value: "", label: t2("echarts.panel.overflow.default") },
1881
1821
  { value: "none", label: t2("echarts.panel.overflow.none") },
@@ -2057,60 +1997,67 @@ function renderProperty(ctx) {
2057
1997
  return withTranslator(ctx.t, () => renderPropertyInner(ctx));
2058
1998
  }
2059
1999
  function renderPropertyInner(ctx) {
2000
+ if (!ctx.openExpression) throw new Error("[echarts] \u56FE\u8868\u5C5E\u6027\u9762\u677F\u9700\u8981\u5BBF\u4E3B\u63D0\u4F9B openExpression\uFF08\u5B57\u6BB5\u9009\u62E9\u4EC5\u652F\u6301\u8868\u8FBE\u5F0F\u5F39\u6846\uFF09");
2060
2001
  const element = ctx.element;
2061
2002
  const type = elementType(element);
2062
2003
  const def = getChartKindDefinition(type);
2063
- const fields = resolveChartPanelFields(type);
2064
- const has = (key) => fields.includes(key);
2004
+ const panelFields = resolveChartPanelFields(type);
2005
+ const has = (key) => panelFields.includes(key);
2065
2006
  const options = element.options;
2066
2007
  const widthMm = Number(options.width) || 0;
2067
2008
  const heightMm = Number(options.height) || 0;
2068
2009
  const limit = maxValueFields(def);
2069
2010
  const palettes = getChartPalettes();
2070
2011
  const fieldLabels = fieldLabelMap(ctx.fields);
2012
+ const allFields = ctx.fields ?? [];
2013
+ const sourceFields = allFields.filter((field2) => field2.fieldType === "list");
2014
+ const bound = String(options.chartDataSource ?? "");
2015
+ const prefixed = bound ? allFields.filter((field2) => field2.fieldKey.startsWith(`${bound}.`)) : [];
2016
+ const rowFields = prefixed.length > 0 ? prefixed : allFields.filter((field2) => field2.fieldType !== "list");
2071
2017
  const root = el("div", "echarts-property");
2072
2018
  const form = el("form", "pd-form");
2073
2019
  form.addEventListener("submit", (event) => event.preventDefault());
2074
2020
  root.appendChild(form);
2075
2021
  if (has("dataSource")) {
2076
2022
  const wrap = field(t2("echarts.panel.dataSourceTitle"));
2077
- const current = String(options.chartDataSource ?? "");
2078
- wrap.appendChild(
2079
- dropdownSelect(
2080
- dropdownOptions(dataSourceCandidates(ctx.data, ctx.fields), current, fieldLabels),
2081
- current,
2082
- (value) => commitOption(ctx, type, panelOption(element), { chartDataSource: value })
2083
- )
2084
- );
2023
+ wrap.appendChild(fieldPicker(
2024
+ ctx,
2025
+ String(options.chartDataSource ?? ""),
2026
+ "options.chartDataSource",
2027
+ sourceFields,
2028
+ fieldLabels,
2029
+ (value) => commitOption(ctx, type, panelOption(element), { chartDataSource: value }),
2030
+ true
2031
+ ));
2085
2032
  form.appendChild(wrap);
2086
2033
  }
2087
2034
  if (has("categoryField")) {
2088
2035
  const wrap = field(t2("echarts.panel.categoryField"));
2089
- const current = String(options.chartCategoryField ?? "");
2090
- wrap.appendChild(
2091
- dropdownSelect(
2092
- dropdownOptions(dataRowFields(ctx.data, String(options.chartDataSource ?? "")), current, fieldLabels),
2093
- current,
2094
- (value) => commitOption(ctx, type, panelOption(element), { chartCategoryField: value })
2095
- )
2096
- );
2036
+ wrap.appendChild(fieldPicker(
2037
+ ctx,
2038
+ String(options.chartCategoryField ?? ""),
2039
+ "options.chartCategoryField",
2040
+ rowFields,
2041
+ fieldLabels,
2042
+ (value) => commitOption(ctx, type, panelOption(element), { chartCategoryField: value })
2043
+ ));
2097
2044
  form.appendChild(wrap);
2098
2045
  }
2099
2046
  if (has("valueFields")) {
2100
2047
  const wrap = field(valueFieldsLabel(def, limit));
2101
2048
  const fieldsNow = readValueFields(element);
2102
2049
  fieldsNow.forEach((value, index) => {
2103
- const row = el("div", "echarts-field-row");
2104
- row.appendChild(
2105
- dropdownSelect(
2106
- dropdownOptions(dataRowFields(ctx.data, String(options.chartDataSource ?? "")), value, fieldLabels),
2107
- value,
2108
- (next) => {
2109
- const list = readValueFields(element);
2110
- list[index] = next;
2111
- syncValueFields(ctx, type, list);
2112
- }
2113
- )
2050
+ const row = fieldPicker(
2051
+ ctx,
2052
+ value,
2053
+ `options.chartValueFields.${index}`,
2054
+ rowFields,
2055
+ fieldLabels,
2056
+ (next) => {
2057
+ const list = readValueFields(element);
2058
+ list[index] = next;
2059
+ syncValueFields(ctx, type, list);
2060
+ }
2114
2061
  );
2115
2062
  if (fieldsNow.length > 1) {
2116
2063
  const remove = el("button", "pd-button small", "\u2212");
@@ -2131,12 +2078,14 @@ function renderPropertyInner(ctx) {
2131
2078
  }
2132
2079
  if (has("seriesField")) {
2133
2080
  const wrap = field(t2("echarts.panel.seriesField"));
2134
- wrap.appendChild(
2135
- textInput(
2136
- { value: String(options.chartSeriesField ?? ""), placeholder: t2("echarts.panel.seriesFieldHint") },
2137
- (value) => commitOption(ctx, type, panelOption(element), { chartSeriesField: value })
2138
- )
2139
- );
2081
+ wrap.appendChild(fieldPicker(
2082
+ ctx,
2083
+ String(options.chartSeriesField ?? ""),
2084
+ "options.chartSeriesField",
2085
+ rowFields,
2086
+ fieldLabels,
2087
+ (value) => commitOption(ctx, type, panelOption(element), { chartSeriesField: value })
2088
+ ));
2140
2089
  form.appendChild(wrap);
2141
2090
  }
2142
2091
  if (has("bubble")) {
@@ -2289,7 +2238,9 @@ var CHART_ELEMENT_UI = defineElementUI({
2289
2238
  renderCanvas,
2290
2239
  renderProperty,
2291
2240
  hasProperties: chartHasProperties,
2292
- group: t2("echarts.panel.group"),
2241
+ get group() {
2242
+ return t2("echarts.panel.group");
2243
+ },
2293
2244
  searchKeywords: SEARCH_KEYWORDS,
2294
2245
  styles: STYLES,
2295
2246
  i18nId: "echarts",
package/dist/node.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.3
2
+ * @worm-print-platform/echarts v1.6.5
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
@@ -457,8 +457,8 @@ function chartFactoryDefaults(type, partial) {
457
457
  title: def?.label ?? "\u56FE\u8868",
458
458
  chartOption: createDefaultChartOption(type),
459
459
  chartDataSource: "",
460
- chartCategoryField: "name",
461
- chartValueFields: ["value"],
460
+ chartCategoryField: "",
461
+ chartValueFields: [],
462
462
  chartSeriesField: "",
463
463
  ...partial
464
464
  };
@@ -657,17 +657,30 @@ function renderChartElement(spec) {
657
657
  var CHART_EXECUTOR_VERSION = "2";
658
658
 
659
659
  // src/plugin.ts
660
- var CHART_OPTION_META = {
661
- chartOption: { kind: "object", label: (0, import_i18n.t)("echarts.meta.chartOption") },
662
- chartDataSource: { kind: "text", label: (0, import_i18n.t)("echarts.meta.dataSource") },
663
- chartCategoryField: { kind: "text", label: (0, import_i18n.t)("echarts.meta.categoryField") },
664
- chartValueFields: { kind: "object", label: (0, import_i18n.t)("echarts.meta.valueFields") },
665
- chartSeriesField: { kind: "text", label: (0, import_i18n.t)("echarts.meta.seriesField") }
666
- };
667
- var SCATTER_OPTION_META = {
668
- ...CHART_OPTION_META,
669
- chartBubble: { kind: "bool", label: (0, import_i18n.t)("echarts.meta.bubbleSize") }
670
- };
660
+ function createChartOptionMeta(includeBubble = false) {
661
+ return {
662
+ chartOption: { kind: "object", get label() {
663
+ return (0, import_i18n.t)("echarts.meta.chartOption");
664
+ } },
665
+ chartDataSource: { kind: "text", get label() {
666
+ return (0, import_i18n.t)("echarts.meta.dataSource");
667
+ } },
668
+ chartCategoryField: { kind: "text", get label() {
669
+ return (0, import_i18n.t)("echarts.meta.categoryField");
670
+ } },
671
+ chartValueFields: { kind: "object", get label() {
672
+ return (0, import_i18n.t)("echarts.meta.valueFields");
673
+ } },
674
+ chartSeriesField: { kind: "text", get label() {
675
+ return (0, import_i18n.t)("echarts.meta.seriesField");
676
+ } },
677
+ ...includeBubble ? { chartBubble: { kind: "bool", get label() {
678
+ return (0, import_i18n.t)("echarts.meta.bubbleSize");
679
+ } } } : {}
680
+ };
681
+ }
682
+ var CHART_OPTION_META = createChartOptionMeta();
683
+ var SCATTER_OPTION_META = createChartOptionMeta(true);
671
684
  var CHART_PLUGIN = (0, import_designer2.defineElementPlugin)({
672
685
  id: CHART_PLUGIN_ID,
673
686
  version: CHART_EXECUTOR_VERSION,
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.3
2
+ * @worm-print-platform/echarts v1.6.5
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.6.3
2
+ * @worm-print-platform/echarts v1.6.5
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
@@ -434,8 +434,8 @@ function chartFactoryDefaults(type, partial) {
434
434
  title: def?.label ?? "\u56FE\u8868",
435
435
  chartOption: createDefaultChartOption(type),
436
436
  chartDataSource: "",
437
- chartCategoryField: "name",
438
- chartValueFields: ["value"],
437
+ chartCategoryField: "",
438
+ chartValueFields: [],
439
439
  chartSeriesField: "",
440
440
  ...partial
441
441
  };
@@ -640,17 +640,30 @@ function renderChartElement(spec) {
640
640
  var CHART_EXECUTOR_VERSION = "2";
641
641
 
642
642
  // src/plugin.ts
643
- var CHART_OPTION_META = {
644
- chartOption: { kind: "object", label: t("echarts.meta.chartOption") },
645
- chartDataSource: { kind: "text", label: t("echarts.meta.dataSource") },
646
- chartCategoryField: { kind: "text", label: t("echarts.meta.categoryField") },
647
- chartValueFields: { kind: "object", label: t("echarts.meta.valueFields") },
648
- chartSeriesField: { kind: "text", label: t("echarts.meta.seriesField") }
649
- };
650
- var SCATTER_OPTION_META = {
651
- ...CHART_OPTION_META,
652
- chartBubble: { kind: "bool", label: t("echarts.meta.bubbleSize") }
653
- };
643
+ function createChartOptionMeta(includeBubble = false) {
644
+ return {
645
+ chartOption: { kind: "object", get label() {
646
+ return t("echarts.meta.chartOption");
647
+ } },
648
+ chartDataSource: { kind: "text", get label() {
649
+ return t("echarts.meta.dataSource");
650
+ } },
651
+ chartCategoryField: { kind: "text", get label() {
652
+ return t("echarts.meta.categoryField");
653
+ } },
654
+ chartValueFields: { kind: "object", get label() {
655
+ return t("echarts.meta.valueFields");
656
+ } },
657
+ chartSeriesField: { kind: "text", get label() {
658
+ return t("echarts.meta.seriesField");
659
+ } },
660
+ ...includeBubble ? { chartBubble: { kind: "bool", get label() {
661
+ return t("echarts.meta.bubbleSize");
662
+ } } } : {}
663
+ };
664
+ }
665
+ var CHART_OPTION_META = createChartOptionMeta();
666
+ var SCATTER_OPTION_META = createChartOptionMeta(true);
654
667
  var CHART_PLUGIN = defineElementPlugin({
655
668
  id: CHART_PLUGIN_ID,
656
669
  version: CHART_EXECUTOR_VERSION,
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.3
2
+ * @worm-print-platform/echarts v1.6.5
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.6.3
2
+ * @worm-print-platform/echarts v1.6.5
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
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * @worm-print-platform/echarts v1.6.5
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 A=require("@worm-print-platform/core/i18n"),x=require("@worm-print-platform/core/designer"),be=require("@worm-print-platform/core"),S=require("echarts/charts"),v=require("echarts/components"),he=require("echarts/core"),pe=require("echarts/renderers");function ge(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 B=ge(he),p=["left","top","width","height","chartOption"],P=["dataSource","categoryField","valueFields","seriesField"],g=["title","legend","palette"],I=[{type:"barChart",label:"柱状图",labelKey:"echarts.series.typeNames.bar",icon:"ChartColumn",seriesType:"bar",orientation:"vertical",fields:[...P,...g,"stack","label"],requiredOptionKeys:p,defaultWidth:100,defaultHeight:60,notes:"柱状图:类目 + 多个数值字段,每字段一个 series;series[].data 写 $data 占位;固定高,禁止 autoHeight",notesKey:"echarts.notes.bar"},{type:"barHChart",label:"条形图",labelKey:"echarts.series.typeNames.barH",icon:"ChartBar",seriesType:"bar",orientation:"horizontal",fields:[...P,...g,"stack","label"],requiredOptionKeys:p,defaultWidth:100,defaultHeight:60,notes:"横向条形图:xAxis 为数值、yAxis 为类目;类目写 yAxis.data 的 $data 占位",notesKey:"echarts.notes.barH"},{type:"lineChart",label:"折线图",labelKey:"echarts.series.typeNames.line",icon:"ChartLine",seriesType:"line",fields:[...P,...g,"stack","label"],requiredOptionKeys:p,defaultWidth:100,defaultHeight:60,notes:"折线图:类目 + 多个数值字段;不写 areaStyle",notesKey:"echarts.notes.line"},{type:"areaChart",label:"面积图",labelKey:"echarts.series.typeNames.area",icon:"ChartArea",seriesType:"line",fields:[...P,...g,"stack","label"],requiredOptionKeys:p,defaultWidth:100,defaultHeight:60,notes:"面积图:折线 + series[].areaStyle;其余同折线图",notesKey:"echarts.notes.area"},{type:"pieChart",label:"饼图",labelKey:"echarts.series.typeNames.pie",icon:"ChartPie",seriesType:"pie",fields:["dataSource","categoryField","valueFields",...g,"label"],requiredOptionKeys:p,defaultWidth:60,defaultHeight:60,notes:"饼图:类目 + 首个数值字段生成 { name, value };只需一个数值字段",notesKey:"echarts.notes.pie"},{type:"doughnutChart",label:"环形图",labelKey:"echarts.series.typeNames.doughnut",icon:"Donut",seriesType:"pie",fields:["dataSource","categoryField","valueFields",...g,"innerRadius","label"],requiredOptionKeys:p,defaultWidth:60,defaultHeight:60,notes:"环形图:饼图 + radius:[内径,外径];内径由面板配置",notesKey:"echarts.notes.doughnut"},{type:"scatterChart",label:"散点图",labelKey:"echarts.series.typeNames.scatter",icon:"ChartScatter",seriesType:"scatter",fields:["dataSource","categoryField","valueFields",...g,"bubble","label"],requiredOptionKeys:p,defaultWidth:80,defaultHeight:60,notes:"散点图:类目字段作 x、首个数值字段作 y;chartBubble 开启时用第二个数值字段作点大小",notesKey:"echarts.notes.scatter"},{type:"radarChart",label:"雷达图",labelKey:"echarts.series.typeNames.radar",icon:"Radar",seriesType:"radar",fields:["dataSource","categoryField","valueFields",...g,"radius","label"],requiredOptionKeys:p,defaultWidth:70,defaultHeight:60,notes:"雷达图:每个数值字段是一个维度(radar.indicator),每行数据是一个系列(类目字段作系列名);半径由面板写 radar.radius(%,默认 75)",notesKey:"echarts.notes.radar"},{type:"funnelChart",label:"漏斗图",labelKey:"echarts.series.typeNames.funnel",icon:"Funnel",seriesType:"funnel",fields:["dataSource","categoryField","valueFields",...g,"padding","label"],requiredOptionKeys:p,defaultWidth:60,defaultHeight:60,notes:"漏斗图:类目 + 首个数值字段,按数值降序;四边内边距由面板写 series.left/right/top/bottom(%,右侧需留外置标签空间)",notesKey:"echarts.notes.funnel"},{type:"gaugeChart",label:"仪表盘",labelKey:"echarts.series.typeNames.gauge",icon:"Gauge",seriesType:"gauge",fields:["dataSource","valueFields",...g,"gaugeRange","label"],requiredOptionKeys:p,defaultWidth:60,defaultHeight:60,notes:"仪表盘:取首行数据的首个数值字段作指针值;min/max 由面板写入 series[0].min/max",notesKey:"echarts.notes.gauge"}],me=I.map(e=>e.type);function b(e){return I.find(t=>t.type===e)}function Ae(e){return b(e)?.fields??[]}function Se(e){const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:0}function z(e,t,r=!1){if(typeof e=="string")return e.startsWith("$data")||r?e:e.includes("{")?be.evaluateTemplate(e,t):e;if(Array.isArray(e))return e.map(a=>z(a,t,r));if(e&&typeof e=="object"){const a={};for(const[n,i]of Object.entries(e)){const o=r||n==="label"||n==="detail";a[n]=z(i,t,o)}return a}return e}function K(e){return Array.isArray(e.data)&&e.data.includes("$data")}function Ce(e,t){const r=typeof e.chartDataSource=="string"?e.chartDataSource:"",a=typeof e.dataSource=="string"?e.dataSource:"",n=r||a;if(n)return Array.isArray(t[n])?t[n]:[];for(const i of Object.values(t))if(Array.isArray(i))return i;return[]}function X(e){return typeof e=="string"&&e.length>0?e:void 0}function xe(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.length>0):[]}function F(e){return Array.isArray(e.series)?e.series:[]}function m(e,t){return t?Se(e[t]):0}function Y(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 Ke(e,t,r,a,n){const i=F(e);if(!i.some(K))return;const o=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]??""),h=u.get(y)??new Map,V=String(d[r??""]);h.set(V,(h.get(V)??0)+m(d,l(0))),u.set(y,h)}const f=[...new Set(o)];e.series=[...u.entries()].map(([d,y])=>({...c,name:d,data:f.map(h=>y.get(String(h))??null)})),Y(e,f);return}const s=i[i.length-1];for(;i.length<a.length;)i.push({...s,data:["$data"]});e.series=i.map((c,u)=>K(c)?{...c,data:t.map(f=>m(f,l(u)))}:c),Y(e,o)}function J(e,t,r,a,n){const i=F(e);if(!i.some(K))return;const o=t.map(l=>({name:r?String(l[r]??""):"",value:m(l,a)}));n&&o.sort((l,s)=>s.value-l.value),e.series=i.map(l=>({...l,data:o}))}function Te(e,t,r,a,n){const i=F(e);if(!i.some(K))return;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);e.series=i.map(d=>({...d,data:t.map(y=>{const h=[m(y,r),m(y,o)];return l?{value:h,symbolSize:f(m(y,l))}:h})}))}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 Oe(e,t,r,a){const n=F(e);if(!n.some(K))return;const i=a.map(o=>Math.max(0,...t.map(l=>m(l,o))));e.radar={...e.radar??{},indicator:a.map((o,l)=>({name:o,max:ve(i[l])}))},e.series=n.map(o=>({...o,data:t.map(l=>({name:r?String(l[r]??""):"",value:a.map(s=>m(l,s))}))}))}function Ee(e,t,r){const a=F(e);if(!a.some(K))return;const n=t[0]??{};e.series=a.map(i=>({...i,data:[{value:m(n,r),name:r}]}))}function te(e,t,r){const a=t.chartOption;if(!a||typeof a!="object"||Array.isArray(a))return{};const n=z(a,r),i=xe(t.chartValueFields);if(i.length===0)return{_chartOption:n};const o=Ce(t,r);if(o.length===0)return{_chartOption:n};const l=X(t.chartCategoryField);switch(b(e)?.seriesType){case"radar":Oe(n,o,l,i);break;case"gauge":Ee(n,o,i[0]);break;case"funnel":J(n,o,l,i[0],!0);break;case"pie":J(n,o,l,i[0],!1);break;case"scatter":Te(n,o,l,i,t.chartBubble===!0);break;default:Ke(n,o,l,i,X(t.chartSeriesField));break}return{_chartOption:n}}const L="@worm-print-platform/echarts",$=[{key:"default",label:"默认蓝",labelKey:"echarts.palette.default",colors:["#5470c6","#91cc75","#fac858","#ee6666","#73c0de"]},{key:"fresh",label:"清新绿",labelKey:"echarts.palette.fresh",colors:["#2f9e6e","#5cc9a7","#9ad6c1","#f2c94c","#4a90e2"]},{key:"warm",label:"暖橙红",labelKey:"echarts.palette.warm",colors:["#f2704e","#f7a35c","#f7d56d","#c54e3f","#8f5a4a"]},{key:"purple",label:"紫灰",labelKey:"echarts.palette.purple",colors:["#7b61ff","#9b8cff","#c3baff","#596275","#8d99ae"]}],re=["示例一","示例二","示例三"],ae={top:6,right:25,bottom:6,left:5},ne=75,ie=50,O={top:60,right:80,bottom:65,left:80},Q={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 se(e){const t=b(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:Q,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:`${ne}%`},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(ae)}]};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:Q,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 Fe(e){x.configurePlugin(L,e)}function R(){return x.getPluginConfig(L)}function Le(){const e=R().palettes??{},t=$.map(a=>{const n=e[a.key];return n?{key:a.key,label:n.label??a.label,labelKey:n.label?void 0:a.labelKey,colors:n.colors}:{key:a.key,label:a.label,labelKey:a.labelKey,colors:a.colors}}),r=Object.entries(e).filter(([a])=>!$.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:re}function le(e,t){const r=R(),a=b(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:se(e),chartDataSource:"",chartCategoryField:"",chartValueFields:[],chartSeriesField:"",...t}}B.use([S.BarChart,S.LineChart,S.PieChart,S.ScatterChart,S.RadarChart,S.FunnelChart,S.GaugeChart,v.GridComponent,v.TooltipComponent,v.LegendComponent,v.TitleComponent,v.DatasetComponent,pe.SVGRenderer]);const Z=new Set;function Re(){const t=(R().components??[]).filter(r=>r!=null&&!Z.has(r));if(t.length!==0){B.use(t);for(const r of t)Z.add(r)}}const Pe=96/25.4;function C(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 Ne(e,t){if(!t||typeof t!="object"||Array.isArray(t))return{};const r=T(t),a=b(e),n=[...oe()],i=[...De],o=Array.isArray(r.series)?r.series:[],l=c=>{for(const u of o)Array.isArray(u.data)&&u.data.includes("$data")&&(u.data=c(u))},s=()=>{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]),s();break}return r}function ke(e,t){const r=Array.isArray(e?.color)?(e?.color).map(String):[];return t.find(n=>n.colors.every((i,o)=>i===r[o])&&r.length===n.colors.length)?.key??"default"}function q(e){return Array.isArray(e)?e[0]&&typeof e[0]=="object"?{...e[0]}:{}:e&&typeof e=="object"?{...e}:{}}function we(e,t,r){const a=T(e),n=Array.isArray(a.series)?a.series:[],i=b(r),o=n[0]??{type:i?.seriesType==="line"?"line":"bar",data:["$data"]};return a.series=Array.from({length:Math.max(t,1)},(l,s)=>({...o,...n[s]??{},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 ce(e,t,r){return Math.min(r,Math.max(t,e))}function E(e){return`${ce(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=C(t),o=C(r);return{top:D(n.top,o,O.top),right:D(n.right,i,O.right),bottom:D(n.bottom,o,O.bottom),left:D(n.left,i,O.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=E(t.top),n.right=E(t.right),n.bottom=E(t.bottom),n.left=E(t.left),r.series=a,r}function je(e,t,r){const n=q((e&&typeof e=="object"?e:{}).radar).radius,i=Array.isArray(n)?n[n.length-1]:n,o=C(t),l=C(r),s=Math.min(o,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,s):ie}function ze(e,t){const r=T(e);return r.radar={...q(r.radar),radius:E(ce(t,20,100))},r}const $e=[{key:"value",label:"数值",labelKey:"echarts.label.formatter.value",formatter:"{c}"},{key:"name-value",label:"名称: 数值",labelKey:"echarts.label.formatter.nameValue",formatter:"{b}: {c}"},{key:"name",label:"名称",labelKey:"echarts.label.formatter.name",formatter:"{b}"},{key:"percent",label:"百分比",labelKey:"echarts.label.formatter.percent",formatter:"{d}%"}],We={bar:[{value:"top",label:"顶部",labelKey:"echarts.label.position.bar.top"},{value:"inside",label:"内部",labelKey:"echarts.label.position.bar.inside"},{value:"insideTop",label:"内部顶端",labelKey:"echarts.label.position.bar.insideTop"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.bar.bottom"},{value:"insideBottom",label:"内部底端",labelKey:"echarts.label.position.bar.insideBottom"},{value:"right",label:"右侧",labelKey:"echarts.label.position.bar.right"},{value:"left",label:"左侧",labelKey:"echarts.label.position.bar.left"},{value:"middle",label:"居中",labelKey:"echarts.label.position.bar.middle"}],line:[{value:"top",label:"顶部",labelKey:"echarts.label.position.line.top"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.line.bottom"},{value:"inside",label:"内部",labelKey:"echarts.label.position.line.inside"},{value:"left",label:"左侧",labelKey:"echarts.label.position.line.left"},{value:"right",label:"右侧",labelKey:"echarts.label.position.line.right"}],pie:[{value:"outside",label:"外侧",labelKey:"echarts.label.position.pie.outside"},{value:"inside",label:"内部",labelKey:"echarts.label.position.pie.inside"},{value:"center",label:"中心",labelKey:"echarts.label.position.pie.center"}],scatter:[{value:"top",label:"顶部",labelKey:"echarts.label.position.scatter.top"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.scatter.bottom"},{value:"left",label:"左侧",labelKey:"echarts.label.position.scatter.left"},{value:"right",label:"右侧",labelKey:"echarts.label.position.scatter.right"},{value:"inside",label:"内部",labelKey:"echarts.label.position.scatter.inside"}],radar:[{value:"top",label:"顶部",labelKey:"echarts.label.position.radar.top"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.radar.bottom"},{value:"left",label:"左侧",labelKey:"echarts.label.position.radar.left"},{value:"right",label:"右侧",labelKey:"echarts.label.position.radar.right"},{value:"inside",label:"内部",labelKey:"echarts.label.position.radar.inside"}],funnel:[{value:"outer",label:"外侧",labelKey:"echarts.label.position.funnel.outer"},{value:"inner",label:"内部",labelKey:"echarts.label.position.funnel.inner"},{value:"left",label:"左侧",labelKey:"echarts.label.position.funnel.left"},{value:"right",label:"右侧",labelKey:"echarts.label.position.funnel.right"},{value:"top",label:"顶部",labelKey:"echarts.label.position.funnel.top"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.funnel.bottom"}],gauge:[]},Ue={bar:!1,line:!1,pie:!0,scatter:!1,radar:!1,funnel:!0,gauge:!0},Be={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}},qe={barHChart:{position:"right",fontSize:12}},Ge={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"]},Ve=["formatter","overflow","position","distance","rotate","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding"];function Xe(e){const t=e?.series;return Array.isArray(t)?t:[]}function k(e){return e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function G(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 b(e)?.seriesType==="gauge"?"detail":"label"}function Ye(e){const t=b(e);return t?Ge[t.seriesType]:[]}function Je(e,t){const r=b(t),a=Xe(e),n=k(a[0]?.[M(t)]);G(n);const i={show:typeof n.show=="boolean"?n.show:r?Ue[r.seriesType]:!1,labelLine:k(a[0]?.labelLine)};for(const l of Ve){const s=n[l];l!=="offset"&&(typeof s=="string"||typeof s=="number")&&(i[l]=s)}const o=n.offset;return Array.isArray(o)&&typeof o[0]=="number"&&typeof o[1]=="number"&&(i.offset=[o[0],o[1]]),i}function Qe(e){const t=b(e);return t?{...Be[t.seriesType],...qe[e]}:{}}function ee(e){return e==null||e===""}function Ze(e,t,r){const a=T(e??{}),n=Array.isArray(a.series)?a.series:[];if(!b(t)||n.length===0)return a;const o=M(t),{enabled:l,labelLine:s,...c}=r;for(const u of n){if(!u||typeof u!="object")continue;const f=k(u[o]);G(f),l===!0?Object.assign(f,{...Qe(t),...f,show:!0}):l===!1&&(f.show=!1);for(const[d,y]of Object.entries(c))ee(y)?delete f[d]:f[d]=y;if(s){const d=k(u.labelLine);for(const[y,h]of Object.entries(s))ee(h)?delete d[y]:d[y]=h;u.labelLine=d}u[o]=f}return a}function et(e){return Array.isArray(e)?e.map(t=>({...t})):[]}function tt(e,t){const r={...e,type:t?"value":"category"};return t?delete r.data:Array.isArray(r.data)||(r.data=["$data"]),r}function rt(e,t){const r={...e,type:t?"category":"value"};return t&&!Array.isArray(r.data)&&(r.data=["$data"]),t||delete r.data,r}function N(e,t){return Array.isArray(e)?e.map(r=>t({...r})):t(e&&typeof e=="object"?{...e}:{})}function ue(e,t){const r=b(e);if(!r)return t;const a=structuredClone(t),n=et(a.series);if(n.length===0)return a;const i=M(e);for(const s of n){const c=s[i];if(c&&typeof c=="object"&&!Array.isArray(c)){const u={...c};G(u),s[i]=u}}if(r.seriesType==="pie")return a.series=n.map(s=>({...s,type:"pie",...e==="doughnutChart"?{radius:s.radius??["40%","70%"]}:{}})),delete a.xAxis,delete a.yAxis,a;if(r.seriesType==="scatter")return a.series=n.map(s=>({...s,type:"scatter"})),a.xAxis=N(a.xAxis,s=>({...s,type:"value",data:void 0})),a.yAxis=N(a.yAxis,s=>({...s,type:"value",data:void 0})),a;if(r.seriesType==="radar")return a.series=n.map(s=>({...s,type:"radar"})),a;if(r.seriesType==="funnel")return a.series=n.map(s=>({...s,type:"funnel",sort:"descending"})),a;if(r.seriesType==="gauge")return a.series=n.map(s=>({...s,type:"gauge"})),a;const o=r.orientation==="horizontal",l=r.seriesType==="line"?"line":"bar";return a.xAxis=N(a.xAxis,s=>tt(s,o)),a.yAxis=N(a.yAxis,s=>rt(s,o)),a.series=n.map(s=>{const c={...s,type:l};return e==="areaChart"?c.areaStyle=s.areaStyle??{}:delete c.areaStyle,c}),a}function fe(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(";"),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}">`;return e.slice(0,a.index)+u+e.slice(a.index+n.length)}function de(e){Re();const t=ue(e.type,e.option);if(!t||typeof t!="object"||Array.isArray(t))throw new Error("图表 option 非法:需要对象");const r=C(e.widthMm),a=C(e.heightMm),n=B.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,o={...e.fontFamily?{fontFamily:e.fontFamily}:{},...i??{}};return n.setOption({animation:!1,...t,...Object.keys(o).length>0?{textStyle:o}:{}}),fe(n.renderToSVGString(),r,a)}finally{n.dispose()}}function at(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function U(e){const t=e._chartOption??e.chartOption,r=`<span>${at(String(e.title??"图表"))}</span>`;if(!t||typeof t!="object"||Array.isArray(t))return r;try{return de({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 nt="2";function ye(e=!1){return{chartOption:{kind:"object",get label(){return A.t("echarts.meta.chartOption")}},chartDataSource:{kind:"text",get label(){return A.t("echarts.meta.dataSource")}},chartCategoryField:{kind:"text",get label(){return A.t("echarts.meta.categoryField")}},chartValueFields:{kind:"object",get label(){return A.t("echarts.meta.valueFields")}},chartSeriesField:{kind:"text",get label(){return A.t("echarts.meta.seriesField")}},...e?{chartBubble:{kind:"bool",get label(){return A.t("echarts.meta.bubbleSize")}}}:{}}}const it=ye(),st=ye(!0),_=x.defineElementPlugin({id:L,version:nt,kinds:I.map(e=>({type:e.type,get label(){return A.t(e.labelKey)},icon:e.icon,fixedHeight:!0,requiredOptionKeys:e.requiredOptionKeys,get notes(){return A.t(e.notesKey)},optionMeta:e.type==="scatterChart"?st:it,defaultOptions:t=>le(e.type,t),binding:{bind:(t,r)=>te(e.type,t,r)}})),render:{html:U,createRenderer:()=>({render:U})}});let w;function j(e,t){const r=x.getElementPluginById(L);if(!e&&!t){const i=x.registerElementPlugin(_);return w=i,i}const a={..._,designer:e??r?.designer??_.designer,render:{..._.render,...r?.render,...t}},n=x.registerElementPlugin(a);return w=n,n}function ot(e){return j(e)}function lt(e){return j(void 0,{executorBundle:e})}function ct(){w?.(),w=void 0}j();exports.CHART_KINDS=me;exports.CHART_KIND_DEFINITIONS=I;exports.CHART_PALETTES=$;exports.CHART_PLUGIN=_;exports.CHART_PLUGIN_ID=L;exports.ECHARTS_FUNNEL_PADDING_PX=O;exports.ECHARTS_RADAR_RADIUS_DEFAULT=ie;exports.FALLBACK_SAMPLE_CATEGORIES=re;exports.FUNNEL_PADDING_DEFAULTS=ae;exports.LABEL_POSITIONS=We;exports.LABEL_PRESETS=$e;exports.RADAR_RADIUS_DEFAULT=ne;exports.asObject=q;exports.bindChartData=te;exports.chartFactoryDefaults=le;exports.cloneChartOption=T;exports.configureChartPlugin=Fe;exports.createDefaultChartOption=se;exports.fitSvgRoot=fe;exports.getChartKindDefinition=b;exports.getChartPalettes=Le;exports.getChartPluginConfig=R;exports.getSampleCategories=oe;exports.labelFieldsOf=Ye;exports.labelTargetOf=M;exports.mmToChartPx=C;exports.normalizeChartOption=ue;exports.previewChartOption=Ne;exports.readChartLabel=Je;exports.readFunnelPadding=He;exports.readPaletteKey=ke;exports.readRadarRadius=je;exports.registerChartDesigner=ot;exports.registerChartExecutorBundle=lt;exports.registerChartPlugin=j;exports.renderChartElement=U;exports.renderChartToSvg=de;exports.resolveChartPanelFields=Ae;exports.syncSeriesCount=we;exports.uninstallChartPlugin=ct;exports.updateChartLabel=Ze;exports.writeFunnelPadding=Me;exports.writeRadarRadius=ze;