2 lines
2.1 KiB
JavaScript
2 lines
2.1 KiB
JavaScript
var m=(s,u,o)=>new Promise((n,l)=>{var i=t=>{try{f(o.next(t))}catch(e){l(e)}},c=t=>{try{f(o.throw(t))}catch(e){l(e)}},f=t=>t.done?n(t.value):Promise.resolve(t.value).then(i,c);f((o=o.apply(s,u)).next())});import{t as g}from"./other.130807fc.js";import{u as b}from"./useECharts.9a99a074.js";import w from"./Box.a393e3ff.js";import{a as B,fh as C,v as k,w as v,bq as D,L as j,k as L,aG as S,o as O,j as $,z as E,i as h,aH as z}from"./index.78bf44cb.js";import{a as N,c as P}from"./colors.35198826.js";import{u as A}from"./visualization.9b37c87d.js";const F=B({components:{Box:w},props:{data:{type:Object},index:{type:Number}},setup(s){const u=A(),o=C(()=>s.data),n=k(null),{setOptions:l}=b(n),i=v({list:[]});function c(){return m(this,null,function*(){const{id:t}=L(s.data);if(!t)return;const e=yield g({crop_id:t,year:u.getYear}),p=[];for(const d in e)if(Object.prototype.hasOwnProperty.call(e,d)){const a=e[d];p.push({name:a.name,list:Object.keys(a.list).map(r=>a.list[r]),axis:Object.keys(a.list).map(r=>r)})}i.list=p,f()})}function f(){var a;const t={legendData:[],series:[]},e=Number(s.index)%2,p=e==1?N:P,d=e==1?"bar":"line";i.list.forEach(({name:r,list:x},y)=>{const _=p[y%p.length];t.legendData.push(r),t.series.push({name:r,data:x,type:d,itemStyle:{color:_.itemColor}})}),l({grid:{left:"2%",right:"2%",top:"10%",bottom:"2%",containLabel:!0},legend:{show:!1,data:t.legendData,top:"0%",right:"0",textStyle:{color:"#ffffff"}},tooltip:{trigger:"axis",axisPointer:{lineStyle:{width:1,color:"#019680"}}},xAxis:{type:"category",data:(a=i.list[0])==null?void 0:a.axis,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}}}),R={class:"h-full flex flex-col w-full"},T={class:"flex-1",ref:"chartRef"};function V(s,u,o,n,l,i){const c=S("Box");return O(),$(c,z({title:s.propsData.name},s.$attrs),{default:E(()=>[h("div",R,[h("div",T,null,512)])]),_:1},16,["title"])}var J=j(F,[["render",V]]);export{J as default};
|