@worm-print-platform/echarts 1.6.2 → 1.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.2
2
+ * @worm-print-platform/echarts v1.6.4
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * @worm-print-platform/echarts v1.6.4
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:"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),n=[...oe()],i=[...De],o=Array.isArray(r.series)?r.series:[],l=c=>{for(const u of o)Array.isArray(u.data)&&u.data.includes("$data")&&(u.data=c(u))},s=()=>{for(const c of["xAxis","yAxis"]){const u=Array.isArray(r[c])?r[c]:r[c]?[r[c]]:[];for(const f of u)f&&Array.isArray(f.data)&&f.data.includes("$data")&&(f.data=[...n])}};switch(a?.seriesType){case"pie":l(()=>n.map((c,u)=>({name:c,value:i[u]??10})));break;case"funnel":l(()=>n.map((c,u)=>({name:c,value:i[u]??10})));break;case"scatter":l(()=>i.map(c=>[c,c+6]));break;case"radar":r.radar={...r.radar??{},indicator:n.map(c=>({name:c,max:30}))},l(()=>[{name:"示例",value:i}]);break;case"gauge":l(()=>[{value:i[0]??40,name:"数量"}]);break;default:l(()=>[...i]),s();break}return r}function ke(e,t){const r=Array.isArray(e?.color)?(e?.color).map(String):[];return t.find(n=>n.colors.every((i,o)=>i===r[o])&&r.length===n.colors.length)?.key??"default"}function q(e){return Array.isArray(e)?e[0]&&typeof e[0]=="object"?{...e[0]}:{}:e&&typeof e=="object"?{...e}:{}}function we(e,t,r){const a=T(e),n=Array.isArray(a.series)?a.series:[],i=b(r),o=n[0]??{type:i?.seriesType==="line"?"line":"bar",data:["$data"]};return a.series=Array.from({length:Math.max(t,1)},(l,s)=>({...o,...n[s]??{},data:["$data"]})),a}const H=e=>Math.round(e*10)/10;function W(e,t){return t>0?H(e/t*100):0}function D(e,t,r){if(typeof e=="string"&&e.trim().endsWith("%")){const a=Number.parseFloat(e);if(Number.isFinite(a))return H(a)}return typeof e=="number"&&Number.isFinite(e)?W(e,t):W(r,t)}function ce(e,t,r){return Math.min(r,Math.max(t,e))}function E(e){return`${ce(H(e),0,100)}%`}function Ie(e){const r=(Array.isArray(e.series)?e.series:[])[0];return r&&typeof r=="object"?r:{}}function He(e,t,r){const n=Ie(e&&typeof e=="object"?e:{}),i=C(t),o=C(r);return{top:D(n.top,o,O.top),right:D(n.right,i,O.right),bottom:D(n.bottom,o,O.bottom),left:D(n.left,i,O.left)}}function Me(e,t){const r=T(e),a=Array.isArray(r.series)?r.series:[];a.length===0&&a.push({type:"funnel",data:["$data"]});const n=a[0];return n.top=E(t.top),n.right=E(t.right),n.bottom=E(t.bottom),n.left=E(t.left),r.series=a,r}function je(e,t,r){const n=q((e&&typeof e=="object"?e:{}).radar).radius,i=Array.isArray(n)?n[n.length-1]:n,o=C(t),l=C(r),s=Math.min(o,l)/2;if(typeof i=="string"&&i.trim().endsWith("%")){const c=Number.parseFloat(i);if(Number.isFinite(c))return H(c)}return typeof i=="number"&&Number.isFinite(i)?W(i,s):ie}function ze(e,t){const r=T(e);return r.radar={...q(r.radar),radius:E(ce(t,20,100))},r}const $e=[{key:"value",label:"数值",labelKey:"echarts.label.formatter.value",formatter:"{c}"},{key:"name-value",label:"名称: 数值",labelKey:"echarts.label.formatter.nameValue",formatter:"{b}: {c}"},{key:"name",label:"名称",labelKey:"echarts.label.formatter.name",formatter:"{b}"},{key:"percent",label:"百分比",labelKey:"echarts.label.formatter.percent",formatter:"{d}%"}],We={bar:[{value:"top",label:"顶部",labelKey:"echarts.label.position.bar.top"},{value:"inside",label:"内部",labelKey:"echarts.label.position.bar.inside"},{value:"insideTop",label:"内部顶端",labelKey:"echarts.label.position.bar.insideTop"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.bar.bottom"},{value:"insideBottom",label:"内部底端",labelKey:"echarts.label.position.bar.insideBottom"},{value:"right",label:"右侧",labelKey:"echarts.label.position.bar.right"},{value:"left",label:"左侧",labelKey:"echarts.label.position.bar.left"},{value:"middle",label:"居中",labelKey:"echarts.label.position.bar.middle"}],line:[{value:"top",label:"顶部",labelKey:"echarts.label.position.line.top"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.line.bottom"},{value:"inside",label:"内部",labelKey:"echarts.label.position.line.inside"},{value:"left",label:"左侧",labelKey:"echarts.label.position.line.left"},{value:"right",label:"右侧",labelKey:"echarts.label.position.line.right"}],pie:[{value:"outside",label:"外侧",labelKey:"echarts.label.position.pie.outside"},{value:"inside",label:"内部",labelKey:"echarts.label.position.pie.inside"},{value:"center",label:"中心",labelKey:"echarts.label.position.pie.center"}],scatter:[{value:"top",label:"顶部",labelKey:"echarts.label.position.scatter.top"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.scatter.bottom"},{value:"left",label:"左侧",labelKey:"echarts.label.position.scatter.left"},{value:"right",label:"右侧",labelKey:"echarts.label.position.scatter.right"},{value:"inside",label:"内部",labelKey:"echarts.label.position.scatter.inside"}],radar:[{value:"top",label:"顶部",labelKey:"echarts.label.position.radar.top"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.radar.bottom"},{value:"left",label:"左侧",labelKey:"echarts.label.position.radar.left"},{value:"right",label:"右侧",labelKey:"echarts.label.position.radar.right"},{value:"inside",label:"内部",labelKey:"echarts.label.position.radar.inside"}],funnel:[{value:"outer",label:"外侧",labelKey:"echarts.label.position.funnel.outer"},{value:"inner",label:"内部",labelKey:"echarts.label.position.funnel.inner"},{value:"left",label:"左侧",labelKey:"echarts.label.position.funnel.left"},{value:"right",label:"右侧",labelKey:"echarts.label.position.funnel.right"},{value:"top",label:"顶部",labelKey:"echarts.label.position.funnel.top"},{value:"bottom",label:"底部",labelKey:"echarts.label.position.funnel.bottom"}],gauge:[]},Ue={bar:!1,line:!1,pie:!0,scatter:!1,radar:!1,funnel:!0,gauge:!0},Be={bar:{position:"top",fontSize:12},line:{position:"top",fontSize:12},pie:{position:"outside",overflow:"none",fontSize:11},scatter:{position:"top",fontSize:11},radar:{position:"top",fontSize:10},funnel:{position:"outer",fontSize:11},gauge:{fontSize:14}},qe={barHChart:{position:"right",fontSize:12}},Ge={bar:["formatter","overflow","position","rotate","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding"],line:["formatter","overflow","position","rotate","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding"],pie:["formatter","overflow","position","distance","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding","labelLine.show","labelLine.length","labelLine.length2","labelLine.smooth"],scatter:["formatter","overflow","position","distance","rotate","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding"],radar:["formatter","fontSize","fontWeight","color"],funnel:["formatter","overflow","position","distance","fontSize","fontWeight","color","labelLine.show","labelLine.length","labelLine.smooth"],gauge:["formatter","fontSize","fontWeight","color","offset"]},Ve=["formatter","overflow","position","distance","rotate","offset","fontSize","fontWeight","color","backgroundColor","borderColor","borderWidth","borderRadius","padding"];function Xe(e){const t=e?.series;return Array.isArray(t)?t:[]}function k(e){return e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{}}function G(e){typeof e.offsetX!="number"&&typeof e.offsetY!="number"||(Array.isArray(e.offset)||(e.offset=[typeof e.offsetX=="number"?e.offsetX:0,typeof e.offsetY=="number"?e.offsetY:0]),delete e.offsetX,delete e.offsetY)}function M(e){return b(e)?.seriesType==="gauge"?"detail":"label"}function Ye(e){const t=b(e);return t?Ge[t.seriesType]:[]}function Je(e,t){const r=b(t),a=Xe(e),n=k(a[0]?.[M(t)]);G(n);const i={show:typeof n.show=="boolean"?n.show:r?Ue[r.seriesType]:!1,labelLine:k(a[0]?.labelLine)};for(const l of Ve){const s=n[l];l!=="offset"&&(typeof s=="string"||typeof s=="number")&&(i[l]=s)}const o=n.offset;return Array.isArray(o)&&typeof o[0]=="number"&&typeof o[1]=="number"&&(i.offset=[o[0],o[1]]),i}function Qe(e){const t=b(e);return t?{...Be[t.seriesType],...qe[e]}:{}}function ee(e){return e==null||e===""}function Ze(e,t,r){const a=T(e??{}),n=Array.isArray(a.series)?a.series:[];if(!b(t)||n.length===0)return a;const o=M(t),{enabled:l,labelLine:s,...c}=r;for(const u of n){if(!u||typeof u!="object")continue;const f=k(u[o]);G(f),l===!0?Object.assign(f,{...Qe(t),...f,show:!0}):l===!1&&(f.show=!1);for(const[d,y]of Object.entries(c))ee(y)?delete f[d]:f[d]=y;if(s){const d=k(u.labelLine);for(const[y,h]of Object.entries(s))ee(h)?delete d[y]:d[y]=h;u.labelLine=d}u[o]=f}return a}function et(e){return Array.isArray(e)?e.map(t=>({...t})):[]}function tt(e,t){const r={...e,type:t?"value":"category"};return t?delete r.data:Array.isArray(r.data)||(r.data=["$data"]),r}function rt(e,t){const r={...e,type:t?"category":"value"};return t&&!Array.isArray(r.data)&&(r.data=["$data"]),t||delete r.data,r}function N(e,t){return Array.isArray(e)?e.map(r=>t({...r})):t(e&&typeof e=="object"?{...e}:{})}function ue(e,t){const r=b(e);if(!r)return t;const a=structuredClone(t),n=et(a.series);if(n.length===0)return a;const i=M(e);for(const s of n){const c=s[i];if(c&&typeof c=="object"&&!Array.isArray(c)){const u={...c};G(u),s[i]=u}}if(r.seriesType==="pie")return a.series=n.map(s=>({...s,type:"pie",...e==="doughnutChart"?{radius:s.radius??["40%","70%"]}:{}})),delete a.xAxis,delete a.yAxis,a;if(r.seriesType==="scatter")return a.series=n.map(s=>({...s,type:"scatter"})),a.xAxis=N(a.xAxis,s=>({...s,type:"value",data:void 0})),a.yAxis=N(a.yAxis,s=>({...s,type:"value",data:void 0})),a;if(r.seriesType==="radar")return a.series=n.map(s=>({...s,type:"radar"})),a;if(r.seriesType==="funnel")return a.series=n.map(s=>({...s,type:"funnel",sort:"descending"})),a;if(r.seriesType==="gauge")return a.series=n.map(s=>({...s,type:"gauge"})),a;const o=r.orientation==="horizontal",l=r.seriesType==="line"?"line":"bar";return a.xAxis=N(a.xAxis,s=>tt(s,o)),a.yAxis=N(a.yAxis,s=>rt(s,o)),a.series=n.map(s=>{const c={...s,type:l};return e==="areaChart"?c.areaStyle=s.areaStyle??{}:delete c.areaStyle,c}),a}function fe(e,t,r){const a=/<svg\b[^>]*>/i.exec(e);if(!a)return e;const n=a[0],i=n.slice(4,-1),l=(/\sstyle\s*=\s*"([^"]*)"/i.exec(i)?.[1]??"").split(";").map(f=>f.trim()).filter(f=>f&&!/^(width|height|display)\s*:/i.test(f)).join(";"),s=i.replace(/\s(width|height|style|viewBox)\s*=\s*"[^"]*"/gi,"").trimEnd(),c=["display:block","width:100%","height:100%",l].filter(Boolean).join(";"),u=`<svg${s} width="100%" height="100%" viewBox="0 0 ${t} ${r}" style="${c}">`;return e.slice(0,a.index)+u+e.slice(a.index+n.length)}function de(e){Re();const t=ue(e.type,e.option);if(!t||typeof t!="object"||Array.isArray(t))throw new Error("图表 option 非法:需要对象");const r=C(e.widthMm),a=C(e.heightMm),n=B.init(null,null,{renderer:"svg",ssr:!0,width:r,height:a});try{const i=t.textStyle&&typeof t.textStyle=="object"&&!Array.isArray(t.textStyle)?t.textStyle:void 0,o={...e.fontFamily?{fontFamily:e.fontFamily}:{},...i??{}};return n.setOption({animation:!1,...t,...Object.keys(o).length>0?{textStyle:o}:{}}),fe(n.renderToSVGString(),r,a)}finally{n.dispose()}}function at(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function U(e){const t=e._chartOption??e.chartOption,r=`<span>${at(String(e.title??"图表"))}</span>`;if(!t||typeof t!="object"||Array.isArray(t))return r;try{return de({key:String(e.key??""),type:String(e.type??""),option:t,widthMm:Number(e.widthMm??0),heightMm:Number(e.heightMm??0),fontFamily:typeof e.fontFamily=="string"?e.fontFamily:void 0})}catch{return r}}const nt="2";function ye(e=!1){return{chartOption:{kind:"object",get label(){return A.t("echarts.meta.chartOption")}},chartDataSource:{kind:"text",get label(){return A.t("echarts.meta.dataSource")}},chartCategoryField:{kind:"text",get label(){return A.t("echarts.meta.categoryField")}},chartValueFields:{kind:"object",get label(){return A.t("echarts.meta.valueFields")}},chartSeriesField:{kind:"text",get label(){return A.t("echarts.meta.seriesField")}},...e?{chartBubble:{kind:"bool",get label(){return A.t("echarts.meta.bubbleSize")}}}:{}}}const it=ye(),st=ye(!0),_=x.defineElementPlugin({id:L,version:nt,kinds:I.map(e=>({type:e.type,get label(){return A.t(e.labelKey)},icon:e.icon,fixedHeight:!0,requiredOptionKeys:e.requiredOptionKeys,get notes(){return A.t(e.notesKey)},optionMeta:e.type==="scatterChart"?st:it,defaultOptions:t=>le(e.type,t),binding:{bind:(t,r)=>te(e.type,t,r)}})),render:{html:U,createRenderer:()=>({render:U})}});let w;function j(e,t){const r=x.getElementPluginById(L);if(!e&&!t){const i=x.registerElementPlugin(_);return w=i,i}const a={..._,designer:e??r?.designer??_.designer,render:{..._.render,...r?.render,...t}},n=x.registerElementPlugin(a);return w=n,n}function ot(e){return j(e)}function lt(e){return j(void 0,{executorBundle:e})}function ct(){w?.(),w=void 0}j();exports.CHART_KINDS=me;exports.CHART_KIND_DEFINITIONS=I;exports.CHART_PALETTES=$;exports.CHART_PLUGIN=_;exports.CHART_PLUGIN_ID=L;exports.ECHARTS_FUNNEL_PADDING_PX=O;exports.ECHARTS_RADAR_RADIUS_DEFAULT=ie;exports.FALLBACK_SAMPLE_CATEGORIES=re;exports.FUNNEL_PADDING_DEFAULTS=ae;exports.LABEL_POSITIONS=We;exports.LABEL_PRESETS=$e;exports.RADAR_RADIUS_DEFAULT=ne;exports.asObject=q;exports.bindChartData=te;exports.chartFactoryDefaults=le;exports.cloneChartOption=T;exports.configureChartPlugin=Fe;exports.createDefaultChartOption=se;exports.fitSvgRoot=fe;exports.getChartKindDefinition=b;exports.getChartPalettes=Le;exports.getChartPluginConfig=R;exports.getSampleCategories=oe;exports.labelFieldsOf=Ye;exports.labelTargetOf=M;exports.mmToChartPx=C;exports.normalizeChartOption=ue;exports.previewChartOption=Ne;exports.readChartLabel=Je;exports.readFunnelPadding=He;exports.readPaletteKey=ke;exports.readRadarRadius=je;exports.registerChartDesigner=ot;exports.registerChartExecutorBundle=lt;exports.registerChartPlugin=j;exports.renderChartElement=U;exports.renderChartToSvg=de;exports.resolveChartPanelFields=Ae;exports.syncSeriesCount=we;exports.uninstallChartPlugin=ct;exports.updateChartLabel=Ze;exports.writeFunnelPadding=Me;exports.writeRadarRadius=ze;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.2
2
+ * @worm-print-platform/echarts v1.6.4
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
@@ -143,11 +143,11 @@ const p = ["left", "top", "width", "height", "chartOption"], T = ["dataSource",
143
143
  notes: "仪表盘:取首行数据的首个数值字段作指针值;min/max 由面板写入 series[0].min/max",
144
144
  notesKey: "echarts.notes.gauge"
145
145
  }
146
- ], lt = H.map((e) => e.type);
146
+ ], ct = H.map((e) => e.type);
147
147
  function b(e) {
148
148
  return H.find((t) => t.type === e);
149
149
  }
150
- function ct(e) {
150
+ function ut(e) {
151
151
  return b(e)?.fields ?? [];
152
152
  }
153
153
  function Ae(e) {
@@ -172,16 +172,16 @@ function S(e) {
172
172
  return Array.isArray(e.data) && e.data.includes("$data");
173
173
  }
174
174
  function Se(e, t) {
175
- const r = e.dataSource;
176
- if (typeof r == "string" && Array.isArray(t[r])) return t[r];
177
- for (const a of Object.values(t))
178
- if (Array.isArray(a)) return a;
175
+ const r = typeof e.chartDataSource == "string" ? e.chartDataSource : "", a = typeof e.dataSource == "string" ? e.dataSource : "", s = r || a;
176
+ if (s) return Array.isArray(t[s]) ? t[s] : [];
177
+ for (const i of Object.values(t))
178
+ if (Array.isArray(i)) return i;
179
179
  return [];
180
180
  }
181
181
  function B(e) {
182
182
  return typeof e == "string" && e.length > 0 ? e : void 0;
183
183
  }
184
- function xe(e) {
184
+ function Ce(e) {
185
185
  return Array.isArray(e) ? e.filter((t) => typeof t == "string" && t.length > 0) : [];
186
186
  }
187
187
  function K(e) {
@@ -197,7 +197,7 @@ function U(e, t) {
197
197
  i && typeof i == "object" && Array.isArray(i.data) && i.data.includes("$data") && (i.data = [...t]);
198
198
  }
199
199
  }
200
- function Ce(e, t, r, a, s) {
200
+ function xe(e, t, r, a, s) {
201
201
  const i = K(e);
202
202
  if (!i.some(S)) return;
203
203
  const o = t.map((c, u) => r ? c[r] : u + 1), l = (c) => a[Math.min(c, a.length - 1)];
@@ -270,9 +270,9 @@ function Oe(e, t, r) {
270
270
  function ke(e, t, r) {
271
271
  const a = t.chartOption;
272
272
  if (!a || typeof a != "object" || Array.isArray(a)) return {};
273
- const s = P(a, r), i = xe(t.chartValueFields);
273
+ const s = P(a, r), i = Ce(t.chartValueFields);
274
274
  if (i.length === 0) return { _chartOption: s };
275
- const o = Se({ ...t, dataSource: t.chartDataSource ?? t.dataSource }, r);
275
+ const o = Se(t, r);
276
276
  if (o.length === 0) return { _chartOption: s };
277
277
  const l = B(t.chartCategoryField);
278
278
  switch (b(e)?.seriesType) {
@@ -292,7 +292,7 @@ function ke(e, t, r) {
292
292
  Ke(s, o, l, i, t.chartBubble === !0);
293
293
  break;
294
294
  default:
295
- Ce(s, o, l, i, B(t.chartSeriesField));
295
+ xe(s, o, l, i, B(t.chartSeriesField));
296
296
  break;
297
297
  }
298
298
  return { _chartOption: s };
@@ -369,13 +369,13 @@ function Ne(e) {
369
369
  }
370
370
  }
371
371
  }
372
- function ut(e) {
372
+ function ft(e) {
373
373
  re(_, e);
374
374
  }
375
375
  function N() {
376
376
  return te(_);
377
377
  }
378
- function ft() {
378
+ function dt() {
379
379
  const e = N().palettes ?? {}, t = G.map((a) => {
380
380
  const s = e[a.key];
381
381
  return s ? { key: a.key, label: s.label ?? a.label, labelKey: s.label ? void 0 : a.labelKey, colors: s.colors } : { key: a.key, label: a.label, labelKey: a.labelKey, colors: a.colors };
@@ -424,7 +424,7 @@ function De() {
424
424
  }
425
425
  }
426
426
  const Me = 96 / 25.4;
427
- function x(e) {
427
+ function C(e) {
428
428
  const t = Number.isFinite(e) ? e : 0;
429
429
  return Math.max(1, Math.round(t * Me));
430
430
  }
@@ -436,7 +436,7 @@ function v(e) {
436
436
  return e;
437
437
  }
438
438
  }
439
- function dt(e, t) {
439
+ function yt(e, t) {
440
440
  if (!t || typeof t != "object" || Array.isArray(t)) return {};
441
441
  const r = v(t), a = b(e), s = [...Re()], i = [...He], o = Array.isArray(r.series) ? r.series : [], l = (c) => {
442
442
  for (const u of o)
@@ -473,14 +473,14 @@ function dt(e, t) {
473
473
  }
474
474
  return r;
475
475
  }
476
- function yt(e, t) {
476
+ function bt(e, t) {
477
477
  const r = Array.isArray(e?.color) ? (e?.color).map(String) : [];
478
478
  return t.find((s) => s.colors.every((i, o) => i === r[o]) && r.length === s.colors.length)?.key ?? "default";
479
479
  }
480
480
  function Q(e) {
481
481
  return Array.isArray(e) ? e[0] && typeof e[0] == "object" ? { ...e[0] } : {} : e && typeof e == "object" ? { ...e } : {};
482
482
  }
483
- function bt(e, t, r) {
483
+ function ht(e, t, r) {
484
484
  const a = v(e), s = Array.isArray(a.series) ? a.series : [], i = b(r), o = s[0] ?? { type: i?.seriesType === "line" ? "line" : "bar", data: ["$data"] };
485
485
  return a.series = Array.from({ length: Math.max(t, 1) }, (l, n) => ({
486
486
  ...o,
@@ -502,15 +502,15 @@ function k(e, t, r) {
502
502
  function Z(e, t, r) {
503
503
  return Math.min(r, Math.max(t, e));
504
504
  }
505
- function C(e) {
505
+ function x(e) {
506
506
  return `${Z(R(e), 0, 100)}%`;
507
507
  }
508
508
  function $e(e) {
509
509
  const r = (Array.isArray(e.series) ? e.series : [])[0];
510
510
  return r && typeof r == "object" ? r : {};
511
511
  }
512
- function ht(e, t, r) {
513
- const s = $e(e && typeof e == "object" ? e : {}), i = x(t), o = x(r);
512
+ function pt(e, t, r) {
513
+ const s = $e(e && typeof e == "object" ? e : {}), i = C(t), o = C(r);
514
514
  return {
515
515
  top: k(s.top, o, O.top),
516
516
  right: k(s.right, i, O.right),
@@ -518,30 +518,30 @@ function ht(e, t, r) {
518
518
  left: k(s.left, i, O.left)
519
519
  };
520
520
  }
521
- function pt(e, t) {
521
+ function mt(e, t) {
522
522
  const r = v(e), a = Array.isArray(r.series) ? r.series : [];
523
523
  a.length === 0 && a.push({ type: "funnel", data: ["$data"] });
524
524
  const s = a[0];
525
- return s.top = C(t.top), s.right = C(t.right), s.bottom = C(t.bottom), s.left = C(t.left), r.series = a, r;
525
+ return s.top = x(t.top), s.right = x(t.right), s.bottom = x(t.bottom), s.left = x(t.left), r.series = a, r;
526
526
  }
527
- function mt(e, t, r) {
528
- const s = Q((e && typeof e == "object" ? e : {}).radar).radius, i = Array.isArray(s) ? s[s.length - 1] : s, o = x(t), l = x(r), n = Math.min(o, l) / 2;
527
+ function gt(e, t, r) {
528
+ const s = Q((e && typeof e == "object" ? e : {}).radar).radius, i = Array.isArray(s) ? s[s.length - 1] : s, o = C(t), l = C(r), n = Math.min(o, l) / 2;
529
529
  if (typeof i == "string" && i.trim().endsWith("%")) {
530
530
  const c = Number.parseFloat(i);
531
531
  if (Number.isFinite(c)) return R(c);
532
532
  }
533
533
  return typeof i == "number" && Number.isFinite(i) ? D(i, n) : we;
534
534
  }
535
- function gt(e, t) {
535
+ function At(e, t) {
536
536
  const r = v(e);
537
- return r.radar = { ...Q(r.radar), radius: C(Z(t, 20, 100)) }, r;
537
+ return r.radar = { ...Q(r.radar), radius: x(Z(t, 20, 100)) }, r;
538
538
  }
539
- const At = [
539
+ const St = [
540
540
  { key: "value", label: "数值", labelKey: "echarts.label.formatter.value", formatter: "{c}" },
541
541
  { key: "name-value", label: "名称: 数值", labelKey: "echarts.label.formatter.nameValue", formatter: "{b}: {c}" },
542
542
  { key: "name", label: "名称", labelKey: "echarts.label.formatter.name", formatter: "{b}" },
543
543
  { key: "percent", label: "百分比", labelKey: "echarts.label.formatter.percent", formatter: "{d}%" }
544
- ], St = {
544
+ ], Ct = {
545
545
  bar: [
546
546
  { value: "top", label: "顶部", labelKey: "echarts.label.position.bar.top" },
547
547
  { value: "inside", label: "内部", labelKey: "echarts.label.position.bar.inside" },
@@ -721,7 +721,7 @@ function xt(e) {
721
721
  const t = b(e);
722
722
  return t ? je[t.seriesType] : [];
723
723
  }
724
- function Ct(e, t) {
724
+ function Kt(e, t) {
725
725
  const r = b(t), a = Ue(e), s = L(a[0]?.[z(t)]);
726
726
  $(s);
727
727
  const i = {
@@ -743,7 +743,7 @@ function qe(e) {
743
743
  function X(e) {
744
744
  return e == null || e === "";
745
745
  }
746
- function Kt(e, t, r) {
746
+ function vt(e, t, r) {
747
747
  const a = v(e ?? {}), s = Array.isArray(a.series) ? a.series : [];
748
748
  if (!b(t) || s.length === 0) return a;
749
749
  const o = z(t), { enabled: l, labelLine: n, ...c } = r;
@@ -821,7 +821,7 @@ function Qe(e) {
821
821
  const t = Xe(e.type, e.option);
822
822
  if (!t || typeof t != "object" || Array.isArray(t))
823
823
  throw new Error("图表 option 非法:需要对象");
824
- const r = x(e.widthMm), a = x(e.heightMm), s = M.init(null, null, { renderer: "svg", ssr: !0, width: r, height: a });
824
+ const r = C(e.widthMm), a = C(e.heightMm), s = M.init(null, null, { renderer: "svg", ssr: !0, width: r, height: a });
825
825
  try {
826
826
  const i = t.textStyle && typeof t.textStyle == "object" && !Array.isArray(t.textStyle) ? t.textStyle : void 0, o = {
827
827
  ...e.fontFamily ? { fontFamily: e.fontFamily } : {},
@@ -855,16 +855,30 @@ function J(e) {
855
855
  return r;
856
856
  }
857
857
  }
858
- const et = "2", ee = {
859
- chartOption: { kind: "object", label: A("echarts.meta.chartOption") },
860
- chartDataSource: { kind: "text", label: A("echarts.meta.dataSource") },
861
- chartCategoryField: { kind: "text", label: A("echarts.meta.categoryField") },
862
- chartValueFields: { kind: "object", label: A("echarts.meta.valueFields") },
863
- chartSeriesField: { kind: "text", label: A("echarts.meta.seriesField") }
864
- }, tt = {
865
- ...ee,
866
- chartBubble: { kind: "bool", label: A("echarts.meta.bubbleSize") }
867
- }, E = ae({
858
+ const et = "2";
859
+ function ee(e = !1) {
860
+ return {
861
+ chartOption: { kind: "object", get label() {
862
+ return A("echarts.meta.chartOption");
863
+ } },
864
+ chartDataSource: { kind: "text", get label() {
865
+ return A("echarts.meta.dataSource");
866
+ } },
867
+ chartCategoryField: { kind: "text", get label() {
868
+ return A("echarts.meta.categoryField");
869
+ } },
870
+ chartValueFields: { kind: "object", get label() {
871
+ return A("echarts.meta.valueFields");
872
+ } },
873
+ chartSeriesField: { kind: "text", get label() {
874
+ return A("echarts.meta.seriesField");
875
+ } },
876
+ ...e ? { chartBubble: { kind: "bool", get label() {
877
+ return A("echarts.meta.bubbleSize");
878
+ } } } : {}
879
+ };
880
+ }
881
+ const tt = ee(), rt = ee(!0), E = ae({
868
882
  id: _,
869
883
  version: et,
870
884
  kinds: H.map((e) => ({
@@ -880,7 +894,7 @@ const et = "2", ee = {
880
894
  get notes() {
881
895
  return A(e.notesKey);
882
896
  },
883
- optionMeta: e.type === "scatterChart" ? tt : ee,
897
+ optionMeta: e.type === "scatterChart" ? rt : tt,
884
898
  defaultOptions: (t) => Pe(e.type, t),
885
899
  binding: { bind: (t, r) => ke(e.type, t, r) }
886
900
  })),
@@ -903,33 +917,33 @@ function I(e, t) {
903
917
  }, s = j(a);
904
918
  return w = s, s;
905
919
  }
906
- function vt(e) {
920
+ function Tt(e) {
907
921
  return I(e);
908
922
  }
909
- function Tt(e) {
923
+ function Ot(e) {
910
924
  return I(void 0, { executorBundle: e });
911
925
  }
912
- function Ot() {
926
+ function kt() {
913
927
  w?.(), w = void 0;
914
928
  }
915
929
  I();
916
930
  export {
917
- mt as A,
918
- vt as B,
919
- lt as C,
920
- Tt as D,
931
+ gt as A,
932
+ Tt as B,
933
+ ct as C,
934
+ Ot as D,
921
935
  O as E,
922
936
  Fe as F,
923
937
  I as G,
924
938
  J as H,
925
939
  Qe as I,
926
- ct as J,
927
- bt as K,
928
- St as L,
929
- Ot as M,
930
- Kt as N,
931
- pt as O,
932
- gt as P,
940
+ ut as J,
941
+ ht as K,
942
+ Ct as L,
943
+ kt as M,
944
+ vt as N,
945
+ mt as O,
946
+ At as P,
933
947
  Le as R,
934
948
  H as a,
935
949
  G as b,
@@ -937,24 +951,24 @@ export {
937
951
  _ as d,
938
952
  we as e,
939
953
  Ee as f,
940
- At as g,
954
+ St as g,
941
955
  Q as h,
942
956
  ke as i,
943
957
  Pe as j,
944
958
  v as k,
945
- ut as l,
959
+ ft as l,
946
960
  Ne as m,
947
961
  Je as n,
948
962
  b as o,
949
- ft as p,
963
+ dt as p,
950
964
  N as q,
951
965
  Re as r,
952
966
  xt as s,
953
967
  z as t,
954
- x as u,
968
+ C as u,
955
969
  Xe as v,
956
- dt as w,
957
- Ct as x,
958
- ht as y,
959
- yt as z
970
+ yt as w,
971
+ Kt as x,
972
+ pt as y,
973
+ bt as z
960
974
  };
package/dist/plugin.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.2
2
+ * @worm-print-platform/echarts v1.6.4
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.2
2
+ * @worm-print-platform/echarts v1.6.4
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.2
2
+ * @worm-print-platform/echarts v1.6.4
3
3
  * Copyright (c) 2026 worm <liu_long_qqcom@qq.com>
4
4
  * SPDX-FileCopyrightText: 2026 worm <liu_long_qqcom@qq.com>
5
5
  * SPDX-License-Identifier: MIT
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.2
2
+ * @worm-print-platform/echarts v1.6.4
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/ui.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.2
2
+ * @worm-print-platform/echarts v1.6.4
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
@@ -690,8 +690,10 @@ function hasDataPlaceholder(series) {
690
690
  return Array.isArray(series.data) && series.data.includes("$data");
691
691
  }
692
692
  function resolveListSource(options, data) {
693
- const explicit = options.dataSource;
694
- if (typeof explicit === "string" && Array.isArray(data[explicit])) return data[explicit];
693
+ const chartSource = typeof options.chartDataSource === "string" ? options.chartDataSource : "";
694
+ const legacySource = typeof options.dataSource === "string" ? options.dataSource : "";
695
+ const explicit = chartSource || legacySource;
696
+ if (explicit) return Array.isArray(data[explicit]) ? data[explicit] : [];
695
697
  for (const value of Object.values(data)) {
696
698
  if (Array.isArray(value)) return value;
697
699
  }
@@ -815,7 +817,7 @@ function bindChartData(type, options, data) {
815
817
  const option = evaluateChartOption(raw, data);
816
818
  const valueFields = asFieldList(options.chartValueFields);
817
819
  if (valueFields.length === 0) return { _chartOption: option };
818
- const list = resolveListSource({ ...options, dataSource: options.chartDataSource ?? options.dataSource }, data);
820
+ const list = resolveListSource(options, data);
819
821
  if (list.length === 0) return { _chartOption: option };
820
822
  const categoryField = asString(options.chartCategoryField);
821
823
  const def = getChartKindDefinition(type);
@@ -1544,17 +1546,30 @@ function renderChartElement(spec) {
1544
1546
  var CHART_EXECUTOR_VERSION = "2";
1545
1547
 
1546
1548
  // src/plugin.ts
1547
- var CHART_OPTION_META = {
1548
- chartOption: { kind: "object", label: (0, import_i18n.t)("echarts.meta.chartOption") },
1549
- chartDataSource: { kind: "text", label: (0, import_i18n.t)("echarts.meta.dataSource") },
1550
- chartCategoryField: { kind: "text", label: (0, import_i18n.t)("echarts.meta.categoryField") },
1551
- chartValueFields: { kind: "object", label: (0, import_i18n.t)("echarts.meta.valueFields") },
1552
- chartSeriesField: { kind: "text", label: (0, import_i18n.t)("echarts.meta.seriesField") }
1553
- };
1554
- var SCATTER_OPTION_META = {
1555
- ...CHART_OPTION_META,
1556
- chartBubble: { kind: "bool", label: (0, import_i18n.t)("echarts.meta.bubbleSize") }
1557
- };
1549
+ function createChartOptionMeta(includeBubble = false) {
1550
+ return {
1551
+ chartOption: { kind: "object", get label() {
1552
+ return (0, import_i18n.t)("echarts.meta.chartOption");
1553
+ } },
1554
+ chartDataSource: { kind: "text", get label() {
1555
+ return (0, import_i18n.t)("echarts.meta.dataSource");
1556
+ } },
1557
+ chartCategoryField: { kind: "text", get label() {
1558
+ return (0, import_i18n.t)("echarts.meta.categoryField");
1559
+ } },
1560
+ chartValueFields: { kind: "object", get label() {
1561
+ return (0, import_i18n.t)("echarts.meta.valueFields");
1562
+ } },
1563
+ chartSeriesField: { kind: "text", get label() {
1564
+ return (0, import_i18n.t)("echarts.meta.seriesField");
1565
+ } },
1566
+ ...includeBubble ? { chartBubble: { kind: "bool", get label() {
1567
+ return (0, import_i18n.t)("echarts.meta.bubbleSize");
1568
+ } } } : {}
1569
+ };
1570
+ }
1571
+ var CHART_OPTION_META = createChartOptionMeta();
1572
+ var SCATTER_OPTION_META = createChartOptionMeta(true);
1558
1573
  var CHART_PLUGIN = (0, import_designer2.defineElementPlugin)({
1559
1574
  id: CHART_PLUGIN_ID,
1560
1575
  version: CHART_EXECUTOR_VERSION,
@@ -1707,15 +1722,18 @@ function valueFieldsLabel(def, limit) {
1707
1722
  if (def?.seriesType === "radar") return t2("echarts.panel.field.dimension");
1708
1723
  return limit === 1 ? t2("echarts.panel.field.value") : t2("echarts.panel.field.valueMulti");
1709
1724
  }
1710
- function dataSourceCandidates(data) {
1725
+ function dataSourceCandidates(data, fields) {
1711
1726
  const first = data?.[0];
1712
- if (!first) return [];
1713
- return Object.keys(first).filter((key) => Array.isArray(first[key]));
1727
+ const keys = first ? Object.keys(first).filter((key) => Array.isArray(first[key])) : [];
1728
+ for (const field2 of fields ?? []) {
1729
+ if (field2.fieldType === "list" && field2.fieldKey && !keys.includes(field2.fieldKey)) keys.push(field2.fieldKey);
1730
+ }
1731
+ return keys;
1714
1732
  }
1715
1733
  function dataRowFields(data, dataSource) {
1716
1734
  const first = data?.[0];
1717
1735
  if (!first) return [];
1718
- const key = dataSource && Array.isArray(first[dataSource]) ? dataSource : Object.keys(first).find((k) => Array.isArray(first[k]));
1736
+ const key = dataSource ? Array.isArray(first[dataSource]) ? dataSource : "" : Object.keys(first).find((k) => Array.isArray(first[k]));
1719
1737
  if (!key) return [];
1720
1738
  const rows = first[key];
1721
1739
  return rows.length > 0 && typeof rows[0] === "object" && rows[0] !== null ? Object.keys(rows[0]) : [];
@@ -2096,7 +2114,7 @@ function renderPropertyInner(ctx) {
2096
2114
  const current = String(options.chartDataSource ?? "");
2097
2115
  wrap.appendChild(
2098
2116
  dropdownSelect(
2099
- dropdownOptions(dataSourceCandidates(ctx.data), current, fieldLabels),
2117
+ dropdownOptions(dataSourceCandidates(ctx.data, ctx.fields), current, fieldLabels),
2100
2118
  current,
2101
2119
  (value) => commitOption(ctx, type, panelOption(element), { chartDataSource: value })
2102
2120
  )
@@ -2308,7 +2326,9 @@ var CHART_ELEMENT_UI = (0, import_plugin_kit.defineElementUI)({
2308
2326
  renderCanvas,
2309
2327
  renderProperty,
2310
2328
  hasProperties: chartHasProperties,
2311
- group: t2("echarts.panel.group"),
2329
+ get group() {
2330
+ return t2("echarts.panel.group");
2331
+ },
2312
2332
  searchKeywords: SEARCH_KEYWORDS,
2313
2333
  styles: STYLES,
2314
2334
  i18nId: "echarts",
package/dist/ui.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @worm-print-platform/echarts v1.6.2
2
+ * @worm-print-platform/echarts v1.6.4
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