Buckets:

download
raw
6.18 kB
import{p as at}from"./Bg0DCbuN.js";import{a3 as T,W as G,bh as nt,g as rt,e as it,f as ot,j as st,z as lt,y as ct,_ as g,m as B,k as ut,O as dt,R as gt,ad as ht,n as pt,A as ft,P as mt}from"./BtE7mKSK.js";import{p as vt}from"./BclYD8g8.js";import{d as q}from"./Cw8S2xMX.js";import{o as xt}from"./CmKTTxBW.js";function yt(t,r){return r<t?-1:r>t?1:r>=t?0:NaN}function St(t){return t}function wt(){var t=St,r=yt,S=null,b=T(0),l=T(G),h=T(0);function i(e){var n,s=(e=nt(e)).length,p,w,$=0,f=new Array(s),o=new Array(s),D=+b.apply(this,arguments),E=Math.min(G,Math.max(-G,l.apply(this,arguments)-D)),k,W=Math.min(Math.abs(E)/s,h.apply(this,arguments)),u=W*(E<0?-1:1),A;for(n=0;n<s;++n)(A=o[f[n]=n]=+t(e[n],n,e))>0&&($+=A);for(r!=null?f.sort(function(M,m){return r(o[M],o[m])}):S!=null&&f.sort(function(M,m){return S(e[M],e[m])}),n=0,w=$?(E-s*u)/$:0;n<s;++n,D=k)p=f[n],A=o[p],k=D+(A>0?A*w:0)+u,o[p]={data:e[p],index:n,value:A,startAngle:D,endAngle:k,padAngle:W};return o}return i.value=function(e){return arguments.length?(t=typeof e=="function"?e:T(+e),i):t},i.sortValues=function(e){return arguments.length?(r=e,S=null,i):r},i.sort=function(e){return arguments.length?(S=e,r=null,i):S},i.startAngle=function(e){return arguments.length?(b=typeof e=="function"?e:T(+e),i):b},i.endAngle=function(e){return arguments.length?(l=typeof e=="function"?e:T(+e),i):l},i.padAngle=function(e){return arguments.length?(h=typeof e=="function"?e:T(+e),i):h},i}var At=mt.pie,I={sections:new Map,showData:!1},P=I.sections,V=I.showData,Ct=structuredClone(At),$t=g(()=>structuredClone(Ct),"getConfig"),Dt=g(()=>{P=new Map,V=I.showData,ft()},"clear"),Tt=g(({label:t,value:r})=>{if(r<0)throw new Error(`"${t}" has invalid value: ${r}. Negative values are not allowed in pie charts. All slice values must be >= 0.`);P.has(t)||(P.set(t,r),B.debug(`added new section: ${t}, with value: ${r}`))},"addSection"),bt=g(()=>P,"getSections"),kt=g(t=>{V=t},"setShowData"),zt=g(()=>V,"getShowData"),J={getConfig:$t,clear:Dt,setDiagramTitle:ct,getDiagramTitle:lt,setAccTitle:st,getAccTitle:ot,setAccDescription:it,getAccDescription:rt,addSection:Tt,getSections:bt,setShowData:kt,getShowData:zt},Et=g((t,r)=>{at(t,r),r.setShowData(t.showData),t.sections.map(r.addSection)},"populateDb"),Mt={parse:g(async t=>{const r=await vt("pie",t);B.debug(r),Et(r,J)},"parse")},Rt=g(t=>`
.pieCircle{
stroke: ${t.pieStrokeColor};
stroke-width : ${t.pieStrokeWidth};
opacity : ${t.pieOpacity};
}
.pieCircle.highlighted{
scale: 1.05;
opacity: 1;
}
.pieCircle.highlightedOnHover:hover{
transition-duration: 250ms;
scale: 1.05;
opacity: 1;
}
.pieOuterCircle{
stroke: ${t.pieOuterStrokeColor};
stroke-width: ${t.pieOuterStrokeWidth};
fill: none;
}
.pieTitleText {
text-anchor: middle;
font-size: ${t.pieTitleTextSize};
fill: ${t.pieTitleTextColor};
font-family: ${t.fontFamily};
}
.slice {
font-family: ${t.fontFamily};
fill: ${t.pieSectionTextColor};
font-size:${t.pieSectionTextSize};
// fill: white;
}
.legend text {
fill: ${t.pieLegendTextColor};
font-family: ${t.fontFamily};
font-size: ${t.pieLegendTextSize};
}
`,"getStyles"),Wt=Rt,Lt=g(t=>{const r=[...t.values()].reduce((l,h)=>l+h,0),S=[...t.entries()].map(([l,h])=>({label:l,value:h})).filter(l=>l.value/r*100>=1);return wt().value(l=>l.value).sort(null)(S)},"createPieArcs"),Ot=g((t,r,S,b)=>{B.debug(`rendering pie chart
`+t);const l=b.db,h=ut(),i=dt(l.getConfig(),h.pie),e=40,n=18,s=4,p=450,w=p,$=gt(r),f=$.append("g");f.attr("transform","translate("+w/2+","+p/2+")");const{themeVariables:o}=h;let[D]=ht(o.pieOuterStrokeWidth);D??=2;const E=i.legendPosition,k=i.textPosition,W=i.donutHole>0&&i.donutHole<=.9?i.donutHole:0,u=Math.min(w,p)/2-e,A=q().innerRadius(W*u).outerRadius(u),M=q().innerRadius(u*k).outerRadius(u*k),m=f.append("g");m.append("circle").attr("cx",0).attr("cy",0).attr("r",u+D/2).attr("class","pieOuterCircle");const L=l.getSections(),K=Lt(L),Q=[o.pie1,o.pie2,o.pie3,o.pie4,o.pie5,o.pie6,o.pie7,o.pie8,o.pie9,o.pie10,o.pie11,o.pie12];let _=0;L.forEach(a=>{_+=a});const j=K.filter(a=>(a.data.value/_*100).toFixed(0)!=="0"),F=xt(Q).domain([...L.keys()]);m.selectAll("mySlices").data(j).enter().append("path").attr("d",A).attr("fill",a=>F(a.data.label)).attr("class",a=>{let c="pieCircle";return i.highlightSlice==="hover"?c+=" highlightedOnHover":i.highlightSlice===a.data.label&&(c+=" highlighted"),c}),m.selectAll("mySlices").data(j).enter().append("text").text(a=>(a.data.value/_*100).toFixed(0)+"%").attr("transform",a=>"translate("+M.centroid(a)+")").style("text-anchor","middle").attr("class","slice");const Y=f.append("text").text(l.getDiagramTitle()).attr("x",0).attr("y",-400/2).attr("class","pieTitleText"),R=[...L.entries()].map(([a,c])=>({label:a,value:c})),C=f.selectAll(".legend").data(R).enter().append("g").attr("class","legend");C.append("rect").attr("width",n).attr("height",n).style("fill",a=>F(a.label)).style("stroke",a=>F(a.label)),C.append("text").attr("x",n+s).attr("y",n-s).text(a=>l.getShowData()?`${a.label} [${a.value}]`:a.label);const z=Math.max(...C.selectAll("text").nodes().map(a=>a?.getBoundingClientRect().width??0));let O=p,H=w+e;const d=n+s,N=R.length*d;switch(E){case"center":C.attr("transform",(a,c)=>{const v=d*R.length/2,x=-z/2-(n+s),y=c*d-v;return"translate("+x+","+y+")"});break;case"top":O+=N,C.attr("transform",(a,c)=>{const v=u,x=-z/2-(n+s),y=c*d-v;return`translate(${x}, ${y})`}),m.attr("transform",()=>`translate(0, ${N+d})`);break;case"bottom":O+=N,C.attr("transform",(a,c)=>{const v=-u-d,x=-z/2-(n+s),y=c*d-v;return"translate("+x+","+y+")"});break;case"left":H+=n+s+z,C.attr("transform",(a,c)=>{const v=d*R.length/2,x=-u-(n+s),y=c*d-v;return"translate("+x+","+y+")"}),m.attr("transform",()=>`translate(${z+n+s}, 0)`);break;default:H+=n+s+z,C.attr("transform",(a,c)=>{const v=d*R.length/2,x=12*n,y=c*d-v;return"translate("+x+","+y+")"});break}const U=Y.node()?.getBoundingClientRect().width??0,tt=w/2-U/2,et=w/2+U/2,X=Math.min(0,tt),Z=Math.max(H,et)-X;$.attr("viewBox",`${X} 0 ${Z} ${O}`),pt($,O,Z,i.useMaxWidth)},"draw"),Pt={draw:Ot},It={parser:Mt,db:J,renderer:Pt,styles:Wt};export{It as diagram};

Xet Storage Details

Size:
6.18 kB
·
Xet hash:
56311365fa7e1ebfa1deb3583bfbfab37df4355a4f832a20b0aad229b59d6287

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.