@undp/data-viz 2.1.5 → 2.1.7
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.
- package/dist/DonutChart.cjs +1 -1
- package/dist/DonutChart.cjs.map +1 -1
- package/dist/DonutChart.d.ts +2 -1
- package/dist/DonutChart.js +118 -118
- package/dist/DonutChart.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/package.json +4 -4
package/dist/DonutChart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-CHPV5EwG-CTPQjnHt.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-CHPV5EwG-CTPQjnHt.cjs"),M=require("react"),ot=require("./Typography-DX7PlgQU.cjs"),mt=require("./index-Cno4Q0YE.cjs"),xt=require("./Source-DYMJRrsq.cjs"),pt=require("./index-DQA8q5sC.cjs"),dt=require("./Tooltip-uUdw6wJL.cjs"),W=require("./Colors.cjs"),ct=require("./numberFormattingFunction-02t-wJta.cjs"),gt=require("./DetailsModal-BN0HDFlV.cjs"),F=require("./array-DMyR1sql.cjs"),ht=require("./use-in-view-QcfiW0w3.cjs"),ft=require("./index-DG2bgAva.cjs"),rt=require("./proxy-BxvUI_9l.cjs"),yt=require("./GraphFooter.cjs"),jt=require("./GraphHeader.cjs"),vt=require("./EmptyState-gLDRXBHm.cjs"),it=require("./GraphContainer-d8A46BK2.cjs"),bt=Math.PI,st=2*bt;function Et(c,t){return t<c?-1:t>c?1:t>=c?0:NaN}function Ct(c){return c}function Mt(){var c=Ct,t=Et,n=null,a=F.constant(0),r=F.constant(st),p=F.constant(0);function s(e){var l,f=(e=F.array(e)).length,d,S,m=0,g=new Array(f),v=new Array(f),y=+a.apply(this,arguments),q=Math.min(st,Math.max(-st,r.apply(this,arguments)-y)),x,P=Math.min(Math.abs(q)/f,p.apply(this,arguments)),G=P*(q<0?-1:1),h;for(l=0;l<f;++l)(h=v[g[l]=l]=+c(e[l],l,e))>0&&(m+=h);for(t!=null?g.sort(function(R,A){return t(v[R],v[A])}):n!=null&&g.sort(function(R,A){return n(e[R],e[A])}),l=0,S=m?(q-f*G)/m:0;l<f;++l,y=x)d=g[l],h=v[d],x=y+(h>0?h*S:0)+G,v[d]={data:e[d],index:l,value:h,startAngle:y,endAngle:x,padAngle:P};return v}return s.value=function(e){return arguments.length?(c=typeof e=="function"?e:F.constant(+e),s):c},s.sortValues=function(e){return arguments.length?(t=e,n=null,s):t},s.sort=function(e){return arguments.length?(n=e,t=null,s):n},s.startAngle=function(e){return arguments.length?(a=typeof e=="function"?e:F.constant(+e),s):a},s.endAngle=function(e){return arguments.length?(r=typeof e=="function"?e:F.constant(+e),s):r},s.padAngle=function(e){return arguments.length?(p=typeof e=="function"?e:F.constant(+e),s):p},s}const at=(c,t,n,a)=>({x:c+n*Math.cos(a),y:t+n*Math.sin(a)});function lt(c,t,n,a,r){const p=at(c,t,n,a),s=at(c,t,n,Math.abs(r-a)===2*Math.PI?.999999*r:r),e=r-a<=Math.PI?"0":"1";return["M",p.x,p.y,"A",n,n,0,e,1,s.x,s.y].join(" ")}function Rt(c){const t=o.compilerRuntimeExports.c(59),{mainText:n,data:a,radius:r,colors:p,subNote:s,strokeWidth:e,tooltip:l,onSeriesMouseOver:f,onSeriesMouseClick:d,colorDomain:S,resetSelectionOnDoubleClick:m,detailsOnClick:g,styles:v,classNames:y,precision:q,animate:x,trackColor:P}=c,G=M.useRef(null);let h;t[0]!==x.amount||t[1]!==x.once?(h={once:x.once,amount:x.amount},t[0]=x.amount,t[1]=x.once,t[2]=h):h=t[2];const R=ht.useInView(G,h),A=Mt().sort(null).startAngle(0).value(Dt),[j,X]=M.useState(void 0),[b,E]=M.useState(void 0),[V,Y]=M.useState(void 0),[I,J]=M.useState(void 0),K=rt.motion,Q=`${r*2}px`,U=`${r*2}px`,D=`0 0 ${r*2} ${r*2}`,z="ltr",et="mx-auto",T=rt.motion,Z=`translate(${r} ${r})`;let O;t[3]!==a||t[4]!==n||t[5]!==q||t[6]!==r||t[7]!==e||t[8]!==s?(O=n||s?o.jsxRuntimeExports.jsx("foreignObject",{y:0-(r-e),x:0-(r-e),width:2*(r-e),height:2*(r-e),children:o.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-0.5 justify-center items-center h-inherit py-0 px-4",children:[n?M.isValidElement(n)?n:o.jsxRuntimeExports.jsx(ot.v,{marginBottom:"none",className:"donut-main-text text-primary-gray-700 dark:text-primary-gray-100 leading-none text-center",children:typeof n=="string"?n:a.findIndex(u=>u.label===n.label)!==-1?ct.numberFormattingFunction(a[a.findIndex(u=>u.label===n.label)].size,"NA",q,n.prefix,n.suffix):"NA"}):null,s?o.jsxRuntimeExports.jsx(ot.j,{marginBottom:"none",size:"base",leading:"none",className:"donut-sub-note text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold",children:s}):typeof n=="string"||!n||M.isValidElement(n)?null:o.jsxRuntimeExports.jsx(ot.j,{size:"base",marginBottom:"none",leading:"none",className:"donut-label text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold",children:n.label})]})}):null,t[3]=a,t[4]=n,t[5]=q,t[6]=r,t[7]=e,t[8]=s,t[9]=O):O=t[9];const _=r-e/2;let N;t[10]!==e||t[11]!==_||t[12]!==P?(N=o.jsxRuntimeExports.jsx("circle",{cx:0,cy:0,r:_,fill:"none",stroke:P,strokeWidth:e}),t[10]=e,t[11]=_,t[12]=P,t[13]=N):N=t[13];const $=ft.AnimatePresence;let k;t[14]!==x.duration||t[15]!==S||t[16]!==p||t[17]!==g||t[18]!==R||t[19]!==b||t[20]!==j||t[21]!==d||t[22]!==f||t[23]!==r||t[24]!==m||t[25]!==E||t[26]!==e?(k=(u,ut)=>o.jsxRuntimeExports.jsx(rt.motion.path,{variants:{initial:{pathLength:0,d:lt(0,0,r-e/2,u.startAngle-Math.PI/2,u.endAngle-Math.PI/2),opacity:j?j.label===u.data.label?1:.3:1},whileInView:{pathLength:1,d:lt(0,0,r-e/2,u.startAngle-Math.PI/2,u.endAngle-Math.PI/2),opacity:j?j.label===u.data.label?1:.3:1,transition:{duration:x.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:x.duration}},style:{stroke:S.indexOf(u.data.label)!==-1?p[S.indexOf(u.data.label)%p.length]:W.Colors.gray,strokeWidth:e,fill:"none"},onMouseEnter:tt=>{X(u.data),J(tt.clientY),Y(tt.clientX),f?.(u)},onClick:()=>{(d||g)&&(pt.isEqual(b,u.data)&&m?(E(void 0),d?.(void 0)):(E(u.data),d&&d(u.data)))},onMouseMove:tt=>{X(u.data),J(tt.clientY),Y(tt.clientX)},onMouseLeave:()=>{X(void 0),Y(void 0),J(void 0),f?.(void 0)}},ut),t[14]=x.duration,t[15]=S,t[16]=p,t[17]=g,t[18]=R,t[19]=b,t[20]=j,t[21]=d,t[22]=f,t[23]=r,t[24]=m,t[25]=E,t[26]=e,t[27]=k):k=t[27];const i=A(a).map(k);let C;t[28]!==$||t[29]!==i?(C=o.jsxRuntimeExports.jsx($,{children:i}),t[28]=$,t[29]=i,t[30]=C):C=t[30];let w;t[31]!==N||t[32]!==C||t[33]!==T.g||t[34]!==Z||t[35]!==O?(w=o.jsxRuntimeExports.jsxs(T.g,{transform:Z,children:[O,N,C]}),t[31]=N,t[32]=C,t[33]=T.g,t[34]=Z,t[35]=O,t[36]=w):w=t[36];let B;t[37]!==K.svg||t[38]!==w||t[39]!==Q||t[40]!==U||t[41]!==D?(B=o.jsxRuntimeExports.jsx(K.svg,{ref:G,width:Q,height:U,viewBox:D,direction:z,className:et,children:w}),t[37]=K.svg,t[38]=w,t[39]=Q,t[40]=U,t[41]=D,t[42]=B):B=t[42];let H;t[43]!==y?.tooltip||t[44]!==V||t[45]!==I||t[46]!==j||t[47]!==v?.tooltip||t[48]!==l?(H=j&&l&&V&&I?o.jsxRuntimeExports.jsx(dt.Tooltip,{data:j,body:l,xPos:V,yPos:I,backgroundStyle:v?.tooltip,className:y?.tooltip}):null,t[43]=y?.tooltip,t[44]=V,t[45]=I,t[46]=j,t[47]=v?.tooltip,t[48]=l,t[49]=H):H=t[49];let L;t[50]!==y?.modal||t[51]!==g||t[52]!==b||t[53]!==E?(L=g&&b!==void 0?o.jsxRuntimeExports.jsx(gt.DetailsModal,{body:g,data:b,setData:E,className:y?.modal}):null,t[50]=y?.modal,t[51]=g,t[52]=b,t[53]=E,t[54]=L):L=t[54];let nt;return t[55]!==B||t[56]!==H||t[57]!==L?(nt=o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[B,H,L]}),t[55]=B,t[56]=H,t[57]=L,t[58]=nt):nt=t[58],nt}function Dt(c){return c.size}function Nt(c){const{mainText:t,graphTitle:n,colors:a=W.Colors.light.categoricalColors.colors,suffix:r="",sources:p,prefix:s="",strokeWidth:e=50,graphDescription:l,subNote:f,footNote:d,radius:S,data:m,showColorScale:g=!0,padding:v,backgroundColor:y=!1,tooltip:q,onSeriesMouseOver:x,graphID:P,onSeriesMouseClick:G,graphDownload:h=!1,dataDownload:R=!1,colorDomain:A,sortData:j,language:X="en",theme:b="light",width:E,height:V,minHeight:Y=0,relativeHeight:I,ariaLabel:J,resetSelectionOnDoubleClick:K=!0,colorScaleMaxWidth:Q,detailsOnClick:U,styles:D,classNames:z,precision:et=2,animate:T=!1,trackColor:Z=W.Colors.light.grays["gray-200"]}=c,[O,_]=M.useState(0),N=M.useRef(null),$=M.useRef(null);M.useEffect(()=>{const i=new ResizeObserver(C=>{_((Math.min(C[0].target.clientWidth||620,C[0].target.clientHeight||480)||420)/2)});return N.current&&i.observe(N.current),()=>i.disconnect()},[]);const k=j?mt.orderBy(m,["size"],[j]):m;return o.jsxRuntimeExports.jsxs(it.GraphContainer,{className:z?.graphContainer,style:D?.graphContainer,id:P,ref:$,"aria-label":J,backgroundColor:y,theme:b,language:X,minHeight:Y,width:E,height:V,relativeHeight:I,padding:v,children:[n||l||h||R?o.jsxRuntimeExports.jsx(jt.GraphHeader,{styles:{title:D?.title,description:D?.description},classNames:{title:z?.title,description:z?.description},graphTitle:n,graphDescription:l,width:E,graphDownload:h?$:void 0,dataDownload:R?m.map(i=>i.data).filter(i=>i!==void 0).length>0?m.map(i=>i.data).filter(i=>i!==void 0):m.filter(i=>i!==void 0):null}):null,g&&m.length>0?o.jsxRuntimeExports.jsxs(o.jsxRuntimeExports.Fragment,{children:[o.jsxRuntimeExports.jsx("div",{className:o.mo("leading-0 flex mb-0 ml-auto mr-auto justify-center gap-x-3 gap-y-0 flex-wrap",z?.colorLegend),style:{maxWidth:Q},"aria-label":"Color legend",children:k.map((i,C)=>o.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center pb-3",children:[o.jsxRuntimeExports.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:(A||k.map(w=>w.label)).indexOf(i.label)!==-1?(a||W.Colors[b].categoricalColors.colors)[(A||k.map(w=>w.label)).indexOf(i.label)%(a||W.Colors[b].categoricalColors.colors).length]:W.Colors.gray}}),o.jsxRuntimeExports.jsxs(ot.j,{marginBottom:"none",size:"sm",className:"text-primary-gray-700 dark:text-primary-gray-100",children:[i.label,":"," ",o.jsxRuntimeExports.jsx("span",{className:"font-bold",style:{fontSize:"inherit"},children:ct.numberFormattingFunction(i.size,"NA",et,s,r)})]})]},C))}),o.jsxRuntimeExports.jsx(xt.n,{size:"lg"})]}):null,o.jsxRuntimeExports.jsxs(it.GraphArea,{ref:N,children:[m.length===0&&o.jsxRuntimeExports.jsx(vt.EmptyState,{}),O&&m.length>0?o.jsxRuntimeExports.jsx(Rt,{mainText:t,data:k,colors:a,radius:S||O,subNote:f,strokeWidth:e,tooltip:q,colorDomain:A||k.map(i=>i.label),onSeriesMouseOver:x,onSeriesMouseClick:G,resetSelectionOnDoubleClick:K,styles:D,detailsOnClick:U,precision:et,animate:T===!0?{duration:.5,once:!0,amount:.5}:T||{duration:0,once:!0,amount:0},trackColor:Z}):null]}),p||d?o.jsxRuntimeExports.jsx(yt.GraphFooter,{styles:{footnote:D?.footnote,source:D?.source},classNames:{footnote:z?.footnote,source:z?.source},sources:p,footNote:d,width:E}):null]})}exports.DonutChart=Nt;
|
|
2
2
|
//# sourceMappingURL=DonutChart.cjs.map
|
package/dist/DonutChart.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonutChart.cjs","sources":["../node_modules/d3-shape/src/math.js","../node_modules/d3-shape/src/descending.js","../node_modules/d3-shape/src/identity.js","../node_modules/d3-shape/src/pie.js","../src/Utils/getArc.ts","../src/Components/Graphs/DonutChart/Graph.tsx","../src/Components/Graphs/DonutChart/index.tsx"],"sourcesContent":["export const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\n\nexport const epsilon = 1e-12;\nexport const pi = Math.PI;\nexport const halfPi = pi / 2;\nexport const tau = 2 * pi;\n\nexport function acos(x) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n","export default function(a, b) {\n return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;\n}\n","export default function(d) {\n return d;\n}\n","import array from \"./array.js\";\nimport constant from \"./constant.js\";\nimport descending from \"./descending.js\";\nimport identity from \"./identity.js\";\nimport {tau} from \"./math.js\";\n\nexport default function() {\n var value = identity,\n sortValues = descending,\n sort = null,\n startAngle = constant(0),\n endAngle = constant(tau),\n padAngle = constant(0);\n\n function pie(data) {\n var i,\n n = (data = array(data)).length,\n j,\n k,\n sum = 0,\n index = new Array(n),\n arcs = new Array(n),\n a0 = +startAngle.apply(this, arguments),\n da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)),\n a1,\n p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)),\n pa = p * (da < 0 ? -1 : 1),\n v;\n\n for (i = 0; i < n; ++i) {\n if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {\n sum += v;\n }\n }\n\n // Optionally sort the arcs by previously-computed values or by data.\n if (sortValues != null) index.sort(function(i, j) { return sortValues(arcs[i], arcs[j]); });\n else if (sort != null) index.sort(function(i, j) { return sort(data[i], data[j]); });\n\n // Compute the arcs! They are stored in the original data's order.\n for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {\n j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {\n data: data[j],\n index: i,\n value: v,\n startAngle: a0,\n endAngle: a1,\n padAngle: p\n };\n }\n\n return arcs;\n }\n\n pie.value = function(_) {\n return arguments.length ? (value = typeof _ === \"function\" ? _ : constant(+_), pie) : value;\n };\n\n pie.sortValues = function(_) {\n return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;\n };\n\n pie.sort = function(_) {\n return arguments.length ? (sort = _, sortValues = null, pie) : sort;\n };\n\n pie.startAngle = function(_) {\n return arguments.length ? (startAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : startAngle;\n };\n\n pie.endAngle = function(_) {\n return arguments.length ? (endAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : endAngle;\n };\n\n pie.padAngle = function(_) {\n return arguments.length ? (padAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : padAngle;\n };\n\n return pie;\n}\n","const polarToCartesian = (\r\n centerX: number,\r\n centerY: number,\r\n radius: number,\r\n angleInRadians: number,\r\n) => {\r\n return {\r\n x: centerX + radius * Math.cos(angleInRadians),\r\n y: centerY + radius * Math.sin(angleInRadians),\r\n };\r\n};\r\n\r\nexport function getArc(\r\n x: number,\r\n y: number,\r\n radius: number,\r\n startAngleInRadians: number,\r\n endAngleInRadians: number,\r\n) {\r\n const start = polarToCartesian(x, y, radius, startAngleInRadians);\r\n const end = polarToCartesian(\r\n x,\r\n y,\r\n radius,\r\n endAngleInRadians === 2 * Math.PI ? 1.9999999999 * Math.PI : endAngleInRadians,\r\n );\r\n const largeArcFlag = endAngleInRadians - startAngleInRadians <= Math.PI ? '0' : '1';\r\n const d = ['M', start.x, start.y, 'A', radius, radius, 0, largeArcFlag, 1, end.x, end.y].join(\r\n ' ',\r\n );\r\n return d;\r\n}\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport isEqual from 'fast-deep-equal';\r\nimport { pie } from 'd3-shape';\r\nimport { useRef, useState } from 'react';\r\nimport { H2, P } from '@undp/design-system-react/Typography';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport { AnimateDataType, ClassNameObject, DonutChartDataType, StyleObject } from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { DetailsModal } from '@/Components/Elements/DetailsModal';\r\nimport { getArc } from '@/Utils/getArc';\r\n\r\ninterface Props {\r\n mainText?: string | { label: string; suffix?: string; prefix?: string };\r\n radius: number;\r\n colors: string[];\r\n subNote?: string;\r\n strokeWidth: number;\r\n data: DonutChartDataType[];\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n onSeriesMouseOver?: (_d: any) => void;\r\n onSeriesMouseClick?: (_d: any) => void;\r\n colorDomain: string[];\r\n resetSelectionOnDoubleClick: boolean;\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n animate: AnimateDataType;\r\n trackColor: string;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n mainText,\r\n data,\r\n radius,\r\n colors,\r\n subNote,\r\n strokeWidth,\r\n tooltip,\r\n onSeriesMouseOver,\r\n onSeriesMouseClick,\r\n colorDomain,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision,\r\n animate,\r\n trackColor,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const pieData = pie()\r\n .sort(null)\r\n .startAngle(0)\r\n .value((d: any) => d.size);\r\n\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n return (\r\n <>\r\n <motion.svg\r\n ref={svgRef}\r\n width={`${radius * 2}px`}\r\n height={`${radius * 2}px`}\r\n viewBox={`0 0 ${radius * 2} ${radius * 2}`}\r\n direction='ltr'\r\n className='mx-auto'\r\n >\r\n <motion.g transform={`translate(${radius} ${radius})`}>\r\n {mainText || subNote ? (\r\n <foreignObject\r\n y={0 - (radius - strokeWidth)}\r\n x={0 - (radius - strokeWidth)}\r\n width={2 * (radius - strokeWidth)}\r\n height={2 * (radius - strokeWidth)}\r\n >\r\n <div className='flex flex-col gap-0.5 justify-center items-center h-inherit py-0 px-4'>\r\n {mainText ? (\r\n <H2\r\n marginBottom='none'\r\n className='donut-main-text text-primary-gray-700 dark:text-primary-gray-100 leading-none text-center'\r\n >\r\n {typeof mainText === 'string'\r\n ? mainText\r\n : data.findIndex(d => d.label === mainText.label) !== -1\r\n ? numberFormattingFunction(\r\n data[data.findIndex(d => d.label === mainText.label)].size,\r\n 'NA',\r\n precision,\r\n mainText.prefix,\r\n mainText.suffix,\r\n )\r\n : 'NA'}\r\n </H2>\r\n ) : null}\r\n {subNote ? (\r\n <P\r\n marginBottom='none'\r\n size='base'\r\n leading='none'\r\n className='donut-sub-note text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold'\r\n >\r\n {subNote}\r\n </P>\r\n ) : typeof mainText === 'string' || !mainText ? null : (\r\n <P\r\n size='base'\r\n marginBottom='none'\r\n leading='none'\r\n className='donut-label text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold'\r\n >\r\n {mainText.label}\r\n </P>\r\n )}\r\n </div>\r\n </foreignObject>\r\n ) : null}\r\n <circle\r\n cx={0}\r\n cy={0}\r\n r={radius - strokeWidth / 2}\r\n fill='none'\r\n stroke={trackColor}\r\n strokeWidth={strokeWidth}\r\n />\r\n <AnimatePresence>\r\n {pieData(data as any).map((d, i) => (\r\n <motion.path\r\n key={i}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n d: getArc(\r\n 0,\r\n 0,\r\n radius - strokeWidth / 2,\r\n d.startAngle - Math.PI / 2,\r\n d.endAngle - Math.PI / 2,\r\n ),\r\n opacity: mouseOverData\r\n ? mouseOverData.label === (d.data as any).label\r\n ? 1\r\n : 0.3\r\n : 1,\r\n },\r\n whileInView: {\r\n pathLength: 1,\r\n d: getArc(\r\n 0,\r\n 0,\r\n radius - strokeWidth / 2,\r\n d.startAngle - Math.PI / 2,\r\n d.endAngle - Math.PI / 2,\r\n ),\r\n opacity: mouseOverData\r\n ? mouseOverData.label === (d.data as any).label\r\n ? 1\r\n : 0.3\r\n : 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n stroke:\r\n colorDomain.indexOf((d.data as any).label) !== -1\r\n ? colors[colorDomain.indexOf((d.data as any).label) % colors.length]\r\n : Colors.gray,\r\n strokeWidth,\r\n fill: 'none',\r\n }}\r\n onMouseEnter={event => {\r\n setMouseOverData(d.data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d.data) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d.data);\r\n if (onSeriesMouseClick) onSeriesMouseClick(d.data);\r\n }\r\n }\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d.data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n />\r\n ))}\r\n </AnimatePresence>\r\n </motion.g>\r\n </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n {detailsOnClick && mouseClickData !== undefined ? (\r\n <DetailsModal\r\n body={detailsOnClick}\r\n data={mouseClickData}\r\n setData={setMouseClickData}\r\n className={classNames?.modal}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useEffect, useRef, useState } from 'react';\r\nimport { P } from '@undp/design-system-react/Typography';\r\nimport orderBy from 'lodash.orderby';\r\nimport { Spacer } from '@undp/design-system-react/Spacer';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n DonutChartDataType,\r\n Languages,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\nimport { GraphArea, GraphContainer } from '@/Components/Elements/GraphContainer';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: DonutChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Array of colors for each segment */\r\n colors?: string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: string[];\r\n /** Background color of the graph */\r\n backgroundColor?: string | boolean;\r\n /** Custom styles for the graph. Each object should be a valid React CSS style object. */\r\n styles?: StyleObject;\r\n /** Custom class names */\r\n classNames?: ClassNameObject;\r\n\r\n // Size and Spacing\r\n /** Width of the graph */\r\n width?: number;\r\n /** Height of the graph */\r\n height?: number;\r\n /** Minimum height of the graph */\r\n minHeight?: number;\r\n /** Relative height scaling factor. This overwrites the height props */\r\n relativeHeight?: number;\r\n /** Padding around the graph. Defaults to 0 if no backgroundColor is mentioned else defaults to 1rem */\r\n padding?: string;\r\n /** Radius of the donut chart */\r\n radius?: number;\r\n\r\n // Values and Ticks\r\n /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Max width of the color scale as a css property */\r\n colorScaleMaxWidth?: string;\r\n /** Stroke width of the arcs and circle of the donut */\r\n strokeWidth?: number;\r\n /** Sorting order for data. This is overwritten by labelOrder prop */\r\n sortData?: 'asc' | 'desc';\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Large text at the center of the donut chart. If the type is an object then the text is the value in the data for the label mentioned in the object */\r\n mainText?: string | { label: string; suffix?: string; prefix?: string };\r\n /** Small text at the center of the donut chart */\r\n subNote?: string;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\r\n /** Track color (i.e. the color of the donut chart's background) of the donut chart */\r\n trackColor?: string;\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n /** Reset selection on double-click. Only applicable when used in a dashboard context with filters. */\r\n resetSelectionOnDoubleClick?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Details displayed on the modal when user clicks of a data point. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n /** Callback for mouse click event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function DonutChart(props: Props) {\r\n const {\r\n mainText,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n suffix = '',\r\n sources,\r\n prefix = '',\r\n strokeWidth = 50,\r\n graphDescription,\r\n subNote,\r\n footNote,\r\n radius,\r\n data,\r\n showColorScale = true,\r\n padding,\r\n backgroundColor = false,\r\n tooltip,\r\n onSeriesMouseOver,\r\n graphID,\r\n onSeriesMouseClick,\r\n graphDownload = false,\r\n dataDownload = false,\r\n colorDomain,\r\n sortData,\r\n language = 'en',\r\n theme = 'light',\r\n width,\r\n height,\r\n minHeight = 0,\r\n relativeHeight,\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n colorScaleMaxWidth,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision = 2,\r\n animate = false,\r\n trackColor = Colors.light.grays['gray-200'],\r\n } = props;\r\n\r\n const [graphRadius, setGraphRadius] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setGraphRadius(\r\n (Math.min(\r\n ...[entries[0].target.clientWidth || 620, entries[0].target.clientHeight || 480],\r\n ) || 420) / 2,\r\n );\r\n });\r\n if (graphDiv.current) {\r\n resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, []);\r\n\r\n const sortedData = sortData ? orderBy(data, ['size'], [sortData]) : data;\r\n\r\n return (\r\n <GraphContainer\r\n className={classNames?.graphContainer}\r\n style={styles?.graphContainer}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={ariaLabel}\r\n backgroundColor={backgroundColor}\r\n theme={theme}\r\n language={language}\r\n minHeight={minHeight}\r\n width={width}\r\n height={height}\r\n relativeHeight={relativeHeight}\r\n padding={padding}\r\n >\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n {showColorScale && data.length > 0 ? (\r\n <>\r\n <div\r\n className={cn(\r\n 'leading-0 flex mb-0 ml-auto mr-auto justify-center gap-x-3 gap-y-0 flex-wrap',\r\n classNames?.colorLegend,\r\n )}\r\n style={{ maxWidth: colorScaleMaxWidth }}\r\n aria-label='Color legend'\r\n >\r\n {sortedData.map((d, i) => (\r\n <div className='flex gap-2 items-center pb-3' key={i}>\r\n <div\r\n className='w-3 h-3 rounded-full'\r\n style={{\r\n backgroundColor:\r\n (colorDomain || sortedData.map(el => el.label)).indexOf(d.label) !== -1\r\n ? (colors || Colors[theme].categoricalColors.colors)[\r\n (colorDomain || sortedData.map(el => el.label)).indexOf(d.label) %\r\n (colors || Colors[theme].categoricalColors.colors).length\r\n ]\r\n : Colors.gray,\r\n }}\r\n />\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n className='text-primary-gray-700 dark:text-primary-gray-100'\r\n >\r\n {d.label}:{' '}\r\n <span className='font-bold' style={{ fontSize: 'inherit' }}>\r\n {numberFormattingFunction(d.size, 'NA', precision, prefix, suffix)}\r\n </span>\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n <Spacer size='lg' />\r\n </>\r\n ) : null}\r\n <GraphArea ref={graphDiv}>\r\n {data.length === 0 && <EmptyState />}\r\n {graphRadius && data.length > 0 ? (\r\n <Graph\r\n mainText={mainText}\r\n data={sortedData}\r\n colors={colors}\r\n radius={radius || graphRadius}\r\n subNote={subNote}\r\n strokeWidth={strokeWidth}\r\n tooltip={tooltip}\r\n colorDomain={colorDomain || sortedData.map(d => d.label)}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n styles={styles}\r\n detailsOnClick={detailsOnClick}\r\n precision={precision}\r\n animate={\r\n animate === true\r\n ? { duration: 0.5, once: true, amount: 0.5 }\r\n : animate || { duration: 0, once: true, amount: 0 }\r\n }\r\n trackColor={trackColor}\r\n />\r\n ) : null}\r\n </GraphArea>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </GraphContainer>\r\n );\r\n}\r\n"],"names":["pi","tau","descending","a","b","identity","d","pie","value","sortValues","sort","startAngle","constant","endAngle","padAngle","data","i","n","array","j","k","sum","index","arcs","a0","da","a1","p","pa","v","_","polarToCartesian","centerX","centerY","radius","angleInRadians","x","Math","cos","y","sin","getArc","startAngleInRadians","endAngleInRadians","start","end","PI","largeArcFlag","join","Graph","props","$","_c","mainText","colors","subNote","strokeWidth","tooltip","onSeriesMouseOver","onSeriesMouseClick","colorDomain","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","precision","animate","trackColor","svgRef","useRef","t0","amount","once","isInView","useInView","pieData","_temp","mouseOverData","setMouseOverData","useState","undefined","mouseClickData","setMouseClickData","eventX","setEventX","eventY","setEventY","t1","motion","t2","t3","t4","t5","t6","t7","t8","t9","jsx","jsxs","H2","findIndex","d_1","label","numberFormattingFunction","d_0","size","prefix","suffix","P","t10","t11","T0","AnimatePresence","t12","duration","d_2","initial","pathLength","opacity","whileInView","transition","stroke","indexOf","length","Colors","gray","fill","event","clientY","clientX","isEqual","event_0","t13","map","t14","t15","g","t16","svg","t17","Tooltip","t18","modal","DetailsModal","t19","Fragment","DonutChart","graphTitle","light","categoricalColors","sources","graphDescription","footNote","showColorScale","padding","backgroundColor","graphID","graphDownload","dataDownload","sortData","language","theme","width","height","minHeight","relativeHeight","ariaLabel","colorScaleMaxWidth","grays","graphRadius","setGraphRadius","graphDiv","graphParentDiv","useEffect","resizeObserver","ResizeObserver","entries","min","target","clientWidth","clientHeight","current","observe","disconnect","sortedData","orderBy","GraphContainer","graphContainer","GraphHeader","title","description","filter","cn","colorLegend","maxWidth","el","fontSize","Spacer","GraphArea","EmptyState","GraphFooter","footnote","source"],"mappings":"0uBASaA,GAAK,KAAK,GAEVC,GAAM,EAAID,GCXR,SAAAE,GAASC,EAAGC,EAAG,CAC5B,OAAOA,EAAID,EAAI,GAAKC,EAAID,EAAI,EAAIC,GAAKD,EAAI,EAA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,QACEC,IAAY,GACR,CAAEgD,SAAU,GAAK1C,KAAM,GAAMD,OAAQ,EAAA,EACrCL,GAAW,CAAEgD,SAAU,EAAG1C,KAAM,GAAMD,OAAQ,CAAA,EAEpD,WAAAJ,EAAuB,EAEvB,IAAA,EACN,EACCmF,GAAWE,EACVvD,EAAAA,kBAAAA,IAACuG,GAAAA,YAAA,CACC,OAAQ,CAAEC,SAAU1I,GAAQ0I,SAAUC,OAAQ3I,GAAQ2I,MAAAA,EACtD,WAAY,CACVD,SAAUzI,GAAYyI,SACtBC,OAAQ1I,GAAY0I,MAAAA,EAEtB,QAAApD,EACA,SAAAE,EACA,MAAAU,CAAA,CAAa,EAEb,IAAA,EACN,CAEJ","x_google_ignoreList":[0,1,2,3]}
|
|
1
|
+
{"version":3,"file":"DonutChart.cjs","sources":["../node_modules/d3-shape/src/math.js","../node_modules/d3-shape/src/descending.js","../node_modules/d3-shape/src/identity.js","../node_modules/d3-shape/src/pie.js","../src/Utils/getArc.ts","../src/Components/Graphs/DonutChart/Graph.tsx","../src/Components/Graphs/DonutChart/index.tsx"],"sourcesContent":["export const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\n\nexport const epsilon = 1e-12;\nexport const pi = Math.PI;\nexport const halfPi = pi / 2;\nexport const tau = 2 * pi;\n\nexport function acos(x) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n","export default function(a, b) {\n return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;\n}\n","export default function(d) {\n return d;\n}\n","import array from \"./array.js\";\nimport constant from \"./constant.js\";\nimport descending from \"./descending.js\";\nimport identity from \"./identity.js\";\nimport {tau} from \"./math.js\";\n\nexport default function() {\n var value = identity,\n sortValues = descending,\n sort = null,\n startAngle = constant(0),\n endAngle = constant(tau),\n padAngle = constant(0);\n\n function pie(data) {\n var i,\n n = (data = array(data)).length,\n j,\n k,\n sum = 0,\n index = new Array(n),\n arcs = new Array(n),\n a0 = +startAngle.apply(this, arguments),\n da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)),\n a1,\n p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)),\n pa = p * (da < 0 ? -1 : 1),\n v;\n\n for (i = 0; i < n; ++i) {\n if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {\n sum += v;\n }\n }\n\n // Optionally sort the arcs by previously-computed values or by data.\n if (sortValues != null) index.sort(function(i, j) { return sortValues(arcs[i], arcs[j]); });\n else if (sort != null) index.sort(function(i, j) { return sort(data[i], data[j]); });\n\n // Compute the arcs! They are stored in the original data's order.\n for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {\n j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {\n data: data[j],\n index: i,\n value: v,\n startAngle: a0,\n endAngle: a1,\n padAngle: p\n };\n }\n\n return arcs;\n }\n\n pie.value = function(_) {\n return arguments.length ? (value = typeof _ === \"function\" ? _ : constant(+_), pie) : value;\n };\n\n pie.sortValues = function(_) {\n return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;\n };\n\n pie.sort = function(_) {\n return arguments.length ? (sort = _, sortValues = null, pie) : sort;\n };\n\n pie.startAngle = function(_) {\n return arguments.length ? (startAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : startAngle;\n };\n\n pie.endAngle = function(_) {\n return arguments.length ? (endAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : endAngle;\n };\n\n pie.padAngle = function(_) {\n return arguments.length ? (padAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : padAngle;\n };\n\n return pie;\n}\n","const polarToCartesian = (\r\n centerX: number,\r\n centerY: number,\r\n radius: number,\r\n angleInRadians: number,\r\n) => {\r\n return {\r\n x: centerX + radius * Math.cos(angleInRadians),\r\n y: centerY + radius * Math.sin(angleInRadians),\r\n };\r\n};\r\n\r\nexport function getArc(\r\n x: number,\r\n y: number,\r\n radius: number,\r\n startAngleInRadians: number,\r\n endAngleInRadians: number,\r\n) {\r\n const start = polarToCartesian(x, y, radius, startAngleInRadians);\r\n const end = polarToCartesian(\r\n x,\r\n y,\r\n radius,\r\n Math.abs(endAngleInRadians - startAngleInRadians) === 2 * Math.PI\r\n ? 0.999999 * endAngleInRadians\r\n : endAngleInRadians,\r\n );\r\n const largeArcFlag = endAngleInRadians - startAngleInRadians <= Math.PI ? '0' : '1';\r\n const d = ['M', start.x, start.y, 'A', radius, radius, 0, largeArcFlag, 1, end.x, end.y].join(\r\n ' ',\r\n );\r\n return d;\r\n}\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport isEqual from 'fast-deep-equal';\r\nimport { pie } from 'd3-shape';\r\nimport { isValidElement, ReactElement, useRef, useState } from 'react';\r\nimport { H2, P } from '@undp/design-system-react/Typography';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport { AnimateDataType, ClassNameObject, DonutChartDataType, StyleObject } from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { DetailsModal } from '@/Components/Elements/DetailsModal';\r\nimport { getArc } from '@/Utils/getArc';\r\n\r\ninterface Props {\r\n mainText?: string | { label: string; suffix?: string; prefix?: string } | ReactElement;\r\n radius: number;\r\n colors: string[];\r\n subNote?: string;\r\n strokeWidth: number;\r\n data: DonutChartDataType[];\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n onSeriesMouseOver?: (_d: any) => void;\r\n onSeriesMouseClick?: (_d: any) => void;\r\n colorDomain: string[];\r\n resetSelectionOnDoubleClick: boolean;\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n animate: AnimateDataType;\r\n trackColor: string;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n mainText,\r\n data,\r\n radius,\r\n colors,\r\n subNote,\r\n strokeWidth,\r\n tooltip,\r\n onSeriesMouseOver,\r\n onSeriesMouseClick,\r\n colorDomain,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision,\r\n animate,\r\n trackColor,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const pieData = pie()\r\n .sort(null)\r\n .startAngle(0)\r\n .value((d: any) => d.size);\r\n\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n return (\r\n <>\r\n <motion.svg\r\n ref={svgRef}\r\n width={`${radius * 2}px`}\r\n height={`${radius * 2}px`}\r\n viewBox={`0 0 ${radius * 2} ${radius * 2}`}\r\n direction='ltr'\r\n className='mx-auto'\r\n >\r\n <motion.g transform={`translate(${radius} ${radius})`}>\r\n {mainText || subNote ? (\r\n <foreignObject\r\n y={0 - (radius - strokeWidth)}\r\n x={0 - (radius - strokeWidth)}\r\n width={2 * (radius - strokeWidth)}\r\n height={2 * (radius - strokeWidth)}\r\n >\r\n <div className='flex flex-col gap-0.5 justify-center items-center h-inherit py-0 px-4'>\r\n {mainText ? (\r\n isValidElement(mainText) ? (\r\n mainText\r\n ) : (\r\n <H2\r\n marginBottom='none'\r\n className='donut-main-text text-primary-gray-700 dark:text-primary-gray-100 leading-none text-center'\r\n >\r\n {typeof mainText === 'string'\r\n ? mainText\r\n : data.findIndex(d => d.label === mainText.label) !== -1\r\n ? numberFormattingFunction(\r\n data[data.findIndex(d => d.label === mainText.label)].size,\r\n 'NA',\r\n precision,\r\n mainText.prefix,\r\n mainText.suffix,\r\n )\r\n : 'NA'}\r\n </H2>\r\n )\r\n ) : null}\r\n {subNote ? (\r\n <P\r\n marginBottom='none'\r\n size='base'\r\n leading='none'\r\n className='donut-sub-note text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold'\r\n >\r\n {subNote}\r\n </P>\r\n ) : typeof mainText === 'string' || !mainText || isValidElement(mainText) ? null : (\r\n <P\r\n size='base'\r\n marginBottom='none'\r\n leading='none'\r\n className='donut-label text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold'\r\n >\r\n {mainText.label}\r\n </P>\r\n )}\r\n </div>\r\n </foreignObject>\r\n ) : null}\r\n <circle\r\n cx={0}\r\n cy={0}\r\n r={radius - strokeWidth / 2}\r\n fill='none'\r\n stroke={trackColor}\r\n strokeWidth={strokeWidth}\r\n />\r\n <AnimatePresence>\r\n {pieData(data as any).map((d, i) => (\r\n <motion.path\r\n key={i}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n d: getArc(\r\n 0,\r\n 0,\r\n radius - strokeWidth / 2,\r\n d.startAngle - Math.PI / 2,\r\n d.endAngle - Math.PI / 2,\r\n ),\r\n opacity: mouseOverData\r\n ? mouseOverData.label === (d.data as any).label\r\n ? 1\r\n : 0.3\r\n : 1,\r\n },\r\n whileInView: {\r\n pathLength: 1,\r\n d: getArc(\r\n 0,\r\n 0,\r\n radius - strokeWidth / 2,\r\n d.startAngle - Math.PI / 2,\r\n d.endAngle - Math.PI / 2,\r\n ),\r\n opacity: mouseOverData\r\n ? mouseOverData.label === (d.data as any).label\r\n ? 1\r\n : 0.3\r\n : 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n stroke:\r\n colorDomain.indexOf((d.data as any).label) !== -1\r\n ? colors[colorDomain.indexOf((d.data as any).label) % colors.length]\r\n : Colors.gray,\r\n strokeWidth,\r\n fill: 'none',\r\n }}\r\n onMouseEnter={event => {\r\n setMouseOverData(d.data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d.data) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d.data);\r\n if (onSeriesMouseClick) onSeriesMouseClick(d.data);\r\n }\r\n }\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d.data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n />\r\n ))}\r\n </AnimatePresence>\r\n </motion.g>\r\n </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n {detailsOnClick && mouseClickData !== undefined ? (\r\n <DetailsModal\r\n body={detailsOnClick}\r\n data={mouseClickData}\r\n setData={setMouseClickData}\r\n className={classNames?.modal}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { ReactElement, useEffect, useRef, useState } from 'react';\r\nimport { P } from '@undp/design-system-react/Typography';\r\nimport orderBy from 'lodash.orderby';\r\nimport { Spacer } from '@undp/design-system-react/Spacer';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n DonutChartDataType,\r\n Languages,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\nimport { GraphArea, GraphContainer } from '@/Components/Elements/GraphContainer';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: DonutChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Array of colors for each segment */\r\n colors?: string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: string[];\r\n /** Background color of the graph */\r\n backgroundColor?: string | boolean;\r\n /** Custom styles for the graph. Each object should be a valid React CSS style object. */\r\n styles?: StyleObject;\r\n /** Custom class names */\r\n classNames?: ClassNameObject;\r\n\r\n // Size and Spacing\r\n /** Width of the graph */\r\n width?: number;\r\n /** Height of the graph */\r\n height?: number;\r\n /** Minimum height of the graph */\r\n minHeight?: number;\r\n /** Relative height scaling factor. This overwrites the height props */\r\n relativeHeight?: number;\r\n /** Padding around the graph. Defaults to 0 if no backgroundColor is mentioned else defaults to 1rem */\r\n padding?: string;\r\n /** Radius of the donut chart */\r\n radius?: number;\r\n\r\n // Values and Ticks\r\n /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Max width of the color scale as a css property */\r\n colorScaleMaxWidth?: string;\r\n /** Stroke width of the arcs and circle of the donut */\r\n strokeWidth?: number;\r\n /** Sorting order for data. This is overwritten by labelOrder prop */\r\n sortData?: 'asc' | 'desc';\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Large text at the center of the donut chart. If the type is an object then the text is the value in the data for the label mentioned in the object */\r\n mainText?: string | { label: string; suffix?: string; prefix?: string } | ReactElement;\r\n /** Small text at the center of the donut chart */\r\n subNote?: string;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\r\n /** Track color (i.e. the color of the donut chart's background) of the donut chart */\r\n trackColor?: string;\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n /** Reset selection on double-click. Only applicable when used in a dashboard context with filters. */\r\n resetSelectionOnDoubleClick?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Details displayed on the modal when user clicks of a data point. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n /** Callback for mouse click event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function DonutChart(props: Props) {\r\n const {\r\n mainText,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n suffix = '',\r\n sources,\r\n prefix = '',\r\n strokeWidth = 50,\r\n graphDescription,\r\n subNote,\r\n footNote,\r\n radius,\r\n data,\r\n showColorScale = true,\r\n padding,\r\n backgroundColor = false,\r\n tooltip,\r\n onSeriesMouseOver,\r\n graphID,\r\n onSeriesMouseClick,\r\n graphDownload = false,\r\n dataDownload = false,\r\n colorDomain,\r\n sortData,\r\n language = 'en',\r\n theme = 'light',\r\n width,\r\n height,\r\n minHeight = 0,\r\n relativeHeight,\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n colorScaleMaxWidth,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision = 2,\r\n animate = false,\r\n trackColor = Colors.light.grays['gray-200'],\r\n } = props;\r\n\r\n const [graphRadius, setGraphRadius] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setGraphRadius(\r\n (Math.min(\r\n ...[entries[0].target.clientWidth || 620, entries[0].target.clientHeight || 480],\r\n ) || 420) / 2,\r\n );\r\n });\r\n if (graphDiv.current) {\r\n resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, []);\r\n\r\n const sortedData = sortData ? orderBy(data, ['size'], [sortData]) : data;\r\n\r\n return (\r\n <GraphContainer\r\n className={classNames?.graphContainer}\r\n style={styles?.graphContainer}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={ariaLabel}\r\n backgroundColor={backgroundColor}\r\n theme={theme}\r\n language={language}\r\n minHeight={minHeight}\r\n width={width}\r\n height={height}\r\n relativeHeight={relativeHeight}\r\n padding={padding}\r\n >\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n {showColorScale && data.length > 0 ? (\r\n <>\r\n <div\r\n className={cn(\r\n 'leading-0 flex mb-0 ml-auto mr-auto justify-center gap-x-3 gap-y-0 flex-wrap',\r\n classNames?.colorLegend,\r\n )}\r\n style={{ maxWidth: colorScaleMaxWidth }}\r\n aria-label='Color legend'\r\n >\r\n {sortedData.map((d, i) => (\r\n <div className='flex gap-2 items-center pb-3' key={i}>\r\n <div\r\n className='w-3 h-3 rounded-full'\r\n style={{\r\n backgroundColor:\r\n (colorDomain || sortedData.map(el => el.label)).indexOf(d.label) !== -1\r\n ? (colors || Colors[theme].categoricalColors.colors)[\r\n (colorDomain || sortedData.map(el => el.label)).indexOf(d.label) %\r\n (colors || Colors[theme].categoricalColors.colors).length\r\n ]\r\n : Colors.gray,\r\n }}\r\n />\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n className='text-primary-gray-700 dark:text-primary-gray-100'\r\n >\r\n {d.label}:{' '}\r\n <span className='font-bold' style={{ fontSize: 'inherit' }}>\r\n {numberFormattingFunction(d.size, 'NA', precision, prefix, suffix)}\r\n </span>\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n <Spacer size='lg' />\r\n </>\r\n ) : null}\r\n <GraphArea ref={graphDiv}>\r\n {data.length === 0 && <EmptyState />}\r\n {graphRadius && data.length > 0 ? (\r\n <Graph\r\n mainText={mainText}\r\n data={sortedData}\r\n colors={colors}\r\n radius={radius || graphRadius}\r\n subNote={subNote}\r\n strokeWidth={strokeWidth}\r\n tooltip={tooltip}\r\n colorDomain={colorDomain || sortedData.map(d => d.label)}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n styles={styles}\r\n detailsOnClick={detailsOnClick}\r\n precision={precision}\r\n animate={\r\n animate === true\r\n ? { duration: 0.5, once: true, amount: 0.5 }\r\n : animate || { duration: 0, once: true, amount: 0 }\r\n }\r\n trackColor={trackColor}\r\n />\r\n ) : null}\r\n </GraphArea>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </GraphContainer>\r\n );\r\n}\r\n"],"names":["pi","tau","descending","a","b","identity","d","pie","value","sortValues","sort","startAngle","constant","endAngle","padAngle","data","i","n","array","j","k","sum","index","arcs","a0","da","a1","p","pa","v","_","polarToCartesian","centerX","centerY","radius","angleInRadians","x","Math","cos","y","sin","getArc","startAngleInRadians","endAngleInRadians","start","end","abs","PI","largeArcFlag","join","Graph","props","$","_c","mainText","colors","subNote","strokeWidth","tooltip","onSeriesMouseOver","onSeriesMouseClick","colorDomain","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","precision","animate","trackColor","svgRef","useRef","t0","amount","once","isInView","useInView","pieData","_temp","mouseOverData","setMouseOverData","useState","undefined","mouseClickData","setMouseClickData","eventX","setEventX","eventY","setEventY","t1","motion","t2","t3","t4","t5","t6","t7","t8","t9","jsx","jsxs","isValidElement","H2","findIndex","d_1","label","numberFormattingFunction","size","prefix","suffix","P","t10","t11","T0","AnimatePresence","t12","duration","d_2","initial","pathLength","opacity","whileInView","transition","stroke","indexOf","length","Colors","gray","fill","event","clientY","clientX","isEqual","event_0","t13","map","t14","t15","g","t16","svg","t17","Tooltip","t18","modal","DetailsModal","t19","Fragment","DonutChart","graphTitle","light","categoricalColors","sources","graphDescription","footNote","showColorScale","padding","backgroundColor","graphID","graphDownload","dataDownload","sortData","language","theme","width","height","minHeight","relativeHeight","ariaLabel","colorScaleMaxWidth","grays","graphRadius","setGraphRadius","graphDiv","graphParentDiv","useEffect","resizeObserver","ResizeObserver","entries","min","target","clientWidth","clientHeight","current","observe","disconnect","sortedData","orderBy","GraphContainer","graphContainer","GraphHeader","title","description","filter","cn","colorLegend","maxWidth","el","fontSize","Spacer","GraphArea","EmptyState","GraphFooter","footnote","source"],"mappings":"0uBASaA,GAAK,KAAK,GAEVC,GAAM,EAAID,GCXR,SAAAE,GAASC,EAAGC,EAAG,CAC5B,OAAOA,EAAID,EAAI,GAAKC,EAAID,EAAI,EAAIC,GAAKD,EAAI,EAAI,GAC/C,CCFe,SAAAE,GAASC,EAAG,CACzB,OAAOA,CACT,CCIe,SAAAC,IAAW,CACxB,IAAIC,EAAQH,GACRI,EAAaP,GACbQ,EAAO,KACPC,EAAaC,EAAAA,SAAS,CAAC,EACvBC,EAAWD,EAAAA,SAASX,EAAG,EACvBa,EAAWF,EAAAA,SAAS,CAAC,EAEzB,SAASL,EAAIQ,EAAM,CACjB,IAAIC,EACAC,GAAKF,EAAOG,QAAMH,CAAI,GAAG,OACzBI,EACAC,EACAC,EAAM,EACNC,EAAQ,IAAI,MAAML,CAAC,EACnBM,EAAO,IAAI,MAAMN,CAAC,EAClBO,EAAK,CAACb,EAAW,MAAM,KAAM,SAAS,EACtCc,EAAK,KAAK,IAAIxB,GAAK,KAAK,IAAI,CAACA,GAAKY,EAAS,MAAM,KAAM,SAAS,EAAIW,CAAE,CAAC,EACvEE,EACAC,EAAI,KAAK,IAAI,KAAK,IAAIF,CAAE,EAAIR,EAAGH,EAAS,MAAM,KAAM,SAAS,CAAC,EAC9Dc,EAAKD,GAAKF,EAAK,EAAI,GAAK,GACxBI,EAEJ,IAAKb,EAAI,EAAGA,EAAIC,EAAG,EAAED,GACda,EAAIN,EAAKD,EAAMN,CAAC,EAAIA,CAAC,EAAI,CAACR,EAAMO,EAAKC,CAAC,EAAGA,EAAGD,CAAI,GAAK,IACxDM,GAAOQ,GASX,IAJIpB,GAAc,KAAMa,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A,KAACoG,GAAAA,UAAA,CAAU,IAAK3B,EACb7J,SAAAA,CAAAA,EAAK6G,SAAW,GAAK1B,EAAAA,kBAAAA,IAACsG,GAAAA,WAAA,CAAA,CAAU,EAChC9B,GAAe3J,EAAK6G,OAAS,0BAC3B1E,GAAA,CACC,SAAAI,EACA,KAAMmI,EACN,OAAAlI,EACA,OAAQrB,GAAUwI,EAClB,QAAAlH,EACA,YAAAC,EACA,QAAAC,EACA,YAAaG,GAAe4H,EAAWnD,IAAIhI,GAAKA,EAAEkG,KAAK,EACvD,kBAAA7C,EACA,mBAAAC,EACA,4BAAAE,EACA,OAAAE,EACA,eAAAD,EACA,UAAAG,GACA,QACEC,IAAY,GACR,CAAEgD,SAAU,GAAK1C,KAAM,GAAMD,OAAQ,EAAA,EACrCL,GAAW,CAAEgD,SAAU,EAAG1C,KAAM,GAAMD,OAAQ,CAAA,EAEpD,WAAAJ,EAAuB,EAEvB,IAAA,EACN,EACCmF,GAAWE,EACVvD,EAAAA,kBAAAA,IAACuG,GAAAA,YAAA,CACC,OAAQ,CAAEC,SAAU1I,GAAQ0I,SAAUC,OAAQ3I,GAAQ2I,MAAAA,EACtD,WAAY,CACVD,SAAUzI,GAAYyI,SACtBC,OAAQ1I,GAAY0I,MAAAA,EAEtB,QAAApD,EACA,SAAAE,EACA,MAAAU,CAAA,CAAa,EAEb,IAAA,EACN,CAEJ","x_google_ignoreList":[0,1,2,3]}
|
package/dist/DonutChart.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSX } from 'react/jsx-runtime';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
2
3
|
|
|
3
4
|
declare interface AnimateDataType {
|
|
4
5
|
duration: number;
|
|
@@ -103,7 +104,7 @@ declare interface Props {
|
|
|
103
104
|
label: string;
|
|
104
105
|
suffix?: string;
|
|
105
106
|
prefix?: string;
|
|
106
|
-
};
|
|
107
|
+
} | ReactElement;
|
|
107
108
|
/** Small text at the center of the donut chart */
|
|
108
109
|
subNote?: string;
|
|
109
110
|
/** Specifies the number of decimal places to display in the value. */
|
package/dist/DonutChart.js
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { useRef as rt, useState as tt, useEffect as
|
|
3
|
-
import { v as
|
|
4
|
-
import { o as
|
|
5
|
-
import { n as
|
|
6
|
-
import { i as
|
|
7
|
-
import { T as
|
|
1
|
+
import { c as dt, j as a, m as pt } from "./index-CHPV5EwG-Curnpaqc.js";
|
|
2
|
+
import { useRef as rt, useState as tt, isValidElement as lt, useEffect as ft } from "react";
|
|
3
|
+
import { v as gt, j as it } from "./Typography-PxtFcnJb.js";
|
|
4
|
+
import { o as ht } from "./index-BZQYSqar.js";
|
|
5
|
+
import { n as xt } from "./Source-DwTHB8fn.js";
|
|
6
|
+
import { i as yt } from "./index-Bwrro8-q.js";
|
|
7
|
+
import { T as vt } from "./Tooltip-Dj5eVppQ.js";
|
|
8
8
|
import { Colors as X } from "./Colors.js";
|
|
9
|
-
import { n as
|
|
10
|
-
import { D as
|
|
11
|
-
import { c as T, a as
|
|
12
|
-
import { u as
|
|
13
|
-
import { A as
|
|
9
|
+
import { n as ut } from "./numberFormattingFunction-14YCbkN2.js";
|
|
10
|
+
import { D as bt } from "./DetailsModal-0Ry5nXiC.js";
|
|
11
|
+
import { c as T, a as jt } from "./array-USo-Szhp.js";
|
|
12
|
+
import { u as Mt } from "./use-in-view-Cxa7y1TH.js";
|
|
13
|
+
import { A as Nt } from "./index-BqfRwk1n.js";
|
|
14
14
|
import { m as nt } from "./proxy-BxkFHwUw.js";
|
|
15
|
-
import { GraphFooter as
|
|
16
|
-
import { GraphHeader as
|
|
17
|
-
import { E as
|
|
18
|
-
import { G as
|
|
19
|
-
const
|
|
20
|
-
function
|
|
21
|
-
return t <
|
|
15
|
+
import { GraphFooter as Ct } from "./GraphFooter.js";
|
|
16
|
+
import { GraphHeader as Dt } from "./GraphHeader.js";
|
|
17
|
+
import { E as kt } from "./EmptyState-C7ZXkZWd.js";
|
|
18
|
+
import { G as wt, a as At } from "./GraphContainer-CRqzdKu2.js";
|
|
19
|
+
const Ot = Math.PI, at = 2 * Ot;
|
|
20
|
+
function St(c, t) {
|
|
21
|
+
return t < c ? -1 : t > c ? 1 : t >= c ? 0 : NaN;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
23
|
+
function zt(c) {
|
|
24
|
+
return c;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
var
|
|
26
|
+
function Pt() {
|
|
27
|
+
var c = zt, t = St, o = null, l = T(0), n = T(at), p = T(0);
|
|
28
28
|
function r(e) {
|
|
29
|
-
var
|
|
30
|
-
for (
|
|
31
|
-
(h = b[g[
|
|
32
|
-
for (t != null ? g.sort(function(C,
|
|
33
|
-
return t(b[C], b[
|
|
34
|
-
}) : o != null && g.sort(function(C,
|
|
35
|
-
return o(e[C], e[
|
|
36
|
-
}),
|
|
37
|
-
f = g[
|
|
29
|
+
var s, x = (e = jt(e)).length, f, O, m = 0, g = new Array(x), b = new Array(x), y = +l.apply(this, arguments), S = Math.min(at, Math.max(-at, n.apply(this, arguments) - y)), d, E = Math.min(Math.abs(S) / x, p.apply(this, arguments)), G = E * (S < 0 ? -1 : 1), h;
|
|
30
|
+
for (s = 0; s < x; ++s)
|
|
31
|
+
(h = b[g[s] = s] = +c(e[s], s, e)) > 0 && (m += h);
|
|
32
|
+
for (t != null ? g.sort(function(C, z) {
|
|
33
|
+
return t(b[C], b[z]);
|
|
34
|
+
}) : o != null && g.sort(function(C, z) {
|
|
35
|
+
return o(e[C], e[z]);
|
|
36
|
+
}), s = 0, O = m ? (S - x * G) / m : 0; s < x; ++s, y = d)
|
|
37
|
+
f = g[s], h = b[f], d = y + (h > 0 ? h * O : 0) + G, b[f] = {
|
|
38
38
|
data: e[f],
|
|
39
|
-
index:
|
|
39
|
+
index: s,
|
|
40
40
|
value: h,
|
|
41
41
|
startAngle: y,
|
|
42
42
|
endAngle: d,
|
|
43
|
-
padAngle:
|
|
43
|
+
padAngle: E
|
|
44
44
|
};
|
|
45
45
|
return b;
|
|
46
46
|
}
|
|
47
47
|
return r.value = function(e) {
|
|
48
|
-
return arguments.length ? (
|
|
48
|
+
return arguments.length ? (c = typeof e == "function" ? e : T(+e), r) : c;
|
|
49
49
|
}, r.sortValues = function(e) {
|
|
50
50
|
return arguments.length ? (t = e, o = null, r) : t;
|
|
51
51
|
}, r.sort = function(e) {
|
|
52
52
|
return arguments.length ? (o = e, t = null, r) : o;
|
|
53
53
|
}, r.startAngle = function(e) {
|
|
54
|
-
return arguments.length ? (
|
|
54
|
+
return arguments.length ? (l = typeof e == "function" ? e : T(+e), r) : l;
|
|
55
55
|
}, r.endAngle = function(e) {
|
|
56
|
-
return arguments.length ? (
|
|
56
|
+
return arguments.length ? (n = typeof e == "function" ? e : T(+e), r) : n;
|
|
57
57
|
}, r.padAngle = function(e) {
|
|
58
58
|
return arguments.length ? (p = typeof e == "function" ? e : T(+e), r) : p;
|
|
59
59
|
}, r;
|
|
60
60
|
}
|
|
61
|
-
const
|
|
62
|
-
x:
|
|
63
|
-
y: t + o * Math.sin(
|
|
61
|
+
const st = (c, t, o, l) => ({
|
|
62
|
+
x: c + o * Math.cos(l),
|
|
63
|
+
y: t + o * Math.sin(l)
|
|
64
64
|
});
|
|
65
|
-
function
|
|
66
|
-
const p =
|
|
65
|
+
function ct(c, t, o, l, n) {
|
|
66
|
+
const p = st(c, t, o, l), r = st(c, t, o, Math.abs(n - l) === 2 * Math.PI ? 0.999999 * n : n), e = n - l <= Math.PI ? "0" : "1";
|
|
67
67
|
return ["M", p.x, p.y, "A", o, o, 0, e, 1, r.x, r.y].join(" ");
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
const t =
|
|
69
|
+
function Et(c) {
|
|
70
|
+
const t = dt.c(59), {
|
|
71
71
|
mainText: o,
|
|
72
|
-
data:
|
|
73
|
-
radius:
|
|
72
|
+
data: l,
|
|
73
|
+
radius: n,
|
|
74
74
|
colors: p,
|
|
75
75
|
subNote: r,
|
|
76
76
|
strokeWidth: e,
|
|
77
|
-
tooltip:
|
|
77
|
+
tooltip: s,
|
|
78
78
|
onSeriesMouseOver: x,
|
|
79
79
|
onSeriesMouseClick: f,
|
|
80
80
|
colorDomain: O,
|
|
@@ -82,35 +82,35 @@ function zt(s) {
|
|
|
82
82
|
detailsOnClick: g,
|
|
83
83
|
styles: b,
|
|
84
84
|
classNames: y,
|
|
85
|
-
precision:
|
|
85
|
+
precision: S,
|
|
86
86
|
animate: d,
|
|
87
|
-
trackColor:
|
|
88
|
-
} =
|
|
87
|
+
trackColor: E
|
|
88
|
+
} = c, G = rt(null);
|
|
89
89
|
let h;
|
|
90
90
|
t[0] !== d.amount || t[1] !== d.once ? (h = {
|
|
91
91
|
once: d.once,
|
|
92
92
|
amount: d.amount
|
|
93
93
|
}, t[0] = d.amount, t[1] = d.once, t[2] = h) : h = t[2];
|
|
94
|
-
const C =
|
|
95
|
-
let
|
|
96
|
-
t[3] !==
|
|
97
|
-
o ? /* @__PURE__ */
|
|
98
|
-
r ? /* @__PURE__ */
|
|
99
|
-
] }) }) : null, t[3] =
|
|
100
|
-
const Z =
|
|
94
|
+
const C = Mt(G, h), z = Pt().sort(null).startAngle(0).value(It), [v, Y] = tt(void 0), [j, M] = tt(void 0), [V, q] = tt(void 0), [$, R] = tt(void 0), J = nt, K = `${n * 2}px`, Q = `${n * 2}px`, D = `0 0 ${n * 2} ${n * 2}`, I = "ltr", et = "mx-auto", B = nt, U = `translate(${n} ${n})`;
|
|
95
|
+
let P;
|
|
96
|
+
t[3] !== l || t[4] !== o || t[5] !== S || t[6] !== n || t[7] !== e || t[8] !== r ? (P = o || r ? /* @__PURE__ */ a.jsx("foreignObject", { y: 0 - (n - e), x: 0 - (n - e), width: 2 * (n - e), height: 2 * (n - e), children: /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col gap-0.5 justify-center items-center h-inherit py-0 px-4", children: [
|
|
97
|
+
o ? lt(o) ? o : /* @__PURE__ */ a.jsx(gt, { marginBottom: "none", className: "donut-main-text text-primary-gray-700 dark:text-primary-gray-100 leading-none text-center", children: typeof o == "string" ? o : l.findIndex((u) => u.label === o.label) !== -1 ? ut(l[l.findIndex((u) => u.label === o.label)].size, "NA", S, o.prefix, o.suffix) : "NA" }) : null,
|
|
98
|
+
r ? /* @__PURE__ */ a.jsx(it, { marginBottom: "none", size: "base", leading: "none", className: "donut-sub-note text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold", children: r }) : typeof o == "string" || !o || lt(o) ? null : /* @__PURE__ */ a.jsx(it, { size: "base", marginBottom: "none", leading: "none", className: "donut-label text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold", children: o.label })
|
|
99
|
+
] }) }) : null, t[3] = l, t[4] = o, t[5] = S, t[6] = n, t[7] = e, t[8] = r, t[9] = P) : P = t[9];
|
|
100
|
+
const Z = n - e / 2;
|
|
101
101
|
let k;
|
|
102
|
-
t[10] !== e || t[11] !== Z || t[12] !==
|
|
103
|
-
const
|
|
104
|
-
let
|
|
105
|
-
t[14] !== d.duration || t[15] !== O || t[16] !== p || t[17] !== g || t[18] !== C || t[19] !== j || t[20] !== v || t[21] !== f || t[22] !== x || t[23] !==
|
|
102
|
+
t[10] !== e || t[11] !== Z || t[12] !== E ? (k = /* @__PURE__ */ a.jsx("circle", { cx: 0, cy: 0, r: Z, fill: "none", stroke: E, strokeWidth: e }), t[10] = e, t[11] = Z, t[12] = E, t[13] = k) : k = t[13];
|
|
103
|
+
const F = Nt;
|
|
104
|
+
let w;
|
|
105
|
+
t[14] !== d.duration || t[15] !== O || t[16] !== p || t[17] !== g || t[18] !== C || t[19] !== j || t[20] !== v || t[21] !== f || t[22] !== x || t[23] !== n || t[24] !== m || t[25] !== M || t[26] !== e ? (w = (u, mt) => /* @__PURE__ */ a.jsx(nt.path, { variants: {
|
|
106
106
|
initial: {
|
|
107
107
|
pathLength: 0,
|
|
108
|
-
d:
|
|
108
|
+
d: ct(0, 0, n - e / 2, u.startAngle - Math.PI / 2, u.endAngle - Math.PI / 2),
|
|
109
109
|
opacity: v ? v.label === u.data.label ? 1 : 0.3 : 1
|
|
110
110
|
},
|
|
111
111
|
whileInView: {
|
|
112
112
|
pathLength: 1,
|
|
113
|
-
d:
|
|
113
|
+
d: ct(0, 0, n - e / 2, u.startAngle - Math.PI / 2, u.endAngle - Math.PI / 2),
|
|
114
114
|
opacity: v ? v.label === u.data.label ? 1 : 0.3 : 1,
|
|
115
115
|
transition: {
|
|
116
116
|
duration: d.duration
|
|
@@ -126,49 +126,49 @@ function zt(s) {
|
|
|
126
126
|
strokeWidth: e,
|
|
127
127
|
fill: "none"
|
|
128
128
|
}, onMouseEnter: (_) => {
|
|
129
|
-
Y(u.data),
|
|
129
|
+
Y(u.data), R(_.clientY), q(_.clientX), x?.(u);
|
|
130
130
|
}, onClick: () => {
|
|
131
|
-
(f || g) && (
|
|
131
|
+
(f || g) && (yt(j, u.data) && m ? (M(void 0), f?.(void 0)) : (M(u.data), f && f(u.data)));
|
|
132
132
|
}, onMouseMove: (_) => {
|
|
133
|
-
Y(u.data),
|
|
133
|
+
Y(u.data), R(_.clientY), q(_.clientX);
|
|
134
134
|
}, onMouseLeave: () => {
|
|
135
|
-
Y(void 0),
|
|
136
|
-
} },
|
|
137
|
-
const i =
|
|
135
|
+
Y(void 0), q(void 0), R(void 0), x?.(void 0);
|
|
136
|
+
} }, mt), t[14] = d.duration, t[15] = O, t[16] = p, t[17] = g, t[18] = C, t[19] = j, t[20] = v, t[21] = f, t[22] = x, t[23] = n, t[24] = m, t[25] = M, t[26] = e, t[27] = w) : w = t[27];
|
|
137
|
+
const i = z(l).map(w);
|
|
138
138
|
let N;
|
|
139
|
-
t[28] !==
|
|
140
|
-
let
|
|
141
|
-
t[31] !== k || t[32] !== N || t[33] !==
|
|
142
|
-
|
|
139
|
+
t[28] !== F || t[29] !== i ? (N = /* @__PURE__ */ a.jsx(F, { children: i }), t[28] = F, t[29] = i, t[30] = N) : N = t[30];
|
|
140
|
+
let A;
|
|
141
|
+
t[31] !== k || t[32] !== N || t[33] !== B.g || t[34] !== U || t[35] !== P ? (A = /* @__PURE__ */ a.jsxs(B.g, { transform: U, children: [
|
|
142
|
+
P,
|
|
143
143
|
k,
|
|
144
144
|
N
|
|
145
|
-
] }), t[31] = k, t[32] = N, t[33] =
|
|
145
|
+
] }), t[31] = k, t[32] = N, t[33] = B.g, t[34] = U, t[35] = P, t[36] = A) : A = t[36];
|
|
146
146
|
let L;
|
|
147
|
-
t[37] !== J.svg || t[38] !==
|
|
147
|
+
t[37] !== J.svg || t[38] !== A || t[39] !== K || t[40] !== Q || t[41] !== D ? (L = /* @__PURE__ */ a.jsx(J.svg, { ref: G, width: K, height: Q, viewBox: D, direction: I, className: et, children: A }), t[37] = J.svg, t[38] = A, t[39] = K, t[40] = Q, t[41] = D, t[42] = L) : L = t[42];
|
|
148
148
|
let W;
|
|
149
|
-
t[43] !== y?.tooltip || t[44] !==
|
|
149
|
+
t[43] !== y?.tooltip || t[44] !== V || t[45] !== $ || t[46] !== v || t[47] !== b?.tooltip || t[48] !== s ? (W = v && s && V && $ ? /* @__PURE__ */ a.jsx(vt, { data: v, body: s, xPos: V, yPos: $, backgroundStyle: b?.tooltip, className: y?.tooltip }) : null, t[43] = y?.tooltip, t[44] = V, t[45] = $, t[46] = v, t[47] = b?.tooltip, t[48] = s, t[49] = W) : W = t[49];
|
|
150
150
|
let H;
|
|
151
|
-
t[50] !== y?.modal || t[51] !== g || t[52] !== j || t[53] !== M ? (H = g && j !== void 0 ? /* @__PURE__ */
|
|
151
|
+
t[50] !== y?.modal || t[51] !== g || t[52] !== j || t[53] !== M ? (H = g && j !== void 0 ? /* @__PURE__ */ a.jsx(bt, { body: g, data: j, setData: M, className: y?.modal }) : null, t[50] = y?.modal, t[51] = g, t[52] = j, t[53] = M, t[54] = H) : H = t[54];
|
|
152
152
|
let ot;
|
|
153
|
-
return t[55] !== L || t[56] !== W || t[57] !== H ? (ot = /* @__PURE__ */
|
|
153
|
+
return t[55] !== L || t[56] !== W || t[57] !== H ? (ot = /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
|
|
154
154
|
L,
|
|
155
155
|
W,
|
|
156
156
|
H
|
|
157
157
|
] }), t[55] = L, t[56] = W, t[57] = H, t[58] = ot) : ot = t[58], ot;
|
|
158
158
|
}
|
|
159
|
-
function It(
|
|
160
|
-
return
|
|
159
|
+
function It(c) {
|
|
160
|
+
return c.size;
|
|
161
161
|
}
|
|
162
|
-
function
|
|
162
|
+
function _t(c) {
|
|
163
163
|
const {
|
|
164
164
|
mainText: t,
|
|
165
165
|
graphTitle: o,
|
|
166
|
-
colors:
|
|
167
|
-
suffix:
|
|
166
|
+
colors: l = X.light.categoricalColors.colors,
|
|
167
|
+
suffix: n = "",
|
|
168
168
|
sources: p,
|
|
169
169
|
prefix: r = "",
|
|
170
170
|
strokeWidth: e = 50,
|
|
171
|
-
graphDescription:
|
|
171
|
+
graphDescription: s,
|
|
172
172
|
subNote: x,
|
|
173
173
|
footNote: f,
|
|
174
174
|
radius: O,
|
|
@@ -176,85 +176,85 @@ function Zt(s) {
|
|
|
176
176
|
showColorScale: g = !0,
|
|
177
177
|
padding: b,
|
|
178
178
|
backgroundColor: y = !1,
|
|
179
|
-
tooltip:
|
|
179
|
+
tooltip: S,
|
|
180
180
|
onSeriesMouseOver: d,
|
|
181
|
-
graphID:
|
|
181
|
+
graphID: E,
|
|
182
182
|
onSeriesMouseClick: G,
|
|
183
183
|
graphDownload: h = !1,
|
|
184
184
|
dataDownload: C = !1,
|
|
185
|
-
colorDomain:
|
|
185
|
+
colorDomain: z,
|
|
186
186
|
sortData: v,
|
|
187
187
|
language: Y = "en",
|
|
188
188
|
theme: j = "light",
|
|
189
189
|
width: M,
|
|
190
|
-
height:
|
|
191
|
-
minHeight:
|
|
192
|
-
relativeHeight:
|
|
193
|
-
ariaLabel:
|
|
190
|
+
height: V,
|
|
191
|
+
minHeight: q = 0,
|
|
192
|
+
relativeHeight: $,
|
|
193
|
+
ariaLabel: R,
|
|
194
194
|
resetSelectionOnDoubleClick: J = !0,
|
|
195
195
|
colorScaleMaxWidth: K,
|
|
196
196
|
detailsOnClick: Q,
|
|
197
197
|
styles: D,
|
|
198
|
-
classNames:
|
|
198
|
+
classNames: I,
|
|
199
199
|
precision: et = 2,
|
|
200
|
-
animate:
|
|
200
|
+
animate: B = !1,
|
|
201
201
|
trackColor: U = X.light.grays["gray-200"]
|
|
202
|
-
} =
|
|
203
|
-
|
|
202
|
+
} = c, [P, Z] = tt(0), k = rt(null), F = rt(null);
|
|
203
|
+
ft(() => {
|
|
204
204
|
const i = new ResizeObserver((N) => {
|
|
205
205
|
Z((Math.min(N[0].target.clientWidth || 620, N[0].target.clientHeight || 480) || 420) / 2);
|
|
206
206
|
});
|
|
207
207
|
return k.current && i.observe(k.current), () => i.disconnect();
|
|
208
208
|
}, []);
|
|
209
|
-
const
|
|
210
|
-
return /* @__PURE__ */
|
|
211
|
-
o ||
|
|
209
|
+
const w = v ? ht(m, ["size"], [v]) : m;
|
|
210
|
+
return /* @__PURE__ */ a.jsxs(wt, { className: I?.graphContainer, style: D?.graphContainer, id: E, ref: F, "aria-label": R, backgroundColor: y, theme: j, language: Y, minHeight: q, width: M, height: V, relativeHeight: $, padding: b, children: [
|
|
211
|
+
o || s || h || C ? /* @__PURE__ */ a.jsx(Dt, { styles: {
|
|
212
212
|
title: D?.title,
|
|
213
213
|
description: D?.description
|
|
214
214
|
}, classNames: {
|
|
215
|
-
title:
|
|
216
|
-
description:
|
|
217
|
-
}, graphTitle: o, graphDescription:
|
|
218
|
-
g && m.length > 0 ? /* @__PURE__ */
|
|
219
|
-
/* @__PURE__ */
|
|
215
|
+
title: I?.title,
|
|
216
|
+
description: I?.description
|
|
217
|
+
}, graphTitle: o, graphDescription: s, width: M, graphDownload: h ? F : void 0, dataDownload: C ? m.map((i) => i.data).filter((i) => i !== void 0).length > 0 ? m.map((i) => i.data).filter((i) => i !== void 0) : m.filter((i) => i !== void 0) : null }) : null,
|
|
218
|
+
g && m.length > 0 ? /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
|
|
219
|
+
/* @__PURE__ */ a.jsx("div", { className: pt("leading-0 flex mb-0 ml-auto mr-auto justify-center gap-x-3 gap-y-0 flex-wrap", I?.colorLegend), style: {
|
|
220
220
|
maxWidth: K
|
|
221
|
-
}, "aria-label": "Color legend", children:
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
-
backgroundColor: (
|
|
221
|
+
}, "aria-label": "Color legend", children: w.map((i, N) => /* @__PURE__ */ a.jsxs("div", { className: "flex gap-2 items-center pb-3", children: [
|
|
222
|
+
/* @__PURE__ */ a.jsx("div", { className: "w-3 h-3 rounded-full", style: {
|
|
223
|
+
backgroundColor: (z || w.map((A) => A.label)).indexOf(i.label) !== -1 ? (l || X[j].categoricalColors.colors)[(z || w.map((A) => A.label)).indexOf(i.label) % (l || X[j].categoricalColors.colors).length] : X.gray
|
|
224
224
|
} }),
|
|
225
|
-
/* @__PURE__ */
|
|
225
|
+
/* @__PURE__ */ a.jsxs(it, { marginBottom: "none", size: "sm", className: "text-primary-gray-700 dark:text-primary-gray-100", children: [
|
|
226
226
|
i.label,
|
|
227
227
|
":",
|
|
228
228
|
" ",
|
|
229
|
-
/* @__PURE__ */
|
|
229
|
+
/* @__PURE__ */ a.jsx("span", { className: "font-bold", style: {
|
|
230
230
|
fontSize: "inherit"
|
|
231
|
-
}, children:
|
|
231
|
+
}, children: ut(i.size, "NA", et, r, n) })
|
|
232
232
|
] })
|
|
233
233
|
] }, N)) }),
|
|
234
|
-
/* @__PURE__ */
|
|
234
|
+
/* @__PURE__ */ a.jsx(xt, { size: "lg" })
|
|
235
235
|
] }) : null,
|
|
236
|
-
/* @__PURE__ */
|
|
237
|
-
m.length === 0 && /* @__PURE__ */
|
|
238
|
-
|
|
236
|
+
/* @__PURE__ */ a.jsxs(At, { ref: k, children: [
|
|
237
|
+
m.length === 0 && /* @__PURE__ */ a.jsx(kt, {}),
|
|
238
|
+
P && m.length > 0 ? /* @__PURE__ */ a.jsx(Et, { mainText: t, data: w, colors: l, radius: O || P, subNote: x, strokeWidth: e, tooltip: S, colorDomain: z || w.map((i) => i.label), onSeriesMouseOver: d, onSeriesMouseClick: G, resetSelectionOnDoubleClick: J, styles: D, detailsOnClick: Q, precision: et, animate: B === !0 ? {
|
|
239
239
|
duration: 0.5,
|
|
240
240
|
once: !0,
|
|
241
241
|
amount: 0.5
|
|
242
|
-
} :
|
|
242
|
+
} : B || {
|
|
243
243
|
duration: 0,
|
|
244
244
|
once: !0,
|
|
245
245
|
amount: 0
|
|
246
246
|
}, trackColor: U }) : null
|
|
247
247
|
] }),
|
|
248
|
-
p || f ? /* @__PURE__ */
|
|
248
|
+
p || f ? /* @__PURE__ */ a.jsx(Ct, { styles: {
|
|
249
249
|
footnote: D?.footnote,
|
|
250
250
|
source: D?.source
|
|
251
251
|
}, classNames: {
|
|
252
|
-
footnote:
|
|
253
|
-
source:
|
|
252
|
+
footnote: I?.footnote,
|
|
253
|
+
source: I?.source
|
|
254
254
|
}, sources: p, footNote: f, width: M }) : null
|
|
255
255
|
] });
|
|
256
256
|
}
|
|
257
257
|
export {
|
|
258
|
-
|
|
258
|
+
_t as DonutChart
|
|
259
259
|
};
|
|
260
260
|
//# sourceMappingURL=DonutChart.js.map
|
package/dist/DonutChart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DonutChart.js","sources":["../node_modules/d3-shape/src/math.js","../node_modules/d3-shape/src/descending.js","../node_modules/d3-shape/src/identity.js","../node_modules/d3-shape/src/pie.js","../src/Utils/getArc.ts","../src/Components/Graphs/DonutChart/Graph.tsx","../src/Components/Graphs/DonutChart/index.tsx"],"sourcesContent":["export const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\n\nexport const epsilon = 1e-12;\nexport const pi = Math.PI;\nexport const halfPi = pi / 2;\nexport const tau = 2 * pi;\n\nexport function acos(x) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n","export default function(a, b) {\n return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;\n}\n","export default function(d) {\n return d;\n}\n","import array from \"./array.js\";\nimport constant from \"./constant.js\";\nimport descending from \"./descending.js\";\nimport identity from \"./identity.js\";\nimport {tau} from \"./math.js\";\n\nexport default function() {\n var value = identity,\n sortValues = descending,\n sort = null,\n startAngle = constant(0),\n endAngle = constant(tau),\n padAngle = constant(0);\n\n function pie(data) {\n var i,\n n = (data = array(data)).length,\n j,\n k,\n sum = 0,\n index = new Array(n),\n arcs = new Array(n),\n a0 = +startAngle.apply(this, arguments),\n da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)),\n a1,\n p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)),\n pa = p * (da < 0 ? -1 : 1),\n v;\n\n for (i = 0; i < n; ++i) {\n if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {\n sum += v;\n }\n }\n\n // Optionally sort the arcs by previously-computed values or by data.\n if (sortValues != null) index.sort(function(i, j) { return sortValues(arcs[i], arcs[j]); });\n else if (sort != null) index.sort(function(i, j) { return sort(data[i], data[j]); });\n\n // Compute the arcs! They are stored in the original data's order.\n for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {\n j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {\n data: data[j],\n index: i,\n value: v,\n startAngle: a0,\n endAngle: a1,\n padAngle: p\n };\n }\n\n return arcs;\n }\n\n pie.value = function(_) {\n return arguments.length ? (value = typeof _ === \"function\" ? _ : constant(+_), pie) : value;\n };\n\n pie.sortValues = function(_) {\n return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;\n };\n\n pie.sort = function(_) {\n return arguments.length ? (sort = _, sortValues = null, pie) : sort;\n };\n\n pie.startAngle = function(_) {\n return arguments.length ? (startAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : startAngle;\n };\n\n pie.endAngle = function(_) {\n return arguments.length ? (endAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : endAngle;\n };\n\n pie.padAngle = function(_) {\n return arguments.length ? (padAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : padAngle;\n };\n\n return pie;\n}\n","const polarToCartesian = (\r\n centerX: number,\r\n centerY: number,\r\n radius: number,\r\n angleInRadians: number,\r\n) => {\r\n return {\r\n x: centerX + radius * Math.cos(angleInRadians),\r\n y: centerY + radius * Math.sin(angleInRadians),\r\n };\r\n};\r\n\r\nexport function getArc(\r\n x: number,\r\n y: number,\r\n radius: number,\r\n startAngleInRadians: number,\r\n endAngleInRadians: number,\r\n) {\r\n const start = polarToCartesian(x, y, radius, startAngleInRadians);\r\n const end = polarToCartesian(\r\n x,\r\n y,\r\n radius,\r\n endAngleInRadians === 2 * Math.PI ? 1.9999999999 * Math.PI : endAngleInRadians,\r\n );\r\n const largeArcFlag = endAngleInRadians - startAngleInRadians <= Math.PI ? '0' : '1';\r\n const d = ['M', start.x, start.y, 'A', radius, radius, 0, largeArcFlag, 1, end.x, end.y].join(\r\n ' ',\r\n );\r\n return d;\r\n}\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport isEqual from 'fast-deep-equal';\r\nimport { pie } from 'd3-shape';\r\nimport { useRef, useState } from 'react';\r\nimport { H2, P } from '@undp/design-system-react/Typography';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport { AnimateDataType, ClassNameObject, DonutChartDataType, StyleObject } from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { DetailsModal } from '@/Components/Elements/DetailsModal';\r\nimport { getArc } from '@/Utils/getArc';\r\n\r\ninterface Props {\r\n mainText?: string | { label: string; suffix?: string; prefix?: string };\r\n radius: number;\r\n colors: string[];\r\n subNote?: string;\r\n strokeWidth: number;\r\n data: DonutChartDataType[];\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n onSeriesMouseOver?: (_d: any) => void;\r\n onSeriesMouseClick?: (_d: any) => void;\r\n colorDomain: string[];\r\n resetSelectionOnDoubleClick: boolean;\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n animate: AnimateDataType;\r\n trackColor: string;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n mainText,\r\n data,\r\n radius,\r\n colors,\r\n subNote,\r\n strokeWidth,\r\n tooltip,\r\n onSeriesMouseOver,\r\n onSeriesMouseClick,\r\n colorDomain,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision,\r\n animate,\r\n trackColor,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const pieData = pie()\r\n .sort(null)\r\n .startAngle(0)\r\n .value((d: any) => d.size);\r\n\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n return (\r\n <>\r\n <motion.svg\r\n ref={svgRef}\r\n width={`${radius * 2}px`}\r\n height={`${radius * 2}px`}\r\n viewBox={`0 0 ${radius * 2} ${radius * 2}`}\r\n direction='ltr'\r\n className='mx-auto'\r\n >\r\n <motion.g transform={`translate(${radius} ${radius})`}>\r\n {mainText || subNote ? (\r\n <foreignObject\r\n y={0 - (radius - strokeWidth)}\r\n x={0 - (radius - strokeWidth)}\r\n width={2 * (radius - strokeWidth)}\r\n height={2 * (radius - strokeWidth)}\r\n >\r\n <div className='flex flex-col gap-0.5 justify-center items-center h-inherit py-0 px-4'>\r\n {mainText ? (\r\n <H2\r\n marginBottom='none'\r\n className='donut-main-text text-primary-gray-700 dark:text-primary-gray-100 leading-none text-center'\r\n >\r\n {typeof mainText === 'string'\r\n ? mainText\r\n : data.findIndex(d => d.label === mainText.label) !== -1\r\n ? numberFormattingFunction(\r\n data[data.findIndex(d => d.label === mainText.label)].size,\r\n 'NA',\r\n precision,\r\n mainText.prefix,\r\n mainText.suffix,\r\n )\r\n : 'NA'}\r\n </H2>\r\n ) : null}\r\n {subNote ? (\r\n <P\r\n marginBottom='none'\r\n size='base'\r\n leading='none'\r\n className='donut-sub-note text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold'\r\n >\r\n {subNote}\r\n </P>\r\n ) : typeof mainText === 'string' || !mainText ? null : (\r\n <P\r\n size='base'\r\n marginBottom='none'\r\n leading='none'\r\n className='donut-label text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold'\r\n >\r\n {mainText.label}\r\n </P>\r\n )}\r\n </div>\r\n </foreignObject>\r\n ) : null}\r\n <circle\r\n cx={0}\r\n cy={0}\r\n r={radius - strokeWidth / 2}\r\n fill='none'\r\n stroke={trackColor}\r\n strokeWidth={strokeWidth}\r\n />\r\n <AnimatePresence>\r\n {pieData(data as any).map((d, i) => (\r\n <motion.path\r\n key={i}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n d: getArc(\r\n 0,\r\n 0,\r\n radius - strokeWidth / 2,\r\n d.startAngle - Math.PI / 2,\r\n d.endAngle - Math.PI / 2,\r\n ),\r\n opacity: mouseOverData\r\n ? mouseOverData.label === (d.data as any).label\r\n ? 1\r\n : 0.3\r\n : 1,\r\n },\r\n whileInView: {\r\n pathLength: 1,\r\n d: getArc(\r\n 0,\r\n 0,\r\n radius - strokeWidth / 2,\r\n d.startAngle - Math.PI / 2,\r\n d.endAngle - Math.PI / 2,\r\n ),\r\n opacity: mouseOverData\r\n ? mouseOverData.label === (d.data as any).label\r\n ? 1\r\n : 0.3\r\n : 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n stroke:\r\n colorDomain.indexOf((d.data as any).label) !== -1\r\n ? colors[colorDomain.indexOf((d.data as any).label) % colors.length]\r\n : Colors.gray,\r\n strokeWidth,\r\n fill: 'none',\r\n }}\r\n onMouseEnter={event => {\r\n setMouseOverData(d.data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d.data) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d.data);\r\n if (onSeriesMouseClick) onSeriesMouseClick(d.data);\r\n }\r\n }\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d.data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n />\r\n ))}\r\n </AnimatePresence>\r\n </motion.g>\r\n </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n {detailsOnClick && mouseClickData !== undefined ? (\r\n <DetailsModal\r\n body={detailsOnClick}\r\n data={mouseClickData}\r\n setData={setMouseClickData}\r\n className={classNames?.modal}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useEffect, useRef, useState } from 'react';\r\nimport { P } from '@undp/design-system-react/Typography';\r\nimport orderBy from 'lodash.orderby';\r\nimport { Spacer } from '@undp/design-system-react/Spacer';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n DonutChartDataType,\r\n Languages,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\nimport { GraphArea, GraphContainer } from '@/Components/Elements/GraphContainer';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: DonutChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Array of colors for each segment */\r\n colors?: string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: string[];\r\n /** Background color of the graph */\r\n backgroundColor?: string | boolean;\r\n /** Custom styles for the graph. Each object should be a valid React CSS style object. */\r\n styles?: StyleObject;\r\n /** Custom class names */\r\n classNames?: ClassNameObject;\r\n\r\n // Size and Spacing\r\n /** Width of the graph */\r\n width?: number;\r\n /** Height of the graph */\r\n height?: number;\r\n /** Minimum height of the graph */\r\n minHeight?: number;\r\n /** Relative height scaling factor. This overwrites the height props */\r\n relativeHeight?: number;\r\n /** Padding around the graph. Defaults to 0 if no backgroundColor is mentioned else defaults to 1rem */\r\n padding?: string;\r\n /** Radius of the donut chart */\r\n radius?: number;\r\n\r\n // Values and Ticks\r\n /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Max width of the color scale as a css property */\r\n colorScaleMaxWidth?: string;\r\n /** Stroke width of the arcs and circle of the donut */\r\n strokeWidth?: number;\r\n /** Sorting order for data. This is overwritten by labelOrder prop */\r\n sortData?: 'asc' | 'desc';\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Large text at the center of the donut chart. If the type is an object then the text is the value in the data for the label mentioned in the object */\r\n mainText?: string | { label: string; suffix?: string; prefix?: string };\r\n /** Small text at the center of the donut chart */\r\n subNote?: string;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\r\n /** Track color (i.e. the color of the donut chart's background) of the donut chart */\r\n trackColor?: string;\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n /** Reset selection on double-click. Only applicable when used in a dashboard context with filters. */\r\n resetSelectionOnDoubleClick?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Details displayed on the modal when user clicks of a data point. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n /** Callback for mouse click event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function DonutChart(props: Props) {\r\n const {\r\n mainText,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n suffix = '',\r\n sources,\r\n prefix = '',\r\n strokeWidth = 50,\r\n graphDescription,\r\n subNote,\r\n footNote,\r\n radius,\r\n data,\r\n showColorScale = true,\r\n padding,\r\n backgroundColor = false,\r\n tooltip,\r\n onSeriesMouseOver,\r\n graphID,\r\n onSeriesMouseClick,\r\n graphDownload = false,\r\n dataDownload = false,\r\n colorDomain,\r\n sortData,\r\n language = 'en',\r\n theme = 'light',\r\n width,\r\n height,\r\n minHeight = 0,\r\n relativeHeight,\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n colorScaleMaxWidth,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision = 2,\r\n animate = false,\r\n trackColor = Colors.light.grays['gray-200'],\r\n } = props;\r\n\r\n const [graphRadius, setGraphRadius] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setGraphRadius(\r\n (Math.min(\r\n ...[entries[0].target.clientWidth || 620, entries[0].target.clientHeight || 480],\r\n ) || 420) / 2,\r\n );\r\n });\r\n if (graphDiv.current) {\r\n resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, []);\r\n\r\n const sortedData = sortData ? orderBy(data, ['size'], [sortData]) : data;\r\n\r\n return (\r\n <GraphContainer\r\n className={classNames?.graphContainer}\r\n style={styles?.graphContainer}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={ariaLabel}\r\n backgroundColor={backgroundColor}\r\n theme={theme}\r\n language={language}\r\n minHeight={minHeight}\r\n width={width}\r\n height={height}\r\n relativeHeight={relativeHeight}\r\n padding={padding}\r\n >\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n {showColorScale && data.length > 0 ? (\r\n <>\r\n <div\r\n className={cn(\r\n 'leading-0 flex mb-0 ml-auto mr-auto justify-center gap-x-3 gap-y-0 flex-wrap',\r\n classNames?.colorLegend,\r\n )}\r\n style={{ maxWidth: colorScaleMaxWidth }}\r\n aria-label='Color legend'\r\n >\r\n {sortedData.map((d, i) => (\r\n <div className='flex gap-2 items-center pb-3' key={i}>\r\n <div\r\n className='w-3 h-3 rounded-full'\r\n style={{\r\n backgroundColor:\r\n (colorDomain || sortedData.map(el => el.label)).indexOf(d.label) !== -1\r\n ? (colors || Colors[theme].categoricalColors.colors)[\r\n (colorDomain || sortedData.map(el => el.label)).indexOf(d.label) %\r\n (colors || Colors[theme].categoricalColors.colors).length\r\n ]\r\n : Colors.gray,\r\n }}\r\n />\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n className='text-primary-gray-700 dark:text-primary-gray-100'\r\n >\r\n {d.label}:{' '}\r\n <span className='font-bold' style={{ fontSize: 'inherit' }}>\r\n {numberFormattingFunction(d.size, 'NA', precision, prefix, suffix)}\r\n </span>\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n <Spacer size='lg' />\r\n </>\r\n ) : null}\r\n <GraphArea ref={graphDiv}>\r\n {data.length === 0 && <EmptyState />}\r\n {graphRadius && data.length > 0 ? (\r\n <Graph\r\n mainText={mainText}\r\n data={sortedData}\r\n colors={colors}\r\n radius={radius || graphRadius}\r\n subNote={subNote}\r\n strokeWidth={strokeWidth}\r\n tooltip={tooltip}\r\n colorDomain={colorDomain || sortedData.map(d => d.label)}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n styles={styles}\r\n detailsOnClick={detailsOnClick}\r\n precision={precision}\r\n animate={\r\n animate === true\r\n ? { duration: 0.5, once: true, amount: 0.5 }\r\n : animate || { duration: 0, once: true, amount: 0 }\r\n }\r\n trackColor={trackColor}\r\n />\r\n ) : null}\r\n </GraphArea>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </GraphContainer>\r\n );\r\n}\r\n"],"names":["pi","tau","descending","a","b","identity","d","pie","value","sortValues","sort","startAngle","constant","endAngle","padAngle","data","i","n","array","j","k","sum","index","arcs","a0","da","a1","p","pa","v","_","polarToCartesian","centerX","centerY","radius","angleInRadians","x","Math","cos","y","sin","getArc","startAngleInRadians","endAngleInRadians","start","end","PI","largeArcFlag","join","Graph","props","$","_c","mainText","colors","subNote","strokeWidth","tooltip","onSeriesMouseOver","onSeriesMouseClick","colorDomain","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","precision","animate","trackColor","svgRef","useRef","t0","amount","once","isInView","useInView","pieData","_temp","mouseOverData","setMouseOverData","useState","undefined","mouseClickData","setMouseClickData","eventX","setEventX","eventY","setEventY","t1","motion","t2","t3","t4","t5","t6","t7","t8","t9","jsx","jsxs","H2","findIndex","d_1","label","numberFormattingFunction","d_0","size","prefix","suffix","P","t10","t11","T0","AnimatePresence","t12","duration","d_2","initial","pathLength","opacity","whileInView","transition","stroke","indexOf","length","Colors","gray","fill","event","clientY","clientX","isEqual","event_0","t13","map","t14","t15","g","t16","svg","t17","Tooltip","t18","modal","DetailsModal","t19","Fragment","DonutChart","graphTitle","light","categoricalColors","sources","graphDescription","footNote","showColorScale","padding","backgroundColor","graphID","graphDownload","dataDownload","sortData","language","theme","width","height","minHeight","relativeHeight","ariaLabel","colorScaleMaxWidth","grays","graphRadius","setGraphRadius","graphDiv","graphParentDiv","useEffect","resizeObserver","ResizeObserver","entries","min","target","clientWidth","clientHeight","current","observe","disconnect","sortedData","orderBy","GraphContainer","graphContainer","GraphHeader","title","description","filter","cn","colorLegend","maxWidth","el","fontSize","Spacer","GraphArea","EmptyState","GraphFooter","footnote","source"],"mappings":";;;;;;;;;;;;;;;;;;AASO,MAAMA,KAAK,KAAK,IAEVC,KAAM,IAAID;ACXR,SAAAE,GAASC,GAAGC,GAAG;AAC5B,SAAOA,IAAID,IAAI,KAAKC,IAAID,IAAI,IAAIC,KAAKD,IAAI,IAAI;AAC/C;ACFe,SAAAE,GAASC,GAAG;AACzB,SAAOA;AACT;ACIe,SAAAC,KAAW;AACxB,MAAIC,IAAQH,IACRI,IAAaP,IACbQ,IAAO,MACPC,IAAaC,EAAS,CAAC,GACvBC,IAAWD,EAASX,EAAG,GACvBa,IAAWF,EAAS,CAAC;AAEzB,WAASL,EAAIQ,GAAM;AACjB,QAAIC,GACAC,KAAKF,IAAOG,GAAMH,CAAI,GAAG,QACzBI,GACAC,GACAC,IAAM,GACNC,IAAQ,IAAI,MAAML,CAAC,GACnBM,IAAO,IAAI,MAAMN,CAAC,GAClBO,IAAK,CAACb,EAAW,MAAM,MAAM,SAAS,GACtCc,IAAK,KAAK,IAAIxB,IAAK,KAAK,IAAI,CAACA,IAAKY,EAAS,MAAM,MAAM,SAAS,IAAIW,CAAE,CAAC,GACvEE,GACAC,IAAI,KAAK,IAAI,KAAK,IAAIF,CAA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AAK1B,gBAAAA,EAAAA,IAACsG,IAAA,CAAA,CAAU;AAAA,MAChC9B,KAAe1J,EAAK4G,SAAS,0BAC3B1E,IAAA,EACC,UAAAI,GACA,MAAMmI,GACN,QAAAlI,GACA,QAAQpB,KAAUuI,GAClB,SAAAlH,GACA,aAAAC,GACA,SAAAC,GACA,aAAaG,KAAe4H,EAAWnD,IAAI/H,CAAAA,MAAKA,EAAEgG,KAAK,GACvD,mBAAA5C,GACA,oBAAAC,GACA,6BAAAE,GACA,QAAAE,GACA,gBAAAD,GACA,WAAAG,IACA,SACEC,MAAY,KACR;AAAA,QAAEgD,UAAU;AAAA,QAAK1C,MAAM;AAAA,QAAMD,QAAQ;AAAA,MAAA,IACrCL,KAAW;AAAA,QAAEgD,UAAU;AAAA,QAAG1C,MAAM;AAAA,QAAMD,QAAQ;AAAA,MAAA,GAEpD,YAAAJ,GAAuB,IAEvB;AAAA,IAAA,GACN;AAAA,IACCmF,KAAWE,IACVvD,gBAAAA,EAAAA,IAACuG,IAAA,EACC,QAAQ;AAAA,MAAEC,UAAU1I,GAAQ0I;AAAAA,MAAUC,QAAQ3I,GAAQ2I;AAAAA,IAAAA,GACtD,YAAY;AAAA,MACVD,UAAUzI,GAAYyI;AAAAA,MACtBC,QAAQ1I,GAAY0I;AAAAA,IAAAA,GAEtB,SAAApD,GACA,UAAAE,GACA,OAAAU,EAAA,CAAa,IAEb;AAAA,EAAA,GACN;AAEJ;","x_google_ignoreList":[0,1,2,3]}
|
|
1
|
+
{"version":3,"file":"DonutChart.js","sources":["../node_modules/d3-shape/src/math.js","../node_modules/d3-shape/src/descending.js","../node_modules/d3-shape/src/identity.js","../node_modules/d3-shape/src/pie.js","../src/Utils/getArc.ts","../src/Components/Graphs/DonutChart/Graph.tsx","../src/Components/Graphs/DonutChart/index.tsx"],"sourcesContent":["export const abs = Math.abs;\nexport const atan2 = Math.atan2;\nexport const cos = Math.cos;\nexport const max = Math.max;\nexport const min = Math.min;\nexport const sin = Math.sin;\nexport const sqrt = Math.sqrt;\n\nexport const epsilon = 1e-12;\nexport const pi = Math.PI;\nexport const halfPi = pi / 2;\nexport const tau = 2 * pi;\n\nexport function acos(x) {\n return x > 1 ? 0 : x < -1 ? pi : Math.acos(x);\n}\n\nexport function asin(x) {\n return x >= 1 ? halfPi : x <= -1 ? -halfPi : Math.asin(x);\n}\n","export default function(a, b) {\n return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;\n}\n","export default function(d) {\n return d;\n}\n","import array from \"./array.js\";\nimport constant from \"./constant.js\";\nimport descending from \"./descending.js\";\nimport identity from \"./identity.js\";\nimport {tau} from \"./math.js\";\n\nexport default function() {\n var value = identity,\n sortValues = descending,\n sort = null,\n startAngle = constant(0),\n endAngle = constant(tau),\n padAngle = constant(0);\n\n function pie(data) {\n var i,\n n = (data = array(data)).length,\n j,\n k,\n sum = 0,\n index = new Array(n),\n arcs = new Array(n),\n a0 = +startAngle.apply(this, arguments),\n da = Math.min(tau, Math.max(-tau, endAngle.apply(this, arguments) - a0)),\n a1,\n p = Math.min(Math.abs(da) / n, padAngle.apply(this, arguments)),\n pa = p * (da < 0 ? -1 : 1),\n v;\n\n for (i = 0; i < n; ++i) {\n if ((v = arcs[index[i] = i] = +value(data[i], i, data)) > 0) {\n sum += v;\n }\n }\n\n // Optionally sort the arcs by previously-computed values or by data.\n if (sortValues != null) index.sort(function(i, j) { return sortValues(arcs[i], arcs[j]); });\n else if (sort != null) index.sort(function(i, j) { return sort(data[i], data[j]); });\n\n // Compute the arcs! They are stored in the original data's order.\n for (i = 0, k = sum ? (da - n * pa) / sum : 0; i < n; ++i, a0 = a1) {\n j = index[i], v = arcs[j], a1 = a0 + (v > 0 ? v * k : 0) + pa, arcs[j] = {\n data: data[j],\n index: i,\n value: v,\n startAngle: a0,\n endAngle: a1,\n padAngle: p\n };\n }\n\n return arcs;\n }\n\n pie.value = function(_) {\n return arguments.length ? (value = typeof _ === \"function\" ? _ : constant(+_), pie) : value;\n };\n\n pie.sortValues = function(_) {\n return arguments.length ? (sortValues = _, sort = null, pie) : sortValues;\n };\n\n pie.sort = function(_) {\n return arguments.length ? (sort = _, sortValues = null, pie) : sort;\n };\n\n pie.startAngle = function(_) {\n return arguments.length ? (startAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : startAngle;\n };\n\n pie.endAngle = function(_) {\n return arguments.length ? (endAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : endAngle;\n };\n\n pie.padAngle = function(_) {\n return arguments.length ? (padAngle = typeof _ === \"function\" ? _ : constant(+_), pie) : padAngle;\n };\n\n return pie;\n}\n","const polarToCartesian = (\r\n centerX: number,\r\n centerY: number,\r\n radius: number,\r\n angleInRadians: number,\r\n) => {\r\n return {\r\n x: centerX + radius * Math.cos(angleInRadians),\r\n y: centerY + radius * Math.sin(angleInRadians),\r\n };\r\n};\r\n\r\nexport function getArc(\r\n x: number,\r\n y: number,\r\n radius: number,\r\n startAngleInRadians: number,\r\n endAngleInRadians: number,\r\n) {\r\n const start = polarToCartesian(x, y, radius, startAngleInRadians);\r\n const end = polarToCartesian(\r\n x,\r\n y,\r\n radius,\r\n Math.abs(endAngleInRadians - startAngleInRadians) === 2 * Math.PI\r\n ? 0.999999 * endAngleInRadians\r\n : endAngleInRadians,\r\n );\r\n const largeArcFlag = endAngleInRadians - startAngleInRadians <= Math.PI ? '0' : '1';\r\n const d = ['M', start.x, start.y, 'A', radius, radius, 0, largeArcFlag, 1, end.x, end.y].join(\r\n ' ',\r\n );\r\n return d;\r\n}\r\n","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport isEqual from 'fast-deep-equal';\r\nimport { pie } from 'd3-shape';\r\nimport { isValidElement, ReactElement, useRef, useState } from 'react';\r\nimport { H2, P } from '@undp/design-system-react/Typography';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport { AnimateDataType, ClassNameObject, DonutChartDataType, StyleObject } from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { DetailsModal } from '@/Components/Elements/DetailsModal';\r\nimport { getArc } from '@/Utils/getArc';\r\n\r\ninterface Props {\r\n mainText?: string | { label: string; suffix?: string; prefix?: string } | ReactElement;\r\n radius: number;\r\n colors: string[];\r\n subNote?: string;\r\n strokeWidth: number;\r\n data: DonutChartDataType[];\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n onSeriesMouseOver?: (_d: any) => void;\r\n onSeriesMouseClick?: (_d: any) => void;\r\n colorDomain: string[];\r\n resetSelectionOnDoubleClick: boolean;\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n animate: AnimateDataType;\r\n trackColor: string;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n mainText,\r\n data,\r\n radius,\r\n colors,\r\n subNote,\r\n strokeWidth,\r\n tooltip,\r\n onSeriesMouseOver,\r\n onSeriesMouseClick,\r\n colorDomain,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision,\r\n animate,\r\n trackColor,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const pieData = pie()\r\n .sort(null)\r\n .startAngle(0)\r\n .value((d: any) => d.size);\r\n\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n return (\r\n <>\r\n <motion.svg\r\n ref={svgRef}\r\n width={`${radius * 2}px`}\r\n height={`${radius * 2}px`}\r\n viewBox={`0 0 ${radius * 2} ${radius * 2}`}\r\n direction='ltr'\r\n className='mx-auto'\r\n >\r\n <motion.g transform={`translate(${radius} ${radius})`}>\r\n {mainText || subNote ? (\r\n <foreignObject\r\n y={0 - (radius - strokeWidth)}\r\n x={0 - (radius - strokeWidth)}\r\n width={2 * (radius - strokeWidth)}\r\n height={2 * (radius - strokeWidth)}\r\n >\r\n <div className='flex flex-col gap-0.5 justify-center items-center h-inherit py-0 px-4'>\r\n {mainText ? (\r\n isValidElement(mainText) ? (\r\n mainText\r\n ) : (\r\n <H2\r\n marginBottom='none'\r\n className='donut-main-text text-primary-gray-700 dark:text-primary-gray-100 leading-none text-center'\r\n >\r\n {typeof mainText === 'string'\r\n ? mainText\r\n : data.findIndex(d => d.label === mainText.label) !== -1\r\n ? numberFormattingFunction(\r\n data[data.findIndex(d => d.label === mainText.label)].size,\r\n 'NA',\r\n precision,\r\n mainText.prefix,\r\n mainText.suffix,\r\n )\r\n : 'NA'}\r\n </H2>\r\n )\r\n ) : null}\r\n {subNote ? (\r\n <P\r\n marginBottom='none'\r\n size='base'\r\n leading='none'\r\n className='donut-sub-note text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold'\r\n >\r\n {subNote}\r\n </P>\r\n ) : typeof mainText === 'string' || !mainText || isValidElement(mainText) ? null : (\r\n <P\r\n size='base'\r\n marginBottom='none'\r\n leading='none'\r\n className='donut-label text-primary-gray-700 dark:text-primary-gray-100 text-center font-bold'\r\n >\r\n {mainText.label}\r\n </P>\r\n )}\r\n </div>\r\n </foreignObject>\r\n ) : null}\r\n <circle\r\n cx={0}\r\n cy={0}\r\n r={radius - strokeWidth / 2}\r\n fill='none'\r\n stroke={trackColor}\r\n strokeWidth={strokeWidth}\r\n />\r\n <AnimatePresence>\r\n {pieData(data as any).map((d, i) => (\r\n <motion.path\r\n key={i}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n d: getArc(\r\n 0,\r\n 0,\r\n radius - strokeWidth / 2,\r\n d.startAngle - Math.PI / 2,\r\n d.endAngle - Math.PI / 2,\r\n ),\r\n opacity: mouseOverData\r\n ? mouseOverData.label === (d.data as any).label\r\n ? 1\r\n : 0.3\r\n : 1,\r\n },\r\n whileInView: {\r\n pathLength: 1,\r\n d: getArc(\r\n 0,\r\n 0,\r\n radius - strokeWidth / 2,\r\n d.startAngle - Math.PI / 2,\r\n d.endAngle - Math.PI / 2,\r\n ),\r\n opacity: mouseOverData\r\n ? mouseOverData.label === (d.data as any).label\r\n ? 1\r\n : 0.3\r\n : 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n stroke:\r\n colorDomain.indexOf((d.data as any).label) !== -1\r\n ? colors[colorDomain.indexOf((d.data as any).label) % colors.length]\r\n : Colors.gray,\r\n strokeWidth,\r\n fill: 'none',\r\n }}\r\n onMouseEnter={event => {\r\n setMouseOverData(d.data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d.data) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d.data);\r\n if (onSeriesMouseClick) onSeriesMouseClick(d.data);\r\n }\r\n }\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d.data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n />\r\n ))}\r\n </AnimatePresence>\r\n </motion.g>\r\n </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n {detailsOnClick && mouseClickData !== undefined ? (\r\n <DetailsModal\r\n body={detailsOnClick}\r\n data={mouseClickData}\r\n setData={setMouseClickData}\r\n className={classNames?.modal}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { ReactElement, useEffect, useRef, useState } from 'react';\r\nimport { P } from '@undp/design-system-react/Typography';\r\nimport orderBy from 'lodash.orderby';\r\nimport { Spacer } from '@undp/design-system-react/Spacer';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n DonutChartDataType,\r\n Languages,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\nimport { GraphArea, GraphContainer } from '@/Components/Elements/GraphContainer';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: DonutChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Array of colors for each segment */\r\n colors?: string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: string[];\r\n /** Background color of the graph */\r\n backgroundColor?: string | boolean;\r\n /** Custom styles for the graph. Each object should be a valid React CSS style object. */\r\n styles?: StyleObject;\r\n /** Custom class names */\r\n classNames?: ClassNameObject;\r\n\r\n // Size and Spacing\r\n /** Width of the graph */\r\n width?: number;\r\n /** Height of the graph */\r\n height?: number;\r\n /** Minimum height of the graph */\r\n minHeight?: number;\r\n /** Relative height scaling factor. This overwrites the height props */\r\n relativeHeight?: number;\r\n /** Padding around the graph. Defaults to 0 if no backgroundColor is mentioned else defaults to 1rem */\r\n padding?: string;\r\n /** Radius of the donut chart */\r\n radius?: number;\r\n\r\n // Values and Ticks\r\n /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Max width of the color scale as a css property */\r\n colorScaleMaxWidth?: string;\r\n /** Stroke width of the arcs and circle of the donut */\r\n strokeWidth?: number;\r\n /** Sorting order for data. This is overwritten by labelOrder prop */\r\n sortData?: 'asc' | 'desc';\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Large text at the center of the donut chart. If the type is an object then the text is the value in the data for the label mentioned in the object */\r\n mainText?: string | { label: string; suffix?: string; prefix?: string } | ReactElement;\r\n /** Small text at the center of the donut chart */\r\n subNote?: string;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\r\n /** Track color (i.e. the color of the donut chart's background) of the donut chart */\r\n trackColor?: string;\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n /** Reset selection on double-click. Only applicable when used in a dashboard context with filters. */\r\n resetSelectionOnDoubleClick?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Details displayed on the modal when user clicks of a data point. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n /** Callback for mouse click event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function DonutChart(props: Props) {\r\n const {\r\n mainText,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n suffix = '',\r\n sources,\r\n prefix = '',\r\n strokeWidth = 50,\r\n graphDescription,\r\n subNote,\r\n footNote,\r\n radius,\r\n data,\r\n showColorScale = true,\r\n padding,\r\n backgroundColor = false,\r\n tooltip,\r\n onSeriesMouseOver,\r\n graphID,\r\n onSeriesMouseClick,\r\n graphDownload = false,\r\n dataDownload = false,\r\n colorDomain,\r\n sortData,\r\n language = 'en',\r\n theme = 'light',\r\n width,\r\n height,\r\n minHeight = 0,\r\n relativeHeight,\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n colorScaleMaxWidth,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision = 2,\r\n animate = false,\r\n trackColor = Colors.light.grays['gray-200'],\r\n } = props;\r\n\r\n const [graphRadius, setGraphRadius] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setGraphRadius(\r\n (Math.min(\r\n ...[entries[0].target.clientWidth || 620, entries[0].target.clientHeight || 480],\r\n ) || 420) / 2,\r\n );\r\n });\r\n if (graphDiv.current) {\r\n resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, []);\r\n\r\n const sortedData = sortData ? orderBy(data, ['size'], [sortData]) : data;\r\n\r\n return (\r\n <GraphContainer\r\n className={classNames?.graphContainer}\r\n style={styles?.graphContainer}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={ariaLabel}\r\n backgroundColor={backgroundColor}\r\n theme={theme}\r\n language={language}\r\n minHeight={minHeight}\r\n width={width}\r\n height={height}\r\n relativeHeight={relativeHeight}\r\n padding={padding}\r\n >\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n {showColorScale && data.length > 0 ? (\r\n <>\r\n <div\r\n className={cn(\r\n 'leading-0 flex mb-0 ml-auto mr-auto justify-center gap-x-3 gap-y-0 flex-wrap',\r\n classNames?.colorLegend,\r\n )}\r\n style={{ maxWidth: colorScaleMaxWidth }}\r\n aria-label='Color legend'\r\n >\r\n {sortedData.map((d, i) => (\r\n <div className='flex gap-2 items-center pb-3' key={i}>\r\n <div\r\n className='w-3 h-3 rounded-full'\r\n style={{\r\n backgroundColor:\r\n (colorDomain || sortedData.map(el => el.label)).indexOf(d.label) !== -1\r\n ? (colors || Colors[theme].categoricalColors.colors)[\r\n (colorDomain || sortedData.map(el => el.label)).indexOf(d.label) %\r\n (colors || Colors[theme].categoricalColors.colors).length\r\n ]\r\n : Colors.gray,\r\n }}\r\n />\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n className='text-primary-gray-700 dark:text-primary-gray-100'\r\n >\r\n {d.label}:{' '}\r\n <span className='font-bold' style={{ fontSize: 'inherit' }}>\r\n {numberFormattingFunction(d.size, 'NA', precision, prefix, suffix)}\r\n </span>\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n <Spacer size='lg' />\r\n </>\r\n ) : null}\r\n <GraphArea ref={graphDiv}>\r\n {data.length === 0 && <EmptyState />}\r\n {graphRadius && data.length > 0 ? (\r\n <Graph\r\n mainText={mainText}\r\n data={sortedData}\r\n colors={colors}\r\n radius={radius || graphRadius}\r\n subNote={subNote}\r\n strokeWidth={strokeWidth}\r\n tooltip={tooltip}\r\n colorDomain={colorDomain || sortedData.map(d => d.label)}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n styles={styles}\r\n detailsOnClick={detailsOnClick}\r\n precision={precision}\r\n animate={\r\n animate === true\r\n ? { duration: 0.5, once: true, amount: 0.5 }\r\n : animate || { duration: 0, once: true, amount: 0 }\r\n }\r\n trackColor={trackColor}\r\n />\r\n ) : null}\r\n </GraphArea>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </GraphContainer>\r\n );\r\n}\r\n"],"names":["pi","tau","descending","a","b","identity","d","pie","value","sortValues","sort","startAngle","constant","endAngle","padAngle","data","i","n","array","j","k","sum","index","arcs","a0","da","a1","p","pa","v","_","polarToCartesian","centerX","centerY","radius","angleInRadians","x","Math","cos","y","sin","getArc","startAngleInRadians","endAngleInRadians","start","end","abs","PI","largeArcFlag","join","Graph","props","$","_c","mainText","colors","subNote","strokeWidth","tooltip","onSeriesMouseOver","onSeriesMouseClick","colorDomain","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","precision","animate","trackColor","svgRef","useRef","t0","amount","once","isInView","useInView","pieData","_temp","mouseOverData","setMouseOverData","useState","undefined","mouseClickData","setMouseClickData","eventX","setEventX","eventY","setEventY","t1","motion","t2","t3","t4","t5","t6","t7","t8","t9","jsx","jsxs","isValidElement","H2","findIndex","d_1","label","numberFormattingFunction","d_0","size","prefix","suffix","P","t10","t11","T0","AnimatePresence","t12","duration","d_2","initial","pathLength","opacity","whileInView","transition","stroke","indexOf","length","Colors","gray","fill","event","clientY","clientX","isEqual","event_0","t13","map","t14","t15","g","t16","svg","t17","Tooltip","t18","modal","DetailsModal","t19","Fragment","DonutChart","graphTitle","light","categoricalColors","sources","graphDescription","footNote","showColorScale","padding","backgroundColor","graphID","graphDownload","dataDownload","sortData","language","theme","width","height","minHeight","relativeHeight","ariaLabel","colorScaleMaxWidth","grays","graphRadius","setGraphRadius","graphDiv","graphParentDiv","useEffect","resizeObserver","ResizeObserver","entries","min","target","clientWidth","clientHeight","current","observe","disconnect","sortedData","orderBy","GraphContainer","graphContainer","GraphHeader","title","description","filter","cn","colorLegend","maxWidth","el","fontSize","Spacer","GraphArea","EmptyState","GraphFooter","footnote","source"],"mappings":";;;;;;;;;;;;;;;;;;AASO,MAAMA,KAAK,KAAK,IAEVC,KAAM,IAAID;ACXR,SAAAE,GAASC,GAAGC,GAAG;AAC5B,SAAOA,IAAID,IAAI,KAAKC,IAAID,IAAI,IAAIC,KAAKD,IAAI,IAAI;AAC/C;ACFe,SAAAE,GAASC,GAAG;AACzB,SAAOA;AACT;ACIe,SAAAC,KAAW;AACxB,MAAIC,IAAQH,IACRI,IAAaP,IACbQ,IAAO,MACPC,IAAaC,EAAS,CAAC,GACvBC,IAAWD,EAASX,EAAG,GACvBa,IAAWF,EAAS,CAAC;AAEzB,WAASL,EAAIQ,GAAM;AACjB,QAAIC,GACAC,KAAKF,IAAOG,GAAMH,CAAI,GAAG,QACzBI,GACAC,GACAC,IAAM,GACNC,IAAQ,IAAI,MAAML,CAAC,GACnBM,IAAO,IAAI,MAAMN,CAAC,GAClBO,IAAK,CAACb,EAAW,MA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import { MultiPolygon } from 'geojson';
|
|
7
7
|
import { Polygon } from 'geojson';
|
|
8
8
|
import { Position as Position_2 } from 'geojson';
|
|
9
|
+
import { ReactElement } from 'react';
|
|
9
10
|
import { RefObject } from 'react';
|
|
10
11
|
import * as THREE from 'three';
|
|
11
12
|
|
|
@@ -6662,7 +6663,7 @@ declare interface Props_3 {
|
|
|
6662
6663
|
label: string;
|
|
6663
6664
|
suffix?: string;
|
|
6664
6665
|
prefix?: string;
|
|
6665
|
-
};
|
|
6666
|
+
} | ReactElement;
|
|
6666
6667
|
/** Small text at the center of the donut chart */
|
|
6667
6668
|
subNote?: string;
|
|
6668
6669
|
/** Specifies the number of decimal places to display in the value. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@undp/data-viz",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"main": "./dist/index.cjs",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"browser": "./dist/index.umd.js",
|
|
@@ -470,7 +470,7 @@
|
|
|
470
470
|
"peerDependencies": {
|
|
471
471
|
"@dnd-kit/core": "^6.3.1",
|
|
472
472
|
"@dnd-kit/modifiers": "^9.0.0",
|
|
473
|
-
"@undp/design-system-react": "^1.5.
|
|
473
|
+
"@undp/design-system-react": "^1.5.3",
|
|
474
474
|
"ajv": "^8.17.1",
|
|
475
475
|
"dom-to-svg": "^0.12.2",
|
|
476
476
|
"file-saver": "^2.0.5",
|
|
@@ -479,8 +479,8 @@
|
|
|
479
479
|
"marked": "^16.4.1",
|
|
480
480
|
"math-expression-evaluator": "^2.0.7",
|
|
481
481
|
"pmtiles": "^4.3.0",
|
|
482
|
-
"react": "^19.2.
|
|
483
|
-
"react-dom": "^19.2.
|
|
482
|
+
"react": "^19.2.3",
|
|
483
|
+
"react-dom": "^19.2.3",
|
|
484
484
|
"react-globe.gl": "^2.36.0",
|
|
485
485
|
"tailwind-animate": "^0.2.10",
|
|
486
486
|
"tailwind-merge": "^3.3.1",
|