@undp/data-viz 1.4.12 → 1.4.14

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 (180) hide show
  1. package/dist/AreaChart.cjs +1 -1
  2. package/dist/AreaChart.cjs.map +1 -1
  3. package/dist/AreaChart.js +25 -24
  4. package/dist/AreaChart.js.map +1 -1
  5. package/dist/BarGraph.cjs +1 -1
  6. package/dist/BarGraph.cjs.map +1 -1
  7. package/dist/BarGraph.js +638 -632
  8. package/dist/BarGraph.js.map +1 -1
  9. package/dist/BeeSwarmChart.cjs +1 -1
  10. package/dist/BeeSwarmChart.cjs.map +1 -1
  11. package/dist/BeeSwarmChart.js +134 -132
  12. package/dist/BeeSwarmChart.js.map +1 -1
  13. package/dist/BiVariateChoroplethMap.cjs +1 -1
  14. package/dist/BiVariateChoroplethMap.cjs.map +1 -1
  15. package/dist/BiVariateChoroplethMap.js +35 -34
  16. package/dist/BiVariateChoroplethMap.js.map +1 -1
  17. package/dist/BulletChart.cjs +1 -1
  18. package/dist/BulletChart.cjs.map +1 -1
  19. package/dist/BulletChart.js +226 -224
  20. package/dist/BulletChart.js.map +1 -1
  21. package/dist/ButterflyChart.cjs +1 -1
  22. package/dist/ButterflyChart.cjs.map +1 -1
  23. package/dist/ButterflyChart.js +48 -47
  24. package/dist/ButterflyChart.js.map +1 -1
  25. package/dist/ChoroplethMap.cjs +1 -1
  26. package/dist/ChoroplethMap.cjs.map +1 -1
  27. package/dist/ChoroplethMap.js +56 -55
  28. package/dist/ChoroplethMap.js.map +1 -1
  29. package/dist/CirclePackingGraph.cjs +1 -1
  30. package/dist/CirclePackingGraph.js +1 -1
  31. package/dist/DataCards.cjs +3 -3
  32. package/dist/DataCards.cjs.map +1 -1
  33. package/dist/DataCards.js +2 -1
  34. package/dist/DataCards.js.map +1 -1
  35. package/dist/DataTable.cjs +1 -1
  36. package/dist/DataTable.cjs.map +1 -1
  37. package/dist/DataTable.js +9 -8
  38. package/dist/DataTable.js.map +1 -1
  39. package/dist/DifferenceLineChart.cjs +1 -1
  40. package/dist/DifferenceLineChart.cjs.map +1 -1
  41. package/dist/DifferenceLineChart.js +1 -0
  42. package/dist/DifferenceLineChart.js.map +1 -1
  43. package/dist/DonutChart.cjs +1 -1
  44. package/dist/DonutChart.cjs.map +1 -1
  45. package/dist/DonutChart.js +77 -76
  46. package/dist/DonutChart.js.map +1 -1
  47. package/dist/DotDensityMap.cjs +1 -1
  48. package/dist/DotDensityMap.cjs.map +1 -1
  49. package/dist/DotDensityMap.js +1 -0
  50. package/dist/DotDensityMap.js.map +1 -1
  51. package/dist/{DropdownSelect-CeHog_ih.js → DropdownSelect-CtOKZHD0.js} +22 -20
  52. package/dist/{DropdownSelect-CeHog_ih.js.map → DropdownSelect-CtOKZHD0.js.map} +1 -1
  53. package/dist/{DropdownSelect-BmE5JaeE.cjs → DropdownSelect-DBDM64B5.cjs} +2 -2
  54. package/dist/{DropdownSelect-BmE5JaeE.cjs.map → DropdownSelect-DBDM64B5.cjs.map} +1 -1
  55. package/dist/DualAxisLineChart.cjs +1 -1
  56. package/dist/DualAxisLineChart.cjs.map +1 -1
  57. package/dist/DualAxisLineChart.d.ts +3 -1
  58. package/dist/DualAxisLineChart.js +265 -261
  59. package/dist/DualAxisLineChart.js.map +1 -1
  60. package/dist/DumbbellChart.cjs +1 -1
  61. package/dist/DumbbellChart.cjs.map +1 -1
  62. package/dist/DumbbellChart.js +216 -214
  63. package/dist/DumbbellChart.js.map +1 -1
  64. package/dist/GeoHubCompareMaps.cjs +1 -1
  65. package/dist/GeoHubCompareMaps.cjs.map +1 -1
  66. package/dist/GeoHubCompareMaps.js +1 -0
  67. package/dist/GeoHubCompareMaps.js.map +1 -1
  68. package/dist/GeoHubMap.cjs +1 -1
  69. package/dist/GeoHubMap.cjs.map +1 -1
  70. package/dist/GeoHubMap.js +29 -28
  71. package/dist/GeoHubMap.js.map +1 -1
  72. package/dist/GeoHubMapWithLayerSelection.cjs +1 -1
  73. package/dist/GeoHubMapWithLayerSelection.cjs.map +1 -1
  74. package/dist/GeoHubMapWithLayerSelection.js +34 -33
  75. package/dist/GeoHubMapWithLayerSelection.js.map +1 -1
  76. package/dist/{GraphEl-s3ctz7oA.js → GraphEl-N6vuMRw_.js} +6 -2
  77. package/dist/GraphEl-N6vuMRw_.js.map +1 -0
  78. package/dist/GraphEl-Zl0W-LK9.cjs +2 -0
  79. package/dist/GraphEl-Zl0W-LK9.cjs.map +1 -0
  80. package/dist/GriddedGraphs.cjs +1 -1
  81. package/dist/GriddedGraphs.d.ts +1 -0
  82. package/dist/GriddedGraphs.js +2 -2
  83. package/dist/GriddedGraphsFromConfig.d.ts +1 -0
  84. package/dist/HeatMap.cjs +1 -1
  85. package/dist/HeatMap.cjs.map +1 -1
  86. package/dist/HeatMap.js +55 -54
  87. package/dist/HeatMap.js.map +1 -1
  88. package/dist/Histogram.cjs +1 -1
  89. package/dist/Histogram.js +1 -1
  90. package/dist/LineChartWithConfidenceInterval.cjs +1 -1
  91. package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
  92. package/dist/LineChartWithConfidenceInterval.js +22 -21
  93. package/dist/LineChartWithConfidenceInterval.js.map +1 -1
  94. package/dist/MultiGraphDashboard.cjs +1 -1
  95. package/dist/MultiGraphDashboard.d.ts +1 -0
  96. package/dist/MultiGraphDashboard.js +1 -1
  97. package/dist/MultiGraphDashboardFromConfig.d.ts +1 -0
  98. package/dist/MultiGraphDashboardWideToLongFormat.cjs +1 -1
  99. package/dist/MultiGraphDashboardWideToLongFormat.js +1 -1
  100. package/dist/MultiLineAltChart.cjs +1 -1
  101. package/dist/MultiLineAltChart.cjs.map +1 -1
  102. package/dist/MultiLineAltChart.js +34 -33
  103. package/dist/MultiLineAltChart.js.map +1 -1
  104. package/dist/MultiLineChart.cjs +1 -1
  105. package/dist/MultiLineChart.cjs.map +1 -1
  106. package/dist/MultiLineChart.js +72 -71
  107. package/dist/MultiLineChart.js.map +1 -1
  108. package/dist/ParetoChart.cjs +1 -1
  109. package/dist/ParetoChart.cjs.map +1 -1
  110. package/dist/ParetoChart.d.ts +4 -0
  111. package/dist/ParetoChart.js +317 -312
  112. package/dist/ParetoChart.js.map +1 -1
  113. package/dist/PerformanceIntensiveMultiGraphDashboard.cjs +1 -1
  114. package/dist/PerformanceIntensiveMultiGraphDashboard.d.ts +1 -0
  115. package/dist/PerformanceIntensiveMultiGraphDashboard.js +1 -1
  116. package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.d.ts +1 -0
  117. package/dist/PerformanceIntensiveScrollStory.d.ts +1 -0
  118. package/dist/RadarChart.cjs +1 -1
  119. package/dist/RadarChart.cjs.map +1 -1
  120. package/dist/RadarChart.js +27 -26
  121. package/dist/RadarChart.js.map +1 -1
  122. package/dist/SankeyChart.cjs +1 -1
  123. package/dist/SankeyChart.cjs.map +1 -1
  124. package/dist/SankeyChart.js +30 -29
  125. package/dist/SankeyChart.js.map +1 -1
  126. package/dist/ScatterPlot.cjs +1 -1
  127. package/dist/ScatterPlot.cjs.map +1 -1
  128. package/dist/ScatterPlot.js +119 -118
  129. package/dist/ScatterPlot.js.map +1 -1
  130. package/dist/ScrollStory.d.ts +1 -0
  131. package/dist/SimpleLineChart.cjs +1 -1
  132. package/dist/SimpleLineChart.cjs.map +1 -1
  133. package/dist/SimpleLineChart.js +16 -15
  134. package/dist/SimpleLineChart.js.map +1 -1
  135. package/dist/SingleGraphDashboard.cjs +1 -1
  136. package/dist/SingleGraphDashboard.d.ts +1 -0
  137. package/dist/SingleGraphDashboard.js +2 -2
  138. package/dist/SingleGraphDashboardFromConfig.d.ts +1 -0
  139. package/dist/SingleGraphDashboardGeoHubMaps.d.ts +1 -0
  140. package/dist/SingleGraphDashboardGeoHubMapsFromConfig.d.ts +1 -0
  141. package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
  142. package/dist/SingleGraphDashboardThreeDGraphs.d.ts +1 -0
  143. package/dist/SingleGraphDashboardThreeDGraphs.js +1 -1
  144. package/dist/SingleGraphDashboardThreeDGraphsFromConfig.d.ts +1 -0
  145. package/dist/SlopeChart.cjs +1 -1
  146. package/dist/SlopeChart.cjs.map +1 -1
  147. package/dist/SlopeChart.js +46 -45
  148. package/dist/SlopeChart.js.map +1 -1
  149. package/dist/SparkLine.cjs +1 -1
  150. package/dist/SparkLine.cjs.map +1 -1
  151. package/dist/SparkLine.js +12 -11
  152. package/dist/SparkLine.js.map +1 -1
  153. package/dist/StripChart.cjs +1 -1
  154. package/dist/StripChart.cjs.map +1 -1
  155. package/dist/StripChart.js +81 -79
  156. package/dist/StripChart.js.map +1 -1
  157. package/dist/ThreeDGlobe.cjs +1 -1
  158. package/dist/ThreeDGlobe.cjs.map +1 -1
  159. package/dist/ThreeDGlobe.js +1 -0
  160. package/dist/ThreeDGlobe.js.map +1 -1
  161. package/dist/TreeMapGraph.cjs +1 -1
  162. package/dist/TreeMapGraph.cjs.map +1 -1
  163. package/dist/TreeMapGraph.js +114 -113
  164. package/dist/TreeMapGraph.js.map +1 -1
  165. package/dist/Types.d.ts +1 -0
  166. package/dist/UnitChart.cjs +1 -1
  167. package/dist/UnitChart.cjs.map +1 -1
  168. package/dist/UnitChart.js +10 -9
  169. package/dist/UnitChart.js.map +1 -1
  170. package/dist/{index-CZLvTu6p.cjs → index-BbNoLJ_w.cjs} +2 -2
  171. package/dist/{index-CZLvTu6p.cjs.map → index-BbNoLJ_w.cjs.map} +1 -1
  172. package/dist/{index-DGAaLNu9.js → index-Bc5VF70V.js} +46 -45
  173. package/dist/{index-DGAaLNu9.js.map → index-Bc5VF70V.js.map} +1 -1
  174. package/dist/index.cjs +1 -1
  175. package/dist/index.d.ts +8 -1
  176. package/dist/index.js +1 -1
  177. package/package.json +2 -2
  178. package/dist/GraphEl-OzC-icbr.cjs +0 -2
  179. package/dist/GraphEl-OzC-icbr.cjs.map +0 -1
  180. package/dist/GraphEl-s3ctz7oA.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SlopeChart.js","sources":["../src/Components/Graphs/SlopeChart/Graph.tsx","../src/Components/Graphs/SlopeChart/index.tsx"],"sourcesContent":["import isEqual from 'fast-deep-equal';\r\nimport { useRef, useState } from 'react';\r\nimport { scaleLinear } from 'd3-scale';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { Modal } from '@undp/design-system-react/Modal';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport {\r\n AnimateDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n SlopeChartDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { string2HTML } from '@/Utils/string2HTML';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\n\r\ninterface Props {\r\n data: SlopeChartDataType[];\r\n width: number;\r\n height: number;\r\n selectedColor?: string;\r\n showLabels: boolean;\r\n colors: string[];\r\n colorDomain: string[];\r\n radius: number;\r\n leftMargin: number;\r\n rightMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n axisTitles: [string, string];\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n highlightedDataPoints: (string | number)[];\r\n maxValue?: number;\r\n minValue?: number;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n resetSelectionOnDoubleClick: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n animate: AnimateDataType;\r\n dimmedOpacity: number;\r\n customLayers: CustomLayerDataType[];\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n showLabels,\r\n colors,\r\n colorDomain,\r\n radius,\r\n leftMargin,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n axisTitles,\r\n highlightedDataPoints,\r\n selectedColor,\r\n minValue,\r\n maxValue,\r\n onSeriesMouseClick,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n animate,\r\n dimmedOpacity,\r\n customLayers,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: leftMargin,\r\n right: rightMargin,\r\n };\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minY = Math.min(Math.min(...data.map(d => d.y1)), Math.min(...data.map(d => d.y2)));\r\n const maxY = Math.max(Math.max(...data.map(d => d.y1)), Math.max(...data.map(d => d.y2)));\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? (minY > 0 ? 0 : minY) : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxY > 0 ? maxY : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n return (\r\n <>\r\n <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n className='mx-auto'\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n <g>\r\n <Axis\r\n y1={0}\r\n y2={graphHeight}\r\n x1={radius}\r\n x2={radius}\r\n classNames={{\r\n axis: cn(\r\n 'stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550',\r\n classNames?.yAxis?.axis,\r\n ),\r\n }}\r\n />\r\n <AxisTitle\r\n x={radius}\r\n y={graphHeight + 15}\r\n style={styles?.yAxis?.title}\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs',\r\n classNames?.yAxis?.title,\r\n )}\r\n text={axisTitles[0]}\r\n />\r\n </g>\r\n <g>\r\n <Axis\r\n y1={0}\r\n y2={graphHeight}\r\n x1={graphWidth - radius}\r\n x2={graphWidth - radius}\r\n classNames={{\r\n axis: cn(\r\n 'stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550',\r\n classNames?.yAxis?.axis,\r\n ),\r\n }}\r\n />\r\n <AxisTitle\r\n x={graphWidth - radius}\r\n y={graphHeight + 15}\r\n style={styles?.yAxis?.title}\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs',\r\n classNames?.yAxis?.title,\r\n )}\r\n text={axisTitles[1]}\r\n />\r\n </g>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <AnimatePresence>\r\n {data.map((d, i) => {\r\n return (\r\n <motion.g\r\n key={i}\r\n variants={{\r\n initial: {\r\n opacity: selectedColor\r\n ? d.color\r\n ? colors[colorDomain.indexOf(`${d.color}`)] === selectedColor\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : mouseOverData\r\n ? mouseOverData.label === d.label\r\n ? 1\r\n : dimmedOpacity\r\n : highlightedDataPoints.length !== 0\r\n ? highlightedDataPoints.indexOf(d.label) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n },\r\n whileInView: {\r\n opacity: selectedColor\r\n ? d.color\r\n ? colors[colorDomain.indexOf(`${d.color}`)] === selectedColor\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : mouseOverData\r\n ? mouseOverData.label === d.label\r\n ? 1\r\n : dimmedOpacity\r\n : highlightedDataPoints.length !== 0\r\n ? highlightedDataPoints.indexOf(d.label) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d);\r\n onSeriesMouseClick?.(d);\r\n }\r\n }\r\n }}\r\n >\r\n <motion.circle\r\n cx={radius}\r\n variants={{\r\n initial: {\r\n cy: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n cy: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n r={radius}\r\n style={{\r\n fillOpacity: 0.6,\r\n }}\r\n />\r\n {showLabels ? (\r\n <motion.text\r\n variants={{\r\n initial: {\r\n y: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n y: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n textAnchor: 'end',\r\n ...(styles?.yAxis?.labels || {}),\r\n }}\r\n className={cn('text-xs', classNames?.yAxis?.labels)}\r\n x={5}\r\n dy='0.33em'\r\n textAnchor='end'\r\n dx={0 - radius - 3}\r\n >\r\n {d.label}\r\n </motion.text>\r\n ) : highlightedDataPoints.length !== 0 ? (\r\n highlightedDataPoints.indexOf(d.label) !== -1 ? (\r\n <motion.text\r\n variants={{\r\n initial: {\r\n y: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n y: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n textAnchor: 'end',\r\n ...(styles?.yAxis?.labels || {}),\r\n }}\r\n className={cn('text-xs', classNames?.yAxis?.labels)}\r\n x={5}\r\n dy='0.33em'\r\n dx={-3}\r\n >\r\n {d.label}\r\n </motion.text>\r\n ) : null\r\n ) : null}\r\n <motion.circle\r\n cx={graphWidth - radius}\r\n variants={{\r\n initial: {\r\n cy: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n cy: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n r={radius}\r\n style={{\r\n fillOpacity: 0.6,\r\n }}\r\n />\r\n {showLabels ? (\r\n <motion.text\r\n variants={{\r\n initial: {\r\n y: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n y: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n textAnchor: 'start',\r\n ...(styles?.yAxis?.labels || {}),\r\n }}\r\n className={cn('text-xs', classNames?.yAxis?.labels)}\r\n x={graphWidth - 5}\r\n dy='0.33em'\r\n dx={radius + 3}\r\n >\r\n {d.label}\r\n </motion.text>\r\n ) : highlightedDataPoints.length !== 0 ? (\r\n highlightedDataPoints.indexOf(d.label) !== -1 ? (\r\n <motion.text\r\n variants={{\r\n initial: {\r\n y: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n y: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n textAnchor: 'start',\r\n ...(styles?.yAxis?.labels || {}),\r\n }}\r\n className={cn('text-xs', classNames?.yAxis?.labels)}\r\n x={graphWidth - 5}\r\n dy='0.33em'\r\n dx={3}\r\n >\r\n {d.label}\r\n </motion.text>\r\n ) : null\r\n ) : null}\r\n <motion.line\r\n x1={radius}\r\n x2={graphWidth - radius}\r\n variants={{\r\n initial: {\r\n y1: y(d.y1),\r\n y2: y(d.y1),\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n },\r\n whileInView: {\r\n y1: y(d.y1),\r\n y2: y(d.y2),\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n className={classNames?.dataConnectors}\r\n style={{\r\n fill: 'none',\r\n strokeWidth: 1,\r\n ...styles?.dataConnectors,\r\n }}\r\n />\r\n </motion.g>\r\n );\r\n })}\r\n </AnimatePresence>\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\r\n </g>\r\n </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n {detailsOnClick && mouseClickData !== undefined ? (\r\n <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 </>\r\n );\r\n}\r\n","import uniqBy from 'lodash.uniqby';\r\nimport { useState, useRef, useEffect } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n Languages,\r\n SlopeChartDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { ColorLegendWithMouseOver } from '@/Components/Elements/ColorLegendWithMouseOver';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: SlopeChartDataType[];\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 /** Color or array of colors for circles */\r\n colors?: string | string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: string[];\r\n /** Title for the color legend */\r\n colorLegendTitle?: 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 /** Left margin of the graph */\r\n leftMargin?: number;\r\n /** Right margin of the graph */\r\n rightMargin?: number;\r\n /** Top margin of the graph */\r\n topMargin?: number;\r\n /** Bottom margin of the graph */\r\n bottomMargin?: number;\r\n /** Toggles the background to fill the container. This only works if the width of the graph is defined. */\r\n fillContainer?: boolean;\r\n\r\n // Values and Ticks\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of labels */\r\n showLabels?: boolean;\r\n /** Radius of the circles */\r\n radius?: number;\r\n /** Title for the two axis */\r\n axisTitles?: [string, string];\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Toggle visibility of NA color in the color scale. This is only applicable if the data props hae color parameter and showColorScale prop is true */\r\n showNAColor?: boolean;\r\n /** Data points to highlight. Use the label value from data to highlight the data point */\r\n highlightedDataPoints?: (string | number)[];\r\n /** Defines the opacity of the non-highlighted data */\r\n dimmedOpacity?: number;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n /** Reset selection on double-click. Only applicable when used in a dashboard context with filters. */\r\n resetSelectionOnDoubleClick?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Details displayed on the modal when user clicks of a data point. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n /** Callback for mouse click event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function SlopeChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n colors,\r\n sources,\r\n graphDescription,\r\n showLabels = false,\r\n height,\r\n width,\r\n footNote,\r\n colorDomain,\r\n colorLegendTitle,\r\n radius = 5,\r\n axisTitles = ['', ''],\r\n padding,\r\n backgroundColor = false,\r\n leftMargin = 50,\r\n rightMargin = 50,\r\n topMargin = 20,\r\n bottomMargin = 20,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n showColorScale = true,\r\n highlightedDataPoints = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n onSeriesMouseClick,\r\n graphDownload = false,\r\n dataDownload = false,\r\n fillContainer = true,\r\n language = 'en',\r\n showNAColor = true,\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n animate = false,\r\n dimmedOpacity = 0.3,\r\n customLayers = [],\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [selectedColor, setSelectedColor] = useState<string | undefined>(undefined);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\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 || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'grow-0' : 'grow'} ${\r\n !fillContainer ? 'w-fit' : 'w-full'\r\n } `}\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 classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a slope chart showing changes in data between two category or starting and ending time. Each line represents a different row in data, with lines sloping up or down to show increase or decrease over two categories or time.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n {data.length === 0 ? (\r\n <EmptyState />\r\n ) : (\r\n <>\r\n {showColorScale && data.filter(el => el.color).length !== 0 ? (\r\n <ColorLegendWithMouseOver\r\n width={width}\r\n colorLegendTitle={colorLegendTitle}\r\n colors={\r\n (colors as string[] | undefined) || Colors[theme].categoricalColors.colors\r\n }\r\n colorDomain={\r\n colorDomain ||\r\n (uniqBy(\r\n data.filter(el => el.color),\r\n 'color',\r\n ).map(d => d.color) as string[])\r\n }\r\n setSelectedColor={setSelectedColor}\r\n showNAColor={showNAColor}\r\n />\r\n ) : null}\r\n <div\r\n className='flex flex-col grow justify-center w-full leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data.filter(\r\n d => !checkIfNullOrUndefined(d.y1) && !checkIfNullOrUndefined(d.y2),\r\n )}\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 colorDomain={\r\n data.filter(el => el.color).length === 0\r\n ? []\r\n : colorDomain ||\r\n (uniqBy(\r\n data.filter(el => el.color),\r\n 'color',\r\n ).map(d => d.color) as string[])\r\n }\r\n colors={\r\n data.filter(el => el.color).length === 0\r\n ? colors\r\n ? [colors as string]\r\n : [Colors.primaryColors['blue-600']]\r\n : (colors as string[] | undefined) ||\r\n Colors[theme].categoricalColors.colors\r\n }\r\n selectedColor={selectedColor}\r\n axisTitles={axisTitles}\r\n showLabels={showLabels}\r\n radius={radius}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n highlightedDataPoints={highlightedDataPoints}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n detailsOnClick={detailsOnClick}\r\n styles={styles}\r\n classNames={classNames}\r\n animate={\r\n animate === true\r\n ? { duration: 0.5, once: true, amount: 0.5 }\r\n : animate || { duration: 0, once: true, amount: 0 }\r\n }\r\n dimmedOpacity={dimmedOpacity}\r\n customLayers={customLayers}\r\n />\r\n ) : null}\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n"],"names":["Graph","props","data","width","height","showLabels","colors","colorDomain","radius","leftMargin","rightMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","axisTitles","highlightedDataPoints","selectedColor","minValue","maxValue","onSeriesMouseClick","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","animate","dimmedOpacity","customLayers","svgRef","useRef","isInView","useInView","mouseOverData","setMouseOverData","useState","mouseClickData","setMouseClickData","eventX","setEventX","eventY","setEventY","margin","graphWidth","graphHeight","minY","d","maxY","scaleLinear","checkIfNullOrUndefined","jsxs","Fragment","jsx","motion","Axis","cn","AxisTitle","AnimatePresence","i","event","isEqual","el","Colors","Tooltip","Modal","string2HTML","SlopeChart","graphTitle","sources","graphDescription","footNote","colorLegendTitle","padding","backgroundColor","relativeHeight","showColorScale","graphID","graphDownload","dataDownload","fillContainer","language","showNAColor","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","setSelectedColor","graphDiv","graphParentDiv","useEffect","resizeObserver","entries","GraphHeader","EmptyState","ColorLegendWithMouseOver","uniqBy","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDO,SAASA,GAAMC,GAAc;AAClC,QAAM;AAAA,IACJ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AAU,CAAC,IAClCvD,KACDuD,EAAOqB,CAAK,EAAE,kBAAkB;AAAA,0BAEtC,eAAAjE;AAAA,0BACA,YAAAF;AAAA,0BACA,YAAAV;AAAA,0BACA,QAAAG;AAAA,0BACA,YAAAC;AAAA,0BACA,aAAAC;AAAA,0BACA,WAAAC;AAAA,0BACA,cAAAC;AAAA,0BACA,SAAAC;AAAA,0BACA,mBAAAC;AAAA,0BACA,uBAAAE;AAAA,0BACA,UAAAE;AAAA,0BACA,UAAAC;AAAA,0BACA,oBAAAC;AAAA,0BACA,6BAAAC;AAAA,0BACA,gBAAAC;AAAA,0BACA,QAAAC;AAAA,0BACA,YAAAC;AAAA,0BACA,SACEC,MAAY,KACR,EAAE,UAAU,KAAK,MAAM,IAAM,QAAQ,IAAA,IACrCA,KAAW,EAAE,UAAU,GAAG,MAAM,IAAM,QAAQ,EAAA;AAAA,0BAEpD,eAAAC;AAAA,0BACA,cAAAC;AAAA,wBAAA;AAAA,sBAAA,IAEA;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACN,EAAA,CACF,EAAA,CAEJ;AAAA,gBACCwC,KAAWE,IACVlB,gBAAAA,EAAAA;AAAAA,kBAAC+C;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAU3E,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAA2C;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAAlE;AAAA,kBAAA;AAAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"SlopeChart.js","sources":["../src/Components/Graphs/SlopeChart/Graph.tsx","../src/Components/Graphs/SlopeChart/index.tsx"],"sourcesContent":["import isEqual from 'fast-deep-equal';\r\nimport { useRef, useState } from 'react';\r\nimport { scaleLinear } from 'd3-scale';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { Modal } from '@undp/design-system-react/Modal';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport {\r\n AnimateDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n SlopeChartDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { string2HTML } from '@/Utils/string2HTML';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\n\r\ninterface Props {\r\n data: SlopeChartDataType[];\r\n width: number;\r\n height: number;\r\n selectedColor?: string;\r\n showLabels: boolean;\r\n colors: string[];\r\n colorDomain: string[];\r\n radius: number;\r\n leftMargin: number;\r\n rightMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n axisTitles: [string, string];\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n highlightedDataPoints: (string | number)[];\r\n maxValue?: number;\r\n minValue?: number;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n resetSelectionOnDoubleClick: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n animate: AnimateDataType;\r\n dimmedOpacity: number;\r\n customLayers: CustomLayerDataType[];\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n showLabels,\r\n colors,\r\n colorDomain,\r\n radius,\r\n leftMargin,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n axisTitles,\r\n highlightedDataPoints,\r\n selectedColor,\r\n minValue,\r\n maxValue,\r\n onSeriesMouseClick,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n animate,\r\n dimmedOpacity,\r\n customLayers,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: leftMargin,\r\n right: rightMargin,\r\n };\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minY = Math.min(Math.min(...data.map(d => d.y1)), Math.min(...data.map(d => d.y2)));\r\n const maxY = Math.max(Math.max(...data.map(d => d.y1)), Math.max(...data.map(d => d.y2)));\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? (minY > 0 ? 0 : minY) : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxY > 0 ? maxY : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n return (\r\n <>\r\n <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n className='mx-auto'\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n <g>\r\n <Axis\r\n y1={0}\r\n y2={graphHeight}\r\n x1={radius}\r\n x2={radius}\r\n classNames={{\r\n axis: cn(\r\n 'stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550',\r\n classNames?.yAxis?.axis,\r\n ),\r\n }}\r\n />\r\n <AxisTitle\r\n x={radius}\r\n y={graphHeight + 15}\r\n style={styles?.yAxis?.title}\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs',\r\n classNames?.yAxis?.title,\r\n )}\r\n text={axisTitles[0]}\r\n />\r\n </g>\r\n <g>\r\n <Axis\r\n y1={0}\r\n y2={graphHeight}\r\n x1={graphWidth - radius}\r\n x2={graphWidth - radius}\r\n classNames={{\r\n axis: cn(\r\n 'stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550',\r\n classNames?.yAxis?.axis,\r\n ),\r\n }}\r\n />\r\n <AxisTitle\r\n x={graphWidth - radius}\r\n y={graphHeight + 15}\r\n style={styles?.yAxis?.title}\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs',\r\n classNames?.yAxis?.title,\r\n )}\r\n text={axisTitles[1]}\r\n />\r\n </g>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <AnimatePresence>\r\n {data.map((d, i) => {\r\n return (\r\n <motion.g\r\n key={i}\r\n variants={{\r\n initial: {\r\n opacity: selectedColor\r\n ? d.color\r\n ? colors[colorDomain.indexOf(`${d.color}`)] === selectedColor\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : mouseOverData\r\n ? mouseOverData.label === d.label\r\n ? 1\r\n : dimmedOpacity\r\n : highlightedDataPoints.length !== 0\r\n ? highlightedDataPoints.indexOf(d.label) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n },\r\n whileInView: {\r\n opacity: selectedColor\r\n ? d.color\r\n ? colors[colorDomain.indexOf(`${d.color}`)] === selectedColor\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : mouseOverData\r\n ? mouseOverData.label === d.label\r\n ? 1\r\n : dimmedOpacity\r\n : highlightedDataPoints.length !== 0\r\n ? highlightedDataPoints.indexOf(d.label) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d);\r\n onSeriesMouseClick?.(d);\r\n }\r\n }\r\n }}\r\n >\r\n <motion.circle\r\n cx={radius}\r\n variants={{\r\n initial: {\r\n cy: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n cy: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n r={radius}\r\n style={{\r\n fillOpacity: 0.6,\r\n }}\r\n />\r\n {showLabels ? (\r\n <motion.text\r\n variants={{\r\n initial: {\r\n y: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n y: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n textAnchor: 'end',\r\n ...(styles?.yAxis?.labels || {}),\r\n }}\r\n className={cn('text-xs', classNames?.yAxis?.labels)}\r\n x={5}\r\n dy='0.33em'\r\n textAnchor='end'\r\n dx={0 - radius - 3}\r\n >\r\n {d.label}\r\n </motion.text>\r\n ) : highlightedDataPoints.length !== 0 ? (\r\n highlightedDataPoints.indexOf(d.label) !== -1 ? (\r\n <motion.text\r\n variants={{\r\n initial: {\r\n y: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n y: y(d.y1),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n textAnchor: 'end',\r\n ...(styles?.yAxis?.labels || {}),\r\n }}\r\n className={cn('text-xs', classNames?.yAxis?.labels)}\r\n x={5}\r\n dy='0.33em'\r\n dx={-3}\r\n >\r\n {d.label}\r\n </motion.text>\r\n ) : null\r\n ) : null}\r\n <motion.circle\r\n cx={graphWidth - radius}\r\n variants={{\r\n initial: {\r\n cy: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n cy: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n r={radius}\r\n style={{\r\n fillOpacity: 0.6,\r\n }}\r\n />\r\n {showLabels ? (\r\n <motion.text\r\n variants={{\r\n initial: {\r\n y: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n y: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n textAnchor: 'start',\r\n ...(styles?.yAxis?.labels || {}),\r\n }}\r\n className={cn('text-xs', classNames?.yAxis?.labels)}\r\n x={graphWidth - 5}\r\n dy='0.33em'\r\n dx={radius + 3}\r\n >\r\n {d.label}\r\n </motion.text>\r\n ) : highlightedDataPoints.length !== 0 ? (\r\n highlightedDataPoints.indexOf(d.label) !== -1 ? (\r\n <motion.text\r\n variants={{\r\n initial: {\r\n y: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n y: y(d.y2),\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n style={{\r\n textAnchor: 'start',\r\n ...(styles?.yAxis?.labels || {}),\r\n }}\r\n className={cn('text-xs', classNames?.yAxis?.labels)}\r\n x={graphWidth - 5}\r\n dy='0.33em'\r\n dx={3}\r\n >\r\n {d.label}\r\n </motion.text>\r\n ) : null\r\n ) : null}\r\n <motion.line\r\n x1={radius}\r\n x2={graphWidth - radius}\r\n variants={{\r\n initial: {\r\n y1: y(d.y1),\r\n y2: y(d.y1),\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n },\r\n whileInView: {\r\n y1: y(d.y1),\r\n y2: y(d.y2),\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? colors[0]\r\n : !d.color\r\n ? Colors.gray\r\n : colors[colorDomain.indexOf(`${d.color}`)],\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n className={classNames?.dataConnectors}\r\n style={{\r\n fill: 'none',\r\n strokeWidth: 1,\r\n ...styles?.dataConnectors,\r\n }}\r\n />\r\n </motion.g>\r\n );\r\n })}\r\n </AnimatePresence>\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\r\n </g>\r\n </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n {detailsOnClick && mouseClickData !== undefined ? (\r\n <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 </>\r\n );\r\n}\r\n","import uniqBy from 'lodash.uniqby';\r\nimport { useState, useRef, useEffect } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n Languages,\r\n SlopeChartDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { ColorLegendWithMouseOver } from '@/Components/Elements/ColorLegendWithMouseOver';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: SlopeChartDataType[];\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 /** Color or array of colors for circles */\r\n colors?: string | string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: string[];\r\n /** Title for the color legend */\r\n colorLegendTitle?: 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 /** Left margin of the graph */\r\n leftMargin?: number;\r\n /** Right margin of the graph */\r\n rightMargin?: number;\r\n /** Top margin of the graph */\r\n topMargin?: number;\r\n /** Bottom margin of the graph */\r\n bottomMargin?: number;\r\n /** Toggles the background to fill the container. This only works if the width of the graph is defined. */\r\n fillContainer?: boolean;\r\n\r\n // Values and Ticks\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of labels */\r\n showLabels?: boolean;\r\n /** Radius of the circles */\r\n radius?: number;\r\n /** Title for the two axis */\r\n axisTitles?: [string, string];\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Toggle visibility of NA color in the color scale. This is only applicable if the data props hae color parameter and showColorScale prop is true */\r\n showNAColor?: boolean;\r\n /** Data points to highlight. Use the label value from data to highlight the data point */\r\n highlightedDataPoints?: (string | number)[];\r\n /** Defines the opacity of the non-highlighted data */\r\n dimmedOpacity?: number;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n /** Reset selection on double-click. Only applicable when used in a dashboard context with filters. */\r\n resetSelectionOnDoubleClick?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Details displayed on the modal when user clicks of a data point. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n /** Callback for mouse click event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function SlopeChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n colors,\r\n sources,\r\n graphDescription,\r\n showLabels = false,\r\n height,\r\n width,\r\n footNote,\r\n colorDomain,\r\n colorLegendTitle,\r\n radius = 5,\r\n axisTitles = ['', ''],\r\n padding,\r\n backgroundColor = false,\r\n leftMargin = 50,\r\n rightMargin = 50,\r\n topMargin = 20,\r\n bottomMargin = 20,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n showColorScale = true,\r\n highlightedDataPoints = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n onSeriesMouseClick,\r\n graphDownload = false,\r\n dataDownload = false,\r\n fillContainer = true,\r\n language = 'en',\r\n showNAColor = true,\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n animate = false,\r\n dimmedOpacity = 0.3,\r\n customLayers = [],\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [selectedColor, setSelectedColor] = useState<string | undefined>(undefined);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\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 || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'grow-0' : 'grow'} ${\r\n !fillContainer ? 'w-fit' : 'w-full'\r\n } `}\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 !fillContainer ? 'w-fit' : 'w-full',\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a slope chart showing changes in data between two category or starting and ending time. Each line represents a different row in data, with lines sloping up or down to show increase or decrease over two categories or time.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n {data.length === 0 ? (\r\n <EmptyState />\r\n ) : (\r\n <>\r\n {showColorScale && data.filter(el => el.color).length !== 0 ? (\r\n <ColorLegendWithMouseOver\r\n width={width}\r\n colorLegendTitle={colorLegendTitle}\r\n colors={\r\n (colors as string[] | undefined) || Colors[theme].categoricalColors.colors\r\n }\r\n colorDomain={\r\n colorDomain ||\r\n (uniqBy(\r\n data.filter(el => el.color),\r\n 'color',\r\n ).map(d => d.color) as string[])\r\n }\r\n setSelectedColor={setSelectedColor}\r\n showNAColor={showNAColor}\r\n />\r\n ) : null}\r\n <div\r\n className='flex flex-col grow justify-center w-full leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data.filter(\r\n d => !checkIfNullOrUndefined(d.y1) && !checkIfNullOrUndefined(d.y2),\r\n )}\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 colorDomain={\r\n data.filter(el => el.color).length === 0\r\n ? []\r\n : colorDomain ||\r\n (uniqBy(\r\n data.filter(el => el.color),\r\n 'color',\r\n ).map(d => d.color) as string[])\r\n }\r\n colors={\r\n data.filter(el => el.color).length === 0\r\n ? colors\r\n ? [colors as string]\r\n : [Colors.primaryColors['blue-600']]\r\n : (colors as string[] | undefined) ||\r\n Colors[theme].categoricalColors.colors\r\n }\r\n selectedColor={selectedColor}\r\n axisTitles={axisTitles}\r\n showLabels={showLabels}\r\n radius={radius}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n highlightedDataPoints={highlightedDataPoints}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n detailsOnClick={detailsOnClick}\r\n styles={styles}\r\n classNames={classNames}\r\n animate={\r\n animate === true\r\n ? { duration: 0.5, once: true, amount: 0.5 }\r\n : animate || { duration: 0, once: true, amount: 0 }\r\n }\r\n dimmedOpacity={dimmedOpacity}\r\n customLayers={customLayers}\r\n />\r\n ) : null}\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n"],"names":["Graph","props","data","width","height","showLabels","colors","colorDomain","radius","leftMargin","rightMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","axisTitles","highlightedDataPoints","selectedColor","minValue","maxValue","onSeriesMouseClick","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","animate","dimmedOpacity","customLayers","svgRef","useRef","isInView","useInView","mouseOverData","setMouseOverData","useState","mouseClickData","setMouseClickData","eventX","setEventX","eventY","setEventY","margin","graphWidth","graphHeight","minY","d","maxY","scaleLinear","checkIfNullOrUndefined","jsxs","Fragment","jsx","motion","Axis","cn","AxisTitle","AnimatePresence","i","event","isEqual","el","Colors","Tooltip","Modal","string2HTML","SlopeChart","graphTitle","sources","graphDescription","footNote","colorLegendTitle","padding","backgroundColor","relativeHeight","showColorScale","graphID","graphDownload","dataDownload","fillContainer","language","showNAColor","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","setSelectedColor","graphDiv","graphParentDiv","useEffect","resizeObserver","entries","GraphHeader","EmptyState","ColorLegendWithMouseOver","uniqBy","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDO,SAASA,GAAMC,GAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA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E,kBAAkB;AAAA,0BAEtC,eAAAjE;AAAA,0BACA,YAAAF;AAAA,0BACA,YAAAV;AAAA,0BACA,QAAAG;AAAA,0BACA,YAAAC;AAAA,0BACA,aAAAC;AAAA,0BACA,WAAAC;AAAA,0BACA,cAAAC;AAAA,0BACA,SAAAC;AAAA,0BACA,mBAAAC;AAAA,0BACA,uBAAAE;AAAA,0BACA,UAAAE;AAAA,0BACA,UAAAC;AAAA,0BACA,oBAAAC;AAAA,0BACA,6BAAAC;AAAA,0BACA,gBAAAC;AAAA,0BACA,QAAAC;AAAA,0BACA,YAAAC;AAAA,0BACA,SACEC,MAAY,KACR,EAAE,UAAU,KAAK,MAAM,IAAM,QAAQ,IAAA,IACrCA,KAAW,EAAE,UAAU,GAAG,MAAM,IAAM,QAAQ,EAAA;AAAA,0BAEpD,eAAAC;AAAA,0BACA,cAAAC;AAAA,wBAAA;AAAA,sBAAA,IAEA;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACN,EAAA,CACF,EAAA,CAEJ;AAAA,gBACCwC,KAAWE,IACVlB,gBAAAA,EAAAA;AAAAA,kBAAC+C;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAU3E,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAA2C;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAAlE;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"),l=require("react"),B=require("./parse-hMnG_lRV.cjs"),K=require("./index-BzeLQvXk.cjs"),Q=require("./Tooltip-n8z5bfav.cjs"),U=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Z=require("./time-Byw_jYQ7.cjs"),_=require("./linear-BVckp9RD.cjs"),ee=require("./area-D3Qx7k7K.cjs"),z=require("./line-DHV4JwCR.cjs"),T=require("./step-BZ3C8QFW.cjs"),te=require("./select-Bnfk0lJx.cjs"),re=require("./init-DU0ybBc_.cjs"),se=require("./pointer-Dkq5NV1q.cjs"),ie=require("./GraphFooter.cjs"),oe=require("./GraphHeader.cjs"),ae=require("./Colors.cjs"),ne=require("./generateRandomString-B5zBiJzS.cjs");function le(F){const{data:y,width:c,height:E,lineColor:p,dateFormat:x,areaId:u,leftMargin:s,rightMargin:$,topMargin:L,bottomMargin:W,tooltip:b,onSeriesMouseOver:o,minValue:C,maxValue:k,curveType:v,styles:w,classNames:M,customLayers:m}=F,D=v==="linear"?z.curveLinear:v==="step"?T.curveStep:v==="stepAfter"?T.stepAfter:v==="stepBefore"?T.stepBefore:T.monotoneX,[h,O]=l.useState(void 0),[H,q]=l.useState(void 0),[S,j]=l.useState(void 0),a={top:L,bottom:W,left:s,right:$},A=l.useRef(null),r=K.sortBy(y.map(e=>({...e,date:B.parse(`${e.date}`,x,new Date)})),"date"),G=c-a.left-a.right,i=E-a.top-a.bottom,d=r[0].date,V=r[r.length-1].date,g=Math.min(...r.map(e=>e.y).filter(e=>e!=null))!==1/0?Math.min(...r.map(e=>e.y).filter(e=>e!=null))>0?0:Math.min(...r.map(e=>e.y).filter(e=>e!=null)):0,N=Math.max(...r.map(e=>e.y).filter(e=>e!=null))!==1/0?Math.max(...r.map(e=>e.y).filter(e=>e!=null)):0,n=Z.time().domain([d,V]).range([0,G]),R=_.linear().domain([U.checkIfNullOrUndefined(C)?g:C,U.checkIfNullOrUndefined(k)?N>0?N:0:k]).range([i,0]).nice(),f=ee.area().x(e=>n(e.date)).y1(e=>R(e.y)).y0(i).curve(D),I=z.line().x(e=>n(e.date)).y(e=>R(e.y)).curve(D);return l.useEffect(()=>{const e=Y=>{const X=r[re.bisectCenter(r.map(J=>J.date),n.invert(se.pointer(Y)[0]),0)];O(X||r[r.length-1]),o?.(X||r[r.length-1]),j(Y.clientY),q(Y.clientX)},P=()=>{O(void 0),o?.(void 0),q(void 0),j(void 0)};te.select(A.current).on("mousemove",e).on("mouseout",P),o?.(void 0)},[n,r,o]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("svg",{width:`${c}px`,height:`${E}px`,viewBox:`0 0 ${c} ${E}`,direction:"ltr",children:[u?t.jsxRuntimeExports.jsxs("linearGradient",{id:u,x1:"0",x2:"0",y1:"0",y2:"1",children:[t.jsxRuntimeExports.jsx("stop",{style:{stopColor:p},stopOpacity:"0.1",offset:"0%"}),t.jsxRuntimeExports.jsx("stop",{style:{stopColor:p},stopOpacity:"0",offset:"100%"})]}):null,t.jsxRuntimeExports.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[m.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx("text",{className:t.mo("xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs",M?.xAxis?.labels),y:i,x:n(r[r.length-1].date),style:{textAnchor:"end",...w?.xAxis?.labels},dy:"1em",children:B.format(r[r.length-1].date,x)}),t.jsxRuntimeExports.jsx("text",{y:i,x:n(r[0].date),style:{textAnchor:"start",...w?.xAxis?.labels},className:t.mo("xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs",M?.xAxis?.labels),dy:"1em",children:B.format(r[0].date,x)})]}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx("path",{d:f(r)||"",style:{fill:`url(#${u})`,clipPath:"url(#clip)"}}),t.jsxRuntimeExports.jsx("path",{d:I(r)||"",style:{stroke:p,fill:"none",strokeWidth:2}}),h?t.jsxRuntimeExports.jsx("circle",{y1:0,cy:R(h.y),cx:n(h.date),r:5,style:{fill:p}}):null]}),m.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:A,style:{fill:"none",pointerEvents:"all"},width:G,height:i})]})]}),h&&b&&H&&S?t.jsxRuntimeExports.jsx(Q.Tooltip,{data:h,body:b,xPos:H,yPos:S,backgroundStyle:w?.tooltip,className:M?.tooltip}):null]})}function ce(F){const{data:y,graphTitle:c,lineColor:E,sources:p,graphDescription:x,height:u,width:s,footNote:$,dateFormat:L="yyyy",area:W=!1,padding:b,backgroundColor:o,leftMargin:C=5,rightMargin:k=5,topMargin:v=10,bottomMargin:w=20,tooltip:M,relativeHeight:m,onSeriesMouseOver:D,graphID:h,minValue:O,maxValue:H,graphDownload:q=!1,dataDownload:S=!1,language:j="en",minHeight:a=0,theme:A="light",ariaLabel:r,curveType:G="curve",styles:i,classNames:d,customLayers:V=[]}=F,[g,N]=l.useState(0),[n,R]=l.useState(0),f=l.useRef(null),I=l.useRef(null);return l.useEffect(()=>{const e=new ResizeObserver(P=>{N(s||P[0].target.clientWidth||620),R(u||P[0].target.clientHeight||480)});return f.current&&(R(f.current.clientHeight||480),N(f.current.clientWidth||620),s||e.observe(f.current)),()=>e.disconnect()},[s,u]),t.jsxRuntimeExports.jsx("div",{className:`${A||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:j==="he"||j==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${o?o===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${j||"en"}`,d?.graphContainer),style:{...i?.graphContainer||{},...o&&o!==!0?{backgroundColor:o}:{}},id:h,ref:I,"aria-label":r||`${c?`The graph shows ${c}. `:""}This is a line chart that show trends over time.${x?` ${x}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:o?b||"1rem":b||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[c||x||q||S?t.jsxRuntimeExports.jsx(oe.GraphHeader,{styles:{title:i?.title,description:i?.description},classNames:{title:d?.title,description:d?.description},graphTitle:c,graphDescription:x,width:s,graphDownload:q?I.current:void 0,dataDownload:S?y.map(e=>e.data).filter(e=>e!==void 0).length>0?y.map(e=>e.data).filter(e=>e!==void 0):y.filter(e=>e!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:f,"aria-label":"Graph area",children:(s||g)&&(u||n)?t.jsxRuntimeExports.jsx(le,{data:y,lineColor:E||ae.Colors.primaryColors["blue-600"],width:s||g,height:Math.max(a,u||(m?a?(s||g)*m>a?(s||g)*m:a:(s||g)*m:n)),dateFormat:L,areaId:W?ne.generateRandomString(8):void 0,leftMargin:C,rightMargin:k,topMargin:v,bottomMargin:w,tooltip:M,onSeriesMouseOver:D,minValue:O,maxValue:H,curveType:G,styles:i,classNames:d,customLayers:V}):null}),p||$?t.jsxRuntimeExports.jsx(ie.GraphFooter,{styles:{footnote:i?.footnote,source:i?.source},classNames:{footnote:d?.footnote,source:d?.source},sources:p,footNote:$,width:s}):null]})})})})}exports.SparkLine=ce;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),l=require("react"),B=require("./parse-hMnG_lRV.cjs"),K=require("./index-BzeLQvXk.cjs"),Q=require("./Tooltip-n8z5bfav.cjs"),U=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Z=require("./time-Byw_jYQ7.cjs"),_=require("./linear-BVckp9RD.cjs"),ee=require("./area-D3Qx7k7K.cjs"),z=require("./line-DHV4JwCR.cjs"),T=require("./step-BZ3C8QFW.cjs"),te=require("./select-Bnfk0lJx.cjs"),re=require("./init-DU0ybBc_.cjs"),se=require("./pointer-Dkq5NV1q.cjs"),ie=require("./GraphFooter.cjs"),oe=require("./GraphHeader.cjs"),ae=require("./Colors.cjs"),ne=require("./generateRandomString-B5zBiJzS.cjs");function le(F){const{data:y,width:c,height:E,lineColor:p,dateFormat:u,areaId:x,leftMargin:s,rightMargin:$,topMargin:L,bottomMargin:W,tooltip:w,onSeriesMouseOver:o,minValue:C,maxValue:k,curveType:v,styles:b,classNames:M,customLayers:m}=F,D=v==="linear"?z.curveLinear:v==="step"?T.curveStep:v==="stepAfter"?T.stepAfter:v==="stepBefore"?T.stepBefore:T.monotoneX,[h,O]=l.useState(void 0),[H,q]=l.useState(void 0),[S,j]=l.useState(void 0),a={top:L,bottom:W,left:s,right:$},A=l.useRef(null),r=K.sortBy(y.map(e=>({...e,date:B.parse(`${e.date}`,u,new Date)})),"date"),G=c-a.left-a.right,i=E-a.top-a.bottom,d=r[0].date,V=r[r.length-1].date,g=Math.min(...r.map(e=>e.y).filter(e=>e!=null))!==1/0?Math.min(...r.map(e=>e.y).filter(e=>e!=null))>0?0:Math.min(...r.map(e=>e.y).filter(e=>e!=null)):0,N=Math.max(...r.map(e=>e.y).filter(e=>e!=null))!==1/0?Math.max(...r.map(e=>e.y).filter(e=>e!=null)):0,n=Z.time().domain([d,V]).range([0,G]),R=_.linear().domain([U.checkIfNullOrUndefined(C)?g:C,U.checkIfNullOrUndefined(k)?N>0?N:0:k]).range([i,0]).nice(),f=ee.area().x(e=>n(e.date)).y1(e=>R(e.y)).y0(i).curve(D),I=z.line().x(e=>n(e.date)).y(e=>R(e.y)).curve(D);return l.useEffect(()=>{const e=Y=>{const X=r[re.bisectCenter(r.map(J=>J.date),n.invert(se.pointer(Y)[0]),0)];O(X||r[r.length-1]),o?.(X||r[r.length-1]),j(Y.clientY),q(Y.clientX)},P=()=>{O(void 0),o?.(void 0),q(void 0),j(void 0)};te.select(A.current).on("mousemove",e).on("mouseout",P),o?.(void 0)},[n,r,o]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("svg",{width:`${c}px`,height:`${E}px`,viewBox:`0 0 ${c} ${E}`,direction:"ltr",children:[x?t.jsxRuntimeExports.jsxs("linearGradient",{id:x,x1:"0",x2:"0",y1:"0",y2:"1",children:[t.jsxRuntimeExports.jsx("stop",{style:{stopColor:p},stopOpacity:"0.1",offset:"0%"}),t.jsxRuntimeExports.jsx("stop",{style:{stopColor:p},stopOpacity:"0",offset:"100%"})]}):null,t.jsxRuntimeExports.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[m.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx("text",{className:t.mo("xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs",M?.xAxis?.labels),y:i,x:n(r[r.length-1].date),style:{textAnchor:"end",...b?.xAxis?.labels},dy:"1em",children:B.format(r[r.length-1].date,u)}),t.jsxRuntimeExports.jsx("text",{y:i,x:n(r[0].date),style:{textAnchor:"start",...b?.xAxis?.labels},className:t.mo("xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs",M?.xAxis?.labels),dy:"1em",children:B.format(r[0].date,u)})]}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx("path",{d:f(r)||"",style:{fill:`url(#${x})`,clipPath:"url(#clip)"}}),t.jsxRuntimeExports.jsx("path",{d:I(r)||"",style:{stroke:p,fill:"none",strokeWidth:2}}),h?t.jsxRuntimeExports.jsx("circle",{y1:0,cy:R(h.y),cx:n(h.date),r:5,style:{fill:p}}):null]}),m.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:A,style:{fill:"none",pointerEvents:"all"},width:G,height:i})]})]}),h&&w&&H&&S?t.jsxRuntimeExports.jsx(Q.Tooltip,{data:h,body:w,xPos:H,yPos:S,backgroundStyle:b?.tooltip,className:M?.tooltip}):null]})}function ce(F){const{data:y,graphTitle:c,lineColor:E,sources:p,graphDescription:u,height:x,width:s,footNote:$,dateFormat:L="yyyy",area:W=!1,padding:w,backgroundColor:o,leftMargin:C=5,rightMargin:k=5,topMargin:v=10,bottomMargin:b=20,tooltip:M,relativeHeight:m,onSeriesMouseOver:D,graphID:h,minValue:O,maxValue:H,graphDownload:q=!1,dataDownload:S=!1,language:j="en",minHeight:a=0,theme:A="light",ariaLabel:r,curveType:G="curve",styles:i,classNames:d,customLayers:V=[]}=F,[g,N]=l.useState(0),[n,R]=l.useState(0),f=l.useRef(null),I=l.useRef(null);return l.useEffect(()=>{const e=new ResizeObserver(P=>{N(s||P[0].target.clientWidth||620),R(x||P[0].target.clientHeight||480)});return f.current&&(R(f.current.clientHeight||480),N(f.current.clientWidth||620),s||e.observe(f.current)),()=>e.disconnect()},[s,x]),t.jsxRuntimeExports.jsx("div",{className:`${A||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:j==="he"||j==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${o?o===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${j||"en"}`,s?"w-fit":"w-full",d?.graphContainer),style:{...i?.graphContainer||{},...o&&o!==!0?{backgroundColor:o}:{}},id:h,ref:I,"aria-label":r||`${c?`The graph shows ${c}. `:""}This is a line chart that show trends over time.${u?` ${u}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:o?w||"1rem":w||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[c||u||q||S?t.jsxRuntimeExports.jsx(oe.GraphHeader,{styles:{title:i?.title,description:i?.description},classNames:{title:d?.title,description:d?.description},graphTitle:c,graphDescription:u,width:s,graphDownload:q?I.current:void 0,dataDownload:S?y.map(e=>e.data).filter(e=>e!==void 0).length>0?y.map(e=>e.data).filter(e=>e!==void 0):y.filter(e=>e!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:f,"aria-label":"Graph area",children:(s||g)&&(x||n)?t.jsxRuntimeExports.jsx(le,{data:y,lineColor:E||ae.Colors.primaryColors["blue-600"],width:s||g,height:Math.max(a,x||(m?a?(s||g)*m>a?(s||g)*m:a:(s||g)*m:n)),dateFormat:L,areaId:W?ne.generateRandomString(8):void 0,leftMargin:C,rightMargin:k,topMargin:v,bottomMargin:b,tooltip:M,onSeriesMouseOver:D,minValue:O,maxValue:H,curveType:G,styles:i,classNames:d,customLayers:V}):null}),p||$?t.jsxRuntimeExports.jsx(ie.GraphFooter,{styles:{footnote:i?.footnote,source:i?.source},classNames:{footnote:d?.footnote,source:d?.source},sources:p,footNote:$,width:s}):null]})})})})}exports.SparkLine=ce;
2
2
  //# sourceMappingURL=SparkLine.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"SparkLine.cjs","sources":["../src/Components/Graphs/LineCharts/SparkLine/Graph.tsx","../src/Components/Graphs/LineCharts/SparkLine/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveMonotoneX,\r\n area,\r\n curveLinear,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport sortBy from 'lodash.sortby';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport {\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n LineChartDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\n\r\ninterface Props {\r\n data: LineChartDataType[];\r\n lineColor: string;\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n areaId?: string;\r\n leftMargin: number;\r\n rightMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n maxValue?: number;\r\n minValue?: number;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n customLayers: CustomLayerDataType[];\r\n}\r\n\r\ninterface FormattedDataType {\r\n y: number;\r\n date: Date;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n lineColor,\r\n dateFormat,\r\n areaId,\r\n leftMargin,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n minValue,\r\n maxValue,\r\n curveType,\r\n styles,\r\n classNames,\r\n customLayers,\r\n } = props;\r\n const curve =\r\n curveType === 'linear'\r\n ? curveLinear\r\n : curveType === 'step'\r\n ? curveStep\r\n : curveType === 'stepAfter'\r\n ? curveStepAfter\r\n : curveType === 'stepBefore'\r\n ? curveStepBefore\r\n : curveMonotoneX;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: leftMargin,\r\n right: rightMargin,\r\n };\r\n const MouseoverRectRef = useRef(null);\r\n const dataFormatted = sortBy(\r\n data.map(d => ({\r\n ...d,\r\n date: parse(`${d.date}`, dateFormat, new Date()),\r\n })),\r\n 'date',\r\n );\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minYear = dataFormatted[0].date;\r\n const maxYear = dataFormatted[dataFormatted.length - 1].date;\r\n const minParam: number =\r\n Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !== Infinity\r\n ? Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) > 0\r\n ? 0\r\n : Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null))\r\n : 0;\r\n const maxParam: number =\r\n Math.max(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !== Infinity\r\n ? Math.max(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null))\r\n : 0;\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? minParam : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxParam > 0 ? maxParam : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n\r\n const mainGraphArea = area<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y1(d => y(d.y))\r\n .y0(graphHeight)\r\n .curve(curve);\r\n const lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n useEffect(() => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const mousemove = (event: any) => {\r\n const selectedData =\r\n dataFormatted[\r\n bisectCenter(\r\n dataFormatted.map(d => d.date),\r\n x.invert(pointer(event)[0]),\r\n 0,\r\n )\r\n ];\r\n setMouseOverData(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n onSeriesMouseOver?.(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n };\r\n const mouseout = () => {\r\n setMouseOverData(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n return (\r\n <>\r\n <svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n >\r\n {areaId ? (\r\n <linearGradient id={areaId} x1='0' x2='0' y1='0' y2='1'>\r\n <stop style={{ stopColor: lineColor }} stopOpacity='0.1' offset='0%' />\r\n <stop style={{ stopColor: lineColor }} stopOpacity='0' offset='100%' />\r\n </linearGradient>\r\n ) : null}\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g>\r\n <text\r\n className={cn(\r\n 'xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n )}\r\n y={graphHeight}\r\n x={x(dataFormatted[dataFormatted.length - 1].date)}\r\n style={{\r\n textAnchor: 'end',\r\n ...styles?.xAxis?.labels,\r\n }}\r\n dy='1em'\r\n >\r\n {format(dataFormatted[dataFormatted.length - 1].date, dateFormat)}\r\n </text>\r\n <text\r\n y={graphHeight}\r\n x={x(dataFormatted[0].date)}\r\n style={{\r\n textAnchor: 'start',\r\n ...styles?.xAxis?.labels,\r\n }}\r\n className={cn(\r\n 'xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n )}\r\n dy='1em'\r\n >\r\n {format(dataFormatted[0].date, dateFormat)}\r\n </text>\r\n </g>\r\n <g>\r\n <path\r\n d={mainGraphArea(dataFormatted) || ''}\r\n style={{\r\n fill: `url(#${areaId})`,\r\n clipPath: 'url(#clip)',\r\n }}\r\n />\r\n <path\r\n d={lineShape(dataFormatted) || ''}\r\n style={{\r\n stroke: lineColor,\r\n fill: 'none',\r\n strokeWidth: 2,\r\n }}\r\n />\r\n {mouseOverData ? (\r\n <circle\r\n y1={0}\r\n cy={y(mouseOverData.y)}\r\n cx={x(mouseOverData.date)}\r\n r={5}\r\n style={{ fill: lineColor }}\r\n />\r\n ) : null}\r\n </g>\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\r\n <rect\r\n ref={MouseoverRectRef}\r\n style={{\r\n fill: 'none',\r\n pointerEvents: 'all',\r\n }}\r\n width={graphWidth}\r\n height={graphHeight}\r\n />\r\n </g>\r\n </svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n Languages,\r\n LineChartDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: LineChartDataType[];\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 of the lines */\r\n lineColor?: 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 /** Left margin of the graph */\r\n leftMargin?: number;\r\n /** Right margin of the graph */\r\n rightMargin?: number;\r\n /** Top margin of the graph */\r\n topMargin?: number;\r\n /** Bottom margin of the graph */\r\n bottomMargin?: number;\r\n\r\n // Values and Ticks\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n\r\n // Graph Parameters\r\n /** Format of the date in the data object. Available formats can be found [here](https://date-fns.org/docs/format) */\r\n dateFormat?: string;\r\n /** Toggles the visibility of the area below the line */\r\n area?: boolean;\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** 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 // 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 /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function SparkLine(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n lineColor,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n dateFormat = 'yyyy',\r\n area = false,\r\n padding,\r\n backgroundColor,\r\n leftMargin = 5,\r\n rightMargin = 5,\r\n topMargin = 10,\r\n bottomMargin = 20,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n customLayers = [],\r\n } = props;\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 const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\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 || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\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 classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a line chart that show trends over time.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n <div\r\n className='flex flex-col grow justify-center leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n lineColor={lineColor || Colors.primaryColors['blue-600']}\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 dateFormat={dateFormat}\r\n areaId={area ? generateRandomString(8) : undefined}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n customLayers={customLayers}\r\n />\r\n ) : null}\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n"],"names":["Graph","props","data","width","height","lineColor","dateFormat","areaId","leftMargin","rightMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","minValue","maxValue","curveType","styles","classNames","customLayers","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","useRef","dataFormatted","sortBy","d","parse","graphWidth","graphHeight","minYear","maxYear","minParam","maxParam","x","scaleTime","y","scaleLinear","checkIfNullOrUndefined","mainGraphArea","area","lineShape","line","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","cn","format","Tooltip","SparkLine","graphTitle","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","Colors","generateRandomString","GraphFooter"],"mappings":"+sBAwDO,SAASA,GAAMC,EAAc,CAClC,KAAM,CACJ,KAAAC,EACA,MAAAC,EACA,OAAAC,EACA,UAAAC,EACA,WAAAC,EACA,OAAAC,EACA,WAAAC,EACA,YAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,EACA,OAAAC,EACA,WAAAC,EACA,aAAAC,CAAA,EACElB,EACEmB,EACJJ,IAAc,SACVK,EAAAA,YACAL,IAAc,OACZM,EAAAA,UACAN,IAAc,YACZO,EAAAA,UACAP,IAAc,aACZQ,EAAAA,WACAC,EAAAA,UAEN,CAACC,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WAAAtF,EACA,YAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,EACA,OAAAC,EACA,WAAAC,EACA,aAAAC,CAAA,CAAA,EAEA,IAAA,CAAA,EAELoD,GAAWE,EACVR,EAAAA,kBAAAA,IAAC8B,GAAAA,YAAA,CACC,OAAQ,CAAE,SAAU9E,GAAQ,SAAU,OAAQA,GAAQ,MAAA,EACtD,WAAY,CACV,SAAUC,GAAY,SACtB,OAAQA,GAAY,MAAA,EAEtB,QAAAqD,EACA,SAAAE,EACA,MAAAtE,CAAA,CAAA,EAEA,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CAGN"}
1
+ {"version":3,"file":"SparkLine.cjs","sources":["../src/Components/Graphs/LineCharts/SparkLine/Graph.tsx","../src/Components/Graphs/LineCharts/SparkLine/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveMonotoneX,\r\n area,\r\n curveLinear,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport sortBy from 'lodash.sortby';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport {\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n LineChartDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\n\r\ninterface Props {\r\n data: LineChartDataType[];\r\n lineColor: string;\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n areaId?: string;\r\n leftMargin: number;\r\n rightMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n maxValue?: number;\r\n minValue?: number;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n customLayers: CustomLayerDataType[];\r\n}\r\n\r\ninterface FormattedDataType {\r\n y: number;\r\n date: Date;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n lineColor,\r\n dateFormat,\r\n areaId,\r\n leftMargin,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n minValue,\r\n maxValue,\r\n curveType,\r\n styles,\r\n classNames,\r\n customLayers,\r\n } = props;\r\n const curve =\r\n curveType === 'linear'\r\n ? curveLinear\r\n : curveType === 'step'\r\n ? curveStep\r\n : curveType === 'stepAfter'\r\n ? curveStepAfter\r\n : curveType === 'stepBefore'\r\n ? curveStepBefore\r\n : curveMonotoneX;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: leftMargin,\r\n right: rightMargin,\r\n };\r\n const MouseoverRectRef = useRef(null);\r\n const dataFormatted = sortBy(\r\n data.map(d => ({\r\n ...d,\r\n date: parse(`${d.date}`, dateFormat, new Date()),\r\n })),\r\n 'date',\r\n );\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minYear = dataFormatted[0].date;\r\n const maxYear = dataFormatted[dataFormatted.length - 1].date;\r\n const minParam: number =\r\n Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !== Infinity\r\n ? Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) > 0\r\n ? 0\r\n : Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null))\r\n : 0;\r\n const maxParam: number =\r\n Math.max(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !== Infinity\r\n ? Math.max(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null))\r\n : 0;\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? minParam : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxParam > 0 ? maxParam : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n\r\n const mainGraphArea = area<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y1(d => y(d.y))\r\n .y0(graphHeight)\r\n .curve(curve);\r\n const lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n useEffect(() => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const mousemove = (event: any) => {\r\n const selectedData =\r\n dataFormatted[\r\n bisectCenter(\r\n dataFormatted.map(d => d.date),\r\n x.invert(pointer(event)[0]),\r\n 0,\r\n )\r\n ];\r\n setMouseOverData(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n onSeriesMouseOver?.(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n };\r\n const mouseout = () => {\r\n setMouseOverData(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n return (\r\n <>\r\n <svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n >\r\n {areaId ? (\r\n <linearGradient id={areaId} x1='0' x2='0' y1='0' y2='1'>\r\n <stop style={{ stopColor: lineColor }} stopOpacity='0.1' offset='0%' />\r\n <stop style={{ stopColor: lineColor }} stopOpacity='0' offset='100%' />\r\n </linearGradient>\r\n ) : null}\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g>\r\n <text\r\n className={cn(\r\n 'xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n )}\r\n y={graphHeight}\r\n x={x(dataFormatted[dataFormatted.length - 1].date)}\r\n style={{\r\n textAnchor: 'end',\r\n ...styles?.xAxis?.labels,\r\n }}\r\n dy='1em'\r\n >\r\n {format(dataFormatted[dataFormatted.length - 1].date, dateFormat)}\r\n </text>\r\n <text\r\n y={graphHeight}\r\n x={x(dataFormatted[0].date)}\r\n style={{\r\n textAnchor: 'start',\r\n ...styles?.xAxis?.labels,\r\n }}\r\n className={cn(\r\n 'xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n )}\r\n dy='1em'\r\n >\r\n {format(dataFormatted[0].date, dateFormat)}\r\n </text>\r\n </g>\r\n <g>\r\n <path\r\n d={mainGraphArea(dataFormatted) || ''}\r\n style={{\r\n fill: `url(#${areaId})`,\r\n clipPath: 'url(#clip)',\r\n }}\r\n />\r\n <path\r\n d={lineShape(dataFormatted) || ''}\r\n style={{\r\n stroke: lineColor,\r\n fill: 'none',\r\n strokeWidth: 2,\r\n }}\r\n />\r\n {mouseOverData ? (\r\n <circle\r\n y1={0}\r\n cy={y(mouseOverData.y)}\r\n cx={x(mouseOverData.date)}\r\n r={5}\r\n style={{ fill: lineColor }}\r\n />\r\n ) : null}\r\n </g>\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\r\n <rect\r\n ref={MouseoverRectRef}\r\n style={{\r\n fill: 'none',\r\n pointerEvents: 'all',\r\n }}\r\n width={graphWidth}\r\n height={graphHeight}\r\n />\r\n </g>\r\n </svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n Languages,\r\n LineChartDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: LineChartDataType[];\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 of the lines */\r\n lineColor?: 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 /** Left margin of the graph */\r\n leftMargin?: number;\r\n /** Right margin of the graph */\r\n rightMargin?: number;\r\n /** Top margin of the graph */\r\n topMargin?: number;\r\n /** Bottom margin of the graph */\r\n bottomMargin?: number;\r\n\r\n // Values and Ticks\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n\r\n // Graph Parameters\r\n /** Format of the date in the data object. Available formats can be found [here](https://date-fns.org/docs/format) */\r\n dateFormat?: string;\r\n /** Toggles the visibility of the area below the line */\r\n area?: boolean;\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** 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 // 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 /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function SparkLine(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n lineColor,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n dateFormat = 'yyyy',\r\n area = false,\r\n padding,\r\n backgroundColor,\r\n leftMargin = 5,\r\n rightMargin = 5,\r\n topMargin = 10,\r\n bottomMargin = 20,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n customLayers = [],\r\n } = props;\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 const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\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 || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n width ? 'w-fit' : 'w-full',\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a line chart that show trends over time.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n <div\r\n className='flex flex-col grow justify-center leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n lineColor={lineColor || Colors.primaryColors['blue-600']}\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 dateFormat={dateFormat}\r\n areaId={area ? generateRandomString(8) : undefined}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n customLayers={customLayers}\r\n />\r\n ) : null}\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n"],"names":["Graph","props","data","width","height","lineColor","dateFormat","areaId","leftMargin","rightMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","minValue","maxValue","curveType","styles","classNames","customLayers","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","useRef","dataFormatted","sortBy","d","parse","graphWidth","graphHeight","minYear","maxYear","minParam","maxParam","x","scaleTime","y","scaleLinear","checkIfNullOrUndefined","mainGraphArea","area","lineShape","line","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","cn","format","Tooltip","SparkLine","graphTitle","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","Colors","generateRandomString","GraphFooter"],"mappings":"+sBAwDO,SAASA,GAAMC,EAAc,CAClC,KAAM,CACJ,KAAAC,EACA,MAAAC,EACA,OAAAC,EACA,UAAAC,EACA,WAAAC,EACA,OAAAC,EACA,WAAAC,EACA,YAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,EACA,OAAAC,EACA,WAAAC,EACA,aAAAC,CAAA,EACElB,EACEmB,EACJJ,IAAc,SACVK,EAAAA,YACAL,IAAc,OACZM,EAAAA,UACAN,IAAc,YACZO,EAAAA,UACAP,IAAc,aACZQ,EAAAA,WACAC,EAAAA,UAEN,CAACC,EAAeC,CAAgB,EAAIC,EAAAA,SAAc,MAAS,EAC3D,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AAC,EACA,aAAAC,EACA,QAAAC,EACA,kBAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,EACA,OAAAC,EACA,WAAAC,EACA,aAAAC,CAAA,CAAA,EAEA,IAAA,CAAA,EAELoD,GAAWE,EACVR,EAAAA,kBAAAA,IAAC8B,GAAAA,YAAA,CACC,OAAQ,CAAE,SAAU9E,GAAQ,SAAU,OAAQA,GAAQ,MAAA,EACtD,WAAY,CACV,SAAUC,GAAY,SACtB,OAAQA,GAAY,MAAA,EAEtB,QAAAqD,EACA,SAAAE,EACA,MAAAtE,CAAA,CAAA,EAEA,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CAGN"}
package/dist/SparkLine.js CHANGED
@@ -20,7 +20,7 @@ function xe(E) {
20
20
  const {
21
21
  data: u,
22
22
  width: n,
23
- height: b,
23
+ height: w,
24
24
  lineColor: p,
25
25
  dateFormat: m,
26
26
  areaId: c,
@@ -28,7 +28,7 @@ function xe(E) {
28
28
  rightMargin: k,
29
29
  topMargin: F,
30
30
  bottomMargin: L,
31
- tooltip: w,
31
+ tooltip: b,
32
32
  onSeriesMouseOver: i,
33
33
  minValue: A,
34
34
  maxValue: O,
@@ -47,7 +47,7 @@ function xe(E) {
47
47
  date: Q(`${e.date}`, m, /* @__PURE__ */ new Date())
48
48
  })),
49
49
  "date"
50
- ), P = n - s.left - s.right, o = b - s.top - s.bottom, d = t[0].date, Y = t[t.length - 1].date, g = Math.min(...t.map((e) => e.y).filter((e) => e != null)) !== 1 / 0 ? Math.min(...t.map((e) => e.y).filter((e) => e != null)) > 0 ? 0 : Math.min(...t.map((e) => e.y).filter((e) => e != null)) : 0, C = Math.max(...t.map((e) => e.y).filter((e) => e != null)) !== 1 / 0 ? Math.max(...t.map((e) => e.y).filter((e) => e != null)) : 0, l = ee().domain([d, Y]).range([0, P]), j = te().domain([
50
+ ), P = n - s.left - s.right, o = w - s.top - s.bottom, d = t[0].date, Y = t[t.length - 1].date, g = Math.min(...t.map((e) => e.y).filter((e) => e != null)) !== 1 / 0 ? Math.min(...t.map((e) => e.y).filter((e) => e != null)) > 0 ? 0 : Math.min(...t.map((e) => e.y).filter((e) => e != null)) : 0, C = Math.max(...t.map((e) => e.y).filter((e) => e != null)) !== 1 / 0 ? Math.max(...t.map((e) => e.y).filter((e) => e != null)) : 0, l = ee().domain([d, Y]).range([0, P]), j = te().domain([
51
51
  q(A) ? g : A,
52
52
  q(O) ? C > 0 ? C : 0 : O
53
53
  ]).range([o, 0]).nice(), x = re().x((e) => l(e.date)).y1((e) => j(e.y)).y0(o).curve(H), R = oe().x((e) => l(e.date)).y((e) => j(e.y)).curve(H);
@@ -68,8 +68,8 @@ function xe(E) {
68
68
  "svg",
69
69
  {
70
70
  width: `${n}px`,
71
- height: `${b}px`,
72
- viewBox: `0 0 ${n} ${b}`,
71
+ height: `${w}px`,
72
+ viewBox: `0 0 ${n} ${w}`,
73
73
  direction: "ltr",
74
74
  children: [
75
75
  c ? /* @__PURE__ */ r.jsxs("linearGradient", { id: c, x1: "0", x2: "0", y1: "0", y2: "1", children: [
@@ -164,11 +164,11 @@ function xe(E) {
164
164
  ]
165
165
  }
166
166
  ),
167
- f && w && G && D ? /* @__PURE__ */ r.jsx(
167
+ f && b && G && D ? /* @__PURE__ */ r.jsx(
168
168
  _,
169
169
  {
170
170
  data: f,
171
- body: w,
171
+ body: b,
172
172
  xPos: G,
173
173
  yPos: D,
174
174
  backgroundStyle: M?.tooltip,
@@ -181,7 +181,7 @@ function Ie(E) {
181
181
  const {
182
182
  data: u,
183
183
  graphTitle: n,
184
- lineColor: b,
184
+ lineColor: w,
185
185
  sources: p,
186
186
  graphDescription: m,
187
187
  height: c,
@@ -189,7 +189,7 @@ function Ie(E) {
189
189
  footNote: k,
190
190
  dateFormat: F = "yyyy",
191
191
  area: L = !1,
192
- padding: w,
192
+ padding: b,
193
193
  backgroundColor: i,
194
194
  leftMargin: A = 5,
195
195
  rightMargin: O = 5,
@@ -227,6 +227,7 @@ function Ie(E) {
227
227
  {
228
228
  className: V(
229
229
  `${i ? i === !0 ? "bg-primary-gray-200 dark:bg-primary-gray-650 " : "" : "bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${v || "en"}`,
230
+ a ? "w-fit" : "w-full",
230
231
  d?.graphContainer
231
232
  ),
232
233
  style: {
@@ -240,7 +241,7 @@ function Ie(E) {
240
241
  "div",
241
242
  {
242
243
  className: "flex grow",
243
- style: { padding: i ? w || "1rem" : w || 0 },
244
+ style: { padding: i ? b || "1rem" : b || 0 },
244
245
  children: /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col w-full gap-4 grow justify-between", children: [
245
246
  n || m || N || D ? /* @__PURE__ */ r.jsx(
246
247
  he,
@@ -270,7 +271,7 @@ function Ie(E) {
270
271
  xe,
271
272
  {
272
273
  data: u,
273
- lineColor: b || fe.primaryColors["blue-600"],
274
+ lineColor: w || fe.primaryColors["blue-600"],
274
275
  width: a || g,
275
276
  height: Math.max(
276
277
  s,