2 lines
3.9 KiB
JavaScript
2 lines
3.9 KiB
JavaScript
var T=(u,b,n)=>new Promise((p,m)=>{var _=a=>{try{i(n.next(a))}catch(f){m(f)}},y=a=>{try{i(n.throw(a))}catch(f){m(f)}},i=a=>a.done?p(a.value):Promise.resolve(a.value).then(_,y);i((n=n.apply(u,b)).next())});import F from"./Box.96907776.js";import{u as N}from"./useECharts.4a9fd424.js";import{j}from"./other.09bce045.js";import{u as Z}from"./visualization.7dc4ea5f.js";import{a as w}from"./colors.69d1b0cd.js";import{u as z}from"./useVContext.64876532.js";import{a as P,s as C,r as B,H as V,bp as M,af as O,J as R,aA as U,o as k,j as W,x as Y,i as g,h as S,F as G,aD as H,n as J,t as q}from"./index.c4b7c8b0.js";import{a as K}from"./add.253a951f.js";const Q=P({components:{Box:F},setup(){const{rootEmitter:u}=z(),b=C([{key:"1",value:"\u9972\u6599"},{key:"2",value:"\u80A5\u6599"}]),n=C({x_axis:[],series:[]}),p=B("1"),m=Z(),_=B(null),y=e=>{p.value!=e&&(p.value=e,f())},{setOptions:i,getInstance:a}=N(_);function f(e=!0){return T(this,null,function*(){const s=yield j({year:m.getYear,type:p.value});n.x_axis=s.x_axis,n.series=s.series,e?A():$()})}let h=[];function I(){const e={legendData:[],series:[]};return n.series.forEach(({name:s,data:o,diffs:l},t)=>{const c=w[t%w.length];e.legendData.push(s),e.series.push({name:"Placeholder",type:"bar",barGap:0,stack:"Total"+t,itemStyle:{borderColor:"transparent",color:"transparent"},data:o}),e.series.push({name:s,type:"bar",stack:"Total"+t,itemStyle:{color:c.itemColor1},label:{show:!1,position:"inside",color:"#fff"},data:l})}),h=e.legendData,e}const A=()=>{const e=I();i({grid:{left:"2%",right:"2%",top:"50px",bottom:"2%",containLabel:!0},legend:{show:!0,data:e.legendData,textStyle:{color:"#ffffff"}},tooltip:{trigger:"axis",axisPointer:{lineStyle:{width:1,color:"#019680"}},formatter:function(s){var l;let o=((l=s[0])==null?void 0:l.name)+"<br/>";return s.forEach(t=>{var c,x;if(t.seriesName!="Placeholder"){const v=n.series.find(d=>d.name==t.seriesName);if(v){const d=(c=v.data[t.dataIndex])!=null?c:0,E=(x=v.diffs[t.dataIndex])!=null?x:0,L=K(Number(d),Number(E));o+=`${t.marker}<span style="width:50px;display: inline-block;">${t.seriesName}</span> ${d}-${L}<br>`}}}),o}},xAxis:{type:"category",data:n.x_axis,axisTick:{show:!1},axisLine:{show:!1},axisLabel:{color:"#fff"}},yAxis:[{position:"left",alignTicks:!0,nameTextStyle:{color:"#fff"},type:"value",axisTick:{show:!1},splitLine:{lineStyle:{type:"solid",color:"#8EEEFF",opacity:.3}},axisLabel:{color:"#fff"}}],series:e.series}),D()};let r=null;function D(){let e=0;const s=3e3;r&&clearInterval(r);let o=0,l=0;const t=2;r=setInterval(()=>{var c;o=e%4,l=e%(4*t),(c=a())==null||c.dispatchAction({type:"showTip",seriesIndex:0,dataIndex:o}),l+1>=4*t&&(r&&clearInterval(r),setTimeout(()=>{var x;(x=a())==null||x.dispatchAction({type:"hideTip"})},s),f(!1)),e++},s)}function $(){const e=I();let s=0,o=0;const l=3e3;r&&clearInterval(r),r=setInterval(()=>{var t,c;o=s%h.length,o==0&&h.forEach((x,v)=>{var d;(d=a())==null||d.dispatchAction({type:"legendUnSelect",name:h[v]})}),(t=a())==null||t.setOption({series:[e.series[o]]}),(c=a())==null||c.dispatchAction({type:"legendSelect",name:h[o]}),o==h.length-1&&(r&&clearInterval(r),setTimeout(()=>{D()},l)),s++},l)}return V(()=>m.getYear,()=>{f()}),M(()=>{f(),u.on("interval:auto",()=>{})}),O(()=>{r&&clearInterval(r)}),{tabList:b,currentTab:p,chartRef:_,changeTab:y}}}),X={class:"h-full flex flex-col"},ee={class:"py-10px"},te={class:"flex items-center justify-center m-0"},ae=["onClick"],se={class:"flex-1",ref:"chartRef"};function oe(u,b,n,p,m,_){const y=U("Box");return k(),W(y,{title:"\u5927\u5B97\u7269\u8D44\uFF08\u5143/\u5428\uFF09"},{default:Y(()=>[g("div",X,[g("div",ee,[g("ul",te,[(k(!0),S(G,null,H(u.tabList,i=>(k(),S("li",{class:J(["mx-11px text-white text-12px cursor-pointer",{active:u.currentTab==i.key}]),onClick:a=>u.changeTab(i.key),key:i.key},q(i.value),11,ae))),128))])]),g("div",se,null,512)])]),_:1})}var me=R(Q,[["render",oe],["__scopeId","data-v-550bd698"]]);export{me as default};
|