import{d as g}from"./debounce-Xd493GvO.js";import{a as A}from"./echarts_auto_tooltip-BNPm6hqZ.js";import{r as b}from"./request-CEvu378m.js";import{u as O}from"./useOnEvent-Cta5e-FG.js";import{ar as S}from"./echarts-DB130vfq.js";import{ax as _,s as C,r as m,l as R,c as y,w as h,j as I,n as w,X as j,S as N,B,z as E}from"./vue-BJk78QHK.js";import"./index-M_JNBppB.js";import"./element-3_pOinej.js";import"./utils-YI6ye1sf.js";import"./threejs-BafxXW5-.js";import"./vxe-Dx3zSILm.js";const G=Object.assign({name:"Chart"},{__name:"Chart",props:{propValue:{type:Object,default:()=>({})},element:{type:Object,default:()=>({})},linkage:{type:Object,default:()=>({})}},setup(k){const e=k,s=_(),o=C(null),V=m(null),x=R(e.propValue.data),q=R(e.propValue.style),i=m(null),f=y(()=>{const t=[];for(let c=0;c<x.editableTabs.length;c++){const n=x.editableTabs[c];t.push(n.name)}q.legend.data=t;const a=JSON.parse(JSON.stringify(q)),r=JSON.parse(JSON.stringify(x));return{tooltip:a.tooltip,title:a.title,grid:a.grid,legend:a.legend,backgroundColor:a.backgroundColor,toolbox:a.toolbox,calculable:!0,xAxis:r.direction?[{type:"category",data:r.x,axisTick:a.xAxis[0].axisTick,axisLine:a.xAxis[0].axisLine,axisLabel:a.xAxis[0].axisLabel}]:a.yAxis,yAxis:r.direction?a.yAxis:[{type:"category",data:r.x,axisTick:a.xAxis[0].axisTick,axisLine:a.xAxis[0].axisLine,axisLabel:a.xAxis[0].axisLabel}],series:r.editableTabs,dataZoom:a.dataZoom}}),K=y(()=>{const t=e.element.style.width,a=e.element.style.height;return{width:t,height:a}});function v(){o.value&&(o.value.setOption(f.value,!0),i.value&&(i.value.clearLoop(),i.value=null),e.propValue.autoPlay&&(i.value=A(o.value,f.value,{interval:e.propValue.autoPlayTime*1e3,loopSeries:e.propValue.loopSeries,seriesIndex:Number.parseInt(e.propValue.seriesIndex)})))}return h(K,g(()=>{f.value,o.value&&o.value.resize()},500),{deep:!0}),h(()=>e.propValue,g(()=>{v()},1e3),{deep:!0}),h(()=>s.state.globalKey,g(()=>{var t,a,r,c;((a=(t=e.propValue.data.request)==null?void 0:t.global)==null?void 0:a.length)>0&&(e.propValue.data.request.global.forEach(n=>{const l=s.state.globalKey.findIndex(u=>u.globalKey===n);if(l>-1){const u=[s.state.globalKey[l].globalKey,s.state.globalKey[l].globalValue],d=e.propValue.data.request.data.findIndex(p=>p[0]===u[0]);d>-1?e.propValue.data.request.data[d][1]=u[1]:e.propValue.data.request.data.push(u)}}),e.propValue.data.cancelRequest(),e.propValue.data.cancelRequest=b(e.propValue.data.request,e.element.propValue.data,"x","array"));for(let n=0;n<e.propValue.data.editableTabs.length;n++){const l=e.propValue.data.editableTabs[n];l.request&&((c=(r=l.request)==null?void 0:r.global)==null?void 0:c.length)>0&&l.request.global.forEach(u=>{const d=s.state.globalKey.findIndex(p=>p.globalKey===u);if(d>-1){const p=[s.state.globalKey[d].globalKey,s.state.globalKey[d].globalValue],T=l.request.data.findIndex(L=>L[0]===p[0]);T>-1?l.request.data[T][1]=p[1]:l.request.data.push(p)}l.cancelRequest(),l.cancelRequest=b(l.request,l,"data","array")})}},500),{deep:!0}),O(y(()=>e.linkage),m(e.element)),I(()=>{o.value=S(V.value,"vintage"),w(()=>{v()}),e.propValue.data.request&&(e.propValue.data.cancelRequest=b(e.propValue.data.request,e.element.propValue.data,"x","array"));for(let t=0;t<e.propValue.data.editableTabs.length;t++){const a=e.propValue.data.editableTabs[t];a.request&&(a.cancelRequest=b(a.request,a,"data","array"))}}),j(()=>{e.propValue.data.cancelRequest&&e.propValue.data.cancelRequest();for(let t=0;t<e.propValue.data.editableTabs.length;t++){const a=e.propValue.data.editableTabs[t];a.cancelRequest&&a.cancelRequest()}i.value&&(i.value.clearLoop(),i.value=null)}),N(()=>{o.value&&(o.value.clear(),o.value=null)}),(t,a)=>(E(),B("div",{ref_key:"chartRef",ref:V,style:{width:"100%",height:"100%"}},null,512))}});export{G as default};
