import{a9 as j,a5 as S,a0 as T,a as b,aA as O}from"./index.17037962789732.js";import"./index.1703796278973303.js";import"./index.170379627897317.js";import"./index.170379627897336.js";import"./index.170379627897316.js";import{c as q,e as I}from"./instance.1703796278973.js";import{u as J}from"./instance.17037962789732.js";import U from"./Chart.17037962789732.js";import{f as G}from"./index.1703796278973314.js";import{d as H,k as _,l as P,m as z,w as R,o as g,c as h,a as o,z as w,b as n,t as l,u as p,M as C,B as M,x as W}from"./vue.1703796278973.js";const X={key:0},Z={style:{width:"100%",height:"500px"}},oe=H({__name:"Charts",props:{data:{type:Object,default:()=>{}},time:{type:Array,default:()=>[]}},setup(L){const t=L,N=["int","float","double","long"],m=_("*"),c=_("AVG"),v=_(!1),y=_([]),A=J(),k=_({}),x=P(()=>{var a,e;const s=N.includes(((e=(a=t.data)==null?void 0:a.valueType)==null?void 0:e.type)||"");return m.value=s?"*":"1m",s}),B=async()=>{var a,e;v.value=!0;const s=await q(A.current.id,{columns:[{property:t.data.id,alias:t.data.id,agg:c.value}],query:{interval:m.value,format:"yyyy-MM-dd HH:mm:ss",from:t.time[0],to:t.time[1]}});if(v.value=!1,s.status===200){const u=[{year:t.time[1],value:void 0,type:((a=t.data)==null?void 0:a.name)||""}];s.result.forEach(i=>{var r;u.push({...i,year:i.time,value:Number(i[t.data.id||""]),type:((r=t.data)==null?void 0:r.name)||""})}),u.push({year:t.time[0],value:void 0,type:((e=t.data)==null?void 0:e.name)||""}),y.value=(u||[]).reverse()}},E=async()=>{var a,e,u,i;v.value=!0;const s=await I(A.current.id,t.data.id,{paging:!1,terms:[{column:"timestamp$BTW",value:t.time[0]&&t.time[1]?[t.time[0],t.time[1]]:[],type:"and"}],sorts:[{name:"timestamp",order:"asc"}]});if(v.value=!1,s.status===200){const r=[{year:t.time[0],value:void 0,type:((a=t.data)==null?void 0:a.name)||""}];(u=(e=s.result)==null?void 0:e.data)==null||u.forEach(f=>{var d;r.push({...f,year:f.timestamp,value:f.value,type:((d=t.data)==null?void 0:d.name)||""})}),r.push({year:t.time[1],value:void 0,type:((i=t.data)==null?void 0:i.name)||""}),y.value=r||[]}},V=s=>{var a;k.value={xAxis:{type:"category",data:s.map(e=>G(`yyyy-MM-dd
hh:mm:ss`,e.year,!1)),name:"时间"},yAxis:{type:"value",name:(a=s[0])==null?void 0:a.type},dataZoom:[{type:"inside",start:0,end:10},{start:0,end:10}],tooltip:{trigger:"axis",position:function(e){return[e[0],"10%"]}},series:[{data:s.map(e=>e.value),type:"line",areaStyle:{}}]}};return z(()=>[m,c],([s,a])=>{s.value==="*"&&x.value?E():B()},{deep:!0,immediate:!0}),R(()=>{y.value.length&&V(y.value)}),(s,a)=>{const e=j,u=S,i=T,r=b,f=O;return g(),h(f,{spinning:p(v)},{default:o(()=>[w("div",null,[n(i,null,{default:o(()=>[w("div",null,[l(" 统计周期： "),n(u,{value:p(m),"onUpdate:value":a[0]||(a[0]=d=>C(m)?m.value=d:null),style:{width:"120px"}},{default:o(()=>[p(x)?(g(),h(e,{key:0,value:"*"},{default:o(()=>[l("实际值")]),_:1})):M("",!0),n(e,{value:"1m"},{default:o(()=>[l("按分钟统计")]),_:1}),n(e,{value:"1h"},{default:o(()=>[l("按小时统计")]),_:1}),n(e,{value:"1d"},{default:o(()=>[l("按天统计")]),_:1}),n(e,{value:"1w"},{default:o(()=>[l("按周统计")]),_:1}),n(e,{value:"1M"},{default:o(()=>[l("按月统计")]),_:1})]),_:1},8,["value"])]),p(m)!=="*"&&p(x)?(g(),W("div",X,[l(" 统计规则： "),n(u,{value:p(c),"onUpdate:value":a[1]||(a[1]=d=>C(c)?c.value=d:null),style:{width:"120px"}},{default:o(()=>[n(e,{value:"AVG"},{default:o(()=>[l("平均值")]),_:1}),n(e,{value:"MAX"},{default:o(()=>[l("最大值")]),_:1}),n(e,{value:"MIN"},{default:o(()=>[l("最小值")]),_:1}),n(e,{value:"COUNT"},{default:o(()=>[l("总数")]),_:1})]),_:1},8,["value"])])):M("",!0)]),_:1})]),w("div",Z,[p(y).length?(g(),h(U,{key:0,options:p(k)},null,8,["options"])):(g(),h(r,{key:1}))])]),_:1},8,["spinning"])}}});export{oe as _};
