@orbcharts/plugins-basic 3.0.9 → 3.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -380,7 +380,7 @@ ${h}`}};Qp.renderFn.toString=()=>`(eventData, { styles, utils }) => {
|
|
380
380
|
<g \${hasSeriesLabel ? \`transform="translate(0, \${styles.textSizePx * 2})"\` : ''}>
|
381
381
|
\${datumSvg}
|
382
382
|
</g>\`
|
383
|
-
}`;const o2={startAngle:-Math.PI/2,endAngle:Math.PI/2,radius:.6,size:20,colorType:"label",value:0},Gz="Bubbles",a2=12,Wz={name:Gz,defaultParams:gg,layerIndex:at,validator:(e,{validateColumns:t})=>{const n=t(e,{force:{toBeTypes:["object"]},bubbleLabel:{toBeTypes:["object"]},arcScaleType:{toBe:'"area" | "radius"',test:r=>r==="area"||r==="radius"}});if(e.force){const r=t(e.force,{velocityDecay:{toBeTypes:["number"]},collisionSpacing:{toBeTypes:["number"]},strength:{toBeTypes:["number"]}});if(r.status==="error")return r}if(e.bubbleLabel){const r=t(e.bubbleLabel,{labelFn:{toBeTypes:["Function"]},colorType:{toBeOption:"ColorType"},fillRate:{toBeTypes:["number"]},lineHeight:{toBeTypes:["number"]},maxLineLength:{toBeTypes:["number"]}});if(r.status==="error")return r}return n}};function Vz(e,t){return Qs().velocityDecay(t.force.velocityDecay).force("collision",Ks().radius(n=>n.r+t.force.collisionSpacing)).force("charge",Js().strength(n=>-Math.pow(n.r,2)*t.force.strength)).on("tick",()=>{e.attr("transform",n=>`translate(${n.x},${n.y})`)})}function Yz({selection:e,bubblesData:t,fullParams:n,fullChartParams:r}){const i=e.selectAll("g").data(t,o=>o.id).join(o=>{const a=o.append("g").attr("cursor","pointer").attr("font-size",a2).style("fill","#ffffff").attr("text-anchor","middle");return a.append("circle").attr("class","node").attr("cx",0).attr("cy",0).attr("fill",s=>s.color),a.append("text").style("opacity",.8).attr("pointer-events","none"),a},o=>o,o=>o.remove()).attr("transform",o=>`translate(${o.x},${o.y})`);return i.select("circle").transition().duration(200).attr("r",o=>o.r).attr("fill",o=>o.color),i.each((o,a,s)=>{const l=Y(s[a]),u=o.renderLabel;l.call(Gv,{text:u,radius:o.r*n.bubbleLabel.fillRate,lineHeight:a2*n.bubbleLabel.lineHeight,isBreakAll:u.length<=n.bubbleLabel.maxLineLength?!1:n.bubbleLabel.wordBreakAll}),l.select("text").attr("fill",c=>Se({datum:o,colorType:n.bubbleLabel.colorType,fullChartParams:r}))}),i}function Xz(e){return Ss().on("start",(t,n)=>{t.active||e.alpha(1).restart(),n.fx=n.x,n.fy=n.y}).on("drag",(t,n)=>{t.active||e.alphaTarget(0),n.fx=t.x,n.fy=t.y}).on("end",(t,n)=>{n.fx=null,n.fy=null,e.alpha(1).restart()})}function jz({_simulation:e,fullParams:t,DatumContainerPositionMap:n}){e.force("x",Ky().strength(t.force.strength).x(r=>{let i=n.get(r.id);return i||(i=n.get(Array.from(n.keys())[0])),(i==null?void 0:i.centerX)??null})).force("y",Qy().strength(t.force.strength).y(r=>{let i=n.get(r.id);return i||(i=n.get(Array.from(n.keys())[0])),(i==null?void 0:i.centerY)??null}))}function Uz({bubblesSelection:e,highlightIds:t,fullChartParams:n}){if(e.interrupt("highlight"),!t.length){e.transition("highlight").style("opacity",1);return}e.each((r,i,o)=>{const a=Y(o[i]);t.includes(r.id)?a.style("opacity",1).transition("highlight").ease(ur).duration(500):a.style("opacity",n.styles.unhighlightedOpacity)})}const Hz=ln(Wz)(({selection:e,name:t,observer:n,subject:r})=>{const i=new J;let o;const a=n.fullParams$.pipe(C(i),L(g=>g.arcScaleType),H(),te(1)),s=n.layout$.pipe(C(i),L(g=>Math.min(g.width,g.height)/2),H(),te(1)),l=n.visibleComputedSortedData$.pipe(C(i),L(g=>g.flat().reduce((y,b)=>y+b.value,0)),H(),te(1)),u=O({totalR:s,totalValue:l,scaleType:a}).pipe(C(i),z(async g=>g),L(g=>xn().domain([0,g.totalValue]).range([0,g.totalR]).exponent(g.scaleType==="area"?.5:1)),te(1)),c=a.pipe(C(i),z(g=>on(()=>g==="area",St(1),O({totalR:s,radiusScale:u,visibleComputedSortedData:n.visibleComputedSortedData$}).pipe(z(async y=>y),L(y=>{const b=y.totalR*y.totalR*Math.PI;return Math.sqrt(b/Bc(y.visibleComputedSortedData.flat(),x=>Math.PI*Math.pow(y.radiusScale(x.value),2)))}))))),h=O({visibleComputedSortedData:n.visibleComputedSortedData$,radiusScale:u,scaleFactor:c}).pipe(C(i),z(async g=>g),L(g=>new Map(g.visibleComputedSortedData.flat().map(b=>[b.id,g.radiusScale(b.value??0)*g.scaleFactor*.9]))),te(1)),f=n.DatumContainerPositionMap$.pipe(C(i),Xn(g=>g.size>0),L(g=>new Map(Array.from(g).map(([y,b])=>[y,{x:b.startX+b.width*Math.random(),y:b.startY+b.height*Math.random()}]))),Br(),te(1)),p=O({visibleComputedSortedData:n.visibleComputedSortedData$,DatumRMap:h,DatumInitXYMap:f,fullParams:n.fullParams$}).pipe(C(i),z(async g=>g),L(g=>g.visibleComputedSortedData.flat().map(y=>{const b=y;if(b.x===void 0||b.y===void 0){let x=g.DatumInitXYMap.get(b.id);x||(x=g.DatumInitXYMap.get(Array.from(g.DatumInitXYMap.keys())[0])),b.x=x.x,b.y=x.y}return b.r=g.DatumRMap.get(b.id),b._originR=b.r,b.renderLabel=g.fullParams.bubbleLabel.labelFn(b),b})),te(1)),d=n.fullChartParams$.pipe(C(i),L(g=>g.highlightTarget),H()),m=O({bubblesData:p,fullParams:n.fullParams$,fullChartParams:n.fullChartParams$,DatumContainerPositionMap:n.DatumContainerPositionMap$}).pipe(C(i),z(async g=>g),L(g=>{o&&o.stop();const y=Yz({selection:e,bubblesData:g.bubblesData,fullParams:g.fullParams,fullChartParams:g.fullChartParams});return o=Vz(y,g.fullParams),o.nodes(g.bubblesData),jz({_simulation:o,fullParams:g.fullParams,DatumContainerPositionMap:g.DatumContainerPositionMap}),o.alpha(1).restart(),y}),te(1));return O({bubblesSelection:m,computedData:n.computedData$,SeriesDataMap:n.SeriesDataMap$,highlightTarget:d}).pipe(C(i),z(async g=>g)).subscribe(g=>{g.bubblesSelection.on("mouseover",(y,b)=>{r.event$.next({type:"series",eventName:"mouseover",pluginName:t,highlightTarget:g.highlightTarget,datum:b,series:g.SeriesDataMap.get(b.seriesLabel),seriesIndex:b.seriesIndex,seriesLabel:b.seriesLabel,event:y,data:g.computedData})}).on("mousemove",(y,b)=>{r.event$.next({type:"series",eventName:"mousemove",pluginName:t,highlightTarget:g.highlightTarget,datum:b,series:g.SeriesDataMap.get(b.seriesLabel),seriesIndex:b.seriesIndex,seriesLabel:b.seriesLabel,event:y,data:g.computedData})}).on("mouseout",(y,b)=>{r.event$.next({type:"series",eventName:"mouseout",pluginName:t,highlightTarget:g.highlightTarget,datum:b,series:g.SeriesDataMap.get(b.seriesLabel),seriesIndex:b.seriesIndex,seriesLabel:b.seriesLabel,event:y,data:g.computedData})}).on("click",(y,b)=>{r.event$.next({type:"series",eventName:"click",pluginName:t,highlightTarget:g.highlightTarget,datum:b,series:g.SeriesDataMap.get(b.seriesLabel),seriesIndex:b.seriesIndex,seriesLabel:b.seriesLabel,event:y,data:g.computedData})}).call(Xz(o))}),O({bubblesSelection:m,highlight:n.seriesHighlight$.pipe(L(g=>g.map(y=>y.id))),fullChartParams:n.fullChartParams$}).pipe(C(i),z(async g=>g)).subscribe(g=>{Uz({bubblesSelection:g.bubblesSelection,highlightIds:g.highlight,fullChartParams:g.fullChartParams})}),()=>{i.next(void 0),o&&(o.stop(),o=void 0)}});function qz({selection:e,pluginName:t,visibleComputedSortedData$:n}){const r=q(t,"series");return n.pipe(L(i=>i.map(o=>o[0]?`${o[0].seriesLabel}_${o[0].label}`:"")),H((i,o)=>JSON.stringify(i)===JSON.stringify(o)),L(i=>e.selectAll(`g.${r}`).data(i,o=>o).join(o=>o.append("g").classed(r,!0),o=>o,o=>o.remove())),te(1))}const Gi=({selection:e,pluginName:t,visibleComputedSortedData$:n,seriesContainerPosition$:r})=>{const i=qz({selection:e,pluginName:t,visibleComputedSortedData$:n});return O({seriesCenterSelection:i,seriesContainerPosition:r}).pipe(z(async o=>o),H((o,a)=>o.seriesContainerPosition.length===a.seriesContainerPosition.length)).subscribe(o=>{o.seriesCenterSelection.attr("transform",(a,s)=>{const l=o.seriesContainerPosition[s]??o.seriesContainerPosition[0];return`translate(${l.centerX}, ${l.centerY})`})}),O({seriesCenterSelection:i,seriesContainerPosition:r}).pipe(z(async o=>o)).subscribe(o=>{o.seriesCenterSelection.transition().attr("transform",(a,s)=>{const l=o.seriesContainerPosition[s]??o.seriesContainerPosition[0];return`translate(${l.centerX}, ${l.centerY})`})}),{seriesCenterSelection$:i}},Sa="Indicator",s2=q(Sa,"indicator-g"),l2=q(Sa,"triangle-g"),Zz={name:Sa,defaultParams:o2,layerIndex:ya,validator:(e,{validateColumns:t})=>t(e,{startAngle:{toBeTypes:["number"]},endAngle:{toBeTypes:["number"]},radius:{toBeTypes:["number"]},size:{toBeTypes:["number"]},colorType:{toBeOption:"ColorType"},value:{toBeTypes:["number"]}})};function Kz({containerSelection:e,angle:t,pointerDistance:n,fullParams:r,fullChartParams:i,graphicColor:o}){const a=e.selectAll(`g.${s2}`).data([t]).join(s=>s.append("g").attr("class",s2).attr("transform",`rotate(${r.startAngle/Math.PI*180})`),s=>s,s=>s.remove());a.transition().duration(i.transitionDuration).attr("transform",`rotate(${t})`),a.selectAll(`g.${l2}`).data([n]).join("g").attr("class",l2).attr("transform",`translate(0, -${n})`).selectAll("path").data([r.size]).join("path").attr("d",J$().type(vp).size(s=>Math.sqrt(3)/4*Math.pow(r.size,2))).attr("fill",o)}function Qz(e,t){const n=new J;t.containerSelection.selectAll("g").remove();const r=t.containerVisibleComputedSortedData$.pipe(L(c=>c.reduce((h,f)=>h+(f.value??0),0)),H()),i=O({fullParams:t.fullParams$,containerValueSum:r}).pipe(z(async c=>c),L(({fullParams:c,containerValueSum:h})=>bn().domain([0,h]).range([c.startAngle/Math.PI*180,c.endAngle/Math.PI*180]))),o=t.fullParams$.pipe(L(c=>c.value),H()),a=O({value:o,valueToAngle:i}).pipe(z(async c=>c),L(({value:c,valueToAngle:h})=>h(c)),H()),s=O({fullParams:t.fullParams$,seriesContainerPosition:t.seriesContainerPosition$}).pipe(z(async c=>c),L(({fullParams:c,seriesContainerPosition:h})=>{const{radius:f}=c,{width:p,height:d}=h;return Math.min(p,d)*f/2}),H()),l=O({value:o,containerVisibleComputedSortedData:t.containerVisibleComputedSortedData$}).pipe(z(async c=>c),L(({value:c,containerVisibleComputedSortedData:h})=>{let f=0,p=0;for(let d=0;d<h.length;d++){const m=h[d].value??0;if(p+=m,p>=c){f=d;break}}return f}),H()),u=O({value:o,valueStackedIndex:l,fullParams:t.fullParams$,fullChartParams:t.fullChartParams$}).pipe(z(async c=>c),L(c=>{const f={color:c.fullParams.colorType==="label"?c.fullChartParams.colors[c.fullChartParams.colorScheme].label[c.valueStackedIndex]:"",seriesIndex:0,seriesLabel:"",seq:0};return Se({datum:f,colorType:c.fullParams.colorType,fullChartParams:c.fullChartParams})}),H());return O({fullParams:t.fullParams$,fullChartParams:t.fullChartParams$,angle:a,pointerDistance:s,graphicColor:u}).subscribe(c=>{Kz({containerSelection:t.containerSelection,angle:c.angle,pointerDistance:c.pointerDistance,fullParams:c.fullParams,fullChartParams:c.fullChartParams,graphicColor:c.graphicColor})}),()=>{n.next(void 0)}}const Jz=ln(Zz)(({selection:e,observer:t,subject:n})=>{const r=new J,{seriesCenterSelection$:i}=Gi({selection:e,pluginName:Sa,visibleComputedSortedData$:t.visibleComputedSortedData$,seriesContainerPosition$:t.seriesContainerPosition$}),o=[];return i.pipe(C(r)).subscribe(a=>{o.forEach(s=>s()),a.each((s,l,u)=>{const c=Y(u[l]),h=t.visibleComputedSortedData$.pipe(C(r),L(p=>p[l]??p[0])),f=t.seriesContainerPosition$.pipe(C(r),L(p=>p[l]??p[0]));o[l]=Qz(Sa,{containerSelection:c,containerVisibleComputedSortedData$:h,fullParams$:t.fullParams$,fullChartParams$:t.fullChartParams$,seriesContainerPosition$:f,event$:n.event$})})}),()=>{r.next(void 0)}});function u2({data:e,startAngle:t,endAngle:n}){return k$().startAngle(t).endAngle(n).value(o=>o.value).sort((o,a)=>o.seq-a.seq)(e).map((o,a)=>{let s=o;return s.id=o.data.id,s})}const xg="Pie",eO={name:xg,defaultParams:n2,layerIndex:at,validator:(e,{validateColumns:t})=>t(e,{outerRadius:{toBeTypes:["number"]},innerRadius:{toBeTypes:["number"]},outerRadiusWhileHighlight:{toBeTypes:["number"]},startAngle:{toBeTypes:["number"]},endAngle:{toBeTypes:["number"]},padAngle:{toBeTypes:["number"]},strokeColorType:{toBeTypes:["string"]},strokeWidth:{toBeTypes:["number"]},cornerRadius:{toBeTypes:["number"]}})};function tO({enter:e,exit:t,data:n,lastTweenData:r,fullParams:i}){return!e.size()&&!t.size()?o=>{const a=n.map((s,l)=>{const u=r[l]??{startAngle:0,endAngle:0,value:0};return{...s,startAngle:s.startAngle*o+u.startAngle*(1-o),endAngle:s.endAngle*o+u.endAngle*(1-o),value:s.value*o+u.value*(1-o)}});return $g(a,i.startAngle,i.endAngle,1)}:o=>$g(n,i.startAngle,i.endAngle,o)}function $g(e,t,n,r){return e.map((i,o)=>{const a=t+(i.startAngle-t)*r,s=a+(i.endAngle-i.startAngle)*r;return{...i,startAngle:a,endAngle:s}})}function c2({selection:e,data:t,arc:n,pathClassName:r,fullParams:i,fullChartParams:o}){return e.selectAll("path").data(t,s=>s.id).join("path").classed(r,!0).style("cursor","pointer").attr("fill",(s,l)=>s.data.color).attr("stroke",(s,l)=>Se({datum:s.data,colorType:i.strokeColorType,fullChartParams:o})).attr("stroke-width",i.strokeWidth).attr("d",(s,l)=>n(s))}function nO({pathSelection:e,ids:t,fullChartParams:n,arc:r,arcHighlight:i}){if(e.interrupt("highlight"),!t.length){e.transition("highlight").style("opacity",1).attr("d",o=>r(o));return}e.each((o,a,s)=>{const l=Y(s[a]);t.includes(o.data.id)?l.style("opacity",1).transition("highlight").ease(ur).duration(500).attr("d",u=>i(u)):l.style("opacity",n.styles.unhighlightedOpacity).transition("highlight").attr("d",u=>r(u))})}function rO(e,t){const n=new J,r=q(e,"path");let i=[],o=[];const a=t.seriesContainerPosition$.pipe(C(n),L(f=>f.width<f.height?f.width:f.height),H()),s=new de(f=>{O({containerVisibleComputedSortedData:t.containerVisibleComputedSortedData$,fullParams:t.fullParams$}).pipe(C(n),z(async p=>p)).subscribe(p=>{const d=u2({data:p.containerVisibleComputedSortedData,startAngle:p.fullParams.startAngle,endAngle:p.fullParams.endAngle});f.next(d)})}),l=new de(f=>{O({shorterSideWith:a,fullParams:t.fullParams$}).pipe(C(n),z(async p=>p)).subscribe(p=>{const d=bu({axisWidth:p.shorterSideWith,innerRadius:p.fullParams.innerRadius,outerRadius:p.fullParams.outerRadius,padAngle:p.fullParams.padAngle,cornerRadius:p.fullParams.cornerRadius});f.next(d)})}),u=new de(f=>{O({shorterSideWith:a,fullParams:t.fullParams$}).pipe(C(n),z(async p=>p)).subscribe(p=>{const d=bu({axisWidth:p.shorterSideWith,innerRadius:p.fullParams.innerRadius,outerRadius:p.fullParams.outerRadiusWhileHighlight,padAngle:p.fullParams.padAngle,cornerRadius:p.fullParams.cornerRadius});f.next(d)})}),c=t.fullChartParams$.pipe(C(n),L(f=>f.highlightTarget),H()),h=new de(f=>{O({pieData:s,arc:l,computedData:t.computedData$,fullParams:t.fullParams$,fullChartParams:t.fullChartParams$,highlightTarget:c}).pipe(C(n),z(async p=>p)).subscribe(p=>{t.containerSelection.interrupt("graphicMove");const d=t.containerSelection.selectAll("path").data(p.pieData,b=>b.id),m=d.enter(),g=d.exit(),y=tO({enter:m,exit:g,data:p.pieData,lastTweenData:i,fullParams:p.fullParams});t.containerSelection.transition("graphicMove").duration(p.fullChartParams.transitionDuration).tween("move",(b,x)=>$=>{o=y($),c2({selection:t.containerSelection,data:o,arc:p.arc,pathClassName:r,fullParams:p.fullParams,fullChartParams:p.fullChartParams})}).on("end",(b,x)=>{o=$g(p.pieData,p.fullParams.startAngle,p.fullParams.endAngle,1);const $=c2({selection:t.containerSelection,data:o,arc:p.arc,pathClassName:r,fullParams:p.fullParams,fullChartParams:p.fullChartParams});f.next($),i=Object.assign([],p.pieData),t.event$.next({type:"series",pluginName:e,eventName:"transitionEnd",event:void 0,highlightTarget:p.highlightTarget,datum:null,series:[],seriesIndex:-1,seriesLabel:"",data:p.computedData})})})}).pipe(te(1));return O({pathSelection:h,SeriesDataMap:t.SeriesDataMap$,computedData:t.computedData$,highlightTarget:c}).pipe(C(n),z(async f=>f)).subscribe(f=>{f.pathSelection.on("mouseover",(p,d)=>{p.stopPropagation(),t.event$.next({type:"series",eventName:"mouseover",pluginName:e,highlightTarget:f.highlightTarget,datum:d.data,series:f.SeriesDataMap.get(d.data.seriesLabel),seriesIndex:d.data.seriesIndex,seriesLabel:d.data.seriesLabel,event:p,data:f.computedData})}).on("mousemove",(p,d)=>{p.stopPropagation(),t.event$.next({type:"series",eventName:"mousemove",pluginName:e,highlightTarget:f.highlightTarget,datum:d.data,series:f.SeriesDataMap.get(d.data.seriesLabel),seriesIndex:d.data.seriesIndex,seriesLabel:d.data.seriesLabel,event:p,data:f.computedData})}).on("mouseout",(p,d)=>{p.stopPropagation(),t.event$.next({type:"series",eventName:"mouseout",pluginName:e,highlightTarget:f.highlightTarget,datum:d.data,series:f.SeriesDataMap.get(d.data.seriesLabel),seriesIndex:d.data.seriesIndex,seriesLabel:d.data.seriesLabel,event:p,data:f.computedData})}).on("click",(p,d)=>{p.stopPropagation(),t.event$.next({type:"series",eventName:"click",pluginName:e,highlightTarget:f.highlightTarget,datum:d.data,series:f.SeriesDataMap.get(d.data.seriesLabel),seriesIndex:d.data.seriesIndex,seriesLabel:d.data.seriesLabel,event:p,data:f.computedData})})}),O({pathSelection:h,highlight:t.seriesHighlight$.pipe(L(f=>f.map(p=>p.id))),fullChartParams:t.fullChartParams$,arc:l,arcHighlight:u}).pipe(C(n),z(async f=>f)).subscribe(f=>{nO({pathSelection:f.pathSelection,ids:f.highlight,fullChartParams:f.fullChartParams,arc:f.arc,arcHighlight:f.arcHighlight})}),()=>{n.next(void 0)}}const iO=ln(eO)(({selection:e,name:t,subject:n,observer:r})=>{const i=new J,{seriesCenterSelection$:o}=Gi({selection:e,pluginName:xg,visibleComputedSortedData$:r.visibleComputedSortedData$,seriesContainerPosition$:r.seriesContainerPosition$}),a=[];return o.pipe(C(i)).subscribe(s=>{a.forEach(l=>l()),s.each((l,u,c)=>{const h=Y(c[u]),f=r.visibleComputedSortedData$.pipe(C(i),L(d=>d[u]??d[0])),p=r.seriesContainerPosition$.pipe(C(i),L(d=>d[u]??d[0]));a[u]=rO(xg,{containerSelection:h,computedData$:r.computedData$,containerVisibleComputedSortedData$:f,SeriesDataMap$:r.SeriesDataMap$,fullParams$:r.fullParams$,fullChartParams$:r.fullChartParams$,seriesHighlight$:r.seriesHighlight$,seriesContainerPosition$:p,event$:n.event$})})}),()=>{i.next(void 0),a.forEach(s=>s())}}),Au="PieEventTexts",f2=q(Au,"text"),oO={name:Au,defaultParams:dg,layerIndex:ya,validator:(e,{validateColumns:t})=>t(e,{renderFn:{toBeTypes:["Function"]},textAttrs:{toBeTypes:["object[]"]},textStyles:{toBeTypes:["object[]"]}})};function vg(e,t){const n=e.selectAll(`text.${f2}`).data(t),r=n.enter().append("text").classed(f2,!0),i=n.merge(r);return i.each((o,a,s)=>{const l=Y(s[a]).text(o.text);Object.keys(o.attr).forEach(u=>{l.attr(u,o.attr[u])}),Object.keys(o.style).forEach(u=>{l.style(u,o.style[u])})}),n.exit().remove(),i}function Sg({eventData:e,renderFn:t,textAttrs:n,textStyles:r}){const i=t(e);return(Array.isArray(i)?i:[i]).map((a,s)=>({text:a,attr:n[s],style:r[s]}))}function aO(e,t){const n=new J;let r;const i=t.fullChartParams$.pipe(C(n),L(o=>o.highlightTarget),H());return O({computedData:t.computedData$,fullParams:t.fullParams$,fullChartParams:t.fullChartParams$,highlightTarget:i}).pipe(C(n),z(async o=>o)).subscribe(o=>{t.containerSelection.transition("move").duration(o.fullChartParams.transitionDuration).tween("move",(a,s)=>l=>{const u=Sg({eventData:{type:"series",pluginName:e,eventName:"transitionMove",event:a,tween:l,highlightTarget:o.highlightTarget,data:o.computedData,series:[],seriesIndex:-1,seriesLabel:"",datum:null},renderFn:o.fullParams.renderFn,textAttrs:o.fullParams.textAttrs,textStyles:o.fullParams.textStyles});vg(t.containerSelection,u)}).on("end",(a,s)=>{const l=Sg({eventData:{type:"series",pluginName:e,eventName:"transitionEnd",event:a,tween:1,highlightTarget:o.highlightTarget,data:o.computedData,series:[],seriesIndex:-1,seriesLabel:"",datum:null},renderFn:o.fullParams.renderFn,textAttrs:o.fullParams.textAttrs,textStyles:o.fullParams.textStyles});vg(t.containerSelection,l),r&&r.unsubscribe(),r=t.event$.subscribe(u=>{const c=Sg({eventData:u,renderFn:o.fullParams.renderFn,textAttrs:o.fullParams.textAttrs,textStyles:o.fullParams.textStyles});vg(t.containerSelection,c)})})}),()=>{n.next(void 0)}}const sO=ln(oO)(({selection:e,name:t,observer:n,subject:r})=>{const i=new J,{seriesCenterSelection$:o}=Gi({selection:e,pluginName:Au,visibleComputedSortedData$:n.visibleComputedSortedData$,seriesContainerPosition$:n.seriesContainerPosition$}),a=[];return o.pipe(C(i)).subscribe(s=>{a.forEach(l=>l()),s.each((l,u,c)=>{const h=Y(c[u]),f=n.computedSortedData$.pipe(C(i),L(d=>d[u]??d[0])),p=n.seriesContainerPosition$.pipe(C(i),L(d=>d[u]??d[0]));a[u]=aO(Au,{containerSelection:h,computedData$:n.computedData$,containerComputedSortedData$:f,SeriesDataMap$:n.SeriesDataMap$,fullParams$:n.fullParams$,fullChartParams$:n.fullChartParams$,seriesHighlight$:n.seriesHighlight$,seriesContainerPosition$:p,event$:r.event$})})}),()=>{i.next(void 0),a.forEach(s=>s())}}),Wi="PieLabels",lO=q(Wi,"label-g"),uO=q(Wi,"line-g"),cO=q(Wi,"text"),h2=2,fO={name:Wi,defaultParams:mg,layerIndex:ya,validator:(e,{validateColumns:t})=>t(e,{outerRadius:{toBeTypes:["number"]},outerRadiusWhileHighlight:{toBeTypes:["number"]},startAngle:{toBeTypes:["number"]},endAngle:{toBeTypes:["number"]},labelCentroid:{toBeTypes:["number"]},labelFn:{toBeTypes:["Function"]},labelColorType:{toBeOption:"ColorType"}})};function hO({pieData:e,arc:t,arcMouseover:n,labelCentroid:r,lineStartCentroid:i,fullParams:o}){return e.map((a,s)=>{const[l,u]=t.centroid(a),[c,h]=n.centroid(a),f=o.labelFn(a.data);return{pieDatum:a,arcIndex:s,arcLabels:f.split(`
|
383
|
+
}`;const o2={startAngle:-Math.PI/2,endAngle:Math.PI/2,radius:.6,size:20,colorType:"label",value:0},Gz="Bubbles",a2=12,Wz={name:Gz,defaultParams:gg,layerIndex:at,validator:(e,{validateColumns:t})=>{const n=t(e,{force:{toBeTypes:["object"]},bubbleLabel:{toBeTypes:["object"]},arcScaleType:{toBe:'"area" | "radius"',test:r=>r==="area"||r==="radius"}});if(e.force){const r=t(e.force,{velocityDecay:{toBeTypes:["number"]},collisionSpacing:{toBeTypes:["number"]},strength:{toBeTypes:["number"]}});if(r.status==="error")return r}if(e.bubbleLabel){const r=t(e.bubbleLabel,{labelFn:{toBeTypes:["Function"]},colorType:{toBeOption:"ColorType"},fillRate:{toBeTypes:["number"]},lineHeight:{toBeTypes:["number"]},maxLineLength:{toBeTypes:["number"]}});if(r.status==="error")return r}return n}};function Vz(e,t){return Qs().velocityDecay(t.force.velocityDecay).force("collision",Ks().radius(n=>n.r+t.force.collisionSpacing)).force("charge",Js().strength(n=>-Math.pow(n.r,2)*t.force.strength)).on("tick",()=>{e.attr("transform",n=>`translate(${n.x},${n.y})`)})}function Yz({selection:e,bubblesData:t,fullParams:n,fullChartParams:r}){const i=e.selectAll("g").data(t,o=>o.id).join(o=>{const a=o.append("g").attr("cursor","pointer").attr("font-size",a2).style("fill","#ffffff").attr("text-anchor","middle");return a.append("circle").attr("class","node").attr("cx",0).attr("cy",0).attr("fill",s=>s.color),a.append("text").style("opacity",.8).attr("pointer-events","none"),a},o=>o,o=>o.remove()).attr("transform",o=>`translate(${o.x},${o.y})`);return i.select("circle").transition().duration(200).attr("r",o=>o.r).attr("fill",o=>o.color),i.each((o,a,s)=>{const l=Y(s[a]),u=o.renderLabel;l.call(Gv,{text:u,radius:o.r*n.bubbleLabel.fillRate,lineHeight:a2*n.bubbleLabel.lineHeight,isBreakAll:u.length<=n.bubbleLabel.maxLineLength?!1:n.bubbleLabel.wordBreakAll}),l.select("text").attr("fill",c=>Se({datum:o,colorType:n.bubbleLabel.colorType,fullChartParams:r}))}),i}function Xz(e){return Ss().on("start",(t,n)=>{t.active||e.alpha(1).restart(),n.fx=n.x,n.fy=n.y}).on("drag",(t,n)=>{t.active||e.alphaTarget(0),n.fx=t.x,n.fy=t.y}).on("end",(t,n)=>{n.fx=null,n.fy=null,e.alpha(1).restart()})}function jz({_simulation:e,fullParams:t,DatumContainerPositionMap:n}){e.force("x",Ky().strength(t.force.strength).x(r=>{let i=n.get(r.id);return i||(i=n.get(Array.from(n.keys())[0])),(i==null?void 0:i.centerX)??null})).force("y",Qy().strength(t.force.strength).y(r=>{let i=n.get(r.id);return i||(i=n.get(Array.from(n.keys())[0])),(i==null?void 0:i.centerY)??null}))}function Uz({bubblesSelection:e,highlightIds:t,fullChartParams:n}){if(e.interrupt("highlight"),!t.length){e.transition("highlight").style("opacity",1);return}e.each((r,i,o)=>{const a=Y(o[i]);t.includes(r.id)?a.style("opacity",1).transition("highlight").ease(ur).duration(500):a.style("opacity",n.styles.unhighlightedOpacity)})}const Hz=ln(Wz)(({selection:e,name:t,observer:n,subject:r})=>{const i=new J;let o;const a=n.fullParams$.pipe(C(i),L(g=>g.arcScaleType),H(),te(1)),s=n.layout$.pipe(C(i),L(g=>Math.min(g.width,g.height)/2),H(),te(1)),l=n.visibleComputedSortedData$.pipe(C(i),L(g=>g.flat().reduce((y,b)=>y+b.value,0)),H(),te(1)),u=O({totalR:s,totalValue:l,scaleType:a}).pipe(C(i),z(async g=>g),L(g=>xn().domain([0,g.totalValue]).range([0,g.totalR]).exponent(g.scaleType==="area"?.5:1)),te(1)),c=a.pipe(C(i),z(g=>on(()=>g==="area",St(1),O({totalR:s,radiusScale:u,visibleComputedSortedData:n.visibleComputedSortedData$}).pipe(z(async y=>y),L(y=>{const b=y.totalR*y.totalR*Math.PI;return Math.sqrt(b/Bc(y.visibleComputedSortedData.flat(),x=>Math.PI*Math.pow(y.radiusScale(x.value),2)))}))))),h=O({visibleComputedSortedData:n.visibleComputedSortedData$,radiusScale:u,scaleFactor:c}).pipe(C(i),z(async g=>g),L(g=>new Map(g.visibleComputedSortedData.flat().map(b=>[b.id,g.radiusScale(b.value??0)*g.scaleFactor*.9]))),te(1)),f=n.DatumContainerPositionMap$.pipe(C(i),Xn(g=>g.size>0),L(g=>new Map(Array.from(g).map(([y,b])=>[y,{x:b.startX+b.width*Math.random(),y:b.startY+b.height*Math.random()}]))),Br(),te(1)),p=O({visibleComputedSortedData:n.visibleComputedSortedData$,DatumRMap:h,DatumInitXYMap:f,fullParams:n.fullParams$}).pipe(C(i),z(async g=>g),L(g=>g.visibleComputedSortedData.flat().map(y=>{const b=y;if(b.x===void 0||b.y===void 0){let x=g.DatumInitXYMap.get(b.id);x||(x=g.DatumInitXYMap.get(Array.from(g.DatumInitXYMap.keys())[0])),b.x=x.x,b.y=x.y}return b.r=g.DatumRMap.get(b.id),b._originR=b.r,b.renderLabel=g.fullParams.bubbleLabel.labelFn(b),b})),te(1)),d=n.fullChartParams$.pipe(C(i),L(g=>g.highlightTarget),H()),m=O({bubblesData:p,fullParams:n.fullParams$,fullChartParams:n.fullChartParams$,DatumContainerPositionMap:n.DatumContainerPositionMap$}).pipe(C(i),z(async g=>g),L(g=>{o&&o.stop();const y=Yz({selection:e,bubblesData:g.bubblesData,fullParams:g.fullParams,fullChartParams:g.fullChartParams});return o=Vz(y,g.fullParams),o.nodes(g.bubblesData),jz({_simulation:o,fullParams:g.fullParams,DatumContainerPositionMap:g.DatumContainerPositionMap}),o.alpha(1).restart(),y}),te(1));return O({bubblesSelection:m,computedData:n.computedData$,SeriesDataMap:n.SeriesDataMap$,highlightTarget:d}).pipe(C(i),z(async g=>g)).subscribe(g=>{g.bubblesSelection.on("mouseover",(y,b)=>{r.event$.next({type:"series",eventName:"mouseover",pluginName:t,highlightTarget:g.highlightTarget,datum:b,series:g.SeriesDataMap.get(b.seriesLabel),seriesIndex:b.seriesIndex,seriesLabel:b.seriesLabel,event:y,data:g.computedData})}).on("mousemove",(y,b)=>{r.event$.next({type:"series",eventName:"mousemove",pluginName:t,highlightTarget:g.highlightTarget,datum:b,series:g.SeriesDataMap.get(b.seriesLabel),seriesIndex:b.seriesIndex,seriesLabel:b.seriesLabel,event:y,data:g.computedData})}).on("mouseout",(y,b)=>{r.event$.next({type:"series",eventName:"mouseout",pluginName:t,highlightTarget:g.highlightTarget,datum:b,series:g.SeriesDataMap.get(b.seriesLabel),seriesIndex:b.seriesIndex,seriesLabel:b.seriesLabel,event:y,data:g.computedData})}).on("click",(y,b)=>{r.event$.next({type:"series",eventName:"click",pluginName:t,highlightTarget:g.highlightTarget,datum:b,series:g.SeriesDataMap.get(b.seriesLabel),seriesIndex:b.seriesIndex,seriesLabel:b.seriesLabel,event:y,data:g.computedData})}).call(Xz(o))}),O({bubblesSelection:m,highlight:n.seriesHighlight$.pipe(L(g=>g.map(y=>y.id))),fullChartParams:n.fullChartParams$}).pipe(C(i),z(async g=>g)).subscribe(g=>{Uz({bubblesSelection:g.bubblesSelection,highlightIds:g.highlight,fullChartParams:g.fullChartParams})}),()=>{i.next(void 0),o&&(o.stop(),o=void 0)}});function qz({selection:e,pluginName:t,visibleComputedSortedData$:n}){const r=q(t,"series");return n.pipe(L(i=>i.map(o=>o[0]?`${o[0].seriesLabel}_${o[0].label}`:"")),H((i,o)=>JSON.stringify(i)===JSON.stringify(o)),L(i=>e.selectAll(`g.${r}`).data(i,o=>o).join(o=>o.append("g").classed(r,!0),o=>o,o=>o.remove())),te(1))}const Gi=({selection:e,pluginName:t,visibleComputedSortedData$:n,seriesContainerPosition$:r})=>{const i=qz({selection:e,pluginName:t,visibleComputedSortedData$:n});return O({seriesCenterSelection:i,seriesContainerPosition:r}).pipe(z(async o=>o),H((o,a)=>o.seriesContainerPosition.length===a.seriesContainerPosition.length)).subscribe(o=>{o.seriesCenterSelection.attr("transform",(a,s)=>{const l=o.seriesContainerPosition[s]??o.seriesContainerPosition[0];return`translate(${l.centerX}, ${l.centerY})`})}),O({seriesCenterSelection:i,seriesContainerPosition:r}).pipe(z(async o=>o)).subscribe(o=>{o.seriesCenterSelection.transition().attr("transform",(a,s)=>{const l=o.seriesContainerPosition[s]??o.seriesContainerPosition[0];return`translate(${l.centerX}, ${l.centerY})`})}),{seriesCenterSelection$:i}},Sa="Indicator",s2=q(Sa,"indicator-g"),l2=q(Sa,"triangle-g"),Zz={name:Sa,defaultParams:o2,layerIndex:ya,validator:(e,{validateColumns:t})=>t(e,{startAngle:{toBeTypes:["number"]},endAngle:{toBeTypes:["number"]},radius:{toBeTypes:["number"]},size:{toBeTypes:["number"]},colorType:{toBeOption:"ColorType"},value:{toBeTypes:["number"]}})};function Kz({containerSelection:e,angle:t,pointerDistance:n,fullParams:r,fullChartParams:i,graphicColor:o}){const a=e.selectAll(`g.${s2}`).data([t]).join(s=>s.append("g").attr("class",s2).attr("transform",`rotate(${r.startAngle/Math.PI*180})`),s=>s,s=>s.remove());a.transition().duration(i.transitionDuration).attr("transform",`rotate(${t})`),a.selectAll(`g.${l2}`).data([n]).join("g").attr("class",l2).attr("transform",`translate(0, -${n})`).selectAll("path").data([r.size]).join("path").attr("d",J$().type(vp).size(s=>Math.sqrt(3)/4*Math.pow(r.size,2))).attr("fill",o)}function Qz(e,t){const n=new J;t.containerSelection.selectAll("g").remove();const r=t.containerVisibleComputedSortedData$.pipe(L(c=>c.reduce((h,f)=>h+(f.value??0),0)),H()),i=O({fullParams:t.fullParams$,containerValueSum:r}).pipe(z(async c=>c),L(({fullParams:c,containerValueSum:h})=>bn().domain([0,h]).range([c.startAngle/Math.PI*180,c.endAngle/Math.PI*180]))),o=t.fullParams$.pipe(L(c=>c.value),H()),a=O({value:o,valueToAngle:i,containerValueSum:r}).pipe(z(async c=>c),L(({value:c,valueToAngle:h,containerValueSum:f})=>{const p=Math.max(Math.min(c,f),0);return h(p)}),H()),s=O({fullParams:t.fullParams$,seriesContainerPosition:t.seriesContainerPosition$}).pipe(z(async c=>c),L(({fullParams:c,seriesContainerPosition:h})=>{const{radius:f}=c,{width:p,height:d}=h;return Math.min(p,d)*f/2}),H()),l=O({value:o,containerVisibleComputedSortedData:t.containerVisibleComputedSortedData$}).pipe(z(async c=>c),L(({value:c,containerVisibleComputedSortedData:h})=>{let f=0,p=0;for(let d=0;d<h.length;d++){const m=h[d].value??0;if(p+=m,p>=c){f=h[d].seriesIndex;break}d===h.length-1&&(f=h[d].seriesIndex)}return f}),H()),u=O({value:o,valueSeriesIndex:l,fullParams:t.fullParams$,fullChartParams:t.fullChartParams$}).pipe(z(async c=>c),L(c=>{const f={color:c.fullParams.colorType==="label"?c.fullChartParams.colors[c.fullChartParams.colorScheme].label[c.valueSeriesIndex]:"",seriesIndex:0,seriesLabel:"",seq:0};return Se({datum:f,colorType:c.fullParams.colorType,fullChartParams:c.fullChartParams})}),H());return O({fullParams:t.fullParams$,fullChartParams:t.fullChartParams$,angle:a,pointerDistance:s,graphicColor:u}).subscribe(c=>{Kz({containerSelection:t.containerSelection,angle:c.angle,pointerDistance:c.pointerDistance,fullParams:c.fullParams,fullChartParams:c.fullChartParams,graphicColor:c.graphicColor})}),()=>{n.next(void 0)}}const Jz=ln(Zz)(({selection:e,observer:t,subject:n})=>{const r=new J,{seriesCenterSelection$:i}=Gi({selection:e,pluginName:Sa,visibleComputedSortedData$:t.visibleComputedSortedData$,seriesContainerPosition$:t.seriesContainerPosition$}),o=[];return i.pipe(C(r)).subscribe(a=>{o.forEach(s=>s()),a.each((s,l,u)=>{const c=Y(u[l]),h=t.visibleComputedSortedData$.pipe(C(r),L(p=>p[l]??p[0])),f=t.seriesContainerPosition$.pipe(C(r),L(p=>p[l]??p[0]));o[l]=Qz(Sa,{containerSelection:c,containerVisibleComputedSortedData$:h,fullParams$:t.fullParams$,fullChartParams$:t.fullChartParams$,seriesContainerPosition$:f,event$:n.event$})})}),()=>{r.next(void 0)}});function u2({data:e,startAngle:t,endAngle:n}){return k$().startAngle(t).endAngle(n).value(o=>o.value).sort((o,a)=>o.seq-a.seq)(e).map((o,a)=>{let s=o;return s.id=o.data.id,s})}const xg="Pie",eO={name:xg,defaultParams:n2,layerIndex:at,validator:(e,{validateColumns:t})=>t(e,{outerRadius:{toBeTypes:["number"]},innerRadius:{toBeTypes:["number"]},outerRadiusWhileHighlight:{toBeTypes:["number"]},startAngle:{toBeTypes:["number"]},endAngle:{toBeTypes:["number"]},padAngle:{toBeTypes:["number"]},strokeColorType:{toBeTypes:["string"]},strokeWidth:{toBeTypes:["number"]},cornerRadius:{toBeTypes:["number"]}})};function tO({enter:e,exit:t,data:n,lastTweenData:r,fullParams:i}){return!e.size()&&!t.size()?o=>{const a=n.map((s,l)=>{const u=r[l]??{startAngle:0,endAngle:0,value:0};return{...s,startAngle:s.startAngle*o+u.startAngle*(1-o),endAngle:s.endAngle*o+u.endAngle*(1-o),value:s.value*o+u.value*(1-o)}});return $g(a,i.startAngle,i.endAngle,1)}:o=>$g(n,i.startAngle,i.endAngle,o)}function $g(e,t,n,r){return e.map((i,o)=>{const a=t+(i.startAngle-t)*r,s=a+(i.endAngle-i.startAngle)*r;return{...i,startAngle:a,endAngle:s}})}function c2({selection:e,data:t,arc:n,pathClassName:r,fullParams:i,fullChartParams:o}){return e.selectAll("path").data(t,s=>s.id).join("path").classed(r,!0).style("cursor","pointer").attr("fill",(s,l)=>s.data.color).attr("stroke",(s,l)=>Se({datum:s.data,colorType:i.strokeColorType,fullChartParams:o})).attr("stroke-width",i.strokeWidth).attr("d",(s,l)=>n(s))}function nO({pathSelection:e,ids:t,fullChartParams:n,arc:r,arcHighlight:i}){if(e.interrupt("highlight"),!t.length){e.transition("highlight").style("opacity",1).attr("d",o=>r(o));return}e.each((o,a,s)=>{const l=Y(s[a]);t.includes(o.data.id)?l.style("opacity",1).transition("highlight").ease(ur).duration(500).attr("d",u=>i(u)):l.style("opacity",n.styles.unhighlightedOpacity).transition("highlight").attr("d",u=>r(u))})}function rO(e,t){const n=new J,r=q(e,"path");let i=[],o=[];const a=t.seriesContainerPosition$.pipe(C(n),L(f=>f.width<f.height?f.width:f.height),H()),s=new de(f=>{O({containerVisibleComputedSortedData:t.containerVisibleComputedSortedData$,fullParams:t.fullParams$}).pipe(C(n),z(async p=>p)).subscribe(p=>{const d=u2({data:p.containerVisibleComputedSortedData,startAngle:p.fullParams.startAngle,endAngle:p.fullParams.endAngle});f.next(d)})}),l=new de(f=>{O({shorterSideWith:a,fullParams:t.fullParams$}).pipe(C(n),z(async p=>p)).subscribe(p=>{const d=bu({axisWidth:p.shorterSideWith,innerRadius:p.fullParams.innerRadius,outerRadius:p.fullParams.outerRadius,padAngle:p.fullParams.padAngle,cornerRadius:p.fullParams.cornerRadius});f.next(d)})}),u=new de(f=>{O({shorterSideWith:a,fullParams:t.fullParams$}).pipe(C(n),z(async p=>p)).subscribe(p=>{const d=bu({axisWidth:p.shorterSideWith,innerRadius:p.fullParams.innerRadius,outerRadius:p.fullParams.outerRadiusWhileHighlight,padAngle:p.fullParams.padAngle,cornerRadius:p.fullParams.cornerRadius});f.next(d)})}),c=t.fullChartParams$.pipe(C(n),L(f=>f.highlightTarget),H()),h=new de(f=>{O({pieData:s,arc:l,computedData:t.computedData$,fullParams:t.fullParams$,fullChartParams:t.fullChartParams$,highlightTarget:c}).pipe(C(n),z(async p=>p)).subscribe(p=>{t.containerSelection.interrupt("graphicMove");const d=t.containerSelection.selectAll("path").data(p.pieData,b=>b.id),m=d.enter(),g=d.exit(),y=tO({enter:m,exit:g,data:p.pieData,lastTweenData:i,fullParams:p.fullParams});t.containerSelection.transition("graphicMove").duration(p.fullChartParams.transitionDuration).tween("move",(b,x)=>$=>{o=y($),c2({selection:t.containerSelection,data:o,arc:p.arc,pathClassName:r,fullParams:p.fullParams,fullChartParams:p.fullChartParams})}).on("end",(b,x)=>{o=$g(p.pieData,p.fullParams.startAngle,p.fullParams.endAngle,1);const $=c2({selection:t.containerSelection,data:o,arc:p.arc,pathClassName:r,fullParams:p.fullParams,fullChartParams:p.fullChartParams});f.next($),i=Object.assign([],p.pieData),t.event$.next({type:"series",pluginName:e,eventName:"transitionEnd",event:void 0,highlightTarget:p.highlightTarget,datum:null,series:[],seriesIndex:-1,seriesLabel:"",data:p.computedData})})})}).pipe(te(1));return O({pathSelection:h,SeriesDataMap:t.SeriesDataMap$,computedData:t.computedData$,highlightTarget:c}).pipe(C(n),z(async f=>f)).subscribe(f=>{f.pathSelection.on("mouseover",(p,d)=>{p.stopPropagation(),t.event$.next({type:"series",eventName:"mouseover",pluginName:e,highlightTarget:f.highlightTarget,datum:d.data,series:f.SeriesDataMap.get(d.data.seriesLabel),seriesIndex:d.data.seriesIndex,seriesLabel:d.data.seriesLabel,event:p,data:f.computedData})}).on("mousemove",(p,d)=>{p.stopPropagation(),t.event$.next({type:"series",eventName:"mousemove",pluginName:e,highlightTarget:f.highlightTarget,datum:d.data,series:f.SeriesDataMap.get(d.data.seriesLabel),seriesIndex:d.data.seriesIndex,seriesLabel:d.data.seriesLabel,event:p,data:f.computedData})}).on("mouseout",(p,d)=>{p.stopPropagation(),t.event$.next({type:"series",eventName:"mouseout",pluginName:e,highlightTarget:f.highlightTarget,datum:d.data,series:f.SeriesDataMap.get(d.data.seriesLabel),seriesIndex:d.data.seriesIndex,seriesLabel:d.data.seriesLabel,event:p,data:f.computedData})}).on("click",(p,d)=>{p.stopPropagation(),t.event$.next({type:"series",eventName:"click",pluginName:e,highlightTarget:f.highlightTarget,datum:d.data,series:f.SeriesDataMap.get(d.data.seriesLabel),seriesIndex:d.data.seriesIndex,seriesLabel:d.data.seriesLabel,event:p,data:f.computedData})})}),O({pathSelection:h,highlight:t.seriesHighlight$.pipe(L(f=>f.map(p=>p.id))),fullChartParams:t.fullChartParams$,arc:l,arcHighlight:u}).pipe(C(n),z(async f=>f)).subscribe(f=>{nO({pathSelection:f.pathSelection,ids:f.highlight,fullChartParams:f.fullChartParams,arc:f.arc,arcHighlight:f.arcHighlight})}),()=>{n.next(void 0)}}const iO=ln(eO)(({selection:e,name:t,subject:n,observer:r})=>{const i=new J,{seriesCenterSelection$:o}=Gi({selection:e,pluginName:xg,visibleComputedSortedData$:r.visibleComputedSortedData$,seriesContainerPosition$:r.seriesContainerPosition$}),a=[];return o.pipe(C(i)).subscribe(s=>{a.forEach(l=>l()),s.each((l,u,c)=>{const h=Y(c[u]),f=r.visibleComputedSortedData$.pipe(C(i),L(d=>d[u]??d[0])),p=r.seriesContainerPosition$.pipe(C(i),L(d=>d[u]??d[0]));a[u]=rO(xg,{containerSelection:h,computedData$:r.computedData$,containerVisibleComputedSortedData$:f,SeriesDataMap$:r.SeriesDataMap$,fullParams$:r.fullParams$,fullChartParams$:r.fullChartParams$,seriesHighlight$:r.seriesHighlight$,seriesContainerPosition$:p,event$:n.event$})})}),()=>{i.next(void 0),a.forEach(s=>s())}}),Au="PieEventTexts",f2=q(Au,"text"),oO={name:Au,defaultParams:dg,layerIndex:ya,validator:(e,{validateColumns:t})=>t(e,{renderFn:{toBeTypes:["Function"]},textAttrs:{toBeTypes:["object[]"]},textStyles:{toBeTypes:["object[]"]}})};function vg(e,t){const n=e.selectAll(`text.${f2}`).data(t),r=n.enter().append("text").classed(f2,!0),i=n.merge(r);return i.each((o,a,s)=>{const l=Y(s[a]).text(o.text);Object.keys(o.attr).forEach(u=>{l.attr(u,o.attr[u])}),Object.keys(o.style).forEach(u=>{l.style(u,o.style[u])})}),n.exit().remove(),i}function Sg({eventData:e,renderFn:t,textAttrs:n,textStyles:r}){const i=t(e);return(Array.isArray(i)?i:[i]).map((a,s)=>({text:a,attr:n[s],style:r[s]}))}function aO(e,t){const n=new J;let r;const i=t.fullChartParams$.pipe(C(n),L(o=>o.highlightTarget),H());return O({computedData:t.computedData$,fullParams:t.fullParams$,fullChartParams:t.fullChartParams$,highlightTarget:i}).pipe(C(n),z(async o=>o)).subscribe(o=>{t.containerSelection.transition("move").duration(o.fullChartParams.transitionDuration).tween("move",(a,s)=>l=>{const u=Sg({eventData:{type:"series",pluginName:e,eventName:"transitionMove",event:a,tween:l,highlightTarget:o.highlightTarget,data:o.computedData,series:[],seriesIndex:-1,seriesLabel:"",datum:null},renderFn:o.fullParams.renderFn,textAttrs:o.fullParams.textAttrs,textStyles:o.fullParams.textStyles});vg(t.containerSelection,u)}).on("end",(a,s)=>{const l=Sg({eventData:{type:"series",pluginName:e,eventName:"transitionEnd",event:a,tween:1,highlightTarget:o.highlightTarget,data:o.computedData,series:[],seriesIndex:-1,seriesLabel:"",datum:null},renderFn:o.fullParams.renderFn,textAttrs:o.fullParams.textAttrs,textStyles:o.fullParams.textStyles});vg(t.containerSelection,l),r&&r.unsubscribe(),r=t.event$.subscribe(u=>{const c=Sg({eventData:u,renderFn:o.fullParams.renderFn,textAttrs:o.fullParams.textAttrs,textStyles:o.fullParams.textStyles});vg(t.containerSelection,c)})})}),()=>{n.next(void 0)}}const sO=ln(oO)(({selection:e,name:t,observer:n,subject:r})=>{const i=new J,{seriesCenterSelection$:o}=Gi({selection:e,pluginName:Au,visibleComputedSortedData$:n.visibleComputedSortedData$,seriesContainerPosition$:n.seriesContainerPosition$}),a=[];return o.pipe(C(i)).subscribe(s=>{a.forEach(l=>l()),s.each((l,u,c)=>{const h=Y(c[u]),f=n.computedSortedData$.pipe(C(i),L(d=>d[u]??d[0])),p=n.seriesContainerPosition$.pipe(C(i),L(d=>d[u]??d[0]));a[u]=aO(Au,{containerSelection:h,computedData$:n.computedData$,containerComputedSortedData$:f,SeriesDataMap$:n.SeriesDataMap$,fullParams$:n.fullParams$,fullChartParams$:n.fullChartParams$,seriesHighlight$:n.seriesHighlight$,seriesContainerPosition$:p,event$:r.event$})})}),()=>{i.next(void 0),a.forEach(s=>s())}}),Wi="PieLabels",lO=q(Wi,"label-g"),uO=q(Wi,"line-g"),cO=q(Wi,"text"),h2=2,fO={name:Wi,defaultParams:mg,layerIndex:ya,validator:(e,{validateColumns:t})=>t(e,{outerRadius:{toBeTypes:["number"]},outerRadiusWhileHighlight:{toBeTypes:["number"]},startAngle:{toBeTypes:["number"]},endAngle:{toBeTypes:["number"]},labelCentroid:{toBeTypes:["number"]},labelFn:{toBeTypes:["Function"]},labelColorType:{toBeOption:"ColorType"}})};function hO({pieData:e,arc:t,arcMouseover:n,labelCentroid:r,lineStartCentroid:i,fullParams:o}){return e.map((a,s)=>{const[l,u]=t.centroid(a),[c,h]=n.centroid(a),f=o.labelFn(a.data);return{pieDatum:a,arcIndex:s,arcLabels:f.split(`
|
384
384
|
`),lineStartX:l*i,lineStartY:u*i,lineStartMouseoverX:c*i,lineStartMouseoverY:h*i,x:l*r,y:u*r,mouseoverX:c*r,mouseoverY:h*r,textWidth:0,collisionShiftX:0,collisionShiftY:0,quadrant:l>=0&&u<=0?1:l<0&&u<=0?2:l<0&&u>0?3:4}}).filter(a=>a.pieDatum.data.visible)}function pO({labelGSelection:e,data:t,fullParams:n,fullChartParams:r,textSizePx:i}){const o=e.selectAll("text").data(t,a=>a.pieDatum.id).join("text").classed(cO,!0).attr("font-weight","bold").attr("text-anchor",a=>a.quadrant==1||a.quadrant==4?"start":"end").style("dominant-baseline",a=>a.quadrant==1||a.quadrant==2?"auto":"hanging").style("cursor",a=>r.highlightTarget&&r.highlightTarget!="none"?"pointer":"none").attr("font-size",r.styles.textSize).attr("x",0).attr("y",0).attr("fill",(a,s)=>Se({datum:a.pieDatum.data,colorType:n.labelColorType,fullChartParams:r})).each((a,s,l)=>{Wv(Y(l[s]),{textArr:a.arcLabels,textSizePx:i,quadrant:a.quadrant})});return o.transition().attr("transform",a=>"translate("+a.x+","+a.y+")"),o}function gO(e,t,n){const r=e.nodes(),i=n,o=r.map((a,s)=>{const l=a.getBBox(),u=[t[s].x,t[s].y];return{node:a,x:u[0],y:u[1],width:l.width,height:l.height}});for(let a=0;a<o.length;a++){const s=o[a];for(let l=a+1;l<o.length;l++){const u=o[l];t[a].textWidth=s.width;const c=s.x+t[a].collisionShiftX,h=s.y+t[a].collisionShiftY,f=u.x+t[l].collisionShiftX,p=u.y+t[l].collisionShiftY;if(!(c+s.width/2<f-u.width/2||c-s.width/2>f+u.width/2||h+s.height/2<p-u.height/2||h-s.height/2>p+u.height/2)){if(t[l].quadrant==2){const d=p>h?-i*2:-i;t[l].collisionShiftY+=d}else if(t[l].quadrant==4){const d=p>h?i:i*2;t[l].collisionShiftY+=d}}}}for(let a=o.length-1;a>=0;a--){const s=o[a];for(let l=a-1;l>=0;l--){const u=o[l];t[a].textWidth=s.width;const c=s.x+t[a].collisionShiftX,h=s.y+t[a].collisionShiftY,f=u.x+t[l].collisionShiftX,p=u.y+t[l].collisionShiftY;if(!(c+s.width/2<f-u.width/2||c-s.width/2>f+u.width/2||h+s.height/2<p-u.height/2||h-s.height/2>p+u.height/2)){if(t[l].quadrant==1){const d=p>h?-i*2:-i;t[l].collisionShiftY+=d}else if(t[l].quadrant==3){const d=p>h?i:i*2;t[l].collisionShiftY+=d}}}}e.data(t).transition().attr("transform",a=>`translate(${a.x+a.collisionShiftX},${a.y+a.collisionShiftY})`)}function dO({lineGSelection:e,data:t,fullParams:n,fullChartParams:r}){const i=t.filter(a=>a.collisionShiftX||a.collisionShiftY),o=e.selectAll("polyline").data(i,a=>a.pieDatum.id).join("polyline").attr("stroke",a=>Se({datum:a.pieDatum.data,colorType:n.labelColorType,fullChartParams:r})).attr("stroke-width",1).attr("fill","none").attr("points",a=>[[a.lineStartX,a.lineStartY],[a.lineStartX,a.lineStartY]]);return o.transition().attr("points",a=>{let s=a.x+a.collisionShiftX,l=a.y+a.collisionShiftY;return[[s,l],[a.lineStartX,a.lineStartY]]}),o}function mO({textSelection:e,lineSelection:t,ids:n,fullChartParams:r}){if(e.interrupt("highlight"),t.interrupt("highlight"),!n.length){e.transition("highlight").duration(200).attr("transform",i=>`translate(${i.x+i.collisionShiftX},${i.y+i.collisionShiftY})`).style("opacity",1),t.transition("highlight").duration(200).style("opacity",1);return}e.each((i,o,a)=>{const s=Y(a[o]);n.includes(i.pieDatum.id)?s.style("opacity",1).transition("highlight").duration(200).attr("transform",l=>l.collisionShiftX||l.collisionShiftY?`translate(${l.x+l.collisionShiftX},${l.y+l.collisionShiftY})`:`translate(${l.mouseoverX+l.collisionShiftX},${l.mouseoverY+l.collisionShiftY})`):s.style("opacity",r.styles.unhighlightedOpacity).transition("highlight").duration(200).attr("transform",l=>`translate(${l.x+l.collisionShiftX},${l.y+l.collisionShiftY})`)}),t.each((i,o,a)=>{const s=Y(a[o]);n.includes(i.pieDatum.data.id)?s.style("opacity",1).transition("highlight").duration(200):s.style("opacity",r.styles.unhighlightedOpacity).transition("highlight").duration(200)})}function yO(e,t){const n=new J;t.containerSelection.selectAll("g").remove();const r=t.containerSelection.append("g");r.classed(uO,!0);const i=t.containerSelection.append("g");i.classed(lO,!0);const o=new J,a=new J;let s=[];const l=t.seriesContainerPosition$.pipe(C(n),L(c=>c.width<c.height?c.width:c.height),H()),u=t.fullParams$.pipe(C(n),L(c=>c.labelCentroid>=h2?h2:c.labelCentroid));return O({shorterSideWith:l,containerVisibleComputedSortedData:t.containerVisibleComputedSortedData$,fullParams:t.fullParams$,fullChartParams:t.fullChartParams$,textSizePx:t.textSizePx$,lineStartCentroid:u}).pipe(C(n),z(async c=>c)).subscribe(c=>{const h=bu({axisWidth:c.shorterSideWith,innerRadius:0,outerRadius:c.fullParams.outerRadius,padAngle:0,cornerRadius:0}),f=bu({axisWidth:c.shorterSideWith,innerRadius:0,outerRadius:c.fullParams.outerRadiusWhileHighlight,padAngle:0,cornerRadius:0}),p=u2({data:c.containerVisibleComputedSortedData,startAngle:c.fullParams.startAngle,endAngle:c.fullParams.endAngle});s=hO({pieData:p,arc:h,arcMouseover:f,labelCentroid:c.fullParams.labelCentroid,lineStartCentroid:c.lineStartCentroid,fullParams:c.fullParams}),r.selectAll("polyline").remove();const d=pO({labelGSelection:i,data:s,fullParams:c.fullParams,fullChartParams:c.fullChartParams,textSizePx:c.textSizePx});setTimeout(()=>{gO(d,s,c.textSizePx);const m=dO({lineGSelection:r,data:s,fullParams:c.fullParams,fullChartParams:c.fullChartParams});a.next(m)},1e3),o.next(d)}),O({textSelection:o,lineSelection:a,highlight:t.seriesHighlight$.pipe(L(c=>c.map(h=>h.id))),fullChartParams:t.fullChartParams$}).pipe(C(n),z(async c=>c)).subscribe(c=>{mO({textSelection:c.textSelection,lineSelection:c.lineSelection,ids:c.highlight,fullChartParams:c.fullChartParams})}),()=>{n.next(void 0)}}const bO=ln(fO)(({selection:e,observer:t,subject:n})=>{const r=new J,{seriesCenterSelection$:i}=Gi({selection:e,pluginName:Wi,visibleComputedSortedData$:t.visibleComputedSortedData$,seriesContainerPosition$:t.seriesContainerPosition$}),o=[];return i.pipe(C(r)).subscribe(a=>{o.forEach(s=>s()),a.each((s,l,u)=>{const c=Y(u[l]),h=t.visibleComputedSortedData$.pipe(C(r),L(p=>p[l]??p[0])),f=t.seriesContainerPosition$.pipe(C(r),L(p=>p[l]??p[0]));o[l]=yO(Wi,{containerSelection:c,containerVisibleComputedSortedData$:h,fullParams$:t.fullParams$,fullChartParams$:t.fullChartParams$,textSizePx$:t.textSizePx$,seriesHighlight$:t.seriesHighlight$,seriesContainerPosition$:f,event$:n.event$})})}),()=>{r.next(void 0)}}),Tg="Rose",xO=Math.PI*2,$O={name:Tg,defaultParams:r2,layerIndex:at,validator:(e,{validateColumns:t})=>t(e,{outerRadius:{toBeTypes:["number"]},padAngle:{toBeTypes:["number"]},strokeColorType:{toBeOption:"ColorType"},strokeWidth:{toBeTypes:["number"]},cornerRadius:{toBeTypes:["number"]},arcScaleType:{toBe:'"area" | "radius"',test:r=>r==="area"||r==="radius"},angleIncreaseWhileHighlight:{toBeTypes:["number"]}})};function vO({cornerRadius:e,outerRadius:t,axisWidth:n,maxValue:r,arcScaleType:i,fullParams:o}){const a=n/2*t,s=i==="area"?.5:1,l=xn().domain([0,r]).range([0,a]).exponent(s);return u=>{const c=l(u.prevValue),h=l(u.value),f=un(c,h);return p=>{const d=f(p);return au().innerRadius(0).outerRadius(d).padAngle(o.padAngle).padRadius(d).cornerRadius(e)(u)}}}function SO({pathSelection:e,ids:t,fullParams:n,fullChartParams:r,tweenArc:i}){if(e.interrupt("highlight"),!t.length){e.transition("highlight").style("opacity",1).attr("d",o=>i(o)(1));return}e.each((o,a,s)=>{const l=Y(s[a]);t.includes(o.data.id)?l.style("opacity",1).transition("highlight").ease(ur).duration(500).attr("d",u=>i({...u,startAngle:u.startAngle-n.angleIncreaseWhileHighlight,endAngle:u.endAngle+n.angleIncreaseWhileHighlight})(1)):l.style("opacity",r.styles.unhighlightedOpacity).transition("highlight").attr("d",u=>i(u)(1))})}function TO(e,t){const n=new J,r=q(e,"path");let i=[];const o=t.seriesContainerPosition$.pipe(C(n),L(p=>p.width<p.height?p.width:p.height),H()),a=O({containerVisibleComputedSortedData:t.containerVisibleComputedSortedData$,fullParams:t.fullParams$}).pipe(C(n),z(async p=>p),L(p=>{const d=xO/p.containerVisibleComputedSortedData.length;return p.containerVisibleComputedSortedData.map((m,g)=>({id:m.id,data:m,index:g,value:m.value,startAngle:d*g,endAngle:d*(g+1),padAngle:p.fullParams.padAngle,prevValue:i[g]&&i[g].id===m.id?i[g].value:0}))})),s=t.fullChartParams$.pipe(C(n),L(p=>p.highlightTarget),H()),l=t.visibleComputedSortedData$.pipe(L(p=>Math.max(...p.flat().map(d=>d.value))),H()),u=O({fullParams:t.fullParams$,axisWidth:o,maxValue:l}).pipe(C(n),z(async p=>p),L(p=>vO({cornerRadius:p.fullParams.cornerRadius,outerRadius:p.fullParams.outerRadius,axisWidth:p.axisWidth,maxValue:p.maxValue,arcScaleType:p.fullParams.arcScaleType,fullParams:p.fullParams}))),c=t.fullChartParams$.pipe(C(n),L(p=>p.transitionDuration),H()),h=new Bu(!1),f=new de(p=>{O({pieData:a,tweenArc:u,transitionDuration:c,fullParams:t.fullParams$,fullChartParams:t.fullChartParams$}).pipe(C(n),z(async d=>d)).subscribe(d=>{const m=d.pieData.map((y,b)=>(y.prevValue=i[b]&&i[b].id===y.id?i[b].value:0,y));h.next(!0);const g=t.containerSelection.selectAll("path").data(m,y=>y.id).join("path").classed(r,!0).style("cursor","pointer").attr("fill",(y,b)=>y.data.color).attr("stroke",(y,b)=>Se({datum:y.data,colorType:d.fullParams.strokeColorType,fullChartParams:d.fullChartParams})).attr("stroke-width",d.fullParams.strokeWidth);g.interrupt("graphicMove"),g.transition("graphicMove").duration(d.transitionDuration).attrTween("d",d.tweenArc).on("end",()=>{p.next(g),h.next(!1)}),i=Object.assign([],m)})}).pipe(te(1));return O({pathSelection:f,SeriesDataMap:t.SeriesDataMap$,computedData:t.computedData$,highlightTarget:s}).pipe(C(n),z(async p=>p)).subscribe(p=>{p.pathSelection.on("mouseover",(d,m)=>{d.stopPropagation(),t.event$.next({type:"series",eventName:"mouseover",pluginName:e,highlightTarget:p.highlightTarget,datum:m.data,series:p.SeriesDataMap.get(m.data.seriesLabel),seriesIndex:m.data.seriesIndex,seriesLabel:m.data.seriesLabel,event:d,data:p.computedData})}).on("mousemove",(d,m)=>{d.stopPropagation(),t.event$.next({type:"series",eventName:"mousemove",pluginName:e,highlightTarget:p.highlightTarget,datum:m.data,series:p.SeriesDataMap.get(m.data.seriesLabel),seriesIndex:m.data.seriesIndex,seriesLabel:m.data.seriesLabel,event:d,data:p.computedData})}).on("mouseout",(d,m)=>{d.stopPropagation(),t.event$.next({type:"series",eventName:"mouseout",pluginName:e,highlightTarget:p.highlightTarget,datum:m.data,series:p.SeriesDataMap.get(m.data.seriesLabel),seriesIndex:m.data.seriesIndex,seriesLabel:m.data.seriesLabel,event:d,data:p.computedData})}).on("click",(d,m)=>{d.stopPropagation(),t.event$.next({type:"series",eventName:"click",pluginName:e,highlightTarget:p.highlightTarget,datum:m.data,series:p.SeriesDataMap.get(m.data.seriesLabel),seriesIndex:m.data.seriesIndex,seriesLabel:m.data.seriesLabel,event:d,data:p.computedData})})}),O({pathSelection:f,highlight:t.seriesHighlight$.pipe(L(p=>p.map(d=>d.id))),fullParams:t.fullParams$,fullChartParams:t.fullChartParams$,tweenArc:u,isTransitionMoving:h}).pipe(C(n),z(async p=>p),Xn(p=>!p.isTransitionMoving)).subscribe(p=>{SO({pathSelection:p.pathSelection,ids:p.highlight,fullParams:p.fullParams,fullChartParams:p.fullChartParams,tweenArc:p.tweenArc})}),()=>{n.next(void 0)}}const _O=ln($O)(({selection:e,name:t,subject:n,observer:r})=>{const i=new J,{seriesCenterSelection$:o}=Gi({selection:e,pluginName:Tg,visibleComputedSortedData$:r.visibleComputedSortedData$,seriesContainerPosition$:r.seriesContainerPosition$}),a=[];return o.pipe(C(i)).subscribe(s=>{a.forEach(l=>l()),s.each((l,u,c)=>{const h=Y(c[u]),f=r.visibleComputedSortedData$.pipe(C(i),L(d=>JSON.parse(JSON.stringify(d[u]??d[0])))),p=r.seriesContainerPosition$.pipe(C(i),L(d=>JSON.parse(JSON.stringify(d[u]??d[0]))));a[u]=TO(Tg,{containerSelection:h,computedData$:r.computedData$,visibleComputedSortedData$:r.visibleComputedSortedData$,containerVisibleComputedSortedData$:f,SeriesDataMap$:r.SeriesDataMap$,fullParams$:r.fullParams$,fullChartParams$:r.fullChartParams$,seriesHighlight$:r.seriesHighlight$,seriesContainerPosition$:p,event$:n.event$})})}),()=>{i.next(void 0),a.forEach(s=>s())}}),Vi="RoseLabels",AO=q(Vi,"label-g"),wO=q(Vi,"line-g"),PO=q(Vi,"text"),p2=2,DO={name:Vi,defaultParams:yg,layerIndex:ya,validator:(e,{validateColumns:t})=>t(e,{outerRadius:{toBeTypes:["number"]},labelCentroid:{toBeTypes:["number"]},labelFn:{toBeTypes:["Function"]},labelColorType:{toBeOption:"ColorType"},arcScaleType:{toBe:'"area" | "radius"',test:r=>r==="area"||r==="radius"}})};function CO({pieData:e,labelCentroid:t,arcScaleType:n,maxValue:r,axisWidth:i,outerRadius:o,lineStartCentroid:a,fullParams:s}){const l=i/2*o,u=n==="area"?.5:1,c=xn().domain([0,r]).range([0,l]).exponent(u);return e.map((h,f)=>{const p=c(h.value),d=au().innerRadius(0).outerRadius(p).padAngle(0).padRadius(p).cornerRadius(0),[m,g]=d.centroid(h),[y,b]=[m,g],x=s.labelFn(h.data);return{pieDatum:h,arcIndex:f,arcLabels:x.split(`
|
385
385
|
`),lineStartX:m*a,lineStartY:g*a,lineStartMouseoverX:y*a,lineStartMouseoverY:b*a,x:m*t,y:g*t,mouseoverX:y*t,mouseoverY:b*t,textWidth:0,collisionShiftX:0,collisionShiftY:0,quadrant:m>=0&&g<=0?1:m<0&&g<=0?2:m<0&&g>0?3:4}}).filter(h=>h.pieDatum.data.visible)}function LO({labelGSelection:e,data:t,fullParams:n,fullChartParams:r,textSizePx:i}){const o=e.selectAll("text").data(t,a=>a.pieDatum.id).join("text").classed(PO,!0).attr("font-weight","bold").attr("text-anchor",a=>a.quadrant==1||a.quadrant==4?"start":"end").style("dominant-baseline",a=>a.quadrant==1||a.quadrant==2?"auto":"hanging").style("cursor",a=>r.highlightTarget&&r.highlightTarget!="none"?"pointer":"none").attr("font-size",r.styles.textSize).attr("fill",(a,s)=>Se({datum:a.pieDatum.data,colorType:n.labelColorType,fullChartParams:r})).each((a,s,l)=>{Wv(Y(l[s]),{textArr:a.arcLabels,textSizePx:i,quadrant:a.quadrant})});return o.transition().attr("transform",a=>"translate("+a.x+","+a.y+")"),o}function MO(e,t,n){const r=e.nodes(),i=n,o=r.map((a,s)=>{const l=a.getBBox(),u=[t[s].x,t[s].y];return{node:a,x:u[0],y:u[1],width:l.width,height:l.height}});for(let a=0;a<o.length;a++){const s=o[a];for(let l=a+1;l<o.length;l++){const u=o[l];t[a].textWidth=s.width;const c=s.x+t[a].collisionShiftX,h=s.y+t[a].collisionShiftY,f=u.x+t[l].collisionShiftX,p=u.y+t[l].collisionShiftY;if(!(c+s.width/2<f-u.width/2||c-s.width/2>f+u.width/2||h+s.height/2<p-u.height/2||h-s.height/2>p+u.height/2)){if(t[l].quadrant==2){const d=p>h?-i*2:-i;t[l].collisionShiftY+=d}else if(t[l].quadrant==4){const d=p>h?i:i*2;t[l].collisionShiftY+=d}}}}for(let a=o.length-1;a>=0;a--){const s=o[a];for(let l=a-1;l>=0;l--){const u=o[l];t[a].textWidth=s.width;const c=s.x+t[a].collisionShiftX,h=s.y+t[a].collisionShiftY,f=u.x+t[l].collisionShiftX,p=u.y+t[l].collisionShiftY;if(!(c+s.width/2<f-u.width/2||c-s.width/2>f+u.width/2||h+s.height/2<p-u.height/2||h-s.height/2>p+u.height/2)){if(t[l].quadrant==1){const d=p>h?-i*2:-i;t[l].collisionShiftY+=d}else if(t[l].quadrant==3){const d=p>h?i:i*2;t[l].collisionShiftY+=d}}}}e.data(t).transition().attr("transform",a=>`translate(${a.x+a.collisionShiftX},${a.y+a.collisionShiftY})`)}function kO({lineGSelection:e,data:t,fullParams:n,fullChartParams:r}){const i=t.filter(a=>a.collisionShiftX||a.collisionShiftY),o=e.selectAll("polyline").data(i,a=>a.pieDatum.id).join("polyline").attr("stroke",a=>Se({datum:a.pieDatum.data,colorType:n.labelColorType,fullChartParams:r})).attr("stroke-width",1).attr("fill","none").attr("points",a=>[[a.lineStartX,a.lineStartY],[a.lineStartX,a.lineStartY]]);return o.transition().attr("points",a=>{let s=a.x+a.collisionShiftX,l=a.y+a.collisionShiftY;return[[s,l],[a.lineStartX,a.lineStartY]]}),o}function RO({textSelection:e,lineSelection:t,ids:n,fullChartParams:r}){if(e.interrupt("highlight"),t.interrupt("highlight"),!n.length){e.transition("highlight").duration(200).attr("transform",i=>`translate(${i.x+i.collisionShiftX},${i.y+i.collisionShiftY})`).style("opacity",1),t.transition("highlight").duration(200).style("opacity",1);return}e.each((i,o,a)=>{const s=Y(a[o]);n.includes(i.pieDatum.data.id)?s.style("opacity",1).transition("highlight").duration(200).attr("transform",l=>`translate(${l.mouseoverX+l.collisionShiftX},${l.mouseoverY+l.collisionShiftY})`):s.style("opacity",r.styles.unhighlightedOpacity).transition("highlight").duration(200).attr("transform",l=>`translate(${l.x+l.collisionShiftX},${l.y+l.collisionShiftY})`)}),t.each((i,o,a)=>{const s=Y(a[o]);n.includes(i.pieDatum.data.id)?s.style("opacity",1).transition("highlight").duration(200):s.style("opacity",r.styles.unhighlightedOpacity).transition("highlight").duration(200)})}function IO(e,t){const n=new J;t.containerSelection.selectAll("g").remove();const r=t.containerSelection.append("g");r.classed(wO,!0);const i=t.containerSelection.append("g");i.classed(AO,!0);const o=new J,a=new J;let s=[];const l=t.seriesContainerPosition$.pipe(C(n),L(h=>h.width<h.height?h.width:h.height),H()),u=t.visibleComputedSortedData$.pipe(L(h=>Math.max(...h.flat().map(f=>f.value))),H()),c=t.fullParams$.pipe(C(n),L(h=>h.labelCentroid>=p2?p2:h.labelCentroid));return O({shorterSideWith:l,containerVisibleComputedSortedData:t.containerVisibleComputedSortedData$,maxValue:u,fullParams:t.fullParams$,fullChartParams:t.fullChartParams$,textSizePx:t.textSizePx$,lineStartCentroid:c}).pipe(C(n),z(async h=>h)).subscribe(h=>{const f=Math.PI*2/h.containerVisibleComputedSortedData.length,p=h.containerVisibleComputedSortedData.map((m,g)=>({id:m.id,data:m,index:g,value:m.value,startAngle:f*g,endAngle:f*(g+1),padAngle:0}));s=CO({pieData:p,labelCentroid:h.fullParams.labelCentroid,arcScaleType:h.fullParams.arcScaleType,maxValue:h.maxValue,axisWidth:h.shorterSideWith,outerRadius:h.fullParams.outerRadius,lineStartCentroid:h.lineStartCentroid,fullParams:h.fullParams}),r.selectAll("polyline").remove();const d=LO({labelGSelection:i,data:s,fullParams:h.fullParams,fullChartParams:h.fullChartParams,textSizePx:h.textSizePx});setTimeout(()=>{MO(d,s,h.textSizePx);const m=kO({lineGSelection:r,data:s,fullParams:h.fullParams,fullChartParams:h.fullChartParams});a.next(m)},1e3),o.next(d)}),O({textSelection:o,lineSelection:a,highlight:t.seriesHighlight$.pipe(L(h=>h.map(f=>f.id))),fullChartParams:t.fullChartParams$}).pipe(C(n),z(async h=>h)).subscribe(h=>{RO({textSelection:h.textSelection,lineSelection:h.lineSelection,ids:h.highlight,fullChartParams:h.fullChartParams})}),()=>{n.next(void 0)}}const EO=ln(DO)(({selection:e,observer:t,subject:n})=>{const r=new J,{seriesCenterSelection$:i}=Gi({selection:e,pluginName:Vi,visibleComputedSortedData$:t.visibleComputedSortedData$,seriesContainerPosition$:t.seriesContainerPosition$}),o=[];return i.pipe(C(r)).subscribe(a=>{o.forEach(s=>s()),a.each((s,l,u)=>{const c=Y(u[l]),h=t.visibleComputedSortedData$.pipe(C(r),L(p=>JSON.parse(JSON.stringify(p[l]??p[0])))),f=t.seriesContainerPosition$.pipe(C(r),L(p=>JSON.parse(JSON.stringify(p[l]??p[0]))));o[l]=IO(Vi,{containerSelection:c,visibleComputedSortedData$:t.visibleComputedSortedData$,containerVisibleComputedSortedData$:h,fullParams$:t.fullParams$,fullChartParams$:t.fullChartParams$,textSizePx$:t.textSizePx$,seriesHighlight$:t.seriesHighlight$,seriesContainerPosition$:f,event$:n.event$})})}),()=>{r.next(void 0)}}),g2="SeriesLegend",BO=ln({name:g2,defaultParams:i2,layerIndex:ki,validator:(e,{validateColumns:t})=>t(e,{placement:{toBe:'"top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end"',test:r=>["top","top-start","top-end","bottom","bottom-start","bottom-end","left","left-start","left-end","right","right-start","right-end"].includes(r)},padding:{toBeTypes:["number"]},backgroundFill:{toBeOption:"ColorType"},backgroundStroke:{toBeOption:"ColorType"},gap:{toBeTypes:["number"]},listRectWidth:{toBeTypes:["number"]},listRectHeight:{toBeTypes:["number"]},listRectRadius:{toBeTypes:["number"]},textColorType:{toBeOption:"ColorType"}})})(({selection:e,rootSelection:t,observer:n,subject:r})=>{const i=new J,o=n.SeriesDataMap$.pipe(C(i),L(l=>Array.from(l.keys()))),a=n.fullParams$.pipe(C(i),L(l=>{const u=[{listRectWidth:l.listRectWidth,listRectHeight:l.listRectHeight,listRectRadius:l.listRectRadius}];return{...l,labelList:u}})),s=Ii(g2,{rootSelection:t,legendLabels$:o,fullParams$:a,layout$:n.layout$,fullChartParams$:n.fullChartParams$,textSizePx$:n.textSizePx$});return()=>{i.next(void 0),s()}}),d2="SeriesTooltip",NO=ln({name:d2,defaultParams:bg,layerIndex:Ri,validator:(e,{validateColumns:t})=>t(e,{backgroundColorType:{toBeOption:"ColorType"},backgroundOpacity:{toBeTypes:["number"]},strokeColorType:{toBeOption:"ColorType"},offset:{toBe:"[number, number]",test:r=>Array.isArray(r)&&r.length===2&&typeof r[0]=="number"&&typeof r[1]=="number"},padding:{toBeTypes:["number"]},textColorType:{toBeOption:"ColorType"},renderFn:{toBeTypes:["Function"]}})})(({selection:e,rootSelection:t,name:n,subject:r,observer:i})=>{const o=new J,a=Bi(d2,{rootSelection:t,fullParams$:i.fullParams$,fullChartParams$:i.fullChartParams$,layout$:i.layout$,event$:r.event$});return()=>{o.next(void 0),a()}}),_g={paddingInner:2,paddingOuter:2,labelColorType:"labelContrast",squarifyRatio:1.618034,sort:(e,t)=>t.value-e.value};_g.sort.toString=()=>"(a, b) => b.value - a.value";const m2={placement:"right-end",padding:28,backgroundFill:"none",backgroundStroke:"none",gap:10,listRectWidth:14,listRectHeight:14,listRectRadius:0,textColorType:"primary"},Ag={backgroundColorType:"background",strokeColorType:"primary",backgroundOpacity:.8,textColorType:"primary",offset:[20,5],padding:10,renderFn:(e,{styles:t,utils:n})=>{const r=!!e.categoryLabel,i=!!e.datum.label,o=n.toCurrency(e.datum.value),a=t.textSizePx*.7,s=t.textSizePx/2-a/2,l=r?`<rect width="${a}" height="${a}" x="${s}" y="${s-1}" rx="${a/2}" fill="${e.datum.color}"></rect>
|
386
386
|
<text x="${t.textSizePx*1.5}" font-size="${t.textSizePx}" dominant-baseline="hanging" fill="${t.textColor}">
|
package/package.json
CHANGED
@@ -139,10 +139,13 @@ function createEachGraphic (pluginName: string, context: {
|
|
139
139
|
const angle$ = combineLatest({
|
140
140
|
value: value$,
|
141
141
|
valueToAngle: valueToAngle$,
|
142
|
+
containerValueSum: containerValueSum$,
|
142
143
|
}).pipe(
|
143
144
|
switchMap(async d => d),
|
144
|
-
map(({ value, valueToAngle }) => {
|
145
|
-
|
145
|
+
map(({ value, valueToAngle, containerValueSum }) => {
|
146
|
+
// value 限制在 0 ~ containerValueSum 之間
|
147
|
+
const validValue = Math.max(Math.min(value, containerValueSum), 0)
|
148
|
+
return valueToAngle(validValue)
|
146
149
|
}),
|
147
150
|
distinctUntilChanged()
|
148
151
|
)
|
@@ -162,30 +165,33 @@ function createEachGraphic (pluginName: string, context: {
|
|
162
165
|
)
|
163
166
|
|
164
167
|
// indicator 的 value 對應到 data 區間
|
165
|
-
const
|
168
|
+
const valueSeriesIndex$ = combineLatest({
|
166
169
|
value: value$,
|
167
170
|
containerVisibleComputedSortedData: context.containerVisibleComputedSortedData$,
|
168
171
|
}).pipe(
|
169
172
|
switchMap(async d => d),
|
170
173
|
map(({ value, containerVisibleComputedSortedData }) => {
|
171
|
-
let
|
174
|
+
let seriesIndex = 0
|
172
175
|
let stackedValue = 0
|
173
176
|
for (let i = 0; i < containerVisibleComputedSortedData.length; i++) {
|
174
177
|
const datumValue = containerVisibleComputedSortedData[i].value ?? 0
|
175
178
|
stackedValue += datumValue
|
176
179
|
if (stackedValue >= value) {
|
177
|
-
|
180
|
+
seriesIndex = containerVisibleComputedSortedData[i].seriesIndex
|
178
181
|
break
|
179
182
|
}
|
183
|
+
if (i === containerVisibleComputedSortedData.length - 1) {
|
184
|
+
seriesIndex = containerVisibleComputedSortedData[i].seriesIndex
|
185
|
+
}
|
180
186
|
}
|
181
|
-
return
|
187
|
+
return seriesIndex
|
182
188
|
}),
|
183
189
|
distinctUntilChanged()
|
184
190
|
)
|
185
191
|
|
186
192
|
const graphicColor$ = combineLatest({
|
187
193
|
value: value$,
|
188
|
-
|
194
|
+
valueSeriesIndex: valueSeriesIndex$,
|
189
195
|
// containerVisibleComputedSortedData: context.containerVisibleComputedSortedData$,
|
190
196
|
fullParams: context.fullParams$,
|
191
197
|
fullChartParams: context.fullChartParams$,
|
@@ -193,7 +199,7 @@ function createEachGraphic (pluginName: string, context: {
|
|
193
199
|
switchMap(async d => d),
|
194
200
|
map(data => {
|
195
201
|
const labelColor = data.fullParams.colorType === 'label'
|
196
|
-
? data.fullChartParams.colors[data.fullChartParams.colorScheme].label[data.
|
202
|
+
? data.fullChartParams.colors[data.fullChartParams.colorScheme].label[data.valueSeriesIndex]
|
197
203
|
: '' // 忽略
|
198
204
|
|
199
205
|
const datum: ComputedDatumBaseSeries = {
|