import{_ as E,a5 as T,b as O,bL as c,ah as $,b1 as I,r as S,o as h,c as u,F as M,A as Y,v as H,n as N,ai as k}from"./index.8d733f79.js";import{E as B}from"./exporting.83037eec.js";import{A as z}from"./annotations.d7724f2a.js";import{g as F}from"./deviceAnalysis.ce7ce4e7.js";const G={style:{height:"100%",width:"100%",overflow:"auto",flex:"1"}},W=["id"],j=["id"],P=T({name:"TrendAnalysis"}),X=Object.assign(P,{setup(U,{expose:g}){const{t:f}=O();z(c),B(c);const _=$({conditionList:[],indicatorList:[],dirction:"",metrics:[],pointId:"",allChartData:{}}),{allChartData:v}=I(_),i={},l=S([]);function C(t,n,a,o){o==="reget"&&(l.value=[]);for(let e=0;e<t.length;e++)i[`chart_${t[e].pointId}`]||(i[`chart_${t[e].pointId}`]=null),l.value.indexOf(t[e].pointId)===-1&&(l.value.push(t[e].pointId),b(t[e],n,a));for(let e=l.value.length-1;e>=0;e--){let r=!1;for(let s=0;s<t.length;s++)t[s].pointId===l.value[e]&&(r=!0);r||l.value.splice(e,1)}}function b(t,n,a){F({metrics:n.calcBasis,pointId:t.pointId,startTime:a[0],endTime:a[1],hasFileId:!1,manualUpload:!1}).then(o=>{v.value=o.data||{},o.data&&JSON.stringify(o.data)!=="{}"?Object.keys(o.data).forEach(e=>{const s=o.data[e][e].data.map(d=>[new Date(d.time).getTime(),Number(d.value)]);setTimeout(()=>{m(`chart_${t.pointId}`,s,{...o.data[e][e].property},{pointName:t.pointName,axial:t.mainAxial,threshold:t.threshold})},0)}):m(`chart_${t.pointId}`,[],{},{pointName:t.pointName,axial:t.mainAxial,threshold:t.threshold})}).catch(()=>{})}function m(t,n,a,o){let e=`${o.pointName} ${f("trendChart")}`;n.length&&(e=`${o.pointName} ${f("trendChart")} (${a.unit})`),i[t]=c.chart(t,{colors:["#1CEC9C"],title:{useHTML:!0,text:e,align:"left",x:-8,y:6,style:{color:"#A9C1E0",fontSize:"15px"}},time:{useUTC:!1},chart:{backgroundColor:"#002042",marginTop:40,marginBottom:20,zoomType:"x",animation:!1,events:{click(){},selection(r){r.xAxis&&Object.keys(i).forEach(s=>{const d=i[s].userOptions.series[0].data.length;if(!d)return;const A=r.xAxis[0].min<i[s].userOptions.series[0].data[0][0]?i[s].userOptions.series[0].data[0][0]:r.xAxis[0].min,D=r.xAxis[0].max>i[s].userOptions.series[0].data[d-1][0]?i[s].userOptions.series[0].data[d-1][0]:r.xAxis[0].max;i[s].xAxis[0].setExtremes(A,D)})}}},exporting:{enabled:!1},yAxis:{title:{text:null},lineColor:"#445775",gridLineDashStyle:"Dash",gridLineColor:"transparent",gridLineWidth:1,minorGridLineWidth:1,minorTickColor:"rgba(68,87,117,0.3)",minorTickInterval:"auto",minorGridLineColor:"rgba(68,87,117,0.3)",minorGridLineDashStyle:"Dash",labels:{style:{color:"#93B3E0"}},plotLines:[{id:t,color:"#D42121",dashStyle:"dot",value:o.threshold,width:2}]},xAxis:{gridLineDashStyle:"Dash",gridLineColor:"transparent",lineColor:n.length?"#445775":"transparent",gridLineWidth:1,minorGridLineWidth:1,minorTickColor:"rgba(68,87,117,0.3)",minorTickInterval:"auto",minorGridLineColor:"rgba(68,87,117,0.3)",minorGridLineDashStyle:"Dash",tickLength:4,labels:{y:16,style:{color:"#93B3E0",fontSize:"12px"}},crosshair:{color:"#93B3E0",dashStyle:"dash",width:1},type:"datetime",dateTimeLabelFormats:{millisecond:"%H:%M:%S",second:"%H:%M:%S",minute:"%H:%M",hour:"%H:%M",day:"%m-%d",week:"%m-%d",month:"%Y-%m",year:"%Y"}},credits:{enabled:!1},legend:{enabled:!1},tooltip:{backgroundColor:"#004584",style:{color:"#EAF2FF"},borderColor:"#004584",shadow:!1,useHTML:!0,shared:!0,shape:"rect",formatter(){return`${k(this.x).format("YYYY-MM-DD HH:mm:ss")}, ${this.y}${a.unit}`}},plotOptions:{series:{label:{connectorAllowed:!1},marker:{lineWidth:0,width:8,height:8,symbol:"circle",radius:2},cursor:"pointer",point:{}}},series:[{data:n}],responsive:{}}),setTimeout(()=>{y(t)},0)}let p,x;function y(t){const n=i[t].container;n.addEventListener("mousedown",a=>{p=a.clientX,x=a.clientY}),n.addEventListener("mouseup",a=>{const o=a.clientX-p,e=a.clientY-x;o<0&&e<0?(i[t].xAxis[0].zoomEnabled=!1,Object.keys(i).forEach(r=>{i[r].zoomOut()})):i[t].xAxis[0].zoomEnabled=!0})}function L(t){if(l.value.indexOf(t.pointId)!==-1){const n=`chart_${t.pointId}`;i[n].yAxis[0].removePlotLine(n),t.threshold&&i[n].yAxis[0].addPlotLine({value:t.threshold,width:2,color:"#D42121",dashStyle:"dot",zIndex:99,id:n})}}return g({handleChartData:C,changePlot:L}),(t,n)=>(h(),u("div",G,[(h(!0),u(M,null,Y(N(l),a=>(h(),u("div",{key:a,class:"chartContent",id:"content_"+a},[H("div",{id:"chart_"+a,style:{height:"100%",width:"100%",overflow:"hidden"}},null,8,j)],8,W))),128))]))}}),q=E(X,[["__scopeId","data-v-8b5fdee1"]]);export{q as default};
