lcny-vue3-antd-admin/dist/assets/BasicChart.2c4e2353.js

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{w as b}from"./other.34d9f216.js";import{u as g}from"./useECharts.2a49e1ec.js";import w from"./Box.894f0a25.js";import{a as B,f$ as C,r as $,s as k,bp as D,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.306321d2.js";import{a as N,c as P}from"./colors.69d1b0cd.js";import{u as z}from"./visualization.a4e224fe.js";const F=B({components:{Box:w},props:{data:{type:Object},index:{type:Number}},setup(s){const d=z(),a=C(()=>s.data),n=$(null),{setOptions:l}=g(n),r=k({list:[]});function c(){return m(this,null,function*(){const{id:t}=v(s.data);if(!t)return;const e=yield b({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 _=p[y%p.length];t.legendData.push(i),t.series.push({name:i,data:x,type:u,itemStyle:{color:_.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 D(()=>{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};