@worm-print-platform/echarts 1.6.4 → 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/README.md +4 -0
- package/dist/bind.d.ts +1 -1
- package/dist/browser/executor.iife.d.ts +1 -1
- package/dist/browser-bundle.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/defaults.d.ts +1 -1
- package/dist/echarts.d.ts +1 -1
- package/dist/echarts.js +20 -20
- package/dist/executor.iife.global.d.ts +1 -1
- package/dist/executor.iife.global.js +2 -2
- package/dist/i18n/en-US.json +2 -0
- package/dist/i18n/th-TH.json +2 -0
- package/dist/i18n/zh-CN.json +2 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/kinds.d.ts +1 -1
- package/dist/kit.cjs +2 -2
- package/dist/kit.d.ts +1 -1
- package/dist/kit.js +2 -2
- package/dist/label.d.ts +1 -1
- package/dist/marketplace.d.ts +1 -1
- package/dist/marketplace.js +88 -152
- package/dist/node.cjs +3 -3
- package/dist/node.d.ts +1 -1
- package/dist/node.js +3 -3
- package/dist/normalize.d.ts +1 -1
- package/dist/option-utils.d.ts +1 -1
- package/dist/plugin-Bt-Rxy-v.cjs +6 -0
- package/dist/{plugin-fBzOuicw.js → plugin-onif6lqS.js} +3 -3
- package/dist/plugin.d.ts +1 -1
- package/dist/renderer.d.ts +1 -1
- package/dist/test-setup.d.ts +1 -1
- package/dist/type-augmentation.d.ts +1 -1
- package/dist/ui.cjs +88 -152
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +88 -152
- package/dist/units.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +6 -6
- package/dist/plugin-DcaxhWUL.cjs +0 -6
package/dist/marketplace.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/echarts v1.6.
|
|
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: "
|
|
459
|
-
chartValueFields: [
|
|
458
|
+
chartCategoryField: "",
|
|
459
|
+
chartValueFields: [],
|
|
460
460
|
chartSeriesField: "",
|
|
461
461
|
...partial
|
|
462
462
|
};
|
|
@@ -1188,6 +1188,8 @@ var zh_CN_default = {
|
|
|
1188
1188
|
"echarts.panel.labelLine.length2": "\u7B2C\u4E8C\u6BB5\u957F\u5EA6",
|
|
1189
1189
|
"echarts.panel.labelLine.smooth": "\u5E73\u6ED1\u5F15\u5BFC\u7EBF",
|
|
1190
1190
|
"echarts.panel.dataSourceTitle": "\u6570\u636E\u6E90",
|
|
1191
|
+
"echarts.panel.selectField": "\u9009\u62E9\u5B57\u6BB5",
|
|
1192
|
+
"echarts.panel.autoSource": "\u81EA\u52A8",
|
|
1191
1193
|
"echarts.panel.categoryField": "\u7C7B\u76EE\u5B57\u6BB5",
|
|
1192
1194
|
"echarts.panel.removeField": "\u5220\u9664\u8BE5\u5B57\u6BB5",
|
|
1193
1195
|
"echarts.panel.addField": "+ \u6DFB\u52A0\u5B57\u6BB5",
|
|
@@ -1343,6 +1345,8 @@ var en_US_default = {
|
|
|
1343
1345
|
"echarts.panel.labelLine.length2": "Second segment length",
|
|
1344
1346
|
"echarts.panel.labelLine.smooth": "Smooth label line",
|
|
1345
1347
|
"echarts.panel.dataSourceTitle": "Data source",
|
|
1348
|
+
"echarts.panel.selectField": "Select field",
|
|
1349
|
+
"echarts.panel.autoSource": "Auto",
|
|
1346
1350
|
"echarts.panel.categoryField": "Category field",
|
|
1347
1351
|
"echarts.panel.removeField": "Remove this field",
|
|
1348
1352
|
"echarts.panel.addField": "+ Add field",
|
|
@@ -1498,6 +1502,8 @@ var th_TH_default = {
|
|
|
1498
1502
|
"echarts.panel.labelLine.length2": "\u0E04\u0E27\u0E32\u0E21\u0E22\u0E32\u0E27\u0E17\u0E48\u0E2D\u0E19\u0E17\u0E35\u0E48\u0E2A\u0E2D\u0E07",
|
|
1499
1503
|
"echarts.panel.labelLine.smooth": "\u0E40\u0E2A\u0E49\u0E19\u0E1B\u0E49\u0E32\u0E22\u0E42\u0E04\u0E49\u0E07",
|
|
1500
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",
|
|
1501
1507
|
"echarts.panel.categoryField": "\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E2B\u0E21\u0E27\u0E14\u0E2B\u0E21\u0E39\u0E48",
|
|
1502
1508
|
"echarts.panel.removeField": "\u0E25\u0E1A\u0E1F\u0E34\u0E25\u0E14\u0E4C\u0E19\u0E35\u0E49",
|
|
1503
1509
|
"echarts.panel.addField": "+ \u0E40\u0E1E\u0E34\u0E48\u0E21\u0E1F\u0E34\u0E25\u0E14\u0E4C",
|
|
@@ -1606,18 +1612,9 @@ var CANVAS_STYLE = "width:100%;height:100%;min-width:0;min-height:0;pointer-even
|
|
|
1606
1612
|
var STYLES = [
|
|
1607
1613
|
".echarts-canvas-element{overflow:hidden}",
|
|
1608
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)}",
|
|
1609
1616
|
".echarts-field-row>.pd-input{flex:1;min-width:0}",
|
|
1610
1617
|
".echarts-field-row>.pd-button{flex:none}",
|
|
1611
|
-
".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}",
|
|
1612
|
-
".echarts-dropdown-trigger:hover{border-color:var(--pd-text-faint,#b4b9c4)}",
|
|
1613
|
-
'.echarts-dropdown-trigger[aria-expanded="true"]{border-color:var(--pd-accent,#165dff);box-shadow:0 0 0 2px rgb(22 93 255 / 12%)}',
|
|
1614
|
-
".echarts-dropdown-value{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
|
|
1615
|
-
".echarts-dropdown-arrow{flex:none;color:var(--pd-text-muted,#909399);font-size:10px;transition:transform .14s}",
|
|
1616
|
-
'.echarts-dropdown-trigger[aria-expanded="true"] .echarts-dropdown-arrow{transform:rotate(180deg)}',
|
|
1617
|
-
".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}",
|
|
1618
|
-
".echarts-dropdown-option{padding:5px 8px;border-radius:4px;cursor:pointer;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}",
|
|
1619
|
-
".echarts-dropdown-option:hover{background:var(--pd-accent-soft,rgb(22 93 255 / 9%))}",
|
|
1620
|
-
".echarts-dropdown-option.is-active{background:var(--pd-accent-soft,rgb(22 93 255 / 9%));color:var(--pd-accent,#165dff)}",
|
|
1621
1618
|
".echarts-label-group{margin-top:8px;border-top:1px solid var(--pd-border,#e5e7eb);padding-top:8px}",
|
|
1622
1619
|
".echarts-label-group>summary{display:flex;align-items:center;cursor:pointer;list-style:none;font-size:12px;font-weight:600}",
|
|
1623
1620
|
".echarts-label-summary>.pd-field{flex:1;margin:0;font-weight:400}",
|
|
@@ -1698,22 +1695,6 @@ function valueFieldsLabel(def, limit) {
|
|
|
1698
1695
|
if (def?.seriesType === "radar") return t2("echarts.panel.field.dimension");
|
|
1699
1696
|
return limit === 1 ? t2("echarts.panel.field.value") : t2("echarts.panel.field.valueMulti");
|
|
1700
1697
|
}
|
|
1701
|
-
function dataSourceCandidates(data, fields) {
|
|
1702
|
-
const first = data?.[0];
|
|
1703
|
-
const keys = first ? Object.keys(first).filter((key) => Array.isArray(first[key])) : [];
|
|
1704
|
-
for (const field2 of fields ?? []) {
|
|
1705
|
-
if (field2.fieldType === "list" && field2.fieldKey && !keys.includes(field2.fieldKey)) keys.push(field2.fieldKey);
|
|
1706
|
-
}
|
|
1707
|
-
return keys;
|
|
1708
|
-
}
|
|
1709
|
-
function dataRowFields(data, dataSource) {
|
|
1710
|
-
const first = data?.[0];
|
|
1711
|
-
if (!first) return [];
|
|
1712
|
-
const key = dataSource ? Array.isArray(first[dataSource]) ? dataSource : "" : Object.keys(first).find((k) => Array.isArray(first[k]));
|
|
1713
|
-
if (!key) return [];
|
|
1714
|
-
const rows = first[key];
|
|
1715
|
-
return rows.length > 0 && typeof rows[0] === "object" && rows[0] !== null ? Object.keys(rows[0]) : [];
|
|
1716
|
-
}
|
|
1717
1698
|
function fieldLabelMap(fields) {
|
|
1718
1699
|
const map = /* @__PURE__ */ new Map();
|
|
1719
1700
|
for (const field2 of fields ?? []) {
|
|
@@ -1721,17 +1702,41 @@ function fieldLabelMap(fields) {
|
|
|
1721
1702
|
}
|
|
1722
1703
|
return map;
|
|
1723
1704
|
}
|
|
1724
|
-
function optionLabel(value, labels
|
|
1725
|
-
if (!value) return
|
|
1705
|
+
function optionLabel(value, labels) {
|
|
1706
|
+
if (!value) return t2("echarts.panel.default");
|
|
1726
1707
|
const name = labels.get(value);
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
const
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
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;
|
|
1735
1740
|
}
|
|
1736
1741
|
function seriesList(option) {
|
|
1737
1742
|
return Array.isArray(option.series) ? option.series : [];
|
|
@@ -1811,84 +1816,6 @@ function selectInput(options, value, onCommit) {
|
|
|
1811
1816
|
select.addEventListener("change", () => onCommit(select.value));
|
|
1812
1817
|
return select;
|
|
1813
1818
|
}
|
|
1814
|
-
var activeDropdown = null;
|
|
1815
|
-
function composedPathOf(ev) {
|
|
1816
|
-
const composed = typeof ev.composedPath === "function" ? ev.composedPath() : [];
|
|
1817
|
-
return composed.length ? composed : [ev.target];
|
|
1818
|
-
}
|
|
1819
|
-
function dropdownSelect(options, value, onCommit) {
|
|
1820
|
-
const current = options.find((item) => item.value === value) ?? { value, label: value || t2("echarts.panel.optionDefault") };
|
|
1821
|
-
const trigger = el("button", "echarts-dropdown-trigger");
|
|
1822
|
-
trigger.type = "button";
|
|
1823
|
-
trigger.setAttribute("aria-haspopup", "listbox");
|
|
1824
|
-
trigger.setAttribute("aria-expanded", "false");
|
|
1825
|
-
const valueEl = el("span", "echarts-dropdown-value", current.label);
|
|
1826
|
-
const arrow = el("span", "echarts-dropdown-arrow", "\u25BE");
|
|
1827
|
-
trigger.appendChild(valueEl);
|
|
1828
|
-
trigger.appendChild(arrow);
|
|
1829
|
-
let panel = null;
|
|
1830
|
-
let off = [];
|
|
1831
|
-
const close = () => {
|
|
1832
|
-
off.forEach((fn) => fn());
|
|
1833
|
-
off = [];
|
|
1834
|
-
panel?.remove();
|
|
1835
|
-
panel = null;
|
|
1836
|
-
trigger.setAttribute("aria-expanded", "false");
|
|
1837
|
-
if (activeDropdown?.close === close) activeDropdown = null;
|
|
1838
|
-
};
|
|
1839
|
-
const open = () => {
|
|
1840
|
-
activeDropdown?.close();
|
|
1841
|
-
const root = trigger.getRootNode();
|
|
1842
|
-
const mount = root instanceof ShadowRoot ? root : document.body;
|
|
1843
|
-
panel = el("div", "echarts-dropdown-panel");
|
|
1844
|
-
panel.setAttribute("role", "listbox");
|
|
1845
|
-
for (const item of options) {
|
|
1846
|
-
const optionEl = el("div", `echarts-dropdown-option${item.value === value ? " is-active" : ""}`, item.label);
|
|
1847
|
-
optionEl.setAttribute("role", "option");
|
|
1848
|
-
optionEl.setAttribute("aria-selected", item.value === value ? "true" : "false");
|
|
1849
|
-
optionEl.addEventListener("click", (ev) => {
|
|
1850
|
-
ev.stopPropagation();
|
|
1851
|
-
close();
|
|
1852
|
-
onCommit(item.value);
|
|
1853
|
-
});
|
|
1854
|
-
panel.appendChild(optionEl);
|
|
1855
|
-
}
|
|
1856
|
-
mount.appendChild(panel);
|
|
1857
|
-
const rect = trigger.getBoundingClientRect();
|
|
1858
|
-
panel.style.left = `${rect.left}px`;
|
|
1859
|
-
panel.style.top = `${rect.bottom + 4}px`;
|
|
1860
|
-
panel.style.minWidth = `${rect.width}px`;
|
|
1861
|
-
trigger.setAttribute("aria-expanded", "true");
|
|
1862
|
-
activeDropdown = { close };
|
|
1863
|
-
const onPointerDown = (ev) => {
|
|
1864
|
-
const path = composedPathOf(ev);
|
|
1865
|
-
if (path.includes(trigger) || path.includes(panel)) return;
|
|
1866
|
-
close();
|
|
1867
|
-
};
|
|
1868
|
-
const onKeydown = (ev) => {
|
|
1869
|
-
if (ev.key === "Escape") close();
|
|
1870
|
-
};
|
|
1871
|
-
const onScroll = () => close();
|
|
1872
|
-
document.addEventListener("pointerdown", onPointerDown, true);
|
|
1873
|
-
document.addEventListener("keydown", onKeydown);
|
|
1874
|
-
window.addEventListener("scroll", onScroll, true);
|
|
1875
|
-
window.addEventListener("resize", onScroll);
|
|
1876
|
-
root.addEventListener("scroll", onScroll, true);
|
|
1877
|
-
off.push(
|
|
1878
|
-
() => document.removeEventListener("pointerdown", onPointerDown, true),
|
|
1879
|
-
() => document.removeEventListener("keydown", onKeydown),
|
|
1880
|
-
() => window.removeEventListener("scroll", onScroll, true),
|
|
1881
|
-
() => window.removeEventListener("resize", onScroll),
|
|
1882
|
-
() => root.removeEventListener("scroll", onScroll, true)
|
|
1883
|
-
);
|
|
1884
|
-
};
|
|
1885
|
-
trigger.addEventListener("click", (ev) => {
|
|
1886
|
-
ev.stopPropagation();
|
|
1887
|
-
if (panel) close();
|
|
1888
|
-
else open();
|
|
1889
|
-
});
|
|
1890
|
-
return trigger;
|
|
1891
|
-
}
|
|
1892
1819
|
var overflowOptions = () => [
|
|
1893
1820
|
{ value: "", label: t2("echarts.panel.overflow.default") },
|
|
1894
1821
|
{ value: "none", label: t2("echarts.panel.overflow.none") },
|
|
@@ -2070,60 +1997,67 @@ function renderProperty(ctx) {
|
|
|
2070
1997
|
return withTranslator(ctx.t, () => renderPropertyInner(ctx));
|
|
2071
1998
|
}
|
|
2072
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");
|
|
2073
2001
|
const element = ctx.element;
|
|
2074
2002
|
const type = elementType(element);
|
|
2075
2003
|
const def = getChartKindDefinition(type);
|
|
2076
|
-
const
|
|
2077
|
-
const has = (key) =>
|
|
2004
|
+
const panelFields = resolveChartPanelFields(type);
|
|
2005
|
+
const has = (key) => panelFields.includes(key);
|
|
2078
2006
|
const options = element.options;
|
|
2079
2007
|
const widthMm = Number(options.width) || 0;
|
|
2080
2008
|
const heightMm = Number(options.height) || 0;
|
|
2081
2009
|
const limit = maxValueFields(def);
|
|
2082
2010
|
const palettes = getChartPalettes();
|
|
2083
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");
|
|
2084
2017
|
const root = el("div", "echarts-property");
|
|
2085
2018
|
const form = el("form", "pd-form");
|
|
2086
2019
|
form.addEventListener("submit", (event) => event.preventDefault());
|
|
2087
2020
|
root.appendChild(form);
|
|
2088
2021
|
if (has("dataSource")) {
|
|
2089
2022
|
const wrap = field(t2("echarts.panel.dataSourceTitle"));
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
)
|
|
2097
|
-
|
|
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
|
+
));
|
|
2098
2032
|
form.appendChild(wrap);
|
|
2099
2033
|
}
|
|
2100
2034
|
if (has("categoryField")) {
|
|
2101
2035
|
const wrap = field(t2("echarts.panel.categoryField"));
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
)
|
|
2109
|
-
);
|
|
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
|
+
));
|
|
2110
2044
|
form.appendChild(wrap);
|
|
2111
2045
|
}
|
|
2112
2046
|
if (has("valueFields")) {
|
|
2113
2047
|
const wrap = field(valueFieldsLabel(def, limit));
|
|
2114
2048
|
const fieldsNow = readValueFields(element);
|
|
2115
2049
|
fieldsNow.forEach((value, index) => {
|
|
2116
|
-
const row =
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
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
|
+
}
|
|
2127
2061
|
);
|
|
2128
2062
|
if (fieldsNow.length > 1) {
|
|
2129
2063
|
const remove = el("button", "pd-button small", "\u2212");
|
|
@@ -2144,12 +2078,14 @@ function renderPropertyInner(ctx) {
|
|
|
2144
2078
|
}
|
|
2145
2079
|
if (has("seriesField")) {
|
|
2146
2080
|
const wrap = field(t2("echarts.panel.seriesField"));
|
|
2147
|
-
wrap.appendChild(
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
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
|
+
));
|
|
2153
2089
|
form.appendChild(wrap);
|
|
2154
2090
|
}
|
|
2155
2091
|
if (has("bubble")) {
|
package/dist/node.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/echarts v1.6.
|
|
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: "
|
|
461
|
-
chartValueFields: [
|
|
460
|
+
chartCategoryField: "",
|
|
461
|
+
chartValueFields: [],
|
|
462
462
|
chartSeriesField: "",
|
|
463
463
|
...partial
|
|
464
464
|
};
|
package/dist/node.d.ts
CHANGED
package/dist/node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/echarts v1.6.
|
|
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: "
|
|
438
|
-
chartValueFields: [
|
|
437
|
+
chartCategoryField: "",
|
|
438
|
+
chartValueFields: [],
|
|
439
439
|
chartSeriesField: "",
|
|
440
440
|
...partial
|
|
441
441
|
};
|
package/dist/normalize.d.ts
CHANGED
package/dist/option-utils.d.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @worm-print-platform/echarts v1.6.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,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @worm-print-platform/echarts v1.6.
|
|
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
|
|
@@ -394,8 +394,8 @@ function Pe(e, t) {
|
|
|
394
394
|
title: a?.label ?? "图表",
|
|
395
395
|
chartOption: Ne(e),
|
|
396
396
|
chartDataSource: "",
|
|
397
|
-
chartCategoryField: "
|
|
398
|
-
chartValueFields: [
|
|
397
|
+
chartCategoryField: "",
|
|
398
|
+
chartValueFields: [],
|
|
399
399
|
chartSeriesField: "",
|
|
400
400
|
...t
|
|
401
401
|
};
|
package/dist/plugin.d.ts
CHANGED
package/dist/renderer.d.ts
CHANGED
package/dist/test-setup.d.ts
CHANGED