@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"),p=require("react"),fe=require("./index-CZbIGs8q.cjs"),d=require("./parse-hMnG_lRV.cjs"),Ae=require("./index-BzeLQvXk.cjs"),Le=require("./numberFormattingFunction-02t-wJta.cjs"),Se=require("./Tooltip-n8z5bfav.cjs"),m=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ne=require("./customArea-CK768gCn.cjs"),Me=require("./AxisTitle-CK9YeovX.cjs"),$e=require("./Axis-DE7dSn1_.cjs"),Te=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Ve=require("./ReferenceLine-CFVBBN__.cjs"),Ue=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Fe=require("./index-DNj994Pv.cjs"),q=require("./Colors.cjs"),He=require("./time-Byw_jYQ7.cjs"),We=require("./linear-BVckp9RD.cjs"),Ge=require("./delaunay-rcy0HhZi.cjs"),qe=require("./line-DHV4JwCR.cjs"),he=require("./step-BZ3C8QFW.cjs"),Ye=require("./select-Bnfk0lJx.cjs"),Pe=require("./init-DU0ybBc_.cjs"),Xe=require("./pointer-Dkq5NV1q.cjs"),Be=require("./use-in-view-sQJZ_xDO.cjs"),Y=require("./proxy-BHRoeZgd.cjs"),ze=require("./GraphFooter.cjs"),Je=require("./GraphHeader.cjs"),Ke=require("./EmptyState-d8_8SxeW.cjs"),Qe=require("./ColorLegendWithMouseOver.cjs");function Ze(de){const{data:s,width:I,height:K,lineColors:a,dateFormat:u,noOfXTicks:pe,rightMargin:_,topMargin:ge,bottomMargin:P,suffix:A,prefix:h,leftMargin:C,tooltip:ee,onSeriesMouseOver:T,refValues:Q,highlightAreaSettings:S,minValue:X,maxValue:te,highlightedLines:N,animate:n,rtl:ie,strokeWidth:k,showDots:B,annotations:ye,customHighlightAreaSettings:je,yAxisTitle:oe,noOfYTicks:we,minDate:ne,maxDate:re,curveType:z,styles:b,colorDomain:v,selectedColor:V,classNames:g,showLabels:U,dimmedOpacity:R,precision:D,naLabel:be,customLayers:se}=de,ae=p.useRef(null),y=Be.useInView(ae,{once:n.once,amount:n.amount}),[E,ve]=p.useState(!1);p.useEffect(()=>{if(y&&!E){const e=setTimeout(()=>{ve(!0)},(n.duration+.5)*1e3);return()=>clearTimeout(e)}},[y,E,n.duration]);const Oe=z==="linear"?qe.curveLinear:z==="step"?he.curveStep:z==="stepAfter"?he.stepAfter:z==="stepBefore"?he.stepBefore:he.monotoneX,l=Ae.sortBy(s.map(e=>({...e,date:d.parse(`${e.date}`,u,new Date)})),"date").filter(e=>!m.checkIfNullOrUndefined(e.y)),Ce=fe.uniqBy(l,e=>e.label).map(e=>e.label),Z=fe.uniqBy(Ae.sortBy(s.map(e=>({...e,date:d.parse(`${e.date}`,u,new Date)})),"date"),e=>e.date).map(e=>e.date),[f,j]=p.useState(void 0),[L,F]=p.useState(void 0),[le,H]=p.useState(void 0),O={top:ge,bottom:P,left:oe?C+30:C,right:_},W=p.useRef(null),ce=Ce.map(e=>Ae.sortBy(l.filter(o=>o.label==e),"date")),xe=S.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:d.parse(`${e.coordinates[0]}`,u,new Date),e.coordinates[1]===null?null:d.parse(`${e.coordinates[1]}`,u,new Date)]})),ue=je.map(e=>({...e,coordinates:e.coordinates.map((o,x)=>x%2===0?d.parse(`${o}`,u,new Date):o)})),w=I-O.left-O.right,M=K-O.top-O.bottom,G=ne?d.parse(`${ne}`,u,new Date):Z[0],me=re?d.parse(`${re}`,u,new Date):Z[Z.length-1],i=m.checkIfNullOrUndefined(X)?Math.min(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e)))?Math.min(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e)))>0?0:Math.min(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e))):0:X,J=Math.max(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e)))?Math.max(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e))):0,r=He.time().domain([G,me]).range([0,w]),c=We.linear().domain([m.checkIfNullOrUndefined(X)?i:X,m.checkIfNullOrUndefined(te)?J>0?J:0:te]).range([M,0]).nice(),Ie=Ge.Delaunay.from(l.filter(e=>!m.checkIfNullOrUndefined(e.date)&&!m.checkIfNullOrUndefined(e.y)),e=>r(e.date),e=>c(e.y)).voronoi([0,0,w<0?0:w,M<0?0:M]),Re=qe.line().x(e=>r(e.date)).y(e=>c(e.y)).curve(Oe),ke=c.ticks(we),De=r.ticks(pe);return p.useEffect(()=>{const e=x=>{const $=l[Pe.bisectCenter(l.map(Ee=>Ee.date),r.invert(Xe.pointer(x)[0]),1)];j($||l[l.length-1]),H(x.clientY),F(x.clientX),T?.($||l[l.length-1])},o=()=>{j(void 0),F(void 0),H(void 0)};Ye.select(W.current).on("mousemove",e).on("mouseout",o),T?.(void 0)},[r,l,T]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(Y.motion.svg,{width:`${I}px`,height:`${K}px`,viewBox:`0 0 ${I} ${K}`,direction:"ltr",ref:ae,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${O.left},${O.top})`,children:[t.jsxRuntimeExports.jsx(Fe.HighlightArea,{areaSettings:xe,width:w,height:M,scale:r,animate:n,isInView:y}),t.jsxRuntimeExports.jsx(Ne.CustomArea,{areaSettings:ue,scaleX:r,scaleY:c,animate:n,isInView:y}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Ue.YTicksAndGridLines,{values:ke.filter(e=>e!==0),y:ke.filter(e=>e!==0).map(e=>c(e)),x1:0-C,x2:w+O.right,styles:{gridLines:b?.yAxis?.gridLines,labels:b?.yAxis?.labels},classNames:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},suffix:A,prefix:h,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}),t.jsxRuntimeExports.jsx($e.Axis,{y1:c(i<0?0:i),y2:c(i<0?0:i),x1:0-C,x2:w+O.right,label:Le.numberFormattingFunction(i<0?0:i,"NA",D,h,A),labelPos:{x:0-C,y:c(i<0?0:i),dx:0,dy:J<0?"1em":-5},classNames:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels},styles:{axis:b?.xAxis?.axis,label:b?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(Me.AxisTitle,{x:0-C-15,y:M/2,style:b?.yAxis?.title,className:g?.yAxis?.title,text:oe,rotate90:!0})]}),t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx(Te.XTicksAndGridLines,{values:De.map(e=>d.format(e,u)),x:De.map(e=>r(e)),y1:0,y2:M,styles:{gridLines:b?.xAxis?.gridLines,labels:b?.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-[9px] md:text-[10px] lg:text-xs",g?.xAxis?.labels)},suffix:A,prefix:h,labelType:"primary",showGridLines:!0,precision:D})}),se.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs(Y.motion.g,{children:[ce.map(e=>t.jsxRuntimeExports.jsxs(Y.motion.g,{exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:f?e[0].label===f.label?1:R:V?e[0].color&&a[v.indexOf(e[0].color)]===V?1:R:N.length!==0?N.indexOf(e[0].label)!==-1?1:R:1},whileInView:{opacity:f?e[0].label===f.label?1:R:V?e[0].color&&a[v.indexOf(e[0].color)]===V?1:R:N.length!==0?N.indexOf(e[0].label)!==-1?1:R:1,transition:{duration:n.duration}}},initial:"initial",animate:y?"whileInView":"initial",children:[t.jsxRuntimeExports.jsx(Y.motion.path,{d:Re(e.filter(o=>!m.checkIfNullOrUndefined(o.y)))||"",style:{fill:"none",strokeWidth:f?e[0].label===f.label?k+Math.max(2,.5*k):k:N.length!==0&&N.indexOf(e[0].label)!==-1?k+Math.max(2,.5*k):k},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:Re(e.filter(o=>!m.checkIfNullOrUndefined(o.y)))||"",opacity:1,stroke:s.filter(o=>o.color).length===0?a[0]:e[0].color?a[v.indexOf(e[0].color)]:q.Colors.gray},whileInView:{pathLength:1,d:Re(e.filter(o=>!m.checkIfNullOrUndefined(o.y)))||"",opacity:1,stroke:s.filter(o=>o.color).length===0?a[0]:e[0].color?a[v.indexOf(e[0].color)]:q.Colors.gray,transition:{duration:n.duration}}},initial:"initial",animate:y?"whileInView":"initial"}),e.map((o,x)=>t.jsxRuntimeExports.jsx(Y.motion.g,{children:m.checkIfNullOrUndefined(o.y)?null:t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:B?t.jsxRuntimeExports.jsx(Y.motion.circle,{r:w/e.length<5?0:w/e.length<20?2:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,fill:s.filter($=>$.color).length===0?a[0]:e[0].color?a[v.indexOf(e[0].color)]:q.Colors.gray,cx:r(o.date),cy:c(o.y)},whileInView:{opacity:1,fill:s.filter($=>$.color).length===0?a[0]:e[0].color?a[v.indexOf(e[0].color)]:q.Colors.gray,transition:{duration:E?n.duration:.5,delay:E?0:n.duration},cx:r(o.date),cy:c(o.y)}},initial:"initial",animate:y?"whileInView":"initial"}):null})},x)),(N.indexOf(e[0].label)!==-1||f?.label===e[0].label)&&U?t.jsxRuntimeExports.jsx(Y.motion.text,{style:{fill:s.filter(o=>o.color).length===0?a[0]:e[0].color?a[v.indexOf(e[0].color)]:q.Colors.gray},className:"text-sm font-bold",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:r(e[e.length-1].date),y:c(e[e.length-1].y)},whileInView:{opacity:1,x:r(e[e.length-1].date),y:c(e[e.length-1].y),transition:{duration:E?n.duration:.5,delay:E?0:n.duration}}},initial:"initial",animate:y?"whileInView":"initial",children:e[0].label}):null]},e[0].label)),f?t.jsxRuntimeExports.jsx("text",{y:c(f.y)-8,x:r(f.date),className:t.mo("graph-value text-sm font-bold",g?.graphObjectValues),style:{fill:s.filter(e=>e.color).length===0?a[0]:f.color?a[v.indexOf(f.color)]:q.Colors.gray,textAnchor:"middle",...b?.graphObjectValues||{}},children:Le.numberFormattingFunction(f.y,be,D,h,A)}):null]}),l.filter(e=>!m.checkIfNullOrUndefined(e.y)).map((e,o)=>t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx("path",{d:Ie.renderCell(l.findIndex(x=>x.label===e.label&&x.date===e.date)),opacity:0,onMouseEnter:x=>{j(e),H(x.clientY),F(x.clientX),T?.(e)},onMouseMove:x=>{j(e),H(x.clientY),F(x.clientX)},onMouseLeave:()=>{j(void 0),F(void 0),H(void 0),T?.(void 0)}})},o)),Q?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:Q.map((e,o)=>t.jsxRuntimeExports.jsx(Ve.RefLineY,{text:e.text,color:e.color,y:c(e.value),x1:0-C,x2:w+O.right,classNames:e.classNames,styles:e.styles,animate:n,isInView:y},o))}):null,t.jsxRuntimeExports.jsx("g",{children:ye.map((e,o)=>{const x=Ne.getLineEndPoint({x:e.xCoordinate?r(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?c(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?r(d.parse(`${e.xCoordinate}`,u,new Date)):0,y:e.yCoordinate?c(e.yCoordinate):0},m.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),$=e.showConnector?{y1:x.y,x1:x.x,y2:e.yCoordinate?c(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0),cy:e.yCoordinate?c(e.yCoordinate):0,cx:e.xCoordinate?r(d.parse(`${e.xCoordinate}`,u,new Date)):0,circleRadius:m.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,Ee={y:e.yCoordinate?c(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:ie?0:e.xCoordinate?r(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:ie?e.xCoordinate?r(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0):w-(e.xCoordinate?r(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(Ne.Annotation,{color:e.color,connectorsSettings:$,labelSettings:Ee,text:e.text,classNames:e.classNames,styles:e.styles,animate:n,isInView:y},o)})}),se.filter(e=>e.position==="after").map(e=>e.layer)]})}),f&&ee&&L&&le?t.jsxRuntimeExports.jsx(Se.Tooltip,{data:f,body:ee,xPos:L,yPos:le,backgroundStyle:b?.tooltip,className:g?.tooltip}):null]})}function _e(de){const{data:s,graphTitle:I,showNAColor:K=!0,colors:a,colorDomain:u,suffix:pe="",sources:_,prefix:ge="",graphDescription:P,height:A,width:h,footNote:C,noOfXTicks:ee=10,dateFormat:T="yyyy",padding:Q,backgroundColor:S=!1,leftMargin:X=30,rightMargin:te=50,topMargin:N=20,bottomMargin:n=25,showColorScale:ie=!0,tooltip:k,relativeHeight:B,onSeriesMouseOver:ye,showLabels:je=!0,refValues:oe=[],highlightAreaSettings:we=[],graphID:ne,minValue:re,maxValue:z,highlightedLines:b=[],graphDownload:v=!1,dataDownload:V=!1,animate:g=!1,language:U="en",colorLegendTitle:R,minHeight:D=0,strokeWidth:be=2,showDots:se=!0,annotations:ae=[],customHighlightAreaSettings:y=[],theme:E="light",ariaLabel:ve,yAxisTitle:Oe,noOfYTicks:l=5,minDate:Ce,maxDate:Z,curveType:f="curve",styles:j,classNames:L,dimmedOpacity:F=.3,precision:le=2,customLayers:H=[],naLabel:O="NA"}=de,[W,ce]=p.useState(0),[xe,ue]=p.useState(0),[w,M]=p.useState(void 0),G=p.useRef(null),me=p.useRef(null);return p.useEffect(()=>{const i=new ResizeObserver(J=>{ce(h||J[0].target.clientWidth||620),ue(A||J[0].target.clientHeight||480)});return G.current&&(ue(G.current.clientHeight||480),ce(G.current.clientWidth||620),h||i.observe(G.current)),()=>i.disconnect()},[h,A]),t.jsxRuntimeExports.jsx("div",{className:`${E||"light"} flex ${h?"w-fit grow-0":"w-full grow"}`,dir:U==="he"||U==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${S?S===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${U||"en"}`,L?.graphContainer),style:{...j?.graphContainer||{},...S&&S!==!0?{backgroundColor:S}:{}},id:ne,ref:me,"aria-label":ve||`${I?`The graph shows ${I}. `:""}This is a multi-line chart that shows trends over time.${P?` ${P}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:S?Q||"1rem":Q||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[I||P||v||V?t.jsxRuntimeExports.jsx(Je.GraphHeader,{styles:{title:j?.title,description:j?.description},classNames:{title:L?.title,description:L?.description},graphTitle:I,graphDescription:P,width:h,graphDownload:v?me.current:void 0,dataDownload:V?s.map(i=>i.data).filter(i=>i!==void 0).length>0?s.map(i=>i.data).filter(i=>i!==void 0):s.filter(i=>i!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?t.jsxRuntimeExports.jsx(Ke.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[ie&&s.filter(i=>i.color).length!==0?t.jsxRuntimeExports.jsx(Qe.ColorLegendWithMouseOver,{width:h,colorLegendTitle:R,colors:a||q.Colors[E].categoricalColors.colors,colorDomain:u||fe.uniqBy(s.filter(i=>i.color),"color").map(i=>i.color).filter(i=>i!==void 0),setSelectedColor:M,showNAColor:K}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:G,"aria-label":"Graph area",children:(h||W)&&(A||xe)?t.jsxRuntimeExports.jsx(Ze,{data:s,lineColors:s.filter(i=>i.color).length===0?a?[a]:[q.Colors.primaryColors["blue-600"]]:a||q.Colors[E].categoricalColors.colors,width:h||W,height:Math.max(D,A||(B?D?(h||W)*B>D?(h||W)*B:D:(h||W)*B:xe)),dateFormat:T,noOfXTicks:ee,leftMargin:X,rightMargin:te,topMargin:N,bottomMargin:n,tooltip:k,onSeriesMouseOver:ye,suffix:pe,prefix:ge,highlightAreaSettings:we,refValues:oe,minValue:re,maxValue:z,highlightedLines:b,animate:g===!0?{duration:.5,once:!0,amount:.5}:g||{duration:0,once:!0,amount:0},rtl:U==="he"||U==="ar",strokeWidth:be,showDots:se,annotations:ae,customHighlightAreaSettings:y,yAxisTitle:Oe,noOfYTicks:l,minDate:Ce,maxDate:Z,curveType:f,styles:j,classNames:L,selectedColor:w,showLabels:je,colorDomain:s.filter(i=>i.color).length===0?[]:u||fe.uniqBy(s.filter(i=>i.color),"color").map(i=>i.color),dimmedOpacity:F,precision:le,customLayers:H,naLabel:O}):null})]})}),_||C?t.jsxRuntimeExports.jsx(ze.GraphFooter,{styles:{footnote:j?.footnote,source:j?.source},classNames:{footnote:L?.footnote,source:L?.source},sources:_,footNote:C,width:h}):null]})})})})}exports.MultiLineAltChart=_e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),p=require("react"),fe=require("./index-CZbIGs8q.cjs"),d=require("./parse-hMnG_lRV.cjs"),Ae=require("./index-BzeLQvXk.cjs"),Le=require("./numberFormattingFunction-02t-wJta.cjs"),Se=require("./Tooltip-n8z5bfav.cjs"),m=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ne=require("./customArea-CK768gCn.cjs"),Me=require("./AxisTitle-CK9YeovX.cjs"),$e=require("./Axis-DE7dSn1_.cjs"),Te=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Ve=require("./ReferenceLine-CFVBBN__.cjs"),Ue=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Fe=require("./index-DNj994Pv.cjs"),q=require("./Colors.cjs"),He=require("./time-Byw_jYQ7.cjs"),We=require("./linear-BVckp9RD.cjs"),Ge=require("./delaunay-rcy0HhZi.cjs"),qe=require("./line-DHV4JwCR.cjs"),he=require("./step-BZ3C8QFW.cjs"),Ye=require("./select-Bnfk0lJx.cjs"),Pe=require("./init-DU0ybBc_.cjs"),Xe=require("./pointer-Dkq5NV1q.cjs"),Be=require("./use-in-view-sQJZ_xDO.cjs"),Y=require("./proxy-BHRoeZgd.cjs"),ze=require("./GraphFooter.cjs"),Je=require("./GraphHeader.cjs"),Ke=require("./EmptyState-d8_8SxeW.cjs"),Qe=require("./ColorLegendWithMouseOver.cjs");function Ze(de){const{data:s,width:I,height:K,lineColors:a,dateFormat:u,noOfXTicks:pe,rightMargin:_,topMargin:ge,bottomMargin:P,suffix:A,prefix:h,leftMargin:C,tooltip:ee,onSeriesMouseOver:T,refValues:Q,highlightAreaSettings:S,minValue:X,maxValue:te,highlightedLines:N,animate:r,rtl:ie,strokeWidth:k,showDots:B,annotations:ye,customHighlightAreaSettings:je,yAxisTitle:oe,noOfYTicks:we,minDate:re,maxDate:ne,curveType:z,styles:v,colorDomain:O,selectedColor:V,classNames:g,showLabels:U,dimmedOpacity:R,precision:D,naLabel:be,customLayers:se}=de,ae=p.useRef(null),y=Be.useInView(ae,{once:r.once,amount:r.amount}),[E,ve]=p.useState(!1);p.useEffect(()=>{if(y&&!E){const e=setTimeout(()=>{ve(!0)},(r.duration+.5)*1e3);return()=>clearTimeout(e)}},[y,E,r.duration]);const Oe=z==="linear"?qe.curveLinear:z==="step"?he.curveStep:z==="stepAfter"?he.stepAfter:z==="stepBefore"?he.stepBefore:he.monotoneX,l=Ae.sortBy(s.map(e=>({...e,date:d.parse(`${e.date}`,u,new Date)})),"date").filter(e=>!m.checkIfNullOrUndefined(e.y)),Ce=fe.uniqBy(l,e=>e.label).map(e=>e.label),Z=fe.uniqBy(Ae.sortBy(s.map(e=>({...e,date:d.parse(`${e.date}`,u,new Date)})),"date"),e=>e.date).map(e=>e.date),[f,j]=p.useState(void 0),[L,F]=p.useState(void 0),[le,H]=p.useState(void 0),w={top:ge,bottom:P,left:oe?C+30:C,right:_},W=p.useRef(null),ce=Ce.map(e=>Ae.sortBy(l.filter(o=>o.label==e),"date")),xe=S.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:d.parse(`${e.coordinates[0]}`,u,new Date),e.coordinates[1]===null?null:d.parse(`${e.coordinates[1]}`,u,new Date)]})),ue=je.map(e=>({...e,coordinates:e.coordinates.map((o,x)=>x%2===0?d.parse(`${o}`,u,new Date):o)})),b=I-w.left-w.right,M=K-w.top-w.bottom,G=re?d.parse(`${re}`,u,new Date):Z[0],me=ne?d.parse(`${ne}`,u,new Date):Z[Z.length-1],i=m.checkIfNullOrUndefined(X)?Math.min(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e)))?Math.min(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e)))>0?0:Math.min(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e))):0:X,J=Math.max(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e)))?Math.max(...l.map(e=>e.y).filter(e=>!m.checkIfNullOrUndefined(e))):0,n=He.time().domain([G,me]).range([0,b]),c=We.linear().domain([m.checkIfNullOrUndefined(X)?i:X,m.checkIfNullOrUndefined(te)?J>0?J:0:te]).range([M,0]).nice(),Ie=Ge.Delaunay.from(l.filter(e=>!m.checkIfNullOrUndefined(e.date)&&!m.checkIfNullOrUndefined(e.y)),e=>n(e.date),e=>c(e.y)).voronoi([0,0,b<0?0:b,M<0?0:M]),Re=qe.line().x(e=>n(e.date)).y(e=>c(e.y)).curve(Oe),ke=c.ticks(we),De=n.ticks(pe);return p.useEffect(()=>{const e=x=>{const $=l[Pe.bisectCenter(l.map(Ee=>Ee.date),n.invert(Xe.pointer(x)[0]),0)];j($||l[l.length-1]),H(x.clientY),F(x.clientX),T?.($||l[l.length-1])},o=()=>{j(void 0),F(void 0),H(void 0)};Ye.select(W.current).on("mousemove",e).on("mouseout",o),T?.(void 0)},[n,l,T]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(Y.motion.svg,{width:`${I}px`,height:`${K}px`,viewBox:`0 0 ${I} ${K}`,direction:"ltr",ref:ae,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${w.left},${w.top})`,children:[t.jsxRuntimeExports.jsx(Fe.HighlightArea,{areaSettings:xe,width:b,height:M,scale:n,animate:r,isInView:y}),t.jsxRuntimeExports.jsx(Ne.CustomArea,{areaSettings:ue,scaleX:n,scaleY:c,animate:r,isInView:y}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Ue.YTicksAndGridLines,{values:ke.filter(e=>e!==0),y:ke.filter(e=>e!==0).map(e=>c(e)),x1:0-C,x2:b+w.right,styles:{gridLines:v?.yAxis?.gridLines,labels:v?.yAxis?.labels},classNames:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},suffix:A,prefix:h,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:D}),t.jsxRuntimeExports.jsx($e.Axis,{y1:c(i<0?0:i),y2:c(i<0?0:i),x1:0-C,x2:b+w.right,label:Le.numberFormattingFunction(i<0?0:i,"NA",D,h,A),labelPos:{x:0-C,y:c(i<0?0:i),dx:0,dy:J<0?"1em":-5},classNames:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels},styles:{axis:v?.xAxis?.axis,label:v?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(Me.AxisTitle,{x:0-C-15,y:M/2,style:v?.yAxis?.title,className:g?.yAxis?.title,text:oe,rotate90:!0})]}),t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx(Te.XTicksAndGridLines,{values:De.map(e=>d.format(e,u)),x:De.map(e=>n(e)),y1:0,y2:M,styles:{gridLines:v?.xAxis?.gridLines,labels:v?.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-[9px] md:text-[10px] lg:text-xs",g?.xAxis?.labels)},suffix:A,prefix:h,labelType:"primary",showGridLines:!0,precision:D})}),se.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs(Y.motion.g,{children:[ce.map(e=>t.jsxRuntimeExports.jsxs(Y.motion.g,{exit:{opacity:0,transition:{duration:r.duration}},variants:{initial:{opacity:f?e[0].label===f.label?1:R:V?e[0].color&&a[O.indexOf(e[0].color)]===V?1:R:N.length!==0?N.indexOf(e[0].label)!==-1?1:R:1},whileInView:{opacity:f?e[0].label===f.label?1:R:V?e[0].color&&a[O.indexOf(e[0].color)]===V?1:R:N.length!==0?N.indexOf(e[0].label)!==-1?1:R:1,transition:{duration:r.duration}}},initial:"initial",animate:y?"whileInView":"initial",children:[t.jsxRuntimeExports.jsx(Y.motion.path,{d:Re(e.filter(o=>!m.checkIfNullOrUndefined(o.y)))||"",style:{fill:"none",strokeWidth:f?e[0].label===f.label?k+Math.max(2,.5*k):k:N.length!==0&&N.indexOf(e[0].label)!==-1?k+Math.max(2,.5*k):k},exit:{opacity:0,transition:{duration:r.duration}},variants:{initial:{pathLength:0,d:Re(e.filter(o=>!m.checkIfNullOrUndefined(o.y)))||"",opacity:1,stroke:s.filter(o=>o.color).length===0?a[0]:e[0].color?a[O.indexOf(e[0].color)]:q.Colors.gray},whileInView:{pathLength:1,d:Re(e.filter(o=>!m.checkIfNullOrUndefined(o.y)))||"",opacity:1,stroke:s.filter(o=>o.color).length===0?a[0]:e[0].color?a[O.indexOf(e[0].color)]:q.Colors.gray,transition:{duration:r.duration}}},initial:"initial",animate:y?"whileInView":"initial"}),e.map((o,x)=>t.jsxRuntimeExports.jsx(Y.motion.g,{children:m.checkIfNullOrUndefined(o.y)?null:t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:B?t.jsxRuntimeExports.jsx(Y.motion.circle,{r:b/e.length<5?0:b/e.length<20?2:4,exit:{opacity:0,transition:{duration:r.duration}},variants:{initial:{opacity:0,fill:s.filter($=>$.color).length===0?a[0]:e[0].color?a[O.indexOf(e[0].color)]:q.Colors.gray,cx:n(o.date),cy:c(o.y)},whileInView:{opacity:1,fill:s.filter($=>$.color).length===0?a[0]:e[0].color?a[O.indexOf(e[0].color)]:q.Colors.gray,transition:{duration:E?r.duration:.5,delay:E?0:r.duration},cx:n(o.date),cy:c(o.y)}},initial:"initial",animate:y?"whileInView":"initial"}):null})},x)),(N.indexOf(e[0].label)!==-1||f?.label===e[0].label)&&U?t.jsxRuntimeExports.jsx(Y.motion.text,{style:{fill:s.filter(o=>o.color).length===0?a[0]:e[0].color?a[O.indexOf(e[0].color)]:q.Colors.gray},className:"text-sm font-bold",dx:5,dy:4,exit:{opacity:0,transition:{duration:r.duration}},variants:{initial:{opacity:0,x:n(e[e.length-1].date),y:c(e[e.length-1].y)},whileInView:{opacity:1,x:n(e[e.length-1].date),y:c(e[e.length-1].y),transition:{duration:E?r.duration:.5,delay:E?0:r.duration}}},initial:"initial",animate:y?"whileInView":"initial",children:e[0].label}):null]},e[0].label)),f?t.jsxRuntimeExports.jsx("text",{y:c(f.y)-8,x:n(f.date),className:t.mo("graph-value text-sm font-bold",g?.graphObjectValues),style:{fill:s.filter(e=>e.color).length===0?a[0]:f.color?a[O.indexOf(f.color)]:q.Colors.gray,textAnchor:"middle",...v?.graphObjectValues||{}},children:Le.numberFormattingFunction(f.y,be,D,h,A)}):null]}),l.filter(e=>!m.checkIfNullOrUndefined(e.y)).map((e,o)=>t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx("path",{d:Ie.renderCell(l.findIndex(x=>x.label===e.label&&x.date===e.date)),opacity:0,onMouseEnter:x=>{j(e),H(x.clientY),F(x.clientX),T?.(e)},onMouseMove:x=>{j(e),H(x.clientY),F(x.clientX)},onMouseLeave:()=>{j(void 0),F(void 0),H(void 0),T?.(void 0)}})},o)),Q?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:Q.map((e,o)=>t.jsxRuntimeExports.jsx(Ve.RefLineY,{text:e.text,color:e.color,y:c(e.value),x1:0-C,x2:b+w.right,classNames:e.classNames,styles:e.styles,animate:r,isInView:y},o))}):null,t.jsxRuntimeExports.jsx("g",{children:ye.map((e,o)=>{const x=Ne.getLineEndPoint({x:e.xCoordinate?n(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?c(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?n(d.parse(`${e.xCoordinate}`,u,new Date)):0,y:e.yCoordinate?c(e.yCoordinate):0},m.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),$=e.showConnector?{y1:x.y,x1:x.x,y2:e.yCoordinate?c(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?n(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0),cy:e.yCoordinate?c(e.yCoordinate):0,cx:e.xCoordinate?n(d.parse(`${e.xCoordinate}`,u,new Date)):0,circleRadius:m.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,Ee={y:e.yCoordinate?c(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:ie?0:e.xCoordinate?n(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:ie?e.xCoordinate?n(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0):b+w.right-(e.xCoordinate?n(d.parse(`${e.xCoordinate}`,u,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(Ne.Annotation,{color:e.color,connectorsSettings:$,labelSettings:Ee,text:e.text,classNames:e.classNames,styles:e.styles,animate:r,isInView:y},o)})}),se.filter(e=>e.position==="after").map(e=>e.layer)]})}),f&&ee&&L&&le?t.jsxRuntimeExports.jsx(Se.Tooltip,{data:f,body:ee,xPos:L,yPos:le,backgroundStyle:v?.tooltip,className:g?.tooltip}):null]})}function _e(de){const{data:s,graphTitle:I,showNAColor:K=!0,colors:a,colorDomain:u,suffix:pe="",sources:_,prefix:ge="",graphDescription:P,height:A,width:h,footNote:C,noOfXTicks:ee=10,dateFormat:T="yyyy",padding:Q,backgroundColor:S=!1,leftMargin:X=30,rightMargin:te=50,topMargin:N=20,bottomMargin:r=25,showColorScale:ie=!0,tooltip:k,relativeHeight:B,onSeriesMouseOver:ye,showLabels:je=!0,refValues:oe=[],highlightAreaSettings:we=[],graphID:re,minValue:ne,maxValue:z,highlightedLines:v=[],graphDownload:O=!1,dataDownload:V=!1,animate:g=!1,language:U="en",colorLegendTitle:R,minHeight:D=0,strokeWidth:be=2,showDots:se=!0,annotations:ae=[],customHighlightAreaSettings:y=[],theme:E="light",ariaLabel:ve,yAxisTitle:Oe,noOfYTicks:l=5,minDate:Ce,maxDate:Z,curveType:f="curve",styles:j,classNames:L,dimmedOpacity:F=.3,precision:le=2,customLayers:H=[],naLabel:w="NA"}=de,[W,ce]=p.useState(0),[xe,ue]=p.useState(0),[b,M]=p.useState(void 0),G=p.useRef(null),me=p.useRef(null);return p.useEffect(()=>{const i=new ResizeObserver(J=>{ce(h||J[0].target.clientWidth||620),ue(A||J[0].target.clientHeight||480)});return G.current&&(ue(G.current.clientHeight||480),ce(G.current.clientWidth||620),h||i.observe(G.current)),()=>i.disconnect()},[h,A]),t.jsxRuntimeExports.jsx("div",{className:`${E||"light"} flex ${h?"w-fit grow-0":"w-full grow"}`,dir:U==="he"||U==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${S?S===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${U||"en"}`,L?.graphContainer),style:{...j?.graphContainer||{},...S&&S!==!0?{backgroundColor:S}:{}},id:re,ref:me,"aria-label":ve||`${I?`The graph shows ${I}. `:""}This is a multi-line chart that shows trends over time.${P?` ${P}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:S?Q||"1rem":Q||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[I||P||O||V?t.jsxRuntimeExports.jsx(Je.GraphHeader,{styles:{title:j?.title,description:j?.description},classNames:{title:L?.title,description:L?.description},graphTitle:I,graphDescription:P,width:h,graphDownload:O?me.current:void 0,dataDownload:V?s.map(i=>i.data).filter(i=>i!==void 0).length>0?s.map(i=>i.data).filter(i=>i!==void 0):s.filter(i=>i!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?t.jsxRuntimeExports.jsx(Ke.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[ie&&s.filter(i=>i.color).length!==0?t.jsxRuntimeExports.jsx(Qe.ColorLegendWithMouseOver,{width:h,colorLegendTitle:R,colors:a||q.Colors[E].categoricalColors.colors,colorDomain:u||fe.uniqBy(s.filter(i=>i.color),"color").map(i=>i.color).filter(i=>i!==void 0),setSelectedColor:M,showNAColor:K}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:G,"aria-label":"Graph area",children:(h||W)&&(A||xe)?t.jsxRuntimeExports.jsx(Ze,{data:s,lineColors:s.filter(i=>i.color).length===0?a?[a]:[q.Colors.primaryColors["blue-600"]]:a||q.Colors[E].categoricalColors.colors,width:h||W,height:Math.max(D,A||(B?D?(h||W)*B>D?(h||W)*B:D:(h||W)*B:xe)),dateFormat:T,noOfXTicks:ee,leftMargin:X,rightMargin:te,topMargin:N,bottomMargin:r,tooltip:k,onSeriesMouseOver:ye,suffix:pe,prefix:ge,highlightAreaSettings:we,refValues:oe,minValue:ne,maxValue:z,highlightedLines:v,animate:g===!0?{duration:.5,once:!0,amount:.5}:g||{duration:0,once:!0,amount:0},rtl:U==="he"||U==="ar",strokeWidth:be,showDots:se,annotations:ae,customHighlightAreaSettings:y,yAxisTitle:Oe,noOfYTicks:l,minDate:Ce,maxDate:Z,curveType:f,styles:j,classNames:L,selectedColor:b,showLabels:je,colorDomain:s.filter(i=>i.color).length===0?[]:u||fe.uniqBy(s.filter(i=>i.color),"color").map(i=>i.color),dimmedOpacity:F,precision:le,customLayers:H,naLabel:w}):null})]})}),_||C?t.jsxRuntimeExports.jsx(ze.GraphFooter,{styles:{footnote:j?.footnote,source:j?.source},classNames:{footnote:L?.footnote,source:L?.source},sources:_,footNote:C,width:h}):null]})})})})}exports.MultiLineAltChart=_e;
2
2
  //# sourceMappingURL=MultiLineAltChart.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"MultiLineAltChart.cjs","sources":["../src/Components/Graphs/LineCharts/MultiLineAltChart/Graph.tsx","../src/Components/Graphs/LineCharts/MultiLineAltChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveLinear,\r\n curveMonotoneX,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport sortBy from 'lodash.sortby';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport uniqBy from 'lodash.uniqby';\r\nimport { Delaunay } from 'd3-delaunay';\r\nimport { 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 MultiLineAltChartDataType,\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\nimport { Colors } from '@/Components/ColorPalette';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: MultiLineAltChartDataType[];\r\n lineColors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n leftMargin: number;\r\n rightMargin: number;\r\n suffix: string;\r\n prefix: 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 highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n refValues: ReferenceDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n highlightedLines: (string | number)[];\r\n animate: AnimateDataType;\r\n rtl: boolean;\r\n strokeWidth: number;\r\n showLabels: boolean;\r\n showDots: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n yAxisTitle?: string;\r\n noOfYTicks: number;\r\n minDate?: string | number;\r\n maxDate?: string | number;\r\n colorDomain: (string | number)[];\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n selectedColor?: string;\r\n dimmedOpacity: number;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n naLabel: string;\r\n}\r\n\r\ninterface FormattedDataType {\r\n y: number;\r\n date: Date;\r\n label: number | string;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n lineColors,\r\n dateFormat,\r\n noOfXTicks,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n suffix,\r\n prefix,\r\n leftMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n refValues,\r\n highlightAreaSettings,\r\n minValue,\r\n maxValue,\r\n highlightedLines,\r\n animate,\r\n rtl,\r\n strokeWidth,\r\n showDots,\r\n annotations,\r\n customHighlightAreaSettings,\r\n yAxisTitle,\r\n noOfYTicks,\r\n minDate,\r\n maxDate,\r\n curveType,\r\n styles,\r\n colorDomain,\r\n selectedColor,\r\n classNames,\r\n showLabels,\r\n dimmedOpacity,\r\n precision,\r\n naLabel,\r\n customLayers,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const [hasAnimatedOnce, setHasAnimatedOnce] = useState(false);\r\n\r\n useEffect(() => {\r\n if (isInView && !hasAnimatedOnce) {\r\n const timeout = setTimeout(\r\n () => {\r\n setHasAnimatedOnce(true);\r\n },\r\n (animate.duration + 0.5) * 1000,\r\n );\r\n return () => clearTimeout(timeout);\r\n }\r\n }, [isInView, hasAnimatedOnce, animate.duration]);\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 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 ).filter(d => !checkIfNullOrUndefined(d.y));\r\n const labels = uniqBy(dataFormatted, d => d.label).map(d => d.label);\r\n const dates = uniqBy(\r\n 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 d => d.date,\r\n ).map(d => d.date);\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 lineArray = labels.map(d =>\r\n sortBy(\r\n dataFormatted.filter(el => el.label == d),\r\n 'date',\r\n ),\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 graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minYear = minDate ? parse(`${minDate}`, dateFormat, new Date()) : dates[0];\r\n const maxYear = maxDate ? parse(`${maxDate}`, dateFormat, new Date()) : dates[dates.length - 1];\r\n const minParam: number = checkIfNullOrUndefined(minValue)\r\n ? Math.min(...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]))\r\n ? (Math.min(\r\n ...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]),\r\n ) as number) > 0\r\n ? 0\r\n : (Math.min(\r\n ...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]),\r\n ) as number)\r\n : 0\r\n : (minValue as number);\r\n const maxParam: number = (Math.max(\r\n ...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]),\r\n ) as number)\r\n ? (Math.max(\r\n ...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]),\r\n ) as number)\r\n : 0;\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? minParam : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxParam > 0 ? maxParam : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n\r\n const voronoiDiagram = Delaunay.from(\r\n dataFormatted.filter(d => !checkIfNullOrUndefined(d.date) && !checkIfNullOrUndefined(d.y)),\r\n d => x(d.date),\r\n d => y(d.y as number),\r\n ).voronoi([0, 0, graphWidth < 0 ? 0 : graphWidth, graphHeight < 0 ? 0 : graphHeight]);\r\n const lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n 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 setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n };\r\n const mouseout = () => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n\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 <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 areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\r\n animate={animate}\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 y: y(minParam < 0 ? 0 : minParam),\r\n dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\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 <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-[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 </g>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <motion.g>\r\n {lineArray.map(d => (\r\n <motion.g\r\n key={d[0].label}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity: mouseOverData\r\n ? d[0].label === mouseOverData.label\r\n ? 1\r\n : dimmedOpacity\r\n : selectedColor\r\n ? d[0].color\r\n ? lineColors[colorDomain.indexOf(d[0].color)] === selectedColor\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(d[0].label) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n },\r\n whileInView: {\r\n opacity: mouseOverData\r\n ? d[0].label === mouseOverData.label\r\n ? 1\r\n : dimmedOpacity\r\n : selectedColor\r\n ? d[0].color\r\n ? lineColors[colorDomain.indexOf(d[0].color)] === selectedColor\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(d[0].label) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n >\r\n <motion.path\r\n d={\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || ''\r\n }\r\n style={{\r\n fill: 'none',\r\n strokeWidth: mouseOverData\r\n ? d[0].label === mouseOverData.label\r\n ? strokeWidth + Math.max(2, 0.5 * strokeWidth)\r\n : strokeWidth\r\n : highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(d[0].label) !== -1\r\n ? strokeWidth + Math.max(2, 0.5 * strokeWidth)\r\n : strokeWidth\r\n : strokeWidth,\r\n }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n d:\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || '',\r\n opacity: 1,\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n },\r\n whileInView: {\r\n pathLength: 1,\r\n d:\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || '',\r\n opacity: 1,\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n {d.map((el, j) => (\r\n <motion.g key={j}>\r\n {!checkIfNullOrUndefined(el.y) ? (\r\n <>\r\n {showDots ? (\r\n <motion.circle\r\n r={graphWidth / d.length < 5 ? 0 : graphWidth / d.length < 20 ? 2 : 4}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity: 0,\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n cx: x(el.date),\r\n cy: y(el.y as number),\r\n },\r\n whileInView: {\r\n opacity: 1,\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n transition: {\r\n duration: hasAnimatedOnce ? animate.duration : 0.5,\r\n delay: hasAnimatedOnce ? 0 : animate.duration,\r\n },\r\n cx: x(el.date),\r\n cy: y(el.y as number),\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n ) : null}\r\n </>\r\n ) : null}\r\n </motion.g>\r\n ))}\r\n {(highlightedLines.indexOf(d[0].label) !== -1 ||\r\n mouseOverData?.label === d[0].label) &&\r\n showLabels ? (\r\n <motion.text\r\n style={{\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n }}\r\n className='text-sm font-bold'\r\n dx={5}\r\n dy={4}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity: 0,\r\n x: x(d[d.length - 1].date),\r\n y: y(d[d.length - 1].y as number),\r\n },\r\n whileInView: {\r\n opacity: 1,\r\n x: x(d[d.length - 1].date),\r\n y: y(d[d.length - 1].y as number),\r\n transition: {\r\n duration: hasAnimatedOnce ? animate.duration : 0.5,\r\n delay: hasAnimatedOnce ? 0 : animate.duration,\r\n },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n >\r\n {d[0].label}\r\n </motion.text>\r\n ) : null}\r\n </motion.g>\r\n ))}\r\n {mouseOverData ? (\r\n <text\r\n y={y(mouseOverData.y) - 8}\r\n x={x(mouseOverData.date)}\r\n className={cn('graph-value text-sm font-bold', classNames?.graphObjectValues)}\r\n style={{\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !mouseOverData.color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(mouseOverData.color)],\r\n textAnchor: 'middle',\r\n ...(styles?.graphObjectValues || {}),\r\n }}\r\n >\r\n {numberFormattingFunction(mouseOverData.y, naLabel, precision, prefix, suffix)}\r\n </text>\r\n ) : null}\r\n </motion.g>\r\n {dataFormatted\r\n .filter(d => !checkIfNullOrUndefined(d.y))\r\n .map((d, i) => {\r\n return (\r\n <g key={i}>\r\n <path\r\n d={voronoiDiagram.renderCell(\r\n dataFormatted.findIndex(el => el.label === d.label && el.date === d.date),\r\n )}\r\n opacity={0}\r\n onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n />\r\n </g>\r\n );\r\n })}\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 cy: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 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 </g>\r\n </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect } from 'react';\r\nimport uniqBy from 'lodash.uniqby';\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 CustomHighlightAreaSettingsDataType,\r\n Languages,\r\n MultiLineAltChartDataType,\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 { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\nimport { ColorLegendWithMouseOver } from '@/Components/Elements/ColorLegendWithMouseOver';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: MultiLineAltChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Color or array of colors for lines */\r\n colors?: string | string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: (string | number)[];\r\n /** Toggle the visibility of labels of the lines when highlighted or mouse hovered */\r\n showLabels?: boolean;\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 /** Maximum value of the date for the chart */\r\n maxDate?: string | number;\r\n /** Minimum value of the date for the chart */\r\n minDate?: string | number;\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 /** Toggle visibility of dots on the line */\r\n showDots?: boolean;\r\n /** Stroke width of the line */\r\n strokeWidth?: number;\r\n /** Toggle the initial animation of the line. If the type is number then it uses the number as the time in seconds for animation. */\r\n animate?: boolean | AnimateDataType;\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 /** Title for the Y-axis */\r\n yAxisTitle?: string;\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Toggle visibility of NA color in the color scale. This is only applicable if the data props hae color parameter and showColorScale prop is true */\r\n showNAColor?: boolean;\r\n /** Defines how “NA” values should be displayed/labelled in the graph */\r\n naLabel?: string;\r\n /** Data points to highlight. Use the label value from data to highlight the data point */\r\n highlightedLines?: (string | number)[];\r\n /** Defines the opacity of the non-highlighted data */\r\n dimmedOpacity?: number;\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 /** 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 MultiLineAltChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n showNAColor = true,\r\n colors,\r\n colorDomain,\r\n suffix = '',\r\n sources,\r\n prefix = '',\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n padding,\r\n backgroundColor = false,\r\n leftMargin = 30,\r\n rightMargin = 50,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n showColorScale = true,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n showLabels = true,\r\n refValues = [],\r\n highlightAreaSettings = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n highlightedLines = [],\r\n graphDownload = false,\r\n dataDownload = false,\r\n animate = false,\r\n language = 'en',\r\n colorLegendTitle,\r\n minHeight = 0,\r\n strokeWidth = 2,\r\n showDots = true,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n minDate,\r\n maxDate,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n dimmedOpacity = 0.3,\r\n precision = 2,\r\n customLayers = [],\r\n naLabel = 'NA',\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [selectedColor, setSelectedColor] = useState<string | undefined>(undefined);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\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 multi-line 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 && data.filter(el => el.color).length !== 0 ? (\r\n <ColorLegendWithMouseOver\r\n width={width}\r\n colorLegendTitle={colorLegendTitle}\r\n colors={\r\n (colors as string[] | undefined) || Colors[theme].categoricalColors.colors\r\n }\r\n colorDomain={\r\n colorDomain ||\r\n uniqBy(\r\n data.filter(el => el.color),\r\n 'color',\r\n )\r\n .map(d => d.color)\r\n .filter(d => d !== undefined)\r\n }\r\n setSelectedColor={setSelectedColor}\r\n showNAColor={showNAColor}\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 lineColors={\r\n data.filter(el => el.color).length === 0\r\n ? colors\r\n ? [colors as string]\r\n : [Colors.primaryColors['blue-600']]\r\n : (colors as string[] | undefined) ||\r\n Colors[theme].categoricalColors.colors\r\n }\r\n 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 suffix={suffix}\r\n prefix={prefix}\r\n highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n highlightedLines={highlightedLines}\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 rtl={language === 'he' || language === 'ar'}\r\n strokeWidth={strokeWidth}\r\n showDots={showDots}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n minDate={minDate}\r\n maxDate={maxDate}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n selectedColor={selectedColor}\r\n showLabels={showLabels}\r\n colorDomain={\r\n data.filter(el => el.color).length === 0\r\n ? []\r\n : colorDomain ||\r\n (uniqBy(\r\n data.filter(el => el.color),\r\n 'color',\r\n ).map(d => d.color) as string[])\r\n }\r\n dimmedOpacity={dimmedOpacity}\r\n precision={precision}\r\n customLayers={customLayers}\r\n naLabel={naLabel}\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","lineColors","dateFormat","noOfXTicks","rightMargin","topMargin","bottomMargin","suffix","prefix","leftMargin","tooltip","onSeriesMouseOver","refValues","highlightAreaSettings","minValue","maxValue","highlightedLines","animate","rtl","strokeWidth","showDots","annotations","customHighlightAreaSettings","yAxisTitle","noOfYTicks","minDate","maxDate","curveType","styles","colorDomain","selectedColor","classNames","showLabels","dimmedOpacity","precision","naLabel","customLayers","svgRef","useRef","isInView","useInView","hasAnimatedOnce","setHasAnimatedOnce","useState","useEffect","timeout","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","dataFormatted","sortBy","d","parse","checkIfNullOrUndefined","labels","uniqBy","dates","mouseOverData","setMouseOverData","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","lineArray","el","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","j","graphWidth","graphHeight","minYear","maxYear","minParam","maxParam","x","scaleTime","y","scaleLinear","voronoiDiagram","Delaunay","lineShape","line","yTicks","xTicks","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","Colors","i","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","MultiLineAltChart","graphTitle","showNAColor","colors","sources","graphDescription","footNote","padding","backgroundColor","showColorScale","relativeHeight","graphID","graphDownload","dataDownload","language","colorLegendTitle","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","setSelectedColor","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","ColorLegendWithMouseOver","GraphFooter"],"mappings":"8rCAkGO,SAASA,GAAMC,GAAc,CAClC,KAAM,CACJ,KAAAC,EACA,MAAAC,EACA,OAAAC,EACA,WAAAC,EACA,WAAAC,EACA,WAAAC,GACA,YAAAC,EACA,UAAAC,GACA,aAAAC,EACA,OAAAC,EACA,OAAAC,EACA,WAAAC,EACA,QAAAC,GACA,kBAAAC,EACA,UAAAC,EACA,sBAAAC,EACA,SAAAC,EACA,SAAAC,GACA,iBAAAC,EACA,QAAAC,EACA,IAAAC,GACA,YAAAC,EACA,SAAAC,EACA,YA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EAEA,IAAA,CACN,CAAA,CAAA,CACF,CAAA,CAEJ,EACCuF,GAAWE,EACV1B,EAAAA,kBAAAA,IAACmD,GAAAA,YAAA,CACC,OAAQ,CAAE,SAAUzH,GAAQ,SAAU,OAAQA,GAAQ,MAAA,EACtD,WAAY,CACV,SAAUG,GAAY,SACtB,OAAQA,GAAY,MAAA,EAEtB,QAAA2F,EACA,SAAAE,EACA,MAAA7H,CAAA,CAAA,EAEA,IAAA,CAAA,CACN,CAAA,CAAA,CACF,CAAA,CACF,CAAA,CAGN"}
1
+ {"version":3,"file":"MultiLineAltChart.cjs","sources":["../src/Components/Graphs/LineCharts/MultiLineAltChart/Graph.tsx","../src/Components/Graphs/LineCharts/MultiLineAltChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveLinear,\r\n curveMonotoneX,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport sortBy from 'lodash.sortby';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport uniqBy from 'lodash.uniqby';\r\nimport { Delaunay } from 'd3-delaunay';\r\nimport { 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 MultiLineAltChartDataType,\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\nimport { Colors } from '@/Components/ColorPalette';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: MultiLineAltChartDataType[];\r\n lineColors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n leftMargin: number;\r\n rightMargin: number;\r\n suffix: string;\r\n prefix: 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 highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n refValues: ReferenceDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n highlightedLines: (string | number)[];\r\n animate: AnimateDataType;\r\n rtl: boolean;\r\n strokeWidth: number;\r\n showLabels: boolean;\r\n showDots: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n yAxisTitle?: string;\r\n noOfYTicks: number;\r\n minDate?: string | number;\r\n maxDate?: string | number;\r\n colorDomain: (string | number)[];\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n selectedColor?: string;\r\n dimmedOpacity: number;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n naLabel: string;\r\n}\r\n\r\ninterface FormattedDataType {\r\n y: number;\r\n date: Date;\r\n label: number | string;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n lineColors,\r\n dateFormat,\r\n noOfXTicks,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n suffix,\r\n prefix,\r\n leftMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n refValues,\r\n highlightAreaSettings,\r\n minValue,\r\n maxValue,\r\n highlightedLines,\r\n animate,\r\n rtl,\r\n strokeWidth,\r\n showDots,\r\n annotations,\r\n customHighlightAreaSettings,\r\n yAxisTitle,\r\n noOfYTicks,\r\n minDate,\r\n maxDate,\r\n curveType,\r\n styles,\r\n colorDomain,\r\n selectedColor,\r\n classNames,\r\n showLabels,\r\n dimmedOpacity,\r\n precision,\r\n naLabel,\r\n customLayers,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const [hasAnimatedOnce, setHasAnimatedOnce] = useState(false);\r\n\r\n useEffect(() => {\r\n if (isInView && !hasAnimatedOnce) {\r\n const timeout = setTimeout(\r\n () => {\r\n setHasAnimatedOnce(true);\r\n },\r\n (animate.duration + 0.5) * 1000,\r\n );\r\n return () => clearTimeout(timeout);\r\n }\r\n }, [isInView, hasAnimatedOnce, animate.duration]);\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 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 ).filter(d => !checkIfNullOrUndefined(d.y));\r\n const labels = uniqBy(dataFormatted, d => d.label).map(d => d.label);\r\n const dates = uniqBy(\r\n 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 d => d.date,\r\n ).map(d => d.date);\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 lineArray = labels.map(d =>\r\n sortBy(\r\n dataFormatted.filter(el => el.label == d),\r\n 'date',\r\n ),\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 graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minYear = minDate ? parse(`${minDate}`, dateFormat, new Date()) : dates[0];\r\n const maxYear = maxDate ? parse(`${maxDate}`, dateFormat, new Date()) : dates[dates.length - 1];\r\n const minParam: number = checkIfNullOrUndefined(minValue)\r\n ? Math.min(...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]))\r\n ? (Math.min(\r\n ...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]),\r\n ) as number) > 0\r\n ? 0\r\n : (Math.min(\r\n ...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]),\r\n ) as number)\r\n : 0\r\n : (minValue as number);\r\n const maxParam: number = (Math.max(\r\n ...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]),\r\n ) as number)\r\n ? (Math.max(\r\n ...(dataFormatted.map(d => d.y).filter(d => !checkIfNullOrUndefined(d)) as number[]),\r\n ) as number)\r\n : 0;\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? minParam : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxParam > 0 ? maxParam : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n\r\n const voronoiDiagram = Delaunay.from(\r\n dataFormatted.filter(d => !checkIfNullOrUndefined(d.date) && !checkIfNullOrUndefined(d.y)),\r\n d => x(d.date),\r\n d => y(d.y as number),\r\n ).voronoi([0, 0, graphWidth < 0 ? 0 : graphWidth, graphHeight < 0 ? 0 : graphHeight]);\r\n const lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n 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 setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n };\r\n const mouseout = () => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n\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 <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 areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\r\n animate={animate}\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 y: y(minParam < 0 ? 0 : minParam),\r\n dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\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 <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-[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 </g>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <motion.g>\r\n {lineArray.map(d => (\r\n <motion.g\r\n key={d[0].label}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity: mouseOverData\r\n ? d[0].label === mouseOverData.label\r\n ? 1\r\n : dimmedOpacity\r\n : selectedColor\r\n ? d[0].color\r\n ? lineColors[colorDomain.indexOf(d[0].color)] === selectedColor\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(d[0].label) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n },\r\n whileInView: {\r\n opacity: mouseOverData\r\n ? d[0].label === mouseOverData.label\r\n ? 1\r\n : dimmedOpacity\r\n : selectedColor\r\n ? d[0].color\r\n ? lineColors[colorDomain.indexOf(d[0].color)] === selectedColor\r\n ? 1\r\n : dimmedOpacity\r\n : dimmedOpacity\r\n : highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(d[0].label) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n >\r\n <motion.path\r\n d={\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || ''\r\n }\r\n style={{\r\n fill: 'none',\r\n strokeWidth: mouseOverData\r\n ? d[0].label === mouseOverData.label\r\n ? strokeWidth + Math.max(2, 0.5 * strokeWidth)\r\n : strokeWidth\r\n : highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(d[0].label) !== -1\r\n ? strokeWidth + Math.max(2, 0.5 * strokeWidth)\r\n : strokeWidth\r\n : strokeWidth,\r\n }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n d:\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || '',\r\n opacity: 1,\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n },\r\n whileInView: {\r\n pathLength: 1,\r\n d:\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || '',\r\n opacity: 1,\r\n stroke:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n {d.map((el, j) => (\r\n <motion.g key={j}>\r\n {!checkIfNullOrUndefined(el.y) ? (\r\n <>\r\n {showDots ? (\r\n <motion.circle\r\n r={graphWidth / d.length < 5 ? 0 : graphWidth / d.length < 20 ? 2 : 4}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity: 0,\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n cx: x(el.date),\r\n cy: y(el.y as number),\r\n },\r\n whileInView: {\r\n opacity: 1,\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n transition: {\r\n duration: hasAnimatedOnce ? animate.duration : 0.5,\r\n delay: hasAnimatedOnce ? 0 : animate.duration,\r\n },\r\n cx: x(el.date),\r\n cy: y(el.y as number),\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n ) : null}\r\n </>\r\n ) : null}\r\n </motion.g>\r\n ))}\r\n {(highlightedLines.indexOf(d[0].label) !== -1 ||\r\n mouseOverData?.label === d[0].label) &&\r\n showLabels ? (\r\n <motion.text\r\n style={{\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !d[0].color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(d[0].color)],\r\n }}\r\n className='text-sm font-bold'\r\n dx={5}\r\n dy={4}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity: 0,\r\n x: x(d[d.length - 1].date),\r\n y: y(d[d.length - 1].y as number),\r\n },\r\n whileInView: {\r\n opacity: 1,\r\n x: x(d[d.length - 1].date),\r\n y: y(d[d.length - 1].y as number),\r\n transition: {\r\n duration: hasAnimatedOnce ? animate.duration : 0.5,\r\n delay: hasAnimatedOnce ? 0 : animate.duration,\r\n },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n >\r\n {d[0].label}\r\n </motion.text>\r\n ) : null}\r\n </motion.g>\r\n ))}\r\n {mouseOverData ? (\r\n <text\r\n y={y(mouseOverData.y) - 8}\r\n x={x(mouseOverData.date)}\r\n className={cn('graph-value text-sm font-bold', classNames?.graphObjectValues)}\r\n style={{\r\n fill:\r\n data.filter(el => el.color).length === 0\r\n ? lineColors[0]\r\n : !mouseOverData.color\r\n ? Colors.gray\r\n : lineColors[colorDomain.indexOf(mouseOverData.color)],\r\n textAnchor: 'middle',\r\n ...(styles?.graphObjectValues || {}),\r\n }}\r\n >\r\n {numberFormattingFunction(mouseOverData.y, naLabel, precision, prefix, suffix)}\r\n </text>\r\n ) : null}\r\n </motion.g>\r\n {dataFormatted\r\n .filter(d => !checkIfNullOrUndefined(d.y))\r\n .map((d, i) => {\r\n return (\r\n <g key={i}>\r\n <path\r\n d={voronoiDiagram.renderCell(\r\n dataFormatted.findIndex(el => el.label === d.label && el.date === d.date),\r\n )}\r\n opacity={0}\r\n onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n />\r\n </g>\r\n );\r\n })}\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 cy: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 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 </g>\r\n </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect } from 'react';\r\nimport uniqBy from 'lodash.uniqby';\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 CustomHighlightAreaSettingsDataType,\r\n Languages,\r\n MultiLineAltChartDataType,\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 { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\nimport { ColorLegendWithMouseOver } from '@/Components/Elements/ColorLegendWithMouseOver';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: MultiLineAltChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Color or array of colors for lines */\r\n colors?: string | string[];\r\n /** Domain of colors for the graph */\r\n colorDomain?: (string | number)[];\r\n /** Toggle the visibility of labels of the lines when highlighted or mouse hovered */\r\n showLabels?: boolean;\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 /** Maximum value of the date for the chart */\r\n maxDate?: string | number;\r\n /** Minimum value of the date for the chart */\r\n minDate?: string | number;\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 /** Toggle visibility of dots on the line */\r\n showDots?: boolean;\r\n /** Stroke width of the line */\r\n strokeWidth?: number;\r\n /** Toggle the initial animation of the line. If the type is number then it uses the number as the time in seconds for animation. */\r\n animate?: boolean | AnimateDataType;\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 /** Title for the Y-axis */\r\n yAxisTitle?: string;\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Toggle visibility of NA color in the color scale. This is only applicable if the data props hae color parameter and showColorScale prop is true */\r\n showNAColor?: boolean;\r\n /** Defines how “NA” values should be displayed/labelled in the graph */\r\n naLabel?: string;\r\n /** Data points to highlight. Use the label value from data to highlight the data point */\r\n highlightedLines?: (string | number)[];\r\n /** Defines the opacity of the non-highlighted data */\r\n dimmedOpacity?: number;\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 /** 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 MultiLineAltChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n showNAColor = true,\r\n colors,\r\n colorDomain,\r\n suffix = '',\r\n sources,\r\n prefix = '',\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n padding,\r\n backgroundColor = false,\r\n leftMargin = 30,\r\n rightMargin = 50,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n showColorScale = true,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n showLabels = true,\r\n refValues = [],\r\n highlightAreaSettings = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n highlightedLines = [],\r\n graphDownload = false,\r\n dataDownload = false,\r\n animate = false,\r\n language = 'en',\r\n colorLegendTitle,\r\n minHeight = 0,\r\n strokeWidth = 2,\r\n showDots = true,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n minDate,\r\n maxDate,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n dimmedOpacity = 0.3,\r\n precision = 2,\r\n customLayers = [],\r\n naLabel = 'NA',\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [selectedColor, setSelectedColor] = useState<string | undefined>(undefined);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\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 multi-line 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 && data.filter(el => el.color).length !== 0 ? (\r\n <ColorLegendWithMouseOver\r\n width={width}\r\n colorLegendTitle={colorLegendTitle}\r\n colors={\r\n (colors as string[] | undefined) || Colors[theme].categoricalColors.colors\r\n }\r\n colorDomain={\r\n colorDomain ||\r\n uniqBy(\r\n data.filter(el => el.color),\r\n 'color',\r\n )\r\n .map(d => d.color)\r\n .filter(d => d !== undefined)\r\n }\r\n setSelectedColor={setSelectedColor}\r\n showNAColor={showNAColor}\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 lineColors={\r\n data.filter(el => el.color).length === 0\r\n ? colors\r\n ? [colors as string]\r\n : [Colors.primaryColors['blue-600']]\r\n : (colors as string[] | undefined) ||\r\n Colors[theme].categoricalColors.colors\r\n }\r\n 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 suffix={suffix}\r\n prefix={prefix}\r\n highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n highlightedLines={highlightedLines}\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 rtl={language === 'he' || language === 'ar'}\r\n strokeWidth={strokeWidth}\r\n showDots={showDots}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n minDate={minDate}\r\n maxDate={maxDate}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n selectedColor={selectedColor}\r\n showLabels={showLabels}\r\n colorDomain={\r\n data.filter(el => el.color).length === 0\r\n ? []\r\n : colorDomain ||\r\n (uniqBy(\r\n data.filter(el => el.color),\r\n 'color',\r\n ).map(d => d.color) as string[])\r\n }\r\n dimmedOpacity={dimmedOpacity}\r\n precision={precision}\r\n customLayers={customLayers}\r\n naLabel={naLabel}\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","lineColors","dateFormat","noOfXTicks","rightMargin","topMargin","bottomMargin","suffix","prefix","leftMargin","tooltip","onSeriesMouseOver","refValues","highlightAreaSettings","minValue","maxValue","highlightedLines","animate","rtl","strokeWidth","showDots","annotations","customHighlightAreaSettings","yAxisTitle","noOfYTicks","minDate","maxDate","curveType","styles","colorDomain","selectedColor","classNames","showLabels","dimmedOpacity","precision","naLabel","customLayers","svgRef","useRef","isInView","useInView","hasAnimatedOnce","setHasAnimatedOnce","useState","useEffect","timeout","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","dataFormatted","sortBy","d","parse","checkIfNullOrUndefined","labels","uniqBy","dates","mouseOverData","setMouseOverData","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","lineArray","el","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","j","graphWidth","graphHeight","minYear","maxYear","minParam","maxParam","x","scaleTime","y","scaleLinear","voronoiDiagram","Delaunay","lineShape","line","yTicks","xTicks","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","Colors","i","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","MultiLineAltChart","graphTitle","showNAColor","colors","sources","graphDescription","footNote","padding","backgroundColor","showColorScale","relativeHeight","graphID","graphDownload","dataDownload","language","colorLegendTitle","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","setSelectedColor","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","ColorLegendWithMouseOver","GraphFooter"],"mappings":"8rCAkGO,SAASA,GAAMC,GAAc,CAClC,KAAM,CACJ,KAAAC,EACA,MAAAC,EACA,OAAAC,EACA,WAAAC,EACA,WAAAC,EACA,WAAAC,GACA,YAAAC,EACA,UAAAC,GACA,aAAAC,EACA,OAAAC,EACA,OAAAC,EACA,WAAAC,EACA,QAAAC,GACA,kBAAAC,EACA,UAAAC,EACA,sBAAAC,EACA,SAAAC,EACA,SAAAC,GACA,iBAAAC,EACA,QAAAC,EACA,IAAAC,GACA,YAAAC,EACA,SAAAC,EACA,YAAAC,GACA,4BAAAC,GACA,WAAAC,GACA,WAAAC,GACA,QAAAC,GACA,QAAAC,GACA,UAAAC,EACA,OAAAC,EACA,YAAAC,EACA,cAAAC,EACA,WAAAC,EACA,WAAAC,EACA,cAAAC,EACA,UAAAC,EACA,QAAAC,GACA,aAAAC,EAAA,EACEvC,GACEwC,GAASC,EAAAA,OAAO,IAAI,EACpBC,EAAWC,GAAAA,UAAUH,GAAQ,CACjC,KAAMpB,EAAQ,KACd,OAAQA,EAAQ,MAAA,CACjB,EACK,CAACwB,EAAiBC,EAAkB,EAAIC,EAAAA,SAAS,EAAK,EAE5DC,EAAAA,UAAU,IAAM,CACd,GAAIL,GAAY,CAACE,EAAiB,CAChC,MAAMI,EAAU,WACd,IAAM,CACJH,GAAmB,EAAI,CACzB,GACCzB,EAAQ,SAAW,IAAO,GAAA,EAE7B,MAAO,IAAM,aAAa4B,CAAO,CACnC,CACF,EAAG,CAACN,EAAUE,EAAiBxB,EAAQ,QAAQ,CAAC,EA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