var C=(h,c,i)=>new Promise((d,p)=>{var v=t=>{try{e(i.next(t))}catch(o){p(o)}},g=t=>{try{e(i.throw(t))}catch(o){p(o)}},e=t=>t.done?d(t.value):Promise.resolve(t.value).then(v,g);e((i=i.apply(h,c)).next())});import{u as E}from"./useECharts.514ffc33.js";import{a as S,r as b,p as k,aa as z,o as $,e as B,ag as F}from"./index.ae52ebae.js";const D=S({__name:"complexLine",props:{width:{type:String,default:"100%"},height:{type:String,default:"400px"},data:{type:Object,default:()=>{}}},setup(h){const c=h,i=b(null),{setOptions:d}=E(i),p=b();k(()=>C(this,null,function*(){!c.data||g()})),z(()=>c.data,e=>{g()});function v(e,t,o){let s=[],r=[],l=[];return e.forEach((a,n)=>{s.push({value:a[0],itemStyle:{color:a[0]*a[1]>=0?"transparent":"#ff9f7f",borderColor:a[0]*a[1]>=0?"transparent":"#ff9f7f"}});const f=o?[a[0],n]:[n,a[0]];l.push({value:a[0],coord:a[0]?f:[]}),r.push({value:a[0]*a[1]>0?(a[1]-a[0]).toFixed(2):a[1],range:a,name:t,label:{formatter:""+a[1]},itemStyle:{color:"#ff9f7f"}})}),{min:s,max:r,minLabel:l}}function g(){let e=c.data,t=e.content[0],o="",s="";e!=null&&e.description&&(o=e.description),((e==null?void 0:e.average)!=null||(e==null?void 0:e.variance)!=null)&&(s+=" \u5747\u6570 \xB1 \u6807\u51C6\u5DEE: "+e.average+"\xB1"+e.variance+" "),(e==null?void 0:e.min)!=null&&(s+=" \u6700\u5C0F\u503C: "+e.min+" "),(e==null?void 0:e.max)!=null&&(s+=" \u6700\u5927\u503C: "+e.max+" "),(e==null?void 0:e.sampleCount)!=null&&(s+=" \u6837\u672C\u6570: "+e.sampleCount);let r=[],l=[];if(t.average!=null&&t.average.length&&(r.push("\u5747\u503C"),l.push({name:"\u5747\u503C",type:e.scatter?"scatter":"line",data:t.average||[]})),t.min!=null&&t.min.length&&(r.push("\u6700\u5C0F\u503C"),l.push({name:"\u6700\u5C0F\u503C",type:e.scatter?"scatter":"line",data:t.min||[]})),t.max!=null&&t.max.length&&(r.push("\u6700\u5927\u503C"),l.push({name:"\u6700\u5927\u503C",type:e.scatter?"scatter":"line",data:t.max||[]})),t.sampleCount!=null&&t.sampleCount.length&&(r.push("\u6837\u672C\u6570"),l.push({name:"\u6837\u672C\u6570",type:e.scatter?"scatter":"line",data:t.sampleCount||[]})),t.variance.length){let n="\u5747\u6570\xB1\u6807\u51C6\u5DEE";r.push(n);const{min:f,max:m,minLabel:y}=v(t.variance,n,!0);l.push({name:n,stack:n,type:"bar",tooltip:{show:!1},color:"#ff9f7f",label:{show:!1},barWidth:10,data:f}),l.push({name:n,stack:n,type:"bar",tooltip:{show:!0},label:{show:!1,position:"top"},markPoint:{symbol:"rect",symbolSize:1e-15,label:{show:!0,position:"bottom"},data:y},barWidth:10,data:m})}let a=e==null?void 0:e.time;p.value=a.length>10?80:0,d({title:{text:o,subtext:s,left:"left",textStyle:{fontSize:16}},toolbox:{feature:{saveAsImage:{}}},tooltip:{trigger:"axis",formatter:function(n){var f="",m="";n.forEach(u=>{if(u.name=="\u5747\u6570\xB1\u6807\u51C6\u5DEE"){const x=u.data.range,w=((x[1]+x[0])/2).toFixed(2)+"\xB1"+((x[1]-x[0])/2).toFixed(2);f+=`
${u.marker} ${u.name} ${w}
`}else m=u.axisValue,f+=`
${u.marker} ${u.seriesName} ${u.value}
`});var y=`
${m}
${f}
`;return y}},legend:{data:r,right:30,top:4},grid:{left:"5%",right:"5%",bottom:"12%",containLabel:!0},xAxis:{type:"category",boundaryGap:!1,data:a,axisLabel:{interval:(e==null?void 0:e.id)==="alarmScatter"?0:"auto"}},yAxis:{type:"value"},dataZoom:(e==null?void 0:e.id)==="alarmScatter"?[]:[{type:"inside",start:p.value,end:100},{start:p.value,end:100}],series:l})}return(e,t)=>($(),B("div",{ref_key:"chartRef",ref:i,style:F({height:h.height,width:h.width})},null,4))}});export{D as default};