@undp/data-viz 1.5.6 → 1.5.8

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 (88) hide show
  1. package/dist/BarGraph.cjs +1 -1
  2. package/dist/BarGraph.cjs.map +1 -1
  3. package/dist/BarGraph.js +650 -648
  4. package/dist/BarGraph.js.map +1 -1
  5. package/dist/BulletChart.cjs +1 -1
  6. package/dist/BulletChart.cjs.map +1 -1
  7. package/dist/BulletChart.js +210 -208
  8. package/dist/BulletChart.js.map +1 -1
  9. package/dist/ButterflyChart.cjs +1 -1
  10. package/dist/ButterflyChart.cjs.map +1 -1
  11. package/dist/ButterflyChart.js +42 -40
  12. package/dist/ButterflyChart.js.map +1 -1
  13. package/dist/DifferenceLineChart.cjs +1 -1
  14. package/dist/DifferenceLineChart.cjs.map +1 -1
  15. package/dist/DifferenceLineChart.js +122 -120
  16. package/dist/DifferenceLineChart.js.map +1 -1
  17. package/dist/DualAxisLineChart.cjs +1 -1
  18. package/dist/DualAxisLineChart.cjs.map +1 -1
  19. package/dist/DualAxisLineChart.js +133 -113
  20. package/dist/DualAxisLineChart.js.map +1 -1
  21. package/dist/DumbbellChart.cjs +1 -1
  22. package/dist/DumbbellChart.cjs.map +1 -1
  23. package/dist/DumbbellChart.js +274 -274
  24. package/dist/DumbbellChart.js.map +1 -1
  25. package/dist/LineChartWithConfidenceInterval.cjs +1 -1
  26. package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
  27. package/dist/LineChartWithConfidenceInterval.js +194 -174
  28. package/dist/LineChartWithConfidenceInterval.js.map +1 -1
  29. package/dist/MultiLineAltChart.cjs +1 -1
  30. package/dist/MultiLineAltChart.cjs.map +1 -1
  31. package/dist/MultiLineAltChart.js +160 -161
  32. package/dist/MultiLineAltChart.js.map +1 -1
  33. package/dist/MultiLineChart.cjs +1 -1
  34. package/dist/MultiLineChart.cjs.map +1 -1
  35. package/dist/MultiLineChart.js +77 -66
  36. package/dist/MultiLineChart.js.map +1 -1
  37. package/dist/ParetoChart.cjs +1 -1
  38. package/dist/ParetoChart.cjs.map +1 -1
  39. package/dist/ParetoChart.js +166 -161
  40. package/dist/ParetoChart.js.map +1 -1
  41. package/dist/RadarChart.cjs +1 -1
  42. package/dist/RadarChart.cjs.map +1 -1
  43. package/dist/RadarChart.js +253 -241
  44. package/dist/RadarChart.js.map +1 -1
  45. package/dist/{RegressionLine-mH7UKOPi.js → RegressionLine-C2--oMQq.js} +10 -9
  46. package/dist/RegressionLine-C2--oMQq.js.map +1 -0
  47. package/dist/RegressionLine-Dj0GSiAp.cjs +2 -0
  48. package/dist/RegressionLine-Dj0GSiAp.cjs.map +1 -0
  49. package/dist/ScatterPlot.cjs +1 -1
  50. package/dist/ScatterPlot.cjs.map +1 -1
  51. package/dist/ScatterPlot.js +130 -129
  52. package/dist/ScatterPlot.js.map +1 -1
  53. package/dist/SimpleLineChart.cjs +1 -1
  54. package/dist/SimpleLineChart.cjs.map +1 -1
  55. package/dist/SimpleLineChart.js +43 -38
  56. package/dist/SimpleLineChart.js.map +1 -1
  57. package/dist/SlopeChart.cjs +1 -1
  58. package/dist/SlopeChart.cjs.map +1 -1
  59. package/dist/SlopeChart.js +113 -109
  60. package/dist/SlopeChart.js.map +1 -1
  61. package/dist/StripChart.cjs +1 -1
  62. package/dist/StripChart.cjs.map +1 -1
  63. package/dist/StripChart.js +282 -270
  64. package/dist/StripChart.js.map +1 -1
  65. package/dist/ThreeDGlobe.cjs +1 -1
  66. package/dist/ThreeDGlobe.cjs.map +1 -1
  67. package/dist/ThreeDGlobe.js +284 -349
  68. package/dist/ThreeDGlobe.js.map +1 -1
  69. package/dist/UnitChart.cjs +1 -1
  70. package/dist/UnitChart.cjs.map +1 -1
  71. package/dist/UnitChart.js +20 -21
  72. package/dist/UnitChart.js.map +1 -1
  73. package/dist/getCentroidCoordinates-Dfk6IqEG.js +70 -0
  74. package/dist/getCentroidCoordinates-Dfk6IqEG.js.map +1 -0
  75. package/dist/getCentroidCoordinates-DxTBqzp2.cjs +2 -0
  76. package/dist/getCentroidCoordinates-DxTBqzp2.cjs.map +1 -0
  77. package/dist/index.cjs +1 -1
  78. package/dist/index.d.ts +7 -0
  79. package/dist/index.js +34 -32
  80. package/dist/index.js.map +1 -1
  81. package/dist/utils.cjs +1 -1
  82. package/dist/utils.d.ts +8 -0
  83. package/dist/utils.js +16 -14
  84. package/dist/utils.js.map +1 -1
  85. package/package.json +1 -1
  86. package/dist/RegressionLine-mH7UKOPi.js.map +0 -1
  87. package/dist/RegressionLine-xKdiJ8sw.cjs +0 -2
  88. package/dist/RegressionLine-xKdiJ8sw.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ThreeDGlobe.js","sources":["../node_modules/@turf/area/dist/esm/index.js","../src/Components/Graphs/Maps/ThreeDGlobe/Graph.tsx","../src/Components/Graphs/Maps/ThreeDGlobe/index.tsx"],"sourcesContent":["// index.ts\nimport { earthRadius } from \"@turf/helpers\";\nimport { geomReduce } from \"@turf/meta\";\nfunction area(geojson) {\n return geomReduce(\n geojson,\n (value, geom) => {\n return value + calculateArea(geom);\n },\n 0\n );\n}\nfunction calculateArea(geom) {\n let total = 0;\n let i;\n switch (geom.type) {\n case \"Polygon\":\n return polygonArea(geom.coordinates);\n case \"MultiPolygon\":\n for (i = 0; i < geom.coordinates.length; i++) {\n total += polygonArea(geom.coordinates[i]);\n }\n return total;\n case \"Point\":\n case \"MultiPoint\":\n case \"LineString\":\n case \"MultiLineString\":\n return 0;\n }\n return 0;\n}\nfunction polygonArea(coords) {\n let total = 0;\n if (coords && coords.length > 0) {\n total += Math.abs(ringArea(coords[0]));\n for (let i = 1; i < coords.length; i++) {\n total -= Math.abs(ringArea(coords[i]));\n }\n }\n return total;\n}\nvar FACTOR = earthRadius * earthRadius / 2;\nvar PI_OVER_180 = Math.PI / 180;\nfunction ringArea(coords) {\n const coordsLength = coords.length - 1;\n if (coordsLength <= 2) return 0;\n let total = 0;\n let i = 0;\n while (i < coordsLength) {\n const lower = coords[i];\n const middle = coords[i + 1 === coordsLength ? 0 : i + 1];\n const upper = coords[i + 2 >= coordsLength ? (i + 2) % coordsLength : i + 2];\n const lowerX = lower[0] * PI_OVER_180;\n const middleY = middle[1] * PI_OVER_180;\n const upperX = upper[0] * PI_OVER_180;\n total += (upperX - lowerX) * Math.sin(middleY);\n i++;\n }\n return total * FACTOR;\n}\nvar turf_area_default = area;\nexport {\n area,\n turf_area_default as default\n};\n//# sourceMappingURL=index.js.map","/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport Globe, { GlobeMethods } from 'react-globe.gl';\r\nimport isEqual from 'fast-deep-equal';\r\nimport { useCallback, useEffect, useRef, useState } from 'react';\r\nimport { scaleOrdinal, scaleThreshold } from 'd3-scale';\r\nimport * as THREE from 'three';\r\nimport { Modal } from '@undp/design-system-react/Modal';\r\nimport { P } from '@undp/design-system-react/Typography';\r\nimport centerOfMass from '@turf/center-of-mass';\r\nimport area from '@turf/area';\r\nimport { Feature, GeoJsonProperties, MultiPolygon, Polygon } from 'geojson';\r\n\r\nimport {\r\n ChoroplethMapDataType,\r\n ClassNameObject,\r\n FogDataType,\r\n LightConfig,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { X } from '@/Components/Icons';\r\nimport { string2HTML } from '@/Utils/string2HTML';\r\n\r\ninterface Props {\r\n width: number;\r\n data: ChoroplethMapDataType[];\r\n autoRotate: number;\r\n enableZoom: boolean;\r\n categorical: boolean;\r\n colorDomain: (number | string)[];\r\n colors: string[];\r\n height: number;\r\n globeMaterial?: THREE.Material;\r\n lights: LightConfig[];\r\n polygonData: any;\r\n mapProperty: string;\r\n mapBorderColor: string;\r\n atmosphereColor: string;\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n onSeriesMouseOver?: (_d: any) => void;\r\n onSeriesMouseClick?: (_d: any) => void;\r\n mapNoDataColor: string;\r\n colorLegendTitle?: string;\r\n showColorScale: boolean;\r\n hoverStrokeColor: string;\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n resetSelectionOnDoubleClick: boolean;\r\n highlightedIds: string[];\r\n scale: number;\r\n globeOffset: [number, number];\r\n polygonAltitude: number;\r\n centerLng: number;\r\n centerLat: number;\r\n atmosphereAltitude: number;\r\n globeCurvatureResolution: number;\r\n fogSettings?: FogDataType;\r\n highlightedAltitude: number;\r\n selectedId?: string;\r\n}\r\n\r\nfunction getMainlandCentroid(\r\n multiPolygonFeature: Feature<Polygon | MultiPolygon, GeoJsonProperties>,\r\n) {\r\n // If it's already a Polygon, just return its centroid\r\n if (multiPolygonFeature.geometry.type === 'Polygon') {\r\n return centerOfMass(multiPolygonFeature);\r\n }\r\n\r\n // If it's MultiPolygon → find the largest polygon\r\n if (multiPolygonFeature.geometry.type === 'MultiPolygon') {\r\n let maxArea = 0;\r\n let largestPolygon: Feature<Polygon, GeoJsonProperties> | null = null;\r\n\r\n for (const coords of multiPolygonFeature.geometry.coordinates) {\r\n const poly: Feature<Polygon, GeoJsonProperties> = {\r\n type: 'Feature',\r\n geometry: {\r\n type: 'Polygon',\r\n coordinates: coords,\r\n },\r\n properties: {},\r\n };\r\n\r\n const polyArea = area(poly);\r\n if (polyArea > maxArea) {\r\n maxArea = polyArea;\r\n largestPolygon = poly;\r\n }\r\n }\r\n\r\n return centerOfMass(largestPolygon);\r\n }\r\n\r\n throw new Error('Unsupported geometry type');\r\n}\r\n\r\nfunction createLightFromConfig(config: LightConfig): THREE.Light {\r\n let light: THREE.Light;\r\n\r\n switch (config.type) {\r\n case 'ambient':\r\n light = new THREE.AmbientLight(config.color, config.intensity);\r\n break;\r\n case 'directional':\r\n light = new THREE.DirectionalLight(config.color, config.intensity);\r\n if (config.position) {\r\n if (config.position === 'camera') light.position.set(0, 0, 0);\r\n else light.position.set(config.position.x, config.position.y, config.position.z);\r\n }\r\n if (config.target || config.position === 'camera') {\r\n (light as THREE.SpotLight).target.position.set(\r\n config.target?.x || 0,\r\n config.target?.y || 0,\r\n config.target?.z === undefined ? -1 : config.target.z,\r\n );\r\n }\r\n if (config.castShadow) {\r\n (light as THREE.DirectionalLight).castShadow = true;\r\n if (config.shadow) {\r\n (light as THREE.DirectionalLight).shadow.mapSize.width = config.shadow.mapSize.width;\r\n (light as THREE.DirectionalLight).shadow.mapSize.height = config.shadow.mapSize.height;\r\n (light as THREE.DirectionalLight).shadow.camera.near = config.shadow.camera.near;\r\n (light as THREE.DirectionalLight).shadow.camera.far = config.shadow.camera.far;\r\n }\r\n }\r\n break;\r\n case 'point':\r\n light = new THREE.PointLight(\r\n config.color,\r\n config.intensity,\r\n config.distance || 0,\r\n config.decay || 2,\r\n );\r\n if (config.position) {\r\n if (config.position === 'camera') light.position.set(0, 0, 0);\r\n else light.position.set(config.position.x, config.position.y, config.position.z);\r\n }\r\n break;\r\n case 'spot':\r\n light = new THREE.SpotLight(\r\n config.color,\r\n config.intensity,\r\n config.distance || 0,\r\n config.angle || Math.PI / 3,\r\n config.penumbra || 0,\r\n config.decay || 2,\r\n );\r\n if (config.position) {\r\n if (config.position === 'camera') light.position.set(0, 0, 0);\r\n else light.position.set(config.position.x, config.position.y, config.position.z);\r\n }\r\n if (config.target || config.position === 'camera') {\r\n (light as THREE.SpotLight).target.position.set(\r\n config.target?.x || 0,\r\n config.target?.y || 0,\r\n config.target?.z || 0,\r\n );\r\n }\r\n if (config.castShadow) {\r\n (light as THREE.SpotLight).castShadow = true;\r\n if (config.shadow) {\r\n (light as THREE.SpotLight).shadow.mapSize.width = config.shadow.mapSize.width;\r\n (light as THREE.SpotLight).shadow.mapSize.height = config.shadow.mapSize.height;\r\n (light as THREE.SpotLight).shadow.camera.near = config.shadow.camera.near;\r\n (light as THREE.SpotLight).shadow.camera.far = config.shadow.camera.far;\r\n }\r\n }\r\n break;\r\n default:\r\n throw new Error('Unknown light type');\r\n }\r\n\r\n return light;\r\n}\r\nfunction Graph(props: Props) {\r\n const {\r\n width,\r\n autoRotate,\r\n data,\r\n enableZoom,\r\n categorical,\r\n colorDomain,\r\n colors,\r\n globeMaterial,\r\n height,\r\n polygonData,\r\n mapProperty,\r\n mapBorderColor,\r\n atmosphereColor,\r\n tooltip,\r\n styles,\r\n classNames,\r\n mapNoDataColor,\r\n colorLegendTitle,\r\n showColorScale,\r\n hoverStrokeColor,\r\n detailsOnClick,\r\n onSeriesMouseClick,\r\n onSeriesMouseOver,\r\n resetSelectionOnDoubleClick,\r\n highlightedIds,\r\n scale,\r\n globeOffset,\r\n polygonAltitude,\r\n centerLng,\r\n centerLat,\r\n atmosphereAltitude,\r\n globeCurvatureResolution,\r\n fogSettings,\r\n lights,\r\n highlightedAltitude,\r\n selectedId,\r\n } = props;\r\n const [globeReady, setGlobeReady] = useState(false);\r\n const globeEl = useRef<GlobeMethods | undefined>(undefined);\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [showLegend, setShowLegend] = useState(!(width < 680));\r\n const [mousePos, setMousePos] = useState({ x: 0, y: 0 });\r\n const [mouseOverData, setMouseOverData] = useState<ChoroplethMapDataType | undefined>(undefined);\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 useEffect(() => {\r\n if (globeEl.current) {\r\n globeEl.current.controls().enableZoom = enableZoom;\r\n }\r\n }, [enableZoom]);\r\n useEffect(() => {\r\n if (globeEl.current) {\r\n if (mouseOverData || mouseClickData || selectedId) {\r\n globeEl.current.controls().autoRotate = false;\r\n } else {\r\n globeEl.current.controls().autoRotate = autoRotate === 0 ? false : true;\r\n globeEl.current.controls().autoRotateSpeed = autoRotate;\r\n }\r\n }\r\n }, [mouseOverData, mouseClickData, selectedId, autoRotate]);\r\n useEffect(() => {\r\n if (globeEl.current && selectedId) {\r\n const selectedPolygon = polygonData.find(\r\n (d: any) => d.properties[mapProperty] === selectedId,\r\n );\r\n const [lng, lat] = getMainlandCentroid(selectedPolygon).geometry.coordinates;\r\n globeEl.current.pointOfView({ lat, lng, altitude: scale }, 1000);\r\n }\r\n }, [selectedId, scale, polygonData, mapProperty]);\r\n\r\n useEffect(() => {\r\n const canvas = globeEl.current?.renderer().domElement;\r\n if (!canvas) return;\r\n\r\n const handleMouseMove = (e: MouseEvent) => {\r\n setMousePos({ x: e.clientX, y: e.clientY });\r\n };\r\n\r\n canvas.addEventListener('mousemove', handleMouseMove);\r\n return () => canvas.removeEventListener('mousemove', handleMouseMove);\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (globeEl.current) {\r\n globeEl.current.pointOfView({ lat: centerLat, lng: centerLng, altitude: scale }, 1000);\r\n }\r\n }, [scale, centerLng, centerLat]);\r\n const materials =\r\n globeMaterial ||\r\n new THREE.MeshBasicMaterial({\r\n color: '#FFF',\r\n });\r\n const setupCustomLighting = useCallback(() => {\r\n if (!globeEl.current) return;\r\n\r\n const scene = globeEl.current.scene();\r\n const camera = globeEl.current.camera();\r\n\r\n let lightsAndObjToRemove: THREE.Object3D[] = [];\r\n scene.traverse(obj => {\r\n if (obj instanceof THREE.Light) {\r\n lightsAndObjToRemove.push(obj);\r\n }\r\n });\r\n lightsAndObjToRemove = [...lightsAndObjToRemove, ...camera.children];\r\n lightsAndObjToRemove.forEach(light => light.parent?.remove(light));\r\n\r\n const lightConfig = lights.map(config => createLightFromConfig(config));\r\n lightConfig.forEach((light, i) => {\r\n if (lights[i].type !== 'ambient' && lights[i].position === 'camera') {\r\n camera.add(light);\r\n if (lights[i].type !== 'point') {\r\n camera.add((light as THREE.DirectionalLight | THREE.SpotLight).target);\r\n }\r\n } else {\r\n scene.add(light);\r\n }\r\n });\r\n\r\n if (fogSettings) {\r\n scene.fog = new THREE.Fog(fogSettings.color, fogSettings.near, fogSettings.far);\r\n }\r\n }, [lights, fogSettings]);\r\n\r\n const handleGlobeReady = useCallback(() => {\r\n setGlobeReady(true);\r\n setupCustomLighting();\r\n }, [setupCustomLighting]);\r\n useEffect(() => {\r\n if (globeReady) {\r\n setupCustomLighting();\r\n }\r\n }, [globeReady, setupCustomLighting]);\r\n return (\r\n <div className='relative'>\r\n <Globe\r\n ref={globeEl}\r\n height={height}\r\n width={width}\r\n globeOffset={globeOffset}\r\n lineHoverPrecision={0}\r\n polygonsData={polygonData}\r\n polygonAltitude={(polygon: any) =>\r\n highlightedIds.includes(polygon?.properties?.[mapProperty]) ||\r\n polygon?.properties?.[mapProperty] === selectedId\r\n ? highlightedAltitude\r\n : polygon?.properties?.[mapProperty] === mouseOverData?.id ||\r\n polygon?.properties?.[mapProperty] === mouseClickData?.id\r\n ? highlightedAltitude\r\n : polygonAltitude\r\n }\r\n polygonCapColor={(polygon: any) => {\r\n const id = polygon?.properties?.[mapProperty];\r\n const val = data.find(el => el.id === id)?.x;\r\n if (val !== undefined && val !== null) {\r\n return colorScale(val as any);\r\n }\r\n return mapNoDataColor;\r\n }}\r\n polygonSideColor={(polygon: any) => {\r\n const id = polygon?.properties?.[mapProperty];\r\n const val = data.find(el => el.id === id)?.x;\r\n const color = val !== undefined && val !== null ? colorScale(val as any) : mapNoDataColor;\r\n return highlightedIds.includes(polygon?.properties?.[mapProperty])\r\n ? color\r\n : 'rgba(100,100,100,0)';\r\n }}\r\n polygonStrokeColor={(polygon: any) =>\r\n polygon?.properties?.[mapProperty] === mouseOverData?.id\r\n ? hoverStrokeColor\r\n : mapBorderColor\r\n }\r\n onGlobeClick={() => {\r\n setMouseClickData(undefined);\r\n }}\r\n onPolygonClick={(polygon: any) => {\r\n const clickedData = polygon?.properties?.[mapProperty]\r\n ? data.find(el => el.id === polygon?.properties?.[mapProperty])\r\n : undefined;\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (\r\n isEqual(mouseClickData, clickedData) &&\r\n resetSelectionOnDoubleClick &&\r\n clickedData\r\n ) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(clickedData);\r\n onSeriesMouseClick?.(clickedData);\r\n }\r\n }\r\n }}\r\n onPolygonHover={(polygon: any) => {\r\n const hoverData = polygon?.properties?.[mapProperty]\r\n ? data.find(el => el.id === polygon?.properties?.[mapProperty])\r\n : undefined;\r\n setMouseOverData(hoverData);\r\n onSeriesMouseOver?.(hoverData);\r\n }}\r\n atmosphereColor={atmosphereColor}\r\n atmosphereAltitude={atmosphereAltitude}\r\n globeCurvatureResolution={globeCurvatureResolution}\r\n globeMaterial={materials}\r\n backgroundColor='rgba(0, 0, 0, 0)'\r\n polygonsTransitionDuration={100}\r\n onGlobeReady={() => {\r\n if (globeEl.current) {\r\n globeEl.current.pointOfView({\r\n lat: centerLat,\r\n lng: centerLng,\r\n });\r\n const scene = globeEl.current.scene();\r\n setTimeout(() => {\r\n const polygons = scene.children[3]?.children[0]?.children[4]?.children || [];\r\n polygons.forEach(d => {\r\n const line = d.children[1];\r\n line.renderOrder = 2;\r\n });\r\n }, 300);\r\n const camera = globeEl.current.camera();\r\n scene.add(camera);\r\n handleGlobeReady();\r\n }\r\n }}\r\n />\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 key={i} className='cursor-pointer'>\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 style={{\r\n fill: colors[i],\r\n 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 x={(colorDomain.length * 320) / colors.length + 1}\r\n y={1}\r\n width={320 / colors.length - 2}\r\n height={8}\r\n style={{\r\n fill: colors[colorDomain.length],\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 key={i} className='flex gap-2 items-center'>\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 {mouseOverData && tooltip ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={mousePos.x}\r\n yPos={mousePos.y}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\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 </div>\r\n );\r\n}\r\n\r\nexport default Graph;\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport { Spinner } from '@undp/design-system-react/Spinner';\r\nimport * as THREE from 'three';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport Graph from './Graph';\r\n\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport {\r\n ChoroplethMapDataType,\r\n ClassNameObject,\r\n FogDataType,\r\n Languages,\r\n LightConfig,\r\n ScaleDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { fetchAndParseJSON } from '@/Utils/fetchAndParseData';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { getUniqValue } from '@/Utils/getUniqValue';\r\nimport { getJenks } from '@/Utils/getJenks';\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 /** Stroke color of the regions in the map */\r\n mapBorderColor?: string;\r\n /** Center point of the map */\r\n centerPoint?: [number, number];\r\n /** Defines if the globe rotates automatically */\r\n autoRotate?: number | boolean;\r\n /** Defines the material property applied to the sphere of the globe */\r\n globeMaterial?: THREE.Material;\r\n /** Defines the lights for the 3D scene */\r\n lights?: LightConfig[];\r\n /** Defines the colo of the glow around the globe */\r\n atmosphereColor?: string;\r\n /** Defines if the globe can be zoomed when scrolled */\r\n enableZoom?: boolean;\r\n /** Position offset of the globe relative to the canvas center */\r\n globeOffset?: [number, number];\r\n /** Defines the camera distance from Earth. This helps in defining the default size of the globe. Smaller = closer camera therefore the globe is bigger) */\r\n scale?: number;\r\n /** Defines the spacing between the country shape polygon with the sphere */\r\n polygonAltitude?: number;\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 /** The max altitude of the atmosphere, in terms of globe radius units. */\r\n atmosphereAltitude?: number;\r\n /** Resolution in angular degrees of the sphere curvature. The finer the resolution, the more the globe is fragmented into smaller faces to approximate the spheric surface, at the cost of performance. */\r\n globeCurvatureResolution?: number;\r\n /** Defines fog settings for the scene. */\r\n fogSettings?: FogDataType;\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 /** Countries or regions to be highlighted */\r\n selectedId?: string;\r\n /** Countries or regions to be highlighted */\r\n highlightedIds?: string[];\r\n /** Defines the altitude of the highlighted countries or the countries on mouseover. */\r\n highlightedAltitude?: number;\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\n/** For using these maps you will have to install [`three`](https://threejs.org/manual/) and [react-globe.gl](https://www.npmjs.com/package/react-globe.gl) package to your project */\r\nexport function ThreeDGlobe(props: Props) {\r\n const {\r\n data,\r\n mapData = 'https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-simplified.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 padding,\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 graphID,\r\n mapProperty = 'ISO3',\r\n dataDownload = false,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n styles,\r\n classNames,\r\n autoRotate = true,\r\n enableZoom = true,\r\n globeMaterial,\r\n centerPoint = [0, 0],\r\n atmosphereColor = '#999',\r\n showColorScale = true,\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n onSeriesMouseOver,\r\n onSeriesMouseClick,\r\n highlightedIds = [],\r\n highlightedAltitude = 0.1,\r\n scale = 1,\r\n globeOffset = [0, 0],\r\n polygonAltitude = 0.01,\r\n globeCurvatureResolution = 4,\r\n atmosphereAltitude = 0.15,\r\n fogSettings,\r\n lights = [\r\n {\r\n type: 'ambient',\r\n color: 0x404040,\r\n intensity: 0.4,\r\n },\r\n {\r\n type: 'directional',\r\n color: 0xffffff,\r\n intensity: 1,\r\n position: { x: 5, y: 10, z: 5 },\r\n },\r\n ],\r\n selectedId,\r\n } = props;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mapShape, setMapShape] = useState<any>(undefined);\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n\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 if (\r\n mapData ===\r\n 'https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-simplified.json'\r\n ) {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const features = d.features.map((el: any) => {\r\n if (el.geometry.type === 'Polygon') {\r\n const reversed = [...el.geometry.coordinates[0]].reverse();\r\n const geometry = { ...el.geometry, coordinates: [reversed] };\r\n return { ...el, geometry };\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const coord: any = [];\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n el.geometry.coordinates.forEach((c: any) => {\r\n const reversed = [...c[0]].reverse();\r\n coord.push([reversed]);\r\n });\r\n const geometry = { ...el.geometry, coordinates: coord };\r\n return { ...el, geometry };\r\n });\r\n setMapShape(features);\r\n } else setMapShape(d.features);\r\n });\r\n } else {\r\n setMapShape(mapData.features);\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 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 aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a map.${graphDescription ? ` ${graphDescription}` : ''}`\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 || 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={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 <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}\r\n globeOffset={globeOffset}\r\n polygonData={mapShape}\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 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 mapNoDataColor={mapNoDataColor}\r\n categorical={scaleType === 'categorical'}\r\n mapBorderColor={mapBorderColor}\r\n tooltip={tooltip}\r\n mapProperty={mapProperty}\r\n styles={styles}\r\n classNames={classNames}\r\n autoRotate={autoRotate === true ? 1.5 : autoRotate === false ? 0 : autoRotate}\r\n enableZoom={enableZoom}\r\n globeMaterial={globeMaterial}\r\n atmosphereColor={atmosphereColor}\r\n colorLegendTitle={colorLegendTitle}\r\n showColorScale={showColorScale}\r\n hoverStrokeColor={\r\n theme === 'light'\r\n ? Colors.light.grays['gray-700']\r\n : Colors.light.grays['gray-300']\r\n }\r\n highlightedIds={highlightedIds}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n detailsOnClick={detailsOnClick}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n scale={scale}\r\n polygonAltitude={polygonAltitude}\r\n centerLat={centerPoint[0]}\r\n centerLng={centerPoint[1]}\r\n atmosphereAltitude={atmosphereAltitude}\r\n globeCurvatureResolution={globeCurvatureResolution}\r\n fogSettings={fogSettings}\r\n lights={lights}\r\n highlightedAltitude={highlightedAltitude}\r\n selectedId={selectedId}\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":["area","geojson","geomReduce","value","geom","calculateArea","total","i","polygonArea","coords","ringArea","FACTOR","earthRadius","PI_OVER_180","coordsLength","lower","middle","upper","lowerX","middleY","upperX","turf_area_default","getMainlandCentroid","multiPolygonFeature","centerOfMass","maxArea","largestPolygon","poly","polyArea","createLightFromConfig","config","light","THREE","Graph","props","width","autoRotate","data","enableZoom","categorical","colorDomain","colors","globeMaterial","height","polygonData","mapProperty","mapBorderColor","atmosphereColor","tooltip","styles","classNames","mapNoDataColor","colorLegendTitle","showColorScale","hoverStrokeColor","detailsOnClick","onSeriesMouseClick","onSeriesMouseOver","resetSelectionOnDoubleClick","highlightedIds","scale","globeOffset","polygonAltitude","centerLng","centerLat","atmosphereAltitude","globeCurvatureResolution","fogSettings","lights","highlightedAltitude","selectedId","globeReady","setGlobeReady","useState","globeEl","useRef","mouseClickData","setMouseClickData","showLegend","setShowLegend","mousePos","setMousePos","mouseOverData","setMouseOverData","colorScale","scaleOrdinal","scaleThreshold","useEffect","selectedPolygon","d","lng","lat","canvas","handleMouseMove","e","materials","setupCustomLighting","useCallback","scene","camera","lightsAndObjToRemove","obj","handleGlobeReady","jsxs","jsx","Globe","polygon","id","val","el","color","clickedData","isEqual","hoverData","line","Fragment","X","P","numberFormattingFunction","Tooltip","Modal","string2HTML","ThreeDGlobe","mapData","graphTitle","sources","graphDescription","footNote","scaleType","padding","Colors","backgroundColor","relativeHeight","graphID","dataDownload","language","minHeight","theme","ariaLabel","centerPoint","mapShape","setMapShape","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","resizeObserver","entries","fetchAndParseJSON","features","reversed","geometry","coord","c","domain","getUniqValue","getJenks","cn","GraphHeader","Spinner","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,GAAKC,GAAS;AACrB,SAAOC;AAAA,IACLD;AAAA,IACA,CAACE,GAAOC,MACCD,IAAQE,GAAcD,CAAI;AAAA,IAEnC;AAAA,EACJ;AACA;AACA,SAASC,GAAcD,GAAM;AAC3B,MAAIE,IAAQ,GACRC;AACJ,UAAQH,EAAK,MAAI;AAAA,IACf,KAAK;AACH,aAAOI,GAAYJ,EAAK,WAAW;AAAA,IACrC,KAAK;AACH,WAAKG,IAAI,GAAGA,IAAIH,EAAK,YAAY,QAAQG;AACvC,QAAAD,KAASE,GAAYJ,EAAK,YAAYG,CAAC,CAAC;AAE1C,aAAOD;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,EACb;AACE,SAAO;AACT;AACA,SAASE,GAAYC,GAAQ;AAC3B,MAAIH,IAAQ;AACZ,MAAIG,KAAUA,EAAO,SAAS,GAAG;AAC/B,IAAAH,KAAS,KAAK,IAAII,GAASD,EAAO,CAAC,CAAC,CAAC;AACrC,aAASF,IAAI,GAAGA,IAAIE,EAAO,QAAQF;AACjC,MAAAD,KAAS,KAAK,IAAII,GAASD,EAAOF,CAAC,CAAC,CAAC;AAAA,EAEzC;AACA,SAAOD;AACT;AACA,IAAIK,KAASC,KAAcA,KAAc,GACrCC,KAAc,KAAK,KAAK;AAC5B,SAASH,GAASD,GAAQ;AACxB,QAAMK,IAAeL,EAAO,SAAS;AACrC,MAAIK,KAAgB,EAAG,QAAO;AAC9B,MAAIR,IAAQ,GACRC,IAAI;AACR,SAAOA,IAAIO,KAAc;AACvB,UAAMC,IAAQN,EAAOF,CAAC,GAChBS,IAASP,EAAOF,IAAI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ACA,QAAAC;AAAA,wBACA,qBAAAC;AAAA,wBACA,YAAAC;AAAA,sBAAA;AAAA,oBAAA,IAGFkC,gBAAAA,EAAAA;AAAAA,sBAAC;AAAA,sBAAA;AAAA,wBACC,OAAO;AAAA,0BACL,QAAQ,GAAG,KAAK;AAAA,4BACdgC;AAAA,4BACA7F,MACGyF,IACGI,KACGrG,KAAS2G,KAAYV,IAAiBI,KACpCrG,KAAS2G,KAAYV,IACtBI,KACDrG,KAAS2G,KAAYV,IACxBY;AAAA,0BAAA,CACP;AAAA,wBAAA;AAAA,wBAEH,WAAU;AAAA,wBAEV,UAAAxC,gBAAAA,EAAAA,IAACwD,IAAA,EAAQ,cAAW,gBAAA,CAAgB;AAAA,sBAAA;AAAA,oBAAA;AAAA,kBACtC;AAAA,gBAAA;AAAA,gBAGHnC,KAAWE,IACVvB,gBAAAA,EAAAA;AAAAA,kBAACyD;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAUhH,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAA2E;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAA5F;AAAA,kBAAA;AAAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"ThreeDGlobe.js","sources":["../src/Components/Graphs/Maps/ThreeDGlobe/Graph.tsx","../src/Components/Graphs/Maps/ThreeDGlobe/index.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport Globe, { GlobeMethods } from 'react-globe.gl';\r\nimport isEqual from 'fast-deep-equal';\r\nimport { useCallback, useEffect, useRef, useState } from 'react';\r\nimport { scaleOrdinal, scaleThreshold } from 'd3-scale';\r\nimport * as THREE from 'three';\r\nimport { Modal } from '@undp/design-system-react/Modal';\r\nimport { P } from '@undp/design-system-react/Typography';\r\n\r\nimport {\r\n ChoroplethMapDataType,\r\n ClassNameObject,\r\n FogDataType,\r\n LightConfig,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { X } from '@/Components/Icons';\r\nimport { string2HTML } from '@/Utils/string2HTML';\r\nimport { getCentroidCoordinates } from '@/Utils/getCentroidCoordinates';\r\n\r\ninterface Props {\r\n width: number;\r\n data: ChoroplethMapDataType[];\r\n autoRotate: number;\r\n enableZoom: boolean;\r\n categorical: boolean;\r\n colorDomain: (number | string)[];\r\n colors: string[];\r\n height: number;\r\n globeMaterial?: THREE.Material;\r\n lights: LightConfig[];\r\n polygonData: any;\r\n mapProperty: string;\r\n mapBorderColor: string;\r\n atmosphereColor: string;\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n onSeriesMouseOver?: (_d: any) => void;\r\n onSeriesMouseClick?: (_d: any) => void;\r\n mapNoDataColor: string;\r\n colorLegendTitle?: string;\r\n showColorScale: boolean;\r\n hoverStrokeColor: string;\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n resetSelectionOnDoubleClick: boolean;\r\n highlightedIds: string[];\r\n scale: number;\r\n globeOffset: [number, number];\r\n polygonAltitude: number;\r\n centerLng: number;\r\n centerLat: number;\r\n atmosphereAltitude: number;\r\n globeCurvatureResolution: number;\r\n fogSettings?: FogDataType;\r\n highlightedAltitude: number;\r\n selectedId?: string;\r\n}\r\n\r\nfunction createLightFromConfig(config: LightConfig): THREE.Light {\r\n let light: THREE.Light;\r\n\r\n switch (config.type) {\r\n case 'ambient':\r\n light = new THREE.AmbientLight(config.color, config.intensity);\r\n break;\r\n case 'directional':\r\n light = new THREE.DirectionalLight(config.color, config.intensity);\r\n if (config.position) {\r\n if (config.position === 'camera') light.position.set(0, 0, 0);\r\n else light.position.set(config.position.x, config.position.y, config.position.z);\r\n }\r\n if (config.target || config.position === 'camera') {\r\n (light as THREE.SpotLight).target.position.set(\r\n config.target?.x || 0,\r\n config.target?.y || 0,\r\n config.target?.z === undefined ? -1 : config.target.z,\r\n );\r\n }\r\n if (config.castShadow) {\r\n (light as THREE.DirectionalLight).castShadow = true;\r\n if (config.shadow) {\r\n (light as THREE.DirectionalLight).shadow.mapSize.width = config.shadow.mapSize.width;\r\n (light as THREE.DirectionalLight).shadow.mapSize.height = config.shadow.mapSize.height;\r\n (light as THREE.DirectionalLight).shadow.camera.near = config.shadow.camera.near;\r\n (light as THREE.DirectionalLight).shadow.camera.far = config.shadow.camera.far;\r\n }\r\n }\r\n break;\r\n case 'point':\r\n light = new THREE.PointLight(\r\n config.color,\r\n config.intensity,\r\n config.distance || 0,\r\n config.decay || 2,\r\n );\r\n if (config.position) {\r\n if (config.position === 'camera') light.position.set(0, 0, 0);\r\n else light.position.set(config.position.x, config.position.y, config.position.z);\r\n }\r\n break;\r\n case 'spot':\r\n light = new THREE.SpotLight(\r\n config.color,\r\n config.intensity,\r\n config.distance || 0,\r\n config.angle || Math.PI / 3,\r\n config.penumbra || 0,\r\n config.decay || 2,\r\n );\r\n if (config.position) {\r\n if (config.position === 'camera') light.position.set(0, 0, 0);\r\n else light.position.set(config.position.x, config.position.y, config.position.z);\r\n }\r\n if (config.target || config.position === 'camera') {\r\n (light as THREE.SpotLight).target.position.set(\r\n config.target?.x || 0,\r\n config.target?.y || 0,\r\n config.target?.z || 0,\r\n );\r\n }\r\n if (config.castShadow) {\r\n (light as THREE.SpotLight).castShadow = true;\r\n if (config.shadow) {\r\n (light as THREE.SpotLight).shadow.mapSize.width = config.shadow.mapSize.width;\r\n (light as THREE.SpotLight).shadow.mapSize.height = config.shadow.mapSize.height;\r\n (light as THREE.SpotLight).shadow.camera.near = config.shadow.camera.near;\r\n (light as THREE.SpotLight).shadow.camera.far = config.shadow.camera.far;\r\n }\r\n }\r\n break;\r\n default:\r\n throw new Error('Unknown light type');\r\n }\r\n\r\n return light;\r\n}\r\nfunction Graph(props: Props) {\r\n const {\r\n width,\r\n autoRotate,\r\n data,\r\n enableZoom,\r\n categorical,\r\n colorDomain,\r\n colors,\r\n globeMaterial,\r\n height,\r\n polygonData,\r\n mapProperty,\r\n mapBorderColor,\r\n atmosphereColor,\r\n tooltip,\r\n styles,\r\n classNames,\r\n mapNoDataColor,\r\n colorLegendTitle,\r\n showColorScale,\r\n hoverStrokeColor,\r\n detailsOnClick,\r\n onSeriesMouseClick,\r\n onSeriesMouseOver,\r\n resetSelectionOnDoubleClick,\r\n highlightedIds,\r\n scale,\r\n globeOffset,\r\n polygonAltitude,\r\n centerLng,\r\n centerLat,\r\n atmosphereAltitude,\r\n globeCurvatureResolution,\r\n fogSettings,\r\n lights,\r\n highlightedAltitude,\r\n selectedId,\r\n } = props;\r\n const [globeReady, setGlobeReady] = useState(false);\r\n const globeEl = useRef<GlobeMethods | undefined>(undefined);\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [showLegend, setShowLegend] = useState(!(width < 680));\r\n const [mousePos, setMousePos] = useState({ x: 0, y: 0 });\r\n const [mouseOverData, setMouseOverData] = useState<ChoroplethMapDataType | undefined>(undefined);\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 useEffect(() => {\r\n if (globeEl.current) {\r\n globeEl.current.controls().enableZoom = enableZoom;\r\n }\r\n }, [enableZoom]);\r\n useEffect(() => {\r\n if (globeEl.current) {\r\n if (mouseOverData || selectedId) {\r\n globeEl.current.controls().autoRotate = false;\r\n } else {\r\n globeEl.current.controls().autoRotate = autoRotate === 0 ? false : true;\r\n globeEl.current.controls().autoRotateSpeed = autoRotate;\r\n }\r\n }\r\n }, [mouseOverData, selectedId, autoRotate]);\r\n useEffect(() => {\r\n if (globeEl.current && selectedId) {\r\n const selectedPolygon = polygonData.find(\r\n (d: any) => d.properties[mapProperty] === selectedId,\r\n );\r\n const [lng, lat] = getCentroidCoordinates(selectedPolygon);\r\n globeEl.current.pointOfView({ lat, lng, altitude: scale }, 1000);\r\n }\r\n }, [selectedId, scale, polygonData, mapProperty]);\r\n\r\n useEffect(() => {\r\n const canvas = globeEl.current?.renderer().domElement;\r\n if (!canvas) return;\r\n\r\n const handleMouseMove = (e: MouseEvent) => {\r\n setMousePos({ x: e.clientX, y: e.clientY });\r\n };\r\n\r\n canvas.addEventListener('mousemove', handleMouseMove);\r\n return () => canvas.removeEventListener('mousemove', handleMouseMove);\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (globeEl.current) {\r\n globeEl.current.pointOfView({ lat: centerLat, lng: centerLng, altitude: scale }, 1000);\r\n }\r\n }, [scale, centerLng, centerLat]);\r\n const materials =\r\n globeMaterial ||\r\n new THREE.MeshBasicMaterial({\r\n color: '#FFF',\r\n });\r\n const setupCustomLighting = useCallback(() => {\r\n if (!globeEl.current) return;\r\n\r\n const scene = globeEl.current.scene();\r\n const camera = globeEl.current.camera();\r\n\r\n let lightsAndObjToRemove: THREE.Object3D[] = [];\r\n scene.traverse(obj => {\r\n if (obj instanceof THREE.Light) {\r\n lightsAndObjToRemove.push(obj);\r\n }\r\n });\r\n lightsAndObjToRemove = [...lightsAndObjToRemove, ...camera.children];\r\n lightsAndObjToRemove.forEach(light => light.parent?.remove(light));\r\n\r\n const lightConfig = lights.map(config => createLightFromConfig(config));\r\n lightConfig.forEach((light, i) => {\r\n if (lights[i].type !== 'ambient' && lights[i].position === 'camera') {\r\n camera.add(light);\r\n if (lights[i].type !== 'point') {\r\n camera.add((light as THREE.DirectionalLight | THREE.SpotLight).target);\r\n }\r\n } else {\r\n scene.add(light);\r\n }\r\n });\r\n\r\n if (fogSettings) {\r\n scene.fog = new THREE.Fog(fogSettings.color, fogSettings.near, fogSettings.far);\r\n }\r\n }, [lights, fogSettings]);\r\n\r\n const handleGlobeReady = useCallback(() => {\r\n setGlobeReady(true);\r\n setupCustomLighting();\r\n }, [setupCustomLighting]);\r\n useEffect(() => {\r\n if (globeReady) {\r\n setupCustomLighting();\r\n }\r\n }, [globeReady, setupCustomLighting]);\r\n return (\r\n <div className='relative'>\r\n <Globe\r\n ref={globeEl}\r\n height={height}\r\n width={width}\r\n globeOffset={globeOffset}\r\n lineHoverPrecision={0}\r\n polygonsData={polygonData}\r\n polygonAltitude={(polygon: any) =>\r\n highlightedIds.includes(polygon?.properties?.[mapProperty]) ||\r\n polygon?.properties?.[mapProperty] === selectedId\r\n ? highlightedAltitude * (polygon?.properties?.[mapProperty] === selectedId ? 2 : 1)\r\n : polygon?.properties?.[mapProperty] === mouseOverData?.id ||\r\n polygon?.properties?.[mapProperty] === mouseClickData?.id\r\n ? highlightedAltitude\r\n : polygonAltitude\r\n }\r\n polygonCapColor={(polygon: any) => {\r\n const id = polygon?.properties?.[mapProperty];\r\n const val = data.find(el => el.id === id)?.x;\r\n if (val !== undefined && val !== null) {\r\n return colorScale(val as any);\r\n }\r\n return mapNoDataColor;\r\n }}\r\n polygonSideColor={(polygon: any) => {\r\n const id = polygon?.properties?.[mapProperty];\r\n const val = data.find(el => el.id === id)?.x;\r\n const color = val !== undefined && val !== null ? colorScale(val as any) : mapNoDataColor;\r\n return highlightedIds.includes(polygon?.properties?.[mapProperty]) ||\r\n polygon?.properties?.[mapProperty] === selectedId\r\n ? color\r\n : 'rgba(100,100,100,0)';\r\n }}\r\n polygonStrokeColor={(polygon: any) =>\r\n polygon?.properties?.[mapProperty] === mouseOverData?.id\r\n ? hoverStrokeColor\r\n : mapBorderColor\r\n }\r\n onGlobeClick={() => {\r\n setMouseClickData(undefined);\r\n }}\r\n onPolygonClick={(polygon: any) => {\r\n const clickedData = polygon?.properties?.[mapProperty]\r\n ? data.find(el => el.id === polygon?.properties?.[mapProperty])\r\n : undefined;\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (\r\n isEqual(mouseClickData, clickedData) &&\r\n resetSelectionOnDoubleClick &&\r\n clickedData\r\n ) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(clickedData);\r\n onSeriesMouseClick?.(clickedData);\r\n }\r\n }\r\n }}\r\n onPolygonHover={(polygon: any) => {\r\n const hoverData = polygon?.properties?.[mapProperty]\r\n ? data.find(el => el.id === polygon?.properties?.[mapProperty])\r\n : undefined;\r\n setMouseOverData(hoverData);\r\n onSeriesMouseOver?.(hoverData);\r\n }}\r\n atmosphereColor={atmosphereColor}\r\n atmosphereAltitude={atmosphereAltitude}\r\n globeCurvatureResolution={globeCurvatureResolution}\r\n globeMaterial={materials}\r\n backgroundColor='rgba(0, 0, 0, 0)'\r\n polygonsTransitionDuration={100}\r\n onGlobeReady={() => {\r\n if (globeEl.current) {\r\n globeEl.current.pointOfView({\r\n lat: centerLat,\r\n lng: centerLng,\r\n });\r\n const scene = globeEl.current.scene();\r\n setTimeout(() => {\r\n const polygons = scene.children[3]?.children[0]?.children[4]?.children || [];\r\n polygons.forEach(d => {\r\n const line = d.children[1];\r\n line.renderOrder = 2;\r\n });\r\n }, 300);\r\n const camera = globeEl.current.camera();\r\n scene.add(camera);\r\n handleGlobeReady();\r\n }\r\n }}\r\n />\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 key={i} className='cursor-pointer'>\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 style={{\r\n fill: colors[i],\r\n 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 x={(colorDomain.length * 320) / colors.length + 1}\r\n y={1}\r\n width={320 / colors.length - 2}\r\n height={8}\r\n style={{\r\n fill: colors[colorDomain.length],\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 key={i} className='flex gap-2 items-center'>\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 {mouseOverData && tooltip ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={mousePos.x}\r\n yPos={mousePos.y}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\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 </div>\r\n );\r\n}\r\n\r\nexport default Graph;\r\n","import React, { useEffect, useRef, useState } from 'react';\r\nimport { Spinner } from '@undp/design-system-react/Spinner';\r\nimport * as THREE from 'three';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport Graph from './Graph';\r\n\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport {\r\n ChoroplethMapDataType,\r\n ClassNameObject,\r\n FogDataType,\r\n Languages,\r\n LightConfig,\r\n ScaleDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { fetchAndParseJSON } from '@/Utils/fetchAndParseData';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { getUniqValue } from '@/Utils/getUniqValue';\r\nimport { getJenks } from '@/Utils/getJenks';\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 /** Stroke color of the regions in the map */\r\n mapBorderColor?: string;\r\n /** Center point of the map */\r\n centerPoint?: [number, number];\r\n /** Defines if the globe rotates automatically */\r\n autoRotate?: number | boolean;\r\n /** Defines the material property applied to the sphere of the globe */\r\n globeMaterial?: THREE.Material;\r\n /** Defines the lights for the 3D scene */\r\n lights?: LightConfig[];\r\n /** Defines the colo of the glow around the globe */\r\n atmosphereColor?: string;\r\n /** Defines if the globe can be zoomed when scrolled */\r\n enableZoom?: boolean;\r\n /** Position offset of the globe relative to the canvas center */\r\n globeOffset?: [number, number];\r\n /** Defines the camera distance from Earth. This helps in defining the default size of the globe. Smaller = closer camera therefore the globe is bigger) */\r\n scale?: number;\r\n /** Defines the spacing between the country shape polygon with the sphere */\r\n polygonAltitude?: number;\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 /** The max altitude of the atmosphere, in terms of globe radius units. */\r\n atmosphereAltitude?: number;\r\n /** Resolution in angular degrees of the sphere curvature. The finer the resolution, the more the globe is fragmented into smaller faces to approximate the spheric surface, at the cost of performance. */\r\n globeCurvatureResolution?: number;\r\n /** Defines fog settings for the scene. */\r\n fogSettings?: FogDataType;\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 /** Countries or regions to be highlighted */\r\n selectedId?: string;\r\n /** Countries or regions to be highlighted */\r\n highlightedIds?: string[];\r\n /** Defines the altitude of the highlighted countries or the countries on mouseover. */\r\n highlightedAltitude?: number;\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\n/** For using these maps you will have to install [`three`](https://threejs.org/manual/) and [react-globe.gl](https://www.npmjs.com/package/react-globe.gl) package to your project */\r\nexport function ThreeDGlobe(props: Props) {\r\n const {\r\n data,\r\n mapData = 'https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-simplified.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 padding,\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 graphID,\r\n mapProperty = 'ISO3',\r\n dataDownload = false,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n styles,\r\n classNames,\r\n autoRotate = true,\r\n enableZoom = true,\r\n globeMaterial,\r\n centerPoint = [0, 0],\r\n atmosphereColor = '#999',\r\n showColorScale = true,\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n onSeriesMouseOver,\r\n onSeriesMouseClick,\r\n highlightedIds = [],\r\n highlightedAltitude = 0.1,\r\n scale = 1,\r\n globeOffset = [0, 0],\r\n polygonAltitude = 0.01,\r\n globeCurvatureResolution = 4,\r\n atmosphereAltitude = 0.15,\r\n fogSettings,\r\n lights = [\r\n {\r\n type: 'ambient',\r\n color: 0x404040,\r\n intensity: 0.4,\r\n },\r\n {\r\n type: 'directional',\r\n color: 0xffffff,\r\n intensity: 1,\r\n position: { x: 5, y: 10, z: 5 },\r\n },\r\n ],\r\n selectedId,\r\n } = props;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mapShape, setMapShape] = useState<any>(undefined);\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n\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 if (\r\n mapData ===\r\n 'https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap-simplified.json'\r\n ) {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const features = d.features.map((el: any) => {\r\n if (el.geometry.type === 'Polygon') {\r\n const reversed = [...el.geometry.coordinates[0]].reverse();\r\n const geometry = { ...el.geometry, coordinates: [reversed] };\r\n return { ...el, geometry };\r\n }\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const coord: any = [];\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n el.geometry.coordinates.forEach((c: any) => {\r\n const reversed = [...c[0]].reverse();\r\n coord.push([reversed]);\r\n });\r\n const geometry = { ...el.geometry, coordinates: coord };\r\n return { ...el, geometry };\r\n });\r\n setMapShape(features);\r\n } else setMapShape(d.features);\r\n });\r\n } else {\r\n setMapShape(mapData.features);\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 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 aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a map.${graphDescription ? ` ${graphDescription}` : ''}`\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 || 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={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 <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}\r\n globeOffset={globeOffset}\r\n polygonData={mapShape}\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 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 mapNoDataColor={mapNoDataColor}\r\n categorical={scaleType === 'categorical'}\r\n mapBorderColor={mapBorderColor}\r\n tooltip={tooltip}\r\n mapProperty={mapProperty}\r\n styles={styles}\r\n classNames={classNames}\r\n autoRotate={autoRotate === true ? 1.5 : autoRotate === false ? 0 : autoRotate}\r\n enableZoom={enableZoom}\r\n globeMaterial={globeMaterial}\r\n atmosphereColor={atmosphereColor}\r\n colorLegendTitle={colorLegendTitle}\r\n showColorScale={showColorScale}\r\n hoverStrokeColor={\r\n theme === 'light'\r\n ? Colors.light.grays['gray-700']\r\n : Colors.light.grays['gray-300']\r\n }\r\n highlightedIds={highlightedIds}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n detailsOnClick={detailsOnClick}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n scale={scale}\r\n polygonAltitude={polygonAltitude}\r\n centerLat={centerPoint[0]}\r\n centerLng={centerPoint[1]}\r\n atmosphereAltitude={atmosphereAltitude}\r\n globeCurvatureResolution={globeCurvatureResolution}\r\n fogSettings={fogSettings}\r\n lights={lights}\r\n highlightedAltitude={highlightedAltitude}\r\n selectedId={selectedId}\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":["createLightFromConfig","config","light","THREE","Graph","props","width","autoRotate","data","enableZoom","categorical","colorDomain","colors","globeMaterial","height","polygonData","mapProperty","mapBorderColor","atmosphereColor","tooltip","styles","classNames","mapNoDataColor","colorLegendTitle","showColorScale","hoverStrokeColor","detailsOnClick","onSeriesMouseClick","onSeriesMouseOver","resetSelectionOnDoubleClick","highlightedIds","scale","globeOffset","polygonAltitude","centerLng","centerLat","atmosphereAltitude","globeCurvatureResolution","fogSettings","lights","highlightedAltitude","selectedId","globeReady","setGlobeReady","useState","globeEl","useRef","mouseClickData","setMouseClickData","showLegend","setShowLegend","mousePos","setMousePos","mouseOverData","setMouseOverData","colorScale","scaleOrdinal","scaleThreshold","useEffect","selectedPolygon","d","lng","lat","getCentroidCoordinates","canvas","handleMouseMove","e","materials","setupCustomLighting","useCallback","scene","camera","lightsAndObjToRemove","obj","i","handleGlobeReady","jsxs","jsx","Globe","polygon","id","val","el","color","clickedData","isEqual","hoverData","line","Fragment","X","P","numberFormattingFunction","Tooltip","Modal","string2HTML","ThreeDGlobe","mapData","graphTitle","sources","graphDescription","footNote","scaleType","padding","Colors","backgroundColor","relativeHeight","graphID","dataDownload","language","minHeight","theme","ariaLabel","centerPoint","mapShape","setMapShape","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","resizeObserver","entries","fetchAndParseJSON","features","reversed","geometry","coord","c","domain","getUniqValue","getJenks","cn","GraphHeader","Spinner","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6DA,SAASA,GAAsBC,GAAkC;AAC/D,MAAIC;AAEJ,UAAQD,EAAO,MAAA;AAAA,IACb,KAAK;AACH,MAAAC,IAAQ,IAAIC,EAAM,aAAaF,EAAO,OAAOA,EAAO,SAAS;AAC7D;AAAA,IACF,KAAK;AACH,MAAAC,IAAQ,IAAIC,EAAM,iBAAiBF,EAAO,OAAOA,EAAO,SAAS,GAC7DA,EAAO,aACLA,EAAO,aAAa,WAAUC,EAAM,SAAS,IAAI,GAAG,GAAG,CAAC,IACvDA,EAAM,SAAS,IAAID,EAAO,SAAS,GAAGA,EAAO,SAAS,GAAGA,EAAO,SAAS,CAAC,KAE7EA,EAAO,UAAUA,EAAO,aAAa,aACtCC,EAA0B,OAAO,SAAS;AAAA,QACzCD,EAAO,QAAQ,KAAK;AAAA,QACpBA,EAAO,QAAQ,KAAK;AAAA,QACpBA,EAAO,QAAQ,MAAM,SAAY,KAAKA,EAAO,OAAO;AAAA,MAAA,GAGpDA,EAAO,eACRC,EAAiC,aAAa,IAC3CD,EAAO,WACRC,EAAiC,OAAO,QAAQ,QAAQD,EAAO,OAAO,QAAQ,OAC9EC,EAAiC,OAAO,QAAQ,SAASD,EAAO,OAAO,QAAQ,QAC/EC,EAAiC,OAAO,OAAO,OAAOD,EAAO,OAAO,OAAO,MAC3EC,EAAiC,OAAO,OAAO,MAAMD,EAAO,OAAO,OAAO;AAG/E;AAAA,IACF,KAAK;AACH,MAAAC,IAAQ,IAAIC,EAAM;AAAA,QAChBF,EAAO;AAAA,QACPA,EAAO;AAAA,QACPA,EAAO,YAAY;AAAA,QACnBA,EAAO,SAAS;AAAA,MAAA,GAEdA,EAAO,aACLA,EAAO,aAAa,WAAUC,EAAM,SAAS,IAAI,GAAG,GAAG,CAAC,IAC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Y;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAA6E;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAA9F;AAAA,kBAAA;AAAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),F=require("react"),O=require("./index-CSNtgibC.cjs"),M=require("./Typography-k-kOjICQ.cjs"),U=require("./GraphFooter.cjs"),J=require("./GraphHeader.cjs"),K=require("./Colors.cjs"),Q=require("./numberFormattingFunction-02t-wJta.cjs"),X=require("./use-in-view-sQJZ_xDO.cjs"),Y=require("./index-BW8iNx7E.cjs"),Z=require("./proxy-BHRoeZgd.cjs");function _(z){const{data:n,size:g=200,graphTitle:x,sources:R,colors:E=K.Colors.light.categoricalColors.colors,graphDescription:d,totalNoOfDots:f=100,unitPadding:G=3,gridSize:c=10,footNote:b,padding:N,backgroundColor:l=!1,graphID:H,graphDownload:k=!1,language:j="en",showColorScale:I=!0,showStrokeForWhiteDots:m=!0,note:C,dataDownload:S=!1,theme:P="light",width:r,height:h,minHeight:s=0,relativeHeight:a,ariaLabel:T,styles:u,classNames:w,animate:$=!1,precision:L=2}=z,q=F.useRef(null),y=$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},W=X.useInView(q,{once:y.once,amount:y.amount}),B=O.sum(n.map(e=>e.value)),D=F.useRef(null),o=g/c,p=(o-G*2)/2;if(p<=0)return console.error("The size of single unit is less than or equal to zero. Check values for ((dimension / gridSize) - (padding * 2)) / 2 is not less than or equal to 0."),null;const v=[];return n.forEach((e,i)=>{const A=Math.round(e.value/B*f);for(let V=0;V<A;V+=1)v.push({color:E[i]})}),t.jsxRuntimeExports.jsx("div",{className:`${P||"light"} flex ${r?"w-fit grow-0":"w-full grow"}`,dir:j==="he"||j==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${l?l===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${j||"en"}`,r?"w-fit":"w-full",w?.graphContainer),style:{...u?.graphContainer||{},minHeight:"inherit",...l&&l!==!0?{backgroundColor:l}:{}},id:H,ref:D,"aria-label":T||`${x?`The graph shows ${x}. `:""}${d?` ${d}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:l?N||"1rem":N||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 w-full grow",children:[x||d||k?t.jsxRuntimeExports.jsx(J.GraphHeader,{styles:{title:u?.title,description:u?.description},classNames:{title:w?.title,description:w?.description},graphTitle:x,graphDescription:d,width:r,graphDownload:k?D.current:void 0,dataDownload:S?n.map(e=>e.data).filter(e=>e!==void 0).length>0?n.map(e=>e.data).filter(e=>e!==void 0):n.filter(e=>e!==void 0):null}):null,C?t.jsxRuntimeExports.jsx(M.f,{marginBottom:"2xs",className:"text-primary-gray-700 dark:text-primary-gray-100 font-bold",style:{width:r?`${r}px`:"100%"},children:C}):null,t.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col gap-4 justify-between",children:[t.jsxRuntimeExports.jsxs("div",{children:[I?t.jsxRuntimeExports.jsx("div",{className:"mb-4 leading-0",style:{width:r?`${r}px`:"100%"},"aria-label":"Color legend",children:t.jsxRuntimeExports.jsx("div",{className:"flex mb-0 flex-wrap gap-x-4 gap-y-1",children:n.map((e,i)=>t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsxRuntimeExports.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:E[i]}}),t.jsxRuntimeExports.jsxs(M.u,{marginBottom:"none",size:"sm",className:"text-primary-gray-700 dark:text-primary-gray-100",children:[e.label,":"," ",t.jsxRuntimeExports.jsx("span",{className:"font-bold",children:Q.numberFormattingFunction(e.value,"NA",L)})]})]},i))})}):null,t.jsxRuntimeExports.jsx("div",{"aria-label":"Graph area",children:t.jsxRuntimeExports.jsx("svg",{width:`${r||g}px`,height:`${Math.max(s,h?a&&r?s?r*a>s?r*a:s:r*a:h:Math.floor((f-1)/c)*o+o/2+p+5)}px`,ref:q,direction:"ltr",viewBox:`0 0 ${r||g} ${Math.max(s,h?a&&r?s?r*a>s?r*a:s:r*a:h:Math.floor((f-1)/c)*o+o/2+p+5)}`,children:t.jsxRuntimeExports.jsx(Y.AnimatePresence,{children:t.jsxRuntimeExports.jsx("g",{children:v.map((e,i)=>t.jsxRuntimeExports.jsx(Z.motion.circle,{cx:i%c*o+o/2,cy:Math.floor(i/c)*o+o/2,style:{...m?{}:{stroke:e.color},strokeWidth:1},variants:{initial:{fill:"#fff",opacity:0,...m?{}:{stroke:e.color},strokeWidth:1},whileInView:{fill:e.color,opacity:1,...m?{}:{stroke:e.color},strokeWidth:1,transition:{duration:0,delay:y.duration/v.length*i}}},initial:"initial",animate:W?"whileInView":"initial",className:(e.color.toLowerCase()==="#fff"||e.color.toLowerCase()==="#ffffff"||e.color.toLowerCase()==="white")&&m?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"",r:p},i))})})})})]}),R||b?t.jsxRuntimeExports.jsx(U.GraphFooter,{styles:{footnote:u?.footnote,source:u?.source},sources:R,footNote:b,width:r}):null]})]})})})})}exports.UnitChart=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),F=require("react"),O=require("./index-CSNtgibC.cjs"),M=require("./Typography-k-kOjICQ.cjs"),U=require("./GraphFooter.cjs"),J=require("./GraphHeader.cjs"),K=require("./Colors.cjs"),Q=require("./numberFormattingFunction-02t-wJta.cjs"),X=require("./use-in-view-sQJZ_xDO.cjs"),Y=require("./index-BW8iNx7E.cjs"),Z=require("./proxy-BHRoeZgd.cjs");function _(z){const{data:n,size:p=200,graphTitle:x,sources:R,colors:E=K.Colors.light.categoricalColors.colors,graphDescription:d,totalNoOfDots:g=100,unitPadding:G=3,gridSize:c=10,footNote:b,padding:N,backgroundColor:l=!1,graphID:H,graphDownload:C=!1,language:f="en",showColorScale:I=!0,showStrokeForWhiteDots:j=!0,note:k,dataDownload:S=!1,theme:P="light",width:r,height:m,minHeight:s=0,relativeHeight:a,ariaLabel:T,styles:u,classNames:w,animate:$=!1,precision:L=2}=z,q=F.useRef(null),y=$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},W=X.useInView(q,{once:y.once,amount:y.amount}),B=O.sum(n.map(e=>e.value)),D=F.useRef(null),o=p/c,h=(o-G*2)/2;if(h<=0)return console.error("The size of single unit is less than or equal to zero. Check values for ((dimension / gridSize) - (padding * 2)) / 2 is not less than or equal to 0."),null;const v=[];return n.forEach((e,i)=>{const A=Math.round(e.value/B*g);for(let V=0;V<A;V+=1)v.push({color:E[i]})}),t.jsxRuntimeExports.jsx("div",{className:`${P||"light"} flex ${r?"w-fit grow-0":"w-full grow"}`,dir:f==="he"||f==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${l?l===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${f||"en"}`,r?"w-fit":"w-full",w?.graphContainer),style:{...u?.graphContainer||{},minHeight:"inherit",...l&&l!==!0?{backgroundColor:l}:{}},id:H,ref:D,"aria-label":T||`${x?`The graph shows ${x}. `:""}${d?` ${d}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:l?N||"1rem":N||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 w-full grow",children:[x||d||C?t.jsxRuntimeExports.jsx(J.GraphHeader,{styles:{title:u?.title,description:u?.description},classNames:{title:w?.title,description:w?.description},graphTitle:x,graphDescription:d,width:r,graphDownload:C?D.current:void 0,dataDownload:S?n.map(e=>e.data).filter(e=>e!==void 0).length>0?n.map(e=>e.data).filter(e=>e!==void 0):n.filter(e=>e!==void 0):null}):null,k?t.jsxRuntimeExports.jsx(M.f,{marginBottom:"2xs",className:"text-primary-gray-700 dark:text-primary-gray-100 font-bold",style:{width:r?`${r}px`:"100%"},children:k}):null,t.jsxRuntimeExports.jsxs("div",{className:"flex grow flex-col gap-4 justify-between",children:[t.jsxRuntimeExports.jsxs("div",{children:[I?t.jsxRuntimeExports.jsx("div",{className:"mb-4 leading-0",style:{width:r?`${r}px`:"100%"},"aria-label":"Color legend",children:t.jsxRuntimeExports.jsx("div",{className:"flex mb-0 flex-wrap gap-x-4 gap-y-1",children:n.map((e,i)=>t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",children:[t.jsxRuntimeExports.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:E[i]}}),t.jsxRuntimeExports.jsxs(M.u,{marginBottom:"none",size:"sm",className:"text-primary-gray-700 dark:text-primary-gray-100",children:[e.label,":"," ",t.jsxRuntimeExports.jsx("span",{className:"font-bold",children:Q.numberFormattingFunction(e.value,"NA",L)})]})]},i))})}):null,t.jsxRuntimeExports.jsx("div",{"aria-label":"Graph area",children:t.jsxRuntimeExports.jsx("svg",{width:`${r||p}px`,height:`${Math.max(s,m?a&&r?s?r*a>s?r*a:s:r*a:m:Math.floor((g-1)/c)*o+o/2+h+5)}px`,ref:q,direction:"ltr",viewBox:`0 0 ${r||p} ${Math.max(s,m?a&&r?s?r*a>s?r*a:s:r*a:m:Math.floor((g-1)/c)*o+o/2+h+5)}`,children:t.jsxRuntimeExports.jsx(Y.AnimatePresence,{children:t.jsxRuntimeExports.jsx("g",{children:v.map((e,i)=>t.jsxRuntimeExports.jsx(Z.motion.circle,{style:{strokeWidth:1},variants:{initial:{fill:"#fff",opacity:0,...j?{}:{stroke:e.color},strokeWidth:1},whileInView:{fill:e.color,opacity:1,...j?{}:{stroke:e.color},strokeWidth:1,cx:i%c*o+o/2,cy:Math.floor(i/c)*o+o/2,transition:{duration:0,delay:y.duration/v.length*i}}},initial:"initial",animate:W?"whileInView":"initial",className:(e.color.toLowerCase()==="#fff"||e.color.toLowerCase()==="#ffffff"||e.color.toLowerCase()==="white")&&j?"stroke-primary-gray-400 dark:stroke-primary-gray-500":"",r:h},i))})})})})]}),R||b?t.jsxRuntimeExports.jsx(U.GraphFooter,{styles:{footnote:u?.footnote,source:u?.source},sources:R,footNote:b,width:r}):null]})]})})})})}exports.UnitChart=_;
2
2
  //# sourceMappingURL=UnitChart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnitChart.cjs","sources":["../src/Components/Graphs/UnitChart/index.tsx"],"sourcesContent":["import { useRef } from 'react';\r\nimport sum from 'lodash.sum';\r\nimport { H2, P } from '@undp/design-system-react/Typography';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport {\r\n UnitChartDataType,\r\n SourcesDataType,\r\n Languages,\r\n StyleObject,\r\n ClassNameObject,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: UnitChartDataType[];\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 /** Note with h2 tag just above the graph. Can be used to highlight text */\r\n note?: string;\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 of the highlighted circles */\r\n colors?: 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 /** Size of the visualization */\r\n size?: number;\r\n /** No. of dots in a single row */\r\n gridSize?: number;\r\n /** Spacing between 2 dots */\r\n unitPadding?: number;\r\n /** Total no. of dot that are rendered in the chart */\r\n totalNoOfDots?: number;\r\n /** Toggle visibility of stroke for the unfilled dots */\r\n showStrokeForWhiteDots?: boolean;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Toggle visibility of color scale */\r\n showColorScale?: boolean;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\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\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 UnitChart(props: Props) {\r\n const {\r\n data,\r\n size = 200,\r\n graphTitle,\r\n sources,\r\n colors = Colors.light.categoricalColors.colors,\r\n graphDescription,\r\n totalNoOfDots = 100,\r\n unitPadding = 3,\r\n gridSize = 10,\r\n footNote,\r\n padding,\r\n backgroundColor = false,\r\n graphID,\r\n graphDownload = false,\r\n language = 'en',\r\n showColorScale = true,\r\n showStrokeForWhiteDots = true,\r\n note,\r\n dataDownload = false,\r\n theme = 'light',\r\n width,\r\n height,\r\n minHeight = 0,\r\n relativeHeight,\r\n ariaLabel,\r\n styles,\r\n classNames,\r\n animate = false,\r\n precision = 2,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const animateValue =\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 const isInView = useInView(svgRef, {\r\n once: animateValue.once,\r\n amount: animateValue.amount,\r\n });\r\n const totalValue = sum(data.map(d => d.value));\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n const gridDimension = size / gridSize;\r\n const radius = (gridDimension - unitPadding * 2) / 2;\r\n if (radius <= 0) {\r\n console.error(\r\n 'The size of single unit is less than or equal to zero. Check values for ((dimension / gridSize) - (padding * 2)) / 2 is not less than or equal to 0.',\r\n );\r\n return null;\r\n }\r\n\r\n const cellsData: { color: string }[] = [];\r\n data.forEach((item, index) => {\r\n const count = Math.round((item.value / totalValue) * totalNoOfDots);\r\n for (let i = 0; i < count; i += 1) {\r\n cellsData.push({ color: colors[index] });\r\n }\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 minHeight: 'inherit',\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 `${graphTitle ? `The graph shows ${graphTitle}. ` : ''}${\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 gap-3 w-full grow'>\r\n {graphTitle || graphDescription || graphDownload ? (\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 {note ? (\r\n <H2\r\n marginBottom='2xs'\r\n className='text-primary-gray-700 dark:text-primary-gray-100 font-bold'\r\n style={{ width: width ? `${width}px` : '100%' }}\r\n >\r\n {note}\r\n </H2>\r\n ) : null}\r\n <div className='flex grow flex-col gap-4 justify-between'>\r\n <div>\r\n {showColorScale ? (\r\n <div\r\n className='mb-4 leading-0'\r\n style={{ width: width ? `${width}px` : '100%' }}\r\n aria-label='Color legend'\r\n >\r\n <div className='flex mb-0 flex-wrap gap-x-4 gap-y-1'>\r\n {data.map((d, i) => (\r\n <div className='flex gap-2 items-center' key={i}>\r\n <div\r\n className='w-3 h-3 rounded-full'\r\n style={{ backgroundColor: colors[i] }}\r\n />\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n className='text-primary-gray-700 dark:text-primary-gray-100'\r\n >\r\n {d.label}:{' '}\r\n <span className='font-bold'>\r\n {numberFormattingFunction(d.value, 'NA', precision)}\r\n </span>\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n ) : null}\r\n <div aria-label='Graph area'>\r\n <svg\r\n width={`${width || size}px`}\r\n height={`${Math.max(\r\n minHeight,\r\n height\r\n ? relativeHeight && width\r\n ? minHeight\r\n ? width * relativeHeight > minHeight\r\n ? width * relativeHeight\r\n : minHeight\r\n : width * relativeHeight\r\n : height\r\n : Math.floor((totalNoOfDots - 1) / gridSize) * gridDimension +\r\n gridDimension / 2 +\r\n radius +\r\n 5,\r\n )}px`}\r\n ref={svgRef}\r\n direction='ltr'\r\n viewBox={`0 0 ${width || size} ${Math.max(\r\n minHeight,\r\n height\r\n ? relativeHeight && width\r\n ? minHeight\r\n ? width * relativeHeight > minHeight\r\n ? width * relativeHeight\r\n : minHeight\r\n : width * relativeHeight\r\n : height\r\n : Math.floor((totalNoOfDots - 1) / gridSize) * gridDimension +\r\n gridDimension / 2 +\r\n radius +\r\n 5,\r\n )}`}\r\n >\r\n <AnimatePresence>\r\n <g>\r\n {cellsData.map((d, i) => (\r\n <motion.circle\r\n key={i}\r\n cx={(i % gridSize) * gridDimension + gridDimension / 2}\r\n cy={Math.floor(i / gridSize) * gridDimension + gridDimension / 2}\r\n style={{\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n }}\r\n variants={{\r\n initial: {\r\n fill: '#fff',\r\n opacity: 0,\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n },\r\n whileInView: {\r\n fill: d.color,\r\n opacity: 1,\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n transition: {\r\n duration: 0,\r\n delay: (animateValue.duration / cellsData.length) * i,\r\n },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n className={\r\n (d.color.toLowerCase() === '#fff' ||\r\n d.color.toLowerCase() === '#ffffff' ||\r\n d.color.toLowerCase() === 'white') &&\r\n showStrokeForWhiteDots\r\n ? 'stroke-primary-gray-400 dark:stroke-primary-gray-500'\r\n : ''\r\n }\r\n r={radius}\r\n />\r\n ))}\r\n </g>\r\n </AnimatePresence>\r\n </svg>\r\n </div>\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{\r\n footnote: styles?.footnote,\r\n source: styles?.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 </div>\r\n );\r\n}\r\n"],"names":["UnitChart","props","data","size","graphTitle","sources","colors","Colors","graphDescription","totalNoOfDots","unitPadding","gridSize","footNote","padding","backgroundColor","graphID","graphDownload","language","showColorScale","showStrokeForWhiteDots","note","dataDownload","theme","width","height","minHeight","relativeHeight","ariaLabel","styles","classNames","animate","precision","svgRef","useRef","animateValue","isInView","useInView","totalValue","sum","d","graphParentDiv","gridDimension","radius","cellsData","item","index","count","i","jsx","cn","jsxs","GraphHeader","H2","P","AnimatePresence","motion","GraphFooter"],"mappings":"sdA2FO,SAASA,EAAUC,EAAc,CACtC,KAAM,CACJ,KAAAC,EACA,KAAAC,EAAO,IACP,WAAAC,EACA,QAAAC,EACA,OAAAC,EAASC,EAAAA,OAAO,MAAM,kBAAkB,OACxC,iBAAAC,EACA,cAAAC,EAAgB,IAChB,YAAAC,EAAc,EACd,SAAAC,EAAW,GACX,SAAAC,EACA,QAAAC,EACA,gBAAAC,EAAkB,GAClB,QAAAC,EACA,cAAAC,EAAgB,GAChB,SAAAC,EAAW,KACX,eAAAC,EAAiB,GACjB,uBAAAC,EAAyB,GACzB,KAAAC,EACA,aAAAC,EAAe,GACf,MAAAC,EAAQ,QACR,MAAAC,EACA,OAAAC,EACA,UAAAC,EAAY,EACZ,eAAAC,EACA,UAAAC,EACA,OAAAC,EACA,WAAAC,EACA,QAAAC,EAAU,GACV,UAAAC,EAAY,CAAA,EACV9B,EACE+B,EAASC,EAAAA,OAAO,IAAI,EACpBC,EACJJ,IAAY,GACR,CAAE,SAAU,GAAK,KAAM,GAAM,OAAQ,IACrCA,GAAW,CAAE,SAAU,EAAG,KAAM,GAAM,OAAQ,CAAA,EAC9CK,EAAWC,EAAAA,UAAUJ,EAAQ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AE,OAAQoB,EAAE,KAAA,EAC1C,YAAa,CAAA,EAEf,YAAa,CACX,KAAMA,EAAE,MACR,QAAS,EACT,GAAKpB,EAA+C,CAAA,EAAtB,CAAE,OAAQoB,EAAE,KAAA,EAC1C,YAAa,EACb,WAAY,CACV,SAAU,EACV,MAAQL,EAAa,SAAWS,EAAU,OAAU,CAAA,CACtD,CACF,EAEF,QAAQ,UACR,QAASR,EAAW,cAAgB,UACpC,WACGI,EAAE,MAAM,YAAA,IAAkB,QACzBA,EAAE,MAAM,YAAA,IAAkB,WAC1BA,EAAE,MAAM,gBAAkB,UAC5BpB,EACI,uDACA,GAEN,EAAGuB,CAAA,EAnCE,CAAA,CAqCR,EACH,CAAA,CACF,CAAA,CAAA,CACF,CACF,CAAA,EACF,EACCrC,GAAWO,EACVoC,EAAAA,kBAAAA,IAACQ,EAAAA,YAAA,CACC,OAAQ,CACN,SAAU5B,GAAQ,SAClB,OAAQA,GAAQ,MAAA,EAElB,QAAAvB,EACA,SAAAO,EACA,MAAAW,CAAA,CAAA,EAEA,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CAGN"}
1
+ {"version":3,"file":"UnitChart.cjs","sources":["../src/Components/Graphs/UnitChart/index.tsx"],"sourcesContent":["import { useRef } from 'react';\r\nimport sum from 'lodash.sum';\r\nimport { H2, P } from '@undp/design-system-react/Typography';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport {\r\n UnitChartDataType,\r\n SourcesDataType,\r\n Languages,\r\n StyleObject,\r\n ClassNameObject,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: UnitChartDataType[];\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 /** Note with h2 tag just above the graph. Can be used to highlight text */\r\n note?: string;\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 of the highlighted circles */\r\n colors?: 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 /** Size of the visualization */\r\n size?: number;\r\n /** No. of dots in a single row */\r\n gridSize?: number;\r\n /** Spacing between 2 dots */\r\n unitPadding?: number;\r\n /** Total no. of dot that are rendered in the chart */\r\n totalNoOfDots?: number;\r\n /** Toggle visibility of stroke for the unfilled dots */\r\n showStrokeForWhiteDots?: boolean;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Toggle visibility of color scale */\r\n showColorScale?: boolean;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\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\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 UnitChart(props: Props) {\r\n const {\r\n data,\r\n size = 200,\r\n graphTitle,\r\n sources,\r\n colors = Colors.light.categoricalColors.colors,\r\n graphDescription,\r\n totalNoOfDots = 100,\r\n unitPadding = 3,\r\n gridSize = 10,\r\n footNote,\r\n padding,\r\n backgroundColor = false,\r\n graphID,\r\n graphDownload = false,\r\n language = 'en',\r\n showColorScale = true,\r\n showStrokeForWhiteDots = true,\r\n note,\r\n dataDownload = false,\r\n theme = 'light',\r\n width,\r\n height,\r\n minHeight = 0,\r\n relativeHeight,\r\n ariaLabel,\r\n styles,\r\n classNames,\r\n animate = false,\r\n precision = 2,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const animateValue =\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 const isInView = useInView(svgRef, {\r\n once: animateValue.once,\r\n amount: animateValue.amount,\r\n });\r\n const totalValue = sum(data.map(d => d.value));\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n const gridDimension = size / gridSize;\r\n const radius = (gridDimension - unitPadding * 2) / 2;\r\n if (radius <= 0) {\r\n console.error(\r\n 'The size of single unit is less than or equal to zero. Check values for ((dimension / gridSize) - (padding * 2)) / 2 is not less than or equal to 0.',\r\n );\r\n return null;\r\n }\r\n\r\n const cellsData: { color: string }[] = [];\r\n data.forEach((item, index) => {\r\n const count = Math.round((item.value / totalValue) * totalNoOfDots);\r\n for (let i = 0; i < count; i += 1) {\r\n cellsData.push({ color: colors[index] });\r\n }\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 minHeight: 'inherit',\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 `${graphTitle ? `The graph shows ${graphTitle}. ` : ''}${\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 gap-3 w-full grow'>\r\n {graphTitle || graphDescription || graphDownload ? (\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 {note ? (\r\n <H2\r\n marginBottom='2xs'\r\n className='text-primary-gray-700 dark:text-primary-gray-100 font-bold'\r\n style={{ width: width ? `${width}px` : '100%' }}\r\n >\r\n {note}\r\n </H2>\r\n ) : null}\r\n <div className='flex grow flex-col gap-4 justify-between'>\r\n <div>\r\n {showColorScale ? (\r\n <div\r\n className='mb-4 leading-0'\r\n style={{ width: width ? `${width}px` : '100%' }}\r\n aria-label='Color legend'\r\n >\r\n <div className='flex mb-0 flex-wrap gap-x-4 gap-y-1'>\r\n {data.map((d, i) => (\r\n <div className='flex gap-2 items-center' key={i}>\r\n <div\r\n className='w-3 h-3 rounded-full'\r\n style={{ backgroundColor: colors[i] }}\r\n />\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n className='text-primary-gray-700 dark:text-primary-gray-100'\r\n >\r\n {d.label}:{' '}\r\n <span className='font-bold'>\r\n {numberFormattingFunction(d.value, 'NA', precision)}\r\n </span>\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n ) : null}\r\n <div aria-label='Graph area'>\r\n <svg\r\n width={`${width || size}px`}\r\n height={`${Math.max(\r\n minHeight,\r\n height\r\n ? relativeHeight && width\r\n ? minHeight\r\n ? width * relativeHeight > minHeight\r\n ? width * relativeHeight\r\n : minHeight\r\n : width * relativeHeight\r\n : height\r\n : Math.floor((totalNoOfDots - 1) / gridSize) * gridDimension +\r\n gridDimension / 2 +\r\n radius +\r\n 5,\r\n )}px`}\r\n ref={svgRef}\r\n direction='ltr'\r\n viewBox={`0 0 ${width || size} ${Math.max(\r\n minHeight,\r\n height\r\n ? relativeHeight && width\r\n ? minHeight\r\n ? width * relativeHeight > minHeight\r\n ? width * relativeHeight\r\n : minHeight\r\n : width * relativeHeight\r\n : height\r\n : Math.floor((totalNoOfDots - 1) / gridSize) * gridDimension +\r\n gridDimension / 2 +\r\n radius +\r\n 5,\r\n )}`}\r\n >\r\n <AnimatePresence>\r\n <g>\r\n {cellsData.map((d, i) => (\r\n <motion.circle\r\n key={i}\r\n style={{\r\n strokeWidth: 1,\r\n }}\r\n variants={{\r\n initial: {\r\n fill: '#fff',\r\n opacity: 0,\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n },\r\n whileInView: {\r\n fill: d.color,\r\n opacity: 1,\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n cx: (i % gridSize) * gridDimension + gridDimension / 2,\r\n cy: Math.floor(i / gridSize) * gridDimension + gridDimension / 2,\r\n transition: {\r\n duration: 0,\r\n delay: (animateValue.duration / cellsData.length) * i,\r\n },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n className={\r\n (d.color.toLowerCase() === '#fff' ||\r\n d.color.toLowerCase() === '#ffffff' ||\r\n d.color.toLowerCase() === 'white') &&\r\n showStrokeForWhiteDots\r\n ? 'stroke-primary-gray-400 dark:stroke-primary-gray-500'\r\n : ''\r\n }\r\n r={radius}\r\n />\r\n ))}\r\n </g>\r\n </AnimatePresence>\r\n </svg>\r\n </div>\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{\r\n footnote: styles?.footnote,\r\n source: styles?.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 </div>\r\n );\r\n}\r\n"],"names":["UnitChart","props","data","size","graphTitle","sources","colors","Colors","graphDescription","totalNoOfDots","unitPadding","gridSize","footNote","padding","backgroundColor","graphID","graphDownload","language","showColorScale","showStrokeForWhiteDots","note","dataDownload","theme","width","height","minHeight","relativeHeight","ariaLabel","styles","classNames","animate","precision","svgRef","useRef","animateValue","isInView","useInView","totalValue","sum","d","graphParentDiv","gridDimension","radius","cellsData","item","index","count","i","jsx","cn","jsxs","GraphHeader","H2","P","AnimatePresence","motion","GraphFooter"],"mappings":"sdA2FO,SAASA,EAAUC,EAAc,CACtC,KAAM,CACJ,KAAAC,EACA,KAAAC,EAAO,IACP,WAAAC,EACA,QAAAC,EACA,OAAAC,EAASC,EAAAA,OAAO,MAAM,kBAAkB,OACxC,iBAAAC,EACA,cAAAC,EAAgB,IAChB,YAAAC,EAAc,EACd,SAAAC,EAAW,GACX,SAAAC,EACA,QAAAC,EACA,gBAAAC,EAAkB,GAClB,QAAAC,EACA,cAAAC,EAAgB,GAChB,SAAAC,EAAW,KACX,eAAAC,EAAiB,GACjB,uBAAAC,EAAyB,GACzB,KAAAC,EACA,aAAAC,EAAe,GACf,MAAAC,EAAQ,QACR,MAAAC,EACA,OAAAC,EACA,UAAAC,EAAY,EACZ,eAAAC,EACA,UAA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,YAAa,CAAA,EAEf,SAAU,CACR,QAAS,CACP,KAAM,OACN,QAAS,EACT,GAAKpC,EAA+C,CAAA,EAAtB,CAAE,OAAQoB,EAAE,KAAA,EAC1C,YAAa,CAAA,EAEf,YAAa,CACX,KAAMA,EAAE,MACR,QAAS,EACT,GAAKpB,EAA+C,CAAA,EAAtB,CAAE,OAAQoB,EAAE,KAAA,EAC1C,YAAa,EACb,GAAK,EAAI5B,EAAY8B,EAAgBA,EAAgB,EACrD,GAAI,KAAK,MAAM,EAAI9B,CAAQ,EAAI8B,EAAgBA,EAAgB,EAC/D,WAAY,CACV,SAAU,EACV,MAAQP,EAAa,SAAWS,EAAU,OAAU,CAAA,CACtD,CACF,EAEF,QAAQ,UACR,QAASR,EAAW,cAAgB,UACpC,WACGI,EAAE,MAAM,YAAA,IAAkB,QACzBA,EAAE,MAAM,YAAA,IAAkB,WAC1BA,EAAE,MAAM,gBAAkB,UAC5BpB,EACI,uDACA,GAEN,EAAGuB,CAAA,EAlCE,CAAA,CAoCR,EACH,CAAA,CACF,CAAA,CAAA,CACF,CACF,CAAA,EACF,EACCrC,GAAWO,EACVoC,EAAAA,kBAAAA,IAACQ,EAAAA,YAAA,CACC,OAAQ,CACN,SAAU5B,GAAQ,SAClB,OAAQA,GAAQ,MAAA,EAElB,QAAAvB,EACA,SAAAO,EACA,MAAAW,CAAA,CAAA,EAEA,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CAGN"}
package/dist/UnitChart.js CHANGED
@@ -12,12 +12,12 @@ import { m as ee } from "./proxy-CkpFesk1.js";
12
12
  function he(H) {
13
13
  const {
14
14
  data: s,
15
- size: p = 200,
15
+ size: g = 200,
16
16
  graphTitle: d,
17
17
  sources: N,
18
18
  colors: b = X.light.categoricalColors.colors,
19
19
  graphDescription: h,
20
- totalNoOfDots: x = 100,
20
+ totalNoOfDots: p = 100,
21
21
  unitPadding: L = 3,
22
22
  gridSize: c = 10,
23
23
  footNote: k,
@@ -25,14 +25,14 @@ function he(H) {
25
25
  backgroundColor: n = !1,
26
26
  graphID: S,
27
27
  graphDownload: C = !1,
28
- language: w = "en",
28
+ language: x = "en",
29
29
  showColorScale: W = !0,
30
- showStrokeForWhiteDots: f = !0,
30
+ showStrokeForWhiteDots: w = !0,
31
31
  note: D,
32
32
  dataDownload: A = !1,
33
33
  theme: B = "light",
34
34
  width: o,
35
- height: u,
35
+ height: f,
36
36
  minHeight: i = 0,
37
37
  relativeHeight: l,
38
38
  ariaLabel: G,
@@ -43,26 +43,26 @@ function he(H) {
43
43
  } = H, M = F(null), v = z === !0 ? { duration: 0.5, once: !0, amount: 0.5 } : z || { duration: 0, once: !0, amount: 0 }, R = Z(M, {
44
44
  once: v.once,
45
45
  amount: v.amount
46
- }), T = O(s.map((e) => e.value)), V = F(null), a = p / c, g = (a - L * 2) / 2;
47
- if (g <= 0)
46
+ }), T = O(s.map((e) => e.value)), V = F(null), a = g / c, u = (a - L * 2) / 2;
47
+ if (u <= 0)
48
48
  return console.error(
49
49
  "The size of single unit is less than or equal to zero. Check values for ((dimension / gridSize) - (padding * 2)) / 2 is not less than or equal to 0."
50
50
  ), null;
51
51
  const j = [];
52
52
  return s.forEach((e, t) => {
53
- const q = Math.round(e.value / T * x);
53
+ const q = Math.round(e.value / T * p);
54
54
  for (let I = 0; I < q; I += 1)
55
55
  j.push({ color: b[t] });
56
56
  }), /* @__PURE__ */ r.jsx(
57
57
  "div",
58
58
  {
59
59
  className: `${B || "light"} flex ${o ? "w-fit grow-0" : "w-full grow"}`,
60
- dir: w === "he" || w === "ar" ? "rtl" : void 0,
60
+ dir: x === "he" || x === "ar" ? "rtl" : void 0,
61
61
  children: /* @__PURE__ */ r.jsx(
62
62
  "div",
63
63
  {
64
64
  className: E(
65
- `${n ? n === !0 ? "bg-primary-gray-200 dark:bg-primary-gray-650 " : "" : "bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${w || "en"}`,
65
+ `${n ? n === !0 ? "bg-primary-gray-200 dark:bg-primary-gray-650 " : "" : "bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${x || "en"}`,
66
66
  o ? "w-fit" : "w-full",
67
67
  y?.graphContainer
68
68
  ),
@@ -143,38 +143,37 @@ function he(H) {
143
143
  /* @__PURE__ */ r.jsx("div", { "aria-label": "Graph area", children: /* @__PURE__ */ r.jsx(
144
144
  "svg",
145
145
  {
146
- width: `${o || p}px`,
146
+ width: `${o || g}px`,
147
147
  height: `${Math.max(
148
148
  i,
149
- u ? l && o ? i ? o * l > i ? o * l : i : o * l : u : Math.floor((x - 1) / c) * a + a / 2 + g + 5
149
+ f ? l && o ? i ? o * l > i ? o * l : i : o * l : f : Math.floor((p - 1) / c) * a + a / 2 + u + 5
150
150
  )}px`,
151
151
  ref: M,
152
152
  direction: "ltr",
153
- viewBox: `0 0 ${o || p} ${Math.max(
153
+ viewBox: `0 0 ${o || g} ${Math.max(
154
154
  i,
155
- u ? l && o ? i ? o * l > i ? o * l : i : o * l : u : Math.floor((x - 1) / c) * a + a / 2 + g + 5
155
+ f ? l && o ? i ? o * l > i ? o * l : i : o * l : f : Math.floor((p - 1) / c) * a + a / 2 + u + 5
156
156
  )}`,
157
157
  children: /* @__PURE__ */ r.jsx(_, { children: /* @__PURE__ */ r.jsx("g", { children: j.map((e, t) => /* @__PURE__ */ r.jsx(
158
158
  ee.circle,
159
159
  {
160
- cx: t % c * a + a / 2,
161
- cy: Math.floor(t / c) * a + a / 2,
162
160
  style: {
163
- ...f ? {} : { stroke: e.color },
164
161
  strokeWidth: 1
165
162
  },
166
163
  variants: {
167
164
  initial: {
168
165
  fill: "#fff",
169
166
  opacity: 0,
170
- ...f ? {} : { stroke: e.color },
167
+ ...w ? {} : { stroke: e.color },
171
168
  strokeWidth: 1
172
169
  },
173
170
  whileInView: {
174
171
  fill: e.color,
175
172
  opacity: 1,
176
- ...f ? {} : { stroke: e.color },
173
+ ...w ? {} : { stroke: e.color },
177
174
  strokeWidth: 1,
175
+ cx: t % c * a + a / 2,
176
+ cy: Math.floor(t / c) * a + a / 2,
178
177
  transition: {
179
178
  duration: 0,
180
179
  delay: v.duration / j.length * t
@@ -183,8 +182,8 @@ function he(H) {
183
182
  },
184
183
  initial: "initial",
185
184
  animate: R ? "whileInView" : "initial",
186
- className: (e.color.toLowerCase() === "#fff" || e.color.toLowerCase() === "#ffffff" || e.color.toLowerCase() === "white") && f ? "stroke-primary-gray-400 dark:stroke-primary-gray-500" : "",
187
- r: g
185
+ className: (e.color.toLowerCase() === "#fff" || e.color.toLowerCase() === "#ffffff" || e.color.toLowerCase() === "white") && w ? "stroke-primary-gray-400 dark:stroke-primary-gray-500" : "",
186
+ r: u
188
187
  },
189
188
  t
190
189
  )) }) })