@undp/data-viz 1.4.15 → 1.4.16
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.
- package/dist/AreaChart.cjs +1 -1
- package/dist/AreaChart.js +1 -1
- package/dist/DifferenceLineChart.cjs +1 -1
- package/dist/DifferenceLineChart.js +1 -1
- package/dist/DualAxisLineChart.cjs +1 -1
- package/dist/DualAxisLineChart.js +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs +1 -1
- package/dist/LineChartWithConfidenceInterval.js +1 -1
- package/dist/MultiLineAltChart.cjs +1 -1
- package/dist/MultiLineAltChart.js +1 -1
- package/dist/MultiLineChart.cjs +1 -1
- package/dist/MultiLineChart.js +1 -1
- package/dist/ScatterPlot.cjs +1 -1
- package/dist/ScatterPlot.cjs.map +1 -1
- package/dist/ScatterPlot.js +26 -24
- package/dist/ScatterPlot.js.map +1 -1
- package/dist/SimpleLineChart.cjs +1 -1
- package/dist/SimpleLineChart.js +1 -1
- package/dist/{index-DNj994Pv.cjs → index-BYzIB5V6.cjs} +2 -2
- package/dist/index-BYzIB5V6.cjs.map +1 -0
- package/dist/{index-Cdcfp4nk.js → index-DKCxu1Gh.js} +2 -2
- package/dist/index-DKCxu1Gh.js.map +1 -0
- package/package.json +1 -1
- package/dist/index-Cdcfp4nk.js.map +0 -1
- package/dist/index-DNj994Pv.cjs.map +0 -1
package/dist/AreaChart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),h=require("react"),m=require("./parse-hMnG_lRV.cjs"),de=require("./index-BzeLQvXk.cjs"),ue=require("./index-C21TvELx.cjs"),he=require("./numberFormattingFunction-02t-wJta.cjs"),fe=require("./Tooltip-n8z5bfav.cjs"),Z=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),me=require("./customArea-CK768gCn.cjs"),ye=require("./AxisTitle-CK9YeovX.cjs"),je=require("./Axis-DE7dSn1_.cjs"),ve=require("./XTicksAndGridLines-CCzXIV8d.cjs"),we=require("./ReferenceLine-CFVBBN__.cjs"),Re=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ee=require("./index-DNj994Pv.cjs"),Ae=require("./time-Byw_jYQ7.cjs"),Ce=require("./linear-BVckp9RD.cjs"),be=require("./area-D3Qx7k7K.cjs"),Oe=require("./line-DHV4JwCR.cjs"),ee=require("./step-BZ3C8QFW.cjs"),qe=require("./select-Bnfk0lJx.cjs"),Ne=require("./init-DU0ybBc_.cjs"),Se=require("./pointer-Dkq5NV1q.cjs"),$e=require("./use-in-view-sQJZ_xDO.cjs"),te=require("./proxy-BHRoeZgd.cjs"),ke=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),De=require("./ColorLegend.cjs"),Me=require("./Colors.cjs"),Fe=require("./EmptyState-d8_8SxeW.cjs");function He(se){const{data:w,width:R,height:q,colors:G,dateFormat:o,noOfXTicks:N,rightMargin:a,leftMargin:f,topMargin:ie,bottomMargin:re,yAxisTitle:P,tooltip:D,onSeriesMouseOver:p,highlightAreaSettings:oe,refValues:V,minValue:I,maxValue:Y,rtl:W,annotations:ne,customHighlightAreaSettings:ae,noOfYTicks:S,prefix:M,suffix:F,curveType:$,styles:g,classNames:d,precision:k,customLayers:H,animate:y}=se,E=h.useRef(null),j=$e.useInView(E,{once:y.once,amount:y.amount}),le=$==="linear"?Oe.curveLinear:$==="step"?ee.curveStep:$==="stepAfter"?ee.stepAfter:$==="stepBefore"?ee.stepBefore:ee.monotoneX,[b,X]=h.useState(void 0),[U,B]=h.useState(void 0),[_,z]=h.useState(void 0),c={top:ie,bottom:re,left:P?f+30:f,right:a},J=h.useRef(null),i=de.sortBy(w.map(e=>({...e,date:m.parse(`${e.date}`,o,new Date)})),"date"),A=oe.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:m.parse(`${e.coordinates[0]}`,o,new Date),e.coordinates[1]===null?null:m.parse(`${e.coordinates[1]}`,o,new Date)]})),ce=ae.map(e=>({...e,coordinates:e.coordinates.map((n,l)=>l%2===0?m.parse(`${n}`,o,new Date):n)})),xe=i[0].y.map((e,n)=>i.map(l=>({date:l.date,y0:n===0?0:ue.sum(l.y.filter((T,O)=>O<n)),y1:ue.sum(l.y.filter((T,O)=>O<=n))}))),v=R-c.left-c.right,x=q-c.top-c.bottom,K=i[0].date,Q=i[i.length-1].date,u=Z.checkIfNullOrUndefined(I)?0:I,C=Z.checkIfNullOrUndefined(Y)?Math.max(...w.map(e=>ue.sum(e.y)||0)):Y,r=Ae.time().domain([K,Q]).range([0,v]),s=Ce.linear().domain([u,C]).range([x,0]).nice(),L=be.area().x(e=>r(e.date)).y0(e=>s(e.y0)).y1(e=>s(e.y1)).curve(le),pe=s.ticks(S),ge=r.ticks(N);return h.useEffect(()=>{const e=l=>{const T=i[Ne.bisectCenter(i.map(O=>O.date),r.invert(Se.pointer(l)[0]),0)];X(T||i[i.length-1]),p?.(T||i[i.length-1]),z(l.clientY),B(l.clientX)},n=()=>{X(void 0),B(void 0),z(void 0),p?.(void 0)};qe.select(J.current).on("mousemove",e).on("mouseout",n),p?.(void 0)},[r,i,p]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(te.motion.svg,{width:`${R}px`,height:`${q}px`,viewBox:`0 0 ${R} ${q}`,direction:"ltr",ref:E,children:t.jsxRuntimeExports.jsx(ke.AnimatePresence,{children:t.jsxRuntimeExports.jsxs(te.motion.g,{transform:`translate(${c.left},${c.top})`,children:[t.jsxRuntimeExports.jsx(Ee.HighlightArea,{areaSettings:A,width:v,height:x,scale:r,animate:y,isInView:j}),t.jsxRuntimeExports.jsx(me.CustomArea,{animate:y,areaSettings:ce,scaleX:r,scaleY:s,isInView:j}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Re.YTicksAndGridLines,{values:pe.filter(e=>e!==0),y:pe.filter(e=>e!==0).map(e=>s(e)),x1:0-f,x2:v+c.right,styles:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},classNames:{gridLines:d?.yAxis?.gridLines,labels:d?.yAxis?.labels},suffix:F,prefix:M,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:k}),t.jsxRuntimeExports.jsx(je.Axis,{y1:s(u<0?0:u),y2:s(u<0?0:u),x1:0-f,x2:v+c.right,label:he.numberFormattingFunction(u<0?0:u,"NA",k,M,F),labelPos:{x:0-f,dx:0,dy:C<0?"1em":-5,y:s(u<0?0:u)},classNames:{axis:d?.xAxis?.axis,label:d?.yAxis?.labels},styles:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(ye.AxisTitle,{x:0-f-15,y:x/2,style:g?.yAxis?.title,className:d?.yAxis?.title,text:P,rotate90:!0})]}),t.jsxRuntimeExports.jsx(ve.XTicksAndGridLines,{values:ge.map(e=>m.format(e,o)),x:ge.map(e=>r(e)),y1:0,y2:x,styles:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",d?.xAxis?.gridLines),labels:t.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs",d?.xAxis?.labels)},suffix:F,prefix:M,labelType:"primary",showGridLines:!0,precision:k}),H.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs(te.motion.g,{children:[xe.map((e,n)=>t.jsxRuntimeExports.jsx(te.motion.path,{d:L(e),exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{d:L(e.map(l=>({...l,y0:0,y1:0}))),opacity:0},whileInView:{d:L(e),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",style:{fill:G[n],opacity:.8}},n)),b?t.jsxRuntimeExports.jsx("line",{y1:0,y2:x,x1:r(b.date),x2:r(b.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",d?.mouseOverLine),style:g?.mouseOverLine}):null]}),V?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:V.map((e,n)=>t.jsxRuntimeExports.jsx(we.RefLineY,{text:e.text,color:e.color,y:s(e.value),x1:0-f,x2:v+c.right,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n))}):null,t.jsxRuntimeExports.jsx("g",{children:ne.map((e,n)=>{const l=me.getLineEndPoint({x:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date)):0,y:e.yCoordinate?s(e.yCoordinate):0},Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),T=e.showConnector?{y1:l.y,x1:l.x,y2:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),cx:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date)):0,cy:e.yCoordinate?s(e.yCoordinate):0,circleRadius:Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,O={y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:W?0:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:W?e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0):v+c.right-(e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(me.Annotation,{color:e.color,connectorsSettings:T,labelSettings:O,text:e.text,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n)})}),H.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:J,style:{fill:"none",pointerEvents:"all"},width:v,height:x})]})})}),b&&D&&U&&_?t.jsxRuntimeExports.jsx(fe.Tooltip,{data:b,body:D,xPos:U,yPos:_,backgroundStyle:g?.tooltip,className:d?.tooltip}):null]})}function Ge(se){const{data:w,graphTitle:R,colors:q=Me.Colors.light.categoricalColors.colors,sources:G,graphDescription:o,height:N,width:a,footNote:f,noOfXTicks:ie=10,dateFormat:re="yyyy",colorDomain:P,padding:D,backgroundColor:p=!1,colorLegendTitle:oe,leftMargin:V=50,rightMargin:I=20,topMargin:Y=20,bottomMargin:W=25,highlightAreaSettings:ne=[],tooltip:ae,relativeHeight:S,onSeriesMouseOver:M,refValues:F=[],graphID:$,minValue:g,maxValue:d,graphDownload:k=!1,dataDownload:H=!1,showColorScale:y=!0,language:E="en",minHeight:j=0,annotations:le=[],customHighlightAreaSettings:b=[],theme:X="light",ariaLabel:U,yAxisTitle:B,noOfYTicks:_=5,prefix:z="",suffix:c="",curveType:J="curve",styles:i,classNames:A,precision:ce=2,customLayers:xe=[],animate:v=!1}=se,[x,K]=h.useState(0),[Q,u]=h.useState(0),C=h.useRef(null),r=h.useRef(null);return h.useEffect(()=>{const s=new ResizeObserver(L=>{K(a||L[0].target.clientWidth||620),u(N||L[0].target.clientHeight||480)});return C.current&&(u(C.current.clientHeight||480),K(C.current.clientWidth||620),a||s.observe(C.current)),()=>s.disconnect()},[a,N]),t.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:E==="he"||E==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${p?p===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${E||"en"}`,a?"w-fit":"w-full",A?.graphContainer),style:{...i?.graphContainer||{},...p&&p!==!0?{backgroundColor:p}:{}},id:$,ref:r,"aria-label":U||`${R?`The graph shows ${R}. `:""}This is a stacked area chart that shows trends over time.${o?` ${o}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:p?D||"1rem":D||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||o||k||H?t.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:i?.title,description:i?.description},classNames:{title:A?.title,description:A?.description},graphTitle:R,graphDescription:o,width:a,graphDownload:k?r.current:void 0,dataDownload:H?w.map(s=>s.data).filter(s=>s!==void 0).length>0?w.map(s=>s.data).filter(s=>s!==void 0):w.filter(s=>s!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:w.length===0?t.jsxRuntimeExports.jsx(Fe.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[y!==!1?t.jsxRuntimeExports.jsx(De.ColorLegend,{colorDomain:P,colors:q,colorLegendTitle:oe,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:C,"aria-label":"Graph area",children:(a||x)&&(N||Q)?t.jsxRuntimeExports.jsx(He,{data:w,colors:q,width:a||x,height:Math.max(j,N||(S?j?(a||x)*S>j?(a||x)*S:j:(a||x)*S:Q)),dateFormat:re,noOfXTicks:ie,leftMargin:V,rightMargin:I,topMargin:Y,bottomMargin:W,tooltip:ae,onSeriesMouseOver:M,highlightAreaSettings:ne,refValues:F,minValue:g,maxValue:d,rtl:E==="he"||E==="ar",annotations:le,customHighlightAreaSettings:b,yAxisTitle:B,noOfYTicks:_,prefix:z,suffix:c,curveType:J,styles:i,classNames:A,precision:ce,customLayers:xe,animate:v===!0?{duration:.5,once:!0,amount:.5}:v||{duration:0,once:!0,amount:0}}):null})]})}),G||f?t.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:i?.footnote,source:i?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:G,footNote:f,width:a}):null]})})})})}exports.AreaChart=Ge;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),h=require("react"),m=require("./parse-hMnG_lRV.cjs"),de=require("./index-BzeLQvXk.cjs"),ue=require("./index-C21TvELx.cjs"),he=require("./numberFormattingFunction-02t-wJta.cjs"),fe=require("./Tooltip-n8z5bfav.cjs"),Z=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),me=require("./customArea-CK768gCn.cjs"),ye=require("./AxisTitle-CK9YeovX.cjs"),je=require("./Axis-DE7dSn1_.cjs"),ve=require("./XTicksAndGridLines-CCzXIV8d.cjs"),we=require("./ReferenceLine-CFVBBN__.cjs"),Re=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ee=require("./index-BYzIB5V6.cjs"),Ae=require("./time-Byw_jYQ7.cjs"),Ce=require("./linear-BVckp9RD.cjs"),be=require("./area-D3Qx7k7K.cjs"),Oe=require("./line-DHV4JwCR.cjs"),ee=require("./step-BZ3C8QFW.cjs"),qe=require("./select-Bnfk0lJx.cjs"),Ne=require("./init-DU0ybBc_.cjs"),Se=require("./pointer-Dkq5NV1q.cjs"),$e=require("./use-in-view-sQJZ_xDO.cjs"),te=require("./proxy-BHRoeZgd.cjs"),ke=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),De=require("./ColorLegend.cjs"),Me=require("./Colors.cjs"),Fe=require("./EmptyState-d8_8SxeW.cjs");function He(se){const{data:w,width:R,height:q,colors:G,dateFormat:o,noOfXTicks:N,rightMargin:a,leftMargin:f,topMargin:ie,bottomMargin:re,yAxisTitle:P,tooltip:D,onSeriesMouseOver:p,highlightAreaSettings:oe,refValues:V,minValue:I,maxValue:Y,rtl:W,annotations:ne,customHighlightAreaSettings:ae,noOfYTicks:S,prefix:M,suffix:F,curveType:$,styles:g,classNames:d,precision:k,customLayers:H,animate:y}=se,E=h.useRef(null),j=$e.useInView(E,{once:y.once,amount:y.amount}),le=$==="linear"?Oe.curveLinear:$==="step"?ee.curveStep:$==="stepAfter"?ee.stepAfter:$==="stepBefore"?ee.stepBefore:ee.monotoneX,[b,X]=h.useState(void 0),[U,B]=h.useState(void 0),[_,z]=h.useState(void 0),c={top:ie,bottom:re,left:P?f+30:f,right:a},J=h.useRef(null),i=de.sortBy(w.map(e=>({...e,date:m.parse(`${e.date}`,o,new Date)})),"date"),A=oe.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:m.parse(`${e.coordinates[0]}`,o,new Date),e.coordinates[1]===null?null:m.parse(`${e.coordinates[1]}`,o,new Date)]})),ce=ae.map(e=>({...e,coordinates:e.coordinates.map((n,l)=>l%2===0?m.parse(`${n}`,o,new Date):n)})),xe=i[0].y.map((e,n)=>i.map(l=>({date:l.date,y0:n===0?0:ue.sum(l.y.filter((T,O)=>O<n)),y1:ue.sum(l.y.filter((T,O)=>O<=n))}))),v=R-c.left-c.right,x=q-c.top-c.bottom,K=i[0].date,Q=i[i.length-1].date,u=Z.checkIfNullOrUndefined(I)?0:I,C=Z.checkIfNullOrUndefined(Y)?Math.max(...w.map(e=>ue.sum(e.y)||0)):Y,r=Ae.time().domain([K,Q]).range([0,v]),s=Ce.linear().domain([u,C]).range([x,0]).nice(),L=be.area().x(e=>r(e.date)).y0(e=>s(e.y0)).y1(e=>s(e.y1)).curve(le),pe=s.ticks(S),ge=r.ticks(N);return h.useEffect(()=>{const e=l=>{const T=i[Ne.bisectCenter(i.map(O=>O.date),r.invert(Se.pointer(l)[0]),0)];X(T||i[i.length-1]),p?.(T||i[i.length-1]),z(l.clientY),B(l.clientX)},n=()=>{X(void 0),B(void 0),z(void 0),p?.(void 0)};qe.select(J.current).on("mousemove",e).on("mouseout",n),p?.(void 0)},[r,i,p]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(te.motion.svg,{width:`${R}px`,height:`${q}px`,viewBox:`0 0 ${R} ${q}`,direction:"ltr",ref:E,children:t.jsxRuntimeExports.jsx(ke.AnimatePresence,{children:t.jsxRuntimeExports.jsxs(te.motion.g,{transform:`translate(${c.left},${c.top})`,children:[t.jsxRuntimeExports.jsx(Ee.HighlightArea,{areaSettings:A,width:v,height:x,scale:r,animate:y,isInView:j}),t.jsxRuntimeExports.jsx(me.CustomArea,{animate:y,areaSettings:ce,scaleX:r,scaleY:s,isInView:j}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Re.YTicksAndGridLines,{values:pe.filter(e=>e!==0),y:pe.filter(e=>e!==0).map(e=>s(e)),x1:0-f,x2:v+c.right,styles:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},classNames:{gridLines:d?.yAxis?.gridLines,labels:d?.yAxis?.labels},suffix:F,prefix:M,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:k}),t.jsxRuntimeExports.jsx(je.Axis,{y1:s(u<0?0:u),y2:s(u<0?0:u),x1:0-f,x2:v+c.right,label:he.numberFormattingFunction(u<0?0:u,"NA",k,M,F),labelPos:{x:0-f,dx:0,dy:C<0?"1em":-5,y:s(u<0?0:u)},classNames:{axis:d?.xAxis?.axis,label:d?.yAxis?.labels},styles:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(ye.AxisTitle,{x:0-f-15,y:x/2,style:g?.yAxis?.title,className:d?.yAxis?.title,text:P,rotate90:!0})]}),t.jsxRuntimeExports.jsx(ve.XTicksAndGridLines,{values:ge.map(e=>m.format(e,o)),x:ge.map(e=>r(e)),y1:0,y2:x,styles:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",d?.xAxis?.gridLines),labels:t.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[8px] sm:text-[9px] md:text-[10px] lg:text-xs",d?.xAxis?.labels)},suffix:F,prefix:M,labelType:"primary",showGridLines:!0,precision:k}),H.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs(te.motion.g,{children:[xe.map((e,n)=>t.jsxRuntimeExports.jsx(te.motion.path,{d:L(e),exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{d:L(e.map(l=>({...l,y0:0,y1:0}))),opacity:0},whileInView:{d:L(e),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",style:{fill:G[n],opacity:.8}},n)),b?t.jsxRuntimeExports.jsx("line",{y1:0,y2:x,x1:r(b.date),x2:r(b.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",d?.mouseOverLine),style:g?.mouseOverLine}):null]}),V?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:V.map((e,n)=>t.jsxRuntimeExports.jsx(we.RefLineY,{text:e.text,color:e.color,y:s(e.value),x1:0-f,x2:v+c.right,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n))}):null,t.jsxRuntimeExports.jsx("g",{children:ne.map((e,n)=>{const l=me.getLineEndPoint({x:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date)):0,y:e.yCoordinate?s(e.yCoordinate):0},Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),T=e.showConnector?{y1:l.y,x1:l.x,y2:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),cx:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date)):0,cy:e.yCoordinate?s(e.yCoordinate):0,circleRadius:Z.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,O={y:e.yCoordinate?s(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:W?0:e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:W?e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0):v+c.right-(e.xCoordinate?r(m.parse(`${e.xCoordinate}`,o,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(me.Annotation,{color:e.color,connectorsSettings:T,labelSettings:O,text:e.text,classNames:e.classNames,styles:e.styles,animate:y,isInView:j},n)})}),H.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:J,style:{fill:"none",pointerEvents:"all"},width:v,height:x})]})})}),b&&D&&U&&_?t.jsxRuntimeExports.jsx(fe.Tooltip,{data:b,body:D,xPos:U,yPos:_,backgroundStyle:g?.tooltip,className:d?.tooltip}):null]})}function Ge(se){const{data:w,graphTitle:R,colors:q=Me.Colors.light.categoricalColors.colors,sources:G,graphDescription:o,height:N,width:a,footNote:f,noOfXTicks:ie=10,dateFormat:re="yyyy",colorDomain:P,padding:D,backgroundColor:p=!1,colorLegendTitle:oe,leftMargin:V=50,rightMargin:I=20,topMargin:Y=20,bottomMargin:W=25,highlightAreaSettings:ne=[],tooltip:ae,relativeHeight:S,onSeriesMouseOver:M,refValues:F=[],graphID:$,minValue:g,maxValue:d,graphDownload:k=!1,dataDownload:H=!1,showColorScale:y=!0,language:E="en",minHeight:j=0,annotations:le=[],customHighlightAreaSettings:b=[],theme:X="light",ariaLabel:U,yAxisTitle:B,noOfYTicks:_=5,prefix:z="",suffix:c="",curveType:J="curve",styles:i,classNames:A,precision:ce=2,customLayers:xe=[],animate:v=!1}=se,[x,K]=h.useState(0),[Q,u]=h.useState(0),C=h.useRef(null),r=h.useRef(null);return h.useEffect(()=>{const s=new ResizeObserver(L=>{K(a||L[0].target.clientWidth||620),u(N||L[0].target.clientHeight||480)});return C.current&&(u(C.current.clientHeight||480),K(C.current.clientWidth||620),a||s.observe(C.current)),()=>s.disconnect()},[a,N]),t.jsxRuntimeExports.jsx("div",{className:`${X||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:E==="he"||E==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${p?p===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${E||"en"}`,a?"w-fit":"w-full",A?.graphContainer),style:{...i?.graphContainer||{},...p&&p!==!0?{backgroundColor:p}:{}},id:$,ref:r,"aria-label":U||`${R?`The graph shows ${R}. `:""}This is a stacked area chart that shows trends over time.${o?` ${o}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:p?D||"1rem":D||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||o||k||H?t.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:i?.title,description:i?.description},classNames:{title:A?.title,description:A?.description},graphTitle:R,graphDescription:o,width:a,graphDownload:k?r.current:void 0,dataDownload:H?w.map(s=>s.data).filter(s=>s!==void 0).length>0?w.map(s=>s.data).filter(s=>s!==void 0):w.filter(s=>s!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:w.length===0?t.jsxRuntimeExports.jsx(Fe.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[y!==!1?t.jsxRuntimeExports.jsx(De.ColorLegend,{colorDomain:P,colors:q,colorLegendTitle:oe,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:C,"aria-label":"Graph area",children:(a||x)&&(N||Q)?t.jsxRuntimeExports.jsx(He,{data:w,colors:q,width:a||x,height:Math.max(j,N||(S?j?(a||x)*S>j?(a||x)*S:j:(a||x)*S:Q)),dateFormat:re,noOfXTicks:ie,leftMargin:V,rightMargin:I,topMargin:Y,bottomMargin:W,tooltip:ae,onSeriesMouseOver:M,highlightAreaSettings:ne,refValues:F,minValue:g,maxValue:d,rtl:E==="he"||E==="ar",annotations:le,customHighlightAreaSettings:b,yAxisTitle:B,noOfYTicks:_,prefix:z,suffix:c,curveType:J,styles:i,classNames:A,precision:ce,customLayers:xe,animate:v===!0?{duration:.5,once:!0,amount:.5}:v||{duration:0,once:!0,amount:0}}):null})]})}),G||f?t.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:i?.footnote,source:i?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:G,footNote:f,width:a}):null]})})})})}exports.AreaChart=Ge;
|
|
2
2
|
//# sourceMappingURL=AreaChart.cjs.map
|
package/dist/AreaChart.js
CHANGED
|
@@ -12,7 +12,7 @@ import { A as je } from "./Axis-Ddg-seDi.js";
|
|
|
12
12
|
import { X as Oe } from "./XTicksAndGridLines-Bn9u5gOM.js";
|
|
13
13
|
import { R as $e } from "./ReferenceLine-CfAW3vKJ.js";
|
|
14
14
|
import { Y as Ne } from "./YTicksAndGridLines-B6ah7CRf.js";
|
|
15
|
-
import { H as De } from "./index-
|
|
15
|
+
import { H as De } from "./index-DKCxu1Gh.js";
|
|
16
16
|
import { t as Le } from "./time-BzJP5SPC.js";
|
|
17
17
|
import { a as ke } from "./linear-DUdu7l2G.js";
|
|
18
18
|
import { a as Se } from "./area-BE2wo7fv.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),m=require("./parse-hMnG_lRV.cjs"),qt=require("./index-BzeLQvXk.cjs"),Et=require("./numberFormattingFunction-02t-wJta.cjs"),Tt=require("./Tooltip-n8z5bfav.cjs"),T=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),bt=require("./customArea-CK768gCn.cjs"),Mt=require("./AxisTitle-CK9YeovX.cjs"),Ft=require("./Axis-DE7dSn1_.cjs"),Pt=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Gt=require("./ReferenceLine-CFVBBN__.cjs"),Ht=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Wt=require("./index-DNj994Pv.cjs"),Yt=require("./time-Byw_jYQ7.cjs"),Xt=require("./linear-BVckp9RD.cjs"),At=require("./line-DHV4JwCR.cjs"),ht=require("./step-BZ3C8QFW.cjs"),Ct=require("./area-D3Qx7k7K.cjs"),Ut=require("./select-Bnfk0lJx.cjs"),Bt=require("./init-DU0ybBc_.cjs"),zt=require("./pointer-Dkq5NV1q.cjs"),Jt=require("./use-in-view-sQJZ_xDO.cjs"),f=require("./proxy-BHRoeZgd.cjs"),Kt=require("./GraphFooter.cjs"),Qt=require("./GraphHeader.cjs"),Zt=require("./ColorLegend.cjs"),pt=require("./Colors.cjs"),_t=require("./generateRandomString-B5zBiJzS.cjs"),te=require("./EmptyState-d8_8SxeW.cjs");function ee(dt){const{data:V,width:O,height:G,lineColors:j,suffix:D,prefix:w,dateFormat:o,showValues:l,noOfXTicks:z,rightMargin:yt,leftMargin:R,topMargin:gt,bottomMargin:J,tooltip:H,highlightAreaSettings:N,onSeriesMouseOver:W,animate:n,rtl:K,showColorLegendAtTop:ft,colorDomain:M,diffAreaColors:Q,idSuffix:E,strokeWidth:Z,showDots:_,refValues:Y,minValue:k,maxValue:X,annotations:L,customHighlightAreaSettings:F,yAxisTitle:U,noOfYTicks:tt,minDate:et,maxDate:it,curveType:P,styles:h,classNames:p,precision:S,customLayers:nt}=dt,at=d.useRef(null),r=Jt.useInView(at,{once:n.once,amount:n.amount}),[c,jt]=d.useState(!1);d.useEffect(()=>{if(r&&!c){const t=setTimeout(()=>{jt(!0)},(n.duration+.5)*1e3);return()=>clearTimeout(t)}},[r,c,n.duration]);const $=P==="linear"?At.curveLinear:P==="step"?ht.curveStep:P==="stepAfter"?ht.stepAfter:P==="stepBefore"?ht.stepBefore:ht.monotoneX,[q,st]=d.useState(void 0),[ot,rt]=d.useState(void 0),[b,A]=d.useState(void 0),y={top:gt,bottom:J,left:U?R+30:R,right:yt},lt=d.useRef(null),i=qt.sortBy(V.map(t=>({...t,date:m.parse(`${t.date}`,o,new Date)})),"date"),ct=N.map(t=>({...t,coordinates:[t.coordinates[0]===null?null:m.parse(`${t.coordinates[0]}`,o,new Date),t.coordinates[1]===null?null:m.parse(`${t.coordinates[1]}`,o,new Date)]})),xt=F.map(t=>({...t,coordinates:t.coordinates.map((v,I)=>I%2===0?m.parse(`${v}`,o,new Date):v)})),x=O-y.left-y.right,g=G-y.top-y.bottom,ut=et?m.parse(`${et}`,o,new Date):i[0].date,u=it?m.parse(`${it}`,o,new Date):i[i.length-1].date,B=Math.min(...i.map(t=>t.y1))!==1/0?Math.min(...i.map(t=>t.y1))>0?0:Math.min(...i.map(t=>t.y1)):0,Ot=Math.min(...i.map(t=>t.y2))!==1/0?Math.min(...i.map(t=>t.y2))>0?0:Math.min(...i.map(t=>t.y2)):0,Nt=Math.max(...i.map(t=>t.y1))!==1/0?Math.max(...i.map(t=>t.y1)):0,It=Math.max(...i.map(t=>t.y2))!==1/0?Math.max(...i.map(t=>t.y2)):0,C=T.checkIfNullOrUndefined(k)?B<Ot?B:Ot:k,wt=Nt>It?Nt:It,a=Yt.time().domain([ut,u]).range([0,x]),s=Xt.linear().domain([T.checkIfNullOrUndefined(k)?C:k,T.checkIfNullOrUndefined(X)?wt>0?wt:0:X]).range([g,0]).nice(),vt=At.line().x(t=>a(t.date)).y(t=>s(t.y1)).curve($),Vt=At.line().x(t=>a(t.date)).y(t=>s(t.y2)).curve($),Dt=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(t=>s(t.y2)).curve($),St=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(0).curve($),$t=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y2)).y0(0).curve($),kt=s.ticks(tt),Lt=a.ticks(z);return d.useEffect(()=>{const t=I=>{const mt=i[Bt.bisectCenter(i.map(Rt=>Rt.date),a.invert(zt.pointer(I)[0]),0)];st(mt||i[i.length-1]),W?.(mt||i[i.length-1]),A(I.clientY),rt(I.clientX)},v=()=>{st(void 0),rt(void 0),A(void 0),W?.(void 0)};Ut.select(lt.current).on("mousemove",t).on("mouseout",v)},[a,i,W]),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.svg,{width:`${O}px`,height:`${G}px`,viewBox:`0 0 ${O} ${G}`,direction:"ltr",ref:at,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${y.left},${y.top})`,children:[e.jsxRuntimeExports.jsx("clipPath",{id:`above${E}`,children:e.jsxRuntimeExports.jsx("path",{d:$t(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx("clipPath",{id:`below${E}`,children:e.jsxRuntimeExports.jsx("path",{d:St(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx(Wt.HighlightArea,{areaSettings:ct,width:x,height:g,scale:a,animate:n,isInView:r}),e.jsxRuntimeExports.jsx(bt.CustomArea,{areaSettings:xt,scaleX:a,scaleY:s,animate:n,isInView:r}),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(Ht.YTicksAndGridLines,{values:kt.filter(t=>t!==0),y:kt.filter(t=>t!==0).map(t=>s(t)),x1:0-R,x2:x+y.right,styles:{gridLines:h?.yAxis?.gridLines,labels:h?.yAxis?.labels},classNames:{gridLines:p?.yAxis?.gridLines,labels:p?.yAxis?.labels},suffix:D,prefix:w,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:S}),e.jsxRuntimeExports.jsx(Ft.Axis,{y1:s(C<0?0:C),y2:s(C<0?0:C),x1:0-R,x2:x+y.right,label:Et.numberFormattingFunction(C<0?0:C,"NA",S,w,D),labelPos:{x:0-R,y:s(C<0?0:C),dx:0,dy:wt<0?"1rem":-5},classNames:{axis:p?.xAxis?.axis,label:p?.yAxis?.labels},styles:{axis:h?.xAxis?.axis,label:h?.yAxis?.labels}}),e.jsxRuntimeExports.jsx(Mt.AxisTitle,{x:0-R-15,y:g/2,style:h?.yAxis?.title,className:p?.yAxis?.title,text:U,rotate90:!0})]})}),e.jsxRuntimeExports.jsx(Pt.XTicksAndGridLines,{values:Lt.map(t=>m.format(t,o)),x:Lt.map(t=>a(t)),y1:0,y2:g,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:e.mo("opacity-0",p?.xAxis?.gridLines),labels:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs",p?.xAxis?.labels)},suffix:D,prefix:w,labelType:"primary",showGridLines:!0,precision:S}),nt.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.path,{clipPath:`url(#below${E})`,d:Dt(i)||"",style:{fill:Q[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:1},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{clipPath:`url(#above${E})`,d:Dt(i)||"",style:{fill:Q[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.path,{d:vt(i)||"",style:{fill:"none",stroke:j[0],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:vt(i)||"",opacity:1},whileInView:{pathLength:1,d:vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{style:{fill:"none",stroke:j[1],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:Vt(i)||"",opacity:1},whileInView:{pathLength:1,d:Vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),ft?null:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.text,{style:{fill:j[0]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y1)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[0]},M[0]),e.jsxRuntimeExports.jsx(f.motion.text,{style:{fill:j[1]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y2)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[1]},M[1])]}),q?e.jsxRuntimeExports.jsx("line",{y1:0,y2:g,x1:a(q.date),x2:a(q.date),className:e.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",p?.mouseOverLine),style:h?.mouseOverLine}):null,i.map((t,v)=>e.jsxRuntimeExports.jsxs(f.motion.g,{children:[T.checkIfNullOrUndefined(t.y1)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(f.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:j[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y1)},whileInView:{opacity:1,transition:{duration:.5,delay:n.duration},cx:a(t.date),cy:s(t.y1)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(f.motion.text,{dy:t.y2<t.y1?-8:"1em",style:{fill:j[0],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-1 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y1)},whileInView:{opacity:1,x:a(t.date),y:s(t.y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y1,"NA",S,w,D)}):null]}),T.checkIfNullOrUndefined(t.y2)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(f.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:j[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y2)},whileInView:{opacity:1,transition:{duration:c?n.duration:.5,delay:c?0:n.duration},cx:a(t.date),cy:s(t.y2)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(f.motion.text,{dy:t.y2>t.y1?-8:"1em",style:{fill:j[1],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-2 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y2)},whileInView:{opacity:1,x:a(t.date),y:s(t.y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y2,"NA",S,w,D)}):null]})]},v))]}),Y?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Y.map((t,v)=>e.jsxRuntimeExports.jsx(Gt.RefLineY,{text:t.text,color:t.color,y:s(t.value),x1:0-R,x2:x+y.right,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v))}):null,e.jsxRuntimeExports.jsx("g",{children:L.map((t,v)=>{const I=bt.getLineEndPoint({x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8},{x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,y:t.yCoordinate?s(t.yCoordinate):0},T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius),mt=t.showConnector?{y1:I.y,x1:I.x,y2:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0):0+(t.yOffset||0),x2:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),cy:t.yCoordinate?s(t.yCoordinate):0,cx:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,circleRadius:T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius,strokeWidth:t.showConnector===!0?2:Math.min(t.showConnector||0,1)}:void 0,Rt={y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8,x:K?0:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),width:K?t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0):x+y.right-(t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0)),maxWidth:t.maxWidth,fontWeight:t.fontWeight,align:t.align};return e.jsxRuntimeExports.jsx(bt.Annotation,{color:t.color,connectorsSettings:mt,labelSettings:Rt,text:t.text,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v)})}),nt.filter(t=>t.position==="after").map(t=>t.layer),e.jsxRuntimeExports.jsx("rect",{ref:lt,style:{fill:"none",pointerEvents:"all"},width:x,height:g})]})}),q&&H&&ot&&b?e.jsxRuntimeExports.jsx(Tt.Tooltip,{data:q,body:H,xPos:ot,yPos:b,backgroundStyle:h?.tooltip,className:p?.tooltip}):null]})}function ie(dt){const{data:V,graphTitle:O,suffix:G="",sources:j,prefix:D="",graphDescription:w,height:o,width:l,footNote:z,noOfXTicks:yt=10,dateFormat:R="yyyy",showValues:gt=!1,padding:J,lineColors:H=[pt.Colors.light.categoricalColors.colors[0],pt.Colors.light.categoricalColors.colors[1]],backgroundColor:N=!1,leftMargin:W=30,rightMargin:n=50,topMargin:K=20,bottomMargin:ft=25,tooltip:M,highlightAreaSettings:Q=[],relativeHeight:E,onSeriesMouseOver:Z,graphID:_,graphDownload:Y=!1,dataDownload:k=!1,animate:X=!1,language:L="en",minHeight:F=0,labels:U,showColorLegendAtTop:tt=!1,colorLegendTitle:et,diffAreaColors:it=[pt.Colors.alerts.red,pt.Colors.alerts.darkGreen],strokeWidth:P=2,showDots:h=!0,refValues:p=[],minValue:S,maxValue:nt,annotations:at=[],customHighlightAreaSettings:r=[],theme:c="light",ariaLabel:jt,yAxisTitle:$,noOfYTicks:q=5,minDate:st,maxDate:ot,curveType:rt="curve",styles:b,classNames:A,precision:y=2,customLayers:lt=[]}=dt,[i,ct]=d.useState(0),[xt,x]=d.useState(0),g=d.useRef(null),ut=d.useRef(null);return d.useEffect(()=>{const u=new ResizeObserver(B=>{ct(l||B[0].target.clientWidth||620),x(o||B[0].target.clientHeight||480)});return g.current&&(x(g.current.clientHeight||480),ct(g.current.clientWidth||620),l||u.observe(g.current)),()=>u.disconnect()},[l,o]),e.jsxRuntimeExports.jsx("div",{className:`${c||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:L==="he"||L==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${N?N===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${L||"en"}`,l?"w-fit":"w-full",A?.graphContainer),style:{...b?.graphContainer||{},...N&&N!==!0?{backgroundColor:N}:{}},id:_,ref:ut,"aria-label":jt||`${O?`The graph shows ${O}. `:""}This is a line chart that highlights the difference between two datasets over time.${w?` ${w}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:N?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[O||w||Y||k?e.jsxRuntimeExports.jsx(Qt.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:A?.title,description:A?.description},graphTitle:O,graphDescription:w,width:l,graphDownload:Y?ut.current:void 0,dataDownload:k?V.map(u=>u.data).filter(u=>u!==void 0).length>0?V.map(u=>u.data).filter(u=>u!==void 0):V.filter(u=>u!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:V.length===0?e.jsxRuntimeExports.jsx(te.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[tt?e.jsxRuntimeExports.jsx(Zt.ColorLegend,{colorDomain:U,colorLegendTitle:et,colors:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:g,"aria-label":"Graph area",children:(l||i)&&(o||xt)?e.jsxRuntimeExports.jsx(ee,{data:V,lineColors:H,colorDomain:U,width:l||i,height:Math.max(F,o||(E?F?(l||i)*E>F?(l||i)*E:F:(l||i)*E:xt)),suffix:G,prefix:D,dateFormat:R,showValues:gt,noOfXTicks:yt,leftMargin:W,rightMargin:n,topMargin:K,bottomMargin:ft,highlightAreaSettings:Q,tooltip:M,onSeriesMouseOver:Z,showColorLegendAtTop:tt,animate:X===!0?{duration:.5,once:!0,amount:.5}:X||{duration:0,once:!0,amount:0},rtl:L==="he"||L==="ar",diffAreaColors:it,idSuffix:_t.generateRandomString(8),strokeWidth:P,showDots:h,refValues:p,minValue:S,maxValue:nt,annotations:at,customHighlightAreaSettings:r,yAxisTitle:$,noOfYTicks:q,minDate:st,maxDate:ot,curveType:rt,styles:b,classNames:A,precision:y,customLayers:lt}):null})]})}),j||z?e.jsxRuntimeExports.jsx(Kt.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:j,footNote:z,width:l}):null]})})})})}exports.DifferenceLineChart=ie;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),m=require("./parse-hMnG_lRV.cjs"),qt=require("./index-BzeLQvXk.cjs"),Et=require("./numberFormattingFunction-02t-wJta.cjs"),Tt=require("./Tooltip-n8z5bfav.cjs"),T=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),bt=require("./customArea-CK768gCn.cjs"),Mt=require("./AxisTitle-CK9YeovX.cjs"),Ft=require("./Axis-DE7dSn1_.cjs"),Pt=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Gt=require("./ReferenceLine-CFVBBN__.cjs"),Ht=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Wt=require("./index-BYzIB5V6.cjs"),Yt=require("./time-Byw_jYQ7.cjs"),Xt=require("./linear-BVckp9RD.cjs"),At=require("./line-DHV4JwCR.cjs"),ht=require("./step-BZ3C8QFW.cjs"),Ct=require("./area-D3Qx7k7K.cjs"),Ut=require("./select-Bnfk0lJx.cjs"),Bt=require("./init-DU0ybBc_.cjs"),zt=require("./pointer-Dkq5NV1q.cjs"),Jt=require("./use-in-view-sQJZ_xDO.cjs"),f=require("./proxy-BHRoeZgd.cjs"),Kt=require("./GraphFooter.cjs"),Qt=require("./GraphHeader.cjs"),Zt=require("./ColorLegend.cjs"),pt=require("./Colors.cjs"),_t=require("./generateRandomString-B5zBiJzS.cjs"),te=require("./EmptyState-d8_8SxeW.cjs");function ee(dt){const{data:V,width:O,height:G,lineColors:j,suffix:D,prefix:w,dateFormat:o,showValues:l,noOfXTicks:z,rightMargin:yt,leftMargin:R,topMargin:gt,bottomMargin:J,tooltip:H,highlightAreaSettings:N,onSeriesMouseOver:W,animate:n,rtl:K,showColorLegendAtTop:ft,colorDomain:M,diffAreaColors:Q,idSuffix:E,strokeWidth:Z,showDots:_,refValues:Y,minValue:k,maxValue:X,annotations:L,customHighlightAreaSettings:F,yAxisTitle:U,noOfYTicks:tt,minDate:et,maxDate:it,curveType:P,styles:h,classNames:p,precision:S,customLayers:nt}=dt,at=d.useRef(null),r=Jt.useInView(at,{once:n.once,amount:n.amount}),[c,jt]=d.useState(!1);d.useEffect(()=>{if(r&&!c){const t=setTimeout(()=>{jt(!0)},(n.duration+.5)*1e3);return()=>clearTimeout(t)}},[r,c,n.duration]);const $=P==="linear"?At.curveLinear:P==="step"?ht.curveStep:P==="stepAfter"?ht.stepAfter:P==="stepBefore"?ht.stepBefore:ht.monotoneX,[q,st]=d.useState(void 0),[ot,rt]=d.useState(void 0),[b,A]=d.useState(void 0),y={top:gt,bottom:J,left:U?R+30:R,right:yt},lt=d.useRef(null),i=qt.sortBy(V.map(t=>({...t,date:m.parse(`${t.date}`,o,new Date)})),"date"),ct=N.map(t=>({...t,coordinates:[t.coordinates[0]===null?null:m.parse(`${t.coordinates[0]}`,o,new Date),t.coordinates[1]===null?null:m.parse(`${t.coordinates[1]}`,o,new Date)]})),xt=F.map(t=>({...t,coordinates:t.coordinates.map((v,I)=>I%2===0?m.parse(`${v}`,o,new Date):v)})),x=O-y.left-y.right,g=G-y.top-y.bottom,ut=et?m.parse(`${et}`,o,new Date):i[0].date,u=it?m.parse(`${it}`,o,new Date):i[i.length-1].date,B=Math.min(...i.map(t=>t.y1))!==1/0?Math.min(...i.map(t=>t.y1))>0?0:Math.min(...i.map(t=>t.y1)):0,Ot=Math.min(...i.map(t=>t.y2))!==1/0?Math.min(...i.map(t=>t.y2))>0?0:Math.min(...i.map(t=>t.y2)):0,Nt=Math.max(...i.map(t=>t.y1))!==1/0?Math.max(...i.map(t=>t.y1)):0,It=Math.max(...i.map(t=>t.y2))!==1/0?Math.max(...i.map(t=>t.y2)):0,C=T.checkIfNullOrUndefined(k)?B<Ot?B:Ot:k,wt=Nt>It?Nt:It,a=Yt.time().domain([ut,u]).range([0,x]),s=Xt.linear().domain([T.checkIfNullOrUndefined(k)?C:k,T.checkIfNullOrUndefined(X)?wt>0?wt:0:X]).range([g,0]).nice(),vt=At.line().x(t=>a(t.date)).y(t=>s(t.y1)).curve($),Vt=At.line().x(t=>a(t.date)).y(t=>s(t.y2)).curve($),Dt=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(t=>s(t.y2)).curve($),St=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(0).curve($),$t=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y2)).y0(0).curve($),kt=s.ticks(tt),Lt=a.ticks(z);return d.useEffect(()=>{const t=I=>{const mt=i[Bt.bisectCenter(i.map(Rt=>Rt.date),a.invert(zt.pointer(I)[0]),0)];st(mt||i[i.length-1]),W?.(mt||i[i.length-1]),A(I.clientY),rt(I.clientX)},v=()=>{st(void 0),rt(void 0),A(void 0),W?.(void 0)};Ut.select(lt.current).on("mousemove",t).on("mouseout",v)},[a,i,W]),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.svg,{width:`${O}px`,height:`${G}px`,viewBox:`0 0 ${O} ${G}`,direction:"ltr",ref:at,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${y.left},${y.top})`,children:[e.jsxRuntimeExports.jsx("clipPath",{id:`above${E}`,children:e.jsxRuntimeExports.jsx("path",{d:$t(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx("clipPath",{id:`below${E}`,children:e.jsxRuntimeExports.jsx("path",{d:St(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx(Wt.HighlightArea,{areaSettings:ct,width:x,height:g,scale:a,animate:n,isInView:r}),e.jsxRuntimeExports.jsx(bt.CustomArea,{areaSettings:xt,scaleX:a,scaleY:s,animate:n,isInView:r}),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(Ht.YTicksAndGridLines,{values:kt.filter(t=>t!==0),y:kt.filter(t=>t!==0).map(t=>s(t)),x1:0-R,x2:x+y.right,styles:{gridLines:h?.yAxis?.gridLines,labels:h?.yAxis?.labels},classNames:{gridLines:p?.yAxis?.gridLines,labels:p?.yAxis?.labels},suffix:D,prefix:w,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:S}),e.jsxRuntimeExports.jsx(Ft.Axis,{y1:s(C<0?0:C),y2:s(C<0?0:C),x1:0-R,x2:x+y.right,label:Et.numberFormattingFunction(C<0?0:C,"NA",S,w,D),labelPos:{x:0-R,y:s(C<0?0:C),dx:0,dy:wt<0?"1rem":-5},classNames:{axis:p?.xAxis?.axis,label:p?.yAxis?.labels},styles:{axis:h?.xAxis?.axis,label:h?.yAxis?.labels}}),e.jsxRuntimeExports.jsx(Mt.AxisTitle,{x:0-R-15,y:g/2,style:h?.yAxis?.title,className:p?.yAxis?.title,text:U,rotate90:!0})]})}),e.jsxRuntimeExports.jsx(Pt.XTicksAndGridLines,{values:Lt.map(t=>m.format(t,o)),x:Lt.map(t=>a(t)),y1:0,y2:g,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:e.mo("opacity-0",p?.xAxis?.gridLines),labels:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs",p?.xAxis?.labels)},suffix:D,prefix:w,labelType:"primary",showGridLines:!0,precision:S}),nt.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.path,{clipPath:`url(#below${E})`,d:Dt(i)||"",style:{fill:Q[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:1},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{clipPath:`url(#above${E})`,d:Dt(i)||"",style:{fill:Q[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.path,{d:vt(i)||"",style:{fill:"none",stroke:j[0],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:vt(i)||"",opacity:1},whileInView:{pathLength:1,d:vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{style:{fill:"none",stroke:j[1],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:Vt(i)||"",opacity:1},whileInView:{pathLength:1,d:Vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),ft?null:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.text,{style:{fill:j[0]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y1)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[0]},M[0]),e.jsxRuntimeExports.jsx(f.motion.text,{style:{fill:j[1]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y2)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[1]},M[1])]}),q?e.jsxRuntimeExports.jsx("line",{y1:0,y2:g,x1:a(q.date),x2:a(q.date),className:e.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",p?.mouseOverLine),style:h?.mouseOverLine}):null,i.map((t,v)=>e.jsxRuntimeExports.jsxs(f.motion.g,{children:[T.checkIfNullOrUndefined(t.y1)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(f.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:j[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y1)},whileInView:{opacity:1,transition:{duration:.5,delay:n.duration},cx:a(t.date),cy:s(t.y1)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(f.motion.text,{dy:t.y2<t.y1?-8:"1em",style:{fill:j[0],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-1 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y1)},whileInView:{opacity:1,x:a(t.date),y:s(t.y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y1,"NA",S,w,D)}):null]}),T.checkIfNullOrUndefined(t.y2)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(f.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:j[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y2)},whileInView:{opacity:1,transition:{duration:c?n.duration:.5,delay:c?0:n.duration},cx:a(t.date),cy:s(t.y2)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(f.motion.text,{dy:t.y2>t.y1?-8:"1em",style:{fill:j[1],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-2 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y2)},whileInView:{opacity:1,x:a(t.date),y:s(t.y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y2,"NA",S,w,D)}):null]})]},v))]}),Y?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Y.map((t,v)=>e.jsxRuntimeExports.jsx(Gt.RefLineY,{text:t.text,color:t.color,y:s(t.value),x1:0-R,x2:x+y.right,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v))}):null,e.jsxRuntimeExports.jsx("g",{children:L.map((t,v)=>{const I=bt.getLineEndPoint({x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8},{x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,y:t.yCoordinate?s(t.yCoordinate):0},T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius),mt=t.showConnector?{y1:I.y,x1:I.x,y2:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0):0+(t.yOffset||0),x2:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),cy:t.yCoordinate?s(t.yCoordinate):0,cx:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,circleRadius:T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius,strokeWidth:t.showConnector===!0?2:Math.min(t.showConnector||0,1)}:void 0,Rt={y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8,x:K?0:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),width:K?t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0):x+y.right-(t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0)),maxWidth:t.maxWidth,fontWeight:t.fontWeight,align:t.align};return e.jsxRuntimeExports.jsx(bt.Annotation,{color:t.color,connectorsSettings:mt,labelSettings:Rt,text:t.text,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v)})}),nt.filter(t=>t.position==="after").map(t=>t.layer),e.jsxRuntimeExports.jsx("rect",{ref:lt,style:{fill:"none",pointerEvents:"all"},width:x,height:g})]})}),q&&H&&ot&&b?e.jsxRuntimeExports.jsx(Tt.Tooltip,{data:q,body:H,xPos:ot,yPos:b,backgroundStyle:h?.tooltip,className:p?.tooltip}):null]})}function ie(dt){const{data:V,graphTitle:O,suffix:G="",sources:j,prefix:D="",graphDescription:w,height:o,width:l,footNote:z,noOfXTicks:yt=10,dateFormat:R="yyyy",showValues:gt=!1,padding:J,lineColors:H=[pt.Colors.light.categoricalColors.colors[0],pt.Colors.light.categoricalColors.colors[1]],backgroundColor:N=!1,leftMargin:W=30,rightMargin:n=50,topMargin:K=20,bottomMargin:ft=25,tooltip:M,highlightAreaSettings:Q=[],relativeHeight:E,onSeriesMouseOver:Z,graphID:_,graphDownload:Y=!1,dataDownload:k=!1,animate:X=!1,language:L="en",minHeight:F=0,labels:U,showColorLegendAtTop:tt=!1,colorLegendTitle:et,diffAreaColors:it=[pt.Colors.alerts.red,pt.Colors.alerts.darkGreen],strokeWidth:P=2,showDots:h=!0,refValues:p=[],minValue:S,maxValue:nt,annotations:at=[],customHighlightAreaSettings:r=[],theme:c="light",ariaLabel:jt,yAxisTitle:$,noOfYTicks:q=5,minDate:st,maxDate:ot,curveType:rt="curve",styles:b,classNames:A,precision:y=2,customLayers:lt=[]}=dt,[i,ct]=d.useState(0),[xt,x]=d.useState(0),g=d.useRef(null),ut=d.useRef(null);return d.useEffect(()=>{const u=new ResizeObserver(B=>{ct(l||B[0].target.clientWidth||620),x(o||B[0].target.clientHeight||480)});return g.current&&(x(g.current.clientHeight||480),ct(g.current.clientWidth||620),l||u.observe(g.current)),()=>u.disconnect()},[l,o]),e.jsxRuntimeExports.jsx("div",{className:`${c||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:L==="he"||L==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${N?N===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${L||"en"}`,l?"w-fit":"w-full",A?.graphContainer),style:{...b?.graphContainer||{},...N&&N!==!0?{backgroundColor:N}:{}},id:_,ref:ut,"aria-label":jt||`${O?`The graph shows ${O}. `:""}This is a line chart that highlights the difference between two datasets over time.${w?` ${w}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:N?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[O||w||Y||k?e.jsxRuntimeExports.jsx(Qt.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:A?.title,description:A?.description},graphTitle:O,graphDescription:w,width:l,graphDownload:Y?ut.current:void 0,dataDownload:k?V.map(u=>u.data).filter(u=>u!==void 0).length>0?V.map(u=>u.data).filter(u=>u!==void 0):V.filter(u=>u!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:V.length===0?e.jsxRuntimeExports.jsx(te.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[tt?e.jsxRuntimeExports.jsx(Zt.ColorLegend,{colorDomain:U,colorLegendTitle:et,colors:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:g,"aria-label":"Graph area",children:(l||i)&&(o||xt)?e.jsxRuntimeExports.jsx(ee,{data:V,lineColors:H,colorDomain:U,width:l||i,height:Math.max(F,o||(E?F?(l||i)*E>F?(l||i)*E:F:(l||i)*E:xt)),suffix:G,prefix:D,dateFormat:R,showValues:gt,noOfXTicks:yt,leftMargin:W,rightMargin:n,topMargin:K,bottomMargin:ft,highlightAreaSettings:Q,tooltip:M,onSeriesMouseOver:Z,showColorLegendAtTop:tt,animate:X===!0?{duration:.5,once:!0,amount:.5}:X||{duration:0,once:!0,amount:0},rtl:L==="he"||L==="ar",diffAreaColors:it,idSuffix:_t.generateRandomString(8),strokeWidth:P,showDots:h,refValues:p,minValue:S,maxValue:nt,annotations:at,customHighlightAreaSettings:r,yAxisTitle:$,noOfYTicks:q,minDate:st,maxDate:ot,curveType:rt,styles:b,classNames:A,precision:y,customLayers:lt}):null})]})}),j||z?e.jsxRuntimeExports.jsx(Kt.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:j,footNote:z,width:l}):null]})})})})}exports.DifferenceLineChart=ie;
|
|
2
2
|
//# sourceMappingURL=DifferenceLineChart.cjs.map
|
|
@@ -11,7 +11,7 @@ import { A as Et } from "./Axis-Ddg-seDi.js";
|
|
|
11
11
|
import { X as Bt } from "./XTicksAndGridLines-Bn9u5gOM.js";
|
|
12
12
|
import { R as zt } from "./ReferenceLine-CfAW3vKJ.js";
|
|
13
13
|
import { Y as Ut } from "./YTicksAndGridLines-B6ah7CRf.js";
|
|
14
|
-
import { H as qt } from "./index-
|
|
14
|
+
import { H as qt } from "./index-DKCxu1Gh.js";
|
|
15
15
|
import { t as Jt } from "./time-BzJP5SPC.js";
|
|
16
16
|
import { a as Kt } from "./linear-DUdu7l2G.js";
|
|
17
17
|
import { l as Mt, c as Qt } from "./line-CPfhohvF.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),h=require("react"),F=require("./parse-hMnG_lRV.cjs"),Ne=require("./index-BzeLQvXk.cjs"),ae=require("./numberFormattingFunction-02t-wJta.cjs"),Ie=require("./Tooltip-n8z5bfav.cjs"),f=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Oe=require("./XTicksAndGridLines-CCzXIV8d.cjs"),ye=require("./Axis-DE7dSn1_.cjs"),we=require("./AxisTitle-CK9YeovX.cjs"),Le=require("./index-DNj994Pv.cjs"),qe=require("./time-Byw_jYQ7.cjs"),Ee=require("./linear-BVckp9RD.cjs"),ge=require("./line-DHV4JwCR.cjs"),oe=require("./step-BZ3C8QFW.cjs"),De=require("./select-Bnfk0lJx.cjs"),Se=require("./init-DU0ybBc_.cjs"),Me=require("./pointer-Dkq5NV1q.cjs"),Te=require("./use-in-view-sQJZ_xDO.cjs"),b=require("./proxy-BHRoeZgd.cjs"),Ve=require("./GraphFooter.cjs"),$e=require("./GraphHeader.cjs"),Fe=require("./ColorLegend.cjs"),Re=require("./Colors.cjs"),Ce=require("./EmptyState-d8_8SxeW.cjs");function Pe(le){const{data:k,width:R,height:D,lineColors:n,labels:y,sameAxes:o,dateFormat:j,showValues:G,noOfXTicks:xe,rightMargin:ce,leftMargin:W,topMargin:X,bottomMargin:ue,tooltip:v,highlightAreaSettings:me,onSeriesMouseOver:C,animate:s,strokeWidth:Y,showDots:P,noOfYTicks:B,lineSuffixes:S,linePrefixes:M,minDate:z,maxDate:N,curveType:T,styles:l,classNames:r,precision:A,customLayers:H,showAxisLabels:J}=le,K=h.useRef(null),d=Te.useInView(K,{once:s.once,amount:s.amount}),[p,V]=h.useState(!1);h.useEffect(()=>{if(d&&!p){const e=setTimeout(()=>{V(!0)},(s.duration+.5)*1e3);return()=>clearTimeout(e)}},[d,p,s.duration]);const Q=T==="linear"?ge.curveLinear:T==="step"?oe.curveStep:T==="stepAfter"?oe.stepAfter:T==="stepBefore"?oe.stepBefore:oe.monotoneX,[I,Z]=h.useState(void 0),[_,ee]=h.useState(void 0),[te,ie]=h.useState(void 0),m={top:X,bottom:ue,left:W+50,right:ce+65},w=h.useRef(null),i=Ne.sortBy(k.map(e=>({...e,date:F.parse(`${e.date}`,j,new Date)})),"date"),de=me.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:F.parse(`${e.coordinates[0]}`,j,new Date),e.coordinates[1]===null?null:F.parse(`${e.coordinates[1]}`,j,new Date)]})),u=R-m.left-m.right,a=D-m.top-m.bottom,se=z?F.parse(`${z}`,j,new Date):i[0].date,ne=N?F.parse(`${N}`,j,new Date):i[i.length-1].date,$=Math.min(...i.map(e=>e.y1).filter(e=>e!=null))!==1/0?Math.min(...i.map(e=>e.y2).filter(e=>e!=null))>0?0:Math.min(...i.map(e=>e.y1).filter(e=>e!=null)):0,E=Math.min(...i.map(e=>e.y2).filter(e=>e!=null))!==1/0?Math.min(...i.map(e=>e.y2).filter(e=>e!=null))>0?0:Math.min(...i.map(e=>e.y2).filter(e=>e!=null)):0,O=Math.max(...i.map(e=>e.y1).filter(e=>e!=null))!==1/0?Math.max(...i.map(e=>e.y1).filter(e=>e!=null)):0,x=Math.max(...i.map(e=>e.y2).filter(e=>e!=null))!==1/0?Math.max(...i.map(e=>e.y2).filter(e=>e!=null)):0,U=$<E?$:E,re=O>x?O:x,c=qe.time().domain([se,ne]).range([0,u]),L=Ee.linear().domain([o?U:$,o?re>0?re:0:O>0?O:0]).range([a,0]).nice(),g=Ee.linear().domain([o?U:E,o?re>0?re:0:x>0?x:0]).range([a,0]).nice(),fe=ge.line().defined(e=>!f.checkIfNullOrUndefined(e.y1)).x(e=>c(e.date)).y(e=>L(e.y1)).curve(Q),he=ge.line().defined(e=>!f.checkIfNullOrUndefined(e.y2)).x(e=>c(e.date)).y(e=>g(e.y2)).curve(Q),Ae=L.ticks(B),be=g.ticks(B),je=c.ticks(xe);return h.useEffect(()=>{const e=pe=>{const ve=i[Se.bisectCenter(i.map(ke=>ke.date),c.invert(Me.pointer(pe)[0]),0)];Z(ve||i[i.length-1]),C?.(ve||i[i.length-1]),ie(pe.clientY),ee(pe.clientX)},q=()=>{Z(void 0),ee(void 0),ie(void 0),C?.(void 0)};De.select(w.current).on("mousemove",e).on("mouseout",q)},[c,i,C]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(b.motion.svg,{width:`${R}px`,height:`${D}px`,viewBox:`0 0 ${R} ${D}`,direction:"ltr",ref:K,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${m.left},${m.top})`,children:[t.jsxRuntimeExports.jsx(Le.HighlightArea,{areaSettings:de,width:u,height:a,scale:c,animate:s,isInView:d}),t.jsxRuntimeExports.jsxs("g",{children:[Ae.map((e,q)=>t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx("line",{y1:L(e),y2:L(e),x1:-15,x2:-20,style:{stroke:n[0],strokeWidth:1,...l?.yAxis?.gridLines||{}},className:r?.yAxis?.gridLines}),t.jsxRuntimeExports.jsx("text",{x:-25,y:L(e),dy:"0.33em",className:t.mo("text-xs",r?.yAxis?.labels),style:{textAnchor:"end",fill:n[0],...l?.yAxis?.labels||{}},children:ae.numberFormattingFunction(e,"NA",A,M[0],S[0])})]},q)),t.jsxRuntimeExports.jsx(ye.Axis,{y1:0,y2:a,x1:-15,x2:-15,classNames:{axis:r?.xAxis?.axis},styles:{axis:{stroke:n[0],...l?.xAxis?.axis||{}}}}),J?t.jsxRuntimeExports.jsx(we.AxisTitle,{x:10-m.left,y:a/2,style:{fill:n[0],...l?.yAxis?.title||{}},className:r?.yAxis?.title,text:y[0].length>100?`${y[0].substring(0,100)}...`:y[0],rotate90:!0}):null]}),t.jsxRuntimeExports.jsxs("g",{children:[be.map((e,q)=>t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx("line",{y1:g(e),y2:g(e),x1:u+15,x2:u+20,style:{stroke:n[1],strokeWidth:1,...l?.yAxis?.gridLines||{}},className:r?.yAxis?.gridLines}),t.jsxRuntimeExports.jsx("text",{x:u+25,y:g(e),dy:"0.33em",dx:-2,style:{textAnchor:"start",fill:n[1],...l?.yAxis?.labels||{}},className:t.mo("text-xs",r?.yAxis?.labels),children:ae.numberFormattingFunction(e,"NA",A,M[1],S[1])})]},q)),t.jsxRuntimeExports.jsx(ye.Axis,{y1:0,y2:a,x1:u+15,x2:u+15,classNames:{axis:r?.xAxis?.axis},styles:{axis:{stroke:n[1],...l?.xAxis?.axis||{}}}}),J?t.jsxRuntimeExports.jsx(we.AxisTitle,{x:u+m.right-15,y:a/2,style:{fill:n[1],...l?.yAxis?.title||{}},className:r?.yAxis?.title,text:y[1].length>100?`${y[1].substring(0,100)}...`:y[1],rotate90:!0}):null]}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(ye.Axis,{y1:a,y2:a,x1:-15,x2:u+15,classNames:{axis:r?.xAxis?.axis},styles:{axis:l?.xAxis?.axis}}),t.jsxRuntimeExports.jsx(Oe.XTicksAndGridLines,{values:je.map(e=>F.format(e,j)),x:je.map(e=>c(e)),y1:0,y2:a,styles:{gridLines:l?.xAxis?.gridLines,labels:l?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",r?.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",r?.xAxis?.labels)},labelType:"primary",showGridLines:!0,precision:A})]}),H.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(b.motion.path,{style:{stroke:n[0],strokeWidth:Y,fill:"none"},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{pathLength:0,d:fe(i.filter(e=>!f.checkIfNullOrUndefined(e.y1)))||"",opacity:1},whileInView:{pathLength:1,d:fe(i.filter(e=>!f.checkIfNullOrUndefined(e.y1)))||"",opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:d?"whileInView":"initial"}),t.jsxRuntimeExports.jsx(b.motion.path,{d:he(i.filter(e=>!f.checkIfNullOrUndefined(e.y2)))||"",style:{stroke:n[1],strokeWidth:Y,fill:"none"},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{pathLength:0,d:he(i.filter(e=>!f.checkIfNullOrUndefined(e.y2)))||"",opacity:1},whileInView:{pathLength:1,d:he(i.filter(e=>!f.checkIfNullOrUndefined(e.y2)))||"",opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:d?"whileInView":"initial"}),I?t.jsxRuntimeExports.jsx("line",{y1:0,y2:a,x1:c(I.date),x2:c(I.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",r?.mouseOverLine),style:l?.mouseOverLine}):null]}),t.jsxRuntimeExports.jsx("g",{children:i.map((e,q)=>t.jsxRuntimeExports.jsxs(b.motion.g,{children:[f.checkIfNullOrUndefined(e.y1)?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[P?t.jsxRuntimeExports.jsx(b.motion.circle,{r:u/i.length<5?0:u/i.length<20?2:4,style:{fill:n[0]},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,cx:c(e.date),cy:L(e.y1)},whileInView:{opacity:1,transition:{duration:p?s.duration:.5,delay:p?0:s.duration},cx:c(e.date),cy:L(e.y1)}},initial:"initial",animate:d?"whileInView":"initial"}):null,G?t.jsxRuntimeExports.jsx(b.motion.text,{dy:f.checkIfNullOrUndefined(e.y2)||e.y2<e.y1?-8:"1em",style:{fill:n[0],textAnchor:"middle",...l?.graphObjectValues||{}},className:t.mo("graph-value graph-value-line-1 text-xs font-bold",r?.graphObjectValues),exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,x:c(e.date),y:g(e.y1)},whileInView:{opacity:1,x:c(e.date),y:g(e.y1),transition:{duration:p?s.duration:.5,delay:p?0:s.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:ae.numberFormattingFunction(e.y1,"NA",A,M[0],S[0])}):null]}),f.checkIfNullOrUndefined(e.y2)?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[P?t.jsxRuntimeExports.jsx(b.motion.circle,{r:u/i.length<5?0:u/i.length<20?2:4,style:{fill:n[1]},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,cx:c(e.date),cy:g(e.y2)},whileInView:{opacity:1,transition:{duration:p?s.duration:.5,delay:p?0:s.duration},cx:c(e.date),cy:g(e.y2)}},initial:"initial",animate:d?"whileInView":"initial"}):null,G?t.jsxRuntimeExports.jsx(b.motion.text,{dy:f.checkIfNullOrUndefined(e.y1)||e.y1<e.y2?-8:"1em",style:{fill:n[1],textAnchor:"middle",...l?.graphObjectValues||{}},className:t.mo("graph-value graph-value-line-2 text-xs font-bold",r?.graphObjectValues),exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,x:c(e.date),y:g(e.y2)},whileInView:{opacity:1,x:c(e.date),y:g(e.y2),transition:{duration:p?s.duration:.5,delay:p?0:s.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:ae.numberFormattingFunction(e.y2,"NA",A,M[1],S[1])}):null]})]},q))}),H.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:w,style:{fill:"none",pointerEvents:"all"},width:u,height:a})]})}),I&&v&&_&&te?t.jsxRuntimeExports.jsx(Ie.Tooltip,{data:I,body:v,xPos:_,yPos:te,backgroundStyle:l?.tooltip,className:r?.tooltip}):null]})}function He(le){const{data:k,graphTitle:R,sources:D,graphDescription:n,height:y,width:o,footNote:j,noOfXTicks:G=10,dateFormat:xe="yyyy",showValues:ce=!1,padding:W,lineColors:X=[Re.Colors.light.categoricalColors.colors[0],Re.Colors.light.categoricalColors.colors[1]],sameAxes:ue=!1,backgroundColor:v=!1,leftMargin:me=80,rightMargin:C=80,topMargin:s=20,bottomMargin:Y=25,labels:P,lineSuffixes:B=["",""],linePrefixes:S=["",""],tooltip:M,highlightAreaSettings:z=[],relativeHeight:N,onSeriesMouseOver:T,graphID:l,graphDownload:r=!1,dataDownload:A=!1,animate:H=!1,strokeWidth:J=2,showDots:K=!0,language:d="en",showColorScale:p=!0,minHeight:V=0,colorLegendTitle:Q,theme:I="light",ariaLabel:Z,noOfYTicks:_=5,maxDate:ee,minDate:te,curveType:ie="curve",styles:m,classNames:w,precision:i=2,customLayers:de=[],showAxisLabels:u=!0}=le,[a,se]=h.useState(0),[ne,$]=h.useState(0),E=h.useRef(null),O=h.useRef(null);return h.useEffect(()=>{const x=new ResizeObserver(U=>{se(o||U[0].target.clientWidth||620),$(y||U[0].target.clientHeight||480)});return E.current&&($(E.current.clientHeight||480),se(E.current.clientWidth||620),o||x.observe(E.current)),()=>x.disconnect()},[o,y]),t.jsxRuntimeExports.jsx("div",{className:`${I||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:d==="he"||d==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${v?v===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${d||"en"}`,o?"w-fit":"w-full",w?.graphContainer),style:{...m?.graphContainer||{},...v&&v!==!0?{backgroundColor:v}:{}},id:l,ref:O,"aria-label":Z||`${R?`The graph shows ${R}. `:""}This is a line chart that show trends for two datasets over time.${n?` ${n}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:v?W||"1rem":W||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||n||r||A?t.jsxRuntimeExports.jsx($e.GraphHeader,{styles:{title:m?.title,description:m?.description},classNames:{title:w?.title,description:w?.description},graphTitle:R,graphDescription:n,width:o,graphDownload:r?O.current:void 0,dataDownload:A?k.map(x=>x.data).filter(x=>x!==void 0).length>0?k.map(x=>x.data).filter(x=>x!==void 0):k.filter(x=>x!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:k.length===0?t.jsxRuntimeExports.jsx(Ce.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[p?t.jsxRuntimeExports.jsx(Fe.ColorLegend,{colorDomain:P,colorLegendTitle:Q,colors:X,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:E,"aria-label":"Graph area",children:(o||a)&&(y||ne)?t.jsxRuntimeExports.jsx(Pe,{data:k,sameAxes:ue,lineColors:X,width:o||a,height:Math.max(V,y||(N?V?(o||a)*N>V?(o||a)*N:V:(o||a)*N:ne)),dateFormat:xe,showValues:ce,noOfXTicks:G,leftMargin:me,rightMargin:C,topMargin:s,bottomMargin:Y,labels:P,highlightAreaSettings:z,tooltip:M,onSeriesMouseOver:T,animate:H===!0?{duration:.5,once:!0,amount:.5}:H||{duration:0,once:!0,amount:0},strokeWidth:J,showDots:K,noOfYTicks:_,lineSuffixes:B,linePrefixes:S,minDate:te,maxDate:ee,curveType:ie,styles:m,classNames:w,precision:i,customLayers:de,showAxisLabels:u}):null})]})}),D||j?t.jsxRuntimeExports.jsx(Ve.GraphFooter,{styles:{footnote:m?.footnote,source:m?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:D,footNote:j,width:o}):null]})})})})}exports.DualAxisLineChart=He;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),h=require("react"),F=require("./parse-hMnG_lRV.cjs"),Ne=require("./index-BzeLQvXk.cjs"),ae=require("./numberFormattingFunction-02t-wJta.cjs"),Ie=require("./Tooltip-n8z5bfav.cjs"),f=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Oe=require("./XTicksAndGridLines-CCzXIV8d.cjs"),ye=require("./Axis-DE7dSn1_.cjs"),we=require("./AxisTitle-CK9YeovX.cjs"),Le=require("./index-BYzIB5V6.cjs"),qe=require("./time-Byw_jYQ7.cjs"),Ee=require("./linear-BVckp9RD.cjs"),ge=require("./line-DHV4JwCR.cjs"),oe=require("./step-BZ3C8QFW.cjs"),De=require("./select-Bnfk0lJx.cjs"),Se=require("./init-DU0ybBc_.cjs"),Me=require("./pointer-Dkq5NV1q.cjs"),Te=require("./use-in-view-sQJZ_xDO.cjs"),b=require("./proxy-BHRoeZgd.cjs"),Ve=require("./GraphFooter.cjs"),$e=require("./GraphHeader.cjs"),Fe=require("./ColorLegend.cjs"),Re=require("./Colors.cjs"),Ce=require("./EmptyState-d8_8SxeW.cjs");function Pe(le){const{data:k,width:R,height:D,lineColors:n,labels:y,sameAxes:o,dateFormat:j,showValues:G,noOfXTicks:xe,rightMargin:ce,leftMargin:W,topMargin:X,bottomMargin:ue,tooltip:v,highlightAreaSettings:me,onSeriesMouseOver:C,animate:s,strokeWidth:Y,showDots:P,noOfYTicks:B,lineSuffixes:S,linePrefixes:M,minDate:z,maxDate:N,curveType:T,styles:l,classNames:r,precision:A,customLayers:H,showAxisLabels:J}=le,K=h.useRef(null),d=Te.useInView(K,{once:s.once,amount:s.amount}),[p,V]=h.useState(!1);h.useEffect(()=>{if(d&&!p){const e=setTimeout(()=>{V(!0)},(s.duration+.5)*1e3);return()=>clearTimeout(e)}},[d,p,s.duration]);const Q=T==="linear"?ge.curveLinear:T==="step"?oe.curveStep:T==="stepAfter"?oe.stepAfter:T==="stepBefore"?oe.stepBefore:oe.monotoneX,[I,Z]=h.useState(void 0),[_,ee]=h.useState(void 0),[te,ie]=h.useState(void 0),m={top:X,bottom:ue,left:W+50,right:ce+65},w=h.useRef(null),i=Ne.sortBy(k.map(e=>({...e,date:F.parse(`${e.date}`,j,new Date)})),"date"),de=me.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:F.parse(`${e.coordinates[0]}`,j,new Date),e.coordinates[1]===null?null:F.parse(`${e.coordinates[1]}`,j,new Date)]})),u=R-m.left-m.right,a=D-m.top-m.bottom,se=z?F.parse(`${z}`,j,new Date):i[0].date,ne=N?F.parse(`${N}`,j,new Date):i[i.length-1].date,$=Math.min(...i.map(e=>e.y1).filter(e=>e!=null))!==1/0?Math.min(...i.map(e=>e.y2).filter(e=>e!=null))>0?0:Math.min(...i.map(e=>e.y1).filter(e=>e!=null)):0,E=Math.min(...i.map(e=>e.y2).filter(e=>e!=null))!==1/0?Math.min(...i.map(e=>e.y2).filter(e=>e!=null))>0?0:Math.min(...i.map(e=>e.y2).filter(e=>e!=null)):0,O=Math.max(...i.map(e=>e.y1).filter(e=>e!=null))!==1/0?Math.max(...i.map(e=>e.y1).filter(e=>e!=null)):0,x=Math.max(...i.map(e=>e.y2).filter(e=>e!=null))!==1/0?Math.max(...i.map(e=>e.y2).filter(e=>e!=null)):0,U=$<E?$:E,re=O>x?O:x,c=qe.time().domain([se,ne]).range([0,u]),L=Ee.linear().domain([o?U:$,o?re>0?re:0:O>0?O:0]).range([a,0]).nice(),g=Ee.linear().domain([o?U:E,o?re>0?re:0:x>0?x:0]).range([a,0]).nice(),fe=ge.line().defined(e=>!f.checkIfNullOrUndefined(e.y1)).x(e=>c(e.date)).y(e=>L(e.y1)).curve(Q),he=ge.line().defined(e=>!f.checkIfNullOrUndefined(e.y2)).x(e=>c(e.date)).y(e=>g(e.y2)).curve(Q),Ae=L.ticks(B),be=g.ticks(B),je=c.ticks(xe);return h.useEffect(()=>{const e=pe=>{const ve=i[Se.bisectCenter(i.map(ke=>ke.date),c.invert(Me.pointer(pe)[0]),0)];Z(ve||i[i.length-1]),C?.(ve||i[i.length-1]),ie(pe.clientY),ee(pe.clientX)},q=()=>{Z(void 0),ee(void 0),ie(void 0),C?.(void 0)};De.select(w.current).on("mousemove",e).on("mouseout",q)},[c,i,C]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(b.motion.svg,{width:`${R}px`,height:`${D}px`,viewBox:`0 0 ${R} ${D}`,direction:"ltr",ref:K,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${m.left},${m.top})`,children:[t.jsxRuntimeExports.jsx(Le.HighlightArea,{areaSettings:de,width:u,height:a,scale:c,animate:s,isInView:d}),t.jsxRuntimeExports.jsxs("g",{children:[Ae.map((e,q)=>t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx("line",{y1:L(e),y2:L(e),x1:-15,x2:-20,style:{stroke:n[0],strokeWidth:1,...l?.yAxis?.gridLines||{}},className:r?.yAxis?.gridLines}),t.jsxRuntimeExports.jsx("text",{x:-25,y:L(e),dy:"0.33em",className:t.mo("text-xs",r?.yAxis?.labels),style:{textAnchor:"end",fill:n[0],...l?.yAxis?.labels||{}},children:ae.numberFormattingFunction(e,"NA",A,M[0],S[0])})]},q)),t.jsxRuntimeExports.jsx(ye.Axis,{y1:0,y2:a,x1:-15,x2:-15,classNames:{axis:r?.xAxis?.axis},styles:{axis:{stroke:n[0],...l?.xAxis?.axis||{}}}}),J?t.jsxRuntimeExports.jsx(we.AxisTitle,{x:10-m.left,y:a/2,style:{fill:n[0],...l?.yAxis?.title||{}},className:r?.yAxis?.title,text:y[0].length>100?`${y[0].substring(0,100)}...`:y[0],rotate90:!0}):null]}),t.jsxRuntimeExports.jsxs("g",{children:[be.map((e,q)=>t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx("line",{y1:g(e),y2:g(e),x1:u+15,x2:u+20,style:{stroke:n[1],strokeWidth:1,...l?.yAxis?.gridLines||{}},className:r?.yAxis?.gridLines}),t.jsxRuntimeExports.jsx("text",{x:u+25,y:g(e),dy:"0.33em",dx:-2,style:{textAnchor:"start",fill:n[1],...l?.yAxis?.labels||{}},className:t.mo("text-xs",r?.yAxis?.labels),children:ae.numberFormattingFunction(e,"NA",A,M[1],S[1])})]},q)),t.jsxRuntimeExports.jsx(ye.Axis,{y1:0,y2:a,x1:u+15,x2:u+15,classNames:{axis:r?.xAxis?.axis},styles:{axis:{stroke:n[1],...l?.xAxis?.axis||{}}}}),J?t.jsxRuntimeExports.jsx(we.AxisTitle,{x:u+m.right-15,y:a/2,style:{fill:n[1],...l?.yAxis?.title||{}},className:r?.yAxis?.title,text:y[1].length>100?`${y[1].substring(0,100)}...`:y[1],rotate90:!0}):null]}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(ye.Axis,{y1:a,y2:a,x1:-15,x2:u+15,classNames:{axis:r?.xAxis?.axis},styles:{axis:l?.xAxis?.axis}}),t.jsxRuntimeExports.jsx(Oe.XTicksAndGridLines,{values:je.map(e=>F.format(e,j)),x:je.map(e=>c(e)),y1:0,y2:a,styles:{gridLines:l?.xAxis?.gridLines,labels:l?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",r?.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",r?.xAxis?.labels)},labelType:"primary",showGridLines:!0,precision:A})]}),H.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(b.motion.path,{style:{stroke:n[0],strokeWidth:Y,fill:"none"},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{pathLength:0,d:fe(i.filter(e=>!f.checkIfNullOrUndefined(e.y1)))||"",opacity:1},whileInView:{pathLength:1,d:fe(i.filter(e=>!f.checkIfNullOrUndefined(e.y1)))||"",opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:d?"whileInView":"initial"}),t.jsxRuntimeExports.jsx(b.motion.path,{d:he(i.filter(e=>!f.checkIfNullOrUndefined(e.y2)))||"",style:{stroke:n[1],strokeWidth:Y,fill:"none"},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{pathLength:0,d:he(i.filter(e=>!f.checkIfNullOrUndefined(e.y2)))||"",opacity:1},whileInView:{pathLength:1,d:he(i.filter(e=>!f.checkIfNullOrUndefined(e.y2)))||"",opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:d?"whileInView":"initial"}),I?t.jsxRuntimeExports.jsx("line",{y1:0,y2:a,x1:c(I.date),x2:c(I.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",r?.mouseOverLine),style:l?.mouseOverLine}):null]}),t.jsxRuntimeExports.jsx("g",{children:i.map((e,q)=>t.jsxRuntimeExports.jsxs(b.motion.g,{children:[f.checkIfNullOrUndefined(e.y1)?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[P?t.jsxRuntimeExports.jsx(b.motion.circle,{r:u/i.length<5?0:u/i.length<20?2:4,style:{fill:n[0]},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,cx:c(e.date),cy:L(e.y1)},whileInView:{opacity:1,transition:{duration:p?s.duration:.5,delay:p?0:s.duration},cx:c(e.date),cy:L(e.y1)}},initial:"initial",animate:d?"whileInView":"initial"}):null,G?t.jsxRuntimeExports.jsx(b.motion.text,{dy:f.checkIfNullOrUndefined(e.y2)||e.y2<e.y1?-8:"1em",style:{fill:n[0],textAnchor:"middle",...l?.graphObjectValues||{}},className:t.mo("graph-value graph-value-line-1 text-xs font-bold",r?.graphObjectValues),exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,x:c(e.date),y:g(e.y1)},whileInView:{opacity:1,x:c(e.date),y:g(e.y1),transition:{duration:p?s.duration:.5,delay:p?0:s.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:ae.numberFormattingFunction(e.y1,"NA",A,M[0],S[0])}):null]}),f.checkIfNullOrUndefined(e.y2)?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[P?t.jsxRuntimeExports.jsx(b.motion.circle,{r:u/i.length<5?0:u/i.length<20?2:4,style:{fill:n[1]},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,cx:c(e.date),cy:g(e.y2)},whileInView:{opacity:1,transition:{duration:p?s.duration:.5,delay:p?0:s.duration},cx:c(e.date),cy:g(e.y2)}},initial:"initial",animate:d?"whileInView":"initial"}):null,G?t.jsxRuntimeExports.jsx(b.motion.text,{dy:f.checkIfNullOrUndefined(e.y1)||e.y1<e.y2?-8:"1em",style:{fill:n[1],textAnchor:"middle",...l?.graphObjectValues||{}},className:t.mo("graph-value graph-value-line-2 text-xs font-bold",r?.graphObjectValues),exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,x:c(e.date),y:g(e.y2)},whileInView:{opacity:1,x:c(e.date),y:g(e.y2),transition:{duration:p?s.duration:.5,delay:p?0:s.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:ae.numberFormattingFunction(e.y2,"NA",A,M[1],S[1])}):null]})]},q))}),H.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:w,style:{fill:"none",pointerEvents:"all"},width:u,height:a})]})}),I&&v&&_&&te?t.jsxRuntimeExports.jsx(Ie.Tooltip,{data:I,body:v,xPos:_,yPos:te,backgroundStyle:l?.tooltip,className:r?.tooltip}):null]})}function He(le){const{data:k,graphTitle:R,sources:D,graphDescription:n,height:y,width:o,footNote:j,noOfXTicks:G=10,dateFormat:xe="yyyy",showValues:ce=!1,padding:W,lineColors:X=[Re.Colors.light.categoricalColors.colors[0],Re.Colors.light.categoricalColors.colors[1]],sameAxes:ue=!1,backgroundColor:v=!1,leftMargin:me=80,rightMargin:C=80,topMargin:s=20,bottomMargin:Y=25,labels:P,lineSuffixes:B=["",""],linePrefixes:S=["",""],tooltip:M,highlightAreaSettings:z=[],relativeHeight:N,onSeriesMouseOver:T,graphID:l,graphDownload:r=!1,dataDownload:A=!1,animate:H=!1,strokeWidth:J=2,showDots:K=!0,language:d="en",showColorScale:p=!0,minHeight:V=0,colorLegendTitle:Q,theme:I="light",ariaLabel:Z,noOfYTicks:_=5,maxDate:ee,minDate:te,curveType:ie="curve",styles:m,classNames:w,precision:i=2,customLayers:de=[],showAxisLabels:u=!0}=le,[a,se]=h.useState(0),[ne,$]=h.useState(0),E=h.useRef(null),O=h.useRef(null);return h.useEffect(()=>{const x=new ResizeObserver(U=>{se(o||U[0].target.clientWidth||620),$(y||U[0].target.clientHeight||480)});return E.current&&($(E.current.clientHeight||480),se(E.current.clientWidth||620),o||x.observe(E.current)),()=>x.disconnect()},[o,y]),t.jsxRuntimeExports.jsx("div",{className:`${I||"light"} flex ${o?"w-fit grow-0":"w-full grow"}`,dir:d==="he"||d==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${v?v===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${d||"en"}`,o?"w-fit":"w-full",w?.graphContainer),style:{...m?.graphContainer||{},...v&&v!==!0?{backgroundColor:v}:{}},id:l,ref:O,"aria-label":Z||`${R?`The graph shows ${R}. `:""}This is a line chart that show trends for two datasets over time.${n?` ${n}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:v?W||"1rem":W||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[R||n||r||A?t.jsxRuntimeExports.jsx($e.GraphHeader,{styles:{title:m?.title,description:m?.description},classNames:{title:w?.title,description:w?.description},graphTitle:R,graphDescription:n,width:o,graphDownload:r?O.current:void 0,dataDownload:A?k.map(x=>x.data).filter(x=>x!==void 0).length>0?k.map(x=>x.data).filter(x=>x!==void 0):k.filter(x=>x!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:k.length===0?t.jsxRuntimeExports.jsx(Ce.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[p?t.jsxRuntimeExports.jsx(Fe.ColorLegend,{colorDomain:P,colorLegendTitle:Q,colors:X,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:E,"aria-label":"Graph area",children:(o||a)&&(y||ne)?t.jsxRuntimeExports.jsx(Pe,{data:k,sameAxes:ue,lineColors:X,width:o||a,height:Math.max(V,y||(N?V?(o||a)*N>V?(o||a)*N:V:(o||a)*N:ne)),dateFormat:xe,showValues:ce,noOfXTicks:G,leftMargin:me,rightMargin:C,topMargin:s,bottomMargin:Y,labels:P,highlightAreaSettings:z,tooltip:M,onSeriesMouseOver:T,animate:H===!0?{duration:.5,once:!0,amount:.5}:H||{duration:0,once:!0,amount:0},strokeWidth:J,showDots:K,noOfYTicks:_,lineSuffixes:B,linePrefixes:S,minDate:te,maxDate:ee,curveType:ie,styles:m,classNames:w,precision:i,customLayers:de,showAxisLabels:u}):null})]})}),D||j?t.jsxRuntimeExports.jsx(Ve.GraphFooter,{styles:{footnote:m?.footnote,source:m?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:D,footNote:j,width:o}):null]})})})})}exports.DualAxisLineChart=He;
|
|
2
2
|
//# sourceMappingURL=DualAxisLineChart.cjs.map
|
|
@@ -8,7 +8,7 @@ import { c as g } from "./checkIfNullOrUndefined-DmfiKkNw.js";
|
|
|
8
8
|
import { X as Vt } from "./XTicksAndGridLines-Bn9u5gOM.js";
|
|
9
9
|
import { A as gt } from "./Axis-Ddg-seDi.js";
|
|
10
10
|
import { A as At } from "./AxisTitle-BmHLMRJZ.js";
|
|
11
|
-
import { H as Ot } from "./index-
|
|
11
|
+
import { H as Ot } from "./index-DKCxu1Gh.js";
|
|
12
12
|
import { t as St } from "./time-BzJP5SPC.js";
|
|
13
13
|
import { a as bt } from "./linear-DUdu7l2G.js";
|
|
14
14
|
import { l as Nt, c as Ct } from "./line-CPfhohvF.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),p=require("react"),y=require("./parse-hMnG_lRV.cjs"),qt=require("./index-BzeLQvXk.cjs"),kt=require("./simple-statistics-xm8c0LQQ.cjs"),ot=require("./numberFormattingFunction-02t-wJta.cjs"),$t=require("./Tooltip-n8z5bfav.cjs"),v=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),bt=require("./customArea-CK768gCn.cjs"),Ft=require("./AxisTitle-CK9YeovX.cjs"),Tt=require("./Axis-DE7dSn1_.cjs"),Wt=require("./ReferenceLine-CFVBBN__.cjs"),Ht=require("./RegressionLine-xKdiJ8sw.cjs"),Pt=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ut=require("./index-DNj994Pv.cjs"),Yt=require("./time-Byw_jYQ7.cjs"),Gt=require("./linear-BVckp9RD.cjs"),lt=require("./line-DHV4JwCR.cjs"),ct=require("./step-BZ3C8QFW.cjs"),Xt=require("./area-D3Qx7k7K.cjs"),Bt=require("./select-Bnfk0lJx.cjs"),zt=require("./init-DU0ybBc_.cjs"),Jt=require("./pointer-Dkq5NV1q.cjs"),Kt=require("./use-in-view-sQJZ_xDO.cjs"),f=require("./proxy-BHRoeZgd.cjs"),Qt=require("./GraphFooter.cjs"),Zt=require("./GraphHeader.cjs"),xt=require("./Colors.cjs"),_t=require("./ColorLegend.cjs"),te=require("./EmptyState-d8_8SxeW.cjs");function ee(ut){const{data:A,width:M,height:$,lineColor:k,suffix:I,prefix:j,dateFormat:o,highlightAreaSettings:m,showValues:G,noOfXTicks:mt,rightMargin:ht,leftMargin:R,topMargin:C,bottomMargin:X,tooltip:B,onSeriesMouseOver:F,refValues:z,minValue:J,maxValue:K,animate:a,rtl:Q,strokeWidth:yt,showDots:D,annotations:pt,customHighlightAreaSettings:dt,regressionLine:T,showIntervalDots:gt,showIntervalValues:ft,intervalLineStrokeWidth:W,intervalLineColors:b,intervalAreaColor:jt,intervalAreaOpacity:wt,yAxisTitle:Z,noOfYTicks:vt,minDate:H,maxDate:P,curveType:L,styles:c,classNames:x,precision:N,customLayers:_}=ut,tt=p.useRef(null),l=Kt.useInView(tt,{once:a.once,amount:a.amount}),[u,Rt]=p.useState(!1);p.useEffect(()=>{if(l&&!u){const t=setTimeout(()=>{Rt(!0)},(a.duration+.5)*1e3);return()=>clearTimeout(t)}},[l,u,a.duration]);const S=L==="linear"?lt.curveLinear:L==="step"?ct.curveStep:L==="stepAfter"?ct.stepAfter:L==="stepBefore"?ct.stepBefore:ct.monotoneX,[V,et]=p.useState(void 0),[it,nt]=p.useState(void 0),[U,Y]=p.useState(void 0),d={top:C,bottom:X,left:Z?R+30:R,right:ht},E=p.useRef(null),n=qt.sortBy(A.filter(t=>!v.checkIfNullOrUndefined(t.y)).map(t=>({date:y.parse(`${t.date}`,o,new Date),y:t.y,yMin:v.checkIfNullOrUndefined(t.yMin)?t.y:t.yMin,yMax:v.checkIfNullOrUndefined(t.yMax)?t.y:t.yMax,data:t.data})),"date"),Et=m.map(t=>({...t,coordinates:[t.coordinates[0]===null?null:y.parse(`${t.coordinates[0]}`,o,new Date),t.coordinates[1]===null?null:y.parse(`${t.coordinates[1]}`,o,new Date)]})),Mt=dt.map(t=>({...t,coordinates:t.coordinates.map((g,O)=>O%2===0?y.parse(`${g}`,o,new Date):g)})),r=M-d.left-d.right,w=$-d.top-d.bottom,at=H?y.parse(`${H}`,o,new Date):n[0].date,st=P?y.parse(`${P}`,o,new Date):n[n.length-1].date,h=v.checkIfNullOrUndefined(J)?Math.min(...n.map(t=>Math.min(t.y,t.yMax,t.yMin)))?Math.min(...n.map(t=>Math.min(t.y,t.yMax,t.yMin)))>0?0:Math.min(...n.map(t=>Math.min(t.y,t.yMax,t.yMin))):0:J,q=Math.max(...n.map(t=>Math.max(t.y,t.yMax,t.yMin)))?Math.max(...n.map(t=>Math.max(t.y,t.yMax,t.yMin))):0,i=Yt.time().domain([at,st]).range([0,r]),s=Gt.linear().domain([h,v.checkIfNullOrUndefined(K)?q>0?q:0:K]).range([w,0]).nice(),Ot=lt.line().x(t=>i(t.date)).y(t=>s(t.y)).curve(S),At=lt.line().x(t=>i(t.date)).y(t=>s(t.yMin)).curve(S),It=lt.line().x(t=>i(t.date)).y(t=>s(t.yMax)).curve(S),Lt=Xt.area().x(t=>i(t.date)).y0(t=>s(t.yMin)).y1(t=>s(t.yMax)).curve(S),Nt=s.ticks(vt),Dt=i.ticks(mt);p.useEffect(()=>{const t=O=>{const rt=n[zt.bisectCenter(n.map(Ct=>Ct.date),i.invert(Jt.pointer(O)[0]),0)];et(rt||n[n.length-1]),F?.(rt||n[n.length-1]),Y(O.clientY),nt(O.clientX)},g=()=>{et(void 0),nt(void 0),Y(void 0),F?.(void 0)};Bt.select(E.current).on("mousemove",t).on("mouseout",g)},[i,n,F]);const St=kt.linearRegression(n.filter(t=>!v.checkIfNullOrUndefined(t.date)&&!v.checkIfNullOrUndefined(t.y)).map(t=>[i(t.date),s(t.y)])),Vt=kt.linearRegressionLine(St);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.svg,{width:`${M}px`,height:`${$}px`,viewBox:`0 0 ${M} ${$}`,direction:"ltr",ref:tt,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[e.jsxRuntimeExports.jsx(Ut.HighlightArea,{areaSettings:Et,width:r,height:w,scale:i,animate:a,isInView:l}),e.jsxRuntimeExports.jsx(bt.CustomArea,{areaSettings:Mt,scaleX:i,scaleY:s,animate:a,isInView:l}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(Pt.YTicksAndGridLines,{values:Nt.filter(t=>t!==0),y:Nt.filter(t=>t!==0).map(t=>s(t)),x1:0-R,x2:r+d.right,styles:{gridLines:c?.yAxis?.gridLines,labels:c?.yAxis?.labels},classNames:{gridLines:x?.yAxis?.gridLines,labels:x?.yAxis?.labels},suffix:I,prefix:j,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:N}),e.jsxRuntimeExports.jsx(Tt.Axis,{y1:s(h<0?0:h),y2:s(h<0?0:h),x1:0-R,x2:r+d.right,label:ot.numberFormattingFunction(h<0?0:h,"NA",N,j,I),labelPos:{x:0-R,y:s(h<0?0:h),dx:0,dy:q<0?"1em":-5},classNames:{axis:x?.xAxis?.axis,label:x?.yAxis?.labels},styles:{axis:c?.xAxis?.axis,label:c?.yAxis?.labels}}),e.jsxRuntimeExports.jsx(Ft.AxisTitle,{x:0-R+15,y:w/2,style:c?.yAxis?.title,className:x?.yAxis?.title,text:Z,rotate90:!0})]}),e.jsxRuntimeExports.jsx("g",{children:Dt.map((t,g)=>e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsx("text",{y:w,x:i(t),style:{textAnchor:"middle"},className:"fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs",dy:15,children:y.format(t,o)})},g))}),_.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsx(f.motion.path,{style:{fill:jt},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,d:Lt(n)||""},whileInView:{opacity:wt,d:Lt(n)||"",transition:{duration:a.duration}}},initial:"initial",animate:l?"whileInView":"initial"}),W?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.path,{style:{stroke:b[0],fill:"none",strokeWidth:W},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{pathLength:0,d:At(n)||"",opacity:1},whileInView:{pathLength:1,d:At(n)||"",opacity:1,transition:{duration:a.duration}}},initial:"initial",animate:l?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{style:{stroke:b[1],fill:"none",strokeWidth:W},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{pathLength:0,d:It(n)||"",opacity:1},whileInView:{pathLength:1,d:It(n)||"",opacity:1,transition:{duration:a.duration}}},initial:"initial",animate:l?"whileInView":"initial"})]}):null,e.jsxRuntimeExports.jsx(f.motion.path,{style:{stroke:k,fill:"none",strokeWidth:yt},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{pathLength:0,d:Ot(n)||"",opacity:1},whileInView:{pathLength:1,d:Ot(n)||"",opacity:1,transition:{duration:a.duration}}},initial:"initial",animate:l?"whileInView":"initial"}),V?e.jsxRuntimeExports.jsx("line",{y1:0,y2:w,x1:i(V.date),x2:i(V.date),className:e.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",x?.mouseOverLine),style:c?.mouseOverLine}):null,e.jsxRuntimeExports.jsx("g",{children:n.map((t,g)=>e.jsxRuntimeExports.jsx(f.motion.g,{children:v.checkIfNullOrUndefined(t.y)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[D?e.jsxRuntimeExports.jsx(f.motion.circle,{r:r/n.length<5?0:r/n.length<20?2:4,style:{fill:k},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,cx:i(t.date),cy:s(t.y)},whileInView:{opacity:1,transition:{duration:u?a.duration:.5,delay:u?0:a.duration},cx:i(t.date),cy:s(t.y)}},initial:"initial",animate:l?"whileInView":"initial"}):null,gt?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.circle,{r:r/n.length<5?0:r/n.length<20?2:4,style:{fill:b[0]},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,cx:i(t.date),cy:s(t.yMin)},whileInView:{opacity:1,transition:{duration:u?a.duration:.5,delay:u?0:a.duration},cx:i(t.date),cy:s(t.yMin)}},initial:"initial",animate:l?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.circle,{r:r/n.length<5?0:r/n.length<20?2:4,style:{fill:b[1]},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,cx:i(t.date),cy:s(t.yMax)},whileInView:{opacity:1,transition:{duration:u?a.duration:.5,delay:u?0:a.duration},cx:i(t.date),cy:s(t.yMax)}},initial:"initial",animate:l?"whileInView":"initial"})]}):null,G?e.jsxRuntimeExports.jsx(f.motion.text,{dy:-8,style:{fill:k,textAnchor:"middle",...c?.graphObjectValues||{}},className:e.mo("graph-value text-xs font-bold",x?.graphObjectValues),exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,x:i(t.date),y:s(t.y)},whileInView:{opacity:1,x:i(t.date),y:s(t.y),transition:{duration:u?a.duration:.5,delay:u?0:a.duration}}},initial:"initial",animate:l?"whileInView":"initial",children:ot.numberFormattingFunction(t.y,"NA",N,j,I)}):null,ft?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.text,{dy:"1em",style:{fill:b[0],textAnchor:"middle",...c?.graphObjectValues||{}},className:e.mo("text-xs font-bold",x?.graphObjectValues),exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,x:i(t.date),y:s(t.yMin)},whileInView:{opacity:1,x:i(t.date),y:s(t.yMin),transition:{duration:u?a.duration:.5,delay:u?0:a.duration}}},initial:"initial",animate:l?"whileInView":"initial",children:ot.numberFormattingFunction(t.yMin,"NA",N,j,I)}),e.jsxRuntimeExports.jsx(f.motion.text,{dy:-8,style:{fill:b[1],textAnchor:"middle",...c?.graphObjectValues||{}},className:e.mo("text-xs font-bold",x?.graphObjectValues),exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,x:i(t.date),y:s(t.yMax)},whileInView:{opacity:1,x:i(t.date),y:s(t.yMax),transition:{duration:u?a.duration:.5,delay:u?0:a.duration}}},initial:"initial",animate:l?"whileInView":"initial",children:ot.numberFormattingFunction(t.yMax,"NA",N,j,I)})]}):null]})},g))}),z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:z.map((t,g)=>e.jsxRuntimeExports.jsx(Wt.RefLineY,{text:t.text,color:t.color,y:s(t.value),x1:0-R,x2:r+d.right,classNames:t.classNames,styles:t.styles,animate:a,isInView:l},g))}):null,e.jsxRuntimeExports.jsx("g",{children:pt.map((t,g)=>{const O=bt.getLineEndPoint({x:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8},{x:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date)):0,y:t.yCoordinate?s(t.yCoordinate):0},v.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius),rt=t.showConnector?{y1:O.y,x1:O.x,y2:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0):0+(t.yOffset||0),x2:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),cy:t.yCoordinate?s(t.yCoordinate):0,cx:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date)):0,circleRadius:v.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius,strokeWidth:t.showConnector===!0?2:Math.min(t.showConnector||0,1)}:void 0,Ct={y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8,x:Q?0:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),width:Q?t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0):r+d.right-(t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0)),maxWidth:t.maxWidth,fontWeight:t.fontWeight,align:t.align};return e.jsxRuntimeExports.jsx(bt.Annotation,{color:t.color,connectorsSettings:rt,labelSettings:Ct,text:t.text,classNames:t.classNames,styles:t.styles,animate:a,isInView:l},g)})}),e.jsxRuntimeExports.jsx("g",{children:T?e.jsxRuntimeExports.jsx(Ht.RegressionLine,{x1:0,x2:r,y1:Vt(0),y2:Vt(r),graphHeight:w,graphWidth:r,className:x?.regLine,style:c?.regLine,color:typeof T=="string"?T:void 0,animate:a,isInView:l}):null}),_.filter(t=>t.position==="after").map(t=>t.layer),e.jsxRuntimeExports.jsx("rect",{ref:E,style:{fill:"none",pointerEvents:"all"},width:r,height:w})]})}),V&&B&&it&&U?e.jsxRuntimeExports.jsx($t.Tooltip,{data:V,body:B,xPos:it,yPos:U,backgroundStyle:c?.tooltip,className:x?.tooltip}):null]})}function ie(ut){const{data:A,graphTitle:M,suffix:$="",sources:k,prefix:I="",graphDescription:j,height:o,width:m,footNote:G,noOfXTicks:mt=10,dateFormat:ht="yyyy",showValues:R=!1,backgroundColor:C=!1,padding:X,lineColor:B,leftMargin:F=30,rightMargin:z=30,topMargin:J=20,bottomMargin:K=25,tooltip:a,refValues:Q=[],highlightAreaSettings:yt=[],relativeHeight:D,onSeriesMouseOver:pt,graphID:dt,minValue:T,maxValue:gt,regressionLine:ft=!1,showIntervalDots:W=!1,showIntervalValues:b=!1,intervalLineStrokeWidth:jt=0,intervalLineColors:wt=[xt.Colors.light.grays["gray-500"],xt.Colors.light.grays["gray-500"]],intervalAreaColor:Z=xt.Colors.primaryColors["blue-100"],intervalAreaOpacity:vt=.4,graphDownload:H=!1,dataDownload:P=!1,animate:L=!1,language:c="en",minHeight:x=0,strokeWidth:N=2,showDots:_=!0,annotations:tt=[],customHighlightAreaSettings:l=[],theme:u="light",ariaLabel:Rt,yAxisTitle:S,noOfYTicks:V=5,minDate:et,maxDate:it,colorLegendTitle:nt,colorLegendColors:U,colorLegendDomain:Y,curveType:d="curve",styles:E,classNames:n,precision:Et=2,customLayers:Mt=[]}=ut,[r,w]=p.useState(0),[at,st]=p.useState(0),h=p.useRef(null),q=p.useRef(null);return p.useEffect(()=>{const i=new ResizeObserver(s=>{w(m||s[0].target.clientWidth||620),st(o||s[0].target.clientHeight||480)});return h.current&&(st(h.current.clientHeight||480),w(h.current.clientWidth||620),m||i.observe(h.current)),()=>i.disconnect()},[m,o]),e.jsxRuntimeExports.jsx("div",{className:`${u||"light"} flex ${m?"w-fit grow-0":"w-full grow"}`,dir:c==="he"||c==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${c||"en"}`,m?"w-fit":"w-full",n?.graphContainer),style:{...E?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:dt,ref:q,"aria-label":Rt||`${M?`The graph shows ${M}. `:""}This is a line chart that highlights the difference between two datasets over time.${j?` ${j}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:C?X||"1rem":X||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[M||j||H||P?e.jsxRuntimeExports.jsx(Zt.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:n?.title,description:n?.description},graphTitle:M,graphDescription:j,width:m,graphDownload:H?q.current:void 0,dataDownload:P?A.map(i=>i.data).filter(i=>i!==void 0).length>0?A.map(i=>i.data).filter(i=>i!==void 0):A.filter(i=>i!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:A.length===0?e.jsxRuntimeExports.jsx(te.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[U&&Y?e.jsxRuntimeExports.jsx(_t.ColorLegend,{width:m,colorLegendTitle:nt,colors:U,colorDomain:Y,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:h,"aria-label":"Graph area",children:(m||r)&&(o||at)?e.jsxRuntimeExports.jsx(ee,{data:A,lineColor:B||xt.Colors.primaryColors["blue-600"],width:m||r,height:Math.max(x,o||(D?x?(m||r)*D>x?(m||r)*D:x:(m||r)*D:at)),suffix:$,prefix:I,dateFormat:ht,showValues:R,noOfXTicks:mt,leftMargin:F,rightMargin:z,topMargin:J,bottomMargin:K,tooltip:a,highlightAreaSettings:yt,onSeriesMouseOver:pt,refValues:Q,minValue:T,maxValue:gt,animate:L===!0?{duration:.5,once:!0,amount:.5}:L||{duration:0,once:!0,amount:0},rtl:c==="he"||c==="ar",strokeWidth:N,showDots:_,annotations:tt,customHighlightAreaSettings:l,regressionLine:ft,showIntervalDots:W,showIntervalValues:b,intervalLineStrokeWidth:jt,intervalLineColors:wt,intervalAreaColor:Z,intervalAreaOpacity:vt,yAxisTitle:S,noOfYTicks:V,minDate:et,maxDate:it,curveType:d,styles:E,classNames:n,precision:Et,customLayers:Mt}):null})]})}),k||G?e.jsxRuntimeExports.jsx(Qt.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:n?.footnote,source:n?.source},sources:k,footNote:G,width:m}):null]})})})})}exports.LineChartWithConfidenceInterval=ie;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),p=require("react"),y=require("./parse-hMnG_lRV.cjs"),qt=require("./index-BzeLQvXk.cjs"),kt=require("./simple-statistics-xm8c0LQQ.cjs"),ot=require("./numberFormattingFunction-02t-wJta.cjs"),$t=require("./Tooltip-n8z5bfav.cjs"),v=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),bt=require("./customArea-CK768gCn.cjs"),Ft=require("./AxisTitle-CK9YeovX.cjs"),Tt=require("./Axis-DE7dSn1_.cjs"),Wt=require("./ReferenceLine-CFVBBN__.cjs"),Ht=require("./RegressionLine-xKdiJ8sw.cjs"),Pt=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ut=require("./index-BYzIB5V6.cjs"),Yt=require("./time-Byw_jYQ7.cjs"),Gt=require("./linear-BVckp9RD.cjs"),lt=require("./line-DHV4JwCR.cjs"),ct=require("./step-BZ3C8QFW.cjs"),Xt=require("./area-D3Qx7k7K.cjs"),Bt=require("./select-Bnfk0lJx.cjs"),zt=require("./init-DU0ybBc_.cjs"),Jt=require("./pointer-Dkq5NV1q.cjs"),Kt=require("./use-in-view-sQJZ_xDO.cjs"),f=require("./proxy-BHRoeZgd.cjs"),Qt=require("./GraphFooter.cjs"),Zt=require("./GraphHeader.cjs"),xt=require("./Colors.cjs"),_t=require("./ColorLegend.cjs"),te=require("./EmptyState-d8_8SxeW.cjs");function ee(ut){const{data:A,width:M,height:$,lineColor:k,suffix:I,prefix:j,dateFormat:o,highlightAreaSettings:m,showValues:G,noOfXTicks:mt,rightMargin:ht,leftMargin:R,topMargin:C,bottomMargin:X,tooltip:B,onSeriesMouseOver:F,refValues:z,minValue:J,maxValue:K,animate:a,rtl:Q,strokeWidth:yt,showDots:D,annotations:pt,customHighlightAreaSettings:dt,regressionLine:T,showIntervalDots:gt,showIntervalValues:ft,intervalLineStrokeWidth:W,intervalLineColors:b,intervalAreaColor:jt,intervalAreaOpacity:wt,yAxisTitle:Z,noOfYTicks:vt,minDate:H,maxDate:P,curveType:L,styles:c,classNames:x,precision:N,customLayers:_}=ut,tt=p.useRef(null),l=Kt.useInView(tt,{once:a.once,amount:a.amount}),[u,Rt]=p.useState(!1);p.useEffect(()=>{if(l&&!u){const t=setTimeout(()=>{Rt(!0)},(a.duration+.5)*1e3);return()=>clearTimeout(t)}},[l,u,a.duration]);const S=L==="linear"?lt.curveLinear:L==="step"?ct.curveStep:L==="stepAfter"?ct.stepAfter:L==="stepBefore"?ct.stepBefore:ct.monotoneX,[V,et]=p.useState(void 0),[it,nt]=p.useState(void 0),[U,Y]=p.useState(void 0),d={top:C,bottom:X,left:Z?R+30:R,right:ht},E=p.useRef(null),n=qt.sortBy(A.filter(t=>!v.checkIfNullOrUndefined(t.y)).map(t=>({date:y.parse(`${t.date}`,o,new Date),y:t.y,yMin:v.checkIfNullOrUndefined(t.yMin)?t.y:t.yMin,yMax:v.checkIfNullOrUndefined(t.yMax)?t.y:t.yMax,data:t.data})),"date"),Et=m.map(t=>({...t,coordinates:[t.coordinates[0]===null?null:y.parse(`${t.coordinates[0]}`,o,new Date),t.coordinates[1]===null?null:y.parse(`${t.coordinates[1]}`,o,new Date)]})),Mt=dt.map(t=>({...t,coordinates:t.coordinates.map((g,O)=>O%2===0?y.parse(`${g}`,o,new Date):g)})),r=M-d.left-d.right,w=$-d.top-d.bottom,at=H?y.parse(`${H}`,o,new Date):n[0].date,st=P?y.parse(`${P}`,o,new Date):n[n.length-1].date,h=v.checkIfNullOrUndefined(J)?Math.min(...n.map(t=>Math.min(t.y,t.yMax,t.yMin)))?Math.min(...n.map(t=>Math.min(t.y,t.yMax,t.yMin)))>0?0:Math.min(...n.map(t=>Math.min(t.y,t.yMax,t.yMin))):0:J,q=Math.max(...n.map(t=>Math.max(t.y,t.yMax,t.yMin)))?Math.max(...n.map(t=>Math.max(t.y,t.yMax,t.yMin))):0,i=Yt.time().domain([at,st]).range([0,r]),s=Gt.linear().domain([h,v.checkIfNullOrUndefined(K)?q>0?q:0:K]).range([w,0]).nice(),Ot=lt.line().x(t=>i(t.date)).y(t=>s(t.y)).curve(S),At=lt.line().x(t=>i(t.date)).y(t=>s(t.yMin)).curve(S),It=lt.line().x(t=>i(t.date)).y(t=>s(t.yMax)).curve(S),Lt=Xt.area().x(t=>i(t.date)).y0(t=>s(t.yMin)).y1(t=>s(t.yMax)).curve(S),Nt=s.ticks(vt),Dt=i.ticks(mt);p.useEffect(()=>{const t=O=>{const rt=n[zt.bisectCenter(n.map(Ct=>Ct.date),i.invert(Jt.pointer(O)[0]),0)];et(rt||n[n.length-1]),F?.(rt||n[n.length-1]),Y(O.clientY),nt(O.clientX)},g=()=>{et(void 0),nt(void 0),Y(void 0),F?.(void 0)};Bt.select(E.current).on("mousemove",t).on("mouseout",g)},[i,n,F]);const St=kt.linearRegression(n.filter(t=>!v.checkIfNullOrUndefined(t.date)&&!v.checkIfNullOrUndefined(t.y)).map(t=>[i(t.date),s(t.y)])),Vt=kt.linearRegressionLine(St);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.svg,{width:`${M}px`,height:`${$}px`,viewBox:`0 0 ${M} ${$}`,direction:"ltr",ref:tt,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[e.jsxRuntimeExports.jsx(Ut.HighlightArea,{areaSettings:Et,width:r,height:w,scale:i,animate:a,isInView:l}),e.jsxRuntimeExports.jsx(bt.CustomArea,{areaSettings:Mt,scaleX:i,scaleY:s,animate:a,isInView:l}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(Pt.YTicksAndGridLines,{values:Nt.filter(t=>t!==0),y:Nt.filter(t=>t!==0).map(t=>s(t)),x1:0-R,x2:r+d.right,styles:{gridLines:c?.yAxis?.gridLines,labels:c?.yAxis?.labels},classNames:{gridLines:x?.yAxis?.gridLines,labels:x?.yAxis?.labels},suffix:I,prefix:j,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:N}),e.jsxRuntimeExports.jsx(Tt.Axis,{y1:s(h<0?0:h),y2:s(h<0?0:h),x1:0-R,x2:r+d.right,label:ot.numberFormattingFunction(h<0?0:h,"NA",N,j,I),labelPos:{x:0-R,y:s(h<0?0:h),dx:0,dy:q<0?"1em":-5},classNames:{axis:x?.xAxis?.axis,label:x?.yAxis?.labels},styles:{axis:c?.xAxis?.axis,label:c?.yAxis?.labels}}),e.jsxRuntimeExports.jsx(Ft.AxisTitle,{x:0-R+15,y:w/2,style:c?.yAxis?.title,className:x?.yAxis?.title,text:Z,rotate90:!0})]}),e.jsxRuntimeExports.jsx("g",{children:Dt.map((t,g)=>e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsx("text",{y:w,x:i(t),style:{textAnchor:"middle"},className:"fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs",dy:15,children:y.format(t,o)})},g))}),_.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsx(f.motion.path,{style:{fill:jt},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,d:Lt(n)||""},whileInView:{opacity:wt,d:Lt(n)||"",transition:{duration:a.duration}}},initial:"initial",animate:l?"whileInView":"initial"}),W?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.path,{style:{stroke:b[0],fill:"none",strokeWidth:W},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{pathLength:0,d:At(n)||"",opacity:1},whileInView:{pathLength:1,d:At(n)||"",opacity:1,transition:{duration:a.duration}}},initial:"initial",animate:l?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{style:{stroke:b[1],fill:"none",strokeWidth:W},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{pathLength:0,d:It(n)||"",opacity:1},whileInView:{pathLength:1,d:It(n)||"",opacity:1,transition:{duration:a.duration}}},initial:"initial",animate:l?"whileInView":"initial"})]}):null,e.jsxRuntimeExports.jsx(f.motion.path,{style:{stroke:k,fill:"none",strokeWidth:yt},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{pathLength:0,d:Ot(n)||"",opacity:1},whileInView:{pathLength:1,d:Ot(n)||"",opacity:1,transition:{duration:a.duration}}},initial:"initial",animate:l?"whileInView":"initial"}),V?e.jsxRuntimeExports.jsx("line",{y1:0,y2:w,x1:i(V.date),x2:i(V.date),className:e.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",x?.mouseOverLine),style:c?.mouseOverLine}):null,e.jsxRuntimeExports.jsx("g",{children:n.map((t,g)=>e.jsxRuntimeExports.jsx(f.motion.g,{children:v.checkIfNullOrUndefined(t.y)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[D?e.jsxRuntimeExports.jsx(f.motion.circle,{r:r/n.length<5?0:r/n.length<20?2:4,style:{fill:k},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,cx:i(t.date),cy:s(t.y)},whileInView:{opacity:1,transition:{duration:u?a.duration:.5,delay:u?0:a.duration},cx:i(t.date),cy:s(t.y)}},initial:"initial",animate:l?"whileInView":"initial"}):null,gt?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.circle,{r:r/n.length<5?0:r/n.length<20?2:4,style:{fill:b[0]},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,cx:i(t.date),cy:s(t.yMin)},whileInView:{opacity:1,transition:{duration:u?a.duration:.5,delay:u?0:a.duration},cx:i(t.date),cy:s(t.yMin)}},initial:"initial",animate:l?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.circle,{r:r/n.length<5?0:r/n.length<20?2:4,style:{fill:b[1]},exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,cx:i(t.date),cy:s(t.yMax)},whileInView:{opacity:1,transition:{duration:u?a.duration:.5,delay:u?0:a.duration},cx:i(t.date),cy:s(t.yMax)}},initial:"initial",animate:l?"whileInView":"initial"})]}):null,G?e.jsxRuntimeExports.jsx(f.motion.text,{dy:-8,style:{fill:k,textAnchor:"middle",...c?.graphObjectValues||{}},className:e.mo("graph-value text-xs font-bold",x?.graphObjectValues),exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,x:i(t.date),y:s(t.y)},whileInView:{opacity:1,x:i(t.date),y:s(t.y),transition:{duration:u?a.duration:.5,delay:u?0:a.duration}}},initial:"initial",animate:l?"whileInView":"initial",children:ot.numberFormattingFunction(t.y,"NA",N,j,I)}):null,ft?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.text,{dy:"1em",style:{fill:b[0],textAnchor:"middle",...c?.graphObjectValues||{}},className:e.mo("text-xs font-bold",x?.graphObjectValues),exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,x:i(t.date),y:s(t.yMin)},whileInView:{opacity:1,x:i(t.date),y:s(t.yMin),transition:{duration:u?a.duration:.5,delay:u?0:a.duration}}},initial:"initial",animate:l?"whileInView":"initial",children:ot.numberFormattingFunction(t.yMin,"NA",N,j,I)}),e.jsxRuntimeExports.jsx(f.motion.text,{dy:-8,style:{fill:b[1],textAnchor:"middle",...c?.graphObjectValues||{}},className:e.mo("text-xs font-bold",x?.graphObjectValues),exit:{opacity:0,transition:{duration:a.duration}},variants:{initial:{opacity:0,x:i(t.date),y:s(t.yMax)},whileInView:{opacity:1,x:i(t.date),y:s(t.yMax),transition:{duration:u?a.duration:.5,delay:u?0:a.duration}}},initial:"initial",animate:l?"whileInView":"initial",children:ot.numberFormattingFunction(t.yMax,"NA",N,j,I)})]}):null]})},g))}),z?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:z.map((t,g)=>e.jsxRuntimeExports.jsx(Wt.RefLineY,{text:t.text,color:t.color,y:s(t.value),x1:0-R,x2:r+d.right,classNames:t.classNames,styles:t.styles,animate:a,isInView:l},g))}):null,e.jsxRuntimeExports.jsx("g",{children:pt.map((t,g)=>{const O=bt.getLineEndPoint({x:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8},{x:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date)):0,y:t.yCoordinate?s(t.yCoordinate):0},v.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius),rt=t.showConnector?{y1:O.y,x1:O.x,y2:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0):0+(t.yOffset||0),x2:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),cy:t.yCoordinate?s(t.yCoordinate):0,cx:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date)):0,circleRadius:v.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius,strokeWidth:t.showConnector===!0?2:Math.min(t.showConnector||0,1)}:void 0,Ct={y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8,x:Q?0:t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),width:Q?t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0):r+d.right-(t.xCoordinate?i(y.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0)),maxWidth:t.maxWidth,fontWeight:t.fontWeight,align:t.align};return e.jsxRuntimeExports.jsx(bt.Annotation,{color:t.color,connectorsSettings:rt,labelSettings:Ct,text:t.text,classNames:t.classNames,styles:t.styles,animate:a,isInView:l},g)})}),e.jsxRuntimeExports.jsx("g",{children:T?e.jsxRuntimeExports.jsx(Ht.RegressionLine,{x1:0,x2:r,y1:Vt(0),y2:Vt(r),graphHeight:w,graphWidth:r,className:x?.regLine,style:c?.regLine,color:typeof T=="string"?T:void 0,animate:a,isInView:l}):null}),_.filter(t=>t.position==="after").map(t=>t.layer),e.jsxRuntimeExports.jsx("rect",{ref:E,style:{fill:"none",pointerEvents:"all"},width:r,height:w})]})}),V&&B&&it&&U?e.jsxRuntimeExports.jsx($t.Tooltip,{data:V,body:B,xPos:it,yPos:U,backgroundStyle:c?.tooltip,className:x?.tooltip}):null]})}function ie(ut){const{data:A,graphTitle:M,suffix:$="",sources:k,prefix:I="",graphDescription:j,height:o,width:m,footNote:G,noOfXTicks:mt=10,dateFormat:ht="yyyy",showValues:R=!1,backgroundColor:C=!1,padding:X,lineColor:B,leftMargin:F=30,rightMargin:z=30,topMargin:J=20,bottomMargin:K=25,tooltip:a,refValues:Q=[],highlightAreaSettings:yt=[],relativeHeight:D,onSeriesMouseOver:pt,graphID:dt,minValue:T,maxValue:gt,regressionLine:ft=!1,showIntervalDots:W=!1,showIntervalValues:b=!1,intervalLineStrokeWidth:jt=0,intervalLineColors:wt=[xt.Colors.light.grays["gray-500"],xt.Colors.light.grays["gray-500"]],intervalAreaColor:Z=xt.Colors.primaryColors["blue-100"],intervalAreaOpacity:vt=.4,graphDownload:H=!1,dataDownload:P=!1,animate:L=!1,language:c="en",minHeight:x=0,strokeWidth:N=2,showDots:_=!0,annotations:tt=[],customHighlightAreaSettings:l=[],theme:u="light",ariaLabel:Rt,yAxisTitle:S,noOfYTicks:V=5,minDate:et,maxDate:it,colorLegendTitle:nt,colorLegendColors:U,colorLegendDomain:Y,curveType:d="curve",styles:E,classNames:n,precision:Et=2,customLayers:Mt=[]}=ut,[r,w]=p.useState(0),[at,st]=p.useState(0),h=p.useRef(null),q=p.useRef(null);return p.useEffect(()=>{const i=new ResizeObserver(s=>{w(m||s[0].target.clientWidth||620),st(o||s[0].target.clientHeight||480)});return h.current&&(st(h.current.clientHeight||480),w(h.current.clientWidth||620),m||i.observe(h.current)),()=>i.disconnect()},[m,o]),e.jsxRuntimeExports.jsx("div",{className:`${u||"light"} flex ${m?"w-fit grow-0":"w-full grow"}`,dir:c==="he"||c==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${c||"en"}`,m?"w-fit":"w-full",n?.graphContainer),style:{...E?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:dt,ref:q,"aria-label":Rt||`${M?`The graph shows ${M}. `:""}This is a line chart that highlights the difference between two datasets over time.${j?` ${j}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:C?X||"1rem":X||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[M||j||H||P?e.jsxRuntimeExports.jsx(Zt.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:n?.title,description:n?.description},graphTitle:M,graphDescription:j,width:m,graphDownload:H?q.current:void 0,dataDownload:P?A.map(i=>i.data).filter(i=>i!==void 0).length>0?A.map(i=>i.data).filter(i=>i!==void 0):A.filter(i=>i!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:A.length===0?e.jsxRuntimeExports.jsx(te.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[U&&Y?e.jsxRuntimeExports.jsx(_t.ColorLegend,{width:m,colorLegendTitle:nt,colors:U,colorDomain:Y,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:h,"aria-label":"Graph area",children:(m||r)&&(o||at)?e.jsxRuntimeExports.jsx(ee,{data:A,lineColor:B||xt.Colors.primaryColors["blue-600"],width:m||r,height:Math.max(x,o||(D?x?(m||r)*D>x?(m||r)*D:x:(m||r)*D:at)),suffix:$,prefix:I,dateFormat:ht,showValues:R,noOfXTicks:mt,leftMargin:F,rightMargin:z,topMargin:J,bottomMargin:K,tooltip:a,highlightAreaSettings:yt,onSeriesMouseOver:pt,refValues:Q,minValue:T,maxValue:gt,animate:L===!0?{duration:.5,once:!0,amount:.5}:L||{duration:0,once:!0,amount:0},rtl:c==="he"||c==="ar",strokeWidth:N,showDots:_,annotations:tt,customHighlightAreaSettings:l,regressionLine:ft,showIntervalDots:W,showIntervalValues:b,intervalLineStrokeWidth:jt,intervalLineColors:wt,intervalAreaColor:Z,intervalAreaOpacity:vt,yAxisTitle:S,noOfYTicks:V,minDate:et,maxDate:it,curveType:d,styles:E,classNames:n,precision:Et,customLayers:Mt}):null})]})}),k||G?e.jsxRuntimeExports.jsx(Qt.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:n?.footnote,source:n?.source},sources:k,footNote:G,width:m}):null]})})})})}exports.LineChartWithConfidenceInterval=ie;
|
|
2
2
|
//# sourceMappingURL=LineChartWithConfidenceInterval.cjs.map
|
|
@@ -12,7 +12,7 @@ import { A as Bt } from "./Axis-Ddg-seDi.js";
|
|
|
12
12
|
import { R as zt } from "./ReferenceLine-CfAW3vKJ.js";
|
|
13
13
|
import { R as Ut } from "./RegressionLine-mH7UKOPi.js";
|
|
14
14
|
import { Y as qt } from "./YTicksAndGridLines-B6ah7CRf.js";
|
|
15
|
-
import { H as Jt } from "./index-
|
|
15
|
+
import { H as Jt } from "./index-DKCxu1Gh.js";
|
|
16
16
|
import { t as Kt } from "./time-BzJP5SPC.js";
|
|
17
17
|
import { a as Qt } from "./linear-DUdu7l2G.js";
|
|
18
18
|
import { l as Ot, c as Zt } from "./line-CPfhohvF.js";
|
|
@@ -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"),h=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:m,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=>!h.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=h.checkIfNullOrUndefined(X)?Math.min(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e)))?Math.min(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e)))>0?0:Math.min(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e))):0:X,J=Math.max(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e)))?Math.max(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e))):0,n=He.time().domain([G,me]).range([0,b]),c=We.linear().domain([h.checkIfNullOrUndefined(X)?i:X,h.checkIfNullOrUndefined(te)?J>0?J:0:te]).range([M,0]).nice(),Ie=Ge.Delaunay.from(l.filter(e=>!h.checkIfNullOrUndefined(e.date)&&!h.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:m,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,m,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:m,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=>!h.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=>!h.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=>!h.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:h.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,m,A)}):null]}),l.filter(e=>!h.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},h.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:h.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:m,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(m||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),m||i.observe(G.current)),()=>i.disconnect()},[m,A]),t.jsxRuntimeExports.jsx("div",{className:`${E||"light"} flex ${m?"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"}`,m?"w-fit":"w-full",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:m,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:m,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:(m||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:m||W,height:Math.max(D,A||(B?D?(m||W)*B>D?(m||W)*B:D:(m||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:m}):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"),h=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-BYzIB5V6.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:m,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=>!h.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=h.checkIfNullOrUndefined(X)?Math.min(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e)))?Math.min(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e)))>0?0:Math.min(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e))):0:X,J=Math.max(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e)))?Math.max(...l.map(e=>e.y).filter(e=>!h.checkIfNullOrUndefined(e))):0,n=He.time().domain([G,me]).range([0,b]),c=We.linear().domain([h.checkIfNullOrUndefined(X)?i:X,h.checkIfNullOrUndefined(te)?J>0?J:0:te]).range([M,0]).nice(),Ie=Ge.Delaunay.from(l.filter(e=>!h.checkIfNullOrUndefined(e.date)&&!h.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:m,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,m,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:m,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=>!h.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=>!h.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=>!h.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:h.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,m,A)}):null]}),l.filter(e=>!h.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},h.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:h.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:m,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(m||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),m||i.observe(G.current)),()=>i.disconnect()},[m,A]),t.jsxRuntimeExports.jsx("div",{className:`${E||"light"} flex ${m?"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"}`,m?"w-fit":"w-full",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:m,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:m,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:(m||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:m||W,height:Math.max(D,A||(B?D?(m||W)*B>D?(m||W)*B:D:(m||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:m}):null]})})})})}exports.MultiLineAltChart=_e;
|
|
2
2
|
//# sourceMappingURL=MultiLineAltChart.cjs.map
|
|
@@ -12,7 +12,7 @@ import { A as Fe } from "./Axis-Ddg-seDi.js";
|
|
|
12
12
|
import { X as Xe } from "./XTicksAndGridLines-Bn9u5gOM.js";
|
|
13
13
|
import { R as Pe } from "./ReferenceLine-CfAW3vKJ.js";
|
|
14
14
|
import { Y as Ee } from "./YTicksAndGridLines-B6ah7CRf.js";
|
|
15
|
-
import { H as Ge } from "./index-
|
|
15
|
+
import { H as Ge } from "./index-DKCxu1Gh.js";
|
|
16
16
|
import { Colors as T } from "./Colors.js";
|
|
17
17
|
import { t as Be } from "./time-BzJP5SPC.js";
|
|
18
18
|
import { a as ze } from "./linear-DUdu7l2G.js";
|
package/dist/MultiLineChart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),f=require("react"),m=require("./parse-hMnG_lRV.cjs"),Ie=require("./index-BzeLQvXk.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),Se=require("./Tooltip-n8z5bfav.cjs"),h=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),be=require("./customArea-CK768gCn.cjs"),De=require("./AxisTitle-CK9YeovX.cjs"),Te=require("./Axis-DE7dSn1_.cjs"),qe=require("./XTicksAndGridLines-CCzXIV8d.cjs"),$e=require("./ReferenceLine-CFVBBN__.cjs"),Me=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ve=require("./index-DNj994Pv.cjs"),Fe=require("./time-Byw_jYQ7.cjs"),He=require("./linear-BVckp9RD.cjs"),Le=require("./line-DHV4JwCR.cjs"),xe=require("./step-BZ3C8QFW.cjs"),Ue=require("./select-Bnfk0lJx.cjs"),Ge=require("./init-DU0ybBc_.cjs"),Pe=require("./pointer-Dkq5NV1q.cjs"),We=require("./use-in-view-sQJZ_xDO.cjs"),T=require("./proxy-BHRoeZgd.cjs"),Ye=require("./GraphFooter.cjs"),Xe=require("./GraphHeader.cjs"),Be=require("./ColorLegend.cjs"),ze=require("./Colors.cjs"),_e=require("./EmptyState-d8_8SxeW.cjs"),Je=require("./generateRandomString-B5zBiJzS.cjs");function Ke(ue){const{data:N,width:A,height:q,lineColors:L,dateFormat:l,noOfXTicks:de,labels:R,rightMargin:$,topMargin:x,bottomMargin:_,suffix:M,prefix:V,leftMargin:E,tooltip:G,onSeriesMouseOver:P,showValues:k,showColorLegendAtTop:me,refValues:J,highlightAreaSettings:he,minValue:F,maxValue:K,highlightedLines:b,animate:s,rtl:W,strokeWidth:pe,showDots:ge,annotations:fe,customHighlightAreaSettings:ye,yAxisTitle:Q,noOfYTicks:je,minDate:Y,maxDate:X,curveType:I,styles:c,classNames:y,dimmedOpacity:S,precision:H,customLayers:Z,dashedLines:B,dashSettings:ee,labelsToBeHidden:we,revealClipId:te}=ue,ie=f.useRef(null),u=We.useInView(ie,{once:s.once,amount:s.amount}),[O,ve]=f.useState(!1);f.useEffect(()=>{if(u&&!O){const e=setTimeout(()=>{ve(!0)},(s.duration+.5)*1e3);return()=>clearTimeout(e)}},[u,O,s.duration]);const Re=I==="linear"?Le.curveLinear:I==="step"?xe.curveStep:I==="stepAfter"?xe.stepAfter:I==="stepBefore"?xe.stepBefore:xe.monotoneX,[j,C]=f.useState(void 0),[ne,se]=f.useState(void 0),[re,ae]=f.useState(void 0),w={top:x,bottom:_,left:Q?E+30:E,right:$},z=f.useRef(null),r=Ie.sortBy(N.map(e=>({...e,date:m.parse(`${e.date}`,l,new Date)})),"date"),D=r[0].y.map((e,i)=>r.map(n=>({...n,y:n.y[i]})).filter(n=>!h.checkIfNullOrUndefined(n.y))),oe=he.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:m.parse(`${e.coordinates[0]}`,l,new Date),e.coordinates[1]===null?null:m.parse(`${e.coordinates[1]}`,l,new Date)]})),le=ye.map(e=>({...e,coordinates:e.coordinates.map((i,n)=>n%2===0?m.parse(`${i}`,l,new Date):i)})),p=A-w.left-w.right,g=q-w.top-w.bottom,ce=Y?m.parse(`${Y}`,l,new Date):r[0].date,d=X?m.parse(`${X}`,l,new Date):r[r.length-1].date,v=h.checkIfNullOrUndefined(F)?Math.min(...r.map(e=>Math.min(...e.y.filter(i=>!h.checkIfNullOrUndefined(i)))))?Math.min(...r.map(e=>Math.min(...e.y.filter(i=>!h.checkIfNullOrUndefined(i)))))>0?0:Math.min(...r.map(e=>Math.min(...e.y.filter(i=>!h.checkIfNullOrUndefined(i))))):0:F,Ee=Math.max(...r.map(e=>Math.max(...e.y.filter(i=>!h.checkIfNullOrUndefined(i)))))?Math.max(...r.map(e=>Math.max(...e.y.filter(i=>!h.checkIfNullOrUndefined(i))))):0,a=Fe.time().domain([ce,d]).range([0,p]),o=He.linear().domain([h.checkIfNullOrUndefined(F)?v:F,h.checkIfNullOrUndefined(K)?Ee>0?Ee:0:K]).range([g,0]).nice(),Ce=Le.line().x(e=>a(e.date)).y(e=>o(e.y)).curve(Re),Ae=o.ticks(je),ke=a.ticks(de);return f.useEffect(()=>{const e=n=>{const U=r[Ge.bisectCenter(r.map(Oe=>Oe.date),a.invert(Pe.pointer(n)[0]),0)];C(U||r[r.length-1]),ae(n.clientY),se(n.clientX),P?.(U||r[r.length-1])},i=()=>{C(void 0),se(void 0),ae(void 0)};Ue.select(z.current).on("mousemove",e).on("mouseout",i),P?.(void 0)},[a,r,P]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(T.motion.svg,{width:`${A}px`,height:`${q}px`,viewBox:`0 0 ${A} ${q}`,direction:"ltr",ref:ie,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${w.left},${w.top})`,children:[t.jsxRuntimeExports.jsx("defs",{children:t.jsxRuntimeExports.jsx("clipPath",{id:te,children:t.jsxRuntimeExports.jsx(T.motion.rect,{x:0,y:0,height:g,variants:{initial:{width:0},whileInView:{width:p,transition:{duration:s.duration}}},initial:"initial",animate:u?"whileInView":"initial"})})}),t.jsxRuntimeExports.jsx(Ve.HighlightArea,{areaSettings:oe,width:p,height:g,scale:a,animate:s,isInView:u}),t.jsxRuntimeExports.jsx(be.CustomArea,{areaSettings:le,scaleX:a,scaleY:o,animate:s,isInView:u}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Me.YTicksAndGridLines,{values:Ae.filter(e=>e!==0),y:Ae.filter(e=>e!==0).map(e=>o(e)),x1:0-E,x2:p+w.right,styles:{gridLines:c?.yAxis?.gridLines,labels:c?.yAxis?.labels},classNames:{gridLines:y?.yAxis?.gridLines,labels:y?.yAxis?.labels},suffix:M,prefix:V,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:H}),t.jsxRuntimeExports.jsx(Te.Axis,{y1:o(v<0?0:v),y2:o(v<0?0:v),x1:0-E,x2:p+w.right,label:Ne.numberFormattingFunction(v<0?0:v,"NA",H,V,M),labelPos:{x:0-E,y:o(v<0?0:v),dx:0,dy:Ee<0?"1em":-5},classNames:{axis:y?.xAxis?.axis,label:y?.yAxis?.labels},styles:{axis:c?.xAxis?.axis,label:c?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(De.AxisTitle,{x:0-E-15,y:g/2,style:c?.yAxis?.title,className:y?.yAxis?.title,text:Q,rotate90:!0})]}),t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx(qe.XTicksAndGridLines,{values:ke.map(e=>m.format(e,l)),x:ke.map(e=>a(e)),y1:0,y2:g,styles:{gridLines:c?.xAxis?.gridLines,labels:c?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",y?.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",y?.xAxis?.labels)},suffix:M,prefix:V,labelType:"primary",showGridLines:!0,precision:H})}),Z.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{children:[D.map((e,i)=>t.jsxRuntimeExports.jsxs(T.motion.g,{exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:b.length!==0?b.indexOf(R[i])!==-1?1:S:1},whileInView:{opacity:b.length!==0?b.indexOf(R[i])!==-1?1:S:1,transition:{duration:s.duration}}},initial:"initial",animate:u?"whileInView":"initial",children:[t.jsxRuntimeExports.jsx(T.motion.path,{style:{fill:"none",strokeWidth:pe},clipPath:`url(#${te})`,exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{...B.length===0?{pathLength:0}:{},d:Ce(e.filter(n=>!h.checkIfNullOrUndefined(n.y)))||"",opacity:1,stroke:L[i]},whileInView:{...B.length===0?{pathLength:1}:{},d:Ce(e.filter(n=>!h.checkIfNullOrUndefined(n.y)))||"",opacity:1,stroke:L[i],transition:{duration:s.duration}}},strokeDasharray:B.includes(R[i])?ee[i%ee.length]:void 0,initial:"initial",animate:u?"whileInView":"initial"}),e.map((n,U)=>t.jsxRuntimeExports.jsx("g",{children:h.checkIfNullOrUndefined(n.y)?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[ge?t.jsxRuntimeExports.jsx(T.motion.circle,{r:p/r.length<5?0:p/r.length<20?2:4,style:{fill:L[i]},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,cx:a(n.date),cy:o(n.y)},whileInView:{opacity:1,transition:{duration:O?s.duration:.5,delay:O?0:s.duration},cx:a(n.date),cy:o(n.y)}},initial:"initial",animate:u?"whileInView":"initial"}):null,k?t.jsxRuntimeExports.jsx(T.motion.text,{dy:-8,style:{fill:L[i],textAnchor:"middle",...c?.graphObjectValues||{}},className:t.mo("graph-value text-xs font-bold",y?.graphObjectValues),exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,x:a(n.date),y:o(n.y)},whileInView:{opacity:1,x:a(n.date),y:o(n.y),transition:{duration:O?s.duration:.5,delay:O?0:s.duration}}},initial:"initial",animate:u?"whileInView":"initial",children:Ne.numberFormattingFunction(n.y,"NA",H,V,M)}):null]})},U)),me||we.includes(R[i])?null:t.jsxRuntimeExports.jsx(T.motion.text,{style:{fill:L[i]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,x:a(e[e.length-1].date),y:o(e[e.length-1].y)},whileInView:{opacity:1,x:a(e[e.length-1].date),y:o(e[e.length-1].y),transition:{duration:O?s.duration:.5,delay:O?0:s.duration}}},initial:"initial",animate:u?"whileInView":"initial",children:R[i]})]},R[i])),j?t.jsxRuntimeExports.jsx("line",{y1:0,y2:g,x1:a(j.date),x2:a(j.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",y?.mouseOverLine),style:c?.mouseOverLine}):null]}),J?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:J.map((e,i)=>t.jsxRuntimeExports.jsx($e.RefLineY,{text:e.text,color:e.color,y:o(e.value),x1:0-E,x2:p+w.right,classNames:e.classNames,styles:e.styles,animate:s,isInView:u},i))}):null,t.jsxRuntimeExports.jsx("g",{children:fe.map((e,i)=>{const n=be.getLineEndPoint({x:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?o(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date)):0,y:e.yCoordinate?o(e.yCoordinate):0},h.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),U=e.showConnector?{y1:n.y,x1:n.x,y2:e.yCoordinate?o(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0),cy:e.yCoordinate?o(e.yCoordinate):0,cx:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date)):0,circleRadius:h.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,Oe={y:e.yCoordinate?o(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:W?0:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:W?e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0):p+w.right-(e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(be.Annotation,{color:e.color,connectorsSettings:U,labelSettings:Oe,text:e.text,classNames:e.classNames,styles:e.styles,animate:s,isInView:u},i)})}),Z.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:z,style:{fill:"none",pointerEvents:"all"},width:p,height:g})]})}),j&&G&&ne&&re?t.jsxRuntimeExports.jsx(Se.Tooltip,{data:j,body:G,xPos:ne,yPos:re,backgroundStyle:c?.tooltip,className:y?.tooltip}):null]})}function Qe(ue){const{data:N,graphTitle:A,lineColors:q=ze.Colors.light.categoricalColors.colors,suffix:L="",sources:l,prefix:de="",graphDescription:R,height:$,width:x,footNote:_,noOfXTicks:M=10,dateFormat:V="yyyy",labels:E,padding:G,showValues:P=!1,backgroundColor:k=!1,leftMargin:me=30,rightMargin:J=50,topMargin:he=20,bottomMargin:F=25,tooltip:K,relativeHeight:b,onSeriesMouseOver:s,showColorLegendAtTop:W=!1,refValues:pe=[],highlightAreaSettings:ge=[],graphID:fe,minValue:ye,maxValue:Q,highlightedLines:je=[],graphDownload:Y=!1,dataDownload:X=!1,animate:I=!1,language:c="en",colorLegendTitle:y,minHeight:S=0,strokeWidth:H=2,showDots:Z=!0,annotations:B=[],customHighlightAreaSettings:ee=[],theme:we="light",ariaLabel:te,yAxisTitle:ie,noOfYTicks:u=5,minDate:O,maxDate:ve,curveType:Re="curve",styles:j,classNames:C,dimmedOpacity:ne=.3,precision:se=2,customLayers:re=[],dashedLines:ae=[],dashSettings:w=["5 5"],labelsToBeHidden:z=[],showColorScale:r=!0}=ue,[D,oe]=f.useState(0),[le,p]=f.useState(0),g=f.useRef(null),ce=f.useRef(null);return f.useEffect(()=>{const d=new ResizeObserver(v=>{oe(x||v[0].target.clientWidth||620),p($||v[0].target.clientHeight||480)});return g.current&&(p(g.current.clientHeight||480),oe(g.current.clientWidth||620),x||d.observe(g.current)),()=>d.disconnect()},[x,$]),t.jsxRuntimeExports.jsx("div",{className:`${we||"light"} flex ${x?"w-fit grow-0":"w-full grow"}`,dir:c==="he"||c==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${k?k===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${c||"en"}`,x?"w-fit":"w-full",C?.graphContainer),style:{...j?.graphContainer||{},...k&&k!==!0?{backgroundColor:k}:{}},id:fe,ref:ce,"aria-label":te||`${A?`The graph shows ${A}. `:""}This is a multi-line chart that shows trends over time.${R?` ${R}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:k?G||"1rem":G||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[A||R||Y||X?t.jsxRuntimeExports.jsx(Xe.GraphHeader,{styles:{title:j?.title,description:j?.description},classNames:{title:C?.title,description:C?.description},graphTitle:A,graphDescription:R,width:x,graphDownload:Y?ce.current:void 0,dataDownload:X?N.map(d=>d.data).filter(d=>d!==void 0).length>0?N.map(d=>d.data).filter(d=>d!==void 0):N.filter(d=>d!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:N.length===0?t.jsxRuntimeExports.jsx(_e.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[W&&r?t.jsxRuntimeExports.jsx(Be.ColorLegend,{colorDomain:E,colorLegendTitle:y,labelsToBeHidden:z,colors:q,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:g,"aria-label":"Graph area",children:(x||D)&&($||le)?t.jsxRuntimeExports.jsx(Ke,{data:N,lineColors:q,width:x||D,height:Math.max(S,$||(b?S?(x||D)*b>S?(x||D)*b:S:(x||D)*b:le)),dateFormat:V,noOfXTicks:M,leftMargin:me,rightMargin:J,topMargin:he,bottomMargin:F,labels:E,tooltip:K,onSeriesMouseOver:s,showColorLegendAtTop:r?W:!0,showValues:P,suffix:L,prefix:de,highlightAreaSettings:ge,refValues:pe,minValue:ye,maxValue:Q,highlightedLines:je,animate:I===!0?{duration:.5,once:!0,amount:.5}:I||{duration:0,once:!0,amount:0},rtl:c==="he"||c==="ar",strokeWidth:H,showDots:Z,annotations:B,customHighlightAreaSettings:ee,yAxisTitle:ie,noOfYTicks:u,minDate:O,maxDate:ve,curveType:Re,styles:j,classNames:C,dimmedOpacity:ne,precision:se,customLayers:re,labelsToBeHidden:z,dashedLines:ae,dashSettings:w,revealClipId:Je.generateRandomString(8)}):null})]})}),l||_?t.jsxRuntimeExports.jsx(Ye.GraphFooter,{styles:{footnote:j?.footnote,source:j?.source},classNames:{footnote:C?.footnote,source:C?.source},sources:l,footNote:_,width:x}):null]})})})})}exports.MultiLineChart=Qe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),f=require("react"),m=require("./parse-hMnG_lRV.cjs"),Ie=require("./index-BzeLQvXk.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),Se=require("./Tooltip-n8z5bfav.cjs"),h=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),be=require("./customArea-CK768gCn.cjs"),De=require("./AxisTitle-CK9YeovX.cjs"),Te=require("./Axis-DE7dSn1_.cjs"),qe=require("./XTicksAndGridLines-CCzXIV8d.cjs"),$e=require("./ReferenceLine-CFVBBN__.cjs"),Me=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Ve=require("./index-BYzIB5V6.cjs"),Fe=require("./time-Byw_jYQ7.cjs"),He=require("./linear-BVckp9RD.cjs"),Le=require("./line-DHV4JwCR.cjs"),xe=require("./step-BZ3C8QFW.cjs"),Ue=require("./select-Bnfk0lJx.cjs"),Ge=require("./init-DU0ybBc_.cjs"),Pe=require("./pointer-Dkq5NV1q.cjs"),We=require("./use-in-view-sQJZ_xDO.cjs"),T=require("./proxy-BHRoeZgd.cjs"),Ye=require("./GraphFooter.cjs"),Xe=require("./GraphHeader.cjs"),Be=require("./ColorLegend.cjs"),ze=require("./Colors.cjs"),_e=require("./EmptyState-d8_8SxeW.cjs"),Je=require("./generateRandomString-B5zBiJzS.cjs");function Ke(ue){const{data:N,width:A,height:q,lineColors:L,dateFormat:l,noOfXTicks:de,labels:R,rightMargin:$,topMargin:x,bottomMargin:_,suffix:M,prefix:V,leftMargin:E,tooltip:G,onSeriesMouseOver:P,showValues:k,showColorLegendAtTop:me,refValues:J,highlightAreaSettings:he,minValue:F,maxValue:K,highlightedLines:b,animate:s,rtl:W,strokeWidth:pe,showDots:ge,annotations:fe,customHighlightAreaSettings:ye,yAxisTitle:Q,noOfYTicks:je,minDate:Y,maxDate:X,curveType:I,styles:c,classNames:y,dimmedOpacity:S,precision:H,customLayers:Z,dashedLines:B,dashSettings:ee,labelsToBeHidden:we,revealClipId:te}=ue,ie=f.useRef(null),u=We.useInView(ie,{once:s.once,amount:s.amount}),[O,ve]=f.useState(!1);f.useEffect(()=>{if(u&&!O){const e=setTimeout(()=>{ve(!0)},(s.duration+.5)*1e3);return()=>clearTimeout(e)}},[u,O,s.duration]);const Re=I==="linear"?Le.curveLinear:I==="step"?xe.curveStep:I==="stepAfter"?xe.stepAfter:I==="stepBefore"?xe.stepBefore:xe.monotoneX,[j,C]=f.useState(void 0),[ne,se]=f.useState(void 0),[re,ae]=f.useState(void 0),w={top:x,bottom:_,left:Q?E+30:E,right:$},z=f.useRef(null),r=Ie.sortBy(N.map(e=>({...e,date:m.parse(`${e.date}`,l,new Date)})),"date"),D=r[0].y.map((e,i)=>r.map(n=>({...n,y:n.y[i]})).filter(n=>!h.checkIfNullOrUndefined(n.y))),oe=he.map(e=>({...e,coordinates:[e.coordinates[0]===null?null:m.parse(`${e.coordinates[0]}`,l,new Date),e.coordinates[1]===null?null:m.parse(`${e.coordinates[1]}`,l,new Date)]})),le=ye.map(e=>({...e,coordinates:e.coordinates.map((i,n)=>n%2===0?m.parse(`${i}`,l,new Date):i)})),p=A-w.left-w.right,g=q-w.top-w.bottom,ce=Y?m.parse(`${Y}`,l,new Date):r[0].date,d=X?m.parse(`${X}`,l,new Date):r[r.length-1].date,v=h.checkIfNullOrUndefined(F)?Math.min(...r.map(e=>Math.min(...e.y.filter(i=>!h.checkIfNullOrUndefined(i)))))?Math.min(...r.map(e=>Math.min(...e.y.filter(i=>!h.checkIfNullOrUndefined(i)))))>0?0:Math.min(...r.map(e=>Math.min(...e.y.filter(i=>!h.checkIfNullOrUndefined(i))))):0:F,Ee=Math.max(...r.map(e=>Math.max(...e.y.filter(i=>!h.checkIfNullOrUndefined(i)))))?Math.max(...r.map(e=>Math.max(...e.y.filter(i=>!h.checkIfNullOrUndefined(i))))):0,a=Fe.time().domain([ce,d]).range([0,p]),o=He.linear().domain([h.checkIfNullOrUndefined(F)?v:F,h.checkIfNullOrUndefined(K)?Ee>0?Ee:0:K]).range([g,0]).nice(),Ce=Le.line().x(e=>a(e.date)).y(e=>o(e.y)).curve(Re),Ae=o.ticks(je),ke=a.ticks(de);return f.useEffect(()=>{const e=n=>{const U=r[Ge.bisectCenter(r.map(Oe=>Oe.date),a.invert(Pe.pointer(n)[0]),0)];C(U||r[r.length-1]),ae(n.clientY),se(n.clientX),P?.(U||r[r.length-1])},i=()=>{C(void 0),se(void 0),ae(void 0)};Ue.select(z.current).on("mousemove",e).on("mouseout",i),P?.(void 0)},[a,r,P]),t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(T.motion.svg,{width:`${A}px`,height:`${q}px`,viewBox:`0 0 ${A} ${q}`,direction:"ltr",ref:ie,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${w.left},${w.top})`,children:[t.jsxRuntimeExports.jsx("defs",{children:t.jsxRuntimeExports.jsx("clipPath",{id:te,children:t.jsxRuntimeExports.jsx(T.motion.rect,{x:0,y:0,height:g,variants:{initial:{width:0},whileInView:{width:p,transition:{duration:s.duration}}},initial:"initial",animate:u?"whileInView":"initial"})})}),t.jsxRuntimeExports.jsx(Ve.HighlightArea,{areaSettings:oe,width:p,height:g,scale:a,animate:s,isInView:u}),t.jsxRuntimeExports.jsx(be.CustomArea,{areaSettings:le,scaleX:a,scaleY:o,animate:s,isInView:u}),t.jsxRuntimeExports.jsxs("g",{children:[t.jsxRuntimeExports.jsx(Me.YTicksAndGridLines,{values:Ae.filter(e=>e!==0),y:Ae.filter(e=>e!==0).map(e=>o(e)),x1:0-E,x2:p+w.right,styles:{gridLines:c?.yAxis?.gridLines,labels:c?.yAxis?.labels},classNames:{gridLines:y?.yAxis?.gridLines,labels:y?.yAxis?.labels},suffix:M,prefix:V,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:H}),t.jsxRuntimeExports.jsx(Te.Axis,{y1:o(v<0?0:v),y2:o(v<0?0:v),x1:0-E,x2:p+w.right,label:Ne.numberFormattingFunction(v<0?0:v,"NA",H,V,M),labelPos:{x:0-E,y:o(v<0?0:v),dx:0,dy:Ee<0?"1em":-5},classNames:{axis:y?.xAxis?.axis,label:y?.yAxis?.labels},styles:{axis:c?.xAxis?.axis,label:c?.yAxis?.labels}}),t.jsxRuntimeExports.jsx(De.AxisTitle,{x:0-E-15,y:g/2,style:c?.yAxis?.title,className:y?.yAxis?.title,text:Q,rotate90:!0})]}),t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx(qe.XTicksAndGridLines,{values:ke.map(e=>m.format(e,l)),x:ke.map(e=>a(e)),y1:0,y2:g,styles:{gridLines:c?.xAxis?.gridLines,labels:c?.xAxis?.labels},classNames:{gridLines:t.mo("opacity-0",y?.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",y?.xAxis?.labels)},suffix:M,prefix:V,labelType:"primary",showGridLines:!0,precision:H})}),Z.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{children:[D.map((e,i)=>t.jsxRuntimeExports.jsxs(T.motion.g,{exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:b.length!==0?b.indexOf(R[i])!==-1?1:S:1},whileInView:{opacity:b.length!==0?b.indexOf(R[i])!==-1?1:S:1,transition:{duration:s.duration}}},initial:"initial",animate:u?"whileInView":"initial",children:[t.jsxRuntimeExports.jsx(T.motion.path,{style:{fill:"none",strokeWidth:pe},clipPath:`url(#${te})`,exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{...B.length===0?{pathLength:0}:{},d:Ce(e.filter(n=>!h.checkIfNullOrUndefined(n.y)))||"",opacity:1,stroke:L[i]},whileInView:{...B.length===0?{pathLength:1}:{},d:Ce(e.filter(n=>!h.checkIfNullOrUndefined(n.y)))||"",opacity:1,stroke:L[i],transition:{duration:s.duration}}},strokeDasharray:B.includes(R[i])?ee[i%ee.length]:void 0,initial:"initial",animate:u?"whileInView":"initial"}),e.map((n,U)=>t.jsxRuntimeExports.jsx("g",{children:h.checkIfNullOrUndefined(n.y)?null:t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[ge?t.jsxRuntimeExports.jsx(T.motion.circle,{r:p/r.length<5?0:p/r.length<20?2:4,style:{fill:L[i]},exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,cx:a(n.date),cy:o(n.y)},whileInView:{opacity:1,transition:{duration:O?s.duration:.5,delay:O?0:s.duration},cx:a(n.date),cy:o(n.y)}},initial:"initial",animate:u?"whileInView":"initial"}):null,k?t.jsxRuntimeExports.jsx(T.motion.text,{dy:-8,style:{fill:L[i],textAnchor:"middle",...c?.graphObjectValues||{}},className:t.mo("graph-value text-xs font-bold",y?.graphObjectValues),exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,x:a(n.date),y:o(n.y)},whileInView:{opacity:1,x:a(n.date),y:o(n.y),transition:{duration:O?s.duration:.5,delay:O?0:s.duration}}},initial:"initial",animate:u?"whileInView":"initial",children:Ne.numberFormattingFunction(n.y,"NA",H,V,M)}):null]})},U)),me||we.includes(R[i])?null:t.jsxRuntimeExports.jsx(T.motion.text,{style:{fill:L[i]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:s.duration}},variants:{initial:{opacity:0,x:a(e[e.length-1].date),y:o(e[e.length-1].y)},whileInView:{opacity:1,x:a(e[e.length-1].date),y:o(e[e.length-1].y),transition:{duration:O?s.duration:.5,delay:O?0:s.duration}}},initial:"initial",animate:u?"whileInView":"initial",children:R[i]})]},R[i])),j?t.jsxRuntimeExports.jsx("line",{y1:0,y2:g,x1:a(j.date),x2:a(j.date),className:t.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",y?.mouseOverLine),style:c?.mouseOverLine}):null]}),J?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:J.map((e,i)=>t.jsxRuntimeExports.jsx($e.RefLineY,{text:e.text,color:e.color,y:o(e.value),x1:0-E,x2:p+w.right,classNames:e.classNames,styles:e.styles,animate:s,isInView:u},i))}):null,t.jsxRuntimeExports.jsx("g",{children:fe.map((e,i)=>{const n=be.getLineEndPoint({x:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?o(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date)):0,y:e.yCoordinate?o(e.yCoordinate):0},h.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),U=e.showConnector?{y1:n.y,x1:n.x,y2:e.yCoordinate?o(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0),cy:e.yCoordinate?o(e.yCoordinate):0,cx:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date)):0,circleRadius:h.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,Oe={y:e.yCoordinate?o(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:W?0:e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0),width:W?e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0):p+w.right-(e.xCoordinate?a(m.parse(`${e.xCoordinate}`,l,new Date))+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return t.jsxRuntimeExports.jsx(be.Annotation,{color:e.color,connectorsSettings:U,labelSettings:Oe,text:e.text,classNames:e.classNames,styles:e.styles,animate:s,isInView:u},i)})}),Z.filter(e=>e.position==="after").map(e=>e.layer),t.jsxRuntimeExports.jsx("rect",{ref:z,style:{fill:"none",pointerEvents:"all"},width:p,height:g})]})}),j&&G&&ne&&re?t.jsxRuntimeExports.jsx(Se.Tooltip,{data:j,body:G,xPos:ne,yPos:re,backgroundStyle:c?.tooltip,className:y?.tooltip}):null]})}function Qe(ue){const{data:N,graphTitle:A,lineColors:q=ze.Colors.light.categoricalColors.colors,suffix:L="",sources:l,prefix:de="",graphDescription:R,height:$,width:x,footNote:_,noOfXTicks:M=10,dateFormat:V="yyyy",labels:E,padding:G,showValues:P=!1,backgroundColor:k=!1,leftMargin:me=30,rightMargin:J=50,topMargin:he=20,bottomMargin:F=25,tooltip:K,relativeHeight:b,onSeriesMouseOver:s,showColorLegendAtTop:W=!1,refValues:pe=[],highlightAreaSettings:ge=[],graphID:fe,minValue:ye,maxValue:Q,highlightedLines:je=[],graphDownload:Y=!1,dataDownload:X=!1,animate:I=!1,language:c="en",colorLegendTitle:y,minHeight:S=0,strokeWidth:H=2,showDots:Z=!0,annotations:B=[],customHighlightAreaSettings:ee=[],theme:we="light",ariaLabel:te,yAxisTitle:ie,noOfYTicks:u=5,minDate:O,maxDate:ve,curveType:Re="curve",styles:j,classNames:C,dimmedOpacity:ne=.3,precision:se=2,customLayers:re=[],dashedLines:ae=[],dashSettings:w=["5 5"],labelsToBeHidden:z=[],showColorScale:r=!0}=ue,[D,oe]=f.useState(0),[le,p]=f.useState(0),g=f.useRef(null),ce=f.useRef(null);return f.useEffect(()=>{const d=new ResizeObserver(v=>{oe(x||v[0].target.clientWidth||620),p($||v[0].target.clientHeight||480)});return g.current&&(p(g.current.clientHeight||480),oe(g.current.clientWidth||620),x||d.observe(g.current)),()=>d.disconnect()},[x,$]),t.jsxRuntimeExports.jsx("div",{className:`${we||"light"} flex ${x?"w-fit grow-0":"w-full grow"}`,dir:c==="he"||c==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${k?k===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${c||"en"}`,x?"w-fit":"w-full",C?.graphContainer),style:{...j?.graphContainer||{},...k&&k!==!0?{backgroundColor:k}:{}},id:fe,ref:ce,"aria-label":te||`${A?`The graph shows ${A}. `:""}This is a multi-line chart that shows trends over time.${R?` ${R}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:k?G||"1rem":G||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[A||R||Y||X?t.jsxRuntimeExports.jsx(Xe.GraphHeader,{styles:{title:j?.title,description:j?.description},classNames:{title:C?.title,description:C?.description},graphTitle:A,graphDescription:R,width:x,graphDownload:Y?ce.current:void 0,dataDownload:X?N.map(d=>d.data).filter(d=>d!==void 0).length>0?N.map(d=>d.data).filter(d=>d!==void 0):N.filter(d=>d!==void 0):null}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:N.length===0?t.jsxRuntimeExports.jsx(_e.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[W&&r?t.jsxRuntimeExports.jsx(Be.ColorLegend,{colorDomain:E,colorLegendTitle:y,labelsToBeHidden:z,colors:q,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"w-full grow leading-0",ref:g,"aria-label":"Graph area",children:(x||D)&&($||le)?t.jsxRuntimeExports.jsx(Ke,{data:N,lineColors:q,width:x||D,height:Math.max(S,$||(b?S?(x||D)*b>S?(x||D)*b:S:(x||D)*b:le)),dateFormat:V,noOfXTicks:M,leftMargin:me,rightMargin:J,topMargin:he,bottomMargin:F,labels:E,tooltip:K,onSeriesMouseOver:s,showColorLegendAtTop:r?W:!0,showValues:P,suffix:L,prefix:de,highlightAreaSettings:ge,refValues:pe,minValue:ye,maxValue:Q,highlightedLines:je,animate:I===!0?{duration:.5,once:!0,amount:.5}:I||{duration:0,once:!0,amount:0},rtl:c==="he"||c==="ar",strokeWidth:H,showDots:Z,annotations:B,customHighlightAreaSettings:ee,yAxisTitle:ie,noOfYTicks:u,minDate:O,maxDate:ve,curveType:Re,styles:j,classNames:C,dimmedOpacity:ne,precision:se,customLayers:re,labelsToBeHidden:z,dashedLines:ae,dashSettings:w,revealClipId:Je.generateRandomString(8)}):null})]})}),l||_?t.jsxRuntimeExports.jsx(Ye.GraphFooter,{styles:{footnote:j?.footnote,source:j?.source},classNames:{footnote:C?.footnote,source:C?.source},sources:l,footNote:_,width:x}):null]})})})})}exports.MultiLineChart=Qe;
|
|
2
2
|
//# sourceMappingURL=MultiLineChart.cjs.map
|
package/dist/MultiLineChart.js
CHANGED
|
@@ -11,7 +11,7 @@ import { A as Ft } from "./Axis-Ddg-seDi.js";
|
|
|
11
11
|
import { X as Wt } from "./XTicksAndGridLines-Bn9u5gOM.js";
|
|
12
12
|
import { R as Pt } from "./ReferenceLine-CfAW3vKJ.js";
|
|
13
13
|
import { Y as Yt } from "./YTicksAndGridLines-B6ah7CRf.js";
|
|
14
|
-
import { H as Xt } from "./index-
|
|
14
|
+
import { H as Xt } from "./index-DKCxu1Gh.js";
|
|
15
15
|
import { t as Et } from "./time-BzJP5SPC.js";
|
|
16
16
|
import { a as Gt } from "./linear-DUdu7l2G.js";
|
|
17
17
|
import { l as Bt, c as zt } from "./line-CPfhohvF.js";
|