import{i as b}from"./echarts.72dc8373.js";import{m as g}from"./enum.dd3cd1a4.js";import{X as c}from"./index.8a64ecdf.js";import{m as w}from"./tools.cf97d3ca.js";import{d as E,r as l,k as L,j as S,p as z,w as D,ae as M,H as R,o as k,c as A,a as C}from"./vue.95e072e2.js";import{_ as q}from"./_plugin-vue_export-helper.c27b6911.js";import"./elementPlus.58179425.js";const B=E({name:"DataTendencyChart",__name:"index",props:{fetchLine:{},query:{},initMetric:{default:()=>[{metric:"sales",color:"#0085ff",label:"销售额"},{metric:"planSales",color:"#3fd4cf",label:"计划销售额"},{metric:"planSales",color:"#3fd4cf",label:"计划销售额"}]},metricEnum:{default:()=>g}},emits:["changeStatDim"],setup(f,{emit:I}){const s=f,o=l(s.initMetric),d=l([]);let t;const m=l(),a={dataset:{source:[]},tooltip:{trigger:"axis",axisPointer:{label:{backgroundColor:"#6a7985"}}},legend:{selected:{},show:!1},grid:{top:50,right:150,bottom:30,left:65},xAxis:{type:"category"},yAxis:[{id:0,type:"value",name:"",splitLine:{show:!0},axisLine:{show:!0,lineStyle:{color:""}},show:!0},{id:1,type:"value",name:"",position:"right",splitLine:{show:!1},axisLine:{show:!0,lineStyle:{color:""}},show:!0}],series:[{id:0,name:"",type:"bar",encode:{x:"data_datetime",y:""},barMaxWidth:"18px",yAxisIndex:0,itemStyle:{color:"",borderRadius:4}},{id:1,name:"",type:"bar",encode:{x:"data_datetime",y:""},barMaxWidth:"18px",yAxisIndex:0,itemStyle:{color:"",borderRadius:4}}]},i=l(!0),h=L(()=>w(s.query));S(()=>{_(),setTimeout(()=>{u()},0)}),z(()=>{t&&(t.dispose(),t=null),x()});const u=async()=>{t=b(m.value),a.dataset.source=d.value,c.arrayEach(a.series,(e,r)=>{const n=o.value[r].color;e.name=o.value[r].label,e.encode.y=o.value[r].metric,e.type==="bar"&&(e.itemStyle.color=n)}),c.arrayEach(a.yAxis,(e,r)=>{e.name=o.value[r].label,e.axisLine.lineStyle.color=o.value[r].color}),c.arrayEach(s.metricEnum,e=>{a.legend.selected[e.label]=!1});for(const e of o.value)a.legend.selected[e.label]=!0;t.setOption(a),i.value=!1},v=async()=>{const e=await s.fetchLine(h.value);d.value=e.data};let p=!1;D(s.query,async()=>{if(!p){p=!0;return}i.value=!0,t.setOption(a,!0),await v(),await u(),i.value=!1});const y=()=>{t.resize()},_=()=>{window.addEventListener("resize",y)},x=()=>{window.removeEventListener("resize",y)};return(e,r)=>{const n=M("loading");return R((k(),A("div",null,[C("div",{ref_key:"chartRef",ref:m,style:{height:"350px"}},null,512)])),[[n,i.value]])}}});const H=q(B,[["__scopeId","data-v-9a46a82c"]]);export{H as default};
