@undp/data-viz 1.4.7 → 1.4.9

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 (38) hide show
  1. package/dist/AreaChart.cjs +1 -1
  2. package/dist/AreaChart.cjs.map +1 -1
  3. package/dist/AreaChart.js +58 -58
  4. package/dist/AreaChart.js.map +1 -1
  5. package/dist/DifferenceLineChart.cjs +1 -1
  6. package/dist/DifferenceLineChart.cjs.map +1 -1
  7. package/dist/DifferenceLineChart.js +44 -44
  8. package/dist/DifferenceLineChart.js.map +1 -1
  9. package/dist/DualAxisLineChart.cjs +1 -1
  10. package/dist/DualAxisLineChart.cjs.map +1 -1
  11. package/dist/DualAxisLineChart.js +1 -1
  12. package/dist/DualAxisLineChart.js.map +1 -1
  13. package/dist/LineChartWithConfidenceInterval.cjs +1 -1
  14. package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
  15. package/dist/LineChartWithConfidenceInterval.js +33 -33
  16. package/dist/LineChartWithConfidenceInterval.js.map +1 -1
  17. package/dist/MultiLineAltChart.cjs +1 -1
  18. package/dist/MultiLineAltChart.cjs.map +1 -1
  19. package/dist/MultiLineAltChart.js +78 -78
  20. package/dist/MultiLineAltChart.js.map +1 -1
  21. package/dist/MultiLineChart.cjs +1 -1
  22. package/dist/MultiLineChart.cjs.map +1 -1
  23. package/dist/MultiLineChart.js +28 -28
  24. package/dist/MultiLineChart.js.map +1 -1
  25. package/dist/ScatterPlot.cjs +1 -1
  26. package/dist/ScatterPlot.cjs.map +1 -1
  27. package/dist/ScatterPlot.js +43 -43
  28. package/dist/ScatterPlot.js.map +1 -1
  29. package/dist/SimpleLineChart.cjs +1 -1
  30. package/dist/SimpleLineChart.cjs.map +1 -1
  31. package/dist/SimpleLineChart.js +17 -17
  32. package/dist/SimpleLineChart.js.map +1 -1
  33. package/dist/SparkLine.cjs +1 -1
  34. package/dist/SparkLine.cjs.map +1 -1
  35. package/dist/SparkLine.js +1 -1
  36. package/dist/SparkLine.js.map +1 -1
  37. package/dist/style.css +1 -1
  38. package/package.json +2 -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"),u=require("./parse-hMnG_lRV.cjs"),de=require("./index-BzeLQvXk.cjs"),ue=require("./index-C21TvELx.cjs"),he=require("./numberFormattingFunction-02t-wJta.cjs"),fe=require("./Tooltip-n8z5bfav.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-DNj994Pv.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:l,leftMargin:f,topMargin:ie,bottomMargin:re,yAxisTitle:P,tooltip:D,onSeriesMouseOver:m,highlightAreaSettings:oe,refValues:V,minValue:I,maxValue:Y,rtl:W,annotations:ne,customHighlightAreaSettings:ae,noOfYTicks:S,prefix:M,suffix:F,curveType:$,styles:p,classNames:g,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),d={top:ie,bottom:re,left:P?f+30:f,right:l},J=h.useRef(null),i=de.sortBy(w.map(e=>({...e,date:u.parse(`${e.date}`,o,new Date)})),"date"),A=oe.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:u.parse(`${e.coordinates[0]}`,o,new Date),e.coordinates[1]===null?null:u.parse(`${e.coordinates[1]}`,o,new Date)]})),ce=ae.map(e=>({...e,coordinates:e.coordinates.map((n,a)=>a%2===0?u.parse(`${n}`,o,new Date):n)})),xe=i[0].y.map((e,n)=>i.map(a=>({date:a.date,y0:n===0?0:ue.sum(a.y.filter((T,O)=>O<n)),y1:ue.sum(a.y.filter((T,O)=>O<=n))}))),v=R-d.left-d.right,c=q-d.top-d.bottom,K=i[0].date,Q=i[i.length-1].date,x=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([x,C]).range([c,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=a=>{const T=i[Ne.bisectCenter(i.map(O=>O.date),r.invert(Se.pointer(a)[0]),1)];X(T||i[i.length-1]),m?.(T||i[i.length-1]),z(a.clientY),B(a.clientX)},n=()=>{X(void 0),B(void 0),z(void 0),m?.(void 0)};qe.select(J.current).on("mousemove",e).on("mouseout",n),m?.(void 0)},[r,i,m]),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(${d.left},${d.top})`,children:[t.jsxRuntimeExports.jsx(Ee.HighlightArea,{areaSettings:A,width:v,height:c,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+d.right,styles:{gridLines:p?.yAxis?.gridLines,labels:p?.yAxis?.labels},classNames:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},suffix:F,prefix:M,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:k}),t.jsxRuntimeExports.jsx(je.Axis,{y1:s(x<0?0:x),y2:s(x<0?0:x),x1:0-f,x2:v+d.right,label:he.numberFormattingFunction(x<0?0:x,"NA",k,M,F),labelPos:{x:0-f,dx:0,dy:C<0?"1em":-5,y:s(x<0?0:x)},classNames:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels},styles:{axis:p?.xAxis?.axis,label:p?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(ye.AxisTitle,{x:0-f-15,y:c/2,style:p?.yAxis?.title,className:g?.yAxis?.title,text:P,rotate90:!0})]}),t.jsxRuntimeExports.jsx(ve.XTicksAndGridLines,{values:ge.map(e=>u.format(e,o)),x:ge.map(e=>r(e)),y1:0,y2:c,styles:{gridLines:p?.xAxis?.gridLines,labels:p?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",g?.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",g?.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(a=>({...a,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:c,x1:r(b.date),x2:r(b.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",g?.mouseOverLine),style:p?.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+d.right,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n))}):null,t.jsxRuntimeExports.jsx("g",{children:ne.map((e,n)=>{const a=me.getLineEndPoint({x:e.xCoordinate?r(u.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(u.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:a.y,x1:a.x,y2:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),cx:e.xCoordinate?r(u.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(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:W?e.xCoordinate?r(u.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0):v-(e.xCoordinate?r(u.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:c})]})})}),b&&D&&U&&_?t.jsxRuntimeExports.jsx(fe.Tooltip,{data:b,body:D,xPos:U,yPos:_,backgroundStyle:p?.tooltip,className:g?.tooltip}):null]})}function Ge(se){const{data:w,graphTitle:R,colors:q=Me.Colors.light.categoricalColors.colors,sources:G,graphDescription:o,height:N,width:l,footNote:f,noOfXTicks:ie=10,dateFormat:re="yyyy",colorDomain:P,padding:D,backgroundColor:m=!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:p,maxValue:g,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:d="",curveType:J="curve",styles:i,classNames:A,precision:ce=2,customLayers:xe=[],animate:v=!1}=se,[c,K]=h.useState(0),[Q,x]=h.useState(0),C=h.useRef(null),r=h.useRef(null);return h.useEffect(()=>{const s=new ResizeObserver(L=>{K(l||L[0].target.clientWidth||620),x(N||L[0].target.clientHeight||480)});return C.current&&(x(C.current.clientHeight||480),K(C.current.clientWidth||620),l||s.observe(C.current)),()=>s.disconnect()},[l,N]),t.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:E==="he"||E==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${m?m===!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?.graphContainer),style:{...i?.graphContainer||{},...m&&m!==!0?{backgroundColor:m}:{}},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:m?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:l,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:(l||c)&&(N||Q)?t.jsxRuntimeExports.jsx(He,{data:w,colors:q,width:l||c,height:Math.max(j,N||(S?j?(l||c)*S>j?(l||c)*S:j:(l||c)*S:Q)),dateFormat:re,noOfXTicks:ie,leftMargin:V,rightMargin:I,topMargin:Y,bottomMargin:W,tooltip:ae,onSeriesMouseOver:M,highlightAreaSettings:ne,refValues:F,minValue:p,maxValue:g,rtl:E==="he"||E==="ar",annotations:le,customHighlightAreaSettings:b,yAxisTitle:B,noOfYTicks:_,prefix:z,suffix:d,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:l}):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"),de=require("./index-BzeLQvXk.cjs"),ue=require("./index-C21TvELx.cjs"),he=require("./numberFormattingFunction-02t-wJta.cjs"),fe=require("./Tooltip-n8z5bfav.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-DNj994Pv.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:l,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:l},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,a)=>a%2===0?m.parse(`${n}`,o,new Date):n)})),xe=i[0].y.map((e,n)=>i.map(a=>({date:a.date,y0:n===0?0:ue.sum(a.y.filter((T,O)=>O<n)),y1:ue.sum(a.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=a=>{const T=i[Ne.bisectCenter(i.map(O=>O.date),r.invert(Se.pointer(a)[0]),0)];X(T||i[i.length-1]),p?.(T||i[i.length-1]),z(a.clientY),B(a.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(a=>({...a,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 a=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:a.y,x1:a.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:l,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(l||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),l||s.observe(C.current)),()=>s.disconnect()},[l,N]),t.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${l?"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?.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:l,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:(l||x)&&(N||Q)?t.jsxRuntimeExports.jsx(He,{data:w,colors:q,width:l||x,height:Math.max(j,N||(S?j?(l||x)*S>j?(l||x)*S:j:(l||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:l}):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 1,\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 (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 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,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,OACpBjD,EAAK,IAAIkD,IAAM,CACb,GAAGA,EACH,KAAMC,EAAAA,MAAM,GAAGD,EAAE,IAAI,GAAI9C,EAAY,IAAI,IAAM,CAAA,EAC/C,EACF,MAAA,EAEIgD,EAA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AAQA,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 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 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,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,EAC5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AAU,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"}
package/dist/AreaChart.js CHANGED
@@ -43,7 +43,7 @@ function ze(oe) {
43
43
  bottomMargin: ie,
44
44
  yAxisTitle: W,
45
45
  tooltip: H,
46
- onSeriesMouseOver: x,
46
+ onSeriesMouseOver: f,
47
47
  highlightAreaSettings: re,
48
48
  refValues: X,
49
49
  minValue: E,
@@ -55,15 +55,15 @@ function ze(oe) {
55
55
  prefix: R,
56
56
  suffix: F,
57
57
  curveType: k,
58
- styles: f,
59
- classNames: g,
58
+ styles: g,
59
+ classNames: p,
60
60
  precision: S,
61
61
  customLayers: Y,
62
62
  animate: d
63
63
  } = oe, C = ae(null), y = We(C, {
64
64
  once: d.once,
65
65
  amount: d.amount
66
- }), ce = k === "linear" ? Te : k === "step" ? Me : k === "stepAfter" ? He : k === "stepBefore" ? Re : Fe, [O, B] = P(void 0), [_, z] = P(void 0), [U, q] = P(void 0), p = {
66
+ }), ce = k === "linear" ? Te : k === "step" ? Me : k === "stepAfter" ? He : k === "stepBefore" ? Re : Fe, [O, B] = P(void 0), [_, z] = P(void 0), [U, q] = P(void 0), c = {
67
67
  top: se,
68
68
  bottom: ie,
69
69
  left: W ? u + 30 : u,
@@ -89,20 +89,20 @@ function ze(oe) {
89
89
  date: n.date,
90
90
  y0: r === 0 ? 0 : fe(n.y.filter((M, $) => $ < r)),
91
91
  y1: fe(n.y.filter((M, $) => $ <= r))
92
- }))), v = A - p.left - p.right, c = N - p.top - p.bottom, K = o[0].date, Q = o[o.length - 1].date, m = Z(E) ? 0 : E, j = Z(G) ? Math.max(...w.map((e) => fe(e.y) || 0)) : G, s = Le().domain([K, Q]).range([0, v]), a = ke().domain([m, j]).range([c, 0]).nice(), T = Se().x((e) => s(e.date)).y0((e) => a(e.y0)).y1((e) => a(e.y1)).curve(ce), ge = a.ticks(L), pe = s.ticks(D);
92
+ }))), v = A - c.left - c.right, m = N - c.top - c.bottom, K = o[0].date, Q = o[o.length - 1].date, x = Z(E) ? 0 : E, j = Z(G) ? Math.max(...w.map((e) => fe(e.y) || 0)) : G, s = Le().domain([K, Q]).range([0, v]), a = ke().domain([x, j]).range([m, 0]).nice(), T = Se().x((e) => s(e.date)).y0((e) => a(e.y0)).y1((e) => a(e.y1)).curve(ce), ge = a.ticks(L), pe = s.ticks(D);
93
93
  return he(() => {
94
94
  const e = (n) => {
95
95
  const M = o[Pe(
96
96
  o.map(($) => $.date),
97
97
  s.invert(Ve(n)[0]),
98
- 1
98
+ 0
99
99
  )];
100
- B(M || o[o.length - 1]), x?.(M || o[o.length - 1]), q(n.clientY), z(n.clientX);
100
+ B(M || o[o.length - 1]), f?.(M || o[o.length - 1]), q(n.clientY), z(n.clientX);
101
101
  }, r = () => {
102
- B(void 0), z(void 0), q(void 0), x?.(void 0);
102
+ B(void 0), z(void 0), q(void 0), f?.(void 0);
103
103
  };
104
- Ye(J.current).on("mousemove", e).on("mouseout", r), x?.(void 0);
105
- }, [s, o, x]), /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
104
+ Ye(J.current).on("mousemove", e).on("mouseout", r), f?.(void 0);
105
+ }, [s, o, f]), /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
106
106
  /* @__PURE__ */ t.jsx(
107
107
  ee.svg,
108
108
  {
@@ -111,13 +111,13 @@ function ze(oe) {
111
111
  viewBox: `0 0 ${A} ${N}`,
112
112
  direction: "ltr",
113
113
  ref: C,
114
- children: /* @__PURE__ */ t.jsx(Xe, { children: /* @__PURE__ */ t.jsxs(ee.g, { transform: `translate(${p.left},${p.top})`, children: [
114
+ children: /* @__PURE__ */ t.jsx(Xe, { children: /* @__PURE__ */ t.jsxs(ee.g, { transform: `translate(${c.left},${c.top})`, children: [
115
115
  /* @__PURE__ */ t.jsx(
116
116
  De,
117
117
  {
118
118
  areaSettings: b,
119
119
  width: v,
120
- height: c,
120
+ height: m,
121
121
  scale: s,
122
122
  animate: d,
123
123
  isInView: y
@@ -140,15 +140,15 @@ function ze(oe) {
140
140
  values: ge.filter((e) => e !== 0),
141
141
  y: ge.filter((e) => e !== 0).map((e) => a(e)),
142
142
  x1: 0 - u,
143
- x2: v + p.right,
143
+ x2: v + c.right,
144
144
  styles: {
145
- gridLines: f?.yAxis?.gridLines,
146
- labels: f?.yAxis?.labels
147
- },
148
- classNames: {
149
145
  gridLines: g?.yAxis?.gridLines,
150
146
  labels: g?.yAxis?.labels
151
147
  },
148
+ classNames: {
149
+ gridLines: p?.yAxis?.gridLines,
150
+ labels: p?.yAxis?.labels
151
+ },
152
152
  suffix: F,
153
153
  prefix: R,
154
154
  labelType: "secondary",
@@ -160,12 +160,12 @@ function ze(oe) {
160
160
  /* @__PURE__ */ t.jsx(
161
161
  je,
162
162
  {
163
- y1: a(m < 0 ? 0 : m),
164
- y2: a(m < 0 ? 0 : m),
163
+ y1: a(x < 0 ? 0 : x),
164
+ y2: a(x < 0 ? 0 : x),
165
165
  x1: 0 - u,
166
- x2: v + p.right,
166
+ x2: v + c.right,
167
167
  label: ye(
168
- m < 0 ? 0 : m,
168
+ x < 0 ? 0 : x,
169
169
  "NA",
170
170
  S,
171
171
  R,
@@ -175,15 +175,15 @@ function ze(oe) {
175
175
  x: 0 - u,
176
176
  dx: 0,
177
177
  dy: j < 0 ? "1em" : -5,
178
- y: a(m < 0 ? 0 : m)
178
+ y: a(x < 0 ? 0 : x)
179
179
  },
180
180
  classNames: {
181
- axis: g?.xAxis?.axis,
182
- label: g?.yAxis?.labels
181
+ axis: p?.xAxis?.axis,
182
+ label: p?.yAxis?.labels
183
183
  },
184
184
  styles: {
185
- axis: f?.xAxis?.axis,
186
- label: f?.yAxis?.labels
185
+ axis: g?.xAxis?.axis,
186
+ label: g?.yAxis?.labels
187
187
  }
188
188
  }
189
189
  ),
@@ -191,9 +191,9 @@ function ze(oe) {
191
191
  be,
192
192
  {
193
193
  x: 0 - u - 15,
194
- y: c / 2,
195
- style: f?.yAxis?.title,
196
- className: g?.yAxis?.title,
194
+ y: m / 2,
195
+ style: g?.yAxis?.title,
196
+ className: p?.yAxis?.title,
197
197
  text: W,
198
198
  rotate90: !0
199
199
  }
@@ -205,16 +205,16 @@ function ze(oe) {
205
205
  values: pe.map((e) => ue(e, i)),
206
206
  x: pe.map((e) => s(e)),
207
207
  y1: 0,
208
- y2: c,
208
+ y2: m,
209
209
  styles: {
210
- gridLines: f?.xAxis?.gridLines,
211
- labels: f?.xAxis?.labels
210
+ gridLines: g?.xAxis?.gridLines,
211
+ labels: g?.xAxis?.labels
212
212
  },
213
213
  classNames: {
214
- gridLines: te("opacity-0", g?.xAxis?.gridLines),
214
+ gridLines: te("opacity-0", p?.xAxis?.gridLines),
215
215
  labels: te(
216
216
  "fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs",
217
- g?.xAxis?.labels
217
+ p?.xAxis?.labels
218
218
  )
219
219
  },
220
220
  suffix: F,
@@ -262,14 +262,14 @@ function ze(oe) {
262
262
  "line",
263
263
  {
264
264
  y1: 0,
265
- y2: c,
265
+ y2: m,
266
266
  x1: s(O.date),
267
267
  x2: s(O.date),
268
268
  className: te(
269
269
  "undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",
270
- g?.mouseOverLine
270
+ p?.mouseOverLine
271
271
  ),
272
- style: f?.mouseOverLine
272
+ style: g?.mouseOverLine
273
273
  }
274
274
  ) : null
275
275
  ] }),
@@ -280,7 +280,7 @@ function ze(oe) {
280
280
  color: e.color,
281
281
  y: a(e.value),
282
282
  x1: 0 - u,
283
- x2: v + p.right,
283
+ x2: v + c.right,
284
284
  classNames: e.classNames,
285
285
  styles: e.styles,
286
286
  animate: d,
@@ -311,7 +311,7 @@ function ze(oe) {
311
311
  } : void 0, $ = {
312
312
  y: e.yCoordinate ? a(e.yCoordinate) + (e.yOffset || 0) - 8 : 0 + (e.yOffset || 0) - 8,
313
313
  x: I ? 0 : e.xCoordinate ? s(h(`${e.xCoordinate}`, i, /* @__PURE__ */ new Date())) + (e.xOffset || 0) : 0 + (e.xOffset || 0),
314
- width: I ? e.xCoordinate ? s(h(`${e.xCoordinate}`, i, /* @__PURE__ */ new Date())) + (e.xOffset || 0) : 0 + (e.xOffset || 0) : v - (e.xCoordinate ? s(h(`${e.xCoordinate}`, i, /* @__PURE__ */ new Date())) + (e.xOffset || 0) : 0 + (e.xOffset || 0)),
314
+ width: I ? e.xCoordinate ? s(h(`${e.xCoordinate}`, i, /* @__PURE__ */ new Date())) + (e.xOffset || 0) : 0 + (e.xOffset || 0) : v + c.right - (e.xCoordinate ? s(h(`${e.xCoordinate}`, i, /* @__PURE__ */ new Date())) + (e.xOffset || 0) : 0 + (e.xOffset || 0)),
315
315
  maxWidth: e.maxWidth,
316
316
  fontWeight: e.fontWeight,
317
317
  align: e.align
@@ -341,7 +341,7 @@ function ze(oe) {
341
341
  pointerEvents: "all"
342
342
  },
343
343
  width: v,
344
- height: c
344
+ height: m
345
345
  }
346
346
  )
347
347
  ] }) })
@@ -354,8 +354,8 @@ function ze(oe) {
354
354
  body: H,
355
355
  xPos: _,
356
356
  yPos: U,
357
- backgroundStyle: f?.tooltip,
358
- className: g?.tooltip
357
+ backgroundStyle: g?.tooltip,
358
+ className: p?.tooltip
359
359
  }
360
360
  ) : null
361
361
  ] });
@@ -374,7 +374,7 @@ function Ot(oe) {
374
374
  dateFormat: ie = "yyyy",
375
375
  colorDomain: W,
376
376
  padding: H,
377
- backgroundColor: x = !1,
377
+ backgroundColor: f = !1,
378
378
  colorLegendTitle: re,
379
379
  leftMargin: X = 50,
380
380
  rightMargin: E = 20,
@@ -386,8 +386,8 @@ function Ot(oe) {
386
386
  onSeriesMouseOver: R,
387
387
  refValues: F = [],
388
388
  graphID: k,
389
- minValue: f,
390
- maxValue: g,
389
+ minValue: g,
390
+ maxValue: p,
391
391
  graphDownload: S = !1,
392
392
  dataDownload: Y = !1,
393
393
  showColorScale: d = !0,
@@ -400,19 +400,19 @@ function Ot(oe) {
400
400
  yAxisTitle: z,
401
401
  noOfYTicks: U = 5,
402
402
  prefix: q = "",
403
- suffix: p = "",
403
+ suffix: c = "",
404
404
  curveType: J = "curve",
405
405
  styles: o,
406
406
  classNames: b,
407
407
  precision: me = 2,
408
408
  customLayers: xe = [],
409
409
  animate: v = !1
410
- } = oe, [c, K] = P(0), [Q, m] = P(0), j = ae(null), s = ae(null);
410
+ } = oe, [m, K] = P(0), [Q, x] = P(0), j = ae(null), s = ae(null);
411
411
  return he(() => {
412
412
  const a = new ResizeObserver((T) => {
413
- K(l || T[0].target.clientWidth || 620), m(D || T[0].target.clientHeight || 480);
413
+ K(l || T[0].target.clientWidth || 620), x(D || T[0].target.clientHeight || 480);
414
414
  });
415
- return j.current && (m(j.current.clientHeight || 480), K(j.current.clientWidth || 620), l || a.observe(j.current)), () => a.disconnect();
415
+ return j.current && (x(j.current.clientHeight || 480), K(j.current.clientWidth || 620), l || a.observe(j.current)), () => a.disconnect();
416
416
  }, [l, D]), /* @__PURE__ */ t.jsx(
417
417
  "div",
418
418
  {
@@ -422,12 +422,12 @@ function Ot(oe) {
422
422
  "div",
423
423
  {
424
424
  className: te(
425
- `${x ? x === !0 ? "bg-primary-gray-200 dark:bg-primary-gray-650 " : "" : "bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${C || "en"}`,
425
+ `${f ? f === !0 ? "bg-primary-gray-200 dark:bg-primary-gray-650 " : "" : "bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${C || "en"}`,
426
426
  b?.graphContainer
427
427
  ),
428
428
  style: {
429
429
  ...o?.graphContainer || {},
430
- ...x && x !== !0 ? { backgroundColor: x } : {}
430
+ ...f && f !== !0 ? { backgroundColor: f } : {}
431
431
  },
432
432
  id: k,
433
433
  ref: s,
@@ -436,7 +436,7 @@ function Ot(oe) {
436
436
  "div",
437
437
  {
438
438
  className: "flex grow",
439
- style: { padding: x ? H || "1rem" : H || 0 },
439
+ style: { padding: f ? H || "1rem" : H || 0 },
440
440
  children: /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col w-full gap-4 grow justify-between", children: [
441
441
  A || i || S || Y ? /* @__PURE__ */ t.jsx(
442
442
  Ge,
@@ -466,15 +466,15 @@ function Ot(oe) {
466
466
  showNAColor: !1
467
467
  }
468
468
  ) : null,
469
- /* @__PURE__ */ t.jsx("div", { className: "w-full grow leading-0", ref: j, "aria-label": "Graph area", children: (l || c) && (D || Q) ? /* @__PURE__ */ t.jsx(
469
+ /* @__PURE__ */ t.jsx("div", { className: "w-full grow leading-0", ref: j, "aria-label": "Graph area", children: (l || m) && (D || Q) ? /* @__PURE__ */ t.jsx(
470
470
  ze,
471
471
  {
472
472
  data: w,
473
473
  colors: N,
474
- width: l || c,
474
+ width: l || m,
475
475
  height: Math.max(
476
476
  y,
477
- D || (L ? y ? (l || c) * L > y ? (l || c) * L : y : (l || c) * L : Q)
477
+ D || (L ? y ? (l || m) * L > y ? (l || m) * L : y : (l || m) * L : Q)
478
478
  ),
479
479
  dateFormat: ie,
480
480
  noOfXTicks: se,
@@ -486,15 +486,15 @@ function Ot(oe) {
486
486
  onSeriesMouseOver: R,
487
487
  highlightAreaSettings: ne,
488
488
  refValues: F,
489
- minValue: f,
490
- maxValue: g,
489
+ minValue: g,
490
+ maxValue: p,
491
491
  rtl: C === "he" || C === "ar",
492
492
  annotations: ce,
493
493
  customHighlightAreaSettings: O,
494
494
  yAxisTitle: z,
495
495
  noOfYTicks: U,
496
496
  prefix: q,
497
- suffix: p,
497
+ suffix: c,
498
498
  curveType: J,
499
499
  styles: o,
500
500
  classNames: b,