@undp/data-viz 1.5.5 → 1.5.6

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.
Files changed (56) hide show
  1. package/dist/BiVariateChoroplethMap.cjs +1 -1
  2. package/dist/BiVariateChoroplethMap.js +2 -2
  3. package/dist/ChoroplethMap.cjs +1 -1
  4. package/dist/ChoroplethMap.cjs.map +1 -1
  5. package/dist/ChoroplethMap.d.ts +0 -2
  6. package/dist/ChoroplethMap.js +2 -2
  7. package/dist/ChoroplethMap.js.map +1 -1
  8. package/dist/DotDensityMap.cjs +1 -1
  9. package/dist/DotDensityMap.js +2 -2
  10. package/dist/GraphEl-C6yjl1VM.cjs +2 -0
  11. package/dist/GraphEl-C6yjl1VM.cjs.map +1 -0
  12. package/dist/{GraphEl-CMWeARJ3.js → GraphEl-CqWzvOyr.js} +1 -2
  13. package/dist/GraphEl-CqWzvOyr.js.map +1 -0
  14. package/dist/GriddedGraphs.cjs +1 -1
  15. package/dist/GriddedGraphs.d.ts +1 -1
  16. package/dist/GriddedGraphs.js +1 -1
  17. package/dist/GriddedGraphsFromConfig.d.ts +1 -1
  18. package/dist/MultiGraphDashboard.d.ts +1 -1
  19. package/dist/MultiGraphDashboardFromConfig.d.ts +1 -1
  20. package/dist/PerformanceIntensiveMultiGraphDashboard.d.ts +1 -1
  21. package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.d.ts +1 -1
  22. package/dist/PerformanceIntensiveScrollStory.d.ts +1 -1
  23. package/dist/ScrollStory.d.ts +1 -1
  24. package/dist/SingleGraphDashboard.cjs +1 -1
  25. package/dist/SingleGraphDashboard.d.ts +1 -1
  26. package/dist/SingleGraphDashboard.js +1 -1
  27. package/dist/SingleGraphDashboardFromConfig.d.ts +1 -1
  28. package/dist/SingleGraphDashboardGeoHubMaps.d.ts +1 -1
  29. package/dist/SingleGraphDashboardGeoHubMapsFromConfig.d.ts +1 -1
  30. package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
  31. package/dist/SingleGraphDashboardThreeDGraphs.cjs.map +1 -1
  32. package/dist/SingleGraphDashboardThreeDGraphs.d.ts +1 -1
  33. package/dist/SingleGraphDashboardThreeDGraphs.js +2 -2
  34. package/dist/SingleGraphDashboardThreeDGraphs.js.map +1 -1
  35. package/dist/SingleGraphDashboardThreeDGraphsFromConfig.d.ts +1 -1
  36. package/dist/ThreeDGlobe.cjs +1 -1
  37. package/dist/ThreeDGlobe.cjs.map +1 -1
  38. package/dist/ThreeDGlobe.d.ts +2 -2
  39. package/dist/ThreeDGlobe.js +394 -333
  40. package/dist/ThreeDGlobe.js.map +1 -1
  41. package/dist/Types.d.ts +1 -1
  42. package/dist/index-9tDEUqOZ.js +752 -0
  43. package/dist/{index-qfWCwobm.js.map → index-9tDEUqOZ.js.map} +1 -1
  44. package/dist/index-CoZbeNM9.cjs +2 -0
  45. package/dist/{index-D05lK1Te.cjs.map → index-CoZbeNM9.cjs.map} +1 -1
  46. package/dist/index.d.ts +3 -5
  47. package/dist/{zoom-Bsbhil-K.cjs → zoom-BiMNsz72.cjs} +2 -2
  48. package/dist/{zoom-Bsbhil-K.cjs.map → zoom-BiMNsz72.cjs.map} +1 -1
  49. package/dist/{zoom-DAu91HKr.js → zoom-QipiAl5W.js} +2 -2
  50. package/dist/{zoom-DAu91HKr.js.map → zoom-QipiAl5W.js.map} +1 -1
  51. package/package.json +2 -1
  52. package/dist/GraphEl-BcYgMnN2.cjs +0 -2
  53. package/dist/GraphEl-BcYgMnN2.cjs.map +0 -1
  54. package/dist/GraphEl-CMWeARJ3.js.map +0 -1
  55. package/dist/index-D05lK1Te.cjs +0 -2
  56. package/dist/index-qfWCwobm.js +0 -682
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),u=require("react"),$e=require("./getSliderMarks-CRIbTGYV.cjs"),Ie=require("./Spinner-DA6Z5E4n.cjs"),Ce=require("./parse-hMnG_lRV.cjs"),Pe=require("./index-DQA8q5sC.cjs"),L=require("./zoom-Bsbhil-K.cjs"),Le=require("./index-D05lK1Te.cjs"),Te=require("./Modal-tXZlLE5s.cjs"),Se=require("./Typography-k-kOjICQ.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),ze=require("./Tooltip-De16GWhY.cjs"),We=require("./string2HTML-z7CwHXcx.cjs"),De=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Re=require("./index-BW_-wD2k.cjs"),ke=require("./select-Bnfk0lJx.cjs"),Me=require("./threshold-DNsSUf8Q.cjs"),Be=require("./use-in-view-sQJZ_xDO.cjs"),ae=require("./proxy-BHRoeZgd.cjs"),Ae=require("./index-BW8iNx7E.cjs"),Fe=require("./GraphHeader.cjs"),Ve=require("./GraphFooter.cjs"),we=require("./Colors.cjs"),He=require("./fetchAndParseData-Ba-_CgxS.cjs"),qe=require("./getJenks-GYmdwBqm.cjs"),_e=require("./uniqBy-O05lp2S5.cjs"),Ge=require("./sort-O96oMZLb.cjs"),Ue=require("./init-DU0ybBc_.cjs");function Xe(je){const{data:v,xDomain:R,mapData:f,xColorLegendTitle:D,yDomain:T,yColorLegendTitle:z,width:d,height:s,colors:Y,scale:J,centerPoint:$,mapBorderWidth:W,mapNoDataColor:M,mapBorderColor:ne,tooltip:se,onSeriesMouseOver:le,zoomScaleExtend:ce,zoomTranslateExtend:ve,highlightedIds:B,onSeriesMouseClick:b,mapProperty:A,resetSelectionOnDoubleClick:E,detailsOnClick:S,showColorScale:ue,styles:be,classNames:Ee,mapProjection:F,zoomInteraction:q,animate:k,dimmedOpacity:V,customLayers:me}=je,[de,K]=u.useState(!(d<680)),[H,_]=u.useState(void 0),[h,Z]=u.useState(void 0),[G,Q]=u.useState(void 0),[pe,w]=u.useState(void 0),[C,ee]=u.useState(void 0),O=u.useRef(null),U=Be.useInView(O,{once:k.once,amount:k.amount}),xe=u.useRef(null),te=u.useRef(null);u.useEffect(()=>{const e=ke.select(xe.current),n=ke.select(O.current),r=o=>{if(q==="noZoom")return!1;if(q==="button")return!o.type.includes("wheel");const a=o.type==="wheel",m=o.type.startsWith("touch"),l=o.type==="mousedown"||o.type==="mousemove";return m?!0:a?q==="scroll"?!0:o.ctrlKey:l&&!o.button&&!o.ctrlKey},i=L.zoom().scaleExtent(ce).translateExtent(ve||[[-20,-20],[d+20,s+20]]).filter(r).on("zoom",({transform:o})=>{e.attr("transform",o)});n.call(i),te.current=i},[s,d,q]);const p=L.turf_bbox_default(f),g=Le.turf_center_of_mass_default(f),he=p[2]-p[0],re=p[3]-p[1],ge=d*190/960*360/he,I=s*190/678*180/re,P=J*Math.min(ge,I),c=F==="mercator"?L.geoMercator().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P):F==="equalEarth"?L.geoEqualEarth().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P):F==="naturalEarth"?L.geoNaturalEarth1().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P):F==="orthographic"?L.geoOrthographic().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P):L.geoAlbersUsa().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P),oe=Array.from({length:R.length},(e,n)=>n),ie=Array.from({length:T.length},(e,n)=>n),X=Me.threshold().domain(R).range(oe),ye=Me.threshold().domain(T).range(ie),N=e=>{if(!O.current||!te.current)return;ke.select(O.current).call(te.current.scaleBy,e==="in"?1.2:1/1.2)};return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"relative",children:[t.jsxRuntimeExports.jsx(ae.motion.svg,{viewBox:`0 0 ${d} ${s}`,width:`${d}px`,height:`${s}px`,ref:O,direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{ref:xe,children:[me.filter(e=>e.position==="before").map(e=>e.layer),f.features.map((e,n)=>v.findIndex(i=>i.id===e.properties[A])!==-1?null:t.jsxRuntimeExports.jsx(ae.motion.g,{opacity:H?V:B.length!==0?B.indexOf(e.properties[A])!==-1?1:V:1,children:e.geometry.type==="MultiPolygon"?e.geometry.coordinates.map((i,o)=>{let a="";return i.forEach(m=>{let l=" M";m.forEach((x,y)=>{const j=c([x[0],x[1]]);y!==m.length-1?l=`${l}${j[0]} ${j[1]}L`:l=`${l}${j[0]} ${j[1]}`}),a+=l}),t.jsxRuntimeExports.jsx("path",{d:a,style:{stroke:ne,strokeWidth:W,fill:M}},o)}):e.geometry.coordinates.map((i,o)=>{let a="M";return i.forEach((m,l)=>{const x=c([m[0],m[1]]);l!==i.length-1?a=`${a}${x[0]} ${x[1]}L`:a=`${a}${x[0]} ${x[1]}`}),t.jsxRuntimeExports.jsx("path",{d:a,style:{stroke:ne,strokeWidth:W,fill:M}},o)})},n)),t.jsxRuntimeExports.jsx(Ae.AnimatePresence,{children:v.map(e=>{const n=f.features.findIndex(a=>e.id===a.properties[A]),r=De.checkIfNullOrUndefined(e.x)?void 0:X(e.x),i=De.checkIfNullOrUndefined(e.y)?void 0:ye(e.y),o=r!==void 0&&i!==void 0?Y[i][r]:M;return t.jsxRuntimeExports.jsx(ae.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:H?H===o?1:V:B.length!==0?B.indexOf(e.id)!==-1?1:V:1,transition:{duration:k.duration}}},initial:"initial",animate:U?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},onMouseEnter:a=>{Q(e),ee(a.clientY),w(a.clientX),le?.(e)},onClick:()=>{(b||S)&&(Pe.isEqual(h,e)&&E?(Z(void 0),b?.(void 0)):(Z(e),b?.(e)))},onMouseMove:a=>{Q(e),ee(a.clientY),w(a.clientX)},onMouseLeave:()=>{Q(void 0),w(void 0),ee(void 0),le?.(void 0)},children:n===-1?null:f.features[n].geometry.type==="MultiPolygon"?f.features[n].geometry.coordinates.map((a,m)=>{let l="";return a.forEach(x=>{let y=" M";x.forEach((j,Oe)=>{const fe=c([j[0],j[1]]);Oe!==x.length-1?y=`${y}${fe[0]} ${fe[1]}L`:y=`${y}${fe[0]} ${fe[1]}`}),l+=y}),t.jsxRuntimeExports.jsx(ae.motion.path,{variants:{initial:{fill:o,opacity:0},whileInView:{fill:o,opacity:1,transition:{duration:k.duration}}},initial:"initial",animate:U?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},d:l,className:`${o===M?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"stroke-primary-white dark:stroke-primary-gray-650"}`,style:{strokeWidth:W}},`${e.id}-${m}`)}):f.features[n].geometry.coordinates.map((a,m)=>{let l="M";return a.forEach((x,y)=>{const j=c([x[0],x[1]]);y!==a.length-1?l=`${l}${j[0]} ${j[1]}L`:l=`${l}${j[0]} ${j[1]}`}),t.jsxRuntimeExports.jsx(ae.motion.path,{d:l,variants:{initial:{fill:o,opacity:0},whileInView:{fill:o,opacity:1,transition:{duration:k.duration}}},initial:"initial",animate:U?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},className:`${o===M?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"stroke-primary-white dark:stroke-primary-gray-650"}`,style:{strokeWidth:W}},`${e.id}-${m}`)})},e.id)})}),G?f.features.filter(e=>e.properties[A]===G.id).map((e,n)=>t.jsxRuntimeExports.jsx("g",{children:e.geometry.type==="MultiPolygon"?e.geometry.coordinates.map((r,i)=>{let o="";return r.forEach(a=>{let m=" M";a.forEach((l,x)=>{const y=c([l[0],l[1]]);x!==a.length-1?m=`${m}${y[0]} ${y[1]}L`:m=`${m}${y[0]} ${y[1]}`}),o+=m}),t.jsxRuntimeExports.jsx("path",{d:o,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},i)}):e.geometry.coordinates.map((r,i)=>{let o="M";return r.forEach((a,m)=>{const l=c([a[0],a[1]]);m!==r.length-1?o=`${o}${l[0]} ${l[1]}L`:o=`${o}${l[0]} ${l[1]}`}),t.jsxRuntimeExports.jsx("path",{d:o,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},i)})},n)):null,me.filter(e=>e.position==="after").map(e=>e.layer)]})}),ue===!1?null:t.jsxRuntimeExports.jsx("div",{className:"absolute left-4 bottom-4",children:de?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{style:{backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"absolute",right:"-0.75rem",top:"-0.75rem"},onClick:()=>{K(!1)},children:t.jsxRuntimeExports.jsx(Re.X,{})}),t.jsxRuntimeExports.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.7)",width:"175px"},children:[t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1 items-center",children:[t.jsxRuntimeExports.jsx("svg",{width:"136px",viewBox:"0 0 136 136",className:"shrink-0",children:t.jsxRuntimeExports.jsxs("g",{children:[Y.map((e,n)=>t.jsxRuntimeExports.jsx("g",{transform:`translate(0,${100-n*25})`,children:e.map((r,i)=>t.jsxRuntimeExports.jsx("rect",{y:1,x:i*25+1,fill:r,width:23,height:23,strokeWidth:H===r?2:.25,style:{cursor:"pointer"},onMouseOver:()=>{_(r)},onMouseLeave:()=>{_(void 0)}},i))},n)),t.jsxRuntimeExports.jsx("g",{transform:"translate(0,125)",children:R.map((e,n)=>t.jsxRuntimeExports.jsx("text",{y:10,x:(n+1)*25,fontSize:10,textAnchor:"middle",children:typeof e=="string"||e<1?e:Ne.numberFormattingFunction(e,"NA")},n))}),T.map((e,n)=>t.jsxRuntimeExports.jsx("g",{transform:`translate(${Math.max(Math.min(R.length+1,5),4)*25+10},${100-n*25})`,children:t.jsxRuntimeExports.jsx("text",{x:0,transform:"rotate(-90)",y:0,fontSize:10,textAnchor:"middle",children:typeof e=="string"||e<1?e:Ne.numberFormattingFunction(e,"NA")})},n))]})}),t.jsxRuntimeExports.jsx(Se.u,{marginBottom:"none",size:"xs",className:"leading-normal text-center shrink-0",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical",overflow:"hidden",writingMode:"vertical-rl",height:"8.5rem",transform:"rotate(180deg)"},children:z})]}),t.jsxRuntimeExports.jsx(Se.u,{marginBottom:"none",size:"xs",className:"mt-1 leading-normal text-center",style:{display:"-webkit-box",WebkitLineClamp:"1",width:"8.5rem",WebkitBoxOrient:"vertical",overflow:"hidden"},children:D})]})]}):t.jsxRuntimeExports.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{K(!0)},children:t.jsxRuntimeExports.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})}),q==="button"&&t.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col",children:[t.jsxRuntimeExports.jsx("button",{onClick:()=>N("in"),className:"leading-0 px-2 py-3.5 border text-primary-gray-700 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),t.jsxRuntimeExports.jsx("button",{onClick:()=>N("out"),className:"leading-0 px-2 py-3.5 border text-primary-gray-700 border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]})]}),G&&se&&pe&&C?t.jsxRuntimeExports.jsx(ze.Tooltip,{data:G,body:se,xPos:pe,yPos:C,backgroundStyle:be?.tooltip,className:Ee?.tooltip}):null,S&&h!==void 0?t.jsxRuntimeExports.jsx(Te.X,{open:h!==void 0,onClose:()=>{Z(void 0)},children:t.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof S=="string"?{__html:We.string2HTML(S,h)}:void 0,children:typeof S=="function"?S(h):null})}):null]})}function Ye(je){const{data:v,graphTitle:R,mapData:f="https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap.json",colors:D=we.Colors.light.bivariateColors.colors05x05,sources:T,graphDescription:z,height:d,width:s,footNote:Y="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.",xDomain:J,yDomain:$,xColorLegendTitle:W="X Color key",yColorLegendTitle:M="Y Color key",tooltip:ne,scale:se=.95,centerPoint:le,padding:ce,mapBorderWidth:ve=.5,mapNoDataColor:B=we.Colors.light.graphNoData,backgroundColor:b=!1,mapBorderColor:A=we.Colors.light.grays["gray-500"],relativeHeight:E,onSeriesMouseOver:S,isWorldMap:ue=!0,zoomScaleExtend:be=[.8,6],zoomTranslateExtend:Ee,graphID:F,showColorScale:q=!0,highlightedIds:k=[],onSeriesMouseClick:V,mapProperty:me="ISO3",graphDownload:de=!1,dataDownload:K=!1,showAntarctica:H=!1,language:_="en",minHeight:h=0,theme:Z="light",ariaLabel:G,resetSelectionOnDoubleClick:Q=!0,detailsOnClick:pe,styles:w,classNames:C,mapProjection:ee,zoomInteraction:O="button",animate:U=!1,dimmedOpacity:xe=.3,customLayers:te=[],timeline:p={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=je,[g,he]=u.useState(0),[re,ge]=u.useState(0),[I,P]=u.useState(p.autoplay),c=Ge.sort(_e.uniqBy(v,"date",!0).map(r=>Ce.parse(`${r}`,p.dateFormat||"yyyy",new Date).getTime()),(r,i)=>Ue.ascending(r,i)),[oe,ie]=u.useState(p.autoplay?0:c.length-1),[X,ye]=u.useState(void 0),N=u.useRef(null),e=u.useRef(null);u.useEffect(()=>{const r=new ResizeObserver(i=>{he(s||i[0].contentRect.width||760),ge(d||i[0].target.clientHeight||480)});return N.current&&(ge(N.current.clientHeight||480),he(N.current.clientWidth||760),s||r.observe(N.current)),()=>r.disconnect()},[s,d]),u.useEffect(()=>{typeof f=="string"?He.fetchAndParseJSON(f).then(i=>{ye(i)}):ye(f)},[f]),u.useEffect(()=>{const r=setInterval(()=>{ie(i=>i<c.length-1?i+1:0)},(p.speed||2)*1e3);return I||clearInterval(r),()=>clearInterval(r)},[c,I,p.speed]);const n=$e.getSliderMarks(c,oe,p.showOnlyActiveDate,p.dateFormat||"yyyy");return J&&$&&(J.length!==D[0].length-1||$.length!==D.length-1)?(console.error("the xDomain and yDomain array length don't match to the color array length"),null):t.jsxRuntimeExports.jsx("div",{className:`${Z||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:_==="he"||_==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${b?b===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${_||"en"}`,s?"w-fit":"w-full",C?.graphContainer),style:{...w?.graphContainer||{},...b&&b!==!0?{backgroundColor:b}:{}},id:F,ref:e,"aria-label":G||`${R?`The graph shows ${R}. `:""}This is bi-variate choropleth map where geographic areas are colored in proportion to two variables.${z?` ${z}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:b?ce||"1rem":ce||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||z||de||K?t.jsxRuntimeExports.jsx(Fe.GraphHeader,{styles:{title:w?.title,description:w?.description},classNames:{title:C?.title,description:C?.description},graphTitle:R,graphDescription:z,width:s,graphDownload:de?e.current:void 0,dataDownload:K?v.map(r=>r.data).filter(r=>r!==void 0).length>0?v.map(r=>r.data).filter(r=>r!==void 0):v.filter(r=>r!==void 0):null}):null,p.enabled&&c.length>0&&n?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{P(!I)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":I?"Click to pause animation":"Click to play animation",children:I?t.jsxRuntimeExports.jsx(Re.Pause,{}):t.jsxRuntimeExports.jsx(Re.Play,{})}),t.jsxRuntimeExports.jsx($e.xr,{min:c[0],max:c[c.length-1],marks:n,step:null,defaultValue:c[c.length-1],value:c[oe],onChangeComplete:r=>{ie(c.indexOf(r))},onChange:r=>{ie(c.indexOf(r))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:N,"aria-label":"Map area",children:(s||g)&&(d||re)&&X?t.jsxRuntimeExports.jsx(Xe,{data:v.filter(r=>p.enabled?r.date===Ce.format(new Date(c[oe]),p.dateFormat||"yyyy"):r),mapData:H?X:{...X,features:X.features.filter(r=>r.properties.NAME!=="Antarctica")},xDomain:J||qe.getJenks(v.map(r=>r.x),D[0].length),yDomain:$||qe.getJenks(v.map(r=>r.y),D.length),width:s||g,height:Math.max(h,d||(E?h?(s||g)*E>h?(s||g)*E:h:(s||g)*E:re)),scale:se,centerPoint:le,colors:D,xColorLegendTitle:W,yColorLegendTitle:M,mapBorderWidth:ve,mapNoDataColor:B,mapBorderColor:A,tooltip:ne,onSeriesMouseOver:S,isWorldMap:ue,zoomScaleExtend:be,zoomTranslateExtend:Ee,onSeriesMouseClick:V,mapProperty:me,highlightedIds:k,resetSelectionOnDoubleClick:Q,styles:w,showColorScale:q,classNames:C,mapProjection:ee||(ue?"naturalEarth":"mercator"),detailsOnClick:pe,zoomInteraction:O,animate:U===!0?{duration:.5,once:!0,amount:.5}:U||{duration:0,once:!0,amount:0},dimmedOpacity:xe,customLayers:te}):t.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(h,d||(E?h?(s||g)*E>h?(s||g)*E:h:(s||g)*E:re))}px`},className:"flex items-center justify-center",children:t.jsxRuntimeExports.jsx(Ie.y,{"aria-label":"Loading graph"})})}),T||Y?t.jsxRuntimeExports.jsx(Ve.GraphFooter,{styles:{footnote:w?.footnote,source:w?.source},classNames:{footnote:C?.footnote,source:C?.source},sources:T,footNote:Y,width:s}):null]})})})})}exports.BiVariateChoroplethMap=Ye;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),u=require("react"),$e=require("./getSliderMarks-CRIbTGYV.cjs"),Ie=require("./Spinner-DA6Z5E4n.cjs"),Ce=require("./parse-hMnG_lRV.cjs"),Pe=require("./index-DQA8q5sC.cjs"),L=require("./zoom-BiMNsz72.cjs"),Le=require("./index-CoZbeNM9.cjs"),Te=require("./Modal-tXZlLE5s.cjs"),Se=require("./Typography-k-kOjICQ.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),ze=require("./Tooltip-De16GWhY.cjs"),We=require("./string2HTML-z7CwHXcx.cjs"),De=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Re=require("./index-BW_-wD2k.cjs"),ke=require("./select-Bnfk0lJx.cjs"),Me=require("./threshold-DNsSUf8Q.cjs"),Be=require("./use-in-view-sQJZ_xDO.cjs"),ae=require("./proxy-BHRoeZgd.cjs"),Ae=require("./index-BW8iNx7E.cjs"),Fe=require("./GraphHeader.cjs"),Ve=require("./GraphFooter.cjs"),we=require("./Colors.cjs"),He=require("./fetchAndParseData-Ba-_CgxS.cjs"),qe=require("./getJenks-GYmdwBqm.cjs"),_e=require("./uniqBy-O05lp2S5.cjs"),Ge=require("./sort-O96oMZLb.cjs"),Ue=require("./init-DU0ybBc_.cjs");function Xe(je){const{data:v,xDomain:R,mapData:f,xColorLegendTitle:D,yDomain:T,yColorLegendTitle:z,width:d,height:s,colors:Y,scale:J,centerPoint:$,mapBorderWidth:W,mapNoDataColor:M,mapBorderColor:ne,tooltip:se,onSeriesMouseOver:le,zoomScaleExtend:ce,zoomTranslateExtend:ve,highlightedIds:B,onSeriesMouseClick:b,mapProperty:A,resetSelectionOnDoubleClick:E,detailsOnClick:S,showColorScale:ue,styles:be,classNames:Ee,mapProjection:F,zoomInteraction:q,animate:k,dimmedOpacity:V,customLayers:me}=je,[de,K]=u.useState(!(d<680)),[H,_]=u.useState(void 0),[h,Z]=u.useState(void 0),[G,Q]=u.useState(void 0),[pe,w]=u.useState(void 0),[C,ee]=u.useState(void 0),O=u.useRef(null),U=Be.useInView(O,{once:k.once,amount:k.amount}),xe=u.useRef(null),te=u.useRef(null);u.useEffect(()=>{const e=ke.select(xe.current),n=ke.select(O.current),r=o=>{if(q==="noZoom")return!1;if(q==="button")return!o.type.includes("wheel");const a=o.type==="wheel",m=o.type.startsWith("touch"),l=o.type==="mousedown"||o.type==="mousemove";return m?!0:a?q==="scroll"?!0:o.ctrlKey:l&&!o.button&&!o.ctrlKey},i=L.zoom().scaleExtent(ce).translateExtent(ve||[[-20,-20],[d+20,s+20]]).filter(r).on("zoom",({transform:o})=>{e.attr("transform",o)});n.call(i),te.current=i},[s,d,q]);const p=L.turf_bbox_default(f),g=Le.turf_center_of_mass_default(f),he=p[2]-p[0],re=p[3]-p[1],ge=d*190/960*360/he,I=s*190/678*180/re,P=J*Math.min(ge,I),c=F==="mercator"?L.geoMercator().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P):F==="equalEarth"?L.geoEqualEarth().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P):F==="naturalEarth"?L.geoNaturalEarth1().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P):F==="orthographic"?L.geoOrthographic().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P):L.geoAlbersUsa().rotate([0,0]).center($||g.geometry.coordinates).translate([d/2,s/2]).scale(P),oe=Array.from({length:R.length},(e,n)=>n),ie=Array.from({length:T.length},(e,n)=>n),X=Me.threshold().domain(R).range(oe),ye=Me.threshold().domain(T).range(ie),N=e=>{if(!O.current||!te.current)return;ke.select(O.current).call(te.current.scaleBy,e==="in"?1.2:1/1.2)};return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"relative",children:[t.jsxRuntimeExports.jsx(ae.motion.svg,{viewBox:`0 0 ${d} ${s}`,width:`${d}px`,height:`${s}px`,ref:O,direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{ref:xe,children:[me.filter(e=>e.position==="before").map(e=>e.layer),f.features.map((e,n)=>v.findIndex(i=>i.id===e.properties[A])!==-1?null:t.jsxRuntimeExports.jsx(ae.motion.g,{opacity:H?V:B.length!==0?B.indexOf(e.properties[A])!==-1?1:V:1,children:e.geometry.type==="MultiPolygon"?e.geometry.coordinates.map((i,o)=>{let a="";return i.forEach(m=>{let l=" M";m.forEach((x,y)=>{const j=c([x[0],x[1]]);y!==m.length-1?l=`${l}${j[0]} ${j[1]}L`:l=`${l}${j[0]} ${j[1]}`}),a+=l}),t.jsxRuntimeExports.jsx("path",{d:a,style:{stroke:ne,strokeWidth:W,fill:M}},o)}):e.geometry.coordinates.map((i,o)=>{let a="M";return i.forEach((m,l)=>{const x=c([m[0],m[1]]);l!==i.length-1?a=`${a}${x[0]} ${x[1]}L`:a=`${a}${x[0]} ${x[1]}`}),t.jsxRuntimeExports.jsx("path",{d:a,style:{stroke:ne,strokeWidth:W,fill:M}},o)})},n)),t.jsxRuntimeExports.jsx(Ae.AnimatePresence,{children:v.map(e=>{const n=f.features.findIndex(a=>e.id===a.properties[A]),r=De.checkIfNullOrUndefined(e.x)?void 0:X(e.x),i=De.checkIfNullOrUndefined(e.y)?void 0:ye(e.y),o=r!==void 0&&i!==void 0?Y[i][r]:M;return t.jsxRuntimeExports.jsx(ae.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:H?H===o?1:V:B.length!==0?B.indexOf(e.id)!==-1?1:V:1,transition:{duration:k.duration}}},initial:"initial",animate:U?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},onMouseEnter:a=>{Q(e),ee(a.clientY),w(a.clientX),le?.(e)},onClick:()=>{(b||S)&&(Pe.isEqual(h,e)&&E?(Z(void 0),b?.(void 0)):(Z(e),b?.(e)))},onMouseMove:a=>{Q(e),ee(a.clientY),w(a.clientX)},onMouseLeave:()=>{Q(void 0),w(void 0),ee(void 0),le?.(void 0)},children:n===-1?null:f.features[n].geometry.type==="MultiPolygon"?f.features[n].geometry.coordinates.map((a,m)=>{let l="";return a.forEach(x=>{let y=" M";x.forEach((j,Oe)=>{const fe=c([j[0],j[1]]);Oe!==x.length-1?y=`${y}${fe[0]} ${fe[1]}L`:y=`${y}${fe[0]} ${fe[1]}`}),l+=y}),t.jsxRuntimeExports.jsx(ae.motion.path,{variants:{initial:{fill:o,opacity:0},whileInView:{fill:o,opacity:1,transition:{duration:k.duration}}},initial:"initial",animate:U?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},d:l,className:`${o===M?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"stroke-primary-white dark:stroke-primary-gray-650"}`,style:{strokeWidth:W}},`${e.id}-${m}`)}):f.features[n].geometry.coordinates.map((a,m)=>{let l="M";return a.forEach((x,y)=>{const j=c([x[0],x[1]]);y!==a.length-1?l=`${l}${j[0]} ${j[1]}L`:l=`${l}${j[0]} ${j[1]}`}),t.jsxRuntimeExports.jsx(ae.motion.path,{d:l,variants:{initial:{fill:o,opacity:0},whileInView:{fill:o,opacity:1,transition:{duration:k.duration}}},initial:"initial",animate:U?"whileInView":"initial",exit:{opacity:0,transition:{duration:k.duration}},className:`${o===M?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"stroke-primary-white dark:stroke-primary-gray-650"}`,style:{strokeWidth:W}},`${e.id}-${m}`)})},e.id)})}),G?f.features.filter(e=>e.properties[A]===G.id).map((e,n)=>t.jsxRuntimeExports.jsx("g",{children:e.geometry.type==="MultiPolygon"?e.geometry.coordinates.map((r,i)=>{let o="";return r.forEach(a=>{let m=" M";a.forEach((l,x)=>{const y=c([l[0],l[1]]);x!==a.length-1?m=`${m}${y[0]} ${y[1]}L`:m=`${m}${y[0]} ${y[1]}`}),o+=m}),t.jsxRuntimeExports.jsx("path",{d:o,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},i)}):e.geometry.coordinates.map((r,i)=>{let o="M";return r.forEach((a,m)=>{const l=c([a[0],a[1]]);m!==r.length-1?o=`${o}${l[0]} ${l[1]}L`:o=`${o}${l[0]} ${l[1]}`}),t.jsxRuntimeExports.jsx("path",{d:o,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},i)})},n)):null,me.filter(e=>e.position==="after").map(e=>e.layer)]})}),ue===!1?null:t.jsxRuntimeExports.jsx("div",{className:"absolute left-4 bottom-4",children:de?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{style:{backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"absolute",right:"-0.75rem",top:"-0.75rem"},onClick:()=>{K(!1)},children:t.jsxRuntimeExports.jsx(Re.X,{})}),t.jsxRuntimeExports.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.7)",width:"175px"},children:[t.jsxRuntimeExports.jsxs("div",{className:"flex gap-1 items-center",children:[t.jsxRuntimeExports.jsx("svg",{width:"136px",viewBox:"0 0 136 136",className:"shrink-0",children:t.jsxRuntimeExports.jsxs("g",{children:[Y.map((e,n)=>t.jsxRuntimeExports.jsx("g",{transform:`translate(0,${100-n*25})`,children:e.map((r,i)=>t.jsxRuntimeExports.jsx("rect",{y:1,x:i*25+1,fill:r,width:23,height:23,strokeWidth:H===r?2:.25,style:{cursor:"pointer"},onMouseOver:()=>{_(r)},onMouseLeave:()=>{_(void 0)}},i))},n)),t.jsxRuntimeExports.jsx("g",{transform:"translate(0,125)",children:R.map((e,n)=>t.jsxRuntimeExports.jsx("text",{y:10,x:(n+1)*25,fontSize:10,textAnchor:"middle",children:typeof e=="string"||e<1?e:Ne.numberFormattingFunction(e,"NA")},n))}),T.map((e,n)=>t.jsxRuntimeExports.jsx("g",{transform:`translate(${Math.max(Math.min(R.length+1,5),4)*25+10},${100-n*25})`,children:t.jsxRuntimeExports.jsx("text",{x:0,transform:"rotate(-90)",y:0,fontSize:10,textAnchor:"middle",children:typeof e=="string"||e<1?e:Ne.numberFormattingFunction(e,"NA")})},n))]})}),t.jsxRuntimeExports.jsx(Se.u,{marginBottom:"none",size:"xs",className:"leading-normal text-center shrink-0",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical",overflow:"hidden",writingMode:"vertical-rl",height:"8.5rem",transform:"rotate(180deg)"},children:z})]}),t.jsxRuntimeExports.jsx(Se.u,{marginBottom:"none",size:"xs",className:"mt-1 leading-normal text-center",style:{display:"-webkit-box",WebkitLineClamp:"1",width:"8.5rem",WebkitBoxOrient:"vertical",overflow:"hidden"},children:D})]})]}):t.jsxRuntimeExports.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{K(!0)},children:t.jsxRuntimeExports.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})}),q==="button"&&t.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col",children:[t.jsxRuntimeExports.jsx("button",{onClick:()=>N("in"),className:"leading-0 px-2 py-3.5 border text-primary-gray-700 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),t.jsxRuntimeExports.jsx("button",{onClick:()=>N("out"),className:"leading-0 px-2 py-3.5 border text-primary-gray-700 border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]})]}),G&&se&&pe&&C?t.jsxRuntimeExports.jsx(ze.Tooltip,{data:G,body:se,xPos:pe,yPos:C,backgroundStyle:be?.tooltip,className:Ee?.tooltip}):null,S&&h!==void 0?t.jsxRuntimeExports.jsx(Te.X,{open:h!==void 0,onClose:()=>{Z(void 0)},children:t.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof S=="string"?{__html:We.string2HTML(S,h)}:void 0,children:typeof S=="function"?S(h):null})}):null]})}function Ye(je){const{data:v,graphTitle:R,mapData:f="https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap.json",colors:D=we.Colors.light.bivariateColors.colors05x05,sources:T,graphDescription:z,height:d,width:s,footNote:Y="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.",xDomain:J,yDomain:$,xColorLegendTitle:W="X Color key",yColorLegendTitle:M="Y Color key",tooltip:ne,scale:se=.95,centerPoint:le,padding:ce,mapBorderWidth:ve=.5,mapNoDataColor:B=we.Colors.light.graphNoData,backgroundColor:b=!1,mapBorderColor:A=we.Colors.light.grays["gray-500"],relativeHeight:E,onSeriesMouseOver:S,isWorldMap:ue=!0,zoomScaleExtend:be=[.8,6],zoomTranslateExtend:Ee,graphID:F,showColorScale:q=!0,highlightedIds:k=[],onSeriesMouseClick:V,mapProperty:me="ISO3",graphDownload:de=!1,dataDownload:K=!1,showAntarctica:H=!1,language:_="en",minHeight:h=0,theme:Z="light",ariaLabel:G,resetSelectionOnDoubleClick:Q=!0,detailsOnClick:pe,styles:w,classNames:C,mapProjection:ee,zoomInteraction:O="button",animate:U=!1,dimmedOpacity:xe=.3,customLayers:te=[],timeline:p={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=je,[g,he]=u.useState(0),[re,ge]=u.useState(0),[I,P]=u.useState(p.autoplay),c=Ge.sort(_e.uniqBy(v,"date",!0).map(r=>Ce.parse(`${r}`,p.dateFormat||"yyyy",new Date).getTime()),(r,i)=>Ue.ascending(r,i)),[oe,ie]=u.useState(p.autoplay?0:c.length-1),[X,ye]=u.useState(void 0),N=u.useRef(null),e=u.useRef(null);u.useEffect(()=>{const r=new ResizeObserver(i=>{he(s||i[0].contentRect.width||760),ge(d||i[0].target.clientHeight||480)});return N.current&&(ge(N.current.clientHeight||480),he(N.current.clientWidth||760),s||r.observe(N.current)),()=>r.disconnect()},[s,d]),u.useEffect(()=>{typeof f=="string"?He.fetchAndParseJSON(f).then(i=>{ye(i)}):ye(f)},[f]),u.useEffect(()=>{const r=setInterval(()=>{ie(i=>i<c.length-1?i+1:0)},(p.speed||2)*1e3);return I||clearInterval(r),()=>clearInterval(r)},[c,I,p.speed]);const n=$e.getSliderMarks(c,oe,p.showOnlyActiveDate,p.dateFormat||"yyyy");return J&&$&&(J.length!==D[0].length-1||$.length!==D.length-1)?(console.error("the xDomain and yDomain array length don't match to the color array length"),null):t.jsxRuntimeExports.jsx("div",{className:`${Z||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:_==="he"||_==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${b?b===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${_||"en"}`,s?"w-fit":"w-full",C?.graphContainer),style:{...w?.graphContainer||{},...b&&b!==!0?{backgroundColor:b}:{}},id:F,ref:e,"aria-label":G||`${R?`The graph shows ${R}. `:""}This is bi-variate choropleth map where geographic areas are colored in proportion to two variables.${z?` ${z}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:b?ce||"1rem":ce||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||z||de||K?t.jsxRuntimeExports.jsx(Fe.GraphHeader,{styles:{title:w?.title,description:w?.description},classNames:{title:C?.title,description:C?.description},graphTitle:R,graphDescription:z,width:s,graphDownload:de?e.current:void 0,dataDownload:K?v.map(r=>r.data).filter(r=>r!==void 0).length>0?v.map(r=>r.data).filter(r=>r!==void 0):v.filter(r=>r!==void 0):null}):null,p.enabled&&c.length>0&&n?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{P(!I)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":I?"Click to pause animation":"Click to play animation",children:I?t.jsxRuntimeExports.jsx(Re.Pause,{}):t.jsxRuntimeExports.jsx(Re.Play,{})}),t.jsxRuntimeExports.jsx($e.xr,{min:c[0],max:c[c.length-1],marks:n,step:null,defaultValue:c[c.length-1],value:c[oe],onChangeComplete:r=>{ie(c.indexOf(r))},onChange:r=>{ie(c.indexOf(r))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:N,"aria-label":"Map area",children:(s||g)&&(d||re)&&X?t.jsxRuntimeExports.jsx(Xe,{data:v.filter(r=>p.enabled?r.date===Ce.format(new Date(c[oe]),p.dateFormat||"yyyy"):r),mapData:H?X:{...X,features:X.features.filter(r=>r.properties.NAME!=="Antarctica")},xDomain:J||qe.getJenks(v.map(r=>r.x),D[0].length),yDomain:$||qe.getJenks(v.map(r=>r.y),D.length),width:s||g,height:Math.max(h,d||(E?h?(s||g)*E>h?(s||g)*E:h:(s||g)*E:re)),scale:se,centerPoint:le,colors:D,xColorLegendTitle:W,yColorLegendTitle:M,mapBorderWidth:ve,mapNoDataColor:B,mapBorderColor:A,tooltip:ne,onSeriesMouseOver:S,isWorldMap:ue,zoomScaleExtend:be,zoomTranslateExtend:Ee,onSeriesMouseClick:V,mapProperty:me,highlightedIds:k,resetSelectionOnDoubleClick:Q,styles:w,showColorScale:q,classNames:C,mapProjection:ee||(ue?"naturalEarth":"mercator"),detailsOnClick:pe,zoomInteraction:O,animate:U===!0?{duration:.5,once:!0,amount:.5}:U||{duration:0,once:!0,amount:0},dimmedOpacity:xe,customLayers:te}):t.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(h,d||(E?h?(s||g)*E>h?(s||g)*E:h:(s||g)*E:re))}px`},className:"flex items-center justify-center",children:t.jsxRuntimeExports.jsx(Ie.y,{"aria-label":"Loading graph"})})}),T||Y?t.jsxRuntimeExports.jsx(Ve.GraphFooter,{styles:{footnote:w?.footnote,source:w?.source},classNames:{footnote:C?.footnote,source:C?.source},sources:T,footNote:Y,width:s}):null]})})})})}exports.BiVariateChoroplethMap=Ye;
2
2
  //# sourceMappingURL=BiVariateChoroplethMap.cjs.map
@@ -4,8 +4,8 @@ import { g as Ie, x as Le } from "./getSliderMarks-9cNoRkDx.js";
4
4
  import { y as ze } from "./Spinner-C85UF28E.js";
5
5
  import { p as We, f as Te } from "./parse-DlCRUFh_.js";
6
6
  import { i as Ae } from "./index-Bwrro8-q.js";
7
- import { z as Be, t as Ve, g as _e, a as Fe, b as He, c as Xe, d as Re } from "./zoom-DAu91HKr.js";
8
- import { t as Ue } from "./index-qfWCwobm.js";
7
+ import { z as Be, t as Ve, g as _e, a as Fe, b as He, c as Xe, d as Re } from "./zoom-QipiAl5W.js";
8
+ import { t as Ue } from "./index-9tDEUqOZ.js";
9
9
  import { X as Ye } from "./Modal-DVVwpKhP.js";
10
10
  import { u as Ne } from "./Typography-Ctgfl1J5.js";
11
11
  import { n as De } from "./numberFormattingFunction-14YCbkN2.js";
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),Ee=require("./getSliderMarks-CRIbTGYV.cjs"),we=require("./Spinner-DA6Z5E4n.cjs"),be=require("./parse-hMnG_lRV.cjs"),Re=require("./index-DQA8q5sC.cjs"),V=require("./zoom-Bsbhil-K.cjs"),$e=require("./Modal-tXZlLE5s.cjs"),ke=require("./Typography-k-kOjICQ.cjs"),Ce=require("./index-D05lK1Te.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),Se=require("./Tooltip-De16GWhY.cjs"),Me=require("./string2HTML-z7CwHXcx.cjs"),qe=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ve=require("./index-BW_-wD2k.cjs"),De=require("./ordinal-BOeNbyae.cjs"),Oe=require("./threshold-DNsSUf8Q.cjs"),je=require("./select-Bnfk0lJx.cjs"),Pe=require("./use-in-view-sQJZ_xDO.cjs"),ue=require("./proxy-BHRoeZgd.cjs"),Ie=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),de=require("./Colors.cjs"),ze=require("./fetchAndParseData-Ba-_CgxS.cjs"),We=require("./getUniqValue-RViz8tTw.cjs"),Ve=require("./getJenks-GYmdwBqm.cjs"),Be=require("./uniqBy-O05lp2S5.cjs"),Fe=require("./sort-O96oMZLb.cjs"),He=require("./init-DU0ybBc_.cjs");function Ae(pe){const{data:E,colorDomain:h,colors:c,mapData:j,colorLegendTitle:B,categorical:q,height:x,width:n,scale:ae,centerPoint:T,tooltip:se,mapBorderWidth:D,mapBorderColor:F,mapNoDataColor:Y,onSeriesMouseOver:J,showColorScale:me,zoomScaleExtend:xe,zoomTranslateExtend:O,highlightedIds:H,onSeriesMouseClick:y,mapProperty:A,resetSelectionOnDoubleClick:he,detailsOnClick:$,styles:ge,classNames:ye,mapProjection:U,zoomInteraction:z,animate:b,dimmedOpacity:G,customLayers:ie}=pe,[k,C]=d.useState(void 0),K=d.useRef(null),[Z,v]=d.useState(!(n<680)),[N,Q]=d.useState(void 0),[_,ee]=d.useState(void 0),[S,w]=d.useState(void 0),[ne,te]=d.useState(void 0),P=d.useRef(null),re=Pe.useInView(P,{once:b.once,amount:b.amount}),le=d.useRef(null),f=q?De.ordinal().domain(h).range(c):Oe.threshold().domain(h).range(c);d.useEffect(()=>{const r=je.select(le.current),l=je.select(P.current),p=a=>{if(z==="noZoom")return!1;if(z==="button")return!a.type.includes("wheel");const i=a.type==="wheel",t=a.type.startsWith("touch"),o=a.type==="mousedown"||a.type==="mousemove";return t?!0:i?z==="scroll"?!0:a.ctrlKey:o&&!a.button&&!a.ctrlKey},s=V.zoom().scaleExtent(xe).translateExtent(O||[[-20,-20],[n+20,x+20]]).filter(p).on("zoom",({transform:a})=>{r.attr("transform",a)});l.call(s),K.current=s},[x,n,z]);const g=V.turf_bbox_default(j),I=Ce.turf_center_of_mass_default(j),oe=g[2]-g[0],ce=g[3]-g[1],W=n*190/960*360/oe,fe=x*190/678*180/ce,u=ae*Math.min(W,fe),R=U==="mercator"?V.geoMercator().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="equalEarth"?V.geoEqualEarth().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="naturalEarth"?V.geoNaturalEarth1().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="orthographic"?V.geoOrthographic().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):V.geoAlbersUsa().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u),X=r=>{if(!P.current||!K.current)return;je.select(P.current).call(K.current.scaleBy,r==="in"?1.2:1/1.2)};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"relative",children:[e.jsxRuntimeExports.jsx(ue.motion.svg,{width:`${n}px`,height:`${x}px`,viewBox:`0 0 ${n} ${x}`,ref:P,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{ref:le,children:[ie.filter(r=>r.position==="before").map(r=>r.layer),j.features.map((r,l)=>E.findIndex(s=>s.id===r.properties[A])!==-1?null:e.jsxRuntimeExports.jsx("g",{opacity:k?G:H.length!==0?H.indexOf(r.properties[A])!==-1?1:G:1,children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((s,a)=>{let i="";return s.forEach(t=>{let o=" M";t.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==t.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),i+=o}),e.jsxRuntimeExports.jsx("path",{d:i,style:{stroke:F,strokeWidth:D,fill:Y}},a)}):r.geometry.coordinates.map((s,a)=>{let i="M";return s.forEach((t,o)=>{const m=R([t[0],t[1]]);o!==s.length-1?i=`${i}${m[0]} ${m[1]}L`:i=`${i}${m[0]} ${m[1]}`}),e.jsxRuntimeExports.jsx("path",{d:i,style:{stroke:F,strokeWidth:D,fill:Y}},a)})},l)),e.jsxRuntimeExports.jsx(Ie.AnimatePresence,{children:E.map(r=>{const l=j.features.findIndex(s=>r.id===s.properties[A]),p=qe.checkIfNullOrUndefined(r.x)?Y:f(r.x);return e.jsxRuntimeExports.jsx(ue.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:k?k===p?1:G:H.length!==0?H.indexOf(r.id)!==-1?1:G:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},onMouseEnter:s=>{ee(r),te(s.clientY),w(s.clientX),J?.(r)},onMouseMove:s=>{ee(r),te(s.clientY),w(s.clientX)},onMouseLeave:()=>{ee(void 0),w(void 0),te(void 0),J?.(void 0)},onClick:()=>{(y||$)&&(Re.isEqual(N,r)&&he?(Q(void 0),y?.(void 0)):(Q(r),y?.(r)))},children:l===-1?null:j.features[l].geometry.type==="MultiPolygon"?j.features[l].geometry.coordinates.map((s,a)=>{let i="";return s.forEach(t=>{let o=" M";t.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==t.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),i+=o}),e.jsxRuntimeExports.jsx(ue.motion.path,{d:i,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)}):j.features[l].geometry.coordinates.map((s,a)=>{let i="M";return s.forEach((t,o)=>{const m=R([t[0],t[1]]);o!==s.length-1?i=`${i}${m[0]} ${m[1]}L`:i=`${i}${m[0]} ${m[1]}`}),e.jsxRuntimeExports.jsx(ue.motion.path,{d:i,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)})},r.id)})}),_?j.features.filter(r=>r.properties[A]===_.id).map((r,l)=>e.jsxRuntimeExports.jsx("g",{children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((p,s)=>{let a="";return p.forEach(i=>{let t=" M";i.forEach((o,m)=>{const L=R([o[0],o[1]]);m!==i.length-1?t=`${t}${L[0]} ${L[1]}L`:t=`${t}${L[0]} ${L[1]}`}),a+=t}),e.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},s)}):r.geometry.coordinates.map((p,s)=>{let a="M";return p.forEach((i,t)=>{const o=R([i[0],i[1]]);t!==p.length-1?a=`${a}${o[0]} ${o[1]}L`:a=`${a}${o[0]} ${o[1]}`}),e.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},s)})},l)):null,ie.filter(r=>r.position==="after").map(r=>r.layer)]})}),me===!1?null:e.jsxRuntimeExports.jsx("div",{className:"absolute left-4 bottom-4",children:Z?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{style:{backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"absolute",right:"-0.75rem",top:"-0.75rem"},onClick:()=>{v(!1)},children:e.jsxRuntimeExports.jsx(ve.X,{})}),e.jsxRuntimeExports.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.7)",width:q?void 0:"340px"},children:[B&&B!==""?e.jsxRuntimeExports.jsx(ke.u,{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:B}):null,q?e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-3",children:h.map((r,l)=>e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{C(c[l%c.length])},onMouseLeave:()=>{C(void 0)},children:[e.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:c[l%c.length]}}),e.jsxRuntimeExports.jsx(ke.u,{size:"sm",marginBottom:"none",leading:"none",children:r})]},l))}):e.jsxRuntimeExports.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{children:[h.map((r,l)=>e.jsxRuntimeExports.jsxs("g",{onMouseOver:()=>{C(c[l])},onMouseLeave:()=>{C(void 0)},className:"cursor-pointer",children:[e.jsxRuntimeExports.jsx("rect",{x:l*320/c.length+1,y:1,width:320/c.length-2,height:8,className:k===c[l]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:c[l],...k===c[l]?{}:{stroke:c[l]}}}),e.jsxRuntimeExports.jsx("text",{x:(l+1)*320/c.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:Ne.numberFormattingFunction(r,"NA")})]},l)),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsx("rect",{onMouseOver:()=>{C(c[h.length])},onMouseLeave:()=>{C(void 0)},x:h.length*320/c.length+1,y:1,width:320/c.length-2,height:8,className:`cursor-pointer ${k===c[h.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:c[h.length],...k===c[h.length]?{}:{stroke:c[h.length]}}})})]})})]})]}):e.jsxRuntimeExports.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{v(!0)},children:e.jsxRuntimeExports.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})}),z==="button"&&e.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col",children:[e.jsxRuntimeExports.jsx("button",{onClick:()=>X("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-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),e.jsxRuntimeExports.jsx("button",{onClick:()=>X("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-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]})]}),$&&N!==void 0?e.jsxRuntimeExports.jsx($e.X,{open:N!==void 0,onClose:()=>{Q(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof $=="string"?{__html:Me.string2HTML($,N)}:void 0,children:typeof $=="function"?$(N):null})}):null,_&&se&&S&&ne?e.jsxRuntimeExports.jsx(Se.Tooltip,{data:_,body:se,xPos:S,yPos:ne,backgroundStyle:ge?.tooltip,className:ye?.tooltip}):null]})}function Ue(pe){const{data:E,mapData:h="https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap.json",graphTitle:c,colors:j,sources:B,graphDescription:q,height:x,width:n,footNote:ae="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.",colorDomain:T,colorLegendTitle:se,scaleType:D="threshold",scale:F=.95,centerPoint:Y,padding:J,mapBorderWidth:me=.5,mapNoDataColor:xe=de.Colors.light.graphNoData,backgroundColor:O=!1,mapBorderColor:H=de.Colors.light.grays["gray-500"],relativeHeight:y,tooltip:A,onSeriesMouseOver:he,isWorldMap:$=!0,showColorScale:ge=!0,zoomScaleExtend:ye=[.8,6],zoomTranslateExtend:U,graphID:z,highlightedIds:b=[],onSeriesMouseClick:G,mapProperty:ie="ISO3",graphDownload:k=!1,dataDownload:C=!1,showAntarctica:K=!1,language:Z="en",minHeight:v=0,theme:N="light",ariaLabel:Q,resetSelectionOnDoubleClick:_=!0,detailsOnClick:ee,styles:S,classNames:w,mapProjection:ne,zoomInteraction:te="button",animate:P=!1,dimmedOpacity:re=.3,customLayers:le=[],timeline:f={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=pe,[g,I]=d.useState(0),[oe,ce]=d.useState(0),[W,fe]=d.useState(f.autoplay),u=Fe.sort(Be.uniqBy(E,"date",!0).map(t=>be.parse(`${t}`,f.dateFormat||"yyyy",new Date).getTime()),(t,o)=>He.ascending(t,o)),[R,X]=d.useState(f.autoplay?0:u.length-1),[r,l]=d.useState(void 0),p=d.useRef(null),s=d.useRef(null);d.useEffect(()=>{const t=new ResizeObserver(o=>{I(n||o[0].target.clientWidth||760),ce(x||o[0].target.clientHeight||480)});return p.current&&(ce(p.current.clientHeight||480),I(p.current.clientWidth||760),n||t.observe(p.current)),()=>t.disconnect()},[n,x]),d.useEffect(()=>{typeof h=="string"?ze.fetchAndParseJSON(h).then(o=>{l(o)}):l(h)},[h]);const a=T||(D==="categorical"?We.getUniqValue(E,"x"):Ve.getJenks(E.map(t=>t.x),j?.length||4));d.useEffect(()=>{const t=setInterval(()=>{X(o=>o<u.length-1?o+1:0)},(f.speed||2)*1e3);return W||clearInterval(t),()=>clearInterval(t)},[u,W,f.speed]);const i=Ee.getSliderMarks(u,R,f.showOnlyActiveDate,f.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${n?"w-fit grow-0":"w-full grow"}`,dir:Z==="he"||Z==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${O?O===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${Z||"en"}`,n?"w-fit":"w-full",w?.graphContainer),style:{...S?.graphContainer||{},...O&&O!==!0?{backgroundColor:O}:{}},id:z,ref:s,"aria-label":Q||`${c?`The graph shows ${c}. `:""}This is a choropleth map where geographic areas are colored in proportion to a specific variable.${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:O?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[c||q||k||C?e.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:S?.title,description:S?.description},classNames:{title:w?.title,description:w?.description},graphTitle:c,graphDescription:q,width:n,graphDownload:k?s.current:void 0,dataDownload:C?E.map(t=>t.data).filter(t=>t!==void 0).length>0?E.map(t=>t.data).filter(t=>t!==void 0):E.filter(t=>t!==void 0):null}):null,f.enabled&&u.length>0&&i?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{fe(!W)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":W?"Click to pause animation":"Click to play animation",children:W?e.jsxRuntimeExports.jsx(ve.Pause,{}):e.jsxRuntimeExports.jsx(ve.Play,{})}),e.jsxRuntimeExports.jsx(Ee.xr,{min:u[0],max:u[u.length-1],marks:i,step:null,defaultValue:u[u.length-1],value:u[R],onChangeComplete:t=>{X(u.indexOf(t))},onChange:t=>{X(u.indexOf(t))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:p,"aria-label":"Map area",children:(n||g)&&(x||oe)&&r?e.jsxRuntimeExports.jsx(Ae,{data:E.filter(t=>f.enabled?t.date===be.format(new Date(u[R]),f.dateFormat||"yyyy"):t),mapData:K?r:{...r,features:r.features.filter(t=>t.properties.NAME!=="Antarctica")},colorDomain:a,width:n||g,height:Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe)),scale:F,centerPoint:Y,colors:j||(D==="categorical"?de.Colors[N].sequentialColors[`neutralColorsx0${a.length}`]:de.Colors[N].sequentialColors[`neutralColorsx0${a.length+1}`]),colorLegendTitle:se,mapBorderWidth:me,mapNoDataColor:xe,categorical:D==="categorical",mapBorderColor:H,tooltip:A,onSeriesMouseOver:he,isWorldMap:$,showColorScale:ge,zoomScaleExtend:ye,zoomTranslateExtend:U,onSeriesMouseClick:G,mapProperty:ie,highlightedIds:b,resetSelectionOnDoubleClick:_,styles:S,classNames:w,detailsOnClick:ee,mapProjection:ne||($?"naturalEarth":"mercator"),zoomInteraction:te,dimmedOpacity:re,animate:P===!0?{duration:.5,once:!0,amount:.5}:P||{duration:0,once:!0,amount:0},customLayers:le}):e.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe))}px`},className:"flex items-center justify-center",children:e.jsxRuntimeExports.jsx(we.y,{"aria-label":"Loading graph"})})}),B||ae?e.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:S?.footnote,source:S?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:B,footNote:ae,width:n}):null]})})})})}exports.ChoroplethMap=Ue;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),Ee=require("./getSliderMarks-CRIbTGYV.cjs"),we=require("./Spinner-DA6Z5E4n.cjs"),be=require("./parse-hMnG_lRV.cjs"),Re=require("./index-DQA8q5sC.cjs"),V=require("./zoom-BiMNsz72.cjs"),$e=require("./Modal-tXZlLE5s.cjs"),ke=require("./Typography-k-kOjICQ.cjs"),Ce=require("./index-CoZbeNM9.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),Se=require("./Tooltip-De16GWhY.cjs"),Me=require("./string2HTML-z7CwHXcx.cjs"),qe=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ve=require("./index-BW_-wD2k.cjs"),De=require("./ordinal-BOeNbyae.cjs"),Oe=require("./threshold-DNsSUf8Q.cjs"),je=require("./select-Bnfk0lJx.cjs"),Pe=require("./use-in-view-sQJZ_xDO.cjs"),ue=require("./proxy-BHRoeZgd.cjs"),Ie=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),de=require("./Colors.cjs"),ze=require("./fetchAndParseData-Ba-_CgxS.cjs"),We=require("./getUniqValue-RViz8tTw.cjs"),Ve=require("./getJenks-GYmdwBqm.cjs"),Be=require("./uniqBy-O05lp2S5.cjs"),Fe=require("./sort-O96oMZLb.cjs"),He=require("./init-DU0ybBc_.cjs");function Ae(pe){const{data:E,colorDomain:h,colors:c,mapData:j,colorLegendTitle:B,categorical:q,height:x,width:n,scale:ae,centerPoint:T,tooltip:se,mapBorderWidth:D,mapBorderColor:F,mapNoDataColor:Y,onSeriesMouseOver:J,showColorScale:me,zoomScaleExtend:xe,zoomTranslateExtend:O,highlightedIds:H,onSeriesMouseClick:y,mapProperty:A,resetSelectionOnDoubleClick:he,detailsOnClick:$,styles:ge,classNames:ye,mapProjection:U,zoomInteraction:z,animate:b,dimmedOpacity:G,customLayers:ie}=pe,[k,C]=d.useState(void 0),K=d.useRef(null),[Z,v]=d.useState(!(n<680)),[N,Q]=d.useState(void 0),[_,ee]=d.useState(void 0),[S,w]=d.useState(void 0),[ne,te]=d.useState(void 0),P=d.useRef(null),re=Pe.useInView(P,{once:b.once,amount:b.amount}),le=d.useRef(null),f=q?De.ordinal().domain(h).range(c):Oe.threshold().domain(h).range(c);d.useEffect(()=>{const r=je.select(le.current),l=je.select(P.current),p=a=>{if(z==="noZoom")return!1;if(z==="button")return!a.type.includes("wheel");const i=a.type==="wheel",t=a.type.startsWith("touch"),o=a.type==="mousedown"||a.type==="mousemove";return t?!0:i?z==="scroll"?!0:a.ctrlKey:o&&!a.button&&!a.ctrlKey},s=V.zoom().scaleExtent(xe).translateExtent(O||[[-20,-20],[n+20,x+20]]).filter(p).on("zoom",({transform:a})=>{r.attr("transform",a)});l.call(s),K.current=s},[x,n,z]);const g=V.turf_bbox_default(j),I=Ce.turf_center_of_mass_default(j),oe=g[2]-g[0],ce=g[3]-g[1],W=n*190/960*360/oe,fe=x*190/678*180/ce,u=ae*Math.min(W,fe),R=U==="mercator"?V.geoMercator().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="equalEarth"?V.geoEqualEarth().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="naturalEarth"?V.geoNaturalEarth1().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="orthographic"?V.geoOrthographic().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):V.geoAlbersUsa().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u),X=r=>{if(!P.current||!K.current)return;je.select(P.current).call(K.current.scaleBy,r==="in"?1.2:1/1.2)};return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs("div",{className:"relative",children:[e.jsxRuntimeExports.jsx(ue.motion.svg,{width:`${n}px`,height:`${x}px`,viewBox:`0 0 ${n} ${x}`,ref:P,direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{ref:le,children:[ie.filter(r=>r.position==="before").map(r=>r.layer),j.features.map((r,l)=>E.findIndex(s=>s.id===r.properties[A])!==-1?null:e.jsxRuntimeExports.jsx("g",{opacity:k?G:H.length!==0?H.indexOf(r.properties[A])!==-1?1:G:1,children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((s,a)=>{let i="";return s.forEach(t=>{let o=" M";t.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==t.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),i+=o}),e.jsxRuntimeExports.jsx("path",{d:i,style:{stroke:F,strokeWidth:D,fill:Y}},a)}):r.geometry.coordinates.map((s,a)=>{let i="M";return s.forEach((t,o)=>{const m=R([t[0],t[1]]);o!==s.length-1?i=`${i}${m[0]} ${m[1]}L`:i=`${i}${m[0]} ${m[1]}`}),e.jsxRuntimeExports.jsx("path",{d:i,style:{stroke:F,strokeWidth:D,fill:Y}},a)})},l)),e.jsxRuntimeExports.jsx(Ie.AnimatePresence,{children:E.map(r=>{const l=j.features.findIndex(s=>r.id===s.properties[A]),p=qe.checkIfNullOrUndefined(r.x)?Y:f(r.x);return e.jsxRuntimeExports.jsx(ue.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:k?k===p?1:G:H.length!==0?H.indexOf(r.id)!==-1?1:G:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},onMouseEnter:s=>{ee(r),te(s.clientY),w(s.clientX),J?.(r)},onMouseMove:s=>{ee(r),te(s.clientY),w(s.clientX)},onMouseLeave:()=>{ee(void 0),w(void 0),te(void 0),J?.(void 0)},onClick:()=>{(y||$)&&(Re.isEqual(N,r)&&he?(Q(void 0),y?.(void 0)):(Q(r),y?.(r)))},children:l===-1?null:j.features[l].geometry.type==="MultiPolygon"?j.features[l].geometry.coordinates.map((s,a)=>{let i="";return s.forEach(t=>{let o=" M";t.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==t.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),i+=o}),e.jsxRuntimeExports.jsx(ue.motion.path,{d:i,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)}):j.features[l].geometry.coordinates.map((s,a)=>{let i="M";return s.forEach((t,o)=>{const m=R([t[0],t[1]]);o!==s.length-1?i=`${i}${m[0]} ${m[1]}L`:i=`${i}${m[0]} ${m[1]}`}),e.jsxRuntimeExports.jsx(ue.motion.path,{d:i,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)})},r.id)})}),_?j.features.filter(r=>r.properties[A]===_.id).map((r,l)=>e.jsxRuntimeExports.jsx("g",{children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((p,s)=>{let a="";return p.forEach(i=>{let t=" M";i.forEach((o,m)=>{const L=R([o[0],o[1]]);m!==i.length-1?t=`${t}${L[0]} ${L[1]}L`:t=`${t}${L[0]} ${L[1]}`}),a+=t}),e.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},s)}):r.geometry.coordinates.map((p,s)=>{let a="M";return p.forEach((i,t)=>{const o=R([i[0],i[1]]);t!==p.length-1?a=`${a}${o[0]} ${o[1]}L`:a=`${a}${o[0]} ${o[1]}`}),e.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},s)})},l)):null,ie.filter(r=>r.position==="after").map(r=>r.layer)]})}),me===!1?null:e.jsxRuntimeExports.jsx("div",{className:"absolute left-4 bottom-4",children:Z?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx("div",{style:{backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"absolute",right:"-0.75rem",top:"-0.75rem"},onClick:()=>{v(!1)},children:e.jsxRuntimeExports.jsx(ve.X,{})}),e.jsxRuntimeExports.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.7)",width:q?void 0:"340px"},children:[B&&B!==""?e.jsxRuntimeExports.jsx(ke.u,{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:B}):null,q?e.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-3",children:h.map((r,l)=>e.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{C(c[l%c.length])},onMouseLeave:()=>{C(void 0)},children:[e.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:c[l%c.length]}}),e.jsxRuntimeExports.jsx(ke.u,{size:"sm",marginBottom:"none",leading:"none",children:r})]},l))}):e.jsxRuntimeExports.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:e.jsxRuntimeExports.jsxs("g",{children:[h.map((r,l)=>e.jsxRuntimeExports.jsxs("g",{onMouseOver:()=>{C(c[l])},onMouseLeave:()=>{C(void 0)},className:"cursor-pointer",children:[e.jsxRuntimeExports.jsx("rect",{x:l*320/c.length+1,y:1,width:320/c.length-2,height:8,className:k===c[l]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:c[l],...k===c[l]?{}:{stroke:c[l]}}}),e.jsxRuntimeExports.jsx("text",{x:(l+1)*320/c.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:Ne.numberFormattingFunction(r,"NA")})]},l)),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsx("rect",{onMouseOver:()=>{C(c[h.length])},onMouseLeave:()=>{C(void 0)},x:h.length*320/c.length+1,y:1,width:320/c.length-2,height:8,className:`cursor-pointer ${k===c[h.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:c[h.length],...k===c[h.length]?{}:{stroke:c[h.length]}}})})]})})]})]}):e.jsxRuntimeExports.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{v(!0)},children:e.jsxRuntimeExports.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})}),z==="button"&&e.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col",children:[e.jsxRuntimeExports.jsx("button",{onClick:()=>X("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-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),e.jsxRuntimeExports.jsx("button",{onClick:()=>X("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-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]})]}),$&&N!==void 0?e.jsxRuntimeExports.jsx($e.X,{open:N!==void 0,onClose:()=>{Q(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof $=="string"?{__html:Me.string2HTML($,N)}:void 0,children:typeof $=="function"?$(N):null})}):null,_&&se&&S&&ne?e.jsxRuntimeExports.jsx(Se.Tooltip,{data:_,body:se,xPos:S,yPos:ne,backgroundStyle:ge?.tooltip,className:ye?.tooltip}):null]})}function Ue(pe){const{data:E,mapData:h="https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap.json",graphTitle:c,colors:j,sources:B,graphDescription:q,height:x,width:n,footNote:ae="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.",colorDomain:T,colorLegendTitle:se,scaleType:D="threshold",scale:F=.95,centerPoint:Y,padding:J,mapBorderWidth:me=.5,mapNoDataColor:xe=de.Colors.light.graphNoData,backgroundColor:O=!1,mapBorderColor:H=de.Colors.light.grays["gray-500"],relativeHeight:y,tooltip:A,onSeriesMouseOver:he,isWorldMap:$=!0,showColorScale:ge=!0,zoomScaleExtend:ye=[.8,6],zoomTranslateExtend:U,graphID:z,highlightedIds:b=[],onSeriesMouseClick:G,mapProperty:ie="ISO3",graphDownload:k=!1,dataDownload:C=!1,showAntarctica:K=!1,language:Z="en",minHeight:v=0,theme:N="light",ariaLabel:Q,resetSelectionOnDoubleClick:_=!0,detailsOnClick:ee,styles:S,classNames:w,mapProjection:ne,zoomInteraction:te="button",animate:P=!1,dimmedOpacity:re=.3,customLayers:le=[],timeline:f={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=pe,[g,I]=d.useState(0),[oe,ce]=d.useState(0),[W,fe]=d.useState(f.autoplay),u=Fe.sort(Be.uniqBy(E,"date",!0).map(t=>be.parse(`${t}`,f.dateFormat||"yyyy",new Date).getTime()),(t,o)=>He.ascending(t,o)),[R,X]=d.useState(f.autoplay?0:u.length-1),[r,l]=d.useState(void 0),p=d.useRef(null),s=d.useRef(null);d.useEffect(()=>{const t=new ResizeObserver(o=>{I(n||o[0].target.clientWidth||760),ce(x||o[0].target.clientHeight||480)});return p.current&&(ce(p.current.clientHeight||480),I(p.current.clientWidth||760),n||t.observe(p.current)),()=>t.disconnect()},[n,x]),d.useEffect(()=>{typeof h=="string"?ze.fetchAndParseJSON(h).then(o=>{l(o)}):l(h)},[h]);const a=T||(D==="categorical"?We.getUniqValue(E,"x"):Ve.getJenks(E.map(t=>t.x),j?.length||4));d.useEffect(()=>{const t=setInterval(()=>{X(o=>o<u.length-1?o+1:0)},(f.speed||2)*1e3);return W||clearInterval(t),()=>clearInterval(t)},[u,W,f.speed]);const i=Ee.getSliderMarks(u,R,f.showOnlyActiveDate,f.dateFormat||"yyyy");return e.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${n?"w-fit grow-0":"w-full grow"}`,dir:Z==="he"||Z==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${O?O===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${Z||"en"}`,n?"w-fit":"w-full",w?.graphContainer),style:{...S?.graphContainer||{},...O&&O!==!0?{backgroundColor:O}:{}},id:z,ref:s,"aria-label":Q||`${c?`The graph shows ${c}. `:""}This is a choropleth map where geographic areas are colored in proportion to a specific variable.${q?` ${q}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:O?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[c||q||k||C?e.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:S?.title,description:S?.description},classNames:{title:w?.title,description:w?.description},graphTitle:c,graphDescription:q,width:n,graphDownload:k?s.current:void 0,dataDownload:C?E.map(t=>t.data).filter(t=>t!==void 0).length>0?E.map(t=>t.data).filter(t=>t!==void 0):E.filter(t=>t!==void 0):null}):null,f.enabled&&u.length>0&&i?e.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[e.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{fe(!W)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":W?"Click to pause animation":"Click to play animation",children:W?e.jsxRuntimeExports.jsx(ve.Pause,{}):e.jsxRuntimeExports.jsx(ve.Play,{})}),e.jsxRuntimeExports.jsx(Ee.xr,{min:u[0],max:u[u.length-1],marks:i,step:null,defaultValue:u[u.length-1],value:u[R],onChangeComplete:t=>{X(u.indexOf(t))},onChange:t=>{X(u.indexOf(t))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:p,"aria-label":"Map area",children:(n||g)&&(x||oe)&&r?e.jsxRuntimeExports.jsx(Ae,{data:E.filter(t=>f.enabled?t.date===be.format(new Date(u[R]),f.dateFormat||"yyyy"):t),mapData:K?r:{...r,features:r.features.filter(t=>t.properties.NAME!=="Antarctica")},colorDomain:a,width:n||g,height:Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe)),scale:F,centerPoint:Y,colors:j||(D==="categorical"?de.Colors[N].sequentialColors[`neutralColorsx0${a.length}`]:de.Colors[N].sequentialColors[`neutralColorsx0${a.length+1}`]),colorLegendTitle:se,mapBorderWidth:me,mapNoDataColor:xe,categorical:D==="categorical",mapBorderColor:H,tooltip:A,onSeriesMouseOver:he,isWorldMap:$,showColorScale:ge,zoomScaleExtend:ye,zoomTranslateExtend:U,onSeriesMouseClick:G,mapProperty:ie,highlightedIds:b,resetSelectionOnDoubleClick:_,styles:S,classNames:w,detailsOnClick:ee,mapProjection:ne||($?"naturalEarth":"mercator"),zoomInteraction:te,dimmedOpacity:re,animate:P===!0?{duration:.5,once:!0,amount:.5}:P||{duration:0,once:!0,amount:0},customLayers:le}):e.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe))}px`},className:"flex items-center justify-center",children:e.jsxRuntimeExports.jsx(we.y,{"aria-label":"Loading graph"})})}),B||ae?e.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:S?.footnote,source:S?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:B,footNote:ae,width:n}):null]})})})})}exports.ChoroplethMap=Ue;
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 { useEffect, useRef, useState } from 'react';\r\nimport {\r\n geoAlbersUsa,\r\n geoEqualEarth,\r\n geoMercator,\r\n geoNaturalEarth1,\r\n geoOrthographic,\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 { Modal } from '@undp/design-system-react/Modal';\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\n\r\nimport {\r\n AnimateDataType,\r\n ChoroplethMapDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n MapProjectionTypes,\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 { string2HTML } from '@/Utils/string2HTML';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { X } from '@/Components/Icons';\r\n\r\ninterface Props {\r\n colorDomain: (number | string)[];\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n mapData: any;\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}\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 } = props;\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(!(width < 680));\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const bounds = bbox(mapData as any);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const center = centerOfMass(mapData as any);\r\n const lonDiff = bounds[2] - bounds[0];\r\n const latDiff = bounds[3] - bounds[1];\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([0, 0])\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([0, 0])\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([0, 0])\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([0, 0])\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([0, 0])\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar);\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 {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n mapData.features.map((d: any, i: number) => {\r\n const index = data.findIndex(el => el.id === d.properties[mapProperty]);\r\n if (index !== -1) return null;\r\n return (\r\n <g\r\n key={i}\r\n opacity={\r\n selectedColor\r\n ? dimmedOpacity\r\n : highlightedIds.length !== 0\r\n ? highlightedIds.indexOf(d.properties[mapProperty]) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1\r\n }\r\n >\r\n {d.geometry.type === 'MultiPolygon'\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.geometry.coordinates.map((el: any, j: any) => {\r\n let masterPath = '';\r\n el.forEach((geo: number[][]) => {\r\n let path = ' M';\r\n geo.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== geo.length - 1) path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n masterPath += path;\r\n });\r\n return (\r\n <path\r\n key={j}\r\n d={masterPath}\r\n style={{\r\n stroke: mapBorderColor,\r\n strokeWidth: mapBorderWidth,\r\n fill: mapNoDataColor,\r\n }}\r\n />\r\n );\r\n })\r\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.geometry.coordinates.map((el: any, j: number) => {\r\n let path = 'M';\r\n el.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== el.length - 1) path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n return (\r\n <path\r\n key={j}\r\n d={path}\r\n style={{\r\n stroke: mapBorderColor,\r\n strokeWidth: mapBorderWidth,\r\n fill: mapNoDataColor,\r\n }}\r\n />\r\n );\r\n })}\r\n </g>\r\n );\r\n })\r\n }\r\n <AnimatePresence>\r\n {data.map(d => {\r\n const index = mapData.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 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 key={d.id}\r\n variants={{\r\n initial: { opacity: 0 },\r\n whileInView: {\r\n opacity: selectedColor\r\n ? selectedColor === color\r\n ? 1\r\n : dimmedOpacity\r\n : highlightedIds.length !== 0\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 {index === -1\r\n ? null\r\n : mapData.features[index].geometry.type === 'MultiPolygon'\r\n ? mapData.features[index].geometry.coordinates.map(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (el: any, j: any) => {\r\n let masterPath = '';\r\n el.forEach((geo: number[][]) => {\r\n let path = ' M';\r\n geo.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== geo.length - 1)\r\n path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n masterPath += path;\r\n });\r\n return (\r\n <motion.path\r\n key={`${d.id}-${j}`}\r\n d={masterPath}\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 }}\r\n />\r\n );\r\n },\r\n )\r\n : mapData.features[index].geometry.coordinates.map(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (el: any, j: number) => {\r\n let path = 'M';\r\n el.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== el.length - 1) path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n return (\r\n <motion.path\r\n key={`${d.id}-${j}`}\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 }}\r\n />\r\n );\r\n },\r\n )}\r\n </motion.g>\r\n );\r\n })}\r\n </AnimatePresence>\r\n {mouseOverData\r\n ? mapData.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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .map((d: any, i: number) => {\r\n return (\r\n <g key={i}>\r\n {d.geometry.type === 'MultiPolygon'\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.geometry.coordinates.map((el: any, j: any) => {\r\n let masterPath = '';\r\n el.forEach((geo: number[][]) => {\r\n let path = ' M';\r\n geo.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== geo.length - 1)\r\n path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n masterPath += path;\r\n });\r\n return (\r\n <path\r\n key={j}\r\n d={masterPath}\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 }}\r\n />\r\n );\r\n })\r\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.geometry.coordinates.map((el: any, j: number) => {\r\n let path = 'M';\r\n el.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== el.length - 1) path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n return (\r\n <path\r\n key={j}\r\n d={path}\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 }}\r\n />\r\n );\r\n })}\r\n </g>\r\n );\r\n })\r\n : null}\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='absolute left-4 bottom-4'>\r\n {showLegend ? (\r\n <>\r\n <div\r\n style={{\r\n backgroundColor: 'rgba(240,240,240, 0.7)',\r\n border: '1px solid var(--gray-400)',\r\n borderRadius: '999px',\r\n width: '24px',\r\n height: '24px',\r\n padding: '3px',\r\n cursor: 'pointer',\r\n zIndex: 10,\r\n position: 'absolute',\r\n right: '-0.75rem',\r\n top: '-0.75rem',\r\n }}\r\n onClick={() => {\r\n setShowLegend(false);\r\n }}\r\n >\r\n <X />\r\n </div>\r\n <div\r\n className='p-2'\r\n style={{\r\n backgroundColor: 'rgba(240,240,240, 0.7)',\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(d as number, 'NA')}\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='mb-0 border-0 bg-transparent p-0 self-start'\r\n onClick={() => {\r\n setShowLegend(true);\r\n }}\r\n >\r\n <div className='items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500'>\r\n Show Legend\r\n </div>\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'>\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-400 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-400 dark:bg-primary-gray-600 dark:text-primary-gray-100'\r\n >\r\n –\r\n </button>\r\n </div>\r\n )}\r\n </div>\r\n {detailsOnClick && mouseClickData !== undefined ? (\r\n <Modal\r\n open={mouseClickData !== undefined}\r\n onClose={() => {\r\n setMouseClickData(undefined);\r\n }}\r\n >\r\n <div\r\n className='graph-modal-content m-0'\r\n dangerouslySetInnerHTML={\r\n typeof detailsOnClick === 'string'\r\n ? { __html: string2HTML(detailsOnClick, mouseClickData) }\r\n : undefined\r\n }\r\n >\r\n {typeof detailsOnClick === 'function' ? detailsOnClick(mouseClickData) : null}\r\n </div>\r\n </Modal>\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 } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\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 { ascending, sort } from 'd3-array';\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} 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 { uniqBy } from '@/Utils/uniqBy';\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n mapData?: any;\r\n /** Scaling factor for the map. Multiplies the scale number to scale. */\r\n scale?: number;\r\n /** Center point of the map */\r\n centerPoint?: [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 /** Toggles if the color scaling is categorical or not */\r\n categorical?: boolean;\r\n /** Toggle visibility of color scale. */\r\n showColorScale?: 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 /** 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.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,\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 } = 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 = sort(\r\n uniqBy(data, 'date', true).map(d =>\r\n parse(`${d}`, timeline.dateFormat || 'yyyy', new Date()).getTime(),\r\n ),\r\n (a, b) => ascending(a, b),\r\n );\r\n const [index, setIndex] = useState(timeline.autoplay ? 0 : uniqDatesSorted.length - 1);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mapShape, setMapShape] = useState<any>(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(width || entries[0].target.clientWidth || 760);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 760);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n useEffect(() => {\r\n if (typeof mapData === 'string') {\r\n const fetchData = fetchAndParseJSON(mapData);\r\n fetchData.then(d => {\r\n setMapShape(d);\r\n });\r\n } else {\r\n setMapShape(mapData);\r\n }\r\n }, [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 <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n width ? 'w-fit' : 'w-full',\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a choropleth map where geographic areas are colored in proportion to a specific variable.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n {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 <div\r\n className='flex flex-col grow justify-center leading-0'\r\n ref={graphDiv}\r\n aria-label='Map area'\r\n >\r\n {(width || svgWidth) && (height || 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(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (el: any) => el.properties.NAME !== 'Antarctica',\r\n ),\r\n }\r\n }\r\n colorDomain={domain}\r\n width={width || svgWidth}\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 )}\r\n scale={scale}\r\n centerPoint={centerPoint}\r\n colors={\r\n colors ||\r\n (scaleType === 'categorical'\r\n ? Colors[theme].sequentialColors[\r\n `neutralColorsx0${domain.length as 4 | 5 | 6 | 7 | 8 | 9}`\r\n ]\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 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 />\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 </div>\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 </div>\r\n </div>\r\n </div>\r\n </div>\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","selectedColor","setSelectedColor","useState","zoomRef","useRef","showLegend","setShowLegend","mouseClickData","setMouseClickData","mouseOverData","setMouseOverData","eventX","setEventX","eventY","setEventY","mapSvg","isInView","useInView","mapG","colorScale","scaleOrdinal","scaleThreshold","useEffect","mapGSelect","select","mapSvgSelect","zoomFilter","e","isWheel","isTouch","isDrag","zoomBehavior","zoom","transform","bounds","bbox","center","centerOfMass","lonDiff","latDiff","scaleX","scaleY","scaleVar","projection","geoMercator","geoEqualEarth","geoNaturalEarth1","geoOrthographic","geoAlbersUsa","handleZoom","direction","jsxs","Fragment","jsx","motion","d","i","el","j","masterPath","geo","path","c","k","point","AnimatePresence","index","color","checkIfNullOrUndefined","event","isEqual","X","P","numberFormattingFunction","Modal","string2HTML","Tooltip","ChoroplethMap","graphTitle","sources","graphDescription","footNote","scaleType","padding","Colors","backgroundColor","relativeHeight","isWorldMap","graphID","graphDownload","dataDownload","showAntarctica","language","minHeight","theme","ariaLabel","timeline","svgWidth","setSvgWidth","svgHeight","setSvgHeight","play","setPlay","uniqDatesSorted","sort","uniqBy","parse","a","b","ascending","setIndex","mapShape","setMapShape","graphDiv","graphParentDiv","resizeObserver","entries","fetchAndParseJSON","domain","getUniqValue","getJenks","interval","markObj","getSliderMarks","cn","GraphHeader","Pause","Play","SliderUI","nextValue","format","Spinner","GraphFooter"],"mappings":"srCAwEO,SAASA,GAAMC,GAAc,CAClC,KAAM,CACJ,KAAAC,EACA,YAAAC,EACA,OAAAC,EACA,QAAAC,EACA,iBAAAC,EACA,YAAAC,EACA,OAAAC,EACA,MAAAC,EACA,MAAAC,GACA,YAAAC,EACA,QAAAC,GACA,eA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,CAAA,CACF,CAAA,CACF,CAAA,CAGN"}
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 { useEffect, useRef, useState } from 'react';\r\nimport {\r\n geoAlbersUsa,\r\n geoEqualEarth,\r\n geoMercator,\r\n geoNaturalEarth1,\r\n geoOrthographic,\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 { Modal } from '@undp/design-system-react/Modal';\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\n\r\nimport {\r\n AnimateDataType,\r\n ChoroplethMapDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n MapProjectionTypes,\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 { string2HTML } from '@/Utils/string2HTML';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { X } from '@/Components/Icons';\r\n\r\ninterface Props {\r\n colorDomain: (number | string)[];\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n mapData: any;\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}\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 } = props;\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(!(width < 680));\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const bounds = bbox(mapData as any);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const center = centerOfMass(mapData as any);\r\n const lonDiff = bounds[2] - bounds[0];\r\n const latDiff = bounds[3] - bounds[1];\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([0, 0])\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([0, 0])\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([0, 0])\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([0, 0])\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([0, 0])\r\n .center(centerPoint || (center.geometry.coordinates as [number, number]))\r\n .translate([width / 2, height / 2])\r\n .scale(scaleVar);\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 {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n mapData.features.map((d: any, i: number) => {\r\n const index = data.findIndex(el => el.id === d.properties[mapProperty]);\r\n if (index !== -1) return null;\r\n return (\r\n <g\r\n key={i}\r\n opacity={\r\n selectedColor\r\n ? dimmedOpacity\r\n : highlightedIds.length !== 0\r\n ? highlightedIds.indexOf(d.properties[mapProperty]) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1\r\n }\r\n >\r\n {d.geometry.type === 'MultiPolygon'\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.geometry.coordinates.map((el: any, j: any) => {\r\n let masterPath = '';\r\n el.forEach((geo: number[][]) => {\r\n let path = ' M';\r\n geo.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== geo.length - 1) path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n masterPath += path;\r\n });\r\n return (\r\n <path\r\n key={j}\r\n d={masterPath}\r\n style={{\r\n stroke: mapBorderColor,\r\n strokeWidth: mapBorderWidth,\r\n fill: mapNoDataColor,\r\n }}\r\n />\r\n );\r\n })\r\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.geometry.coordinates.map((el: any, j: number) => {\r\n let path = 'M';\r\n el.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== el.length - 1) path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n return (\r\n <path\r\n key={j}\r\n d={path}\r\n style={{\r\n stroke: mapBorderColor,\r\n strokeWidth: mapBorderWidth,\r\n fill: mapNoDataColor,\r\n }}\r\n />\r\n );\r\n })}\r\n </g>\r\n );\r\n })\r\n }\r\n <AnimatePresence>\r\n {data.map(d => {\r\n const index = mapData.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 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 key={d.id}\r\n variants={{\r\n initial: { opacity: 0 },\r\n whileInView: {\r\n opacity: selectedColor\r\n ? selectedColor === color\r\n ? 1\r\n : dimmedOpacity\r\n : highlightedIds.length !== 0\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 {index === -1\r\n ? null\r\n : mapData.features[index].geometry.type === 'MultiPolygon'\r\n ? mapData.features[index].geometry.coordinates.map(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (el: any, j: any) => {\r\n let masterPath = '';\r\n el.forEach((geo: number[][]) => {\r\n let path = ' M';\r\n geo.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== geo.length - 1)\r\n path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n masterPath += path;\r\n });\r\n return (\r\n <motion.path\r\n key={`${d.id}-${j}`}\r\n d={masterPath}\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 }}\r\n />\r\n );\r\n },\r\n )\r\n : mapData.features[index].geometry.coordinates.map(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (el: any, j: number) => {\r\n let path = 'M';\r\n el.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== el.length - 1) path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n return (\r\n <motion.path\r\n key={`${d.id}-${j}`}\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 }}\r\n />\r\n );\r\n },\r\n )}\r\n </motion.g>\r\n );\r\n })}\r\n </AnimatePresence>\r\n {mouseOverData\r\n ? mapData.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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .map((d: any, i: number) => {\r\n return (\r\n <g key={i}>\r\n {d.geometry.type === 'MultiPolygon'\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.geometry.coordinates.map((el: any, j: any) => {\r\n let masterPath = '';\r\n el.forEach((geo: number[][]) => {\r\n let path = ' M';\r\n geo.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== geo.length - 1)\r\n path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n masterPath += path;\r\n });\r\n return (\r\n <path\r\n key={j}\r\n d={masterPath}\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 }}\r\n />\r\n );\r\n })\r\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.geometry.coordinates.map((el: any, j: number) => {\r\n let path = 'M';\r\n el.forEach((c: number[], k: number) => {\r\n const point = projection([c[0], c[1]]) as [number, number];\r\n if (k !== el.length - 1) path = `${path}${point[0]} ${point[1]}L`;\r\n else path = `${path}${point[0]} ${point[1]}`;\r\n });\r\n return (\r\n <path\r\n key={j}\r\n d={path}\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 }}\r\n />\r\n );\r\n })}\r\n </g>\r\n );\r\n })\r\n : null}\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='absolute left-4 bottom-4'>\r\n {showLegend ? (\r\n <>\r\n <div\r\n style={{\r\n backgroundColor: 'rgba(240,240,240, 0.7)',\r\n border: '1px solid var(--gray-400)',\r\n borderRadius: '999px',\r\n width: '24px',\r\n height: '24px',\r\n padding: '3px',\r\n cursor: 'pointer',\r\n zIndex: 10,\r\n position: 'absolute',\r\n right: '-0.75rem',\r\n top: '-0.75rem',\r\n }}\r\n onClick={() => {\r\n setShowLegend(false);\r\n }}\r\n >\r\n <X />\r\n </div>\r\n <div\r\n className='p-2'\r\n style={{\r\n backgroundColor: 'rgba(240,240,240, 0.7)',\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(d as number, 'NA')}\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='mb-0 border-0 bg-transparent p-0 self-start'\r\n onClick={() => {\r\n setShowLegend(true);\r\n }}\r\n >\r\n <div className='items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500'>\r\n Show Legend\r\n </div>\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'>\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-400 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-400 dark:bg-primary-gray-600 dark:text-primary-gray-100'\r\n >\r\n –\r\n </button>\r\n </div>\r\n )}\r\n </div>\r\n {detailsOnClick && mouseClickData !== undefined ? (\r\n <Modal\r\n open={mouseClickData !== undefined}\r\n onClose={() => {\r\n setMouseClickData(undefined);\r\n }}\r\n >\r\n <div\r\n className='graph-modal-content m-0'\r\n dangerouslySetInnerHTML={\r\n typeof detailsOnClick === 'string'\r\n ? { __html: string2HTML(detailsOnClick, mouseClickData) }\r\n : undefined\r\n }\r\n >\r\n {typeof detailsOnClick === 'function' ? detailsOnClick(mouseClickData) : null}\r\n </div>\r\n </Modal>\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 } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\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 { ascending, sort } from 'd3-array';\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} 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 { uniqBy } from '@/Utils/uniqBy';\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n mapData?: any;\r\n /** Scaling factor for the map. Multiplies the scale number to scale. */\r\n scale?: number;\r\n /** Center point of the map */\r\n centerPoint?: [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 /** 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 /** 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.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,\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 } = 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 = sort(\r\n uniqBy(data, 'date', true).map(d =>\r\n parse(`${d}`, timeline.dateFormat || 'yyyy', new Date()).getTime(),\r\n ),\r\n (a, b) => ascending(a, b),\r\n );\r\n const [index, setIndex] = useState(timeline.autoplay ? 0 : uniqDatesSorted.length - 1);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mapShape, setMapShape] = useState<any>(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(width || entries[0].target.clientWidth || 760);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 760);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n useEffect(() => {\r\n if (typeof mapData === 'string') {\r\n const fetchData = fetchAndParseJSON(mapData);\r\n fetchData.then(d => {\r\n setMapShape(d);\r\n });\r\n } else {\r\n setMapShape(mapData);\r\n }\r\n }, [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 <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n width ? 'w-fit' : 'w-full',\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a choropleth map where geographic areas are colored in proportion to a specific variable.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n {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 <div\r\n className='flex flex-col grow justify-center leading-0'\r\n ref={graphDiv}\r\n aria-label='Map area'\r\n >\r\n {(width || svgWidth) && (height || 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(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (el: any) => el.properties.NAME !== 'Antarctica',\r\n ),\r\n }\r\n }\r\n colorDomain={domain}\r\n width={width || svgWidth}\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 )}\r\n scale={scale}\r\n centerPoint={centerPoint}\r\n colors={\r\n colors ||\r\n (scaleType === 'categorical'\r\n ? Colors[theme].sequentialColors[\r\n `neutralColorsx0${domain.length as 4 | 5 | 6 | 7 | 8 | 9}`\r\n ]\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 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 />\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 </div>\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 </div>\r\n </div>\r\n </div>\r\n </div>\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","selectedColor","setSelectedColor","useState","zoomRef","useRef","showLegend","setShowLegend","mouseClickData","setMouseClickData","mouseOverData","setMouseOverData","eventX","setEventX","eventY","setEventY","mapSvg","isInView","useInView","mapG","colorScale","scaleOrdinal","scaleThreshold","useEffect","mapGSelect","select","mapSvgSelect","zoomFilter","e","isWheel","isTouch","isDrag","zoomBehavior","zoom","transform","bounds","bbox","center","centerOfMass","lonDiff","latDiff","scaleX","scaleY","scaleVar","projection","geoMercator","geoEqualEarth","geoNaturalEarth1","geoOrthographic","geoAlbersUsa","handleZoom","direction","jsxs","Fragment","jsx","motion","d","i","el","j","masterPath","geo","path","c","k","point","AnimatePresence","index","color","checkIfNullOrUndefined","event","isEqual","X","P","numberFormattingFunction","Modal","string2HTML","Tooltip","ChoroplethMap","graphTitle","sources","graphDescription","footNote","scaleType","padding","Colors","backgroundColor","relativeHeight","isWorldMap","graphID","graphDownload","dataDownload","showAntarctica","language","minHeight","theme","ariaLabel","timeline","svgWidth","setSvgWidth","svgHeight","setSvgHeight","play","setPlay","uniqDatesSorted","sort","uniqBy","parse","a","b","ascending","setIndex","mapShape","setMapShape","graphDiv","graphParentDiv","resizeObserver","entries","fetchAndParseJSON","domain","getUniqValue","getJenks","interval","markObj","getSliderMarks","cn","GraphHeader","Pause","Play","SliderUI","nextValue","format","Spinner","GraphFooter"],"mappings":"srCAwEO,SAASA,GAAMC,GAAc,CAClC,KAAM,CACJ,KAAAC,EACA,YAAAC,EACA,OAAAC,EACA,QAAAC,EACA,iBAAAC,EACA,YAAAC,EACA,OAAAC,EACA,MAAAC,EACA,MAAAC,GACA,YAAAC,EACA,QAAAC,GACA,eAAAC,EACA,eAAAC,EACA,eAAAC,EACA,kBAAAC,EACA,eAAAC,GACA,gBAAAC,GACA,oBAAAC,EACA,eAAAC,EACA,mBAAAC,EACA,YAAAC,EACA,4BAAAC,GACA,eAAAC,EACA,OAAAC,GACA,WAAAC,GACA,cAAAC,EACA,gB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O,OAAS,CAA2B,EAChE,GAEN,iBAAAhJ,GACA,eAAAO,GACA,eAAAE,GACA,YAAamG,IAAc,cAC3B,eAAApG,EACA,QAAAF,EACA,kBAAAI,GACA,WAAAuG,EACA,eAAAtG,GACA,gBAAAC,GACA,oBAAAC,EACA,mBAAAE,EACA,YAAAC,GACA,eAAAF,EACA,4BAAAG,EACA,OAAAE,EACA,WAAAC,EACA,eAAAF,GACA,cAAeG,KAAkB4F,EAAa,eAAiB,YAC/D,gBAAA3F,GACA,cAAAE,GACA,QACED,IAAY,GACR,CAAE,SAAU,GAAK,KAAM,GAAM,OAAQ,EAAA,EACrCA,GAAW,CAAE,SAAU,EAAG,KAAM,GAAM,OAAQ,CAAA,EAEpD,aAAAE,EAAA,CAAA,EAGFsD,EAAAA,kBAAAA,IAAC,MAAA,CACC,MAAO,CACL,OAAQ,GAAG,KAAK,IACdwC,EACArH,IACG8G,EACGO,GACGpH,GAASwH,GAAYX,EAAiBO,GACpCpH,GAASwH,GAAYX,EACtBO,GACDpH,GAASwH,GAAYX,EACxBa,GAAA,CACP,IAAA,EAEH,UAAU,mCAEV,SAAA9C,EAAAA,kBAAAA,IAAC8E,GAAAA,EAAA,CAAQ,aAAW,eAAA,CAAgB,CAAA,CAAA,CACtC,CAAA,EAGHpD,GAAWE,GACV5B,EAAAA,kBAAAA,IAAC+E,GAAAA,YAAA,CACC,OAAQ,CAAE,SAAU3I,GAAQ,SAAU,OAAQA,GAAQ,MAAA,EACtD,WAAY,CACV,SAAUC,GAAY,SACtB,OAAQA,GAAY,MAAA,EAEtB,QAAAqF,EACA,SAAAE,GACA,MAAAxG,CAAA,CAAA,EAEA,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CAGN"}
@@ -120,8 +120,6 @@ declare interface Props {
120
120
  animate?: boolean | AnimateDataType;
121
121
  /** Scale for the colors */
122
122
  scaleType?: Exclude<ScaleDataType, 'linear'>;
123
- /** Toggles if the color scaling is categorical or not */
124
- categorical?: boolean;
125
123
  /** Toggle visibility of color scale. */
126
124
  showColorScale?: boolean;
127
125
  /** Property in the property object in mapData geoJson object is used to match to the id in the data object */
@@ -4,10 +4,10 @@ import { g as we, x as $e } from "./getSliderMarks-9cNoRkDx.js";
4
4
  import { y as Ne } from "./Spinner-C85UF28E.js";
5
5
  import { p as Ce, f as Me } from "./parse-DlCRUFh_.js";
6
6
  import { i as De } from "./index-Bwrro8-q.js";
7
- import { z as Se, t as Oe, g as Ee, a as Pe, b as Ie, c as Le, d as ze } from "./zoom-DAu91HKr.js";
7
+ import { z as Se, t as Oe, g as Ee, a as Pe, b as Ie, c as Le, d as ze } from "./zoom-QipiAl5W.js";
8
8
  import { X as We } from "./Modal-DVVwpKhP.js";
9
9
  import { u as ke } from "./Typography-Ctgfl1J5.js";
10
- import { t as Te } from "./index-qfWCwobm.js";
10
+ import { t as Te } from "./index-9tDEUqOZ.js";
11
11
  import { n as Be } from "./numberFormattingFunction-14YCbkN2.js";
12
12
  import { T as Ae } from "./Tooltip-CVCGWyzw.js";
13
13
  import { s as Ve } from "./string2HTML-oFCROsus.js";