物管理前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

1 lines
5.4 KiB

import{i as re,e as X}from"./index-Csvj-veb.js";import{d as v}from"./dayjs.min-tKPc2Ebd.js";import{t as le,c as ie,g as Z,a as ce,x as de,s as fe}from"./utils-BnHQDKCA.js";import{c as ee}from"./cloneDeep-C6NKQlMO.js";import{d as me,Y as pe,t as ue,Q as ge,v as he,p as ye,o as Fe,b as be,k as ve}from"./index-bVOhw2NF.js";import"./_initCloneObject-K-Y0ueWp.js";import"./_baseEach-BwxcRWC6.js";import"./_getTag-BJ2nhJXz.js";import"./get-BuNGRF3A.js";import"./toString-eibgRg41.js";import"./_baseFor-mOzdmxoL.js";function te(t,l,s,x,r){t.legend.icon="rect",t.series.forEach((e,i)=>{e.type="pictorialBar",e.animation=!1,e.symbolSize=["100%","100%"],e.barCategoryGap=50,i===0?e.symbolOffset=[8,0]:i===1&&(e.symbolOffset=[-6,0]),e.barWidth=r,e.data=e.data.map(g=>({value:g,symbol:`image://${x[i].unselected}`}))});const f=()=>{const e=s.getOption();e.series.forEach((i,g)=>{i.data.forEach(m=>{m.symbol=`image://${x[g].unselected}`})}),s.setOption(e,!0)};return s.on("mouseover",e=>{const i=s.getOption(),g=e.dataIndex;i.series.forEach((m,h)=>{m.data.forEach((B,w)=>{g!==w?B.symbol=`image://${x[h].unselected}`:g===w&&(B.symbol=`image://${x[h].selected}`)})}),s.setOption(i,!0)}),s.on("mouseout",()=>{f()}),s.on("gobalout",()=>{f()}),t}const xe=me({name:"EsBarchart3d",components:{},props:{options:{type:Object,default:()=>({})},datasets:{type:[Array,Object,String],default:()=>[]},eventData:{type:[String,Boolean,Number],default:""},element:{type:Object,default:()=>({})}},setup(t){const l=pe(null),s={day:{prev:"昨日",curr:"今日"},month:{prev:"上月",curr:"当月"},year:{prev:"去年",curr:"今年"}},x=(r,f)=>{const{grid:e,title:i,legend:g,tooltip:m,xAxis:h,yAxis:B,codeConfig:w,timeAxisFormatter:b,completeDatas:H,timeCompare:a,dataShowTypes:ae,legendNameType:oe,renderMode:ne,columnsImgs:R,barWidth:W}=f,se=le.bind({timeCompare:a,timeAxisFormatter:b}),I=document.querySelector(`.chart-${t.element.id}`);if(I){l.value||(l.value=re(I,null,{renderer:ne}));const G=r.info,p=Array.isArray(r.values)?r.values:r,P=r.param;if(p&&G&&P){let $=[];H&&($=ie(P,G,p));let y=[],C=[],o=[],E=null;if(p.length>0){const z=Z(p,"thingCode");for(const T in z){const M=Z(z[T],"attrKey"),J=Object.keys(M).length;for(const U in M){let c=M[U];const _=ce(G,T,U,ae,oe,c);if(C.push(_),!E){const F=c[0],d=c[c.length-1];F.ts>d.ts&&(c=c.reverse());const D=v(+F.ts),A=v(+d.ts),O=D.diff(A,"day"),S=D.diff(A,"month");E=de.bind({months:S,days:O,timeAxisFormatter:b,timeCompare:H&&a})}if(H&&$.length>0)if(a){const F=fe($,a),d={},D=F.prev.map((u,q)=>{let n=null;if(a==="day"?n=v(u).format(b||"HH:mm"):a==="month"?n=v(u).format(b||"DD"):a==="year"&&(n=v(u).format(b||"MM")),!o.includes(n)){o.push(n),d[q]=!0;const k=c.find(N=>+N.ts===u);return k&&k.val||0}}),A=F.curr.map((u,q)=>{if(o.length===0){let n=null;if(a==="day"?n=v(u).format(b||"HH:mm"):a==="month"?n=v(u).format(b||"DD"):a==="year"&&(n=v(u).format(b||"MM")),!o.includes(n)){o.push(n);const k=c.find(N=>+N.ts===u);return k&&k.val||0}}else if(d[q]){const n=c.find(k=>+k.ts===u);return n&&n.val||0}});let O="",S="";J>1?(O=`${_}(${s[a].prev})`,S=`${_}(${s[a].curr})`):J===1&&(O=`${s[a].prev}`,S=`${s[a].curr}`),C.push(O),C.push(S),y.push({name:O,type:"bar",stack:t.options.stack?"total":!1,data:D.filter(Boolean)}),y.push({name:S,type:"bar",stack:t.options.stack?"total":!1,data:A.filter(Boolean)})}else{const F=$.map(d=>{o.push(d);const D=c.find(A=>+A.ts===d);return D&&D.val||0});y.push({name:_,type:"bar",stack:t.options.stack?"total":!1,data:F})}else{const F=c.map(d=>(o.push(+d.ts),d.val));y.push({name:_,type:"bar",stack:t.options.stack?"total":!1,data:F})}}}}else C=["测试图例"],o=[1,2,3,4,5,6,7,8],y=[{type:"bar",name:"测试图例",data:[100,80,60,40,20,10,5,0]}];o=[...new Set(o)].sort();const K={...g,data:C.filter(Boolean)},V={...h,axisLabel:{...h.axisLabel,formatter:H&&a?null:E},nameLocation:"end",nameGap:5,nameTextStyle:{color:h.nameColor,verticalAlign:"top",lineHeight:28},data:o},j={grid:e,title:i,tooltip:{...m,formatter:se,borderColor:m.backgroundColor,textStyle:{...m.textStyle,align:"left"}},legend:K,xAxis:V,yAxis:B,series:y};j.color=["#4992FFFF","#7CFFB2FF","#FDDD60FF","#FF6E76FF","#58D9F9FF","#05C091FF"];const Q=te(j,p,l.value,R,W),L=new Function("option","datas","instance","echarts",w)(ee(Q),p,l.value,X);l.value.setOption(L)}else{const $=t.element.dataSource.legendConfig||[{dataField:"data1",legend:"legend1"},{dataField:"data2",legend:"legend2"}],y=[],C=[...new Set(p.map(L=>L.category))],o=[];for(const L of $){const{dataField:z,legend:T}=L;y.push(T),o.push({name:T,type:"bar",stack:t.options.stack?"total":!1,data:p.map(M=>M[z])})}const E={...h,axisLabel:{...h.axisLabel},nameLocation:"end",nameGap:5,nameTextStyle:{color:h.nameColor,verticalAlign:"top",lineHeight:28},data:C},K={...g,data:y.filter(Boolean)},V={grid:e,title:i,tooltip:{...m,borderColor:m.backgroundColor,textStyle:{...m.textStyle,align:"left"}},legend:K,xAxis:E,yAxis:B,series:o};V.color=["#4992FFFF","#7CFFB2FF","#FDDD60FF","#FF6E76FF","#58D9F9FF","#05C091FF"];const j=te(V,p,l.value,R,W),Y=new Function("option","datas","instance","echarts",w)(ee(j),p,l.value,X);l.value.setOption(Y)}}};return ue([()=>t.datasets,()=>t.options],([r,f])=>{r&&ge(()=>{x(r,f)})},{immediate:!0,deep:!0}),he(()=>{const r=new ResizeObserver(()=>{l.value.resize()}),f=document.querySelector(`.chart-${t.element.id}`);f&&r.observe(f)}),{myChart:l}}});function Ce(t,l,s,x,r,f){return Fe(),be("div",{class:ve(`chart-${t.element.id}`),width:"100%",height:"100%"},null,2)}const Me=ye(xe,[["render",Ce]]);export{Me as default};