2 lines
6.8 KiB
JavaScript
2 lines
6.8 KiB
JavaScript
var e=Object.defineProperty,t=Object.defineProperties,a=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,i=(t,a,n)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[a]=n,s=(e,t)=>{for(var a in t||(t={}))l.call(t,a)&&i(e,a,t[a]);if(n)for(var a of n(t))r.call(t,a)&&i(e,a,t[a]);return e},o=(e,n)=>t(e,a(n));import{A as u,B as c,a as p,C as h,b as m,E as d,G as v,Z as g,I as f,L as y,c as b,P as L,d as x,R as C,e as S,f as E,S as w,g as D,h as O,i as A,j as F,k as P,l as R,m as z,n as T,o as k,p as j,q as I,r as B,s as V,t as q,u as G,v as H,w as M,x as _,y as W,z as J,D as K,F as N,H as Q,J as U,K as X,M as Y,N as Z,O as $,Q as ee,T as te,U as ae,V as ne,W as le,X as re,Y as ie,_ as se}from"./installCanvasRenderer-D-xUkWdX.js";import{L as oe,c as ue,x as ce,y as pe,r as he,o as me,l as de,aP as ve,A as ge,n as fe}from"./index-BoIUJTA2.js";const ye=Object.freeze(Object.defineProperty({__proto__:null,Arc:u,BezierCurve:c,BoundingRect:p,Circle:h,CompoundPath:m,Ellipse:d,Group:v,Image:g,IncrementalDisplayable:f,Line:y,LinearGradient:b,Polygon:L,Polyline:x,RadialGradient:C,Rect:S,Ring:E,Sector:w,Text:D,clipPointsByRect:O,clipRectByRect:A,createIcon:F,extendPath:P,extendShape:R,getShapeClass:z,getTransform:T,initProps:k,makeImage:j,makePath:I,mergePath:B,registerShape:V,resizePath:q,updateProps:G},Symbol.toStringTag,{value:"Module"}));H([M,_,W,J,K,N,Q,U,X,Y,Z,$,ee,te,ae,ne,le,re,ie]);const be=ye,Le=()=>({chartHeight:"16rem",fontSize:13,fontColor:"#999",themeColor:oe("--el-color-primary-light-1"),colors:[oe("--el-color-primary-light-1"),"#4ABEFF","#EDF2FF","#14DEBA","#FFAF20","#FA8A6C","#FFAF20"]}),xe=[50,100,200,350],Ce=[50,100,200];function Se(e={}){const{initOptions:t,initDelay:a=0,threshold:n=.1,autoTheme:l=!0}=e,r=ce(),{isDark:i,menuOpen:u,menuType:c}=pe(r),p=he();let h=null,m=null,d=null,v=null,g=null,f=!1,y=null;const b=()=>{g&&cancelAnimationFrame(g),g=requestAnimationFrame(()=>{T(),g=null})},L=()=>{v&&clearTimeout(v),v=window.setTimeout(()=>{b(),v=null},100)},x=e=>{fe(b),e.forEach(e=>{setTimeout(b,e)})};let C=null,S=null;let E=null;const w=(e,t=1,a)=>s({color:e,width:t},a&&{type:a}),D={axisLine:null,splitLine:null,axisLabel:null,lastDarkValue:i.value},O=()=>{D.axisLine=null,D.splitLine=null,D.axisLabel=null,D.lastDarkValue=i.value},A=()=>{m&&(m.disconnect(),m=null)},F=e=>{h||!p.value||f||(h=se(p.value),C=ge(u,()=>x(xe)),S=ge(c,()=>{fe(b),setTimeout(()=>x(Ce),0)}),l&&(E=ge(i,()=>{P.updateStyle(),h&&!f&&requestAnimationFrame(()=>{if(h&&!f){const e=h.getOption();e&&z(e)}})}))),h&&!f&&(h.setOption(e),d=null)},P={create:()=>{p.value&&!y&&(y=document.createElement("div"),y.style.cssText=`\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n font-size: 12px;\n color: ${i.value?"#555555":"#B3B2B2"};\n background: transparent;\n z-index: 10;\n `,y.innerHTML="<span>暂无数据</span>","relative"!==p.value.style.position&&"absolute"!==p.value.style.position&&(p.value.style.position="relative"),p.value.appendChild(y))},remove:()=>{y&&p.value&&(p.value.removeChild(y),y=null)},updateStyle:()=>{y&&(y.style.color=i.value?"#666":"#999")}},R=(e={},l=!1)=>{if(!p.value||f)return;const r=s(s({},t),e);try{if(l)return h&&h.clear(),void P.create();P.remove(),(e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0&&t.top<window.innerHeight&&t.bottom>0})(p.value)?a>0?setTimeout(()=>F(r),a):F(r):(d=r,!m&&p.value&&(m=new IntersectionObserver(e=>{e.forEach(e=>{e.isIntersecting&&d&&!f&&requestAnimationFrame(()=>{if(!f&&d)try{h||(h=se(e.target));const t=new CustomEvent("chartVisible",{detail:{options:d}});e.target.dispatchEvent(t),d=null,A()}catch(t){}})})},{threshold:n}),m.observe(p.value)))}catch(i){}},z=e=>{if(!f)try{if(!h)return void R(e);h.setOption(e)}catch(t){}},T=()=>{if(h&&!f)try{h.resize()}catch(e){}},k=()=>{if(f=!0,h)try{h.dispose()}catch(e){}finally{h=null}null==C||C(),null==S||S(),C=null,S=null,null==E||E(),E=null,P.remove(),A(),v&&(clearTimeout(v),v=null),g&&(cancelAnimationFrame(g),g=null),O(),d=null};return me(()=>{window.addEventListener("resize",L)}),de(()=>{window.removeEventListener("resize",L)}),ve(()=>{k()}),{isDark:i,chartRef:p,initChart:R,updateChart:z,handleResize:T,destroyChart:k,getChartInstance:()=>h,isChartInitialized:()=>null!==h,emptyStateManager:P,getAxisLineStyle:(e=!0)=>(D.lastDarkValue!==i.value&&O(),D.axisLine||(D.axisLine={show:e,lineStyle:w(i.value?"#444":"#EDEDED")}),D.axisLine),getSplitLineStyle:(e=!0)=>(D.lastDarkValue!==i.value&&O(),D.splitLine||(D.splitLine={show:e,lineStyle:w(i.value?"#444":"#EDEDED",1,"dashed")}),D.splitLine),getAxisLabelStyle:(e=!0)=>{if(D.lastDarkValue!==i.value&&O(),!D.axisLabel){const{fontColor:t,fontSize:a}=Le();D.axisLabel={show:e,color:t,fontSize:a}}return D.axisLabel},getAxisTickStyle:()=>({show:!1}),getAnimationConfig:(e=50,t=1500)=>({animationDelay:t=>t*e+200,animationDuration:e=>t-50*e,animationEasing:"quarticOut"}),getTooltipStyle:(e="axis",t={})=>s({trigger:e,backgroundColor:i.value?"rgba(0, 0, 0, 0.8)":"rgba(255, 255, 255, 0.9)",borderColor:i.value?"#333":"#ddd",borderWidth:1,textStyle:{color:i.value?"#fff":"#333"}},t),getLegendStyle:(e="bottom",t={})=>{const a=s({textStyle:{color:i.value?"#fff":"#333"},itemWidth:12,itemHeight:12,itemGap:20},t);switch(e){case"bottom":return o(s({},a),{bottom:0,left:"center",orient:"horizontal",icon:"roundRect"});case"top":return o(s({},a),{top:0,left:"center",orient:"horizontal",icon:"roundRect"});case"left":return o(s({},a),{left:0,top:"center",orient:"vertical",icon:"roundRect"});case"right":return o(s({},a),{right:0,top:"center",orient:"vertical",icon:"roundRect"});default:return a}},useChartOps:Le,getGridWithLegend:(e,t="bottom",a={})=>{const n=s({top:15,right:15,bottom:8,left:0,containLabel:!0},a);if(!e)return n;switch(t){case"bottom":return o(s({},n),{bottom:40});case"top":return o(s({},n),{top:40});case"left":return o(s({},n),{left:120});case"right":return o(s({},n),{right:120});default:return n}}}}function Ee(e){const{props:t,generateOptions:a,checkEmpty:n,watchSources:l=[],onVisible:r,chartOptions:i={}}=e,u=Se(i),{chartRef:c,initChart:p,isDark:h,emptyStateManager:m}=u,d=ue(()=>!!t.isEmpty||!!n&&n()),v=()=>{fe(()=>{var e;d.value?(u.getChartInstance()&&(null==(e=u.getChartInstance())||e.clear()),m.create()):(m.remove(),p(a()))})},g=()=>{r?r():v()},f=[];return(()=>{if(l.length>0){const e=ge(l,v,{deep:!0});f.push(e)}const e=ge(h,()=>{m.updateStyle(),v()});f.push(e)})(),me(()=>{v(),c.value&&c.value.addEventListener("chartVisible",g)}),de(()=>{c.value&&c.value.removeEventListener("chartVisible",g),f.forEach(e=>e()),f.length=0,m.remove()}),o(s({},u),{isEmpty:d,updateChart:v,handleChartVisible:g})}export{Ee as a,be as g,Le as u};
|