@undp/data-viz 1.5.1 → 1.5.3

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 (230) hide show
  1. package/dist/AreaChart.cjs +1 -1
  2. package/dist/AreaChart.cjs.map +1 -1
  3. package/dist/AreaChart.js +3 -2
  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 +1221 -1247
  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 +130 -142
  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 +41 -41
  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 +483 -487
  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 +99 -99
  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 +125 -125
  28. package/dist/ChoroplethMap.js.map +1 -1
  29. package/dist/CirclePackingGraph.cjs +1 -1
  30. package/dist/CirclePackingGraph.js +2 -2
  31. package/dist/Data/BureauPerformance.csv +8 -0
  32. package/dist/Data/EGDashboardData.csv +6 -0
  33. package/dist/DataCards.cjs +2 -2
  34. package/dist/DataCards.cjs.map +1 -1
  35. package/dist/DataCards.js +6 -6
  36. package/dist/DataCards.js.map +1 -1
  37. package/dist/DataTable.cjs +1 -1
  38. package/dist/DataTable.cjs.map +1 -1
  39. package/dist/DataTable.js +66 -68
  40. package/dist/DataTable.js.map +1 -1
  41. package/dist/DifferenceLineChart.cjs +1 -1
  42. package/dist/DifferenceLineChart.cjs.map +1 -1
  43. package/dist/DifferenceLineChart.js +3 -2
  44. package/dist/DifferenceLineChart.js.map +1 -1
  45. package/dist/DonutChart.cjs +1 -1
  46. package/dist/DonutChart.cjs.map +1 -1
  47. package/dist/DonutChart.js +205 -205
  48. package/dist/DonutChart.js.map +1 -1
  49. package/dist/DotDensityMap.cjs +1 -1
  50. package/dist/DotDensityMap.cjs.map +1 -1
  51. package/dist/DotDensityMap.js +78 -81
  52. package/dist/DotDensityMap.js.map +1 -1
  53. package/dist/DualAxisLineChart.cjs +1 -1
  54. package/dist/DualAxisLineChart.cjs.map +1 -1
  55. package/dist/DualAxisLineChart.js +3 -2
  56. package/dist/DualAxisLineChart.js.map +1 -1
  57. package/dist/DumbbellChart.cjs +1 -1
  58. package/dist/DumbbellChart.cjs.map +1 -1
  59. package/dist/DumbbellChart.js +64 -65
  60. package/dist/DumbbellChart.js.map +1 -1
  61. package/dist/GeoHubMap.cjs +1 -1
  62. package/dist/GeoHubMap.js +1 -1
  63. package/dist/GeoHubMapWithLayerSelection.cjs +1 -1
  64. package/dist/GeoHubMapWithLayerSelection.js +1 -1
  65. package/dist/{GraphEl-4RUlclvW.cjs → GraphEl-BcYgMnN2.cjs} +2 -2
  66. package/dist/{GraphEl-4RUlclvW.cjs.map → GraphEl-BcYgMnN2.cjs.map} +1 -1
  67. package/dist/{GraphEl-ClIxlWa3.js → GraphEl-CMWeARJ3.js} +2 -2
  68. package/dist/{GraphEl-ClIxlWa3.js.map → GraphEl-CMWeARJ3.js.map} +1 -1
  69. package/dist/GriddedGraphs.cjs +1 -1
  70. package/dist/GriddedGraphs.js +4 -4
  71. package/dist/GriddedGraphsFromConfig.cjs +1 -1
  72. package/dist/GriddedGraphsFromConfig.js +1 -1
  73. package/dist/HeatMap.cjs +1 -1
  74. package/dist/HeatMap.cjs.map +1 -1
  75. package/dist/HeatMap.js +83 -83
  76. package/dist/HeatMap.js.map +1 -1
  77. package/dist/Histogram.cjs +1 -1
  78. package/dist/Histogram.js +1 -1
  79. package/dist/LineChartWithConfidenceInterval.cjs +1 -1
  80. package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
  81. package/dist/LineChartWithConfidenceInterval.js +7 -6
  82. package/dist/LineChartWithConfidenceInterval.js.map +1 -1
  83. package/dist/MultiGraphDashboard.cjs +1 -1
  84. package/dist/MultiGraphDashboard.js +2 -2
  85. package/dist/MultiGraphDashboardFromConfig.cjs +1 -1
  86. package/dist/MultiGraphDashboardFromConfig.js +1 -1
  87. package/dist/MultiGraphDashboardWideToLongFormat.cjs +1 -1
  88. package/dist/MultiGraphDashboardWideToLongFormat.js +1 -1
  89. package/dist/MultiGraphDashboardWideToLongFormatFromConfig.cjs +1 -1
  90. package/dist/MultiGraphDashboardWideToLongFormatFromConfig.js +1 -1
  91. package/dist/MultiLineAltChart.cjs +1 -1
  92. package/dist/MultiLineAltChart.cjs.map +1 -1
  93. package/dist/MultiLineAltChart.js +82 -91
  94. package/dist/MultiLineAltChart.js.map +1 -1
  95. package/dist/MultiLineChart.cjs +1 -1
  96. package/dist/MultiLineChart.cjs.map +1 -1
  97. package/dist/MultiLineChart.js +3 -2
  98. package/dist/MultiLineChart.js.map +1 -1
  99. package/dist/PerformanceIntensiveMultiGraphDashboard.cjs +1 -1
  100. package/dist/PerformanceIntensiveMultiGraphDashboard.js +2 -2
  101. package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.cjs +1 -1
  102. package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.js +1 -1
  103. package/dist/RadarChart.cjs +1 -1
  104. package/dist/RadarChart.cjs.map +1 -1
  105. package/dist/RadarChart.js +124 -130
  106. package/dist/RadarChart.js.map +1 -1
  107. package/dist/SankeyChart.cjs +1 -1
  108. package/dist/SankeyChart.cjs.map +1 -1
  109. package/dist/SankeyChart.js +200 -200
  110. package/dist/SankeyChart.js.map +1 -1
  111. package/dist/ScatterPlot.cjs +1 -1
  112. package/dist/ScatterPlot.cjs.map +1 -1
  113. package/dist/ScatterPlot.js +149 -155
  114. package/dist/ScatterPlot.js.map +1 -1
  115. package/dist/SimpleLineChart.cjs +1 -1
  116. package/dist/SimpleLineChart.cjs.map +1 -1
  117. package/dist/SimpleLineChart.js +44 -43
  118. package/dist/SimpleLineChart.js.map +1 -1
  119. package/dist/SingleGraphDashboard.cjs +1 -1
  120. package/dist/SingleGraphDashboard.js +4 -4
  121. package/dist/SingleGraphDashboardFromConfig.cjs +1 -1
  122. package/dist/SingleGraphDashboardFromConfig.js +1 -1
  123. package/dist/SingleGraphDashboardGeoHubMapsFromConfig.cjs +1 -1
  124. package/dist/SingleGraphDashboardGeoHubMapsFromConfig.js +1 -1
  125. package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
  126. package/dist/SingleGraphDashboardThreeDGraphs.js +3 -3
  127. package/dist/SingleGraphDashboardThreeDGraphsFromConfig.cjs +1 -1
  128. package/dist/SingleGraphDashboardThreeDGraphsFromConfig.js +1 -1
  129. package/dist/SlopeChart.cjs +1 -1
  130. package/dist/SlopeChart.cjs.map +1 -1
  131. package/dist/SlopeChart.js +107 -113
  132. package/dist/SlopeChart.js.map +1 -1
  133. package/dist/SparkLine.cjs +1 -1
  134. package/dist/SparkLine.cjs.map +1 -1
  135. package/dist/SparkLine.js +3 -2
  136. package/dist/SparkLine.js.map +1 -1
  137. package/dist/StripChart.cjs +1 -1
  138. package/dist/StripChart.cjs.map +1 -1
  139. package/dist/StripChart.js +159 -159
  140. package/dist/StripChart.js.map +1 -1
  141. package/dist/ThreeDGlobe.cjs +1 -1
  142. package/dist/ThreeDGlobe.cjs.map +1 -1
  143. package/dist/ThreeDGlobe.js +3 -3
  144. package/dist/ThreeDGlobe.js.map +1 -1
  145. package/dist/TreeMapGraph.cjs +1 -1
  146. package/dist/TreeMapGraph.cjs.map +1 -1
  147. package/dist/TreeMapGraph.js +194 -200
  148. package/dist/TreeMapGraph.js.map +1 -1
  149. package/dist/ensureCompleteData-DkQYPeDa.cjs +2 -0
  150. package/dist/ensureCompleteData-DkQYPeDa.cjs.map +1 -0
  151. package/dist/{ensureCompleteData-BALdOrsS.js → ensureCompleteData-DlmibgaI.js} +28 -8
  152. package/dist/ensureCompleteData-DlmibgaI.js.map +1 -0
  153. package/dist/fetchAndParseData-Ba-_CgxS.cjs +16 -0
  154. package/dist/fetchAndParseData-Ba-_CgxS.cjs.map +1 -0
  155. package/dist/fetchAndParseData-sapWbnYk.js +583 -0
  156. package/dist/fetchAndParseData-sapWbnYk.js.map +1 -0
  157. package/dist/fetchAndParseData.cjs +1 -1
  158. package/dist/fetchAndParseData.js +1 -1
  159. package/dist/getJenks-BbngDoBQ.js +19 -0
  160. package/dist/getJenks-BbngDoBQ.js.map +1 -0
  161. package/dist/getJenks-GYmdwBqm.cjs +2 -0
  162. package/dist/getJenks-GYmdwBqm.cjs.map +1 -0
  163. package/dist/getSliderMarks-9cNoRkDx.js +1023 -0
  164. package/dist/getSliderMarks-9cNoRkDx.js.map +1 -0
  165. package/dist/getSliderMarks-CRIbTGYV.cjs +6 -0
  166. package/dist/getSliderMarks-CRIbTGYV.cjs.map +1 -0
  167. package/dist/getUniqValue-DiCh_MOD.js +13 -0
  168. package/dist/getUniqValue-DiCh_MOD.js.map +1 -0
  169. package/dist/getUniqValue-RViz8tTw.cjs +2 -0
  170. package/dist/getUniqValue-RViz8tTw.cjs.map +1 -0
  171. package/dist/{index-BMgDMxKJ.js → index-37q0ULNQ.js} +44 -50
  172. package/dist/index-37q0ULNQ.js.map +1 -0
  173. package/dist/index-CVlCtJbC.cjs +2 -0
  174. package/dist/index-CVlCtJbC.cjs.map +1 -0
  175. package/dist/index.cjs +1 -1
  176. package/dist/index.d.ts +1 -1
  177. package/dist/index.js +6 -6
  178. package/dist/sort-DfK1b0F5.js +34 -0
  179. package/dist/sort-DfK1b0F5.js.map +1 -0
  180. package/dist/sort-O96oMZLb.cjs +2 -0
  181. package/dist/sort-O96oMZLb.cjs.map +1 -0
  182. package/dist/transformData.cjs +1 -1
  183. package/dist/transformData.js +3 -3
  184. package/dist/transformDataForAggregation-KXGm6flX.cjs +2 -0
  185. package/dist/{transformDataForAggregation-BVxVu4yY.cjs.map → transformDataForAggregation-KXGm6flX.cjs.map} +1 -1
  186. package/dist/{transformDataForAggregation-1BYVFqvF.js → transformDataForAggregation-sBpdlX8n.js} +40 -44
  187. package/dist/{transformDataForAggregation-1BYVFqvF.js.map → transformDataForAggregation-sBpdlX8n.js.map} +1 -1
  188. package/dist/{transformDataForGraphFromFile-BC9Ha8hF.js → transformDataForGraphFromFile-ComYvzuz.js} +3 -3
  189. package/dist/{transformDataForGraphFromFile-BC9Ha8hF.js.map → transformDataForGraphFromFile-ComYvzuz.js.map} +1 -1
  190. package/dist/{transformDataForGraphFromFile-b41aNQYY.cjs → transformDataForGraphFromFile-DVZodTHd.cjs} +2 -2
  191. package/dist/{transformDataForGraphFromFile-b41aNQYY.cjs.map → transformDataForGraphFromFile-DVZodTHd.cjs.map} +1 -1
  192. package/dist/uniqBy-BHy4I8PK.js +8 -0
  193. package/dist/uniqBy-BHy4I8PK.js.map +1 -0
  194. package/dist/uniqBy-O05lp2S5.cjs +2 -0
  195. package/dist/uniqBy-O05lp2S5.cjs.map +1 -0
  196. package/dist/utils.cjs +1 -1
  197. package/dist/utils.d.ts +1 -1
  198. package/dist/utils.js +2 -2
  199. package/package.json +1 -7
  200. package/dist/ensureCompleteData-BALdOrsS.js.map +0 -1
  201. package/dist/ensureCompleteData-BU5Zlccy.cjs +0 -2
  202. package/dist/ensureCompleteData-BU5Zlccy.cjs.map +0 -1
  203. package/dist/fetchAndParseData-DBOl1Icl.js +0 -1196
  204. package/dist/fetchAndParseData-DBOl1Icl.js.map +0 -1
  205. package/dist/fetchAndParseData-Dcy7AS_0.cjs +0 -16
  206. package/dist/fetchAndParseData-Dcy7AS_0.cjs.map +0 -1
  207. package/dist/getJenks-DW96UYNE.js +0 -23
  208. package/dist/getJenks-DW96UYNE.js.map +0 -1
  209. package/dist/getJenks-vofIZmeb.cjs +0 -2
  210. package/dist/getJenks-vofIZmeb.cjs.map +0 -1
  211. package/dist/getSliderMarks-C0jptXeP.js +0 -1054
  212. package/dist/getSliderMarks-C0jptXeP.js.map +0 -1
  213. package/dist/getSliderMarks-CtsEXiLV.cjs +0 -6
  214. package/dist/getSliderMarks-CtsEXiLV.cjs.map +0 -1
  215. package/dist/getUniqValue-CfuE_l9c.cjs +0 -2
  216. package/dist/getUniqValue-CfuE_l9c.cjs.map +0 -1
  217. package/dist/getUniqValue-CttuU_wn.js +0 -20
  218. package/dist/getUniqValue-CttuU_wn.js.map +0 -1
  219. package/dist/index-AqnpA7_O.js +0 -631
  220. package/dist/index-AqnpA7_O.js.map +0 -1
  221. package/dist/index-BJOeaYTk.cjs +0 -2
  222. package/dist/index-BJOeaYTk.cjs.map +0 -1
  223. package/dist/index-BMgDMxKJ.js.map +0 -1
  224. package/dist/index-DYH8g9WA.cjs +0 -2
  225. package/dist/index-DYH8g9WA.cjs.map +0 -1
  226. package/dist/index-Da2GUKrr.cjs +0 -2
  227. package/dist/index-Da2GUKrr.cjs.map +0 -1
  228. package/dist/index-fwdktvAS.js +0 -707
  229. package/dist/index-fwdktvAS.js.map +0 -1
  230. package/dist/transformDataForAggregation-BVxVu4yY.cjs +0 -2
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),h=require("react"),m=require("./parse-hMnG_lRV.cjs"),de=require("./index-DYH8g9WA.cjs"),ue=require("./index-CSNtgibC.cjs"),he=require("./numberFormattingFunction-02t-wJta.cjs"),fe=require("./Tooltip-De16GWhY.cjs"),Z=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),me=require("./customArea-CK768gCn.cjs"),ye=require("./AxisTitle-CK9YeovX.cjs"),je=require("./Axis-DE7dSn1_.cjs"),ve=require("./XTicksAndGridLines-CCzXIV8d.cjs"),we=require("./ReferenceLine-CFVBBN__.cjs"),Re=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ee=require("./index-BYzIB5V6.cjs"),Ae=require("./time-Byw_jYQ7.cjs"),Ce=require("./linear-BVckp9RD.cjs"),be=require("./area-D3Qx7k7K.cjs"),Oe=require("./line-DHV4JwCR.cjs"),ee=require("./step-BZ3C8QFW.cjs"),qe=require("./select-Bnfk0lJx.cjs"),Ne=require("./init-DU0ybBc_.cjs"),Se=require("./pointer-Dkq5NV1q.cjs"),$e=require("./use-in-view-sQJZ_xDO.cjs"),te=require("./proxy-BHRoeZgd.cjs"),ke=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),De=require("./ColorLegend.cjs"),Me=require("./Colors.cjs"),Fe=require("./EmptyState-d8_8SxeW.cjs");function He(se){const{data:w,width:R,height:q,colors:G,dateFormat:o,noOfXTicks:N,rightMargin:a,leftMargin:f,topMargin:ie,bottomMargin:re,yAxisTitle:P,tooltip:D,onSeriesMouseOver:p,highlightAreaSettings:oe,refValues:V,minValue:I,maxValue:Y,rtl:W,annotations:ne,customHighlightAreaSettings:ae,noOfYTicks:S,prefix:M,suffix:F,curveType:$,styles:g,classNames:d,precision:k,customLayers:H,animate:y}=se,E=h.useRef(null),j=$e.useInView(E,{once:y.once,amount:y.amount}),le=$==="linear"?Oe.curveLinear:$==="step"?ee.curveStep:$==="stepAfter"?ee.stepAfter:$==="stepBefore"?ee.stepBefore:ee.monotoneX,[b,X]=h.useState(void 0),[U,B]=h.useState(void 0),[_,z]=h.useState(void 0),c={top:ie,bottom:re,left:P?f+30:f,right:a},J=h.useRef(null),i=de.sortBy(w.map(e=>({...e,date:m.parse(`${e.date}`,o,new Date)})),"date"),A=oe.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:m.parse(`${e.coordinates[0]}`,o,new Date),e.coordinates[1]===null?null:m.parse(`${e.coordinates[1]}`,o,new Date)]})),ce=ae.map(e=>({...e,coordinates:e.coordinates.map((n,l)=>l%2===0?m.parse(`${n}`,o,new Date):n)})),xe=i[0].y.map((e,n)=>i.map(l=>({date:l.date,y0:n===0?0:ue.sum(l.y.filter((T,O)=>O<n)),y1:ue.sum(l.y.filter((T,O)=>O<=n))}))),v=R-c.left-c.right,x=q-c.top-c.bottom,K=i[0].date,Q=i[i.length-1].date,u=Z.checkIfNullOrUndefined(I)?0:I,C=Z.checkIfNullOrUndefined(Y)?Math.max(...w.map(e=>ue.sum(e.y)||0)):Y,r=Ae.time().domain([K,Q]).range([0,v]),s=Ce.linear().domain([u,C]).range([x,0]).nice(),L=be.area().x(e=>r(e.date)).y0(e=>s(e.y0)).y1(e=>s(e.y1)).curve(le),pe=s.ticks(S),ge=r.ticks(N);return h.useEffect(()=>{const e=l=>{const T=i[Ne.bisectCenter(i.map(O=>O.date),r.invert(Se.pointer(l)[0]),0)];X(T||i[i.length-1]),p?.(T||i[i.length-1]),z(l.clientY),B(l.clientX)},n=()=>{X(void 0),B(void 0),z(void 0),p?.(void 0)};qe.select(J.current).on("mousemove",e).on("mouseout",n),p?.(void 0)},[r,i,p]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(te.motion.svg,{width:`${R}px`,height:`${q}px`,viewBox:`0 0 ${R} ${q}`,direction:"ltr",ref:E,children:t.jsxRuntimeExports.jsx(ke.AnimatePresence,{children:t.jsxRuntimeExports.jsxs(te.motion.g,{transform:`translate(${c.left},${c.top})`,children:[t.jsxRuntimeExports.jsx(Ee.HighlightArea,{areaSettings:A,width:v,height:x,scale:r,animate:y,isInView:j}),t.jsxRuntimeExports.jsx(me.CustomArea,{animate:y,areaSettings:ce,scaleX:r,scaleY:s,isInView:j}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Re.YTicksAndGridLines,{values:pe.filter(e=>e!==0),y:pe.filter(e=>e!==0).map(e=>s(e)),x1:0-f,x2:v+c.right,styles:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},classNames:{gridLines:d?.yAxis?.gridLines,labels:d?.yAxis?.labels},suffix:F,prefix:M,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:k}),t.jsxRuntimeExports.jsx(je.Axis,{y1:s(u<0?0:u),y2:s(u<0?0:u),x1:0-f,x2:v+c.right,label:he.numberFormattingFunction(u<0?0:u,"NA",k,M,F),labelPos:{x:0-f,dx:0,dy:C<0?"1em":-5,y:s(u<0?0:u)},classNames:{axis:d?.xAxis?.axis,label:d?.yAxis?.labels},styles:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(ye.AxisTitle,{x:0-f-15,y:x/2,style:g?.yAxis?.title,className:d?.yAxis?.title,text:P,rotate90:!0})]}),t.jsxRuntimeExports.jsx(ve.XTicksAndGridLines,{values:ge.map(e=>m.format(e,o)),x:ge.map(e=>r(e)),y1:0,y2:x,styles:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",d?.xAxis?.gridLines),labels:t.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs",d?.xAxis?.labels)},suffix:F,prefix:M,labelType:"primary",showGridLines:!0,precision:k}),H.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs(te.motion.g,{children:[xe.map((e,n)=>t.jsxRuntimeExports.jsx(te.motion.path,{d:L(e),exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{d:L(e.map(l=>({...l,y0:0,y1:0}))),opacity:0},whileInView:{d:L(e),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",style:{fill:G[n],opacity:.8}},n)),b?t.jsxRuntimeExports.jsx("line",{y1:0,y2:x,x1:r(b.date),x2:r(b.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",d?.mouseOverLine),style:g?.mouseOverLine}):null]}),V?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:V.map((e,n)=>t.jsxRuntimeExports.jsx(we.RefLineY,{text:e.text,color:e.color,y:s(e.value),x1:0-f,x2:v+c.right,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n))}):null,t.jsxRuntimeExports.jsx("g",{children:ne.map((e,n)=>{const l=me.getLineEndPoint({x:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date)):0,y:e.yCoordinate?s(e.yCoordinate):0},Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),T=e.showConnector?{y1:l.y,x1:l.x,y2:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),cx:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date)):0,cy:e.yCoordinate?s(e.yCoordinate):0,circleRadius:Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,O={y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:W?0:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:W?e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0):v+c.right-(e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(me.Annotation,{color:e.color,connectorsSettings:T,labelSettings:O,text:e.text,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n)})}),H.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:J,style:{fill:"none",pointerEvents:"all"},width:v,height:x})]})})}),b&&D&&U&&_?t.jsxRuntimeExports.jsx(fe.Tooltip,{data:b,body:D,xPos:U,yPos:_,backgroundStyle:g?.tooltip,className:d?.tooltip}):null]})}function Ge(se){const{data:w,graphTitle:R,colors:q=Me.Colors.light.categoricalColors.colors,sources:G,graphDescription:o,height:N,width:a,footNote:f,noOfXTicks:ie=10,dateFormat:re="yyyy",colorDomain:P,padding:D,backgroundColor:p=!1,colorLegendTitle:oe,leftMargin:V=50,rightMargin:I=20,topMargin:Y=20,bottomMargin:W=25,highlightAreaSettings:ne=[],tooltip:ae,relativeHeight:S,onSeriesMouseOver:M,refValues:F=[],graphID:$,minValue:g,maxValue:d,graphDownload:k=!1,dataDownload:H=!1,showColorScale:y=!0,language:E="en",minHeight:j=0,annotations:le=[],customHighlightAreaSettings:b=[],theme:X="light",ariaLabel:U,yAxisTitle:B,noOfYTicks:_=5,prefix:z="",suffix:c="",curveType:J="curve",styles:i,classNames:A,precision:ce=2,customLayers:xe=[],animate:v=!1}=se,[x,K]=h.useState(0),[Q,u]=h.useState(0),C=h.useRef(null),r=h.useRef(null);return h.useEffect(()=>{const s=new ResizeObserver(L=>{K(a||L[0].target.clientWidth||620),u(N||L[0].target.clientHeight||480)});return C.current&&(u(C.current.clientHeight||480),K(C.current.clientWidth||620),a||s.observe(C.current)),()=>s.disconnect()},[a,N]),t.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:E==="he"||E==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${p?p===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${E||"en"}`,a?"w-fit":"w-full",A?.graphContainer),style:{...i?.graphContainer||{},...p&&p!==!0?{backgroundColor:p}:{}},id:$,ref:r,"aria-label":U||`${R?`The graph shows ${R}. `:""}This is a stacked area chart that shows trends over time.${o?` ${o}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:p?D||"1rem":D||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||o||k||H?t.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:i?.title,description:i?.description},classNames:{title:A?.title,description:A?.description},graphTitle:R,graphDescription:o,width:a,graphDownload:k?r.current:void 0,dataDownload:H?w.map(s=>s.data).filter(s=>s!==void 0).length>0?w.map(s=>s.data).filter(s=>s!==void 0):w.filter(s=>s!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:w.length===0?t.jsxRuntimeExports.jsx(Fe.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[y!==!1?t.jsxRuntimeExports.jsx(De.ColorLegend,{colorDomain:P,colors:q,colorLegendTitle:oe,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:C,"aria-label":"Graph area",children:(a||x)&&(N||Q)?t.jsxRuntimeExports.jsx(He,{data:w,colors:q,width:a||x,height:Math.max(j,N||(S?j?(a||x)*S>j?(a||x)*S:j:(a||x)*S:Q)),dateFormat:re,noOfXTicks:ie,leftMargin:V,rightMargin:I,topMargin:Y,bottomMargin:W,tooltip:ae,onSeriesMouseOver:M,highlightAreaSettings:ne,refValues:F,minValue:g,maxValue:d,rtl:E==="he"||E==="ar",annotations:le,customHighlightAreaSettings:b,yAxisTitle:B,noOfYTicks:_,prefix:z,suffix:c,curveType:J,styles:i,classNames:A,precision:ce,customLayers:xe,animate:v===!0?{duration:.5,once:!0,amount:.5}:v||{duration:0,once:!0,amount:0}}):null})]})}),G||f?t.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:i?.footnote,source:i?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:G,footNote:f,width:a}):null]})})})})}exports.AreaChart=Ge;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),h=require("react"),m=require("./parse-hMnG_lRV.cjs"),ue=require("./index-CSNtgibC.cjs"),de=require("./index-CQ3e6Ewi.cjs"),he=require("./numberFormattingFunction-02t-wJta.cjs"),fe=require("./Tooltip-De16GWhY.cjs"),Z=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),me=require("./customArea-CK768gCn.cjs"),ye=require("./AxisTitle-CK9YeovX.cjs"),je=require("./Axis-DE7dSn1_.cjs"),ve=require("./XTicksAndGridLines-CCzXIV8d.cjs"),we=require("./ReferenceLine-CFVBBN__.cjs"),Re=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ee=require("./index-BYzIB5V6.cjs"),Ae=require("./time-Byw_jYQ7.cjs"),Ce=require("./linear-BVckp9RD.cjs"),be=require("./area-D3Qx7k7K.cjs"),Oe=require("./line-DHV4JwCR.cjs"),ee=require("./step-BZ3C8QFW.cjs"),qe=require("./select-Bnfk0lJx.cjs"),Ne=require("./init-DU0ybBc_.cjs"),Se=require("./pointer-Dkq5NV1q.cjs"),$e=require("./use-in-view-sQJZ_xDO.cjs"),te=require("./proxy-BHRoeZgd.cjs"),ke=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),De=require("./ColorLegend.cjs"),Me=require("./Colors.cjs"),Fe=require("./EmptyState-d8_8SxeW.cjs");function He(se){const{data:w,width:R,height:q,colors:G,dateFormat:o,noOfXTicks:N,rightMargin:a,leftMargin:f,topMargin:ie,bottomMargin:re,yAxisTitle:P,tooltip:D,onSeriesMouseOver:p,highlightAreaSettings:oe,refValues:V,minValue:I,maxValue:Y,rtl:W,annotations:ne,customHighlightAreaSettings:ae,noOfYTicks:S,prefix:M,suffix:F,curveType:$,styles:g,classNames:d,precision:k,customLayers:H,animate:y}=se,E=h.useRef(null),j=$e.useInView(E,{once:y.once,amount:y.amount}),le=$==="linear"?Oe.curveLinear:$==="step"?ee.curveStep:$==="stepAfter"?ee.stepAfter:$==="stepBefore"?ee.stepBefore:ee.monotoneX,[b,X]=h.useState(void 0),[U,B]=h.useState(void 0),[_,z]=h.useState(void 0),c={top:ie,bottom:re,left:P?f+30:f,right:a},J=h.useRef(null),i=de.orderBy(w.map(e=>({...e,date:m.parse(`${e.date}`,o,new Date)})),["date"],["asc"]),A=oe.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:m.parse(`${e.coordinates[0]}`,o,new Date),e.coordinates[1]===null?null:m.parse(`${e.coordinates[1]}`,o,new Date)]})),ce=ae.map(e=>({...e,coordinates:e.coordinates.map((n,l)=>l%2===0?m.parse(`${n}`,o,new Date):n)})),xe=i[0].y.map((e,n)=>i.map(l=>({date:l.date,y0:n===0?0:ue.sum(l.y.filter((T,O)=>O<n)),y1:ue.sum(l.y.filter((T,O)=>O<=n))}))),v=R-c.left-c.right,x=q-c.top-c.bottom,K=i[0].date,Q=i[i.length-1].date,u=Z.checkIfNullOrUndefined(I)?0:I,C=Z.checkIfNullOrUndefined(Y)?Math.max(...w.map(e=>ue.sum(e.y)||0)):Y,r=Ae.time().domain([K,Q]).range([0,v]),s=Ce.linear().domain([u,C]).range([x,0]).nice(),L=be.area().x(e=>r(e.date)).y0(e=>s(e.y0)).y1(e=>s(e.y1)).curve(le),pe=s.ticks(S),ge=r.ticks(N);return h.useEffect(()=>{const e=l=>{const T=i[Ne.bisectCenter(i.map(O=>O.date),r.invert(Se.pointer(l)[0]),0)];X(T||i[i.length-1]),p?.(T||i[i.length-1]),z(l.clientY),B(l.clientX)},n=()=>{X(void 0),B(void 0),z(void 0),p?.(void 0)};qe.select(J.current).on("mousemove",e).on("mouseout",n),p?.(void 0)},[r,i,p]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(te.motion.svg,{width:`${R}px`,height:`${q}px`,viewBox:`0 0 ${R} ${q}`,direction:"ltr",ref:E,children:t.jsxRuntimeExports.jsx(ke.AnimatePresence,{children:t.jsxRuntimeExports.jsxs(te.motion.g,{transform:`translate(${c.left},${c.top})`,children:[t.jsxRuntimeExports.jsx(Ee.HighlightArea,{areaSettings:A,width:v,height:x,scale:r,animate:y,isInView:j}),t.jsxRuntimeExports.jsx(me.CustomArea,{animate:y,areaSettings:ce,scaleX:r,scaleY:s,isInView:j}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Re.YTicksAndGridLines,{values:pe.filter(e=>e!==0),y:pe.filter(e=>e!==0).map(e=>s(e)),x1:0-f,x2:v+c.right,styles:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},classNames:{gridLines:d?.yAxis?.gridLines,labels:d?.yAxis?.labels},suffix:F,prefix:M,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:k}),t.jsxRuntimeExports.jsx(je.Axis,{y1:s(u<0?0:u),y2:s(u<0?0:u),x1:0-f,x2:v+c.right,label:he.numberFormattingFunction(u<0?0:u,"NA",k,M,F),labelPos:{x:0-f,dx:0,dy:C<0?"1em":-5,y:s(u<0?0:u)},classNames:{axis:d?.xAxis?.axis,label:d?.yAxis?.labels},styles:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(ye.AxisTitle,{x:0-f-15,y:x/2,style:g?.yAxis?.title,className:d?.yAxis?.title,text:P,rotate90:!0})]}),t.jsxRuntimeExports.jsx(ve.XTicksAndGridLines,{values:ge.map(e=>m.format(e,o)),x:ge.map(e=>r(e)),y1:0,y2:x,styles:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",d?.xAxis?.gridLines),labels:t.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs",d?.xAxis?.labels)},suffix:F,prefix:M,labelType:"primary",showGridLines:!0,precision:k}),H.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs(te.motion.g,{children:[xe.map((e,n)=>t.jsxRuntimeExports.jsx(te.motion.path,{d:L(e),exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{d:L(e.map(l=>({...l,y0:0,y1:0}))),opacity:0},whileInView:{d:L(e),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",style:{fill:G[n],opacity:.8}},n)),b?t.jsxRuntimeExports.jsx("line",{y1:0,y2:x,x1:r(b.date),x2:r(b.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",d?.mouseOverLine),style:g?.mouseOverLine}):null]}),V?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:V.map((e,n)=>t.jsxRuntimeExports.jsx(we.RefLineY,{text:e.text,color:e.color,y:s(e.value),x1:0-f,x2:v+c.right,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n))}):null,t.jsxRuntimeExports.jsx("g",{children:ne.map((e,n)=>{const l=me.getLineEndPoint({x:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date)):0,y:e.yCoordinate?s(e.yCoordinate):0},Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),T=e.showConnector?{y1:l.y,x1:l.x,y2:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),cx:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date)):0,cy:e.yCoordinate?s(e.yCoordinate):0,circleRadius:Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,O={y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:W?0:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:W?e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0):v+c.right-(e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(me.Annotation,{color:e.color,connectorsSettings:T,labelSettings:O,text:e.text,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n)})}),H.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:J,style:{fill:"none",pointerEvents:"all"},width:v,height:x})]})})}),b&&D&&U&&_?t.jsxRuntimeExports.jsx(fe.Tooltip,{data:b,body:D,xPos:U,yPos:_,backgroundStyle:g?.tooltip,className:d?.tooltip}):null]})}function Ge(se){const{data:w,graphTitle:R,colors:q=Me.Colors.light.categoricalColors.colors,sources:G,graphDescription:o,height:N,width:a,footNote:f,noOfXTicks:ie=10,dateFormat:re="yyyy",colorDomain:P,padding:D,backgroundColor:p=!1,colorLegendTitle:oe,leftMargin:V=50,rightMargin:I=20,topMargin:Y=20,bottomMargin:W=25,highlightAreaSettings:ne=[],tooltip:ae,relativeHeight:S,onSeriesMouseOver:M,refValues:F=[],graphID:$,minValue:g,maxValue:d,graphDownload:k=!1,dataDownload:H=!1,showColorScale:y=!0,language:E="en",minHeight:j=0,annotations:le=[],customHighlightAreaSettings:b=[],theme:X="light",ariaLabel:U,yAxisTitle:B,noOfYTicks:_=5,prefix:z="",suffix:c="",curveType:J="curve",styles:i,classNames:A,precision:ce=2,customLayers:xe=[],animate:v=!1}=se,[x,K]=h.useState(0),[Q,u]=h.useState(0),C=h.useRef(null),r=h.useRef(null);return h.useEffect(()=>{const s=new ResizeObserver(L=>{K(a||L[0].target.clientWidth||620),u(N||L[0].target.clientHeight||480)});return C.current&&(u(C.current.clientHeight||480),K(C.current.clientWidth||620),a||s.observe(C.current)),()=>s.disconnect()},[a,N]),t.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:E==="he"||E==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${p?p===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${E||"en"}`,a?"w-fit":"w-full",A?.graphContainer),style:{...i?.graphContainer||{},...p&&p!==!0?{backgroundColor:p}:{}},id:$,ref:r,"aria-label":U||`${R?`The graph shows ${R}. `:""}This is a stacked area chart that shows trends over time.${o?` ${o}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:p?D||"1rem":D||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||o||k||H?t.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:i?.title,description:i?.description},classNames:{title:A?.title,description:A?.description},graphTitle:R,graphDescription:o,width:a,graphDownload:k?r.current:void 0,dataDownload:H?w.map(s=>s.data).filter(s=>s!==void 0).length>0?w.map(s=>s.data).filter(s=>s!==void 0):w.filter(s=>s!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:w.length===0?t.jsxRuntimeExports.jsx(Fe.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[y!==!1?t.jsxRuntimeExports.jsx(De.ColorLegend,{colorDomain:P,colors:q,colorLegendTitle:oe,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:C,"aria-label":"Graph area",children:(a||x)&&(N||Q)?t.jsxRuntimeExports.jsx(He,{data:w,colors:q,width:a||x,height:Math.max(j,N||(S?j?(a||x)*S>j?(a||x)*S:j:(a||x)*S:Q)),dateFormat:re,noOfXTicks:ie,leftMargin:V,rightMargin:I,topMargin:Y,bottomMargin:W,tooltip:ae,onSeriesMouseOver:M,highlightAreaSettings:ne,refValues:F,minValue:g,maxValue:d,rtl:E==="he"||E==="ar",annotations:le,customHighlightAreaSettings:b,yAxisTitle:B,noOfYTicks:_,prefix:z,suffix:c,curveType:J,styles:i,classNames:A,precision:ce,customLayers:xe,animate:v===!0?{duration:.5,once:!0,amount:.5}:v||{duration:0,once:!0,amount:0}}):null})]})}),G||f?t.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:i?.footnote,source:i?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:G,footNote:f,width:a}):null]})})})})}exports.AreaChart=Ge;
2
2
  //# sourceMappingURL=AreaChart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"AreaChart.cjs","sources":["../src/Components/Graphs/StackedAreaChart/Graph.tsx","../src/Components/Graphs/StackedAreaChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\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 sum from 'lodash.sum';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport {\r\n AnimateDataType,\r\n AnnotationSettingsDataType,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomHighlightAreaSettingsDataType,\r\n CustomLayerDataType,\r\n HighlightAreaSettingsDataType,\r\n MultiLineChartDataType,\r\n ReferenceDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { getLineEndPoint } from '@/Utils/getLineEndPoint';\r\nimport { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { RefLineY } from '@/Components/Elements/ReferenceLine';\r\nimport { Annotation } from '@/Components/Elements/Annotations';\r\nimport { YTicksAndGridLines } from '@/Components/Elements/Axes/YTicksAndGridLines';\r\nimport { CustomArea } from '@/Components/Elements/HighlightArea/customArea';\r\nimport { HighlightArea } from '@/Components/Elements/HighlightArea';\r\n\r\ninterface Props {\r\n data: MultiLineChartDataType[];\r\n colors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n rightMargin: number;\r\n leftMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n yAxisTitle?: 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 refValues?: ReferenceDataType[];\r\n highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n rtl: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n noOfYTicks: number;\r\n prefix: string;\r\n suffix: string;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n animate: AnimateDataType;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n colors,\r\n dateFormat,\r\n noOfXTicks,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n yAxisTitle,\r\n tooltip,\r\n onSeriesMouseOver,\r\n highlightAreaSettings,\r\n refValues,\r\n minValue,\r\n maxValue,\r\n rtl,\r\n annotations,\r\n customHighlightAreaSettings,\r\n noOfYTicks,\r\n prefix,\r\n suffix,\r\n curveType,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n animate,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const 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: yAxisTitle ? leftMargin + 30 : 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 highlightAreaSettingsFormatted = highlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: [\r\n d.coordinates[0] === null ? null : parse(`${d.coordinates[0]}`, dateFormat, new Date()),\r\n d.coordinates[1] === null ? null : parse(`${d.coordinates[1]}`, dateFormat, new Date()),\r\n ],\r\n }));\r\n const customHighlightAreaSettingsFormatted = customHighlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: d.coordinates.map((el, j) =>\r\n j % 2 === 0 ? parse(`${el}`, dateFormat, new Date()) : (el as number),\r\n ),\r\n }));\r\n const dataArray = dataFormatted[0].y.map((_d, i) => {\r\n return dataFormatted.map(el => ({\r\n date: el.date,\r\n y0: i === 0 ? 0 : sum(el.y.filter((_element, k) => k < i)),\r\n y1: sum(el.y.filter((_element, k) => k <= i)),\r\n }));\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 = checkIfNullOrUndefined(minValue) ? 0 : (minValue as number);\r\n const maxParam: number = checkIfNullOrUndefined(maxValue)\r\n ? Math.max(...data.map(d => sum(d.y) || 0))\r\n : (maxValue as number);\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear().domain([minParam, maxParam]).range([graphHeight, 0]).nice();\r\n\r\n const areaShape = area()\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .x((d: any) => x(d.date))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y0((d: any) => y(d.y0))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y1((d: any) => y(d.y1))\r\n .curve(curve);\r\n const yTicks = y.ticks(noOfYTicks);\r\n const xTicks = x.ticks(noOfXTicks);\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 setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(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 <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n <AnimatePresence>\r\n <motion.g transform={`translate(${margin.left},${margin.top})`}>\r\n <HighlightArea\r\n areaSettings={highlightAreaSettingsFormatted}\r\n width={graphWidth}\r\n height={graphHeight}\r\n scale={x}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n <CustomArea\r\n animate={animate}\r\n areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\r\n isInView={isInView}\r\n />\r\n <g>\r\n <YTicksAndGridLines\r\n values={yTicks.filter(d => d !== 0)}\r\n y={yTicks.filter(d => d !== 0).map(d => y(d))}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n styles={{\r\n gridLines: styles?.yAxis?.gridLines,\r\n labels: styles?.yAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.yAxis?.gridLines,\r\n labels: classNames?.yAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n labelPos='vertical'\r\n precision={precision}\r\n />\r\n <Axis\r\n y1={y(minParam < 0 ? 0 : minParam)}\r\n y2={y(minParam < 0 ? 0 : minParam)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n label={numberFormattingFunction(\r\n minParam < 0 ? 0 : minParam,\r\n 'NA',\r\n precision,\r\n prefix,\r\n suffix,\r\n )}\r\n labelPos={{\r\n x: 0 - leftMargin,\r\n dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\r\n y: y(minParam < 0 ? 0 : minParam),\r\n }}\r\n classNames={{\r\n axis: classNames?.xAxis?.axis,\r\n label: classNames?.yAxis?.labels,\r\n }}\r\n styles={{\r\n axis: styles?.xAxis?.axis,\r\n label: styles?.yAxis?.labels,\r\n }}\r\n />\r\n <AxisTitle\r\n x={0 - leftMargin - 15}\r\n y={graphHeight / 2}\r\n style={styles?.yAxis?.title}\r\n className={classNames?.yAxis?.title}\r\n text={yAxisTitle}\r\n rotate90\r\n />\r\n </g>\r\n <XTicksAndGridLines\r\n values={xTicks.map(d => format(d, dateFormat))}\r\n x={xTicks.map(d => x(d))}\r\n y1={0}\r\n y2={graphHeight}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: cn('opacity-0', classNames?.xAxis?.gridLines),\r\n labels: cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n ),\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='primary'\r\n showGridLines\r\n precision={precision}\r\n />\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <motion.g>\r\n {dataArray.map((d, i) => {\r\n return (\r\n <motion.path\r\n key={i}\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d={areaShape(d as any) as string}\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n d: areaShape(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.map(el => ({ ...el, y0: 0, y1: 0 })) as any,\r\n ) as string as string,\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d: areaShape(d as any) as string,\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 style={{\r\n fill: colors[i],\r\n opacity: 0.8,\r\n }}\r\n />\r\n );\r\n })}\r\n {mouseOverData ? (\r\n <line\r\n y1={0}\r\n y2={graphHeight}\r\n x1={x(mouseOverData.date)}\r\n x2={x(mouseOverData.date)}\r\n className={cn(\r\n 'undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100',\r\n classNames?.mouseOverLine,\r\n )}\r\n style={styles?.mouseOverLine}\r\n />\r\n ) : null}\r\n </motion.g>\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineY\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n y={y(el.value as number)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n classNames={el.classNames}\r\n styles={el.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n ))}\r\n </>\r\n ) : null}\r\n <g>\r\n {annotations.map((d, i) => {\r\n const endPoints = getLineEndPoint(\r\n {\r\n x: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n },\r\n {\r\n x: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n y: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n },\r\n checkIfNullOrUndefined(d.connectorRadius) ? 3.5 : (d.connectorRadius as number),\r\n );\r\n const connectorSettings = d.showConnector\r\n ? {\r\n y1: endPoints.y,\r\n x1: endPoints.x,\r\n y2: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0)\r\n : 0 + (d.yOffset || 0),\r\n x2: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n cy: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n circleRadius: checkIfNullOrUndefined(d.connectorRadius)\r\n ? 3.5\r\n : (d.connectorRadius as number),\r\n strokeWidth: d.showConnector === true ? 2 : Math.min(d.showConnector || 0, 1),\r\n }\r\n : undefined;\r\n const labelSettings = {\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n x: rtl\r\n ? 0\r\n : d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n width: rtl\r\n ? d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)\r\n : graphWidth +\r\n margin.right -\r\n (d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)),\r\n maxWidth: d.maxWidth,\r\n fontWeight: d.fontWeight,\r\n align: d.align,\r\n };\r\n return (\r\n <Annotation\r\n key={i}\r\n color={d.color}\r\n connectorsSettings={connectorSettings}\r\n labelSettings={labelSettings}\r\n text={d.text}\r\n classNames={d.classNames}\r\n styles={d.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n );\r\n })}\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 </motion.g>\r\n </AnimatePresence>\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 </>\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 AnnotationSettingsDataType,\r\n AreaChartDataType,\r\n CustomHighlightAreaSettingsDataType,\r\n Languages,\r\n ReferenceDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n HighlightAreaSettingsDataType,\r\n CurveTypes,\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 { ColorLegend } from '@/Components/Elements/ColorLegend';\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: AreaChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** array of colors for different lines and areas */\r\n colors?: 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\r\n // Values and Ticks\r\n /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n /** Reference values for comparison */\r\n refValues?: ReferenceDataType[];\r\n /** No. of ticks on the x-axis */\r\n noOfXTicks?: number;\r\n /** No. of ticks on the y-axis */\r\n noOfYTicks?: 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 /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Title for the Y-axis */\r\n yAxisTitle?: string;\r\n /** Annotations on the chart */\r\n annotations?: AnnotationSettingsDataType[];\r\n /** Highlighted area(square) on the chart */\r\n highlightAreaSettings?: HighlightAreaSettingsDataType[];\r\n /** Highlighted area(custom shape) on the chart */\r\n customHighlightAreaSettings?: CustomHighlightAreaSettingsDataType[];\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\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 /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\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 AreaChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n colorDomain,\r\n padding,\r\n backgroundColor = false,\r\n colorLegendTitle,\r\n leftMargin = 50,\r\n rightMargin = 20,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n highlightAreaSettings = [],\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n refValues = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n showColorScale = true,\r\n language = 'en',\r\n minHeight = 0,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n prefix = '',\r\n suffix = '',\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n precision = 2,\r\n customLayers = [],\r\n animate = false,\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 stacked area chart that shows 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 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 !== false ? (\r\n <ColorLegend\r\n colorDomain={colorDomain}\r\n colors={colors}\r\n colorLegendTitle={colorLegendTitle}\r\n showNAColor={false}\r\n />\r\n ) : null}\r\n <div className='w-full grow leading-0' ref={graphDiv} aria-label='Graph area'>\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n colors={colors}\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 noOfXTicks={noOfXTicks}\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 highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n rtl={language === 'he' || language === 'ar'}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n prefix={prefix}\r\n suffix={suffix}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n precision={precision}\r\n customLayers={customLayers}\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 />\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","colors","dateFormat","noOfXTicks","rightMargin","leftMargin","topMargin","bottomMargin","yAxisTitle","tooltip","onSeriesMouseOver","highlightAreaSettings","refValues","minValue","maxValue","rtl","annotations","customHighlightAreaSettings","noOfYTicks","prefix","suffix","curveType","styles","classNames","precision","customLayers","animate","svgRef","useRef","isInView","useInView","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","dataFormatted","sortBy","d","parse","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","el","j","dataArray","_d","i","sum","_element","k","graphWidth","graphHeight","minYear","maxYear","minParam","checkIfNullOrUndefined","maxParam","x","scaleTime","y","scaleLinear","areaShape","area","yTicks","xTicks","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","AnimatePresence","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","AreaChart","graphTitle","Colors","sources","graphDescription","footNote","colorDomain","padding","backgroundColor","colorLegendTitle","relativeHeight","graphID","graphDownload","dataDownload","showColorScale","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","ColorLegend","GraphFooter"],"mappings":"ktCA8EO,SAASA,GAAMC,GAAc,CAClC,KAAM,CACJ,KAAAC,EACA,MAAAC,EACA,OAAAC,EACA,OAAAC,EACA,WAAAC,EACA,WAAAC,EACA,YAAAC,EACA,WAAAC,EACA,UAAAC,GACA,aAAAC,GACA,WAAAC,EACA,QAAAC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,YAAa,EAAA,CAAA,EAEb,KACJ5B,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,wBAAwB,IAAK0C,EAAU,aAAW,aAC7D,UAAAhI,GAAS4H,KAAc3H,GAAU6H,GACjCxC,EAAAA,kBAAAA,IAACzF,GAAA,CACC,KAAAE,EACA,OAAAG,EACA,MAAOF,GAAS4H,EAChB,OAAQ,KAAK,IACXH,EACAxH,IACGkH,EACGM,GACGzH,GAAS4H,GAAYT,EAAiBM,GACpCzH,GAAS4H,GAAYT,EACtBM,GACDzH,GAAS4H,GAAYT,EACxBW,EAAA,EAER,WAAA3H,GACA,WAAAC,GACA,WAAAE,EACA,YAAAD,EACA,UAAAE,EACA,aAAAC,EACA,QAAAE,GACA,kBAAAC,EACA,sBAAAC,GACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,IAAKyG,IAAa,MAAQA,IAAa,KACvC,YAAAvG,GACA,4BAAAC,EACA,WAAAT,EACA,WAAAU,EACA,OAAAC,EACA,OAAAC,EACA,UAAAC,EACA,OAAAC,EACA,WAAAC,EACA,UAAAC,GACA,aAAAC,GACA,QACEC,IAAY,GACR,CAAE,SAAU,GAAK,KAAM,GAAM,OAAQ,EAAA,EACrCA,GAAW,CAAE,SAAU,EAAG,KAAM,GAAM,OAAQ,CAAA,CAAE,CAAA,EAGtD,IAAA,CACN,CAAA,CAAA,CACF,CAAA,CAEJ,EACCiF,GAAWE,EACVxB,EAAAA,kBAAAA,IAACiD,GAAAA,YAAA,CACC,OAAQ,CAAE,SAAUhH,GAAQ,SAAU,OAAQA,GAAQ,MAAA,EACtD,WAAY,CACV,SAAUC,GAAY,SACtB,OAAQA,GAAY,MAAA,EAEtB,QAAAoF,EACA,SAAAE,EACA,MAAA9G,CAAA,CAAA,EAEA,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CAGN"}
1
+ {"version":3,"file":"AreaChart.cjs","sources":["../src/Components/Graphs/StackedAreaChart/Graph.tsx","../src/Components/Graphs/StackedAreaChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\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 sum from 'lodash.sum';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport orderBy from 'lodash.orderby';\r\n\r\nimport {\r\n AnimateDataType,\r\n AnnotationSettingsDataType,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomHighlightAreaSettingsDataType,\r\n CustomLayerDataType,\r\n HighlightAreaSettingsDataType,\r\n MultiLineChartDataType,\r\n ReferenceDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { getLineEndPoint } from '@/Utils/getLineEndPoint';\r\nimport { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { RefLineY } from '@/Components/Elements/ReferenceLine';\r\nimport { Annotation } from '@/Components/Elements/Annotations';\r\nimport { YTicksAndGridLines } from '@/Components/Elements/Axes/YTicksAndGridLines';\r\nimport { CustomArea } from '@/Components/Elements/HighlightArea/customArea';\r\nimport { HighlightArea } from '@/Components/Elements/HighlightArea';\r\n\r\ninterface Props {\r\n data: MultiLineChartDataType[];\r\n colors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n rightMargin: number;\r\n leftMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n yAxisTitle?: 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 refValues?: ReferenceDataType[];\r\n highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n rtl: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n noOfYTicks: number;\r\n prefix: string;\r\n suffix: string;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n animate: AnimateDataType;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n colors,\r\n dateFormat,\r\n noOfXTicks,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n yAxisTitle,\r\n tooltip,\r\n onSeriesMouseOver,\r\n highlightAreaSettings,\r\n refValues,\r\n minValue,\r\n maxValue,\r\n rtl,\r\n annotations,\r\n customHighlightAreaSettings,\r\n noOfYTicks,\r\n prefix,\r\n suffix,\r\n curveType,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n animate,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const 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: yAxisTitle ? leftMargin + 30 : leftMargin,\r\n right: rightMargin,\r\n };\r\n const MouseoverRectRef = useRef(null);\r\n const dataFormatted = orderBy(\r\n data.map(d => ({\r\n ...d,\r\n date: parse(`${d.date}`, dateFormat, new Date()),\r\n })),\r\n ['date'],\r\n ['asc'],\r\n );\r\n const highlightAreaSettingsFormatted = highlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: [\r\n d.coordinates[0] === null ? null : parse(`${d.coordinates[0]}`, dateFormat, new Date()),\r\n d.coordinates[1] === null ? null : parse(`${d.coordinates[1]}`, dateFormat, new Date()),\r\n ],\r\n }));\r\n const customHighlightAreaSettingsFormatted = customHighlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: d.coordinates.map((el, j) =>\r\n j % 2 === 0 ? parse(`${el}`, dateFormat, new Date()) : (el as number),\r\n ),\r\n }));\r\n const dataArray = dataFormatted[0].y.map((_d, i) => {\r\n return dataFormatted.map(el => ({\r\n date: el.date,\r\n y0: i === 0 ? 0 : sum(el.y.filter((_element, k) => k < i)),\r\n y1: sum(el.y.filter((_element, k) => k <= i)),\r\n }));\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 = checkIfNullOrUndefined(minValue) ? 0 : (minValue as number);\r\n const maxParam: number = checkIfNullOrUndefined(maxValue)\r\n ? Math.max(...data.map(d => sum(d.y) || 0))\r\n : (maxValue as number);\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear().domain([minParam, maxParam]).range([graphHeight, 0]).nice();\r\n\r\n const areaShape = area()\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .x((d: any) => x(d.date))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y0((d: any) => y(d.y0))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y1((d: any) => y(d.y1))\r\n .curve(curve);\r\n const yTicks = y.ticks(noOfYTicks);\r\n const xTicks = x.ticks(noOfXTicks);\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 setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(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 <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n <AnimatePresence>\r\n <motion.g transform={`translate(${margin.left},${margin.top})`}>\r\n <HighlightArea\r\n areaSettings={highlightAreaSettingsFormatted}\r\n width={graphWidth}\r\n height={graphHeight}\r\n scale={x}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n <CustomArea\r\n animate={animate}\r\n areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\r\n isInView={isInView}\r\n />\r\n <g>\r\n <YTicksAndGridLines\r\n values={yTicks.filter(d => d !== 0)}\r\n y={yTicks.filter(d => d !== 0).map(d => y(d))}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n styles={{\r\n gridLines: styles?.yAxis?.gridLines,\r\n labels: styles?.yAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.yAxis?.gridLines,\r\n labels: classNames?.yAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n labelPos='vertical'\r\n precision={precision}\r\n />\r\n <Axis\r\n y1={y(minParam < 0 ? 0 : minParam)}\r\n y2={y(minParam < 0 ? 0 : minParam)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n label={numberFormattingFunction(\r\n minParam < 0 ? 0 : minParam,\r\n 'NA',\r\n precision,\r\n prefix,\r\n suffix,\r\n )}\r\n labelPos={{\r\n x: 0 - leftMargin,\r\n dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\r\n y: y(minParam < 0 ? 0 : minParam),\r\n }}\r\n classNames={{\r\n axis: classNames?.xAxis?.axis,\r\n label: classNames?.yAxis?.labels,\r\n }}\r\n styles={{\r\n axis: styles?.xAxis?.axis,\r\n label: styles?.yAxis?.labels,\r\n }}\r\n />\r\n <AxisTitle\r\n x={0 - leftMargin - 15}\r\n y={graphHeight / 2}\r\n style={styles?.yAxis?.title}\r\n className={classNames?.yAxis?.title}\r\n text={yAxisTitle}\r\n rotate90\r\n />\r\n </g>\r\n <XTicksAndGridLines\r\n values={xTicks.map(d => format(d, dateFormat))}\r\n x={xTicks.map(d => x(d))}\r\n y1={0}\r\n y2={graphHeight}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: cn('opacity-0', classNames?.xAxis?.gridLines),\r\n labels: cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n ),\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='primary'\r\n showGridLines\r\n precision={precision}\r\n />\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <motion.g>\r\n {dataArray.map((d, i) => {\r\n return (\r\n <motion.path\r\n key={i}\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d={areaShape(d as any) as string}\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n d: areaShape(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.map(el => ({ ...el, y0: 0, y1: 0 })) as any,\r\n ) as string as string,\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d: areaShape(d as any) as string,\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 style={{\r\n fill: colors[i],\r\n opacity: 0.8,\r\n }}\r\n />\r\n );\r\n })}\r\n {mouseOverData ? (\r\n <line\r\n y1={0}\r\n y2={graphHeight}\r\n x1={x(mouseOverData.date)}\r\n x2={x(mouseOverData.date)}\r\n className={cn(\r\n 'undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100',\r\n classNames?.mouseOverLine,\r\n )}\r\n style={styles?.mouseOverLine}\r\n />\r\n ) : null}\r\n </motion.g>\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineY\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n y={y(el.value as number)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n classNames={el.classNames}\r\n styles={el.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n ))}\r\n </>\r\n ) : null}\r\n <g>\r\n {annotations.map((d, i) => {\r\n const endPoints = getLineEndPoint(\r\n {\r\n x: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n },\r\n {\r\n x: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n y: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n },\r\n checkIfNullOrUndefined(d.connectorRadius) ? 3.5 : (d.connectorRadius as number),\r\n );\r\n const connectorSettings = d.showConnector\r\n ? {\r\n y1: endPoints.y,\r\n x1: endPoints.x,\r\n y2: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0)\r\n : 0 + (d.yOffset || 0),\r\n x2: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n cy: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n circleRadius: checkIfNullOrUndefined(d.connectorRadius)\r\n ? 3.5\r\n : (d.connectorRadius as number),\r\n strokeWidth: d.showConnector === true ? 2 : Math.min(d.showConnector || 0, 1),\r\n }\r\n : undefined;\r\n const labelSettings = {\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n x: rtl\r\n ? 0\r\n : d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n width: rtl\r\n ? d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)\r\n : graphWidth +\r\n margin.right -\r\n (d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)),\r\n maxWidth: d.maxWidth,\r\n fontWeight: d.fontWeight,\r\n align: d.align,\r\n };\r\n return (\r\n <Annotation\r\n key={i}\r\n color={d.color}\r\n connectorsSettings={connectorSettings}\r\n labelSettings={labelSettings}\r\n text={d.text}\r\n classNames={d.classNames}\r\n styles={d.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n );\r\n })}\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 </motion.g>\r\n </AnimatePresence>\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 </>\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 AnnotationSettingsDataType,\r\n AreaChartDataType,\r\n CustomHighlightAreaSettingsDataType,\r\n Languages,\r\n ReferenceDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n HighlightAreaSettingsDataType,\r\n CurveTypes,\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 { ColorLegend } from '@/Components/Elements/ColorLegend';\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: AreaChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** array of colors for different lines and areas */\r\n colors?: 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\r\n // Values and Ticks\r\n /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n /** Reference values for comparison */\r\n refValues?: ReferenceDataType[];\r\n /** No. of ticks on the x-axis */\r\n noOfXTicks?: number;\r\n /** No. of ticks on the y-axis */\r\n noOfYTicks?: 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 /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Title for the Y-axis */\r\n yAxisTitle?: string;\r\n /** Annotations on the chart */\r\n annotations?: AnnotationSettingsDataType[];\r\n /** Highlighted area(square) on the chart */\r\n highlightAreaSettings?: HighlightAreaSettingsDataType[];\r\n /** Highlighted area(custom shape) on the chart */\r\n customHighlightAreaSettings?: CustomHighlightAreaSettingsDataType[];\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\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 /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\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 AreaChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n colorDomain,\r\n padding,\r\n backgroundColor = false,\r\n colorLegendTitle,\r\n leftMargin = 50,\r\n rightMargin = 20,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n highlightAreaSettings = [],\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n refValues = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n showColorScale = true,\r\n language = 'en',\r\n minHeight = 0,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n prefix = '',\r\n suffix = '',\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n precision = 2,\r\n customLayers = [],\r\n animate = false,\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 stacked area chart that shows 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 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 !== false ? (\r\n <ColorLegend\r\n colorDomain={colorDomain}\r\n colors={colors}\r\n colorLegendTitle={colorLegendTitle}\r\n showNAColor={false}\r\n />\r\n ) : null}\r\n <div className='w-full grow leading-0' ref={graphDiv} aria-label='Graph area'>\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n colors={colors}\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 noOfXTicks={noOfXTicks}\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 highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n rtl={language === 'he' || language === 'ar'}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n prefix={prefix}\r\n suffix={suffix}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n precision={precision}\r\n customLayers={customLayers}\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 />\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","colors","dateFormat","noOfXTicks","rightMargin","leftMargin","topMargin","bottomMargin","yAxisTitle","tooltip","onSeriesMouseOver","highlightAreaSettings","refValues","minValue","maxValue","rtl","annotations","customHighlightAreaSettings","noOfYTicks","prefix","suffix","curveType","styles","classNames","precision","customLayers","animate","svgRef","useRef","isInView","useInView","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","dataFormatted","orderBy","d","parse","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","el","j","dataArray","_d","i","sum","_element","k","graphWidth","graphHeight","minYear","maxYear","minParam","checkIfNullOrUndefined","maxParam","x","scaleTime","y","scaleLinear","areaShape","area","yTicks","xTicks","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","AnimatePresence","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","AreaChart","graphTitle","Colors","sources","graphDescription","footNote","colorDomain","padding","backgroundColor","colorLegendTitle","relativeHeight","graphID","graphDownload","dataDownload","showColorScale","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","ColorLegend","GraphFooter"],"mappings":"ktCA8EO,SAASA,GAAMC,GAAc,CAClC,KAAM,CACJ,KAAAC,EACA,MAAAC,EACA,OAAAC,EACA,OAAAC,EACA,WAAAC,EACA,WAAAC,EACA,YAAAC,EACA,WAAAC,EACA,UAAAC,GACA,aAAAC,GACA,WAAAC,EACA,QAAAC,EACA,kBAAAC,EACA,sBAAAC,GACA,UAAAC,EACA,SAAAC,EACA,SAAAC,EACA,IAAAC,EACA,YAAAC,GACA,4BAAAC,GACA,WAAAC,EACA,OAAAC,EACA,OAAAC,EACA,UAAAC,EACA,OAAAC,EACA,WAAAC,EACA,UAAAC,EACA,aAAAC,EACA,QAAAC,CAAA,EACE7B,GACE8B,EAASC,EAAAA,OAAO,IAAI,EACpBC,EAAWC,GAAAA,UAAUH,EAAQ,CACjC,KAAMD,EAAQ,KACd,OAAQA,EAAQ,MAAA,CACjB,EACKK,GACJV,IAAc,SACVW,GAAAA,YACAX,IAAc,OACZY,GAAAA,UACAZ,IAAc,YACZa,GAAAA,UACAb,IAAc,aACZc,GAAAA,WACAC,GAAAA,UAEN,CAACC,EAAeC,CAAgB,EAAIC,EAAAA,SAAc,MAAS,EAC3D,CAACC,EAAQC,CAAS,EAAIF,EAAAA,SAA6B,MAAS,EAC5D,CAACG,EAAQC,CAAS,EAAIJ,EAAAA,SAA6B,MAAS,EAC5DK,EAAS,CACb,IAAKtC,GACL,OAAQC,GACR,KAAMC,EAAaH,EAAa,GAAKA,EACrC,MAAOD,CAAA,EAEHyC,EAAmBjB,EAAAA,OAAO,IAAI,EAC9BkB,EAAgBC,GAAAA,QACpBjD,EAAK,IAAIkD,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,EAAG,KAAM,GAAM,OAAQ,CAAA,CAAE,CAAA,EAGtD,IAAA,CACN,CAAA,CAAA,CACF,CAAA,CAEJ,EACCiF,GAAWE,EACVxB,EAAAA,kBAAAA,IAACiD,GAAAA,YAAA,CACC,OAAQ,CAAE,SAAUhH,GAAQ,SAAU,OAAQA,GAAQ,MAAA,EACtD,WAAY,CACV,SAAUC,GAAY,SACtB,OAAQA,GAAY,MAAA,EAEtB,QAAAoF,EACA,SAAAE,EACA,MAAA9G,CAAA,CAAA,EAEA,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CAGN"}
package/dist/AreaChart.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { j as t, m as te } from "./index-CHPV5EwG-BPSP-7Jg.js";
2
2
  import { useRef as ae, useState as P, useEffect as he } from "react";
3
3
  import { p as h, f as ue } from "./parse-DlCRUFh_.js";
4
- import { s as de } from "./index-fwdktvAS.js";
5
4
  import { s as fe } from "./index-CeVNqhMO.js";
5
+ import { o as de } from "./index-DvVprvy6.js";
6
6
  import { n as ye } from "./numberFormattingFunction-14YCbkN2.js";
7
7
  import { T as ve } from "./Tooltip-CVCGWyzw.js";
8
8
  import { c as Z } from "./checkIfNullOrUndefined-DmfiKkNw.js";
@@ -73,7 +73,8 @@ function ze(oe) {
73
73
  ...e,
74
74
  date: h(`${e.date}`, i, /* @__PURE__ */ new Date())
75
75
  })),
76
- "date"
76
+ ["date"],
77
+ ["asc"]
77
78
  ), b = re.map((e) => ({
78
79
  ...e,
79
80
  coordinates: [
@@ -1 +1 @@
1
- {"version":3,"file":"AreaChart.js","sources":["../src/Components/Graphs/StackedAreaChart/Graph.tsx","../src/Components/Graphs/StackedAreaChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\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 sum from 'lodash.sum';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport {\r\n AnimateDataType,\r\n AnnotationSettingsDataType,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomHighlightAreaSettingsDataType,\r\n CustomLayerDataType,\r\n HighlightAreaSettingsDataType,\r\n MultiLineChartDataType,\r\n ReferenceDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { getLineEndPoint } from '@/Utils/getLineEndPoint';\r\nimport { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { RefLineY } from '@/Components/Elements/ReferenceLine';\r\nimport { Annotation } from '@/Components/Elements/Annotations';\r\nimport { YTicksAndGridLines } from '@/Components/Elements/Axes/YTicksAndGridLines';\r\nimport { CustomArea } from '@/Components/Elements/HighlightArea/customArea';\r\nimport { HighlightArea } from '@/Components/Elements/HighlightArea';\r\n\r\ninterface Props {\r\n data: MultiLineChartDataType[];\r\n colors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n rightMargin: number;\r\n leftMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n yAxisTitle?: 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 refValues?: ReferenceDataType[];\r\n highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n rtl: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n noOfYTicks: number;\r\n prefix: string;\r\n suffix: string;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n animate: AnimateDataType;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n colors,\r\n dateFormat,\r\n noOfXTicks,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n yAxisTitle,\r\n tooltip,\r\n onSeriesMouseOver,\r\n highlightAreaSettings,\r\n refValues,\r\n minValue,\r\n maxValue,\r\n rtl,\r\n annotations,\r\n customHighlightAreaSettings,\r\n noOfYTicks,\r\n prefix,\r\n suffix,\r\n curveType,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n animate,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const 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: yAxisTitle ? leftMargin + 30 : 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 highlightAreaSettingsFormatted = highlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: [\r\n d.coordinates[0] === null ? null : parse(`${d.coordinates[0]}`, dateFormat, new Date()),\r\n d.coordinates[1] === null ? null : parse(`${d.coordinates[1]}`, dateFormat, new Date()),\r\n ],\r\n }));\r\n const customHighlightAreaSettingsFormatted = customHighlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: d.coordinates.map((el, j) =>\r\n j % 2 === 0 ? parse(`${el}`, dateFormat, new Date()) : (el as number),\r\n ),\r\n }));\r\n const dataArray = dataFormatted[0].y.map((_d, i) => {\r\n return dataFormatted.map(el => ({\r\n date: el.date,\r\n y0: i === 0 ? 0 : sum(el.y.filter((_element, k) => k < i)),\r\n y1: sum(el.y.filter((_element, k) => k <= i)),\r\n }));\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 = checkIfNullOrUndefined(minValue) ? 0 : (minValue as number);\r\n const maxParam: number = checkIfNullOrUndefined(maxValue)\r\n ? Math.max(...data.map(d => sum(d.y) || 0))\r\n : (maxValue as number);\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear().domain([minParam, maxParam]).range([graphHeight, 0]).nice();\r\n\r\n const areaShape = area()\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .x((d: any) => x(d.date))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y0((d: any) => y(d.y0))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y1((d: any) => y(d.y1))\r\n .curve(curve);\r\n const yTicks = y.ticks(noOfYTicks);\r\n const xTicks = x.ticks(noOfXTicks);\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 setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(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 <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n <AnimatePresence>\r\n <motion.g transform={`translate(${margin.left},${margin.top})`}>\r\n <HighlightArea\r\n areaSettings={highlightAreaSettingsFormatted}\r\n width={graphWidth}\r\n height={graphHeight}\r\n scale={x}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n <CustomArea\r\n animate={animate}\r\n areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\r\n isInView={isInView}\r\n />\r\n <g>\r\n <YTicksAndGridLines\r\n values={yTicks.filter(d => d !== 0)}\r\n y={yTicks.filter(d => d !== 0).map(d => y(d))}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n styles={{\r\n gridLines: styles?.yAxis?.gridLines,\r\n labels: styles?.yAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.yAxis?.gridLines,\r\n labels: classNames?.yAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n labelPos='vertical'\r\n precision={precision}\r\n />\r\n <Axis\r\n y1={y(minParam < 0 ? 0 : minParam)}\r\n y2={y(minParam < 0 ? 0 : minParam)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n label={numberFormattingFunction(\r\n minParam < 0 ? 0 : minParam,\r\n 'NA',\r\n precision,\r\n prefix,\r\n suffix,\r\n )}\r\n labelPos={{\r\n x: 0 - leftMargin,\r\n dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\r\n y: y(minParam < 0 ? 0 : minParam),\r\n }}\r\n classNames={{\r\n axis: classNames?.xAxis?.axis,\r\n label: classNames?.yAxis?.labels,\r\n }}\r\n styles={{\r\n axis: styles?.xAxis?.axis,\r\n label: styles?.yAxis?.labels,\r\n }}\r\n />\r\n <AxisTitle\r\n x={0 - leftMargin - 15}\r\n y={graphHeight / 2}\r\n style={styles?.yAxis?.title}\r\n className={classNames?.yAxis?.title}\r\n text={yAxisTitle}\r\n rotate90\r\n />\r\n </g>\r\n <XTicksAndGridLines\r\n values={xTicks.map(d => format(d, dateFormat))}\r\n x={xTicks.map(d => x(d))}\r\n y1={0}\r\n y2={graphHeight}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: cn('opacity-0', classNames?.xAxis?.gridLines),\r\n labels: cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n ),\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='primary'\r\n showGridLines\r\n precision={precision}\r\n />\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <motion.g>\r\n {dataArray.map((d, i) => {\r\n return (\r\n <motion.path\r\n key={i}\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d={areaShape(d as any) as string}\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n d: areaShape(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.map(el => ({ ...el, y0: 0, y1: 0 })) as any,\r\n ) as string as string,\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d: areaShape(d as any) as string,\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 style={{\r\n fill: colors[i],\r\n opacity: 0.8,\r\n }}\r\n />\r\n );\r\n })}\r\n {mouseOverData ? (\r\n <line\r\n y1={0}\r\n y2={graphHeight}\r\n x1={x(mouseOverData.date)}\r\n x2={x(mouseOverData.date)}\r\n className={cn(\r\n 'undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100',\r\n classNames?.mouseOverLine,\r\n )}\r\n style={styles?.mouseOverLine}\r\n />\r\n ) : null}\r\n </motion.g>\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineY\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n y={y(el.value as number)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n classNames={el.classNames}\r\n styles={el.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n ))}\r\n </>\r\n ) : null}\r\n <g>\r\n {annotations.map((d, i) => {\r\n const endPoints = getLineEndPoint(\r\n {\r\n x: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n },\r\n {\r\n x: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n y: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n },\r\n checkIfNullOrUndefined(d.connectorRadius) ? 3.5 : (d.connectorRadius as number),\r\n );\r\n const connectorSettings = d.showConnector\r\n ? {\r\n y1: endPoints.y,\r\n x1: endPoints.x,\r\n y2: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0)\r\n : 0 + (d.yOffset || 0),\r\n x2: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n cy: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n circleRadius: checkIfNullOrUndefined(d.connectorRadius)\r\n ? 3.5\r\n : (d.connectorRadius as number),\r\n strokeWidth: d.showConnector === true ? 2 : Math.min(d.showConnector || 0, 1),\r\n }\r\n : undefined;\r\n const labelSettings = {\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n x: rtl\r\n ? 0\r\n : d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n width: rtl\r\n ? d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)\r\n : graphWidth +\r\n margin.right -\r\n (d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)),\r\n maxWidth: d.maxWidth,\r\n fontWeight: d.fontWeight,\r\n align: d.align,\r\n };\r\n return (\r\n <Annotation\r\n key={i}\r\n color={d.color}\r\n connectorsSettings={connectorSettings}\r\n labelSettings={labelSettings}\r\n text={d.text}\r\n classNames={d.classNames}\r\n styles={d.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n );\r\n })}\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 </motion.g>\r\n </AnimatePresence>\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 </>\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 AnnotationSettingsDataType,\r\n AreaChartDataType,\r\n CustomHighlightAreaSettingsDataType,\r\n Languages,\r\n ReferenceDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n HighlightAreaSettingsDataType,\r\n CurveTypes,\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 { ColorLegend } from '@/Components/Elements/ColorLegend';\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: AreaChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** array of colors for different lines and areas */\r\n colors?: 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\r\n // Values and Ticks\r\n /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n /** Reference values for comparison */\r\n refValues?: ReferenceDataType[];\r\n /** No. of ticks on the x-axis */\r\n noOfXTicks?: number;\r\n /** No. of ticks on the y-axis */\r\n noOfYTicks?: 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 /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Title for the Y-axis */\r\n yAxisTitle?: string;\r\n /** Annotations on the chart */\r\n annotations?: AnnotationSettingsDataType[];\r\n /** Highlighted area(square) on the chart */\r\n highlightAreaSettings?: HighlightAreaSettingsDataType[];\r\n /** Highlighted area(custom shape) on the chart */\r\n customHighlightAreaSettings?: CustomHighlightAreaSettingsDataType[];\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\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 /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\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 AreaChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n colorDomain,\r\n padding,\r\n backgroundColor = false,\r\n colorLegendTitle,\r\n leftMargin = 50,\r\n rightMargin = 20,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n highlightAreaSettings = [],\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n refValues = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n showColorScale = true,\r\n language = 'en',\r\n minHeight = 0,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n prefix = '',\r\n suffix = '',\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n precision = 2,\r\n customLayers = [],\r\n animate = false,\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 stacked area chart that shows 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 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 !== false ? (\r\n <ColorLegend\r\n colorDomain={colorDomain}\r\n colors={colors}\r\n colorLegendTitle={colorLegendTitle}\r\n showNAColor={false}\r\n />\r\n ) : null}\r\n <div className='w-full grow leading-0' ref={graphDiv} aria-label='Graph area'>\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n colors={colors}\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 noOfXTicks={noOfXTicks}\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 highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n rtl={language === 'he' || language === 'ar'}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n prefix={prefix}\r\n suffix={suffix}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n precision={precision}\r\n customLayers={customLayers}\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 />\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","colors","dateFormat","noOfXTicks","rightMargin","leftMargin","topMargin","bottomMargin","yAxisTitle","tooltip","onSeriesMouseOver","highlightAreaSettings","refValues","minValue","maxValue","rtl","annotations","customHighlightAreaSettings","noOfYTicks","prefix","suffix","curveType","styles","classNames","precision","customLayers","animate","svgRef","useRef","isInView","useInView","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","dataFormatted","sortBy","d","parse","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","el","j","dataArray","_d","i","sum","_element","k","graphWidth","graphHeight","minYear","maxYear","minParam","checkIfNullOrUndefined","maxParam","x","scaleTime","y","scaleLinear","areaShape","area","yTicks","xTicks","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","AnimatePresence","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","AreaChart","graphTitle","Colors","sources","graphDescription","footNote","colorDomain","padding","backgroundColor","colorLegendTitle","relativeHeight","graphID","graphDownload","dataDownload","showColorScale","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","G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,KAAK,MAAM,IAAM,QAAQ,IAAA,IACrCA,KAAW,EAAE,UAAU,GAAG,MAAM,IAAM,QAAQ,EAAA;AAAA,oBAAE;AAAA,kBAAA,IAGtD,KAAA,CACN;AAAA,gBAAA,EAAA,CACF,EAAA,CAEJ;AAAA,gBACCiF,KAAWE,IACVxB,gBAAAA,EAAAA;AAAAA,kBAACiD;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAUhH,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAAoF;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAA9G;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":"AreaChart.js","sources":["../src/Components/Graphs/StackedAreaChart/Graph.tsx","../src/Components/Graphs/StackedAreaChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\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 sum from 'lodash.sum';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport orderBy from 'lodash.orderby';\r\n\r\nimport {\r\n AnimateDataType,\r\n AnnotationSettingsDataType,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomHighlightAreaSettingsDataType,\r\n CustomLayerDataType,\r\n HighlightAreaSettingsDataType,\r\n MultiLineChartDataType,\r\n ReferenceDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { getLineEndPoint } from '@/Utils/getLineEndPoint';\r\nimport { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { RefLineY } from '@/Components/Elements/ReferenceLine';\r\nimport { Annotation } from '@/Components/Elements/Annotations';\r\nimport { YTicksAndGridLines } from '@/Components/Elements/Axes/YTicksAndGridLines';\r\nimport { CustomArea } from '@/Components/Elements/HighlightArea/customArea';\r\nimport { HighlightArea } from '@/Components/Elements/HighlightArea';\r\n\r\ninterface Props {\r\n data: MultiLineChartDataType[];\r\n colors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n rightMargin: number;\r\n leftMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n yAxisTitle?: 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 refValues?: ReferenceDataType[];\r\n highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n rtl: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n noOfYTicks: number;\r\n prefix: string;\r\n suffix: string;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n animate: AnimateDataType;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n colors,\r\n dateFormat,\r\n noOfXTicks,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n yAxisTitle,\r\n tooltip,\r\n onSeriesMouseOver,\r\n highlightAreaSettings,\r\n refValues,\r\n minValue,\r\n maxValue,\r\n rtl,\r\n annotations,\r\n customHighlightAreaSettings,\r\n noOfYTicks,\r\n prefix,\r\n suffix,\r\n curveType,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n animate,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const 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: yAxisTitle ? leftMargin + 30 : leftMargin,\r\n right: rightMargin,\r\n };\r\n const MouseoverRectRef = useRef(null);\r\n const dataFormatted = orderBy(\r\n data.map(d => ({\r\n ...d,\r\n date: parse(`${d.date}`, dateFormat, new Date()),\r\n })),\r\n ['date'],\r\n ['asc'],\r\n );\r\n const highlightAreaSettingsFormatted = highlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: [\r\n d.coordinates[0] === null ? null : parse(`${d.coordinates[0]}`, dateFormat, new Date()),\r\n d.coordinates[1] === null ? null : parse(`${d.coordinates[1]}`, dateFormat, new Date()),\r\n ],\r\n }));\r\n const customHighlightAreaSettingsFormatted = customHighlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: d.coordinates.map((el, j) =>\r\n j % 2 === 0 ? parse(`${el}`, dateFormat, new Date()) : (el as number),\r\n ),\r\n }));\r\n const dataArray = dataFormatted[0].y.map((_d, i) => {\r\n return dataFormatted.map(el => ({\r\n date: el.date,\r\n y0: i === 0 ? 0 : sum(el.y.filter((_element, k) => k < i)),\r\n y1: sum(el.y.filter((_element, k) => k <= i)),\r\n }));\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 = checkIfNullOrUndefined(minValue) ? 0 : (minValue as number);\r\n const maxParam: number = checkIfNullOrUndefined(maxValue)\r\n ? Math.max(...data.map(d => sum(d.y) || 0))\r\n : (maxValue as number);\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear().domain([minParam, maxParam]).range([graphHeight, 0]).nice();\r\n\r\n const areaShape = area()\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .x((d: any) => x(d.date))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y0((d: any) => y(d.y0))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y1((d: any) => y(d.y1))\r\n .curve(curve);\r\n const yTicks = y.ticks(noOfYTicks);\r\n const xTicks = x.ticks(noOfXTicks);\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 setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(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 <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n <AnimatePresence>\r\n <motion.g transform={`translate(${margin.left},${margin.top})`}>\r\n <HighlightArea\r\n areaSettings={highlightAreaSettingsFormatted}\r\n width={graphWidth}\r\n height={graphHeight}\r\n scale={x}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n <CustomArea\r\n animate={animate}\r\n areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\r\n isInView={isInView}\r\n />\r\n <g>\r\n <YTicksAndGridLines\r\n values={yTicks.filter(d => d !== 0)}\r\n y={yTicks.filter(d => d !== 0).map(d => y(d))}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n styles={{\r\n gridLines: styles?.yAxis?.gridLines,\r\n labels: styles?.yAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.yAxis?.gridLines,\r\n labels: classNames?.yAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n labelPos='vertical'\r\n precision={precision}\r\n />\r\n <Axis\r\n y1={y(minParam < 0 ? 0 : minParam)}\r\n y2={y(minParam < 0 ? 0 : minParam)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n label={numberFormattingFunction(\r\n minParam < 0 ? 0 : minParam,\r\n 'NA',\r\n precision,\r\n prefix,\r\n suffix,\r\n )}\r\n labelPos={{\r\n x: 0 - leftMargin,\r\n dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\r\n y: y(minParam < 0 ? 0 : minParam),\r\n }}\r\n classNames={{\r\n axis: classNames?.xAxis?.axis,\r\n label: classNames?.yAxis?.labels,\r\n }}\r\n styles={{\r\n axis: styles?.xAxis?.axis,\r\n label: styles?.yAxis?.labels,\r\n }}\r\n />\r\n <AxisTitle\r\n x={0 - leftMargin - 15}\r\n y={graphHeight / 2}\r\n style={styles?.yAxis?.title}\r\n className={classNames?.yAxis?.title}\r\n text={yAxisTitle}\r\n rotate90\r\n />\r\n </g>\r\n <XTicksAndGridLines\r\n values={xTicks.map(d => format(d, dateFormat))}\r\n x={xTicks.map(d => x(d))}\r\n y1={0}\r\n y2={graphHeight}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: cn('opacity-0', classNames?.xAxis?.gridLines),\r\n labels: cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n ),\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='primary'\r\n showGridLines\r\n precision={precision}\r\n />\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <motion.g>\r\n {dataArray.map((d, i) => {\r\n return (\r\n <motion.path\r\n key={i}\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d={areaShape(d as any) as string}\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n d: areaShape(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.map(el => ({ ...el, y0: 0, y1: 0 })) as any,\r\n ) as string as string,\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d: areaShape(d as any) as string,\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 style={{\r\n fill: colors[i],\r\n opacity: 0.8,\r\n }}\r\n />\r\n );\r\n })}\r\n {mouseOverData ? (\r\n <line\r\n y1={0}\r\n y2={graphHeight}\r\n x1={x(mouseOverData.date)}\r\n x2={x(mouseOverData.date)}\r\n className={cn(\r\n 'undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100',\r\n classNames?.mouseOverLine,\r\n )}\r\n style={styles?.mouseOverLine}\r\n />\r\n ) : null}\r\n </motion.g>\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineY\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n y={y(el.value as number)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n classNames={el.classNames}\r\n styles={el.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n ))}\r\n </>\r\n ) : null}\r\n <g>\r\n {annotations.map((d, i) => {\r\n const endPoints = getLineEndPoint(\r\n {\r\n x: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n },\r\n {\r\n x: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n y: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n },\r\n checkIfNullOrUndefined(d.connectorRadius) ? 3.5 : (d.connectorRadius as number),\r\n );\r\n const connectorSettings = d.showConnector\r\n ? {\r\n y1: endPoints.y,\r\n x1: endPoints.x,\r\n y2: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0)\r\n : 0 + (d.yOffset || 0),\r\n x2: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n cy: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n circleRadius: checkIfNullOrUndefined(d.connectorRadius)\r\n ? 3.5\r\n : (d.connectorRadius as number),\r\n strokeWidth: d.showConnector === true ? 2 : Math.min(d.showConnector || 0, 1),\r\n }\r\n : undefined;\r\n const labelSettings = {\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n x: rtl\r\n ? 0\r\n : d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n width: rtl\r\n ? d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)\r\n : graphWidth +\r\n margin.right -\r\n (d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)),\r\n maxWidth: d.maxWidth,\r\n fontWeight: d.fontWeight,\r\n align: d.align,\r\n };\r\n return (\r\n <Annotation\r\n key={i}\r\n color={d.color}\r\n connectorsSettings={connectorSettings}\r\n labelSettings={labelSettings}\r\n text={d.text}\r\n classNames={d.classNames}\r\n styles={d.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n );\r\n })}\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 </motion.g>\r\n </AnimatePresence>\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 </>\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 AnnotationSettingsDataType,\r\n AreaChartDataType,\r\n CustomHighlightAreaSettingsDataType,\r\n Languages,\r\n ReferenceDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n HighlightAreaSettingsDataType,\r\n CurveTypes,\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 { ColorLegend } from '@/Components/Elements/ColorLegend';\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: AreaChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** array of colors for different lines and areas */\r\n colors?: 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\r\n // Values and Ticks\r\n /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n /** Reference values for comparison */\r\n refValues?: ReferenceDataType[];\r\n /** No. of ticks on the x-axis */\r\n noOfXTicks?: number;\r\n /** No. of ticks on the y-axis */\r\n noOfYTicks?: 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 /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Title for the Y-axis */\r\n yAxisTitle?: string;\r\n /** Annotations on the chart */\r\n annotations?: AnnotationSettingsDataType[];\r\n /** Highlighted area(square) on the chart */\r\n highlightAreaSettings?: HighlightAreaSettingsDataType[];\r\n /** Highlighted area(custom shape) on the chart */\r\n customHighlightAreaSettings?: CustomHighlightAreaSettingsDataType[];\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\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 /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\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 AreaChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n colorDomain,\r\n padding,\r\n backgroundColor = false,\r\n colorLegendTitle,\r\n leftMargin = 50,\r\n rightMargin = 20,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n highlightAreaSettings = [],\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n refValues = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n showColorScale = true,\r\n language = 'en',\r\n minHeight = 0,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n prefix = '',\r\n suffix = '',\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n precision = 2,\r\n customLayers = [],\r\n animate = false,\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 stacked area chart that shows 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 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 !== false ? (\r\n <ColorLegend\r\n colorDomain={colorDomain}\r\n colors={colors}\r\n colorLegendTitle={colorLegendTitle}\r\n showNAColor={false}\r\n />\r\n ) : null}\r\n <div className='w-full grow leading-0' ref={graphDiv} aria-label='Graph area'>\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n colors={colors}\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 noOfXTicks={noOfXTicks}\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 highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n rtl={language === 'he' || language === 'ar'}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n prefix={prefix}\r\n suffix={suffix}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n precision={precision}\r\n customLayers={customLayers}\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 />\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","colors","dateFormat","noOfXTicks","rightMargin","leftMargin","topMargin","bottomMargin","yAxisTitle","tooltip","onSeriesMouseOver","highlightAreaSettings","refValues","minValue","maxValue","rtl","annotations","customHighlightAreaSettings","noOfYTicks","prefix","suffix","curveType","styles","classNames","precision","customLayers","animate","svgRef","useRef","isInView","useInView","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","dataFormatted","orderBy","d","parse","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","el","j","dataArray","_d","i","sum","_element","k","graphWidth","graphHeight","minYear","maxYear","minParam","checkIfNullOrUndefined","maxParam","x","scaleTime","y","scaleLinear","areaShape","area","yTicks","xTicks","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","AnimatePresence","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","AreaChart","graphTitle","Colors","sources","graphDescription","footNote","colorDomain","padding","backgroundColor","colorLegendTitle","relativeHeight","graphID","graphDownload","dataDownload","showColorScale","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","ColorLegend","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EO,SAASA,GAAMC,IAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,uB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