import{i as b}from"./echarts.72dc8373.js";import{m as g}from"./enum.75055dcb.js";import{X as c}from"./index.ad3efb29.js";import{m as w}from"./tools.cdecb49f.js";import{d as E,r as l,k as L,j as S,A as z,w as A,aq as D,P as M,o as R,c as k,a as q}from"./vue.adf17aba.js";import{_ as C}from"./_plugin-vue_export-helper.c27b6911.js";import"./elementPlus.4833989a.js";import"./columns.c1b3552e.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:P}){const i=f,o=l(i.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}}]},s=l(!0),h=L(()=>w(i.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(i.metricEnum,e=>{a.legend.selected[e.label]=!1});for(const e of o.value)a.legend.selected[e.label]=!0;t.setOption(a),s.value=!1},v=async()=>{const e=await i.fetchLine(h.value);d.value=e.data};let p=!1;A(i.query,async()=>{if(!p){p=!0;return}s.value=!0,t.setOption(a,!0),await v(),await u(),s.value=!1});const y=()=>{t.resize()},_=()=>{window.addEventListener("resize",y)},x=()=>{window.removeEventListener("resize",y)};return(e,r)=>{const n=D("loading");return M((R(),k("div",null,[q("div",{ref_key:"chartRef",ref:m,style:{height:"350px"}},null,512)])),[[n,s.value]])}}});const Q=C(B,[["__scopeId","data-v-9a46a82c"]]);export{Q as default};
