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
7.5 KiB
1 lines
7.5 KiB
import{p as ge,d as he,B as A,s as L,c as R,D as P,t as z,x as U,o as w,b,F as pe,r as ye,n as g,e as C,K as V,g as M,v as ve,Q as we}from"./index-bVOhw2NF.js";function be(e){return{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Undefined]":"undefined","[object Null]":"null","[object Object]":"object"}[Object.prototype.toString.call(e)]}function I(e){const n=be(e);let o;if(n==="array")o=[];else if(n==="object")o={};else return e;if(n==="array")for(let i=0;i<e.length;i++)o.push(I(e[i]));else if(n==="object")for(const i in e)o[i]=I(e[i]);return o}function K(e,n){for(const o in n){if(e[o]&&typeof e[o]=="object"){K(e[o],n[o]);continue}if(typeof n[o]=="object"){e[o]=I(n[o]);continue}e[o]=n[o]}return e}function Ce(e,n,o){let i;function s(){const r=this,a=arguments;function l(){i&&clearTimeout(i)}function c(){e.apply(r,a)}l(),i=setTimeout(c,n)}return s}function ke(e,n){return Ce(e,n)}function Se(e,n,o){const i=L(null),s=P({width:0,height:0});let r=null;function a(l=!0){we().then(()=>{const c=i.value;s.width=c?c.clientWidth:0,s.height=c?c.clientHeight:0,c?(!s.width||!s.height)&&console.warn("fei-datav: Component width or height is 0px, rendering abnormality may occur!"):console.warn("fei-datav: Failed to get dom node, component rendering may be abnormal!"),typeof o=="function"&&l&&o()})}return z([e,n],()=>{r&&r()}),ve(()=>{setTimeout(()=>{a()},500),r=ke(a,100)}),{domRef:i,...A(s),resize:a}}const je=he({name:"EsScrollRankTable",props:{options:{type:Object,default:()=>({})},datasets:{type:[Object,Array],default:()=>[]},element:{type:Object,default:()=>({})}},emits:["mouseover","click"],setup(e){const{rowNum:n,waitTime:o=2e3,color:i,textColor:s,fontSize:r,rankColumnStyle:a,insideColumnStyle:l,carousel:c,unit:k,enableCarousel:T,showRank:H,nameColor:Q,valueColor:q,unitColor:G,showRatio:J,ratioColor:X,rankFormat:Y,ratioSpace:Z,divideInsideColumn:_,fontFamily:ee,fontColor:ne,fontStyle:te,gradientFontColor:oe,dividerWidth:ie,dividerSpace:re,dividerBack:ae,numberColor:le}=A(e.options),se=L([]),O=R(()=>Number.parseInt(e.element.width)||0),B=R(()=>Number.parseInt(e.element.height)||0),D=R(()=>({data:e.datasets.map(u=>({name:u.category,value:u.data1})),rowNum:n.value,waitTime:Number.parseInt(o.value),carousel:c.value,unit:k.value,sort:!0,valueFormatter:null,color:i.value,textColor:s.value,fontSize:r.value}));function N(){S(),de(),fe(),me(),x(!0)}const{domRef:ue,height:ce}=Se(O,B,N),E=L({data:[],rowNum:5,waitTime:2e3,carousel:"single",unit:"",sort:!0,valueFormatter:null,textColor:"#fff",color:"#1370fb",fontSize:13}),t=P({mergedConfig:null,rowsData:[],rows:[],heights:[],avgHeight:0,animationIndex:0,animationHandler:"",updater:0});z(D,()=>{S(),N()},{deep:!0}),U(()=>{S()});function de(){t.mergedConfig=K(I(E.value),D.value||{})}function fe(){let{data:u}=t.mergedConfig;const{rowNum:h,sort:f}=t.mergedConfig;f&&u.sort(({value:d},{value:v})=>d>v?-1:d<v?1:0);const m=u.map(({value:d})=>d),j=Math.min(...m)||0,p=Math.abs(j),$=(Math.max(...m)||0)+p;u=u.map((d,v)=>({...d,ranking:v+1,percent:(d.value+p)/$*100}));const y=u.length;y>h&&y<2*h&&(u=[...u,...u]),u=u.map((d,v)=>({...d,scroll:v})),t.rowsData=u,t.rows=u}function me(u=!1){const{rowNum:h,data:f}=t.mergedConfig,m=ce.value/h;t.avgHeight=m,u||(t.heights=Array.from({length:f.length}).fill(m))}const W=R(()=>t.mergedConfig.carousel==="single");async function x(u=!1){if(!T.value)return;const{waitTime:h,rowNum:f}=t.mergedConfig,m=t.rowsData.length;if(f>=m)return;const{updater:j}=t;if(u&&(await new Promise(y=>setTimeout(y,h)),j!==t.updater))return;const p=W.value?1:f,F=t.rowsData.slice(t.animationIndex);if(F.push(...t.rowsData.slice(0,t.animationIndex)),t.rows=F.slice(0,W.value?f+1:f*2),t.heights=Array.from({length:t.rows.length}).fill(t.avgHeight),await new Promise(y=>setTimeout(y,300)),j!==t.updater)return;t.heights.splice(0,p,...new Array(p).fill(0)),t.animationIndex+=p;const $=t.animationIndex-m;$>=0&&(t.animationIndex=$),t.animationIndex+=p,t.animationHandler=setTimeout(x,h-300)}function S(){t.updater=(t.updater+1)%999999,t.animationHandler&&clearTimeout(t.animationHandler)}return z(()=>D,()=>{S(),t.animationIndex=0,N()},{deep:!0}),U(()=>{S()}),{defaultConfig:E,...A(t),containerWidth:O,containerHeight:B,domRef:ue,color:i,textColor:s,fontSize:r,insideColRefs:se,rankColumnStyle:a,insideColumnStyle:l,carousel:c,unit:k,enableCarousel:T,showRank:H,nameColor:Q,valueColor:q,unitColor:G,showRatio:J,ratioColor:X,rankFormat:Y,ratioSpace:Z,divideInsideColumn:_,dividerWidth:ie,dividerSpace:re,dividerBack:ae,numberColor:le,fontFamily:ee,fontColor:ne,fontStyle:te,gradientFontColor:oe}},computed:{getRowItemStyle:()=>(e,n)=>({height:`${e[n]}px`}),getRankingColumnStyle:()=>e=>{const n=new Function("",e);let o={};const i=n();return i&&typeof i=="object"&&(o={...i}),{...o}},getInsideColumnStyle:()=>(e,n,o)=>{const i=new Function("",o);let s={};const r=i();return r&&typeof r=="object"&&(s={...r}),{width:`${e.percent}%`,background:n,...s}},getValueUnit:()=>(e,n,o,i,s,r,a)=>{const l={};return r&&(r.includes("bold")&&(l.fontWeight="bold"),r.includes("italic")&&(l.fontStyle="italic"),r.includes("underline,line-through")?l.textDecoration="underline line-through":r.includes("line-through,underline")?l.textDecoration="line-through underline":r.includes("underline")?l.textDecoration="underline":r.includes("line-through")&&(l.textDecoration="line-through")),e.valueFormatter?e.valueFormatter(n,o,i):`<span style='color: ${a||o}; font-family: ${s};font-weight: ${l.fontWeight}; font-style: ${l.fontStyle};text-decoration: ${l.textDecoration}'>${n.value}</span><span style='color: ${i}; margin-left: 3px'>${e.unit}</span>`},getRanking:()=>(e,n)=>{if(n==="No.1")return`No.${e.ranking}`;if(n==="1.")return`${e.ranking}.`;if(n==="1.")return`${e.ranking}`},getRatioStyle:()=>(e,n)=>({color:e,flex:`0 0 ${n}%`,textAlign:"left"}),dividerColumnContent:()=>(e,n,o,i,s,r,a)=>{const l=Math.floor(e*(o.percent/100)/(s+r)),c=new Array(l).fill("");let k="";return c.forEach(T=>{const H=`<span style='float: left; display: inline-block; width: ${s}px; height: 100%; background: ${a}; margin-left: ${r}px'></span>`;k+=H}),k}}}),$e=["innerHTML"],Re=["innerHTML"],Ie=["innerHTML"];function Te(e,n,o,i,s,r){return w(),b("div",{ref:"domRef",class:"dv-scroll-ranking-board",style:g({color:e.textColor})},[(w(!0),b(pe,null,ye(e.rows,(a,l)=>(w(),b("div",{key:a.toString()+a.scroll,class:"row-item",style:g(e.getRowItemStyle(e.heights,l))},[C("div",{class:"ranking-info",style:g({fontSize:e.fontSize})},[e.showRank?(w(),b("div",{key:0,class:"rank",style:g({color:e.numberColor||e.color})},V(e.getRanking(a,e.rankFormat)),5)):M("",!0),C("div",{class:"info-name",style:g({color:e.nameColor||e.textColor}),innerHTML:a.name},null,12,$e),e.showRatio?(w(),b("div",{key:1,style:g(e.getRatioStyle(e.ratioColor,e.ratioSpace))},V(`${a.percent.toFixed(2)}%`),5)):M("",!0),C("div",{class:"ranking-value",innerHTML:e.getValueUnit(e.mergedConfig,a,e.valueColor,e.unitColor,e.fontFamily,e.fontStyle,e.gradientFontColor)},null,8,Re)],4),C("div",{class:"ranking-column",style:g(e.getRankingColumnStyle(e.rankColumnStyle))},[C("div",{ref_for:!0,ref:"insideColRefs",class:"inside-column",style:g(e.getInsideColumnStyle(a,e.color,e.insideColumnStyle))},[e.divideInsideColumn?(w(),b("div",{key:0,class:"dividerColumn",innerHTML:e.dividerColumnContent(e.containerWidth,e.containerHeight,a,l,e.dividerWidth,e.dividerSpace,e.dividerBack)},null,8,Ie)):M("",!0),n[0]||(n[0]=C("div",{class:"shine"},null,-1))],4)],4)],4))),128))],4)}const De=ge(je,[["render",Te],["__scopeId","data-v-0f02abfd"]]);export{De as default};
|