complexLine.502a6dc8.js 4.4 KB

12345678910111213141516171819202122232425262728
  1. 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+=`
  2. <div style="margin: 6px 0 0;line-height:1;">
  3. ${u.marker}
  4. <span style="font-size:14px;color:#666;font-weight:400;margin-left:2px">
  5. ${u.name}
  6. </span>
  7. <span style="float:right;margin-left:20px;font-size:14px;color:#666;font-weight:900">
  8. ${w}
  9. </span>
  10. </div>
  11. `}else m=u.axisValue,f+=`
  12. <div style="margin: 6px 0 0;line-height:1;">
  13. ${u.marker}
  14. <span style="font-size:14px;color:#666;font-weight:400;margin-left:2px">
  15. ${u.seriesName}
  16. </span>
  17. <span style="float:right;margin-left:20px;font-size:14px;color:#666;font-weight:900">
  18. ${u.value}
  19. </span>
  20. </div>
  21. `});var y=`
  22. <div style="font-size:14px;color:#666;font-weight:400;line-height:1;">
  23. ${m}
  24. </div>
  25. <div style="margin: 10px 0 0;line-height:1;">
  26. ${f}
  27. </div>
  28. `;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};