import{i as z,L as I}from"./echarts.0aac64e0.js";import{q as D}from"./enum.f5dda017.js";import{M as A}from"./index.43a915b5.js";import{p as N,X as f,I as O}from"./index.b0fbf8af.js";import{d as T,r as m,k as W,j as q,p as H,w as R,a8 as L,ae as B,H as U,o as P,c as j,M as c,G as p,K as h,a as G}from"./vue.95e072e2.js";import{_ as X}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.df979911.js";import"./elementPlus.1bc6bbc0.js";const $=T({name:"DataTendencyChart",__name:"dataTendency",props:{fetchCard:{},fetchLine:{},fetchLineMonth:{},fetchLineWeek:{},fetchLineHour:{},query:{},initMetric:{default:()=>[{metric:"Impression",color:"#0085ff",label:"曝光量"},{metric:"Click",color:"#3fd4cf",label:"点击量"},{metric:"Spend",color:"#ff9500",label:"花费"}]},metricEnum:{default:()=>D}},setup(x){const a=x,o=m(a.initMetric),y=m([]);let l;const _=m(),u=m("day"),i={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,min:0,type:"value",name:"",splitLine:{show:!0},axisLine:{show:!0,lineStyle:{color:""}},show:!0},{id:1,min:0,type:"value",name:"",position:"right",splitLine:{show:!1},axisLine:{show:!0,lineStyle:{color:""}},show:!0},{id:2,min:0,type:"value",position:"right",offset:90,name:"",splitLine:{show:!1},axisLine:{show:!0,lineStyle:{color:""}},show:!0}],series:[{id:0,name:"",type:"bar",encode:{x:"Name",y:""},barWidth:"18px",yAxisIndex:0,itemStyle:{color:"",borderRadius:4}},{id:1,name:"",type:"line",encode:{x:"Name",y:""},symbolSize:6,symbol:"circle",smooth:!0,yAxisIndex:1,itemStyle:{},areaStyle:{},emphasis:{focus:"series"}},{id:2,name:"",type:"line",encode:{x:"Name",y:""},symbolSize:6,symbol:"circle",smooth:!0,yAxisIndex:2,itemStyle:{},areaStyle:{},emphasis:{focus:"series"}}]},n=m(!0),d=W(()=>N(a.query));q(()=>{g(),E(),setTimeout(()=>{C()},0)}),H(()=>{l&&(l.dispose(),l=null),M()});const C=async()=>{l=z(_.value);const s=await v();i.dataset.source=s,f.arrayEach(i.series,(e,t)=>{const r=o.value[t].color;e.name=o.value[t].label,e.encode.y=o.value[t].metric,e.type==="bar"?e.itemStyle.color=r:(e.itemStyle={color:r,borderColor:r},e.areaStyle={color:new I(0,0,0,1,[{offset:0,color:r+"53"},{offset:1,color:r+"03"}])})}),f.arrayEach(i.yAxis,(e,t)=>{e.name=o.value[t].label,e.axisLine.lineStyle.color=o.value[t].color}),f.arrayEach(a.metricEnum,e=>{i.legend.selected[e.label]=!1});for(const e of o.value)i.legend.selected[e.label]=!0;l.setOption(i),n.value=!1},v=async()=>{if(u.value==="week"){if(a.fetchLineWeek)return(await a.fetchLineWeek(d.value)).data}else if(u.value==="month"){if(a.fetchLineMonth)return(await a.fetchLineMonth(d.value)).data}else if(u.value==="hour"){if(a.fetchLineHour)return(await a.fetchLineHour(d.value)).data}else return(await a.fetchLine(d.value)).data},g=async()=>{const e=(await a.fetchCard(d.value)).data;y.value.length=0,f.arrayEach(a.metricEnum,t=>{const r={label:t.label,value:t.value,metricVal:e[t.value],gapVal:e[`gap${t.value}`],preVal:e[`prev${t.value}`]};y.value.push(r)})},S=()=>{const s=O(i,o.value);l.setOption(s)},k=async()=>{n.value=!0;let s=await v();s.length>0&&l.setOption({dataset:{source:s}}),n.value=!1};R(a.query,async()=>{n.value=!0,await g();const e={dataset:{source:await v()}};l.setOption(e),n.value=!1});const w=()=>{l.resize()},E=()=>{window.addEventListener("resize",w)},M=()=>{window.removeEventListener("resize",w)};return(s,e)=>{const t=L("el-radio-button"),r=L("el-radio-group"),V=B("loading");return U((P(),j("div",null,[c(A,{modelValue:o.value,"onUpdate:modelValue":e[0]||(e[0]=b=>o.value=b),"metric-items":y.value,onChange:S},null,8,["modelValue","metric-items"]),c(r,{modelValue:u.value,"onUpdate:modelValue":e[1]||(e[1]=b=>u.value=b),class:"chart-button-group",onChange:k},{default:p(()=>[c(t,{label:"hour",disabled:!a.fetchLineHour},{default:p(()=>[h("时")]),_:1},8,["disabled"]),c(t,{label:"day"},{default:p(()=>[h("日")]),_:1}),c(t,{label:"week",disabled:!a.fetchLineWeek},{default:p(()=>[h("周")]),_:1},8,["disabled"]),c(t,{label:"month",disabled:!a.fetchLineWeek},{default:p(()=>[h("月")]),_:1},8,["disabled"])]),_:1},8,["modelValue"]),G("div",{style:{height:"350px"},ref_key:"chartRef",ref:_},null,512)])),[[V,n.value]])}}});const ae=X($,[["__scopeId","data-v-7ab9b914"]]);export{ae as default};