import{c as e}from"./chunk-4KE642ED-DMtXVwOD.js";import{p as t}from"./treemap-75Q7IDZK-HKTH2UG6-CtK1P-cI.js";import{m as a,K as i,Z as n,j as r,X as l,J as s,Q as o,t as p,h as d,L as c,a6 as g,a8 as h,a9 as u,aa as m,Y as f,l as x,ab as S,u as w}from"./index-Bd_j0xvv.js";import"./chunk-5ZJXQJOJ-BQpwB-Bn.js";var y=w.pie,$={sections:new Map,showData:!1},D=$.sections,T=$.showData,C=structuredClone(y),b={getConfig:a(()=>structuredClone(C),"getConfig"),clear:a(()=>{D=new Map,T=$.showData,x()},"clear"),setDiagramTitle:o,getDiagramTitle:s,setAccTitle:l,getAccTitle:r,setAccDescription:n,getAccDescription:i,addSection:a(({label:e,value:t})=>{D.has(e)||(D.set(e,t),p.debug(`added new section: ${e}, with value: ${t}`))},"addSection"),getSections:a(()=>D,"getSections"),setShowData:a(e=>{T=e},"setShowData"),getShowData:a(()=>T,"getShowData")},k=a((t,a)=>{e(t,a),a.setShowData(t.showData),t.sections.map(a.addSection)},"populateDb"),v={parse:a(async e=>{let a=await t("pie",e);p.debug(a),k(a,b)},"parse")},A=a(e=>`\n  .pieCircle{\n    stroke: ${e.pieStrokeColor};\n    stroke-width : ${e.pieStrokeWidth};\n    opacity : ${e.pieOpacity};\n  }\n  .pieOuterCircle{\n    stroke: ${e.pieOuterStrokeColor};\n    stroke-width: ${e.pieOuterStrokeWidth};\n    fill: none;\n  }\n  .pieTitleText {\n    text-anchor: middle;\n    font-size: ${e.pieTitleTextSize};\n    fill: ${e.pieTitleTextColor};\n    font-family: ${e.fontFamily};\n  }\n  .slice {\n    font-family: ${e.fontFamily};\n    fill: ${e.pieSectionTextColor};\n    font-size:${e.pieSectionTextSize};\n    // fill: white;\n  }\n  .legend text {\n    fill: ${e.pieLegendTextColor};\n    font-family: ${e.fontFamily};\n    font-size: ${e.pieLegendTextSize};\n  }\n`,"getStyles"),O=a(e=>{let t=[...e.entries()].map(e=>({label:e[0],value:e[1]})).sort((e,t)=>t.value-e.value);return S().value(e=>e.value)(t)},"createPieArcs"),z=a((e,t,a,i)=>{p.debug("rendering pie chart\n"+e);let n=i.db,r=d(),l=c(n.getConfig(),r.pie),s=18,o=450,x=o,S=g(t),w=S.append("g");w.attr("transform","translate(225,225)");let{themeVariables:y}=r,[$]=h(y.pieOuterStrokeWidth);$??=2;let D=l.textPosition,T=Math.min(x,o)/2-40,C=u().innerRadius(0).outerRadius(T),b=u().innerRadius(T*D).outerRadius(T*D);w.append("circle").attr("cx",0).attr("cy",0).attr("r",T+$/2).attr("class","pieOuterCircle");let k=n.getSections(),v=O(k),A=[y.pie1,y.pie2,y.pie3,y.pie4,y.pie5,y.pie6,y.pie7,y.pie8,y.pie9,y.pie10,y.pie11,y.pie12],z=m(A);w.selectAll("mySlices").data(v).enter().append("path").attr("d",C).attr("fill",e=>z(e.data.label)).attr("class","pieCircle");let j=0;k.forEach(e=>{j+=e}),w.selectAll("mySlices").data(v).enter().append("text").text(e=>(e.data.value/j*100).toFixed(0)+"%").attr("transform",e=>"translate("+b.centroid(e)+")").style("text-anchor","middle").attr("class","slice"),w.append("text").text(n.getDiagramTitle()).attr("x",0).attr("y",-200).attr("class","pieTitleText");let M=w.selectAll(".legend").data(z.domain()).enter().append("g").attr("class","legend").attr("transform",(e,t)=>"translate(216,"+(22*t-22*z.domain().length/2)+")");M.append("rect").attr("width",s).attr("height",s).style("fill",z).style("stroke",z),M.data(v).append("text").attr("x",22).attr("y",14).text(e=>{let{label:t,value:a}=e.data;return n.getShowData()?`${t} [${a}]`:t});let R=512+Math.max(...M.selectAll("text").nodes().map(e=>e?.getBoundingClientRect().width??0));S.attr("viewBox",`0 0 ${R} 450`),f(S,o,R,l.useMaxWidth)},"draw"),j={parser:v,db:b,renderer:{draw:z},styles:A};export{j as diagram};
//# sourceMappingURL=pieDiagram-F7MUPDZA-CGf9hk6i.js.map
