2 lines
2.2 KiB
JavaScript
2 lines
2.2 KiB
JavaScript
var m=(e,u,o)=>new Promise((n,l)=>{var i=t=>{try{f(o.next(t))}catch(a){l(a)}},c=t=>{try{f(o.throw(t))}catch(a){l(a)}},f=t=>t.done?n(t.value):Promise.resolve(t.value).then(i,c);f((o=o.apply(e,u)).next())});import{B as _}from"./other.d43d2a78.js";import{u as B}from"./useECharts.f2bf9eb6.js";import w from"./Box.ea9d0e0a.js";import{a as C,ga as h,v as k,w as v,x as D,q as S,k as $,aE as j,o as E,j as L,B as O,i as x,aF as I}from"./index.203f4f59.js";import{a as N,c as F}from"./colors.69d1b0cd.js";import{u as P}from"./visualization.0e8abb36.js";const z=C({components:{Box:w},props:{data:{type:Object},index:{type:Number},baseId:{type:[String,Number]}},setup(e){e.baseId;const u=P(),o=h(()=>e.data),n=k(null),{setOptions:l}=B(n),i=v({list:[]});function c(){return m(this,null,function*(){const{id:t}=$(e.data);if(!t)return;const a=yield _({crop_id:t,year:u.getYear,base_id:e.baseId}),p=[];for(const d in a)if(Object.prototype.hasOwnProperty.call(a,d)){const s=a[d];p.push({name:`${s.name}(${s.unit})`,list:Object.keys(s.list).map(r=>s.list[r]),axis:Object.keys(s.list).map(r=>r)})}i.list=p,f()})}h(()=>!!e.baseId);function f(){var s;const t={legendData:[],series:[]},a=Number(e.index)%2,p=a==1?N:F,d=a==1?"bar":"line";i.list.forEach(({name:r,list:y},b)=>{const g=p[b%p.length];t.legendData.push(r),t.series.push({name:r,data:y,type:d,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:(s=i.list[0])==null?void 0:s.axis,boundaryGap:d!="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 D(()=>{c()}),{propsData:o,chartRef:n}}}),A={class:"h-full flex flex-col w-full"},R={class:"flex-1",ref:"chartRef"};function T(e,u,o,n,l,i){const c=j("Box");return E(),L(c,I({title:e.propsData.name},e.$attrs),{default:O(()=>[x("div",A,[x("div",R,null,512)])]),_:1},16,["title"])}var J=S(z,[["render",T]]);export{J as default};
|