import{d as w}from"./debounce-Xd493GvO.js";import{r as V}from"./request-CEvu378m.js";import{ar as B}from"./echarts-DB130vfq.js";import{ax as K,r as q,s as j,c as s,j as E,w as g,S as R,B as U,z as G}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 Q=Object.assign({name:"Pie2"},{__name:"Pie2",props:{propValue:{type:Object,required:!0},request:{type:Object,default:()=>({})},element:{type:Object,default:()=>({})}},setup(S){const e=S,d=K(),y=q(null),r=j(null),u=q(null),W=s(()=>e.propValue.data.data),x=s(()=>e.propValue.data.color),O=s(()=>e.propValue.data.bgColor),_=s(()=>e.propValue.data.ringWidth),C=s(()=>e.propValue.data.ringGap),k=s(()=>e.propValue.data.legendUnit||""),A=s(()=>{const a=e.element.style.width,o=e.element.style.height;return{width:a,height:o}}),h=s(()=>{const a=JSON.parse(JSON.stringify(e.propValue.option)),o=W.value,p=x.value,i=O.value,l=_.value,n=C.value,c=o.reduce((t,m)=>t+m.value,0),v=[],b=[];for(let t=0;t<o.length;t++)v.push({name:"",type:"pie",clockWise:!1,hoverAnimation:!1,radius:[`${45-t*(l+n)}%`,`${45-t*(l+n)-l}%`],center:["40%","50%"],label:{show:!1},itemStyle:{borderWidth:e.propValue.option.seriesBorderWidth},data:[{value:o[t].value,name:o[t].name,itemStyle:{color:p[t%p.length]}},{value:c-o[t].value,name:"",itemStyle:{color:"transparent"},tooltip:{show:!1},hoverAnimation:!1}]}),v.push({name:"",type:"pie",silent:!0,z:1,clockWise:!1,hoverAnimation:!1,radius:[`${45-t*(l+n)}%`,`${45-t*(l+n)-l}%`],center:["40%","50%"],label:{show:!1},itemStyle:{borderWidth:e.propValue.option.bgSeriesBorderWidth},data:[{value:7.5,itemStyle:{color:i[t%i.length]},tooltip:{show:!1},hoverAnimation:!1},{value:2.5,itemStyle:{color:"rgba(0,0,0,0)",borderWidth:0},tooltip:{show:!1},hoverAnimation:!1}]}),b.push((o[t].value/c*100).toFixed(2)+"%");return a.series=v,a.color=p,a.backgroundColor=e.propValue.option.backgroundColor,a.legend.show&&(a.legend.data=o.map(t=>t.name),a.legend.formatter=t=>{const m=o.find(z=>z.name===t);return`{title|${t}}
{value|${m?m.value:""}}{value|${k.value}}`}),a.yAxis[0].data=b,a});function $(){r.value&&r.value.dispose(),r.value=B(y.value),r.value.setOption(h.value)}function f(){r.value&&r.value.resize()}return E(()=>{var a,o;e.request&&(u.value=V(e.request,e.propValue,"data")),((o=(a=e.request)==null?void 0:a.global)==null?void 0:o.length)>0&&g(()=>d.state.globalKey,()=>{e.request.global.forEach(p=>{const i=d.state.globalKey.findIndex(l=>l.globalKey===p);if(i>-1){const l=[d.state.globalKey[i].globalKey,d.state.globalKey[i].globalValue],n=e.request.data.findIndex(c=>c[0]===l[0]);n>-1?e.request.data[n][1]=l[1]:e.request.data.push(l)}}),u.value(),u.value=V(e.request,e.propValue,"data")},{deep:!0}),$(),window.addEventListener("resize",f)}),R(()=>{window.removeEventListener("resize",f),e.propValue.request&&u.value&&u.value(),r.value&&(r.value.dispose(),r.value=null)}),g(()=>h,w(()=>{r.value&&r.value.setOption(h.value,!0)},300),{deep:!0}),g(A,w(()=>{f()},300),{deep:!0}),(a,o)=>(G(),U("div",{ref_key:"chartRef",ref:y,style:{width:"100%",height:"100%"}},null,512))}});export{Q as default};
