@undp/data-viz 2.5.3 → 2.5.4

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-D4pAp7u0.cjs"),n=require("react"),kt=require("./getSliderMarks-BzrpHrHS.cjs"),It=require("./Spinner-WHzzloYQ.cjs"),wt=require("./parse-xYI9yrvL.cjs"),Pt=require("./index-DQA8q5sC.cjs"),N=require("./index-DLFt97gy.cjs"),Ct=require("./Typography-BqmyF1gP.cjs"),zt=require("./index-C5K--w8d.cjs"),_t=require("./numberFormattingFunction-u2iNHL_c.cjs"),Wt=require("./Tooltip-C9F3uYG0.cjs"),At=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ct=require("./index-BhI7mBJx.cjs"),Ft=require("./DetailsModal-Du8Fr1QD.cjs"),$t=require("./ImageDownloadButton.cjs"),Lt=require("./CsvDownloadButton.cjs"),Tt=require("./ordinal-CrsysVE-.cjs"),Gt=require("./threshold-DNsSUf8Q.cjs"),Et=require("./select-Bnfk0lJx.cjs"),it=require("./proxy-CqH8m8IQ.cjs"),Ht=require("./use-in-view-dnRv_qqF.cjs"),Vt=require("./index-FXfr51ZM.cjs"),Ut=require("./GraphFooter.cjs"),Xt=require("./GraphHeader.cjs"),lt=require("./Colors.cjs"),Rt=require("./fetchAndParseData-QTF6tjij.cjs"),Yt=require("./getUniqValue-NX8DgwND.cjs"),Jt=require("./getJenks-BzJvhy_H.cjs"),St=require("./GraphContainer-Cul9b74X.cjs");function Zt(p){const{data:e,colorDomain:s,colors:i,mapData:F,colorLegendTitle:k,categorical:$,height:v,width:h,scale:f,centerPoint:L,tooltip:te,mapBorderWidth:U,mapBorderColor:oe,mapNoDataColor:be,onSeriesMouseOver:re,showColorScale:Ee,zoomScaleExtend:ze,zoomTranslateExtend:_e,highlightedIds:b,onSeriesMouseClick:ae,mapProperty:y,resetSelectionOnDoubleClick:De,detailsOnClick:X,styles:We,classNames:ne,mapProjection:M,zoomInteraction:O,animate:w,dimmedOpacity:q,customLayers:se,collapseColorScaleByDefault:ke,zoomAndCenterByHighlightedIds:we,projectionRotate:T,rewindCoordinatesInMapData:Y,overlayMapData:J,overlayMapBorderColor:Ae,overlayMapBorderWidth:Fe,numberDisplayOptions:Z,graphDownload:ie,dataDownload:B}=p,a=n.useMemo(()=>Y?N.index_default(F,{reverse:!0}):F,[F,Y]),x=n.useMemo(()=>!Y||!J?J:N.index_default(J,{reverse:!0}),[J,Y]),[C,I]=n.useState(void 0),le=n.useRef(null),[$e,K]=n.useState(ke===void 0?!(h<680):!ke),[G,Q]=n.useState(void 0),[P,ce]=n.useState(void 0),[Ce,g]=n.useState(void 0),[de,E]=n.useState(void 0),R=n.useRef(null),S=Ht.useInView(R,{once:w.once,amount:w.amount}),ue=n.useRef(null),Re=$?Tt.ordinal().domain(s).range(i):Gt.threshold().domain(s).range(i);n.useEffect(()=>{const o=Et.select(ue.current),r=Et.select(R.current),m=d=>{if(O==="noZoom")return!1;if(O==="button")return!d.type.includes("wheel");const Oe=d.type==="wheel",qe=d.type.startsWith("touch"),xe=d.type==="mousedown"||d.type==="mousemove";return qe?!0:Oe?O==="scroll"?!0:d.ctrlKey:xe&&!d.button&&!d.ctrlKey},j=N.zoom().scaleExtent(ze).translateExtent(_e||[[-20,-20],[h+20,v+20]]).filter(m).on("zoom",({transform:d})=>{o.attr("transform",d)});r.call(j),le.current=j},[v,h,O]);const H=N.index_default$1({...a,features:we?a.features.filter(o=>(b||[]).length===0||b?.indexOf(o.properties[y])!==-1):a.features}),z=zt.index_default({...a,features:we?a.features.filter(o=>(b||[]).length===0||b?.indexOf(o.properties[y])!==-1):a.features}),Se=(H[2]-H[0])*1.15,pe=(H[3]-H[1])*1.15,Ne=h*190/960*360/Se,me=v*190/678*180/pe,_=f*Math.min(Ne,me),Me=M==="mercator"?N.geoMercator().rotate(T).center(L||z.geometry.coordinates).translate([h/2,v/2]).scale(_):M==="equalEarth"?N.geoEqualEarth().rotate(T).center(L||z.geometry.coordinates).translate([h/2,v/2]).scale(_):M==="naturalEarth"?N.geoNaturalEarth1().rotate(T).center(L||z.geometry.coordinates).translate([h/2,v/2]).scale(_):M==="orthographic"?N.geoOrthographic().rotate(T).center(L||z.geometry.coordinates).translate([h/2,v/2]).scale(_):N.geoAlbersUsa().rotate(T).center(L||z.geometry.coordinates).translate([h/2,v/2]).scale(_),V=N.geoPath().projection(Me),he=o=>{if(!R.current||!le.current)return;Et.select(R.current).call(le.current.scaleBy,o==="in"?1.2:1/1.2)};return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"relative",children:[t.jsxRuntimeExports.jsx(it.motion.svg,{width:`${h}px`,height:`${v}px`,viewBox:`0 0 ${h} ${v}`,ref:R,direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{ref:ue,children:[se.filter(o=>o.position==="before").map(o=>o.layer),a.features.map((o,r)=>{if(!o.properties?.[y])return null;const m=V(o);return m?t.jsxRuntimeExports.jsx(it.motion.g,{opacity:C?q:b?b.indexOf(o.properties[y])!==-1?1:q:1,children:t.jsxRuntimeExports.jsx("path",{d:m,style:{stroke:oe,strokeWidth:U,fill:be,vectorEffect:"non-scaling-stroke"}})},r):null}),t.jsxRuntimeExports.jsx(Vt.AnimatePresence,{children:e.map(o=>{const r=a.features.findIndex(d=>o.id===d.properties[y]);if(r===-1)return null;const m=V(a.features[r]);if(!m)return null;const j=At.checkIfNullOrUndefined(o.x)?be:Re(o.x);return t.jsxRuntimeExports.jsx(it.motion.g,{className:"undp-map-shapes",variants:{initial:{opacity:0},whileInView:{opacity:C?C===j&&(!b||b.indexOf(o.id)!==-1)?1:q:b?b.indexOf(o.id)!==-1?1:q:1,transition:{duration:w.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},onMouseEnter:d=>{ce(o),E(d.clientY),g(d.clientX),re?.(o)},onMouseMove:d=>{ce(o),E(d.clientY),g(d.clientX)},onMouseLeave:()=>{ce(void 0),g(void 0),E(void 0),re?.(void 0)},onClick:()=>{(ae||X)&&(Pt.isEqual(G,o)&&De?(Q(void 0),ae?.(void 0)):(Q(o),ae?.(o)))},children:t.jsxRuntimeExports.jsx(it.motion.path,{d:m,variants:{initial:{fill:j,opacity:0},whileInView:{fill:j,opacity:1,transition:{duration:w.duration}}},initial:"initial",animate:S?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},style:{stroke:oe,strokeWidth:U,vectorEffect:"non-scaling-stroke"}},`${o.id}`)},o.id)})}),P?a.features.filter(o=>o.properties[y]===P.id).map((o,r)=>t.jsxRuntimeExports.jsx("path",{d:V(o)||"",className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5",vectorEffect:"non-scaling-stroke"}},r)):null,x?.features.map((o,r)=>{const m=V(o);return m?t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx("path",{d:m,style:{stroke:Ae||oe,strokeWidth:Fe||U+1,fill:"none",pointerEvents:"none",vectorEffect:"non-scaling-stroke"}})},r):null}),se.filter(o=>o.position==="after").map(o=>o.layer)]})}),Ee===!1?null:t.jsxRuntimeExports.jsx("div",{className:t.mo("absolute left-4 bottom-4 map-color-legend",ne?.colorLegend),children:$e?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{className:"color-legend-close-button bg-[rgba(240,240,240,0.7)] dark:bg-[rgba(30,30,30,0.7)] border border-[var(--gray-400)] rounded-full w-6 h-6 p-[3px] cursor-pointer z-10 absolute right-[-0.75rem] top-[-0.75rem]",onClick:()=>{K(!1)},children:t.jsxRuntimeExports.jsx(ct.X,{})}),t.jsxRuntimeExports.jsxs("div",{className:"color-legend-box p-2 bg-[rgba(240,240,240,0.7)] dark:bg-[rgba(30,30,30,0.7)]",style:{width:$?void 0:"340px"},children:[k&&k!==""?t.jsxRuntimeExports.jsx(Ct._,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:k}):null,$?t.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-3",children:s.map((o,r)=>t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{I(i[r%i.length])},onMouseLeave:()=>{I(void 0)},children:[t.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:i[r%i.length]}}),t.jsxRuntimeExports.jsx(Ct._,{size:"sm",marginBottom:"none",leading:"none",children:o})]},r))}):t.jsxRuntimeExports.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{children:[s.map((o,r)=>t.jsxRuntimeExports.jsxs("g",{onMouseOver:()=>{I(i[r])},onMouseLeave:()=>{I(void 0)},className:"cursor-pointer",children:[t.jsxRuntimeExports.jsx("rect",{x:r*320/i.length+1,y:1,width:320/i.length-2,height:8,className:C===i[r]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:i[r],...C===i[r]?{}:{stroke:i[r]}}}),t.jsxRuntimeExports.jsx("text",{x:(r+1)*320/i.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:_t.numberFormattingFunction(o,"NA",Z?.precision??2,void 0,void 0,Z?.locale||"en",Z?.padZeros||!1)})]},r)),t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx("rect",{onMouseOver:()=>{I(i[s.length])},onMouseLeave:()=>{I(void 0)},x:s.length*320/i.length+1,y:1,width:320/i.length-2,height:8,className:`cursor-pointer ${C===i[s.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:i[s.length],...C===i[s.length]?{}:{stroke:i[s.length]}}})})]})})]})]}):t.jsxRuntimeExports.jsx("button",{type:"button",className:"p-1 border-0 rounded-[2px] text-primary-gray-700 bg-primary-gray-300 dark:bg-primary-gray-500 map-legend-button",onClick:()=>{K(!0)},children:t.jsxRuntimeExports.jsx(ct.ExpandIcon,{})})}),O==="button"&&t.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col undp-viz-zoom-buttons",children:[t.jsxRuntimeExports.jsx("button",{onClick:()=>he("in"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-550 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),t.jsxRuntimeExports.jsx("button",{onClick:()=>he("out"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-550 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]}),(ie||B)&&t.jsxRuntimeExports.jsxs("div",{className:"absolute right-4 top-4 flex flex-col image-download-button gap-2",children:[ie&&t.jsxRuntimeExports.jsx($t.ImageDownloadButton,{nodeID:ie,buttonSmall:!0,className:"p-1"}),B&&B.length>0&&t.jsxRuntimeExports.jsx(Lt.CsvDownloadButton,{csvData:B,buttonSmall:!0,headers:Object.keys(B[0]).map(o=>({label:o,key:o})),className:"p-1"})]})]}),X&&G!==void 0?t.jsxRuntimeExports.jsx(Ft.DetailsModal,{body:X,data:G,setData:Q,className:ne?.modal}):null,P&&te&&Ce&&de?t.jsxRuntimeExports.jsx(Wt.Tooltip,{data:P,body:te,xPos:Ce,yPos:de,backgroundStyle:We?.tooltip,className:ne?.tooltip}):null]})}function Kt(p){const e=t.compilerRuntimeExports.c(133),{data:s,mapData:i,graphTitle:F,colors:k,sources:$,graphDescription:v,height:h,width:f,footNote:L,colorDomain:te,colorLegendTitle:U,scaleType:oe,scale:be,centerPoint:re,padding:Ee,mapBorderWidth:ze,mapNoDataColor:_e,backgroundColor:b,mapBorderColor:ae,relativeHeight:y,tooltip:De,onSeriesMouseOver:X,isWorldMap:We,showColorScale:ne,zoomScaleExtend:M,zoomTranslateExtend:O,graphID:w,highlightedIds:q,onSeriesMouseClick:se,mapProperty:ke,graphDownload:we,dataDownload:T,showAntarctica:Y,language:J,minHeight:Ae,theme:Fe,ariaLabel:Z,resetSelectionOnDoubleClick:ie,detailsOnClick:B,styles:a,classNames:x,mapProjection:C,zoomInteraction:I,animate:le,dimmedOpacity:$e,customLayers:K,timeline:G,collapseColorScaleByDefault:Q,projectionRotate:P,zoomAndCenterByHighlightedIds:ce,rewindCoordinatesInMapData:Ce,mapOverlay:g,numberDisplayOptions:de}=p,E=i===void 0?"https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-v2.json":i,R=L===void 0?"The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.":L,S=oe===void 0?"threshold":oe,ue=be===void 0?.95:be,Re=ze===void 0?.5:ze,H=_e===void 0?lt.Colors.light.graphNoData:_e,z=b===void 0?!1:b,Se=ae===void 0?lt.Colors.light.grays["gray-500"]:ae,pe=We===void 0?!0:We,Ne=ne===void 0?!0:ne;let me;e[0]!==M?(me=M===void 0?[.8,6]:M,e[0]=M,e[1]=me):me=e[1];const _=me,Me=ke===void 0?"ISO3":ke,V=we===void 0?!1:we,he=T===void 0?!1:T,o=Y===void 0?!1:Y,r=J===void 0?"en":J,m=Ae===void 0?0:Ae,j=Fe===void 0?"light":Fe,d=ie===void 0?!0:ie,Oe=C===void 0?"naturalEarth":C,qe=I===void 0?"button":I,xe=le===void 0?!1:le,dt=$e===void 0?.3:$e;let Le;e[2]!==K?(Le=K===void 0?[]:K,e[2]=K,e[3]=Le):Le=e[3];const ut=Le;let Te;e[4]!==G?(Te=G===void 0?{enabled:!1,autoplay:!1,showOnlyActiveDate:!0}:G,e[4]=G,e[5]=Te):Te=e[5];const l=Te;let Ge;e[6]!==P?(Ge=P===void 0?[0,0]:P,e[6]=P,e[7]=Ge):Ge=e[7];const pt=Ge,mt=ce===void 0?!1:ce,ht=Ce===void 0?!0:Ce,[ee,Nt]=n.useState(0),[Be,Mt]=n.useState(0),[W,Ot]=n.useState(l.autoplay);let Ie;if(e[8]!==s||e[9]!==l.dateFormat){let c;e[11]!==l.dateFormat?(c=D=>wt.parse(`${D.date}`,l.dateFormat||"yyyy",new Date).getTime(),e[11]=l.dateFormat,e[12]=c):c=e[12],Ie=[...new Set(s.filter(io).map(c))],Ie.sort(so),e[8]=s,e[9]=l.dateFormat,e[10]=Ie}else Ie=e[10];const u=Ie,[A,xt]=n.useState(l.autoplay?0:u.length-1),[ge,qt]=n.useState(void 0),[gt,Bt]=n.useState(void 0),ft=n.useRef(null),Dt=n.useRef(null);let He,Ve;e[13]===Symbol.for("react.memo_cache_sentinel")?(He=()=>{const c=new ResizeObserver(D=>{Nt(D[0].target.clientWidth||620),Mt(D[0].target.clientHeight||480)});return ft.current&&c.observe(ft.current),()=>c.disconnect()},Ve=[],e[13]=He,e[14]=Ve):(He=e[13],Ve=e[14]),n.useEffect(He,Ve);let Ue;e[15]===Symbol.for("react.memo_cache_sentinel")?(Ue=c=>{qt(c)},e[15]=Ue):Ue=e[15];const Xe=n.useEffectEvent(Ue);let Ye;e[16]===Symbol.for("react.memo_cache_sentinel")?(Ye=c=>{Bt(c)},e[16]=Ye):Ye=e[16];const Pe=n.useEffectEvent(Ye);let Je;e[17]!==E||e[18]!==Xe?(Je=()=>{typeof E=="string"?Rt.fetchAndParseJSON(E).then(D=>{Xe(D)}):Xe(E)},e[17]=E,e[18]=Xe,e[19]=Je):Je=e[19];let Ze;e[20]!==E?(Ze=[E],e[20]=E,e[21]=Ze):Ze=e[21],n.useEffect(Je,Ze);let Ke;e[22]!==g?.mapData||e[23]!==Pe?(Ke=()=>{g?.mapData||Pe(void 0),typeof g?.mapData=="string"?Rt.fetchAndParseJSON(g?.mapData).then(D=>{Pe(D)}):Pe(g?.mapData)},e[22]=g?.mapData,e[23]=Pe,e[24]=Ke):Ke=e[24];const yt=g?.mapData;let Qe;e[25]!==yt?(Qe=[yt],e[25]=yt,e[26]=Qe):Qe=e[26],n.useEffect(Ke,Qe);let et;e[27]!==te||e[28]!==k?.length||e[29]!==s||e[30]!==S?(et=te||(S==="categorical"?Yt.getUniqValue(s,"x"):Jt.getJenks(s.map(no),k?.length||4)),e[27]=te,e[28]=k?.length,e[29]=s,e[30]=S,e[31]=et):et=e[31];const tt=et;let ot,rt;e[32]!==W||e[33]!==l.speed||e[34]!==u?(ot=()=>{const c=setInterval(()=>{xt(D=>D<u.length-1?D+1:0)},(l.speed||2)*1e3);return W||clearInterval(c),()=>clearInterval(c)},rt=[u,W,l.speed],e[32]=W,e[33]=l.speed,e[34]=u,e[35]=ot,e[36]=rt):(ot=e[35],rt=e[36]),n.useEffect(ot,rt);const vt=l.dateFormat||"yyyy";let at;e[37]!==A||e[38]!==vt||e[39]!==l.showOnlyActiveDate||e[40]!==u?(at=kt.getSliderMarks(u,A,l.showOnlyActiveDate,vt),e[37]=A,e[38]=vt,e[39]=l.showOnlyActiveDate,e[40]=u,e[41]=at):at=e[41];const nt=at,jt=x?.graphContainer,bt=a?.graphContainer;let fe;e[42]!==x?.description||e[43]!==x?.title||e[44]!==v||e[45]!==F||e[46]!==a?.description||e[47]!==a?.title||e[48]!==f?(fe=F||v?t.jsxRuntimeExports.jsx(Xt.GraphHeader,{styles:{title:a?.title,description:a?.description},classNames:{title:x?.title,description:x?.description},graphTitle:F,graphDescription:v,width:f}):null,e[42]=x?.description,e[43]=x?.title,e[44]=v,e[45]=F,e[46]=a?.description,e[47]=a?.title,e[48]=f,e[49]=fe):fe=e[49];let ye;e[50]!==A||e[51]!==nt||e[52]!==W||e[53]!==l.enabled||e[54]!==u?(ye=l.enabled&&u.length>0&&nt?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ot(!W)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":W?"Click to pause animation":"Click to play animation",children:W?t.jsxRuntimeExports.jsx(ct.Pause,{}):t.jsxRuntimeExports.jsx(ct.Play,{})}),t.jsxRuntimeExports.jsx(kt.Nr,{min:u[0],max:u[u.length-1],marks:nt,step:null,defaultValue:u[u.length-1],value:u[A],onChangeComplete:c=>{xt(u.indexOf(c))},onChange:c=>{xt(u.indexOf(c))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e[50]=A,e[51]=nt,e[52]=W,e[53]=l.enabled,e[54]=u,e[55]=ye):ye=e[55];let ve;e[56]!==xe||e[57]!==re||e[58]!==x||e[59]!==Q||e[60]!==U||e[61]!==k||e[62]!==ut||e[63]!==s||e[64]!==he||e[65]!==B||e[66]!==dt||e[67]!==tt||e[68]!==V||e[69]!==h||e[70]!==q||e[71]!==A||e[72]!==pe||e[73]!==Se||e[74]!==Re||e[75]!==H||e[76]!==g?.mapBorderColor||e[77]!==g?.mapBorderWidth||e[78]!==Oe||e[79]!==Me||e[80]!==ge||e[81]!==m||e[82]!==de||e[83]!==se||e[84]!==X||e[85]!==gt||e[86]!==pt||e[87]!==y||e[88]!==d||e[89]!==ht||e[90]!==ue||e[91]!==S||e[92]!==o||e[93]!==Ne||e[94]!==a||e[95]!==Be||e[96]!==ee||e[97]!==j||e[98]!==l.dateFormat||e[99]!==l.enabled||e[100]!==De||e[101]!==u||e[102]!==f||e[103]!==mt||e[104]!==qe||e[105]!==_||e[106]!==O?(ve=t.jsxRuntimeExports.jsx(St.GraphArea,{ref:ft,children:ee&&Be&&ge?t.jsxRuntimeExports.jsx(Zt,{data:s.filter(c=>l.enabled?`${c.date}`===wt.format(new Date(u[A]),l.dateFormat||"yyyy"):c),mapData:o?ge:{...ge,features:ge.features.filter(ao)},colorDomain:tt,width:ee,height:Be,scale:ue,centerPoint:re,colors:k||(S==="categorical"?lt.Colors[j].categoricalColors.colors:lt.Colors[j].sequentialColors[`neutralColorsx0${tt.length+1}`]),colorLegendTitle:U,mapBorderWidth:Re,mapNoDataColor:H,categorical:S==="categorical",mapBorderColor:Se,tooltip:De,onSeriesMouseOver:X,isWorldMap:pe,showColorScale:Ne,zoomScaleExtend:_,zoomTranslateExtend:O,onSeriesMouseClick:se,mapProperty:Me,highlightedIds:q,resetSelectionOnDoubleClick:d,styles:a,overlayMapData:gt,overlayMapBorderColor:g?.mapBorderColor,overlayMapBorderWidth:g?.mapBorderWidth,classNames:x,detailsOnClick:B,mapProjection:Oe||(pe?"naturalEarth":"mercator"),zoomInteraction:qe,dimmedOpacity:dt,animate:xe===!0?{duration:.5,once:!0,amount:.5}:xe||{duration:0,once:!0,amount:0},customLayers:ut,zoomAndCenterByHighlightedIds:mt,collapseColorScaleByDefault:Q,projectionRotate:pt,rewindCoordinatesInMapData:ht,numberDisplayOptions:de,graphDownload:V?Dt:void 0,dataDownload:he?s.map(ro).filter(oo).length>0?s.map(to).filter(eo):s.filter(Qt):null}):t.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(m,h||(y?m?(f||ee)*y>m?(f||ee)*y:m:(f||ee)*y:Be))}px`},className:"flex items-center justify-center",children:t.jsxRuntimeExports.jsx(It.w,{"aria-label":"Loading graph"})})}),e[56]=xe,e[57]=re,e[58]=x,e[59]=Q,e[60]=U,e[61]=k,e[62]=ut,e[63]=s,e[64]=he,e[65]=B,e[66]=dt,e[67]=tt,e[68]=V,e[69]=h,e[70]=q,e[71]=A,e[72]=pe,e[73]=Se,e[74]=Re,e[75]=H,e[76]=g?.mapBorderColor,e[77]=g?.mapBorderWidth,e[78]=Oe,e[79]=Me,e[80]=ge,e[81]=m,e[82]=de,e[83]=se,e[84]=X,e[85]=gt,e[86]=pt,e[87]=y,e[88]=d,e[89]=ht,e[90]=ue,e[91]=S,e[92]=o,e[93]=Ne,e[94]=a,e[95]=Be,e[96]=ee,e[97]=j,e[98]=l.dateFormat,e[99]=l.enabled,e[100]=De,e[101]=u,e[102]=f,e[103]=mt,e[104]=qe,e[105]=_,e[106]=O,e[107]=ve):ve=e[107];let je;e[108]!==x?.footnote||e[109]!==x?.source||e[110]!==R||e[111]!==$||e[112]!==a?.footnote||e[113]!==a?.source||e[114]!==f?(je=$||R?t.jsxRuntimeExports.jsx(Ut.GraphFooter,{styles:{footnote:a?.footnote,source:a?.source},classNames:{footnote:x?.footnote,source:x?.source},sources:$,footNote:R,width:f}):null,e[108]=x?.footnote,e[109]=x?.source,e[110]=R,e[111]=$,e[112]=a?.footnote,e[113]=a?.source,e[114]=f,e[115]=je):je=e[115];let st;return e[116]!==Z||e[117]!==z||e[118]!==w||e[119]!==h||e[120]!==r||e[121]!==m||e[122]!==Ee||e[123]!==y||e[124]!==jt||e[125]!==bt||e[126]!==fe||e[127]!==ye||e[128]!==ve||e[129]!==je||e[130]!==j||e[131]!==f?(st=t.jsxRuntimeExports.jsxs(St.GraphContainer,{className:jt,style:bt,id:w,ref:Dt,"aria-label":Z,backgroundColor:z,theme:j,language:r,minHeight:m,width:f,height:h,relativeHeight:y,padding:Ee,children:[fe,ye,ve,je]}),e[116]=Z,e[117]=z,e[118]=w,e[119]=h,e[120]=r,e[121]=m,e[122]=Ee,e[123]=y,e[124]=jt,e[125]=bt,e[126]=fe,e[127]=ye,e[128]=ve,e[129]=je,e[130]=j,e[131]=f,e[132]=st):st=e[132],st}function Qt(p){return p!==void 0}function eo(p){return p!==void 0}function to(p){return p.data}function oo(p){return p!==void 0}function ro(p){return p.data}function ao(p){return p.properties?.NAME!=="Antarctica"}function no(p){return p.x}function so(p,e){return p-e}function io(p){return p.date}exports.ChoroplethMap=Kt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-D4pAp7u0.cjs"),i=require("react"),wt=require("./getSliderMarks-BzrpHrHS.cjs"),zt=require("./Spinner-WHzzloYQ.cjs"),Ct=require("./parse-xYI9yrvL.cjs"),Pt=require("./index-DQA8q5sC.cjs"),O=require("./index-DLFt97gy.cjs"),it=require("./Typography-BqmyF1gP.cjs"),_t=require("./index-C5K--w8d.cjs"),Dt=require("./numberFormattingFunction-u2iNHL_c.cjs"),Ft=require("./Tooltip-C9F3uYG0.cjs"),At=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),dt=require("./index-BhI7mBJx.cjs"),Wt=require("./DetailsModal-Du8Fr1QD.cjs"),$t=require("./ImageDownloadButton.cjs"),Lt=require("./CsvDownloadButton.cjs"),Tt=require("./ordinal-CrsysVE-.cjs"),Gt=require("./threshold-DNsSUf8Q.cjs"),kt=require("./select-Bnfk0lJx.cjs"),lt=require("./proxy-CqH8m8IQ.cjs"),Ht=require("./use-in-view-dnRv_qqF.cjs"),Vt=require("./index-FXfr51ZM.cjs"),Ut=require("./GraphFooter.cjs"),Xt=require("./GraphHeader.cjs"),ct=require("./Colors.cjs"),St=require("./fetchAndParseData-QTF6tjij.cjs"),Yt=require("./getUniqValue-NX8DgwND.cjs"),Zt=require("./getJenks-BzJvhy_H.cjs"),Nt=require("./GraphContainer-Cul9b74X.cjs");function Jt(p){const{data:e,colorDomain:r,colors:a,mapData:L,colorLegendTitle:w,categorical:q,height:v,width:x,scale:f,centerPoint:T,tooltip:te,mapBorderWidth:X,mapBorderColor:oe,mapNoDataColor:be,onSeriesMouseOver:re,showColorScale:Ee,zoomScaleExtend:Pe,zoomTranslateExtend:_e,highlightedIds:b,onSeriesMouseClick:ae,mapProperty:y,resetSelectionOnDoubleClick:De,detailsOnClick:Y,styles:Fe,classNames:ne,mapProjection:B,zoomInteraction:I,animate:C,dimmedOpacity:z,customLayers:se,collapseColorScaleByDefault:ke,zoomAndCenterByHighlightedIds:Re,projectionRotate:G,rewindCoordinatesInMapData:Z,overlayMapData:J,overlayMapBorderColor:Ae,overlayMapBorderWidth:We,numberDisplayOptions:E,graphDownload:ie,dataDownload:P}=p,s=i.useMemo(()=>Z?O.index_default(L,{reverse:!0}):L,[L,Z]),h=i.useMemo(()=>!Z||!J?J:O.index_default(J,{reverse:!0}),[J,Z]),[S,D]=i.useState(void 0),le=i.useRef(null),[$e,K]=i.useState(ke===void 0?!(x<680):!ke),[H,Q]=i.useState(void 0),[_,ce]=i.useState(void 0),[we,g]=i.useState(void 0),[de,k]=i.useState(void 0),N=i.useRef(null),M=Ht.useInView(N,{once:C.once,amount:C.amount}),ue=i.useRef(null),Ce=q?Tt.ordinal().domain(r).range(a):Gt.threshold().domain(r).range(a);i.useEffect(()=>{const o=kt.select(ue.current),n=kt.select(N.current),m=d=>{if(I==="noZoom")return!1;if(I==="button")return!d.type.includes("wheel");const Oe=d.type==="wheel",qe=d.type.startsWith("touch"),he=d.type==="mousedown"||d.type==="mousemove";return qe?!0:Oe?I==="scroll"?!0:d.ctrlKey:he&&!d.button&&!d.ctrlKey},j=O.zoom().scaleExtent(Pe).translateExtent(_e||[[-20,-20],[x+20,v+20]]).filter(m).on("zoom",({transform:d})=>{o.attr("transform",d)});n.call(j),le.current=j},[v,x,I]);const V=O.index_default$1({...s,features:Re?s.features.filter(o=>(b||[]).length===0||b?.indexOf(o.properties[y])!==-1):s.features}),F=_t.index_default({...s,features:Re?s.features.filter(o=>(b||[]).length===0||b?.indexOf(o.properties[y])!==-1):s.features}),Se=(V[2]-V[0])*1.15,pe=(V[3]-V[1])*1.15,Ne=x*190/960*360/Se,me=v*190/678*180/pe,A=f*Math.min(Ne,me),Me=B==="mercator"?O.geoMercator().rotate(G).center(T||F.geometry.coordinates).translate([x/2,v/2]).scale(A):B==="equalEarth"?O.geoEqualEarth().rotate(G).center(T||F.geometry.coordinates).translate([x/2,v/2]).scale(A):B==="naturalEarth"?O.geoNaturalEarth1().rotate(G).center(T||F.geometry.coordinates).translate([x/2,v/2]).scale(A):B==="orthographic"?O.geoOrthographic().rotate(G).center(T||F.geometry.coordinates).translate([x/2,v/2]).scale(A):O.geoAlbersUsa().rotate(G).center(T||F.geometry.coordinates).translate([x/2,v/2]).scale(A),U=O.geoPath().projection(Me),xe=o=>{if(!N.current||!le.current)return;kt.select(N.current).call(le.current.scaleBy,o==="in"?1.2:1/1.2)};return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"relative",children:[t.jsxRuntimeExports.jsx(lt.motion.svg,{width:`${x}px`,height:`${v}px`,viewBox:`0 0 ${x} ${v}`,ref:N,direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{ref:ue,children:[se.filter(o=>o.position==="before").map(o=>o.layer),s.features.map((o,n)=>{if(!o.properties?.[y])return null;const m=U(o);return m?t.jsxRuntimeExports.jsx(lt.motion.g,{opacity:S?z:b?b.indexOf(o.properties[y])!==-1?1:z:1,children:t.jsxRuntimeExports.jsx("path",{d:m,style:{stroke:oe,strokeWidth:X,fill:be,vectorEffect:"non-scaling-stroke"}})},n):null}),t.jsxRuntimeExports.jsx(Vt.AnimatePresence,{children:e.map(o=>{const n=s.features.findIndex(d=>o.id===d.properties[y]);if(n===-1)return null;const m=U(s.features[n]);if(!m)return null;const j=At.checkIfNullOrUndefined(o.x)?be:Ce(o.x);return t.jsxRuntimeExports.jsx(lt.motion.g,{className:"undp-map-shapes",variants:{initial:{opacity:0},whileInView:{opacity:S?S===j&&(!b||b.indexOf(o.id)!==-1)?1:z:b?b.indexOf(o.id)!==-1?1:z:1,transition:{duration:C.duration}}},initial:"initial",animate:M?"whileInView":"initial",exit:{opacity:0,transition:{duration:C.duration}},onMouseEnter:d=>{ce(o),k(d.clientY),g(d.clientX),re?.(o)},onMouseMove:d=>{ce(o),k(d.clientY),g(d.clientX)},onMouseLeave:()=>{ce(void 0),g(void 0),k(void 0),re?.(void 0)},onClick:()=>{(ae||Y)&&(Pt.isEqual(H,o)&&De?(Q(void 0),ae?.(void 0)):(Q(o),ae?.(o)))},children:t.jsxRuntimeExports.jsx(lt.motion.path,{d:m,variants:{initial:{fill:j,opacity:0},whileInView:{fill:j,opacity:1,transition:{duration:C.duration}}},initial:"initial",animate:M?"whileInView":"initial",exit:{opacity:0,transition:{duration:C.duration}},style:{stroke:oe,strokeWidth:X,vectorEffect:"non-scaling-stroke"}},`${o.id}`)},o.id)})}),_?s.features.filter(o=>o.properties[y]===_.id).map((o,n)=>t.jsxRuntimeExports.jsx("path",{d:U(o)||"",className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5",vectorEffect:"non-scaling-stroke"}},n)):null,h?.features.map((o,n)=>{const m=U(o);return m?t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx("path",{d:m,style:{stroke:Ae||oe,strokeWidth:We||X+1,fill:"none",pointerEvents:"none",vectorEffect:"non-scaling-stroke"}})},n):null}),se.filter(o=>o.position==="after").map(o=>o.layer)]})}),Ee===!1?null:t.jsxRuntimeExports.jsx("div",{className:t.mo("absolute left-4 bottom-4 map-color-legend",ne?.colorLegend),children:$e?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{className:"color-legend-close-button bg-[rgba(240,240,240,0.7)] dark:bg-[rgba(30,30,30,0.7)] border border-[var(--gray-400)] rounded-full w-6 h-6 p-[3px] cursor-pointer z-10 absolute right-[-0.75rem] top-[-0.75rem]",onClick:()=>{K(!1)},children:t.jsxRuntimeExports.jsx(dt.X,{})}),t.jsxRuntimeExports.jsxs("div",{className:"color-legend-box p-2 bg-[rgba(240,240,240,0.7)] dark:bg-[rgba(30,30,30,0.7)]",style:{width:q||r.length<2?void 0:"340px"},children:[w&&w!==""?t.jsxRuntimeExports.jsx(it._,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:w}):null,!q&&r.length>1?t.jsxRuntimeExports.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{children:[r.map((o,n)=>t.jsxRuntimeExports.jsxs("g",{onMouseOver:()=>{D(a[n])},onMouseLeave:()=>{D(void 0)},className:"cursor-pointer",children:[t.jsxRuntimeExports.jsx("rect",{x:n*320/a.length+1,y:1,width:320/a.length-2,height:8,className:S===a[n]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:a[n],...S===a[n]?{}:{stroke:a[n]}}}),t.jsxRuntimeExports.jsx("text",{x:(n+1)*320/a.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:Dt.numberFormattingFunction(o,"NA",E?.precision??2,void 0,void 0,E?.locale||"en",E?.padZeros||!1)})]},n)),t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx("rect",{onMouseOver:()=>{D(a[r.length])},onMouseLeave:()=>{D(void 0)},x:r.length*320/a.length+1,y:1,width:320/a.length-2,height:8,className:`cursor-pointer ${S===a[r.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:a[r.length],...S===a[r.length]?{}:{stroke:a[r.length]}}})})]})}):q?t.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-3",children:r.map((o,n)=>t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{D(a[n%a.length])},onMouseLeave:()=>{D(void 0)},children:[t.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a[n%a.length]}}),t.jsxRuntimeExports.jsx(it._,{size:"sm",marginBottom:"none",leading:"none",children:o})]},n))}):t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{D(a[0])},onMouseLeave:()=>{D(void 0)},children:[t.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a[0]}}),t.jsxRuntimeExports.jsx(it._,{size:"sm",marginBottom:"none",leading:"none",children:`<= ${Dt.numberFormattingFunction(r[0],"NA",E?.precision??2,void 0,void 0,E?.locale||"en",E?.padZeros||!1)}`})]}),t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{D(a[1])},onMouseLeave:()=>{D(void 0)},children:[t.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:a[1]}}),t.jsxRuntimeExports.jsx(it._,{size:"sm",marginBottom:"none",leading:"none",children:`> ${Dt.numberFormattingFunction(r[0],"NA",E?.precision??2,void 0,void 0,E?.locale||"en",E?.padZeros||!1)}`})]})]})]})]}):t.jsxRuntimeExports.jsx("button",{type:"button",className:"p-1 border-0 rounded-[2px] text-primary-gray-700 bg-primary-gray-300 dark:bg-primary-gray-500 map-legend-button",onClick:()=>{K(!0)},children:t.jsxRuntimeExports.jsx(dt.ExpandIcon,{})})}),I==="button"&&t.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col undp-viz-zoom-buttons",children:[t.jsxRuntimeExports.jsx("button",{onClick:()=>xe("in"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-550 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),t.jsxRuntimeExports.jsx("button",{onClick:()=>xe("out"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-550 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]}),(ie||P)&&t.jsxRuntimeExports.jsxs("div",{className:"absolute right-4 top-4 flex flex-col image-download-button gap-2",children:[ie&&t.jsxRuntimeExports.jsx($t.ImageDownloadButton,{nodeID:ie,buttonSmall:!0,className:"p-1"}),P&&P.length>0&&t.jsxRuntimeExports.jsx(Lt.CsvDownloadButton,{csvData:P,buttonSmall:!0,headers:Object.keys(P[0]).map(o=>({label:o,key:o})),className:"p-1"})]})]}),Y&&H!==void 0?t.jsxRuntimeExports.jsx(Wt.DetailsModal,{body:Y,data:H,setData:Q,className:ne?.modal}):null,_&&te&&we&&de?t.jsxRuntimeExports.jsx(Ft.Tooltip,{data:_,body:te,xPos:we,yPos:de,backgroundStyle:Fe?.tooltip,className:ne?.tooltip}):null]})}function Kt(p){const e=t.compilerRuntimeExports.c(133),{data:r,mapData:a,graphTitle:L,colors:w,sources:q,graphDescription:v,height:x,width:f,footNote:T,colorDomain:te,colorLegendTitle:X,scaleType:oe,scale:be,centerPoint:re,padding:Ee,mapBorderWidth:Pe,mapNoDataColor:_e,backgroundColor:b,mapBorderColor:ae,relativeHeight:y,tooltip:De,onSeriesMouseOver:Y,isWorldMap:Fe,showColorScale:ne,zoomScaleExtend:B,zoomTranslateExtend:I,graphID:C,highlightedIds:z,onSeriesMouseClick:se,mapProperty:ke,graphDownload:Re,dataDownload:G,showAntarctica:Z,language:J,minHeight:Ae,theme:We,ariaLabel:E,resetSelectionOnDoubleClick:ie,detailsOnClick:P,styles:s,classNames:h,mapProjection:S,zoomInteraction:D,animate:le,dimmedOpacity:$e,customLayers:K,timeline:H,collapseColorScaleByDefault:Q,projectionRotate:_,zoomAndCenterByHighlightedIds:ce,rewindCoordinatesInMapData:we,mapOverlay:g,numberDisplayOptions:de}=p,k=a===void 0?"https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-v2.json":a,N=T===void 0?"The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.":T,M=oe===void 0?"threshold":oe,ue=be===void 0?.95:be,Ce=Pe===void 0?.5:Pe,V=_e===void 0?ct.Colors.light.graphNoData:_e,F=b===void 0?!1:b,Se=ae===void 0?ct.Colors.light.grays["gray-500"]:ae,pe=Fe===void 0?!0:Fe,Ne=ne===void 0?!0:ne;let me;e[0]!==B?(me=B===void 0?[.8,6]:B,e[0]=B,e[1]=me):me=e[1];const A=me,Me=ke===void 0?"ISO3":ke,U=Re===void 0?!1:Re,xe=G===void 0?!1:G,o=Z===void 0?!1:Z,n=J===void 0?"en":J,m=Ae===void 0?0:Ae,j=We===void 0?"light":We,d=ie===void 0?!0:ie,Oe=S===void 0?"naturalEarth":S,qe=D===void 0?"button":D,he=le===void 0?!1:le,ut=$e===void 0?.3:$e;let Le;e[2]!==K?(Le=K===void 0?[]:K,e[2]=K,e[3]=Le):Le=e[3];const pt=Le;let Te;e[4]!==H?(Te=H===void 0?{enabled:!1,autoplay:!1,showOnlyActiveDate:!0}:H,e[4]=H,e[5]=Te):Te=e[5];const l=Te;let Ge;e[6]!==_?(Ge=_===void 0?[0,0]:_,e[6]=_,e[7]=Ge):Ge=e[7];const mt=Ge,xt=ce===void 0?!1:ce,ht=we===void 0?!0:we,[ee,Mt]=i.useState(0),[Be,Ot]=i.useState(0),[W,qt]=i.useState(l.autoplay);let Ie;if(e[8]!==r||e[9]!==l.dateFormat){let c;e[11]!==l.dateFormat?(c=R=>Ct.parse(`${R.date}`,l.dateFormat||"yyyy",new Date).getTime(),e[11]=l.dateFormat,e[12]=c):c=e[12],Ie=[...new Set(r.filter(io).map(c))],Ie.sort(so),e[8]=r,e[9]=l.dateFormat,e[10]=Ie}else Ie=e[10];const u=Ie,[$,gt]=i.useState(l.autoplay?0:u.length-1),[ge,Bt]=i.useState(void 0),[ft,It]=i.useState(void 0),yt=i.useRef(null),Rt=i.useRef(null);let He,Ve;e[13]===Symbol.for("react.memo_cache_sentinel")?(He=()=>{const c=new ResizeObserver(R=>{Mt(R[0].target.clientWidth||620),Ot(R[0].target.clientHeight||480)});return yt.current&&c.observe(yt.current),()=>c.disconnect()},Ve=[],e[13]=He,e[14]=Ve):(He=e[13],Ve=e[14]),i.useEffect(He,Ve);let Ue;e[15]===Symbol.for("react.memo_cache_sentinel")?(Ue=c=>{Bt(c)},e[15]=Ue):Ue=e[15];const Xe=i.useEffectEvent(Ue);let Ye;e[16]===Symbol.for("react.memo_cache_sentinel")?(Ye=c=>{It(c)},e[16]=Ye):Ye=e[16];const ze=i.useEffectEvent(Ye);let Ze;e[17]!==k||e[18]!==Xe?(Ze=()=>{typeof k=="string"?St.fetchAndParseJSON(k).then(R=>{Xe(R)}):Xe(k)},e[17]=k,e[18]=Xe,e[19]=Ze):Ze=e[19];let Je;e[20]!==k?(Je=[k],e[20]=k,e[21]=Je):Je=e[21],i.useEffect(Ze,Je);let Ke;e[22]!==g?.mapData||e[23]!==ze?(Ke=()=>{g?.mapData||ze(void 0),typeof g?.mapData=="string"?St.fetchAndParseJSON(g?.mapData).then(R=>{ze(R)}):ze(g?.mapData)},e[22]=g?.mapData,e[23]=ze,e[24]=Ke):Ke=e[24];const vt=g?.mapData;let Qe;e[25]!==vt?(Qe=[vt],e[25]=vt,e[26]=Qe):Qe=e[26],i.useEffect(Ke,Qe);let et;e[27]!==te||e[28]!==w?.length||e[29]!==r||e[30]!==M?(et=te||(M==="categorical"?Yt.getUniqValue(r,"x"):Zt.getJenks(r.map(no),w?.length||4)),e[27]=te,e[28]=w?.length,e[29]=r,e[30]=M,e[31]=et):et=e[31];const tt=et;let ot,rt;e[32]!==W||e[33]!==l.speed||e[34]!==u?(ot=()=>{const c=setInterval(()=>{gt(R=>R<u.length-1?R+1:0)},(l.speed||2)*1e3);return W||clearInterval(c),()=>clearInterval(c)},rt=[u,W,l.speed],e[32]=W,e[33]=l.speed,e[34]=u,e[35]=ot,e[36]=rt):(ot=e[35],rt=e[36]),i.useEffect(ot,rt);const jt=l.dateFormat||"yyyy";let at;e[37]!==$||e[38]!==jt||e[39]!==l.showOnlyActiveDate||e[40]!==u?(at=wt.getSliderMarks(u,$,l.showOnlyActiveDate,jt),e[37]=$,e[38]=jt,e[39]=l.showOnlyActiveDate,e[40]=u,e[41]=at):at=e[41];const nt=at,bt=h?.graphContainer,Et=s?.graphContainer;let fe;e[42]!==h?.description||e[43]!==h?.title||e[44]!==v||e[45]!==L||e[46]!==s?.description||e[47]!==s?.title||e[48]!==f?(fe=L||v?t.jsxRuntimeExports.jsx(Xt.GraphHeader,{styles:{title:s?.title,description:s?.description},classNames:{title:h?.title,description:h?.description},graphTitle:L,graphDescription:v,width:f}):null,e[42]=h?.description,e[43]=h?.title,e[44]=v,e[45]=L,e[46]=s?.description,e[47]=s?.title,e[48]=f,e[49]=fe):fe=e[49];let ye;e[50]!==$||e[51]!==nt||e[52]!==W||e[53]!==l.enabled||e[54]!==u?(ye=l.enabled&&u.length>0&&nt?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{qt(!W)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":W?"Click to pause animation":"Click to play animation",children:W?t.jsxRuntimeExports.jsx(dt.Pause,{}):t.jsxRuntimeExports.jsx(dt.Play,{})}),t.jsxRuntimeExports.jsx(wt.Nr,{min:u[0],max:u[u.length-1],marks:nt,step:null,defaultValue:u[u.length-1],value:u[$],onChangeComplete:c=>{gt(u.indexOf(c))},onChange:c=>{gt(u.indexOf(c))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e[50]=$,e[51]=nt,e[52]=W,e[53]=l.enabled,e[54]=u,e[55]=ye):ye=e[55];let ve;e[56]!==he||e[57]!==re||e[58]!==h||e[59]!==Q||e[60]!==X||e[61]!==w||e[62]!==pt||e[63]!==r||e[64]!==xe||e[65]!==P||e[66]!==ut||e[67]!==tt||e[68]!==U||e[69]!==x||e[70]!==z||e[71]!==$||e[72]!==pe||e[73]!==Se||e[74]!==Ce||e[75]!==V||e[76]!==g?.mapBorderColor||e[77]!==g?.mapBorderWidth||e[78]!==Oe||e[79]!==Me||e[80]!==ge||e[81]!==m||e[82]!==de||e[83]!==se||e[84]!==Y||e[85]!==ft||e[86]!==mt||e[87]!==y||e[88]!==d||e[89]!==ht||e[90]!==ue||e[91]!==M||e[92]!==o||e[93]!==Ne||e[94]!==s||e[95]!==Be||e[96]!==ee||e[97]!==j||e[98]!==l.dateFormat||e[99]!==l.enabled||e[100]!==De||e[101]!==u||e[102]!==f||e[103]!==xt||e[104]!==qe||e[105]!==A||e[106]!==I?(ve=t.jsxRuntimeExports.jsx(Nt.GraphArea,{ref:yt,children:ee&&Be&&ge?t.jsxRuntimeExports.jsx(Jt,{data:r.filter(c=>l.enabled?`${c.date}`===Ct.format(new Date(u[$]),l.dateFormat||"yyyy"):c),mapData:o?ge:{...ge,features:ge.features.filter(ao)},colorDomain:tt,width:ee,height:Be,scale:ue,centerPoint:re,colors:w||(M==="categorical"?ct.Colors[j].categoricalColors.colors:ct.Colors[j].sequentialColors[`neutralColorsx0${tt.length+1}`]),colorLegendTitle:X,mapBorderWidth:Ce,mapNoDataColor:V,categorical:M==="categorical",mapBorderColor:Se,tooltip:De,onSeriesMouseOver:Y,isWorldMap:pe,showColorScale:Ne,zoomScaleExtend:A,zoomTranslateExtend:I,onSeriesMouseClick:se,mapProperty:Me,highlightedIds:z,resetSelectionOnDoubleClick:d,styles:s,overlayMapData:ft,overlayMapBorderColor:g?.mapBorderColor,overlayMapBorderWidth:g?.mapBorderWidth,classNames:h,detailsOnClick:P,mapProjection:Oe||(pe?"naturalEarth":"mercator"),zoomInteraction:qe,dimmedOpacity:ut,animate:he===!0?{duration:.5,once:!0,amount:.5}:he||{duration:0,once:!0,amount:0},customLayers:pt,zoomAndCenterByHighlightedIds:xt,collapseColorScaleByDefault:Q,projectionRotate:mt,rewindCoordinatesInMapData:ht,numberDisplayOptions:de,graphDownload:U?Rt:void 0,dataDownload:xe?r.map(ro).filter(oo).length>0?r.map(to).filter(eo):r.filter(Qt):null}):t.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(m,x||(y?m?(f||ee)*y>m?(f||ee)*y:m:(f||ee)*y:Be))}px`},className:"flex items-center justify-center",children:t.jsxRuntimeExports.jsx(zt.w,{"aria-label":"Loading graph"})})}),e[56]=he,e[57]=re,e[58]=h,e[59]=Q,e[60]=X,e[61]=w,e[62]=pt,e[63]=r,e[64]=xe,e[65]=P,e[66]=ut,e[67]=tt,e[68]=U,e[69]=x,e[70]=z,e[71]=$,e[72]=pe,e[73]=Se,e[74]=Ce,e[75]=V,e[76]=g?.mapBorderColor,e[77]=g?.mapBorderWidth,e[78]=Oe,e[79]=Me,e[80]=ge,e[81]=m,e[82]=de,e[83]=se,e[84]=Y,e[85]=ft,e[86]=mt,e[87]=y,e[88]=d,e[89]=ht,e[90]=ue,e[91]=M,e[92]=o,e[93]=Ne,e[94]=s,e[95]=Be,e[96]=ee,e[97]=j,e[98]=l.dateFormat,e[99]=l.enabled,e[100]=De,e[101]=u,e[102]=f,e[103]=xt,e[104]=qe,e[105]=A,e[106]=I,e[107]=ve):ve=e[107];let je;e[108]!==h?.footnote||e[109]!==h?.source||e[110]!==N||e[111]!==q||e[112]!==s?.footnote||e[113]!==s?.source||e[114]!==f?(je=q||N?t.jsxRuntimeExports.jsx(Ut.GraphFooter,{styles:{footnote:s?.footnote,source:s?.source},classNames:{footnote:h?.footnote,source:h?.source},sources:q,footNote:N,width:f}):null,e[108]=h?.footnote,e[109]=h?.source,e[110]=N,e[111]=q,e[112]=s?.footnote,e[113]=s?.source,e[114]=f,e[115]=je):je=e[115];let st;return e[116]!==E||e[117]!==F||e[118]!==C||e[119]!==x||e[120]!==n||e[121]!==m||e[122]!==Ee||e[123]!==y||e[124]!==bt||e[125]!==Et||e[126]!==fe||e[127]!==ye||e[128]!==ve||e[129]!==je||e[130]!==j||e[131]!==f?(st=t.jsxRuntimeExports.jsxs(Nt.GraphContainer,{className:bt,style:Et,id:C,ref:Rt,"aria-label":E,backgroundColor:F,theme:j,language:n,minHeight:m,width:f,height:x,relativeHeight:y,padding:Ee,children:[fe,ye,ve,je]}),e[116]=E,e[117]=F,e[118]=C,e[119]=x,e[120]=n,e[121]=m,e[122]=Ee,e[123]=y,e[124]=bt,e[125]=Et,e[126]=fe,e[127]=ye,e[128]=ve,e[129]=je,e[130]=j,e[131]=f,e[132]=st):st=e[132],st}function Qt(p){return p!==void 0}function eo(p){return p!==void 0}function to(p){return p.data}function oo(p){return p!==void 0}function ro(p){return p.data}function ao(p){return p.properties?.NAME!=="Antarctica"}function no(p){return p.x}function so(p,e){return p-e}function io(p){return p.date}exports.ChoroplethMap=Kt;
2
2
  //# sourceMappingURL=ChoroplethMap.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChoroplethMap.cjs","sources":["../src/Components/Graphs/Maps/ChoroplethMap/Graph.tsx","../src/Components/Graphs/Maps/ChoroplethMap/index.tsx"],"sourcesContent":["import isEqual from 'fast-deep-equal';\r\nimport { RefObject, useEffect, useMemo, useRef, useState } from 'react';\r\nimport {\r\n geoAlbersUsa,\r\n geoEqualEarth,\r\n geoMercator,\r\n geoNaturalEarth1,\r\n geoOrthographic,\r\n geoPath,\r\n} from 'd3-geo';\r\nimport { D3ZoomEvent, zoom, ZoomBehavior } from 'd3-zoom';\r\nimport { select } from 'd3-selection';\r\nimport { scaleThreshold, scaleOrdinal } from 'd3-scale';\r\nimport { P } from '@undp/design-system-react/Typography';\r\nimport bbox from '@turf/bbox';\r\nimport centerOfMass from '@turf/center-of-mass';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport rewind from '@turf/rewind';\r\nimport { FeatureCollection } from 'geojson';\r\n\r\nimport {\r\n AnimateDataType,\r\n ChoroplethMapDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n MapProjectionTypes,\r\n NumberFormatOptions,\r\n StyleObject,\r\n ZoomInteractionTypes,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { ExpandIcon, X } from '@/Components/Icons';\r\nimport { DetailsModal } from '@/Components/Elements/DetailsModal';\r\nimport { ImageDownloadButton } from '@/Components/Actions/ImageDownloadButton';\r\nimport { CsvDownloadButton } from '@/Components/Actions/CsvDownloadButton';\r\n\r\ninterface Props {\r\n colorDomain: (number | string)[];\r\n mapData: FeatureCollection;\r\n width: number;\r\n height: number;\r\n colors: string[];\r\n colorLegendTitle?: string;\r\n categorical: boolean;\r\n data: ChoroplethMapDataType[];\r\n scale: number;\r\n centerPoint?: [number, number];\r\n mapBorderWidth: number;\r\n mapNoDataColor: string;\r\n mapBorderColor: string;\r\n isWorldMap: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n showColorScale: boolean;\r\n zoomScaleExtend: [number, number];\r\n zoomTranslateExtend?: [[number, number], [number, number]];\r\n highlightedIds?: string[];\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n mapProperty: string;\r\n resetSelectionOnDoubleClick: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n zoomInteraction: ZoomInteractionTypes;\r\n mapProjection: MapProjectionTypes;\r\n animate: AnimateDataType;\r\n dimmedOpacity: number;\r\n customLayers: CustomLayerDataType[];\r\n collapseColorScaleByDefault?: boolean;\r\n zoomAndCenterByHighlightedIds: boolean;\r\n projectionRotate: [number, number] | [number, number, number];\r\n rewindCoordinatesInMapData: boolean;\r\n overlayMapData?: FeatureCollection;\r\n overlayMapBorderColor?: string;\r\n overlayMapBorderWidth?: number;\r\n numberDisplayOptions?: Omit<NumberFormatOptions, 'suffix' | 'prefix'>;\r\n graphDownload?: RefObject<HTMLDivElement | null>;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n dataDownload: any;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n colorDomain,\r\n colors,\r\n mapData,\r\n colorLegendTitle,\r\n categorical,\r\n height,\r\n width,\r\n scale,\r\n centerPoint,\r\n tooltip,\r\n mapBorderWidth,\r\n mapBorderColor,\r\n mapNoDataColor,\r\n onSeriesMouseOver,\r\n showColorScale,\r\n zoomScaleExtend,\r\n zoomTranslateExtend,\r\n highlightedIds,\r\n onSeriesMouseClick,\r\n mapProperty,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n mapProjection,\r\n zoomInteraction,\r\n animate,\r\n dimmedOpacity,\r\n customLayers,\r\n collapseColorScaleByDefault,\r\n zoomAndCenterByHighlightedIds,\r\n projectionRotate,\r\n rewindCoordinatesInMapData,\r\n overlayMapData,\r\n overlayMapBorderColor,\r\n overlayMapBorderWidth,\r\n numberDisplayOptions,\r\n graphDownload,\r\n dataDownload,\r\n } = props;\r\n const formattedMapData = useMemo(() => {\r\n if (!rewindCoordinatesInMapData) return mapData;\r\n\r\n return rewind(mapData, { reverse: true }) as FeatureCollection;\r\n }, [mapData, rewindCoordinatesInMapData]);\r\n const formattedOverlayMapData = useMemo(() => {\r\n if (!rewindCoordinatesInMapData || !overlayMapData) return overlayMapData;\r\n\r\n return rewind(overlayMapData, { reverse: true }) as FeatureCollection;\r\n }, [overlayMapData, rewindCoordinatesInMapData]);\r\n const [selectedColor, setSelectedColor] = useState<string | undefined>(undefined);\r\n const zoomRef = useRef<ZoomBehavior<SVGSVGElement, unknown> | null>(null);\r\n const [showLegend, setShowLegend] = useState(\r\n collapseColorScaleByDefault === undefined ? !(width < 680) : !collapseColorScaleByDefault,\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const mapSvg = useRef<SVGSVGElement>(null);\r\n const isInView = useInView(mapSvg, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const mapG = useRef<SVGGElement>(null);\r\n const colorScale = categorical\r\n ? scaleOrdinal<number | string, string>().domain(colorDomain).range(colors)\r\n : scaleThreshold<number, string>()\r\n .domain(colorDomain as number[])\r\n .range(colors);\r\n\r\n useEffect(() => {\r\n const mapGSelect = select(mapG.current);\r\n const mapSvgSelect = select(mapSvg.current);\r\n const zoomFilter = (e: D3ZoomEvent<SVGSVGElement, unknown>['sourceEvent']) => {\r\n if (zoomInteraction === 'noZoom') return false;\r\n if (zoomInteraction === 'button') return !e.type.includes('wheel');\r\n const isWheel = e.type === 'wheel';\r\n const isTouch = e.type.startsWith('touch');\r\n const isDrag = e.type === 'mousedown' || e.type === 'mousemove';\r\n\r\n if (isTouch) return true;\r\n if (isWheel) {\r\n if (zoomInteraction === 'scroll') return true;\r\n return e.ctrlKey;\r\n }\r\n return isDrag && !e.button && !e.ctrlKey;\r\n };\r\n const zoomBehavior = zoom<SVGSVGElement, unknown>()\r\n .scaleExtent(zoomScaleExtend)\r\n .translateExtent(\r\n zoomTranslateExtend || [\r\n [-20, -20],\r\n [width + 20, height + 20],\r\n ],\r\n )\r\n .filter(zoomFilter)\r\n .on('zoom', ({ transform }) => {\r\n mapGSelect.attr('transform', transform);\r\n });\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n mapSvgSelect.call(zoomBehavior as any);\r\n\r\n zoomRef.current = zoomBehavior;\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [height, width, zoomInteraction]);\r\n\r\n const bounds = bbox({\r\n ...formattedMapData,\r\n features: zoomAndCenterByHighlightedIds\r\n ? formattedMapData.features.filter(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d: any) =>\r\n (highlightedIds || []).length === 0 ||\r\n highlightedIds?.indexOf(d.properties[mapProperty]) !== -1,\r\n )\r\n : formattedMapData.features,\r\n });\r\n\r\n const center = centerOfMass({\r\n ...formattedMapData,\r\n features: zoomAndCenterByHighlightedIds\r\n ? formattedMapData.features.filter(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d: any) =>\r\n (highlightedIds || []).length === 0 ||\r\n highlightedIds?.indexOf(d.properties[mapProperty]) !== -1,\r\n )\r\n : formattedMapData.features,\r\n });\r\n const lonDiff = (bounds[2] - bounds[0]) * 1.15;\r\n const latDiff = (bounds[3] - bounds[1]) * 1.15;\r\n const scaleX = (((width * 190) / 960) * 360) / lonDiff;\r\n const scaleY = (((height * 190) / 678) * 180) / latDiff;\r\n const scaleVar = scale * Math.min(scaleX, scaleY);\r\n\r\n const projection =\r\n mapProjection === 'mercator'\r\n ? geoMercator()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar)\r\n : mapProjection === 'equalEarth'\r\n ? geoEqualEarth()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar)\r\n : mapProjection === 'naturalEarth'\r\n ? geoNaturalEarth1()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar)\r\n : mapProjection === 'orthographic'\r\n ? geoOrthographic()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar)\r\n : geoAlbersUsa()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar);\r\n const pathGenerator = geoPath().projection(projection);\r\n const handleZoom = (direction: 'in' | 'out') => {\r\n if (!mapSvg.current || !zoomRef.current) return;\r\n const svg = select(mapSvg.current);\r\n svg.call(zoomRef.current.scaleBy, direction === 'in' ? 1.2 : 1 / 1.2);\r\n };\r\n return (\r\n <>\r\n <div className='relative'>\r\n <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n ref={mapSvg}\r\n direction='ltr'\r\n >\r\n <g ref={mapG}>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n {formattedMapData.features.map((d, i: number) => {\r\n if (!d.properties?.[mapProperty]) return null;\r\n const path = pathGenerator(d);\r\n if (!path) return null;\r\n return (\r\n <motion.g\r\n key={i}\r\n opacity={\r\n selectedColor\r\n ? dimmedOpacity\r\n : highlightedIds\r\n ? highlightedIds.indexOf(d.properties[mapProperty]) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1\r\n }\r\n >\r\n <path\r\n d={path}\r\n style={{\r\n stroke: mapBorderColor,\r\n strokeWidth: mapBorderWidth,\r\n fill: mapNoDataColor,\r\n vectorEffect: 'non-scaling-stroke',\r\n }}\r\n />\r\n </motion.g>\r\n );\r\n })}\r\n <AnimatePresence>\r\n {data.map(d => {\r\n const index = formattedMapData.features.findIndex(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (el: any) => d.id === el.properties[mapProperty],\r\n );\r\n if (index === -1) return null;\r\n const path = pathGenerator(formattedMapData.features[index]);\r\n if (!path) return null;\r\n const color = !checkIfNullOrUndefined(d.x)\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n colorScale(d.x as any)\r\n : mapNoDataColor;\r\n return (\r\n <motion.g\r\n className='undp-map-shapes'\r\n key={d.id}\r\n variants={{\r\n initial: { opacity: 0 },\r\n whileInView: {\r\n opacity: selectedColor\r\n ? selectedColor === color\r\n ? !highlightedIds || highlightedIds.indexOf(d.id) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : highlightedIds\r\n ? highlightedIds.indexOf(d.id) !== -1\r\n ? 1\r\n : dimmedOpacity\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 onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\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 onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d);\r\n onSeriesMouseClick?.(d);\r\n }\r\n }\r\n }}\r\n >\r\n <motion.path\r\n key={`${d.id}`}\r\n d={path}\r\n variants={{\r\n initial: { fill: color, opacity: 0 },\r\n whileInView: {\r\n fill: color,\r\n opacity: 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: mapBorderColor,\r\n strokeWidth: mapBorderWidth,\r\n vectorEffect: 'non-scaling-stroke',\r\n }}\r\n />\r\n </motion.g>\r\n );\r\n })}\r\n </AnimatePresence>\r\n {mouseOverData\r\n ? formattedMapData.features\r\n .filter(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d: { properties: any }) => d.properties[mapProperty] === mouseOverData.id,\r\n )\r\n .map((d, i) => (\r\n <path\r\n key={i}\r\n d={pathGenerator(d) || ''}\r\n className='stroke-primary-gray-700 dark:stroke-primary-gray-300'\r\n style={{\r\n fill: 'none',\r\n fillOpacity: 0,\r\n strokeWidth: '0.5',\r\n vectorEffect: 'non-scaling-stroke',\r\n }}\r\n />\r\n ))\r\n : null}\r\n {formattedOverlayMapData?.features.map((d, i: number) => {\r\n const path = pathGenerator(d);\r\n if (!path) return null;\r\n return (\r\n <g key={i}>\r\n <path\r\n d={path}\r\n style={{\r\n stroke: overlayMapBorderColor || mapBorderColor,\r\n strokeWidth: overlayMapBorderWidth || mapBorderWidth + 1,\r\n fill: 'none',\r\n pointerEvents: 'none',\r\n vectorEffect: 'non-scaling-stroke',\r\n }}\r\n />\r\n </g>\r\n );\r\n })}\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\r\n </g>\r\n </motion.svg>\r\n {showColorScale === false ? null : (\r\n <div className={cn('absolute left-4 bottom-4 map-color-legend', classNames?.colorLegend)}>\r\n {showLegend ? (\r\n <>\r\n <div\r\n className='color-legend-close-button bg-[rgba(240,240,240,0.7)] dark:bg-[rgba(30,30,30,0.7)] border border-[var(--gray-400)] rounded-full w-6 h-6 p-[3px] cursor-pointer z-10 absolute right-[-0.75rem] top-[-0.75rem]'\r\n onClick={() => {\r\n setShowLegend(false);\r\n }}\r\n >\r\n <X />\r\n </div>\r\n <div\r\n className='color-legend-box p-2 bg-[rgba(240,240,240,0.7)] dark:bg-[rgba(30,30,30,0.7)]'\r\n style={{\r\n width: categorical ? undefined : '340px',\r\n }}\r\n >\r\n {colorLegendTitle && colorLegendTitle !== '' ? (\r\n <P\r\n size='xs'\r\n marginBottom='xs'\r\n className='p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300'\r\n style={{\r\n display: '-webkit-box',\r\n WebkitLineClamp: '1',\r\n WebkitBoxOrient: 'vertical',\r\n }}\r\n >\r\n {colorLegendTitle}\r\n </P>\r\n ) : null}\r\n {!categorical ? (\r\n <svg width='100%' viewBox='0 0 320 30' direction='ltr'>\r\n <g>\r\n {colorDomain.map((d, i) => (\r\n <g\r\n key={i}\r\n onMouseOver={() => {\r\n setSelectedColor(colors[i]);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedColor(undefined);\r\n }}\r\n className='cursor-pointer'\r\n >\r\n <rect\r\n x={(i * 320) / colors.length + 1}\r\n y={1}\r\n width={320 / colors.length - 2}\r\n height={8}\r\n className={\r\n selectedColor === colors[i]\r\n ? 'stroke-primary-gray-700 dark:stroke-primary-gray-300'\r\n : ''\r\n }\r\n style={{\r\n fill: colors[i],\r\n ...(selectedColor === colors[i] ? {} : { stroke: colors[i] }),\r\n }}\r\n />\r\n <text\r\n x={((i + 1) * 320) / colors.length}\r\n y={25}\r\n className='fill-primary-gray-700 dark:fill-primary-gray-300 text-xs'\r\n style={{ textAnchor: 'middle' }}\r\n >\r\n {numberFormattingFunction(\r\n d as number,\r\n 'NA',\r\n numberDisplayOptions?.precision ?? 2,\r\n undefined,\r\n undefined,\r\n numberDisplayOptions?.locale || 'en',\r\n numberDisplayOptions?.padZeros || false,\r\n )}\r\n </text>\r\n </g>\r\n ))}\r\n <g>\r\n <rect\r\n onMouseOver={() => {\r\n setSelectedColor(colors[colorDomain.length]);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedColor(undefined);\r\n }}\r\n x={(colorDomain.length * 320) / colors.length + 1}\r\n y={1}\r\n width={320 / colors.length - 2}\r\n height={8}\r\n className={`cursor-pointer ${\r\n selectedColor === colors[colorDomain.length]\r\n ? 'stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300'\r\n : ''\r\n }`}\r\n style={{\r\n fill: colors[colorDomain.length],\r\n ...(selectedColor === colors[colorDomain.length]\r\n ? {}\r\n : { stroke: colors[colorDomain.length] }),\r\n }}\r\n />\r\n </g>\r\n </g>\r\n </svg>\r\n ) : (\r\n <div className='flex flex-col gap-3'>\r\n {colorDomain.map((d, i) => (\r\n <div\r\n key={i}\r\n className='flex gap-2 items-center'\r\n onMouseOver={() => {\r\n setSelectedColor(colors[i % colors.length]);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedColor(undefined);\r\n }}\r\n >\r\n <div\r\n className='w-2 h-2 rounded-full'\r\n style={{ backgroundColor: colors[i % colors.length] }}\r\n />\r\n <P size='sm' marginBottom='none' leading='none'>\r\n {d}\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n ) : (\r\n <button\r\n type='button'\r\n className='p-1 border-0 rounded-[2px] text-primary-gray-700 bg-primary-gray-300 dark:bg-primary-gray-500 map-legend-button'\r\n onClick={() => {\r\n setShowLegend(true);\r\n }}\r\n >\r\n <ExpandIcon />\r\n </button>\r\n )}\r\n </div>\r\n )}\r\n {zoomInteraction === 'button' && (\r\n <div className='absolute left-4 top-4 flex flex-col undp-viz-zoom-buttons'>\r\n <button\r\n onClick={() => handleZoom('in')}\r\n className='leading-0 px-2 py-3.5 text-primary-gray-700 border border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-550 dark:bg-primary-gray-600 dark:text-primary-gray-100'\r\n >\r\n +\r\n </button>\r\n <button\r\n onClick={() => handleZoom('out')}\r\n className='leading-0 px-2 py-3.5 text-primary-gray-700 border border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-550 dark:bg-primary-gray-600 dark:text-primary-gray-100'\r\n >\r\n –\r\n </button>\r\n </div>\r\n )}\r\n {(graphDownload || dataDownload) && (\r\n <div className='absolute right-4 top-4 flex flex-col image-download-button gap-2'>\r\n {graphDownload && (\r\n <ImageDownloadButton nodeID={graphDownload} buttonSmall className='p-1' />\r\n )}\r\n {dataDownload && dataDownload.length > 0 && (\r\n <CsvDownloadButton\r\n csvData={dataDownload}\r\n buttonSmall\r\n headers={Object.keys(dataDownload[0]).map(d => ({\r\n label: d,\r\n key: d,\r\n }))}\r\n className='p-1'\r\n />\r\n )}\r\n </div>\r\n )}\r\n </div>\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 {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 </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect, useEffectEvent, useMemo } from 'react';\r\nimport { SliderUI } from '@undp/design-system-react/SliderUI';\r\nimport { Spinner } from '@undp/design-system-react/Spinner';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { FeatureCollection } from 'geojson';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n ChoroplethMapDataType,\r\n Languages,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n ScaleDataType,\r\n MapProjectionTypes,\r\n ZoomInteractionTypes,\r\n CustomLayerDataType,\r\n AnimateDataType,\r\n TimelineDataType,\r\n MapOverlayDataType,\r\n NumberFormatOptions,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { fetchAndParseJSON } from '@/Utils/fetchAndParseData';\r\nimport { getUniqValue } from '@/Utils/getUniqValue';\r\nimport { getJenks } from '@/Utils/getJenks';\r\nimport { Pause, Play } from '@/Components/Icons';\r\nimport { getSliderMarks } from '@/Utils/getSliderMarks';\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: ChoroplethMapDataType[];\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 /** Colors for the choropleth map */\r\n colors?: string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: number[] | string[];\r\n /** Title for the color legend */\r\n colorLegendTitle?: string;\r\n /** Color for the areas where data is no available */\r\n mapNoDataColor?: 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\r\n // Graph Parameters\r\n /** Map data as an object in geoJson format or a url for geoJson */\r\n mapData?: FeatureCollection | string;\r\n /** Detail if any other map needs to be overlayed over the main map */\r\n mapOverlay?: MapOverlayDataType;\r\n /** Defines if the coordinates in the map data should be rewinded or not. Try to change this is the visualization shows countries as holes instead of shapes. */\r\n rewindCoordinatesInMapData?: boolean;\r\n /** Scaling factor for the map. Multiplies the scale number to scale. */\r\n scale?: number;\r\n /** Toggle if the map is centered and zoomed to the highlighted ids. */\r\n zoomAndCenterByHighlightedIds?: boolean;\r\n /** Center point of the map */\r\n centerPoint?: [number, number];\r\n /** Controls the rotation of the map projection, in degrees, applied before rendering. Useful for shifting the antimeridian to focus the map on different regions */\r\n projectionRotate?: [number, number] | [number, number, number];\r\n /** Defines the zoom mode for the map */\r\n zoomInteraction?: ZoomInteractionTypes;\r\n /** Stroke width of the regions in the map */\r\n mapBorderWidth?: number;\r\n /** Stroke color of the regions in the map */\r\n mapBorderColor?: string;\r\n /** Toggle if the map is a world map */\r\n isWorldMap?: boolean;\r\n /** Map projection type */\r\n mapProjection?: MapProjectionTypes;\r\n /** Extend of the allowed zoom in the map */\r\n zoomScaleExtend?: [number, number];\r\n /** Extend of the allowed panning in the map */\r\n zoomTranslateExtend?: [[number, number], [number, number]];\r\n /** Countries or regions to be highlighted */\r\n highlightedIds?: string[];\r\n /** Defines the opacity of the non-highlighted data */\r\n dimmedOpacity?: number;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Scale for the colors */\r\n scaleType?: Exclude<ScaleDataType, 'linear'>;\r\n /** Toggle visibility of color scale. */\r\n showColorScale?: boolean;\r\n /** Toggle if color scale is collapsed by default. */\r\n collapseColorScaleByDefault?: boolean;\r\n /** Property in the property object in mapData geoJson object is used to match to the id in the data object */\r\n mapProperty?: string;\r\n /** Toggles the visibility of Antarctica in the default map. Only applicable for the default map. */\r\n showAntarctica?: boolean;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** Configures playback and slider controls for animating the chart over time. The data must have a key date for it to work properly. */\r\n timeline?: TimelineDataType;\r\n /** Configuration options for controlling number formatting, localization, precision, and zero padding. */\r\n numberDisplayOptions?: Omit<NumberFormatOptions, 'suffix' | 'prefix'>;\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 ChoroplethMap(props: Props) {\r\n const {\r\n data,\r\n mapData = 'https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-v2.json',\r\n graphTitle,\r\n colors,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote = 'The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.',\r\n colorDomain,\r\n colorLegendTitle,\r\n scaleType = 'threshold',\r\n scale = 0.95,\r\n centerPoint,\r\n padding,\r\n mapBorderWidth = 0.5,\r\n mapNoDataColor = Colors.light.graphNoData,\r\n backgroundColor = false,\r\n mapBorderColor = Colors.light.grays['gray-500'],\r\n relativeHeight,\r\n tooltip,\r\n onSeriesMouseOver,\r\n isWorldMap = true,\r\n showColorScale = true,\r\n zoomScaleExtend = [0.8, 6],\r\n zoomTranslateExtend,\r\n graphID,\r\n highlightedIds,\r\n onSeriesMouseClick,\r\n mapProperty = 'ISO3',\r\n graphDownload = false,\r\n dataDownload = false,\r\n showAntarctica = false,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n mapProjection = 'naturalEarth',\r\n zoomInteraction = 'button',\r\n animate = false,\r\n dimmedOpacity = 0.3,\r\n customLayers = [],\r\n timeline = { enabled: false, autoplay: false, showOnlyActiveDate: true },\r\n collapseColorScaleByDefault,\r\n projectionRotate = [0, 0],\r\n zoomAndCenterByHighlightedIds = false,\r\n rewindCoordinatesInMapData = true,\r\n mapOverlay,\r\n numberDisplayOptions,\r\n } = props;\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [play, setPlay] = useState(timeline.autoplay);\r\n const uniqDatesSorted = useMemo(() => {\r\n const dates = [\r\n ...new Set(\r\n data\r\n .filter(d => d.date)\r\n .map(d => parse(`${d.date}`, timeline.dateFormat || 'yyyy', new Date()).getTime()),\r\n ),\r\n ];\r\n dates.sort((a, b) => a - b);\r\n return dates;\r\n }, [data, timeline.dateFormat]);\r\n const [index, setIndex] = useState(timeline.autoplay ? 0 : uniqDatesSorted.length - 1);\r\n\r\n const [mapShape, setMapShape] = useState<FeatureCollection | undefined>(undefined);\r\n const [overlayMapShape, setOverlayMapShape] = useState<FeatureCollection | undefined>(undefined);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(entries[0].target.clientWidth || 620);\r\n setSvgHeight(entries[0].target.clientHeight || 480);\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 onUpdateShape = useEffectEvent((shape: FeatureCollection) => {\r\n setMapShape(shape);\r\n });\r\n\r\n const onUpdateOverlayMapShape = useEffectEvent((shape: FeatureCollection | undefined) => {\r\n setOverlayMapShape(shape);\r\n });\r\n useEffect(() => {\r\n if (typeof mapData === 'string') {\r\n const fetchData = fetchAndParseJSON(mapData);\r\n fetchData.then(d => {\r\n onUpdateShape(d);\r\n });\r\n } else {\r\n onUpdateShape(mapData);\r\n }\r\n }, [mapData]);\r\n useEffect(() => {\r\n if (!mapOverlay?.mapData) onUpdateOverlayMapShape(undefined);\r\n if (typeof mapOverlay?.mapData === 'string') {\r\n const fetchData = fetchAndParseJSON(mapOverlay?.mapData);\r\n fetchData.then(d => {\r\n onUpdateOverlayMapShape(d as FeatureCollection);\r\n });\r\n } else {\r\n onUpdateOverlayMapShape(mapOverlay?.mapData);\r\n }\r\n }, [mapOverlay?.mapData]);\r\n\r\n const domain =\r\n colorDomain ||\r\n (scaleType === 'categorical'\r\n ? getUniqValue(data, 'x')\r\n : getJenks(\r\n data.map(d => d.x as number | null | undefined),\r\n colors?.length || 4,\r\n ));\r\n\r\n useEffect(() => {\r\n const interval = setInterval(\r\n () => {\r\n setIndex(i => (i < uniqDatesSorted.length - 1 ? i + 1 : 0));\r\n },\r\n (timeline.speed || 2) * 1000,\r\n );\r\n if (!play) clearInterval(interval);\r\n return () => clearInterval(interval);\r\n }, [uniqDatesSorted, play, timeline.speed]);\r\n\r\n const markObj = getSliderMarks(\r\n uniqDatesSorted,\r\n index,\r\n timeline.showOnlyActiveDate,\r\n timeline.dateFormat || 'yyyy',\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 ? (\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 />\r\n ) : null}\r\n {timeline.enabled && uniqDatesSorted.length > 0 && markObj ? (\r\n <div className='flex gap-6 items-center' dir='ltr'>\r\n <button\r\n type='button'\r\n onClick={() => {\r\n setPlay(!play);\r\n }}\r\n className='p-0 border-0 cursor-pointer bg-transparent'\r\n aria-label={play ? 'Click to pause animation' : 'Click to play animation'}\r\n >\r\n {play ? <Pause /> : <Play />}\r\n </button>\r\n <SliderUI\r\n min={uniqDatesSorted[0]}\r\n max={uniqDatesSorted[uniqDatesSorted.length - 1]}\r\n marks={markObj}\r\n step={null}\r\n defaultValue={uniqDatesSorted[uniqDatesSorted.length - 1]}\r\n value={uniqDatesSorted[index]}\r\n onChangeComplete={nextValue => {\r\n setIndex(uniqDatesSorted.indexOf(nextValue as number));\r\n }}\r\n onChange={nextValue => {\r\n setIndex(uniqDatesSorted.indexOf(nextValue as number));\r\n }}\r\n aria-label='Time slider. Use arrow keys to adjust selected time period.'\r\n />\r\n </div>\r\n ) : null}\r\n <GraphArea ref={graphDiv}>\r\n {svgWidth && svgHeight && mapShape ? (\r\n <Graph\r\n data={data.filter(d =>\r\n timeline.enabled\r\n ? `${d.date}` ===\r\n format(new Date(uniqDatesSorted[index]), timeline.dateFormat || 'yyyy')\r\n : d,\r\n )}\r\n mapData={\r\n showAntarctica\r\n ? mapShape\r\n : {\r\n ...mapShape,\r\n features: mapShape.features.filter(el => el.properties?.NAME !== 'Antarctica'),\r\n }\r\n }\r\n colorDomain={domain}\r\n width={svgWidth}\r\n height={svgHeight}\r\n scale={scale}\r\n centerPoint={centerPoint}\r\n colors={\r\n colors ||\r\n (scaleType === 'categorical'\r\n ? Colors[theme].categoricalColors.colors\r\n : Colors[theme].sequentialColors[\r\n `neutralColorsx0${(domain.length + 1) as 4 | 5 | 6 | 7 | 8 | 9}`\r\n ])\r\n }\r\n colorLegendTitle={colorLegendTitle}\r\n mapBorderWidth={mapBorderWidth}\r\n mapNoDataColor={mapNoDataColor}\r\n categorical={scaleType === 'categorical'}\r\n mapBorderColor={mapBorderColor}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n isWorldMap={isWorldMap}\r\n showColorScale={showColorScale}\r\n zoomScaleExtend={zoomScaleExtend}\r\n zoomTranslateExtend={zoomTranslateExtend}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n mapProperty={mapProperty}\r\n highlightedIds={highlightedIds}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n styles={styles}\r\n overlayMapData={overlayMapShape}\r\n overlayMapBorderColor={mapOverlay?.mapBorderColor}\r\n overlayMapBorderWidth={mapOverlay?.mapBorderWidth}\r\n classNames={classNames}\r\n detailsOnClick={detailsOnClick}\r\n mapProjection={mapProjection || (isWorldMap ? 'naturalEarth' : 'mercator')}\r\n zoomInteraction={zoomInteraction}\r\n dimmedOpacity={dimmedOpacity}\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 customLayers={customLayers}\r\n zoomAndCenterByHighlightedIds={zoomAndCenterByHighlightedIds}\r\n collapseColorScaleByDefault={collapseColorScaleByDefault}\r\n projectionRotate={projectionRotate}\r\n rewindCoordinatesInMapData={rewindCoordinatesInMapData}\r\n numberDisplayOptions={numberDisplayOptions}\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 ) : (\r\n <div\r\n style={{\r\n height: `${Math.max(\r\n minHeight,\r\n height ||\r\n (relativeHeight\r\n ? minHeight\r\n ? (width || svgWidth) * relativeHeight > minHeight\r\n ? (width || svgWidth) * relativeHeight\r\n : minHeight\r\n : (width || svgWidth) * relativeHeight\r\n : svgHeight),\r\n )}px`,\r\n }}\r\n className='flex items-center justify-center'\r\n >\r\n <Spinner aria-label='Loading graph' />\r\n </div>\r\n )}\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":["Graph","props","data","colorDomain","colors","mapData","colorLegendTitle","categorical","height","width","scale","centerPoint","tooltip","mapBorderWidth","mapBorderColor","mapNoDataColor","onSeriesMouseOver","showColorScale","zoomScaleExtend","zoomTranslateExtend","highlightedIds","onSeriesMouseClick","mapProperty","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","mapProjection","zoomInteraction","animate","dimmedOpacity","customLayers","collapseColorScaleByDefault","zoomAndCenterByHighlightedIds","projectionRotate","rewindCoordinatesInMapData","overlayMapData","overlayMapBorderColor","overlayMapBorderWidth","numberDisplayOptions","graphDownload","dataDownload","formattedMapData","useMemo","rewind","reverse","formattedOverlayMapData","selectedColor","setSelectedColor","useState","undefined","zoomRef","useRef","showLegend","setShowLegend","mouseClickData","setMouseClickData","mouseOverData","setMouseOverData","eventX","setEventX","eventY","setEventY","mapSvg","isInView","useInView","once","amount","mapG","colorScale","scaleOrdinal","domain","range","scaleThreshold","useEffect","mapGSelect","select","current","mapSvgSelect","zoomFilter","e","type","includes","isWheel","isTouch","startsWith","isDrag","ctrlKey","button","zoomBehavior","zoom","scaleExtent","translateExtent","filter","on","transform","attr","call","bounds","bbox","features","d","length","indexOf","properties","center","centerOfMass","lonDiff","latDiff","scaleX","scaleY","scaleVar","Math","min","projection","geoMercator","rotate","geometry","coordinates","translate","geoEqualEarth","geoNaturalEarth1","geoOrthographic","geoAlbersUsa","pathGenerator","geoPath","handleZoom","direction","scaleBy","jsxs","Fragment","jsx","motion","position","map","layer","i","path","stroke","strokeWidth","fill","vectorEffect","AnimatePresence","index","findIndex","el","id","color","checkIfNullOrUndefined","x","initial","opacity","whileInView","transition","duration","event","clientY","clientX","isEqual","fillOpacity","pointerEvents","cn","colorLegend","X","P","display","WebkitLineClamp","WebkitBoxOrient","backgroundColor","textAnchor","numberFormattingFunction","precision","locale","padZeros","ExpandIcon","ImageDownloadButton","CsvDownloadButton","Object","keys","label","key","DetailsModal","modal","Tooltip","ChoroplethMap","$","_c","t0","graphTitle","sources","graphDescription","footNote","t1","scaleType","t2","t3","padding","t4","t5","t6","t7","relativeHeight","isWorldMap","t8","t9","t10","graphID","t11","t12","t13","showAntarctica","t14","language","t15","minHeight","t16","theme","t17","ariaLabel","t18","t19","t20","t21","t22","t23","timeline","t24","t25","t26","t27","mapOverlay","Colors","light","graphNoData","grays","t28","t29","t30","enabled","autoplay","showOnlyActiveDate","t31","svgWidth","setSvgWidth","svgHeight","setSvgHeight","play","setPlay","dates","dateFormat","t32","d_0","parse","date","Date","getTime","Set","_temp","sort","_temp2","uniqDatesSorted","setIndex","mapShape","setMapShape","overlayMapShape","setOverlayMapShape","graphDiv","graphParentDiv","t33","Symbol","for","resizeObserver","ResizeObserver","entries","target","clientWidth","clientHeight","observe","disconnect","t34","shape","onUpdateShape","useEffectEvent","t35","shape_0","onUpdateOverlayMapShape","t36","fetchAndParseJSON","then","d_1","t37","t38","d_2","t39","t40","t41","getUniqValue","getJenks","_temp3","t42","t43","speed","interval","setInterval","clearInterval","t44","t45","getSliderMarks","markObj","t46","graphContainer","t47","t48","description","title","GraphHeader","t49","Pause","Play","SliderUI","nextValue","nextValue_0","t50","GraphArea","d_4","format","_temp4","categoricalColors","sequentialColors","_temp5","_temp6","_temp7","_temp8","_temp9","max","Spinner","t51","footnote","source","GraphFooter","t52","GraphContainer","d_7","d_6","d_5","d_9","d_8","NAME","d_3","a","b"],"mappings":"uqCAwFO,SAASA,GAAMC,EAAc,CAClC,KAAM,CACJC,KAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,QAAAA,EACAC,iBAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,MAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,QAAAA,GACAC,eAAAA,EACAC,eAAAA,GACAC,eAAAA,GACAC,kBAAAA,GACAC,eAAAA,GACAC,gBAAAA,GACAC,oBAAAA,GACAC,eAAAA,EACAC,mBAAAA,GACAC,YAAAA,EACAC,4BAAAA,GACAC,eAAAA,E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,GAAA9H,OAAA+H,GAAA/H,OAAAmI,GAAAnI,OAAAyI,GAAAzI,OAAAuJ,GAAAvJ,OAAA+B,EAAA/B,OAAAhL,EAAAgL,OAAA2J,IAAAA,GAAA3J,EAAA,GAAA,EAtKjB2J,EAsKiB,CAtTd,SAAAP,GAAAS,EAAA,CAAA,OAiR8BjP,IAAMnD,MAAS,CAjR7C,SAAA0R,GAAAW,EAAA,CAAA,OAgR+ClP,IAAMnD,MAAS,CAhR9D,SAAAyR,GAAAa,EAAA,CAAA,OAgR2BnP,EAACnG,IAAK,CAhRjC,SAAAwU,GAAAe,EAAA,CAAA,OA+Q6CpP,IAAMnD,MAAS,CA/Q5D,SAAAuR,GAAAiB,EAAA,CAAA,OA+QyBrP,EAACnG,IAAK,CA/Q/B,SAAAoU,GAAArL,EAAA,CAAA,OAyNsDA,EAAEzC,YAAiBmP,OAAK,YAAY,CAzN1F,SAAAjD,GAAAkD,EAAA,CAAA,OA0HiBvP,EAACgD,CAA+B,CA1HjD,SAAA8G,GAAA0F,EAAAC,EAAA,CAAA,OAmEkBD,EAAIC,CAAC,CAnEvB,SAAA7F,GAAA5J,EAAA,CAAA,OA+DgBA,EAACwJ,IAAK"}
1
+ {"version":3,"file":"ChoroplethMap.cjs","sources":["../src/Components/Graphs/Maps/ChoroplethMap/Graph.tsx","../src/Components/Graphs/Maps/ChoroplethMap/index.tsx"],"sourcesContent":["import isEqual from 'fast-deep-equal';\r\nimport { RefObject, useEffect, useMemo, useRef, useState } from 'react';\r\nimport {\r\n geoAlbersUsa,\r\n geoEqualEarth,\r\n geoMercator,\r\n geoNaturalEarth1,\r\n geoOrthographic,\r\n geoPath,\r\n} from 'd3-geo';\r\nimport { D3ZoomEvent, zoom, ZoomBehavior } from 'd3-zoom';\r\nimport { select } from 'd3-selection';\r\nimport { scaleThreshold, scaleOrdinal } from 'd3-scale';\r\nimport { P } from '@undp/design-system-react/Typography';\r\nimport bbox from '@turf/bbox';\r\nimport centerOfMass from '@turf/center-of-mass';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport rewind from '@turf/rewind';\r\nimport { FeatureCollection } from 'geojson';\r\n\r\nimport {\r\n AnimateDataType,\r\n ChoroplethMapDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n MapProjectionTypes,\r\n NumberFormatOptions,\r\n StyleObject,\r\n ZoomInteractionTypes,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { ExpandIcon, X } from '@/Components/Icons';\r\nimport { DetailsModal } from '@/Components/Elements/DetailsModal';\r\nimport { ImageDownloadButton } from '@/Components/Actions/ImageDownloadButton';\r\nimport { CsvDownloadButton } from '@/Components/Actions/CsvDownloadButton';\r\n\r\ninterface Props {\r\n colorDomain: (number | string)[];\r\n mapData: FeatureCollection;\r\n width: number;\r\n height: number;\r\n colors: string[];\r\n colorLegendTitle?: string;\r\n categorical: boolean;\r\n data: ChoroplethMapDataType[];\r\n scale: number;\r\n centerPoint?: [number, number];\r\n mapBorderWidth: number;\r\n mapNoDataColor: string;\r\n mapBorderColor: string;\r\n isWorldMap: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n showColorScale: boolean;\r\n zoomScaleExtend: [number, number];\r\n zoomTranslateExtend?: [[number, number], [number, number]];\r\n highlightedIds?: string[];\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n mapProperty: string;\r\n resetSelectionOnDoubleClick: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n zoomInteraction: ZoomInteractionTypes;\r\n mapProjection: MapProjectionTypes;\r\n animate: AnimateDataType;\r\n dimmedOpacity: number;\r\n customLayers: CustomLayerDataType[];\r\n collapseColorScaleByDefault?: boolean;\r\n zoomAndCenterByHighlightedIds: boolean;\r\n projectionRotate: [number, number] | [number, number, number];\r\n rewindCoordinatesInMapData: boolean;\r\n overlayMapData?: FeatureCollection;\r\n overlayMapBorderColor?: string;\r\n overlayMapBorderWidth?: number;\r\n numberDisplayOptions?: Omit<NumberFormatOptions, 'suffix' | 'prefix'>;\r\n graphDownload?: RefObject<HTMLDivElement | null>;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n dataDownload: any;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n colorDomain,\r\n colors,\r\n mapData,\r\n colorLegendTitle,\r\n categorical,\r\n height,\r\n width,\r\n scale,\r\n centerPoint,\r\n tooltip,\r\n mapBorderWidth,\r\n mapBorderColor,\r\n mapNoDataColor,\r\n onSeriesMouseOver,\r\n showColorScale,\r\n zoomScaleExtend,\r\n zoomTranslateExtend,\r\n highlightedIds,\r\n onSeriesMouseClick,\r\n mapProperty,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n mapProjection,\r\n zoomInteraction,\r\n animate,\r\n dimmedOpacity,\r\n customLayers,\r\n collapseColorScaleByDefault,\r\n zoomAndCenterByHighlightedIds,\r\n projectionRotate,\r\n rewindCoordinatesInMapData,\r\n overlayMapData,\r\n overlayMapBorderColor,\r\n overlayMapBorderWidth,\r\n numberDisplayOptions,\r\n graphDownload,\r\n dataDownload,\r\n } = props;\r\n const formattedMapData = useMemo(() => {\r\n if (!rewindCoordinatesInMapData) return mapData;\r\n\r\n return rewind(mapData, { reverse: true }) as FeatureCollection;\r\n }, [mapData, rewindCoordinatesInMapData]);\r\n const formattedOverlayMapData = useMemo(() => {\r\n if (!rewindCoordinatesInMapData || !overlayMapData) return overlayMapData;\r\n\r\n return rewind(overlayMapData, { reverse: true }) as FeatureCollection;\r\n }, [overlayMapData, rewindCoordinatesInMapData]);\r\n const [selectedColor, setSelectedColor] = useState<string | undefined>(undefined);\r\n const zoomRef = useRef<ZoomBehavior<SVGSVGElement, unknown> | null>(null);\r\n const [showLegend, setShowLegend] = useState(\r\n collapseColorScaleByDefault === undefined ? !(width < 680) : !collapseColorScaleByDefault,\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const mapSvg = useRef<SVGSVGElement>(null);\r\n const isInView = useInView(mapSvg, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const mapG = useRef<SVGGElement>(null);\r\n const colorScale = categorical\r\n ? scaleOrdinal<number | string, string>().domain(colorDomain).range(colors)\r\n : scaleThreshold<number, string>()\r\n .domain(colorDomain as number[])\r\n .range(colors);\r\n\r\n useEffect(() => {\r\n const mapGSelect = select(mapG.current);\r\n const mapSvgSelect = select(mapSvg.current);\r\n const zoomFilter = (e: D3ZoomEvent<SVGSVGElement, unknown>['sourceEvent']) => {\r\n if (zoomInteraction === 'noZoom') return false;\r\n if (zoomInteraction === 'button') return !e.type.includes('wheel');\r\n const isWheel = e.type === 'wheel';\r\n const isTouch = e.type.startsWith('touch');\r\n const isDrag = e.type === 'mousedown' || e.type === 'mousemove';\r\n\r\n if (isTouch) return true;\r\n if (isWheel) {\r\n if (zoomInteraction === 'scroll') return true;\r\n return e.ctrlKey;\r\n }\r\n return isDrag && !e.button && !e.ctrlKey;\r\n };\r\n const zoomBehavior = zoom<SVGSVGElement, unknown>()\r\n .scaleExtent(zoomScaleExtend)\r\n .translateExtent(\r\n zoomTranslateExtend || [\r\n [-20, -20],\r\n [width + 20, height + 20],\r\n ],\r\n )\r\n .filter(zoomFilter)\r\n .on('zoom', ({ transform }) => {\r\n mapGSelect.attr('transform', transform);\r\n });\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n mapSvgSelect.call(zoomBehavior as any);\r\n\r\n zoomRef.current = zoomBehavior;\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n }, [height, width, zoomInteraction]);\r\n\r\n const bounds = bbox({\r\n ...formattedMapData,\r\n features: zoomAndCenterByHighlightedIds\r\n ? formattedMapData.features.filter(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d: any) =>\r\n (highlightedIds || []).length === 0 ||\r\n highlightedIds?.indexOf(d.properties[mapProperty]) !== -1,\r\n )\r\n : formattedMapData.features,\r\n });\r\n\r\n const center = centerOfMass({\r\n ...formattedMapData,\r\n features: zoomAndCenterByHighlightedIds\r\n ? formattedMapData.features.filter(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d: any) =>\r\n (highlightedIds || []).length === 0 ||\r\n highlightedIds?.indexOf(d.properties[mapProperty]) !== -1,\r\n )\r\n : formattedMapData.features,\r\n });\r\n const lonDiff = (bounds[2] - bounds[0]) * 1.15;\r\n const latDiff = (bounds[3] - bounds[1]) * 1.15;\r\n const scaleX = (((width * 190) / 960) * 360) / lonDiff;\r\n const scaleY = (((height * 190) / 678) * 180) / latDiff;\r\n const scaleVar = scale * Math.min(scaleX, scaleY);\r\n\r\n const projection =\r\n mapProjection === 'mercator'\r\n ? geoMercator()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar)\r\n : mapProjection === 'equalEarth'\r\n ? geoEqualEarth()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar)\r\n : mapProjection === 'naturalEarth'\r\n ? geoNaturalEarth1()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar)\r\n : mapProjection === 'orthographic'\r\n ? geoOrthographic()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar)\r\n : geoAlbersUsa()\r\n .rotate(projectionRotate)\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar);\r\n const pathGenerator = geoPath().projection(projection);\r\n const handleZoom = (direction: 'in' | 'out') => {\r\n if (!mapSvg.current || !zoomRef.current) return;\r\n const svg = select(mapSvg.current);\r\n svg.call(zoomRef.current.scaleBy, direction === 'in' ? 1.2 : 1 / 1.2);\r\n };\r\n return (\r\n <>\r\n <div className='relative'>\r\n <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n ref={mapSvg}\r\n direction='ltr'\r\n >\r\n <g ref={mapG}>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n {formattedMapData.features.map((d, i: number) => {\r\n if (!d.properties?.[mapProperty]) return null;\r\n const path = pathGenerator(d);\r\n if (!path) return null;\r\n return (\r\n <motion.g\r\n key={i}\r\n opacity={\r\n selectedColor\r\n ? dimmedOpacity\r\n : highlightedIds\r\n ? highlightedIds.indexOf(d.properties[mapProperty]) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1\r\n }\r\n >\r\n <path\r\n d={path}\r\n style={{\r\n stroke: mapBorderColor,\r\n strokeWidth: mapBorderWidth,\r\n fill: mapNoDataColor,\r\n vectorEffect: 'non-scaling-stroke',\r\n }}\r\n />\r\n </motion.g>\r\n );\r\n })}\r\n <AnimatePresence>\r\n {data.map(d => {\r\n const index = formattedMapData.features.findIndex(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (el: any) => d.id === el.properties[mapProperty],\r\n );\r\n if (index === -1) return null;\r\n const path = pathGenerator(formattedMapData.features[index]);\r\n if (!path) return null;\r\n const color = !checkIfNullOrUndefined(d.x)\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n colorScale(d.x as any)\r\n : mapNoDataColor;\r\n return (\r\n <motion.g\r\n className='undp-map-shapes'\r\n key={d.id}\r\n variants={{\r\n initial: { opacity: 0 },\r\n whileInView: {\r\n opacity: selectedColor\r\n ? selectedColor === color\r\n ? !highlightedIds || highlightedIds.indexOf(d.id) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : highlightedIds\r\n ? highlightedIds.indexOf(d.id) !== -1\r\n ? 1\r\n : dimmedOpacity\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 onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\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 onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d);\r\n onSeriesMouseClick?.(d);\r\n }\r\n }\r\n }}\r\n >\r\n <motion.path\r\n key={`${d.id}`}\r\n d={path}\r\n variants={{\r\n initial: { fill: color, opacity: 0 },\r\n whileInView: {\r\n fill: color,\r\n opacity: 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: mapBorderColor,\r\n strokeWidth: mapBorderWidth,\r\n vectorEffect: 'non-scaling-stroke',\r\n }}\r\n />\r\n </motion.g>\r\n );\r\n })}\r\n </AnimatePresence>\r\n {mouseOverData\r\n ? formattedMapData.features\r\n .filter(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d: { properties: any }) => d.properties[mapProperty] === mouseOverData.id,\r\n )\r\n .map((d, i) => (\r\n <path\r\n key={i}\r\n d={pathGenerator(d) || ''}\r\n className='stroke-primary-gray-700 dark:stroke-primary-gray-300'\r\n style={{\r\n fill: 'none',\r\n fillOpacity: 0,\r\n strokeWidth: '0.5',\r\n vectorEffect: 'non-scaling-stroke',\r\n }}\r\n />\r\n ))\r\n : null}\r\n {formattedOverlayMapData?.features.map((d, i: number) => {\r\n const path = pathGenerator(d);\r\n if (!path) return null;\r\n return (\r\n <g key={i}>\r\n <path\r\n d={path}\r\n style={{\r\n stroke: overlayMapBorderColor || mapBorderColor,\r\n strokeWidth: overlayMapBorderWidth || mapBorderWidth + 1,\r\n fill: 'none',\r\n pointerEvents: 'none',\r\n vectorEffect: 'non-scaling-stroke',\r\n }}\r\n />\r\n </g>\r\n );\r\n })}\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\r\n </g>\r\n </motion.svg>\r\n {showColorScale === false ? null : (\r\n <div className={cn('absolute left-4 bottom-4 map-color-legend', classNames?.colorLegend)}>\r\n {showLegend ? (\r\n <>\r\n <div\r\n className='color-legend-close-button bg-[rgba(240,240,240,0.7)] dark:bg-[rgba(30,30,30,0.7)] border border-[var(--gray-400)] rounded-full w-6 h-6 p-[3px] cursor-pointer z-10 absolute right-[-0.75rem] top-[-0.75rem]'\r\n onClick={() => {\r\n setShowLegend(false);\r\n }}\r\n >\r\n <X />\r\n </div>\r\n <div\r\n className='color-legend-box p-2 bg-[rgba(240,240,240,0.7)] dark:bg-[rgba(30,30,30,0.7)]'\r\n style={{\r\n width: categorical || colorDomain.length < 2 ? undefined : '340px',\r\n }}\r\n >\r\n {colorLegendTitle && colorLegendTitle !== '' ? (\r\n <P\r\n size='xs'\r\n marginBottom='xs'\r\n className='p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300'\r\n style={{\r\n display: '-webkit-box',\r\n WebkitLineClamp: '1',\r\n WebkitBoxOrient: 'vertical',\r\n }}\r\n >\r\n {colorLegendTitle}\r\n </P>\r\n ) : null}\r\n {!categorical && colorDomain.length > 1 ? (\r\n <svg width='100%' viewBox='0 0 320 30' direction='ltr'>\r\n <g>\r\n {colorDomain.map((d, i) => (\r\n <g\r\n key={i}\r\n onMouseOver={() => {\r\n setSelectedColor(colors[i]);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedColor(undefined);\r\n }}\r\n className='cursor-pointer'\r\n >\r\n <rect\r\n x={(i * 320) / colors.length + 1}\r\n y={1}\r\n width={320 / colors.length - 2}\r\n height={8}\r\n className={\r\n selectedColor === colors[i]\r\n ? 'stroke-primary-gray-700 dark:stroke-primary-gray-300'\r\n : ''\r\n }\r\n style={{\r\n fill: colors[i],\r\n ...(selectedColor === colors[i] ? {} : { stroke: colors[i] }),\r\n }}\r\n />\r\n <text\r\n x={((i + 1) * 320) / colors.length}\r\n y={25}\r\n className='fill-primary-gray-700 dark:fill-primary-gray-300 text-xs'\r\n style={{ textAnchor: 'middle' }}\r\n >\r\n {numberFormattingFunction(\r\n d as number,\r\n 'NA',\r\n numberDisplayOptions?.precision ?? 2,\r\n undefined,\r\n undefined,\r\n numberDisplayOptions?.locale || 'en',\r\n numberDisplayOptions?.padZeros || false,\r\n )}\r\n </text>\r\n </g>\r\n ))}\r\n <g>\r\n <rect\r\n onMouseOver={() => {\r\n setSelectedColor(colors[colorDomain.length]);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedColor(undefined);\r\n }}\r\n x={(colorDomain.length * 320) / colors.length + 1}\r\n y={1}\r\n width={320 / colors.length - 2}\r\n height={8}\r\n className={`cursor-pointer ${\r\n selectedColor === colors[colorDomain.length]\r\n ? 'stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300'\r\n : ''\r\n }`}\r\n style={{\r\n fill: colors[colorDomain.length],\r\n ...(selectedColor === colors[colorDomain.length]\r\n ? {}\r\n : { stroke: colors[colorDomain.length] }),\r\n }}\r\n />\r\n </g>\r\n </g>\r\n </svg>\r\n ) : categorical ? (\r\n <div className='flex flex-col gap-3'>\r\n {colorDomain.map((d, i) => (\r\n <div\r\n key={i}\r\n className='flex gap-2 items-center'\r\n onMouseOver={() => {\r\n setSelectedColor(colors[i % colors.length]);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedColor(undefined);\r\n }}\r\n >\r\n <div\r\n className='w-2 h-2 rounded-full'\r\n style={{ backgroundColor: colors[i % colors.length] }}\r\n />\r\n <P size='sm' marginBottom='none' leading='none'>\r\n {d}\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n ) : (\r\n <div className='flex flex-col gap-3'>\r\n <div\r\n className='flex gap-2 items-center'\r\n onMouseOver={() => {\r\n setSelectedColor(colors[0]);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedColor(undefined);\r\n }}\r\n >\r\n <div\r\n className='w-2 h-2 rounded-full'\r\n style={{ backgroundColor: colors[0] }}\r\n />\r\n <P size='sm' marginBottom='none' leading='none'>\r\n {`<= ${numberFormattingFunction(\r\n colorDomain[0] as number,\r\n 'NA',\r\n numberDisplayOptions?.precision ?? 2,\r\n undefined,\r\n undefined,\r\n numberDisplayOptions?.locale || 'en',\r\n numberDisplayOptions?.padZeros || false,\r\n )}`}\r\n </P>\r\n </div>\r\n <div\r\n className='flex gap-2 items-center'\r\n onMouseOver={() => {\r\n setSelectedColor(colors[1]);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedColor(undefined);\r\n }}\r\n >\r\n <div\r\n className='w-2 h-2 rounded-full'\r\n style={{ backgroundColor: colors[1] }}\r\n />\r\n <P size='sm' marginBottom='none' leading='none'>\r\n {`> ${numberFormattingFunction(\r\n colorDomain[0] as number,\r\n 'NA',\r\n numberDisplayOptions?.precision ?? 2,\r\n undefined,\r\n undefined,\r\n numberDisplayOptions?.locale || 'en',\r\n numberDisplayOptions?.padZeros || false,\r\n )}`}\r\n </P>\r\n </div>\r\n </div>\r\n )}\r\n </div>\r\n </>\r\n ) : (\r\n <button\r\n type='button'\r\n className='p-1 border-0 rounded-[2px] text-primary-gray-700 bg-primary-gray-300 dark:bg-primary-gray-500 map-legend-button'\r\n onClick={() => {\r\n setShowLegend(true);\r\n }}\r\n >\r\n <ExpandIcon />\r\n </button>\r\n )}\r\n </div>\r\n )}\r\n {zoomInteraction === 'button' && (\r\n <div className='absolute left-4 top-4 flex flex-col undp-viz-zoom-buttons'>\r\n <button\r\n onClick={() => handleZoom('in')}\r\n className='leading-0 px-2 py-3.5 text-primary-gray-700 border border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-550 dark:bg-primary-gray-600 dark:text-primary-gray-100'\r\n >\r\n +\r\n </button>\r\n <button\r\n onClick={() => handleZoom('out')}\r\n className='leading-0 px-2 py-3.5 text-primary-gray-700 border border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-550 dark:bg-primary-gray-600 dark:text-primary-gray-100'\r\n >\r\n –\r\n </button>\r\n </div>\r\n )}\r\n {(graphDownload || dataDownload) && (\r\n <div className='absolute right-4 top-4 flex flex-col image-download-button gap-2'>\r\n {graphDownload && (\r\n <ImageDownloadButton nodeID={graphDownload} buttonSmall className='p-1' />\r\n )}\r\n {dataDownload && dataDownload.length > 0 && (\r\n <CsvDownloadButton\r\n csvData={dataDownload}\r\n buttonSmall\r\n headers={Object.keys(dataDownload[0]).map(d => ({\r\n label: d,\r\n key: d,\r\n }))}\r\n className='p-1'\r\n />\r\n )}\r\n </div>\r\n )}\r\n </div>\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 {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 </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect, useEffectEvent, useMemo } from 'react';\r\nimport { SliderUI } from '@undp/design-system-react/SliderUI';\r\nimport { Spinner } from '@undp/design-system-react/Spinner';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { FeatureCollection } from 'geojson';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n ChoroplethMapDataType,\r\n Languages,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n ScaleDataType,\r\n MapProjectionTypes,\r\n ZoomInteractionTypes,\r\n CustomLayerDataType,\r\n AnimateDataType,\r\n TimelineDataType,\r\n MapOverlayDataType,\r\n NumberFormatOptions,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { fetchAndParseJSON } from '@/Utils/fetchAndParseData';\r\nimport { getUniqValue } from '@/Utils/getUniqValue';\r\nimport { getJenks } from '@/Utils/getJenks';\r\nimport { Pause, Play } from '@/Components/Icons';\r\nimport { getSliderMarks } from '@/Utils/getSliderMarks';\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: ChoroplethMapDataType[];\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 /** Colors for the choropleth map */\r\n colors?: string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: number[] | string[];\r\n /** Title for the color legend */\r\n colorLegendTitle?: string;\r\n /** Color for the areas where data is no available */\r\n mapNoDataColor?: 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\r\n // Graph Parameters\r\n /** Map data as an object in geoJson format or a url for geoJson */\r\n mapData?: FeatureCollection | string;\r\n /** Detail if any other map needs to be overlayed over the main map */\r\n mapOverlay?: MapOverlayDataType;\r\n /** Defines if the coordinates in the map data should be rewinded or not. Try to change this is the visualization shows countries as holes instead of shapes. */\r\n rewindCoordinatesInMapData?: boolean;\r\n /** Scaling factor for the map. Multiplies the scale number to scale. */\r\n scale?: number;\r\n /** Toggle if the map is centered and zoomed to the highlighted ids. */\r\n zoomAndCenterByHighlightedIds?: boolean;\r\n /** Center point of the map */\r\n centerPoint?: [number, number];\r\n /** Controls the rotation of the map projection, in degrees, applied before rendering. Useful for shifting the antimeridian to focus the map on different regions */\r\n projectionRotate?: [number, number] | [number, number, number];\r\n /** Defines the zoom mode for the map */\r\n zoomInteraction?: ZoomInteractionTypes;\r\n /** Stroke width of the regions in the map */\r\n mapBorderWidth?: number;\r\n /** Stroke color of the regions in the map */\r\n mapBorderColor?: string;\r\n /** Toggle if the map is a world map */\r\n isWorldMap?: boolean;\r\n /** Map projection type */\r\n mapProjection?: MapProjectionTypes;\r\n /** Extend of the allowed zoom in the map */\r\n zoomScaleExtend?: [number, number];\r\n /** Extend of the allowed panning in the map */\r\n zoomTranslateExtend?: [[number, number], [number, number]];\r\n /** Countries or regions to be highlighted */\r\n highlightedIds?: string[];\r\n /** Defines the opacity of the non-highlighted data */\r\n dimmedOpacity?: number;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Scale for the colors */\r\n scaleType?: Exclude<ScaleDataType, 'linear'>;\r\n /** Toggle visibility of color scale. */\r\n showColorScale?: boolean;\r\n /** Toggle if color scale is collapsed by default. */\r\n collapseColorScaleByDefault?: boolean;\r\n /** Property in the property object in mapData geoJson object is used to match to the id in the data object */\r\n mapProperty?: string;\r\n /** Toggles the visibility of Antarctica in the default map. Only applicable for the default map. */\r\n showAntarctica?: boolean;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** Configures playback and slider controls for animating the chart over time. The data must have a key date for it to work properly. */\r\n timeline?: TimelineDataType;\r\n /** Configuration options for controlling number formatting, localization, precision, and zero padding. */\r\n numberDisplayOptions?: Omit<NumberFormatOptions, 'suffix' | 'prefix'>;\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 ChoroplethMap(props: Props) {\r\n const {\r\n data,\r\n mapData = 'https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-v2.json',\r\n graphTitle,\r\n colors,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote = 'The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.',\r\n colorDomain,\r\n colorLegendTitle,\r\n scaleType = 'threshold',\r\n scale = 0.95,\r\n centerPoint,\r\n padding,\r\n mapBorderWidth = 0.5,\r\n mapNoDataColor = Colors.light.graphNoData,\r\n backgroundColor = false,\r\n mapBorderColor = Colors.light.grays['gray-500'],\r\n relativeHeight,\r\n tooltip,\r\n onSeriesMouseOver,\r\n isWorldMap = true,\r\n showColorScale = true,\r\n zoomScaleExtend = [0.8, 6],\r\n zoomTranslateExtend,\r\n graphID,\r\n highlightedIds,\r\n onSeriesMouseClick,\r\n mapProperty = 'ISO3',\r\n graphDownload = false,\r\n dataDownload = false,\r\n showAntarctica = false,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n mapProjection = 'naturalEarth',\r\n zoomInteraction = 'button',\r\n animate = false,\r\n dimmedOpacity = 0.3,\r\n customLayers = [],\r\n timeline = { enabled: false, autoplay: false, showOnlyActiveDate: true },\r\n collapseColorScaleByDefault,\r\n projectionRotate = [0, 0],\r\n zoomAndCenterByHighlightedIds = false,\r\n rewindCoordinatesInMapData = true,\r\n mapOverlay,\r\n numberDisplayOptions,\r\n } = props;\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [play, setPlay] = useState(timeline.autoplay);\r\n const uniqDatesSorted = useMemo(() => {\r\n const dates = [\r\n ...new Set(\r\n data\r\n .filter(d => d.date)\r\n .map(d => parse(`${d.date}`, timeline.dateFormat || 'yyyy', new Date()).getTime()),\r\n ),\r\n ];\r\n dates.sort((a, b) => a - b);\r\n return dates;\r\n }, [data, timeline.dateFormat]);\r\n const [index, setIndex] = useState(timeline.autoplay ? 0 : uniqDatesSorted.length - 1);\r\n\r\n const [mapShape, setMapShape] = useState<FeatureCollection | undefined>(undefined);\r\n const [overlayMapShape, setOverlayMapShape] = useState<FeatureCollection | undefined>(undefined);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(entries[0].target.clientWidth || 620);\r\n setSvgHeight(entries[0].target.clientHeight || 480);\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 onUpdateShape = useEffectEvent((shape: FeatureCollection) => {\r\n setMapShape(shape);\r\n });\r\n\r\n const onUpdateOverlayMapShape = useEffectEvent((shape: FeatureCollection | undefined) => {\r\n setOverlayMapShape(shape);\r\n });\r\n useEffect(() => {\r\n if (typeof mapData === 'string') {\r\n const fetchData = fetchAndParseJSON(mapData);\r\n fetchData.then(d => {\r\n onUpdateShape(d);\r\n });\r\n } else {\r\n onUpdateShape(mapData);\r\n }\r\n }, [mapData]);\r\n useEffect(() => {\r\n if (!mapOverlay?.mapData) onUpdateOverlayMapShape(undefined);\r\n if (typeof mapOverlay?.mapData === 'string') {\r\n const fetchData = fetchAndParseJSON(mapOverlay?.mapData);\r\n fetchData.then(d => {\r\n onUpdateOverlayMapShape(d as FeatureCollection);\r\n });\r\n } else {\r\n onUpdateOverlayMapShape(mapOverlay?.mapData);\r\n }\r\n }, [mapOverlay?.mapData]);\r\n\r\n const domain =\r\n colorDomain ||\r\n (scaleType === 'categorical'\r\n ? getUniqValue(data, 'x')\r\n : getJenks(\r\n data.map(d => d.x as number | null | undefined),\r\n colors?.length || 4,\r\n ));\r\n\r\n useEffect(() => {\r\n const interval = setInterval(\r\n () => {\r\n setIndex(i => (i < uniqDatesSorted.length - 1 ? i + 1 : 0));\r\n },\r\n (timeline.speed || 2) * 1000,\r\n );\r\n if (!play) clearInterval(interval);\r\n return () => clearInterval(interval);\r\n }, [uniqDatesSorted, play, timeline.speed]);\r\n\r\n const markObj = getSliderMarks(\r\n uniqDatesSorted,\r\n index,\r\n timeline.showOnlyActiveDate,\r\n timeline.dateFormat || 'yyyy',\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 ? (\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 />\r\n ) : null}\r\n {timeline.enabled && uniqDatesSorted.length > 0 && markObj ? (\r\n <div className='flex gap-6 items-center' dir='ltr'>\r\n <button\r\n type='button'\r\n onClick={() => {\r\n setPlay(!play);\r\n }}\r\n className='p-0 border-0 cursor-pointer bg-transparent'\r\n aria-label={play ? 'Click to pause animation' : 'Click to play animation'}\r\n >\r\n {play ? <Pause /> : <Play />}\r\n </button>\r\n <SliderUI\r\n min={uniqDatesSorted[0]}\r\n max={uniqDatesSorted[uniqDatesSorted.length - 1]}\r\n marks={markObj}\r\n step={null}\r\n defaultValue={uniqDatesSorted[uniqDatesSorted.length - 1]}\r\n value={uniqDatesSorted[index]}\r\n onChangeComplete={nextValue => {\r\n setIndex(uniqDatesSorted.indexOf(nextValue as number));\r\n }}\r\n onChange={nextValue => {\r\n setIndex(uniqDatesSorted.indexOf(nextValue as number));\r\n }}\r\n aria-label='Time slider. Use arrow keys to adjust selected time period.'\r\n />\r\n </div>\r\n ) : null}\r\n <GraphArea ref={graphDiv}>\r\n {svgWidth && svgHeight && mapShape ? (\r\n <Graph\r\n data={data.filter(d =>\r\n timeline.enabled\r\n ? `${d.date}` ===\r\n format(new Date(uniqDatesSorted[index]), timeline.dateFormat || 'yyyy')\r\n : d,\r\n )}\r\n mapData={\r\n showAntarctica\r\n ? mapShape\r\n : {\r\n ...mapShape,\r\n features: mapShape.features.filter(el => el.properties?.NAME !== 'Antarctica'),\r\n }\r\n }\r\n colorDomain={domain}\r\n width={svgWidth}\r\n height={svgHeight}\r\n scale={scale}\r\n centerPoint={centerPoint}\r\n colors={\r\n colors ||\r\n (scaleType === 'categorical'\r\n ? Colors[theme].categoricalColors.colors\r\n : Colors[theme].sequentialColors[\r\n `neutralColorsx0${(domain.length + 1) as 4 | 5 | 6 | 7 | 8 | 9}`\r\n ])\r\n }\r\n colorLegendTitle={colorLegendTitle}\r\n mapBorderWidth={mapBorderWidth}\r\n mapNoDataColor={mapNoDataColor}\r\n categorical={scaleType === 'categorical'}\r\n mapBorderColor={mapBorderColor}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n isWorldMap={isWorldMap}\r\n showColorScale={showColorScale}\r\n zoomScaleExtend={zoomScaleExtend}\r\n zoomTranslateExtend={zoomTranslateExtend}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n mapProperty={mapProperty}\r\n highlightedIds={highlightedIds}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n styles={styles}\r\n overlayMapData={overlayMapShape}\r\n overlayMapBorderColor={mapOverlay?.mapBorderColor}\r\n overlayMapBorderWidth={mapOverlay?.mapBorderWidth}\r\n classNames={classNames}\r\n detailsOnClick={detailsOnClick}\r\n mapProjection={mapProjection || (isWorldMap ? 'naturalEarth' : 'mercator')}\r\n zoomInteraction={zoomInteraction}\r\n dimmedOpacity={dimmedOpacity}\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 customLayers={customLayers}\r\n zoomAndCenterByHighlightedIds={zoomAndCenterByHighlightedIds}\r\n collapseColorScaleByDefault={collapseColorScaleByDefault}\r\n projectionRotate={projectionRotate}\r\n rewindCoordinatesInMapData={rewindCoordinatesInMapData}\r\n numberDisplayOptions={numberDisplayOptions}\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 ) : (\r\n <div\r\n style={{\r\n height: `${Math.max(\r\n minHeight,\r\n height ||\r\n (relativeHeight\r\n ? minHeight\r\n ? (width || svgWidth) * relativeHeight > minHeight\r\n ? (width || svgWidth) * relativeHeight\r\n : minHeight\r\n : (width || svgWidth) * relativeHeight\r\n : svgHeight),\r\n )}px`,\r\n }}\r\n className='flex items-center justify-center'\r\n >\r\n <Spinner aria-label='Loading graph' />\r\n </div>\r\n )}\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":["Graph","props","data","colorDomain","colors","mapData","colorLegendTitle","categorical","height","width","scale","centerPoint","tooltip","mapBorderWidth","mapBorderColor","mapNoDataColor","onSeriesMouseOver","showColorScale","zoomScaleExtend","zoomTranslateExtend","highlightedIds","onSeriesMouseClick","mapProperty","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","mapProjection","zoomInteraction","animate","dimmedOpacity","customLayers","collapseColorScaleByDefault","zoomAndCenterByHighlightedIds","projectionRotate","rewindCoordinatesInMapData","overlayMapData","overlayMapBorderColor","overlayMapBorderWidth","numberDisplayOptions","graphDownload","dataDownload","formattedMapData","useMemo","rewind","reverse","formattedOverlayMapData","selectedColor","setSelectedColor","useState","undefined","zoomRef","useRef","showLegend","setShowLegend","mouseClickData","setMouseClickData","mouseOverData","setMouseOverData","eventX","setEventX","eventY","setEventY","mapSvg","isInView","useInView","once","amount","mapG","colorScale","scaleOrdinal","domain","range","scaleThreshold","useEffect","mapGSelect","select","current","mapSvgSelect","zoomFilter","e","type","includes","isWheel","isTouch","startsWith","isDrag","ctrlKey","button","zoomBehavior","zoom","scaleExtent","translateExtent","filter","on","transform","attr","call","bounds","bbox","features","d","length","indexOf","properties","center","centerOfMass","lonDiff","latDiff","scaleX","scaleY","scaleVar","Math","min","projection","geoMercator","rotate","geometry","coordinates","translate","geoEqualEarth","geoNaturalEarth1","geoOrthographic","geoAlbersUsa","pathGenerator","geoPath","handleZoom","direction","scaleBy","jsxs","Fragment","jsx","motion","position","map","layer","i","path","stroke","strokeWidth","fill","vectorEffect","AnimatePresence","index","findIndex","el","id","color","checkIfNullOrUndefined","x","initial","opacity","whileInView","transition","duration","event","clientY","clientX","isEqual","fillOpacity","pointerEvents","cn","colorLegend","X","P","display","WebkitLineClamp","WebkitBoxOrient","textAnchor","numberFormattingFunction","precision","locale","padZeros","backgroundColor","ExpandIcon","ImageDownloadButton","CsvDownloadButton","Object","keys","label","key","DetailsModal","modal","Tooltip","ChoroplethMap","$","_c","t0","graphTitle","sources","graphDescription","footNote","t1","scaleType","t2","t3","padding","t4","t5","t6","t7","relativeHeight","isWorldMap","t8","t9","t10","graphID","t11","t12","t13","showAntarctica","t14","language","t15","minHeight","t16","theme","t17","ariaLabel","t18","t19","t20","t21","t22","t23","timeline","t24","t25","t26","t27","mapOverlay","Colors","light","graphNoData","grays","t28","t29","t30","enabled","autoplay","showOnlyActiveDate","t31","svgWidth","setSvgWidth","svgHeight","setSvgHeight","play","setPlay","dates","dateFormat","t32","d_0","parse","date","Date","getTime","Set","_temp","sort","_temp2","uniqDatesSorted","setIndex","mapShape","setMapShape","overlayMapShape","setOverlayMapShape","graphDiv","graphParentDiv","t33","Symbol","for","resizeObserver","ResizeObserver","entries","target","clientWidth","clientHeight","observe","disconnect","t34","shape","onUpdateShape","useEffectEvent","t35","shape_0","onUpdateOverlayMapShape","t36","fetchAndParseJSON","then","d_1","t37","t38","d_2","t39","t40","t41","getUniqValue","getJenks","_temp3","t42","t43","speed","interval","setInterval","clearInterval","t44","t45","getSliderMarks","markObj","t46","graphContainer","t47","t48","description","title","GraphHeader","t49","Pause","Play","SliderUI","nextValue","nextValue_0","t50","GraphArea","d_4","format","_temp4","categoricalColors","sequentialColors","_temp5","_temp6","_temp7","_temp8","_temp9","max","Spinner","t51","footnote","source","GraphFooter","t52","GraphContainer","d_7","d_6","d_5","d_9","d_8","NAME","d_3","a","b"],"mappings":"uqCAwFO,SAASA,GAAMC,EAAc,CAClC,KAAM,CACJC,KAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,QAAAA,EACAC,iBAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,MAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,QAAAA,GACAC,eAAAA,EACAC,eAAAA,GACAC,eAAAA,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