@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.
package/dist/ui.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
@@ -74,6 +74,8 @@ var zh_CN_default = {
74
74
  "echarts.panel.labelLine.length2": "\u7B2C\u4E8C\u6BB5\u957F\u5EA6",
75
75
  "echarts.panel.labelLine.smooth": "\u5E73\u6ED1\u5F15\u5BFC\u7EBF",
76
76
  "echarts.panel.dataSourceTitle": "\u6570\u636E\u6E90",
77
+ "echarts.panel.selectField": "\u9009\u62E9\u5B57\u6BB5",
78
+ "echarts.panel.autoSource": "\u81EA\u52A8",
77
79
  "echarts.panel.categoryField": "\u7C7B\u76EE\u5B57\u6BB5",
78
80
  "echarts.panel.removeField": "\u5220\u9664\u8BE5\u5B57\u6BB5",
79
81
  "echarts.panel.addField": "+ \u6DFB\u52A0\u5B57\u6BB5",
@@ -229,6 +231,8 @@ var en_US_default = {
229
231
  "echarts.panel.labelLine.length2": "Second segment length",
230
232
  "echarts.panel.labelLine.smooth": "Smooth label line",
231
233
  "echarts.panel.dataSourceTitle": "Data source",
234
+ "echarts.panel.selectField": "Select field",
235
+ "echarts.panel.autoSource": "Auto",
232
236
  "echarts.panel.categoryField": "Category field",
233
237
  "echarts.panel.removeField": "Remove this field",
234
238
  "echarts.panel.addField": "+ Add field",
@@ -384,6 +388,8 @@ var th_TH_default = {
384
388
  "echarts.panel.labelLine.length2": "\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E17\u0E48\u0E2D\u0E19\u0E17\u0E35\u0E48\u0E2A\u0E2D\u0E07",
385
389
  "echarts.panel.labelLine.smooth": "\u0E40\u0E2A\u0E49\u0E19\u0E1B\u0E49\u0E32\u0E22\u0E42\u0E04\u0E49\u0E07",
386
390
  "echarts.panel.dataSourceTitle": "\u0E41\u0E2B\u0E25\u0E48\u0E07\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25",
391
+ "echarts.panel.selectField": "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E1F\u0E34\u0E25\u0E14\u0E4C",
392
+ "echarts.panel.autoSource": "\u0E2D\u0E31\u0E15\u0E42\u0E19\u0E21\u0E31\u0E15\u0E34",
387
393
  "echarts.panel.categoryField": "\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E2B\u0E21\u0E27\u0E14\u0E2B\u0E21\u0E39\u0E48",
388
394
  "echarts.panel.removeField": "\u0E25\u0E1A\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E19\u0E35\u0E49",
389
395
  "echarts.panel.addField": "+ \u0E40\u0E1E\u0E34\u0E48\u0E21\u0E1F\u0E34\u0E25\u0E14\u0E4C",
@@ -928,8 +934,8 @@ function chartFactoryDefaults(type, partial) {
928
934
  title: def?.label ?? "\u56FE\u8868",
929
935
  chartOption: createDefaultChartOption(type),
930
936
  chartDataSource: "",
931
- chartCategoryField: "name",
932
- chartValueFields: ["value"],
937
+ chartCategoryField: "",
938
+ chartValueFields: [],
933
939
  chartSeriesField: "",
934
940
  ...partial
935
941
  };
@@ -1521,17 +1527,30 @@ function renderChartElement(spec) {
1521
1527
  var CHART_EXECUTOR_VERSION = "2";
1522
1528
 
1523
1529
  // src/plugin.ts
1524
- var CHART_OPTION_META = {
1525
- chartOption: { kind: "object", label: t("echarts.meta.chartOption") },
1526
- chartDataSource: { kind: "text", label: t("echarts.meta.dataSource") },
1527
- chartCategoryField: { kind: "text", label: t("echarts.meta.categoryField") },
1528
- chartValueFields: { kind: "object", label: t("echarts.meta.valueFields") },
1529
- chartSeriesField: { kind: "text", label: t("echarts.meta.seriesField") }
1530
- };
1531
- var SCATTER_OPTION_META = {
1532
- ...CHART_OPTION_META,
1533
- chartBubble: { kind: "bool", label: t("echarts.meta.bubbleSize") }
1534
- };
1530
+ function createChartOptionMeta(includeBubble = false) {
1531
+ return {
1532
+ chartOption: { kind: "object", get label() {
1533
+ return t("echarts.meta.chartOption");
1534
+ } },
1535
+ chartDataSource: { kind: "text", get label() {
1536
+ return t("echarts.meta.dataSource");
1537
+ } },
1538
+ chartCategoryField: { kind: "text", get label() {
1539
+ return t("echarts.meta.categoryField");
1540
+ } },
1541
+ chartValueFields: { kind: "object", get label() {
1542
+ return t("echarts.meta.valueFields");
1543
+ } },
1544
+ chartSeriesField: { kind: "text", get label() {
1545
+ return t("echarts.meta.seriesField");
1546
+ } },
1547
+ ...includeBubble ? { chartBubble: { kind: "bool", get label() {
1548
+ return t("echarts.meta.bubbleSize");
1549
+ } } } : {}
1550
+ };
1551
+ }
1552
+ var CHART_OPTION_META = createChartOptionMeta();
1553
+ var SCATTER_OPTION_META = createChartOptionMeta(true);
1535
1554
  var CHART_PLUGIN = defineElementPlugin({
1536
1555
  id: CHART_PLUGIN_ID,
1537
1556
  version: CHART_EXECUTOR_VERSION,
@@ -1592,18 +1611,9 @@ var CANVAS_STYLE = "width:100%;height:100%;min-width:0;min-height:0;pointer-even
1592
1611
  var STYLES = [
1593
1612
  ".echarts-canvas-element{overflow:hidden}",
1594
1613
  ".echarts-field-row{display:flex;gap:6px;align-items:center}",
1614
+ ".echarts-field-current{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--pd-text-secondary,#6b7280)}",
1595
1615
  ".echarts-field-row>.pd-input{flex:1;min-width:0}",
1596
1616
  ".echarts-field-row>.pd-button{flex:none}",
1597
- ".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}",
1598
- ".echarts-dropdown-trigger:hover{border-color:var(--pd-text-faint,#b4b9c4)}",
1599
- '.echarts-dropdown-trigger[aria-expanded="true"]{border-color:var(--pd-accent,#165dff);box-shadow:0 0 0 2px rgb(22 93 255 / 12%)}',
1600
- ".echarts-dropdown-value{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
1601
- ".echarts-dropdown-arrow{flex:none;color:var(--pd-text-muted,#909399);font-size:10px;transition:transform .14s}",
1602
- '.echarts-dropdown-trigger[aria-expanded="true"] .echarts-dropdown-arrow{transform:rotate(180deg)}',
1603
- ".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}",
1604
- ".echarts-dropdown-option{padding:5px 8px;border-radius:4px;cursor:pointer;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",
1605
- ".echarts-dropdown-option:hover{background:var(--pd-accent-soft,rgb(22 93 255 / 9%))}",
1606
- ".echarts-dropdown-option.is-active{background:var(--pd-accent-soft,rgb(22 93 255 / 9%));color:var(--pd-accent,#165dff)}",
1607
1617
  ".echarts-label-group{margin-top:8px;border-top:1px solid var(--pd-border,#e5e7eb);padding-top:8px}",
1608
1618
  ".echarts-label-group>summary{display:flex;align-items:center;cursor:pointer;list-style:none;font-size:12px;font-weight:600}",
1609
1619
  ".echarts-label-summary>.pd-field{flex:1;margin:0;font-weight:400}",
@@ -1684,22 +1694,6 @@ function valueFieldsLabel(def, limit) {
1684
1694
  if (def?.seriesType === "radar") return t2("echarts.panel.field.dimension");
1685
1695
  return limit === 1 ? t2("echarts.panel.field.value") : t2("echarts.panel.field.valueMulti");
1686
1696
  }
1687
- function dataSourceCandidates(data, fields) {
1688
- const first = data?.[0];
1689
- const keys = first ? Object.keys(first).filter((key) => Array.isArray(first[key])) : [];
1690
- for (const field2 of fields ?? []) {
1691
- if (field2.fieldType === "list" && field2.fieldKey && !keys.includes(field2.fieldKey)) keys.push(field2.fieldKey);
1692
- }
1693
- return keys;
1694
- }
1695
- function dataRowFields(data, dataSource) {
1696
- const first = data?.[0];
1697
- if (!first) return [];
1698
- const key = dataSource ? Array.isArray(first[dataSource]) ? dataSource : "" : Object.keys(first).find((k) => Array.isArray(first[k]));
1699
- if (!key) return [];
1700
- const rows = first[key];
1701
- return rows.length > 0 && typeof rows[0] === "object" && rows[0] !== null ? Object.keys(rows[0]) : [];
1702
- }
1703
1697
  function fieldLabelMap(fields) {
1704
1698
  const map = /* @__PURE__ */ new Map();
1705
1699
  for (const field2 of fields ?? []) {
@@ -1707,17 +1701,41 @@ function fieldLabelMap(fields) {
1707
1701
  }
1708
1702
  return map;
1709
1703
  }
1710
- function optionLabel(value, labels, fallbackSuffix) {
1711
- if (!value) return fallbackSuffix ?? t2("echarts.panel.default");
1704
+ function optionLabel(value, labels) {
1705
+ if (!value) return t2("echarts.panel.default");
1712
1706
  const name = labels.get(value);
1713
- const base = name ? `${name}\uFF08${value}\uFF09` : value;
1714
- return fallbackSuffix ? `${base}${fallbackSuffix}` : base;
1715
- }
1716
- function dropdownOptions(candidates, current, labels = /* @__PURE__ */ new Map()) {
1717
- const opts = candidates.map((value) => ({ value, label: optionLabel(value, labels) }));
1718
- if (current && !candidates.includes(current)) opts.unshift({ value: current, label: optionLabel(current, labels, t2("echarts.panel.current")) });
1719
- if (!current) opts.unshift({ value: "", label: t2("echarts.panel.defaultFirstArray") });
1720
- return opts;
1707
+ return name ? `${name}\uFF08${value}\uFF09` : value;
1708
+ }
1709
+ function fieldBindingKey(next) {
1710
+ if (next.binding) return next.binding;
1711
+ const matched = /^\{\s*([^{}]+?)\s*\}$/.exec(next.formatter?.trim() ?? "");
1712
+ return matched?.[1]?.trim() ?? "";
1713
+ }
1714
+ function fieldPicker(ctx, current, targetPath, fields, labels, onSelect, allowAuto = false) {
1715
+ const row = el("div", "echarts-field-row");
1716
+ const display = el(
1717
+ "span",
1718
+ "echarts-field-current",
1719
+ current ? optionLabel(current, labels) : allowAuto ? t2("echarts.panel.autoSource") : t2("echarts.panel.default")
1720
+ );
1721
+ const picker = el("button", "pd-button small echarts-field-picker", t2("echarts.panel.selectField"));
1722
+ picker.type = "button";
1723
+ picker.addEventListener("click", () => ctx.openExpression({
1724
+ elementId: ctx.element.id,
1725
+ targetPath,
1726
+ value: current ? `{${current}}` : "",
1727
+ binding: current || void 0,
1728
+ fieldOnly: true,
1729
+ fields
1730
+ }, (next) => onSelect(fieldBindingKey(next))));
1731
+ row.append(display, picker);
1732
+ if (allowAuto) {
1733
+ const auto = el("button", "pd-button small echarts-auto-source", t2("echarts.panel.autoSource"));
1734
+ auto.type = "button";
1735
+ auto.addEventListener("click", () => onSelect(""));
1736
+ row.appendChild(auto);
1737
+ }
1738
+ return row;
1721
1739
  }
1722
1740
  function seriesList(option) {
1723
1741
  return Array.isArray(option.series) ? option.series : [];
@@ -1797,84 +1815,6 @@ function selectInput(options, value, onCommit) {
1797
1815
  select.addEventListener("change", () => onCommit(select.value));
1798
1816
  return select;
1799
1817
  }
1800
- var activeDropdown = null;
1801
- function composedPathOf(ev) {
1802
- const composed = typeof ev.composedPath === "function" ? ev.composedPath() : [];
1803
- return composed.length ? composed : [ev.target];
1804
- }
1805
- function dropdownSelect(options, value, onCommit) {
1806
- const current = options.find((item) => item.value === value) ?? { value, label: value || t2("echarts.panel.optionDefault") };
1807
- const trigger = el("button", "echarts-dropdown-trigger");
1808
- trigger.type = "button";
1809
- trigger.setAttribute("aria-haspopup", "listbox");
1810
- trigger.setAttribute("aria-expanded", "false");
1811
- const valueEl = el("span", "echarts-dropdown-value", current.label);
1812
- const arrow = el("span", "echarts-dropdown-arrow", "\u25BE");
1813
- trigger.appendChild(valueEl);
1814
- trigger.appendChild(arrow);
1815
- let panel = null;
1816
- let off = [];
1817
- const close = () => {
1818
- off.forEach((fn) => fn());
1819
- off = [];
1820
- panel?.remove();
1821
- panel = null;
1822
- trigger.setAttribute("aria-expanded", "false");
1823
- if (activeDropdown?.close === close) activeDropdown = null;
1824
- };
1825
- const open = () => {
1826
- activeDropdown?.close();
1827
- const root = trigger.getRootNode();
1828
- const mount = root instanceof ShadowRoot ? root : document.body;
1829
- panel = el("div", "echarts-dropdown-panel");
1830
- panel.setAttribute("role", "listbox");
1831
- for (const item of options) {
1832
- const optionEl = el("div", `echarts-dropdown-option${item.value === value ? " is-active" : ""}`, item.label);
1833
- optionEl.setAttribute("role", "option");
1834
- optionEl.setAttribute("aria-selected", item.value === value ? "true" : "false");
1835
- optionEl.addEventListener("click", (ev) => {
1836
- ev.stopPropagation();
1837
- close();
1838
- onCommit(item.value);
1839
- });
1840
- panel.appendChild(optionEl);
1841
- }
1842
- mount.appendChild(panel);
1843
- const rect = trigger.getBoundingClientRect();
1844
- panel.style.left = `${rect.left}px`;
1845
- panel.style.top = `${rect.bottom + 4}px`;
1846
- panel.style.minWidth = `${rect.width}px`;
1847
- trigger.setAttribute("aria-expanded", "true");
1848
- activeDropdown = { close };
1849
- const onPointerDown = (ev) => {
1850
- const path = composedPathOf(ev);
1851
- if (path.includes(trigger) || path.includes(panel)) return;
1852
- close();
1853
- };
1854
- const onKeydown = (ev) => {
1855
- if (ev.key === "Escape") close();
1856
- };
1857
- const onScroll = () => close();
1858
- document.addEventListener("pointerdown", onPointerDown, true);
1859
- document.addEventListener("keydown", onKeydown);
1860
- window.addEventListener("scroll", onScroll, true);
1861
- window.addEventListener("resize", onScroll);
1862
- root.addEventListener("scroll", onScroll, true);
1863
- off.push(
1864
- () => document.removeEventListener("pointerdown", onPointerDown, true),
1865
- () => document.removeEventListener("keydown", onKeydown),
1866
- () => window.removeEventListener("scroll", onScroll, true),
1867
- () => window.removeEventListener("resize", onScroll),
1868
- () => root.removeEventListener("scroll", onScroll, true)
1869
- );
1870
- };
1871
- trigger.addEventListener("click", (ev) => {
1872
- ev.stopPropagation();
1873
- if (panel) close();
1874
- else open();
1875
- });
1876
- return trigger;
1877
- }
1878
1818
  var overflowOptions = () => [
1879
1819
  { value: "", label: t2("echarts.panel.overflow.default") },
1880
1820
  { value: "none", label: t2("echarts.panel.overflow.none") },
@@ -2056,60 +1996,67 @@ function renderProperty(ctx) {
2056
1996
  return withTranslator(ctx.t, () => renderPropertyInner(ctx));
2057
1997
  }
2058
1998
  function renderPropertyInner(ctx) {
1999
+ 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");
2059
2000
  const element = ctx.element;
2060
2001
  const type = elementType(element);
2061
2002
  const def = getChartKindDefinition(type);
2062
- const fields = resolveChartPanelFields(type);
2063
- const has = (key) => fields.includes(key);
2003
+ const panelFields = resolveChartPanelFields(type);
2004
+ const has = (key) => panelFields.includes(key);
2064
2005
  const options = element.options;
2065
2006
  const widthMm = Number(options.width) || 0;
2066
2007
  const heightMm = Number(options.height) || 0;
2067
2008
  const limit = maxValueFields(def);
2068
2009
  const palettes = getChartPalettes();
2069
2010
  const fieldLabels = fieldLabelMap(ctx.fields);
2011
+ const allFields = ctx.fields ?? [];
2012
+ const sourceFields = allFields.filter((field2) => field2.fieldType === "list");
2013
+ const bound = String(options.chartDataSource ?? "");
2014
+ const prefixed = bound ? allFields.filter((field2) => field2.fieldKey.startsWith(`${bound}.`)) : [];
2015
+ const rowFields = prefixed.length > 0 ? prefixed : allFields.filter((field2) => field2.fieldType !== "list");
2070
2016
  const root = el("div", "echarts-property");
2071
2017
  const form = el("form", "pd-form");
2072
2018
  form.addEventListener("submit", (event) => event.preventDefault());
2073
2019
  root.appendChild(form);
2074
2020
  if (has("dataSource")) {
2075
2021
  const wrap = field(t2("echarts.panel.dataSourceTitle"));
2076
- const current = String(options.chartDataSource ?? "");
2077
- wrap.appendChild(
2078
- dropdownSelect(
2079
- dropdownOptions(dataSourceCandidates(ctx.data, ctx.fields), current, fieldLabels),
2080
- current,
2081
- (value) => commitOption(ctx, type, panelOption(element), { chartDataSource: value })
2082
- )
2083
- );
2022
+ wrap.appendChild(fieldPicker(
2023
+ ctx,
2024
+ String(options.chartDataSource ?? ""),
2025
+ "options.chartDataSource",
2026
+ sourceFields,
2027
+ fieldLabels,
2028
+ (value) => commitOption(ctx, type, panelOption(element), { chartDataSource: value }),
2029
+ true
2030
+ ));
2084
2031
  form.appendChild(wrap);
2085
2032
  }
2086
2033
  if (has("categoryField")) {
2087
2034
  const wrap = field(t2("echarts.panel.categoryField"));
2088
- const current = String(options.chartCategoryField ?? "");
2089
- wrap.appendChild(
2090
- dropdownSelect(
2091
- dropdownOptions(dataRowFields(ctx.data, String(options.chartDataSource ?? "")), current, fieldLabels),
2092
- current,
2093
- (value) => commitOption(ctx, type, panelOption(element), { chartCategoryField: value })
2094
- )
2095
- );
2035
+ wrap.appendChild(fieldPicker(
2036
+ ctx,
2037
+ String(options.chartCategoryField ?? ""),
2038
+ "options.chartCategoryField",
2039
+ rowFields,
2040
+ fieldLabels,
2041
+ (value) => commitOption(ctx, type, panelOption(element), { chartCategoryField: value })
2042
+ ));
2096
2043
  form.appendChild(wrap);
2097
2044
  }
2098
2045
  if (has("valueFields")) {
2099
2046
  const wrap = field(valueFieldsLabel(def, limit));
2100
2047
  const fieldsNow = readValueFields(element);
2101
2048
  fieldsNow.forEach((value, index) => {
2102
- const row = el("div", "echarts-field-row");
2103
- row.appendChild(
2104
- dropdownSelect(
2105
- dropdownOptions(dataRowFields(ctx.data, String(options.chartDataSource ?? "")), value, fieldLabels),
2106
- value,
2107
- (next) => {
2108
- const list = readValueFields(element);
2109
- list[index] = next;
2110
- syncValueFields(ctx, type, list);
2111
- }
2112
- )
2049
+ const row = fieldPicker(
2050
+ ctx,
2051
+ value,
2052
+ `options.chartValueFields.${index}`,
2053
+ rowFields,
2054
+ fieldLabels,
2055
+ (next) => {
2056
+ const list = readValueFields(element);
2057
+ list[index] = next;
2058
+ syncValueFields(ctx, type, list);
2059
+ }
2113
2060
  );
2114
2061
  if (fieldsNow.length > 1) {
2115
2062
  const remove = el("button", "pd-button small", "\u2212");
@@ -2130,12 +2077,14 @@ function renderPropertyInner(ctx) {
2130
2077
  }
2131
2078
  if (has("seriesField")) {
2132
2079
  const wrap = field(t2("echarts.panel.seriesField"));
2133
- wrap.appendChild(
2134
- textInput(
2135
- { value: String(options.chartSeriesField ?? ""), placeholder: t2("echarts.panel.seriesFieldHint") },
2136
- (value) => commitOption(ctx, type, panelOption(element), { chartSeriesField: value })
2137
- )
2138
- );
2080
+ wrap.appendChild(fieldPicker(
2081
+ ctx,
2082
+ String(options.chartSeriesField ?? ""),
2083
+ "options.chartSeriesField",
2084
+ rowFields,
2085
+ fieldLabels,
2086
+ (value) => commitOption(ctx, type, panelOption(element), { chartSeriesField: value })
2087
+ ));
2139
2088
  form.appendChild(wrap);
2140
2089
  }
2141
2090
  if (has("bubble")) {
@@ -2288,7 +2237,9 @@ var CHART_ELEMENT_UI = defineElementUI({
2288
2237
  renderCanvas,
2289
2238
  renderProperty,
2290
2239
  hasProperties: chartHasProperties,
2291
- group: t2("echarts.panel.group"),
2240
+ get group() {
2241
+ return t2("echarts.panel.group");
2242
+ },
2292
2243
  searchKeywords: SEARCH_KEYWORDS,
2293
2244
  styles: STYLES,
2294
2245
  i18nId: "echarts",
package/dist/units.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/version.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worm-print-platform/echarts",
3
- "version": "1.6.3",
3
+ "version": "1.6.5",
4
4
  "type": "module",
5
5
  "description": "兼容镜像包:源码唯一真源在 marketplace/plugins/echarts(@worm-print-platform/plugin-echarts),本包由同一源码生成,保留原包名与子路径供存量依赖方零改动使用",
6
6
  "main": "./dist/index.cjs",
@@ -45,7 +45,7 @@
45
45
  "dir": "dist/i18n",
46
46
  "base": "zh-CN"
47
47
  },
48
- "version": "1.6.3",
48
+ "version": "1.6.5",
49
49
  "entry": "dist/marketplace.js",
50
50
  "kinds": [
51
51
  "barChart",
@@ -61,8 +61,8 @@
61
61
  ],
62
62
  "exportFormats": [],
63
63
  "peerDeps": {
64
- "@worm-print-platform/core": "^1.6.3",
65
- "@worm-print-platform/plugin-kit": "^1.6.3"
64
+ "@worm-print-platform/core": "^1.6.5",
65
+ "@worm-print-platform/plugin-kit": "^1.6.5"
66
66
  }
67
67
  },
68
68
  "license": "MIT",
@@ -87,8 +87,8 @@
87
87
  "test:watch": "npm --prefix ../../marketplace/plugins/echarts run test:watch"
88
88
  },
89
89
  "dependencies": {
90
- "@worm-print-platform/core": "^1.6.3",
91
- "@worm-print-platform/plugin-kit": "^1.6.3",
90
+ "@worm-print-platform/core": "^1.6.5",
91
+ "@worm-print-platform/plugin-kit": "^1.6.5",
92
92
  "echarts": "^6.1.0"
93
93
  },
94
94
  "devDependencies": {
@@ -1,6 +0,0 @@
1
- /*!
2
- * @worm-print-platform/echarts v1.6.3
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[i,n]of Object.entries(e)){const o=r||i==="label"||i==="detail";a[i]=z(n,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:"",i=r||a;if(i)return Array.isArray(t[i])?t[i]:[];for(const n of Object.values(t))if(Array.isArray(n))return n;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],i=Array.isArray(a)?a:a?[a]:[];for(const n of i)n&&typeof n=="object"&&Array.isArray(n.data)&&n.data.includes("$data")&&(n.data=[...t])}}function Ke(e,t,r,a,i){const n=F(e);if(!n.some(K))return;const o=t.map((c,u)=>r?c[r]:u+1),l=c=>a[Math.min(c,a.length-1)];if(i){const c=n[0],u=new Map;for(const d of t){const y=String(d[i]??""),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=n[n.length-1];for(;n.length<a.length;)n.push({...s,data:["$data"]});e.series=n.map((c,u)=>K(c)?{...c,data:t.map(f=>m(f,l(u)))}:c),Y(e,o)}function J(e,t,r,a,i){const n=F(e);if(!n.some(K))return;const o=t.map(l=>({name:r?String(l[r]??""):"",value:m(l,a)}));i&&o.sort((l,s)=>s.value-l.value),e.series=n.map(l=>({...l,data:o}))}function Te(e,t,r,a,i){const n=F(e);if(!n.some(K))return;const o=a[0],l=i?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=n.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 i=F(e);if(!i.some(K))return;const n=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(n[l])}))},e.series=i.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 i=t[0]??{};e.series=a.map(n=>({...n,data:[{value:m(i,r),name:r}]}))}function te(e,t,r){const a=t.chartOption;if(!a||typeof a!="object"||Array.isArray(a))return{};const i=z(a,r),n=xe(t.chartValueFields);if(n.length===0)return{_chartOption:i};const o=Ce(t,r);if(o.length===0)return{_chartOption:i};const l=X(t.chartCategoryField);switch(b(e)?.seriesType){case"radar":Oe(i,o,l,n);break;case"gauge":Ee(i,o,n[0]);break;case"funnel":J(i,o,l,n[0],!0);break;case"pie":J(i,o,l,n[0],!1);break;case"scatter":Te(i,o,l,n,t.chartBubble===!0);break;default:Ke(i,o,l,n,X(t.chartSeriesField));break}return{_chartOption:i}}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},ie=75,ne=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:`${ie}%`},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",i=t?.seriesType==="line"&&e==="areaChart",n=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:n,name:"数量",data:["$data"],...i?{areaStyle:{}}:{}}]}}}}function Fe(e){x.configurePlugin(L,e)}function R(){return x.getPluginConfig(L)}function Le(){const e=R().palettes??{},t=$.map(a=>{const i=e[a.key];return i?{key:a.key,label:i.label??a.label,labelKey:i.label?void 0:a.labelKey,colors:i.colors}:{key:a.key,label:a.label,labelKey:a.labelKey,colors:a.colors}}),r=Object.entries(e).filter(([a])=>!$.some(i=>i.key===a)).map(([a,i])=>({key:a,label:i.label??a,colors:i.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:"name",chartValueFields:["value"],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),i=[...oe()],n=[...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=[...i])}};switch(a?.seriesType){case"pie":l(()=>i.map((c,u)=>({name:c,value:n[u]??10})));break;case"funnel":l(()=>i.map((c,u)=>({name:c,value:n[u]??10})));break;case"scatter":l(()=>n.map(c=>[c,c+6]));break;case"radar":r.radar={...r.radar??{},indicator:i.map(c=>({name:c,max:30}))},l(()=>[{name:"示例",value:n}]);break;case"gauge":l(()=>[{value:n[0]??40,name:"数量"}]);break;default:l(()=>[...n]),s();break}return r}function ke(e,t){const r=Array.isArray(e?.color)?(e?.color).map(String):[];return t.find(i=>i.colors.every((n,o)=>n===r[o])&&r.length===i.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),i=Array.isArray(a.series)?a.series:[],n=b(r),o=i[0]??{type:n?.seriesType==="line"?"line":"bar",data:["$data"]};return a.series=Array.from({length:Math.max(t,1)},(l,s)=>({...o,...i[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 i=Ie(e&&typeof e=="object"?e:{}),n=C(t),o=C(r);return{top:D(i.top,o,O.top),right:D(i.right,n,O.right),bottom:D(i.bottom,o,O.bottom),left:D(i.left,n,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 i=a[0];return i.top=E(t.top),i.right=E(t.right),i.bottom=E(t.bottom),i.left=E(t.left),r.series=a,r}function je(e,t,r){const i=q((e&&typeof e=="object"?e:{}).radar).radius,n=Array.isArray(i)?i[i.length-1]:i,o=C(t),l=C(r),s=Math.min(o,l)/2;if(typeof n=="string"&&n.trim().endsWith("%")){const c=Number.parseFloat(n);if(Number.isFinite(c))return H(c)}return typeof n=="number"&&Number.isFinite(n)?W(n,s):ne}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),i=k(a[0]?.[M(t)]);G(i);const n={show:typeof i.show=="boolean"?i.show:r?Ue[r.seriesType]:!1,labelLine:k(a[0]?.labelLine)};for(const l of Ve){const s=i[l];l!=="offset"&&(typeof s=="string"||typeof s=="number")&&(n[l]=s)}const o=i.offset;return Array.isArray(o)&&typeof o[0]=="number"&&typeof o[1]=="number"&&(n.offset=[o[0],o[1]]),n}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??{}),i=Array.isArray(a.series)?a.series:[];if(!b(t)||i.length===0)return a;const o=M(t),{enabled:l,labelLine:s,...c}=r;for(const u of i){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),i=et(a.series);if(i.length===0)return a;const n=M(e);for(const s of i){const c=s[n];if(c&&typeof c=="object"&&!Array.isArray(c)){const u={...c};G(u),s[n]=u}}if(r.seriesType==="pie")return a.series=i.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=i.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=i.map(s=>({...s,type:"radar"})),a;if(r.seriesType==="funnel")return a.series=i.map(s=>({...s,type:"funnel",sort:"descending"})),a;if(r.seriesType==="gauge")return a.series=i.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=i.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 i=a[0],n=i.slice(4,-1),l=(/\sstyle\s*=\s*"([^"]*)"/i.exec(n)?.[1]??"").split(";").map(f=>f.trim()).filter(f=>f&&!/^(width|height|display)\s*:/i.test(f)).join(";"),s=n.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+i.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),i=B.init(null,null,{renderer:"svg",ssr:!0,width:r,height:a});try{const n=t.textStyle&&typeof t.textStyle=="object"&&!Array.isArray(t.textStyle)?t.textStyle:void 0,o={...e.fontFamily?{fontFamily:e.fontFamily}:{},...n??{}};return i.setOption({animation:!1,...t,...Object.keys(o).length>0?{textStyle:o}:{}}),fe(i.renderToSVGString(),r,a)}finally{i.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 it="2",ye={chartOption:{kind:"object",label:A.t("echarts.meta.chartOption")},chartDataSource:{kind:"text",label:A.t("echarts.meta.dataSource")},chartCategoryField:{kind:"text",label:A.t("echarts.meta.categoryField")},chartValueFields:{kind:"object",label:A.t("echarts.meta.valueFields")},chartSeriesField:{kind:"text",label:A.t("echarts.meta.seriesField")}},nt={...ye,chartBubble:{kind:"bool",label:A.t("echarts.meta.bubbleSize")}},_=x.defineElementPlugin({id:L,version:it,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"?nt:ye,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 n=x.registerElementPlugin(_);return w=n,n}const a={..._,designer:e??r?.designer??_.designer,render:{..._.render,...r?.render,...t}},i=x.registerElementPlugin(a);return w=i,i}function st(e){return j(e)}function ot(e){return j(void 0,{executorBundle:e})}function lt(){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=ne;exports.FALLBACK_SAMPLE_CATEGORIES=re;exports.FUNNEL_PADDING_DEFAULTS=ae;exports.LABEL_POSITIONS=We;exports.LABEL_PRESETS=$e;exports.RADAR_RADIUS_DEFAULT=ie;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=st;exports.registerChartExecutorBundle=ot;exports.registerChartPlugin=j;exports.renderChartElement=U;exports.renderChartToSvg=de;exports.resolveChartPanelFields=Ae;exports.syncSeriesCount=we;exports.uninstallChartPlugin=lt;exports.updateChartLabel=Ze;exports.writeFunnelPadding=Me;exports.writeRadarRadius=ze;