2 lines
2.1 KiB
JavaScript
2 lines
2.1 KiB
JavaScript
var m=(s,d,a)=>new Promise((n,l)=>{var r=t=>{try{f(a.next(t))}catch(e){l(e)}},c=t=>{try{f(a.throw(t))}catch(e){l(e)}},f=t=>t.done?n(t.value):Promise.resolve(t.value).then(r,c);f((a=a.apply(s,d)).next())});import{t as _}from"./other.bf7df480.js";import{u as b}from"./useECharts.408be3a1.js";import B from"./Box.a274c820.js";import{a as w,g3 as C,r as k,s as D,bp as $,J as j,k as v,aA as S,o as L,j as O,x as E,i as h,aB as A}from"./index.4ae7dbff.js";import{a as N,c as P}from"./colors.69d1b0cd.js";import{u as z}from"./visualization.1ad8504e.js";const F=w({components:{Box:B},props:{data:{type:Object},index:{type:Number}},setup(s){const d=z(),a=C(()=>s.data),n=k(null),{setOptions:l}=b(n),r=D({list:[]});function c(){return m(this,null,function*(){const{id:t}=v(s.data);if(!t)return;const e=yield _({crop_id:t,year:d.getYear}),p=[];for(const u in e)if(Object.prototype.hasOwnProperty.call(e,u)){const o=e[u];p.push({name:`${o.name}(${o.unit})`,list:Object.keys(o.list).map(i=>o.list[i]),axis:Object.keys(o.list).map(i=>i)})}r.list=p,f()})}function f(){var o;const t={legendData:[],series:[]},e=Number(s.index)%2,p=e==1?N:P,u=e==1?"bar":"line";r.list.forEach(({name:i,list:x},y)=>{const g=p[y%p.length];t.legendData.push(i),t.series.push({name:i,data:x,type:u,itemStyle:{color:g.itemColor}})}),l({grid:{left:"2%",right:"2%",top:"30px",bottom:"2%",containLabel:!0},legend:{show:!0,data:t.legendData,top:"0%",right:"0",textStyle:{color:"#ffffff"}},tooltip:{trigger:"axis",axisPointer:{lineStyle:{width:1,color:"#019680"}}},xAxis:{type:"category",data:(o=r.list[0])==null?void 0:o.axis,boundaryGap:u!="line",axisTick:{show:!1},axisLine:{show:!1},axisLabel:{color:"#fff"}},yAxis:[{type:"value",axisTick:{show:!1},splitLine:{lineStyle:{type:"solid",color:"#8EEEFF",opacity:.3}},axisLabel:{color:"#fff"}}],series:t.series})}return $(()=>{c()}),{propsData:a,chartRef:n}}}),R={class:"h-full flex flex-col w-full"},T={class:"flex-1",ref:"chartRef"};function V(s,d,a,n,l,r){const c=S("Box");return L(),O(c,A({title:s.propsData.name},s.$attrs),{default:E(()=>[h("div",R,[h("div",T,null,512)])]),_:1},16,["title"])}var H=j(F,[["render",V]]);export{H as default};
|