import{i as w}from"./echarts.DoXO02ct.js";import{g as S}from"./api.DGelHC0B.js";/* empty css                   */import{h as A}from"./elementPlus.CXoFsoPv.js";import{d as I,r as i,j as M,A as W,aq as L,P as E,o as R,c as z,a as D}from"./vue.1RczIYhx.js";const P=I({__name:"LineChart",setup(B){let t;const l=i(null),o=i(!1),c=i([]),d=i([]),x=i([]),p=i([]);M(()=>{b(),u()}),W(()=>{t&&(t.dispose(),t=null),f()});const a={title:{left:"-0.2%",text:"每月平均评分",textStyle:{fontSize:"16px",fontWeight:"500"}},tooltip:{trigger:"axis"},legend:{top:"10%",align:"right"},grid:{top:"30%",left:"5%",right:"5%",bottom:"5%",containLabel:!0},xAxis:{type:"category",data:[]},yAxis:[{type:"value",name:"平均评分",min:2,max:5,interval:.5,position:"left",axisLine:{show:!0,lineStyle:{color:"#70b6e3"}},axisLabel:{formatter:"{value} 分"}},{type:"value",name:"评分数量",min:0,position:"right",splitLine:{show:!1},axisLine:{show:!0,lineStyle:{color:"#5470c6"}},axisLabel:{formatter:"{value} 个"}}],series:[{id:0,name:"新品平均评分",type:"line",yAxisIndex:0,itemStyle:{color:"#70b6e3",lineStyle:{color:"#70b6e3"}},data:[]},{id:1,name:"旧品平均评分",type:"line",yAxisIndex:0,itemStyle:{color:"#8170cc",lineStyle:{color:"#3f3da4"}},data:[]},{name:"新品一星",type:"bar",stack:"stack1",yAxisIndex:1,barGap:0,barMaxWidth:"14px",itemStyle:{color:"#e7b3b3"},data:[]},{name:"旧品一星",type:"bar",stack:"stack1",yAxisIndex:1,barGap:0,barMaxWidth:"14px",itemStyle:{color:"rgba(231,179,179,0.73)"},data:[]},{name:"新品二星",type:"bar",stack:"stack2",yAxisIndex:1,barMaxWidth:"14px",itemStyle:{color:"#fdba74"},data:[]},{name:"旧品二星",type:"bar",stack:"stack2",yAxisIndex:1,barMaxWidth:"14px",itemStyle:{color:"rgba(253,186,116,0.79)"},data:[]},{name:"新品三星",type:"bar",stack:"stack3",yAxisIndex:1,barMaxWidth:"14px",itemStyle:{color:"#eae09e"},data:[]},{name:"旧品三星",type:"bar",stack:"stack3",yAxisIndex:1,barMaxWidth:"14px",itemStyle:{color:"rgba(234,224,158,0.76)"},data:[]},{name:"新品四星",type:"bar",yAxisIndex:1,stack:"stack4",barMaxWidth:"14px",itemStyle:{color:"#bae6fd"},data:[]},{name:"旧品四星",type:"bar",yAxisIndex:1,stack:"stack4",barMaxWidth:"14px",itemStyle:{color:"rgba(186,230,253,0.76)"},data:[]},{name:"新品五星",type:"bar",stack:"stack5",yAxisIndex:1,barMaxWidth:"14px",itemStyle:{color:"#a6e3a1"},data:[]},{name:"旧品五星",type:"bar",stack:"stack5",yAxisIndex:1,barMaxWidth:"14px",itemStyle:{color:"rgba(166,227,161,0.66)"},data:[]}]};async function u(){await v(),t=w(l.value),t.setOption(a,!0)}async function v(){try{o.value=!0;const s=(await S({})).data;c.value=s.new_avg_score.map(e=>e.avg_val),d.value=s.old_avg_score.map(e=>e.avg_val),a.xAxis.data=s.new_avg_score.map(e=>e.date),a.series[0].data=c.value,a.series[1].data=d.value,s.reviews_items.forEach(e=>{const r=[e.reviews1_sum||0,e.reviews2_sum||0,e.reviews3_sum||0,e.reviews4_sum||0,e.reviews5_sum||0];e.is_new_sku?x.value.push(r):p.value.push(r)}),[x,p].forEach((e,r)=>{e.value.forEach((g,_)=>{g.forEach((k,n)=>{a.series[2*n+r+2].data=a.series[2*n+r+2].data||[],a.series[2*n+r+2].data[_]=k})})})}catch{A.error("加载数据失败，请稍后再试")}finally{o.value=!1}}function y(){t.resize()}function b(){window.addEventListener("resize",y)}function f(){window.removeEventListener("resize",y)}return(m,h)=>{const s=L("loading");return E((R(),z("div",null,[D("div",{ref_key:"chartRef",ref:l,style:{width:"100%",height:"520px",background:"#fff"}},null,512)])),[[s,o.value]])}}});export{P as _};
