@undp/data-viz 1.5.3 → 1.5.5

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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),y=require("react"),pe=require("./getSliderMarks-CRIbTGYV.cjs"),fe=require("./parse-hMnG_lRV.cjs"),ye=require("./index-DQA8q5sC.cjs"),Me=require("./Modal-tXZlLE5s.cjs"),je=require("./numberFormattingFunction-02t-wJta.cjs"),Ae=require("./Tooltip-De16GWhY.cjs"),Ce=require("./string2HTML-z7CwHXcx.cjs"),be=require("./XTicksAndGridLines-CCzXIV8d.cjs"),ve=require("./Axis-DE7dSn1_.cjs"),Le=require("./YAxesLabels-D8IydyZj.cjs"),we=require("./ReferenceLine-CFVBBN__.cjs"),ke=require("./band-CAApY4Pd.cjs"),Re=require("./linear-BVckp9RD.cjs"),Ne=require("./use-in-view-sQJZ_xDO.cjs"),T=require("./proxy-BHRoeZgd.cjs"),me=require("./index-BW8iNx7E.cjs"),$e=require("./GraphFooter.cjs"),qe=require("./GraphHeader.cjs"),Ve=require("./ColorLegend.cjs"),Ee=require("./Colors.cjs"),Se=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./index-BW_-wD2k.cjs"),de=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Te=require("./ensureCompleteData-DkQYPeDa.cjs"),Oe=require("./uniqBy-O05lp2S5.cjs"),Ie=require("./sort-O96oMZLb.cjs"),De=require("./init-DU0ybBc_.cjs");function Fe(W){const{data:x,width:j,height:R,barColors:u,centerGap:d,refValues:a,maxValue:E,minValue:U,showValues:z,axisTitles:B,rightMargin:ne,leftMargin:oe,topMargin:_,bottomMargin:le,tooltip:J,onSeriesMouseOver:O,barPadding:xe,truncateBy:I,onSeriesMouseClick:k,showTicks:te,suffix:G,prefix:H,resetSelectionOnDoubleClick:ie,detailsOnClick:M,styles:h,classNames:n,noOfTicks:A,animate:m,precision:P,customLayers:se,minValueLeftBar:N,minValueRightBar:$,naLabel:K}=W,Q=y.useRef(null),b=Ne.useInView(Q,{once:m.once,amount:m.amount}),[re,v]=y.useState(void 0),[q,D]=y.useState(void 0),[ae,V]=y.useState(void 0),[C,p]=y.useState(void 0),c={top:_,bottom:le,left:oe,right:ne},L=j-c.left-c.right,w=R-c.top-c.bottom,X=x.map((e,r)=>({...e,id:`${r}`})),s=ke.band().domain(X.map(e=>`${e.id}`)).range([w,0]).paddingInner(xe),l=Re.linear().domain([U,E]).range([0,(L-d)/2]).nice(),S=l.ticks(A),o=Re.linear().domain([U,E]).range([(L-d)/2,0]).nice(),Z=o.ticks(A);return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(T.motion.svg,{width:`${j}px`,height:`${R}px`,viewBox:`0 0 ${j} ${R}`,direction:"ltr",ref:Q,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[se.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{transform:"translate(0,0)",children:[te?t.jsxRuntimeExports.jsx(be.XTicksAndGridLines,{values:Z.filter(e=>e!==0),x:Z.filter(e=>e!==0).map(e=>o(e)),y1:0-_,y2:w+c.bottom,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:n?.xAxis?.gridLines,labels:n?.xAxis?.labels},suffix:G,prefix:H,labelType:"secondary",showGridLines:!0,leftLabel:!0,precision:P}):null,t.jsxRuntimeExports.jsxs(me.AnimatePresence,{children:[X.map((e,r)=>t.jsxRuntimeExports.jsxs(T.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{v(e),p(f.clientY),V(f.clientX),O?.(e)},onClick:()=>{(k||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),k?.(void 0)):(D(e),k?.(e)))},onMouseMove:f=>{v(e),p(f.clientY),V(f.clientX)},onMouseLeave:()=>{v(void 0),V(void 0),p(void 0),O?.(void 0)},children:[e.leftBar?t.jsxRuntimeExports.jsx(T.motion.rect,{y:s(`${r}`),style:{fill:u[0]},height:s.bandwidth(),variants:{initial:{x:o(0),width:0},whileInView:{x:e.leftBar<0?o(0):o(e.leftBar),width:e.leftBar<0?o(e.leftBar)-o(0):o(0)-o(e.leftBar),transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",exit:{x:o(0),width:0,transition:{duration:m.duration}}}):null,z?t.jsxRuntimeExports.jsx(T.motion.text,{y:s(`${r}`)+s.bandwidth()/2,style:{fill:u[0],textAnchor:e.rightBar&&e.rightBar>0?"end":"start",...h?.graphObjectValues||{}},dx:e.rightBar&&e.rightBar>0?-5:5,dy:"0.33em",className:t.mo("graph-value text-sm",n?.graphObjectValues),exit:{opacity:0,transition:{duration:m.duration}},variants:{initial:{x:o(0),opacity:0},whileInView:{x:e.leftBar?o(e.leftBar):o(N<0?0:N),opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",children:je.numberFormattingFunction(e.rightBar,K,P,H,G)}):null]},e.label)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:o(N<0?0:N),x2:o(N<0?0:N),classNames:{axis:n?.yAxis?.axis},styles:{axis:h?.yAxis?.axis}}),a?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:a.map((e,r)=>t.jsxRuntimeExports.jsx(we.RefLineX,{text:e.text,color:e.color,x:o(e.value),y1:0-c.top,y2:w+c.bottom,textSide:"left",classNames:e.classNames,styles:e.styles,animate:m,isInView:b},r))}):null]})]}),t.jsxRuntimeExports.jsxs("g",{transform:`translate(${(L+d)/2},0)`,children:[te?t.jsxRuntimeExports.jsx(be.XTicksAndGridLines,{values:S.filter(e=>e!==0),x:S.filter(e=>e!==0).map(e=>l(e)),y1:0-_,y2:w+c.bottom,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:n?.xAxis?.gridLines,labels:n?.xAxis?.labels},suffix:G,prefix:H,labelType:"secondary",showGridLines:!0,precision:P}):null,t.jsxRuntimeExports.jsxs(me.AnimatePresence,{children:[X.map((e,r)=>t.jsxRuntimeExports.jsxs(T.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{v(e),p(f.clientY),V(f.clientX),O?.(e)},onClick:()=>{(k||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),k?.(void 0)):(D(e),k?.(e)))},onMouseMove:f=>{v(e),p(f.clientY),V(f.clientX)},onMouseLeave:()=>{v(void 0),V(void 0),p(void 0),O?.(void 0)},children:[e.rightBar?t.jsxRuntimeExports.jsx(T.motion.rect,{y:s(`${r}`),style:{fill:u[1]},height:s.bandwidth(),exit:{x:l(0),width:0,transition:{duration:m.duration}},variants:{initial:{x:l(0),width:0},whileInView:{x:e.rightBar>=0?l(0):l(e.rightBar),width:e.rightBar>=0?l(e.rightBar)-l(0):l(0)-l(e.rightBar),transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial"}):null,z?t.jsxRuntimeExports.jsx(T.motion.text,{y:s(`${r}`)+s.bandwidth()/2,style:{fill:u[1],textAnchor:e.rightBar&&e.rightBar<0?"end":"start",...h?.graphObjectValues||{}},className:t.mo("graph-value text-sm",n?.graphObjectValues),dx:e.rightBar&&e.rightBar<0?-5:5,dy:"0.33em",exit:{opacity:0,transition:{duration:m.duration}},variants:{initial:{x:l(0),opacity:0},whileInView:{x:e.rightBar?l(e.rightBar):l($<0?0:$),opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",children:je.numberFormattingFunction(e.rightBar,K,P,H,G)}):null]},r)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:l($<0?0:$),x2:l($<0?0:$),classNames:{axis:n?.yAxis?.axis},styles:{axis:h?.yAxis?.axis}}),a?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:a.map((e,r)=>t.jsxRuntimeExports.jsx(we.RefLineX,{text:e.text,color:e.color,x:l(e.value),y1:0-c.top,y2:w+c.bottom,textSide:"right",classNames:e.classNames,styles:e.styles,animate:m,isInView:b},r))}):null]})]}),t.jsxRuntimeExports.jsx(me.AnimatePresence,{children:t.jsxRuntimeExports.jsx(T.motion.g,{transform:`translate(${L/2},0)`,children:X.map((e,r)=>t.jsxRuntimeExports.jsx(Le.YAxesLabels,{value:`${e.label}`.length<I?`${e.label}`:`${`${e.label}`.substring(0,I)}...`,y:s(`${e.id}`),x:0-d/2,width:d,height:s.bandwidth(),alignment:"center",style:h?.yAxis?.labels,className:n?.yAxis?.labels,animate:m,isInView:b},r))})}),t.jsxRuntimeExports.jsxs("g",{transform:`translate(0,${w})`,children:[t.jsxRuntimeExports.jsx("text",{style:{fill:u[0],textAnchor:"end",...h?.yAxis?.title},className:t.mo("text-base",n?.yAxis?.title),x:L/2-d/2,y:0,dx:-5,dy:20,children:B[0]}),t.jsxRuntimeExports.jsx("text",{style:{fill:u[1],textAnchor:"start",...h?.yAxis?.title},className:t.mo("text-base",n?.yAxis?.title),x:L/2+d/2,y:0,dx:5,dy:20,children:B[1]})]}),se.filter(e=>e.position==="after").map(e=>e.layer)]})}),re&&J&&ae&&C?t.jsxRuntimeExports.jsx(Ae.Tooltip,{data:re,body:J,xPos:ae,yPos:C,backgroundStyle:h?.tooltip,className:n?.tooltip}):null,M&&q!==void 0?t.jsxRuntimeExports.jsx(Me.X,{open:q!==void 0,onClose:()=>{D(void 0)},children:t.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof M=="string"?{__html:Ce.string2HTML(M,q)}:void 0,children:typeof M=="function"?M(q):null})}):null]})}function Y(W,x,j,R){const u=W.map(E=>E[x]).filter(E=>!de.checkIfNullOrUndefined(E)),d=de.checkIfNullOrUndefined(j)?Math.min(...u)>=0?0:Math.min(...u):j,a=de.checkIfNullOrUndefined(R)?Math.max(...u)<0?0:Math.max(...u):R;return{min:d,max:a}}function Ge(W){const{data:x,graphTitle:j,sources:R,graphDescription:u,height:d,width:a,footNote:E,padding:U,barColors:z=[Ee.Colors.light.categoricalColors.colors[0],Ee.Colors.light.categoricalColors.colors[1]],backgroundColor:B=!1,leftMargin:ne=20,rightMargin:oe=20,topMargin:_=25,bottomMargin:le=30,rightBarTitle:J="Right bar graph",leftBarTitle:O="Left bar graph",tooltip:xe,relativeHeight:I,onSeriesMouseOver:k,graphID:te,barPadding:G=.25,truncateBy:H=999,onSeriesMouseClick:ie,centerGap:M=100,showValues:h=!0,maxValue:n,minValue:A,refValues:m=[],suffix:P="",prefix:se="",showTicks:N=!0,showColorScale:$=!1,graphDownload:K=!1,dataDownload:Q=!1,language:b="en",colorLegendTitle:re,minHeight:v=0,theme:q="light",ariaLabel:D,resetSelectionOnDoubleClick:ae=!0,detailsOnClick:V,styles:C,classNames:p,noOfTicks:c=5,animate:L=!1,precision:w=2,customLayers:X=[],timeline:s={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:l="NA"}=W,[S,o]=y.useState(0),[Z,e]=y.useState(0),[r,f]=y.useState(s.autoplay),g=Ie.sort(Oe.uniqBy(x,"date",!0).map(i=>fe.parse(`${i}`,s.dateFormat||"yyyy",new Date).getTime()),(i,F)=>De.ascending(i,F)),[ue,ce]=y.useState(s.autoplay?0:g.length-1),ee=y.useRef(null),he=y.useRef(null);y.useEffect(()=>{const i=new ResizeObserver(F=>{o(a||F[0].target.clientWidth||620),e(d||F[0].target.clientHeight||480)});return ee.current&&(e(ee.current.clientHeight||480),o(ee.current.clientWidth||620),a||i.observe(ee.current)),()=>i.disconnect()},[a,d]),y.useEffect(()=>{const i=setInterval(()=>{ce(F=>F<g.length-1?F+1:0)},(s.speed||2)*1e3);return r||clearInterval(i),()=>clearInterval(i)},[g,r,s.speed]);const ge=pe.getSliderMarks(g,ue,s.showOnlyActiveDate,s.dateFormat||"yyyy");return t.jsxRuntimeExports.jsx("div",{className:`${q||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:b==="he"||b==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${B?B===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${b||"en"}`,a?"w-fit":"w-full",p?.graphContainer),style:{...C?.graphContainer||{},...B&&B!==!0?{backgroundColor:B}:{}},id:te,ref:he,"aria-label":D||`${j?`The graph shows ${j}. `:""}This is a diverging bar chart. ${u?` ${u}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:B?U||"1rem":U||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[j||u||K||Q?t.jsxRuntimeExports.jsx(qe.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:p?.title,description:p?.description},graphTitle:j,graphDescription:u,width:a,graphDownload:K?he.current:void 0,dataDownload:Q?x.map(i=>i.data).filter(i=>i!==void 0).length>0?x.map(i=>i.data).filter(i=>i!==void 0):x.filter(i=>i!==void 0):null}):null,s.enabled&&g.length>0&&ge?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f(!r)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":r?"Click to pause animation":"Click to play animation",children:r?t.jsxRuntimeExports.jsx(Be.Pause,{}):t.jsxRuntimeExports.jsx(Be.Play,{})}),t.jsxRuntimeExports.jsx(pe.xr,{min:g[0],max:g[g.length-1],marks:ge,step:null,defaultValue:g[g.length-1],value:g[ue],onChangeComplete:i=>{ce(g.indexOf(i))},onChange:i=>{ce(g.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:x.length===0?t.jsxRuntimeExports.jsx(Se.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[$?t.jsxRuntimeExports.jsx(Ve.ColorLegend,{colorLegendTitle:re,colorDomain:[O,J],colors:z,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:ee,"aria-label":"Graph area",children:(a||S)&&(d||Z)?t.jsxRuntimeExports.jsx(Fe,{data:Te.ensureCompleteDataForButterFlyChart(x,s.dateFormat||"yyyy").filter(i=>s.enabled?i.date===fe.format(new Date(g[ue]),s.dateFormat||"yyyy"):i),barColors:z,width:a||S,centerGap:M,height:Math.max(v,d||(I?v?(a||S)*I>v?(a||S)*I:v:(a||S)*I:Z)),truncateBy:H,leftMargin:ne,rightMargin:oe,topMargin:_,bottomMargin:le,axisTitles:[O,J],tooltip:xe,onSeriesMouseOver:k,barPadding:G,refValues:m,maxValue:Math.max(Y(x,"leftBar",A,n).max,Y(x,"rightBar",A,n).max),minValue:Math.min(Y(x,"leftBar",A,n).min,Y(x,"rightBar",A,n).min),minValueLeftBar:Y(x,"leftBar",A,n).min,minValueRightBar:Y(x,"rightBar",A,n).min,showValues:h,onSeriesMouseClick:ie,showTicks:N,suffix:P,prefix:se,resetSelectionOnDoubleClick:ae,detailsOnClick:V,styles:C,classNames:p,noOfTicks:c,animate:L===!0?{duration:.5,once:!0,amount:.5}:L||{duration:0,once:!0,amount:0},precision:w,customLayers:X,naLabel:l}):null})]})}),R||E?t.jsxRuntimeExports.jsx($e.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:p?.footnote,source:p?.source},sources:R,footNote:E,width:a}):null]})})})})}exports.ButterflyChart=Ge;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),y=require("react"),pe=require("./getSliderMarks-CRIbTGYV.cjs"),fe=require("./parse-hMnG_lRV.cjs"),ye=require("./index-DQA8q5sC.cjs"),Me=require("./Modal-tXZlLE5s.cjs"),je=require("./numberFormattingFunction-02t-wJta.cjs"),Ae=require("./Tooltip-De16GWhY.cjs"),Ce=require("./string2HTML-z7CwHXcx.cjs"),be=require("./XTicksAndGridLines-CCzXIV8d.cjs"),ve=require("./Axis-DE7dSn1_.cjs"),Le=require("./YAxesLabels-yRFFdx1s.cjs"),we=require("./ReferenceLine-CFVBBN__.cjs"),ke=require("./band-CAApY4Pd.cjs"),Re=require("./linear-BVckp9RD.cjs"),Ne=require("./use-in-view-sQJZ_xDO.cjs"),T=require("./proxy-BHRoeZgd.cjs"),me=require("./index-BW8iNx7E.cjs"),$e=require("./GraphFooter.cjs"),qe=require("./GraphHeader.cjs"),Ve=require("./ColorLegend.cjs"),Ee=require("./Colors.cjs"),Se=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./index-BW_-wD2k.cjs"),de=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Te=require("./ensureCompleteData-DkQYPeDa.cjs"),Oe=require("./uniqBy-O05lp2S5.cjs"),Ie=require("./sort-O96oMZLb.cjs"),De=require("./init-DU0ybBc_.cjs");function Fe(W){const{data:x,width:j,height:R,barColors:u,centerGap:d,refValues:a,maxValue:E,minValue:U,showValues:z,axisTitles:B,rightMargin:ne,leftMargin:oe,topMargin:_,bottomMargin:le,tooltip:J,onSeriesMouseOver:O,barPadding:xe,truncateBy:I,onSeriesMouseClick:k,showTicks:te,suffix:G,prefix:H,resetSelectionOnDoubleClick:ie,detailsOnClick:M,styles:h,classNames:n,noOfTicks:A,animate:m,precision:P,customLayers:se,minValueLeftBar:N,minValueRightBar:$,naLabel:K}=W,Q=y.useRef(null),b=Ne.useInView(Q,{once:m.once,amount:m.amount}),[re,v]=y.useState(void 0),[q,D]=y.useState(void 0),[ae,V]=y.useState(void 0),[C,p]=y.useState(void 0),c={top:_,bottom:le,left:oe,right:ne},L=j-c.left-c.right,w=R-c.top-c.bottom,X=x.map((e,r)=>({...e,id:`${r}`})),s=ke.band().domain(X.map(e=>`${e.id}`)).range([w,0]).paddingInner(xe),l=Re.linear().domain([U,E]).range([0,(L-d)/2]).nice(),S=l.ticks(A),o=Re.linear().domain([U,E]).range([(L-d)/2,0]).nice(),Z=o.ticks(A);return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx(T.motion.svg,{width:`${j}px`,height:`${R}px`,viewBox:`0 0 ${j} ${R}`,direction:"ltr",ref:Q,children:t.jsxRuntimeExports.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[se.filter(e=>e.position==="before").map(e=>e.layer),t.jsxRuntimeExports.jsxs("g",{transform:"translate(0,0)",children:[te?t.jsxRuntimeExports.jsx(be.XTicksAndGridLines,{values:Z.filter(e=>e!==0),x:Z.filter(e=>e!==0).map(e=>o(e)),y1:0-_,y2:w+c.bottom,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:n?.xAxis?.gridLines,labels:n?.xAxis?.labels},suffix:G,prefix:H,labelType:"secondary",showGridLines:!0,leftLabel:!0,precision:P}):null,t.jsxRuntimeExports.jsxs(me.AnimatePresence,{children:[X.map((e,r)=>t.jsxRuntimeExports.jsxs(T.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{v(e),p(f.clientY),V(f.clientX),O?.(e)},onClick:()=>{(k||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),k?.(void 0)):(D(e),k?.(e)))},onMouseMove:f=>{v(e),p(f.clientY),V(f.clientX)},onMouseLeave:()=>{v(void 0),V(void 0),p(void 0),O?.(void 0)},children:[e.leftBar?t.jsxRuntimeExports.jsx(T.motion.rect,{y:s(`${r}`),style:{fill:u[0]},height:s.bandwidth(),variants:{initial:{x:o(0),width:0},whileInView:{x:e.leftBar<0?o(0):o(e.leftBar),width:e.leftBar<0?o(e.leftBar)-o(0):o(0)-o(e.leftBar),transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",exit:{x:o(0),width:0,transition:{duration:m.duration}}}):null,z?t.jsxRuntimeExports.jsx(T.motion.text,{y:s(`${r}`)+s.bandwidth()/2,style:{fill:u[0],textAnchor:e.rightBar&&e.rightBar>0?"end":"start",...h?.graphObjectValues||{}},dx:e.rightBar&&e.rightBar>0?-5:5,dy:"0.33em",className:t.mo("graph-value text-sm",n?.graphObjectValues),exit:{opacity:0,transition:{duration:m.duration}},variants:{initial:{x:o(0),opacity:0},whileInView:{x:e.leftBar?o(e.leftBar):o(N<0?0:N),opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",children:je.numberFormattingFunction(e.rightBar,K,P,H,G)}):null]},e.label)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:o(N<0?0:N),x2:o(N<0?0:N),classNames:{axis:n?.yAxis?.axis},styles:{axis:h?.yAxis?.axis}}),a?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:a.map((e,r)=>t.jsxRuntimeExports.jsx(we.RefLineX,{text:e.text,color:e.color,x:o(e.value),y1:0-c.top,y2:w+c.bottom,textSide:"left",classNames:e.classNames,styles:e.styles,animate:m,isInView:b},r))}):null]})]}),t.jsxRuntimeExports.jsxs("g",{transform:`translate(${(L+d)/2},0)`,children:[te?t.jsxRuntimeExports.jsx(be.XTicksAndGridLines,{values:S.filter(e=>e!==0),x:S.filter(e=>e!==0).map(e=>l(e)),y1:0-_,y2:w+c.bottom,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:n?.xAxis?.gridLines,labels:n?.xAxis?.labels},suffix:G,prefix:H,labelType:"secondary",showGridLines:!0,precision:P}):null,t.jsxRuntimeExports.jsxs(me.AnimatePresence,{children:[X.map((e,r)=>t.jsxRuntimeExports.jsxs(T.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{v(e),p(f.clientY),V(f.clientX),O?.(e)},onClick:()=>{(k||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),k?.(void 0)):(D(e),k?.(e)))},onMouseMove:f=>{v(e),p(f.clientY),V(f.clientX)},onMouseLeave:()=>{v(void 0),V(void 0),p(void 0),O?.(void 0)},children:[e.rightBar?t.jsxRuntimeExports.jsx(T.motion.rect,{y:s(`${r}`),style:{fill:u[1]},height:s.bandwidth(),exit:{x:l(0),width:0,transition:{duration:m.duration}},variants:{initial:{x:l(0),width:0},whileInView:{x:e.rightBar>=0?l(0):l(e.rightBar),width:e.rightBar>=0?l(e.rightBar)-l(0):l(0)-l(e.rightBar),transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial"}):null,z?t.jsxRuntimeExports.jsx(T.motion.text,{y:s(`${r}`)+s.bandwidth()/2,style:{fill:u[1],textAnchor:e.rightBar&&e.rightBar<0?"end":"start",...h?.graphObjectValues||{}},className:t.mo("graph-value text-sm",n?.graphObjectValues),dx:e.rightBar&&e.rightBar<0?-5:5,dy:"0.33em",exit:{opacity:0,transition:{duration:m.duration}},variants:{initial:{x:l(0),opacity:0},whileInView:{x:e.rightBar?l(e.rightBar):l($<0?0:$),opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:b?"whileInView":"initial",children:je.numberFormattingFunction(e.rightBar,K,P,H,G)}):null]},r)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:l($<0?0:$),x2:l($<0?0:$),classNames:{axis:n?.yAxis?.axis},styles:{axis:h?.yAxis?.axis}}),a?t.jsxRuntimeExports.jsx(t.jsxRuntimeExports.Fragment,{children:a.map((e,r)=>t.jsxRuntimeExports.jsx(we.RefLineX,{text:e.text,color:e.color,x:l(e.value),y1:0-c.top,y2:w+c.bottom,textSide:"right",classNames:e.classNames,styles:e.styles,animate:m,isInView:b},r))}):null]})]}),t.jsxRuntimeExports.jsx(me.AnimatePresence,{children:t.jsxRuntimeExports.jsx(T.motion.g,{transform:`translate(${L/2},0)`,children:X.map((e,r)=>t.jsxRuntimeExports.jsx(Le.YAxesLabels,{value:`${e.label}`.length<I?`${e.label}`:`${`${e.label}`.substring(0,I)}...`,y:s(`${e.id}`),x:0-d/2,width:d,height:s.bandwidth(),alignment:"center",style:h?.yAxis?.labels,className:n?.yAxis?.labels,animate:m,isInView:b},r))})}),t.jsxRuntimeExports.jsxs("g",{transform:`translate(0,${w})`,children:[t.jsxRuntimeExports.jsx("text",{style:{fill:u[0],textAnchor:"end",...h?.yAxis?.title},className:t.mo("text-base",n?.yAxis?.title),x:L/2-d/2,y:0,dx:-5,dy:20,children:B[0]}),t.jsxRuntimeExports.jsx("text",{style:{fill:u[1],textAnchor:"start",...h?.yAxis?.title},className:t.mo("text-base",n?.yAxis?.title),x:L/2+d/2,y:0,dx:5,dy:20,children:B[1]})]}),se.filter(e=>e.position==="after").map(e=>e.layer)]})}),re&&J&&ae&&C?t.jsxRuntimeExports.jsx(Ae.Tooltip,{data:re,body:J,xPos:ae,yPos:C,backgroundStyle:h?.tooltip,className:n?.tooltip}):null,M&&q!==void 0?t.jsxRuntimeExports.jsx(Me.X,{open:q!==void 0,onClose:()=>{D(void 0)},children:t.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof M=="string"?{__html:Ce.string2HTML(M,q)}:void 0,children:typeof M=="function"?M(q):null})}):null]})}function Y(W,x,j,R){const u=W.map(E=>E[x]).filter(E=>!de.checkIfNullOrUndefined(E)),d=de.checkIfNullOrUndefined(j)?Math.min(...u)>=0?0:Math.min(...u):j,a=de.checkIfNullOrUndefined(R)?Math.max(...u)<0?0:Math.max(...u):R;return{min:d,max:a}}function Ge(W){const{data:x,graphTitle:j,sources:R,graphDescription:u,height:d,width:a,footNote:E,padding:U,barColors:z=[Ee.Colors.light.categoricalColors.colors[0],Ee.Colors.light.categoricalColors.colors[1]],backgroundColor:B=!1,leftMargin:ne=20,rightMargin:oe=20,topMargin:_=25,bottomMargin:le=30,rightBarTitle:J="Right bar graph",leftBarTitle:O="Left bar graph",tooltip:xe,relativeHeight:I,onSeriesMouseOver:k,graphID:te,barPadding:G=.25,truncateBy:H=999,onSeriesMouseClick:ie,centerGap:M=100,showValues:h=!0,maxValue:n,minValue:A,refValues:m=[],suffix:P="",prefix:se="",showTicks:N=!0,showColorScale:$=!1,graphDownload:K=!1,dataDownload:Q=!1,language:b="en",colorLegendTitle:re,minHeight:v=0,theme:q="light",ariaLabel:D,resetSelectionOnDoubleClick:ae=!0,detailsOnClick:V,styles:C,classNames:p,noOfTicks:c=5,animate:L=!1,precision:w=2,customLayers:X=[],timeline:s={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},naLabel:l="NA"}=W,[S,o]=y.useState(0),[Z,e]=y.useState(0),[r,f]=y.useState(s.autoplay),g=Ie.sort(Oe.uniqBy(x,"date",!0).map(i=>fe.parse(`${i}`,s.dateFormat||"yyyy",new Date).getTime()),(i,F)=>De.ascending(i,F)),[ue,ce]=y.useState(s.autoplay?0:g.length-1),ee=y.useRef(null),he=y.useRef(null);y.useEffect(()=>{const i=new ResizeObserver(F=>{o(a||F[0].target.clientWidth||620),e(d||F[0].target.clientHeight||480)});return ee.current&&(e(ee.current.clientHeight||480),o(ee.current.clientWidth||620),a||i.observe(ee.current)),()=>i.disconnect()},[a,d]),y.useEffect(()=>{const i=setInterval(()=>{ce(F=>F<g.length-1?F+1:0)},(s.speed||2)*1e3);return r||clearInterval(i),()=>clearInterval(i)},[g,r,s.speed]);const ge=pe.getSliderMarks(g,ue,s.showOnlyActiveDate,s.dateFormat||"yyyy");return t.jsxRuntimeExports.jsx("div",{className:`${q||"light"} flex ${a?"w-fit grow-0":"w-full grow"}`,dir:b==="he"||b==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${B?B===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${b||"en"}`,a?"w-fit":"w-full",p?.graphContainer),style:{...C?.graphContainer||{},...B&&B!==!0?{backgroundColor:B}:{}},id:te,ref:he,"aria-label":D||`${j?`The graph shows ${j}. `:""}This is a diverging bar chart. ${u?` ${u}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:B?U||"1rem":U||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[j||u||K||Q?t.jsxRuntimeExports.jsx(qe.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:p?.title,description:p?.description},graphTitle:j,graphDescription:u,width:a,graphDownload:K?he.current:void 0,dataDownload:Q?x.map(i=>i.data).filter(i=>i!==void 0).length>0?x.map(i=>i.data).filter(i=>i!==void 0):x.filter(i=>i!==void 0):null}):null,s.enabled&&g.length>0&&ge?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f(!r)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":r?"Click to pause animation":"Click to play animation",children:r?t.jsxRuntimeExports.jsx(Be.Pause,{}):t.jsxRuntimeExports.jsx(Be.Play,{})}),t.jsxRuntimeExports.jsx(pe.xr,{min:g[0],max:g[g.length-1],marks:ge,step:null,defaultValue:g[g.length-1],value:g[ue],onChangeComplete:i=>{ce(g.indexOf(i))},onChange:i=>{ce(g.indexOf(i))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,t.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:x.length===0?t.jsxRuntimeExports.jsx(Se.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[$?t.jsxRuntimeExports.jsx(Ve.ColorLegend,{colorLegendTitle:re,colorDomain:[O,J],colors:z,showNAColor:!1}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:ee,"aria-label":"Graph area",children:(a||S)&&(d||Z)?t.jsxRuntimeExports.jsx(Fe,{data:Te.ensureCompleteDataForButterFlyChart(x,s.dateFormat||"yyyy").filter(i=>s.enabled?i.date===fe.format(new Date(g[ue]),s.dateFormat||"yyyy"):i),barColors:z,width:a||S,centerGap:M,height:Math.max(v,d||(I?v?(a||S)*I>v?(a||S)*I:v:(a||S)*I:Z)),truncateBy:H,leftMargin:ne,rightMargin:oe,topMargin:_,bottomMargin:le,axisTitles:[O,J],tooltip:xe,onSeriesMouseOver:k,barPadding:G,refValues:m,maxValue:Math.max(Y(x,"leftBar",A,n).max,Y(x,"rightBar",A,n).max),minValue:Math.min(Y(x,"leftBar",A,n).min,Y(x,"rightBar",A,n).min),minValueLeftBar:Y(x,"leftBar",A,n).min,minValueRightBar:Y(x,"rightBar",A,n).min,showValues:h,onSeriesMouseClick:ie,showTicks:N,suffix:P,prefix:se,resetSelectionOnDoubleClick:ae,detailsOnClick:V,styles:C,classNames:p,noOfTicks:c,animate:L===!0?{duration:.5,once:!0,amount:.5}:L||{duration:0,once:!0,amount:0},precision:w,customLayers:X,naLabel:l}):null})]})}),R||E?t.jsxRuntimeExports.jsx($e.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:p?.footnote,source:p?.source},sources:R,footNote:E,width:a}):null]})})})})}exports.ButterflyChart=Ge;
2
2
  //# sourceMappingURL=ButterflyChart.cjs.map
@@ -9,7 +9,7 @@ import { T as Vt } from "./Tooltip-CVCGWyzw.js";
9
9
  import { s as Tt } from "./string2HTML-oFCROsus.js";
10
10
  import { X as wt } from "./XTicksAndGridLines-Bn9u5gOM.js";
11
11
  import { A as jt } from "./Axis-Ddg-seDi.js";
12
- import { Y as Ot } from "./YAxesLabels-CPGZjmZJ.js";
12
+ import { Y as Ot } from "./YAxesLabels-DECkMgq8.js";
13
13
  import { a as Bt } from "./ReferenceLine-CfAW3vKJ.js";
14
14
  import { b as Dt } from "./band-BEjh2CHI.js";
15
15
  import { a as Mt } from "./linear-DUdu7l2G.js";
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),x=require("react"),ve=require("./parse-hMnG_lRV.cjs"),Oe=require("./getSliderMarks-CRIbTGYV.cjs"),Me=require("./index-CQ3e6Ewi.cjs"),Le=require("./index-DQA8q5sC.cjs"),Ve=require("./Modal-tXZlLE5s.cjs"),Te=require("./numberFormattingFunction-02t-wJta.cjs"),$e=require("./Tooltip-De16GWhY.cjs"),A=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ae=require("./string2HTML-z7CwHXcx.cjs"),Ze=require("./XTicksAndGridLines-CCzXIV8d.cjs"),qe=require("./AxisTitle-CK9YeovX.cjs"),et=require("./YAxesLabels-D8IydyZj.cjs"),Fe=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Pe=require("./ReferenceLine-CFVBBN__.cjs"),Be=require("./linear-BVckp9RD.cjs"),He=require("./band-CAApY4Pd.cjs"),We=require("./use-in-view-sQJZ_xDO.cjs"),le=require("./proxy-BHRoeZgd.cjs"),Ue=require("./index-BW8iNx7E.cjs"),Ge=require("./GraphHeader.cjs"),Xe=require("./GraphFooter.cjs"),Ye=require("./ColorLegendWithMouseOver.cjs"),_e=require("./Colors.cjs"),ze=require("./EmptyState-d8_8SxeW.cjs"),Ne=require("./index-BW_-wD2k.cjs"),je=require("./ensureCompleteData-DkQYPeDa.cjs"),Je=require("./uniqBy-O05lp2S5.cjs"),Ke=require("./sort-O96oMZLb.cjs"),Qe=require("./init-DU0ybBc_.cjs"),tt=require("./Axis-DE7dSn1_.cjs"),it=require("./XAxesLabels-OjBNl_lS.cjs");function at(ye){const{data:l,dotColors:g,suffix:_,prefix:z,barPadding:w,showValues:ue,showTicks:Z,leftMargin:ee,truncateBy:ce,width:te,height:ie,rightMargin:J,topMargin:N,bottomMargin:s,radius:q,showLabels:xe,tooltip:O,onSeriesMouseOver:F,maxValue:E,minValue:ae,onSeriesMouseClick:B,selectedColor:I,arrowConnector:R,connectorStrokeWidth:pe,maxBarThickness:re,minBarThickness:ne,resetSelectionOnDoubleClick:ge,detailsOnClick:v,axisTitle:U,noOfTicks:fe,valueColor:se,styles:d,classNames:h,labelOrder:D,refValues:oe,rtl:y,animate:u,precision:M,customLayers:G,highlightedDataPoints:X,dimmedOpacity:L}=ye,j=x.useRef(null),p=We.useInView(j,{once:u.once,amount:u.amount}),m={top:U?N+25:N,bottom:s,left:ee,right:J},H=te-m.left-m.right,W=ie-m.top-m.bottom,[K,P]=x.useState(void 0),[C,b]=x.useState(void 0),[S,Q]=x.useState(void 0),[V,$]=x.useState(void 0),Y=l.map((t,n)=>({...t,id:D?`${t.label}`:`${n}`})),k=D||Y.map(t=>`${t.id}`),f=Be.linear().domain([ae,E]).range([0,H]).nice(),T=He.band().domain(k).range([0,ne?Math.max(W,ne*Y.length):re?Math.min(W,re*Y.length):W]).paddingInner(w),a=f.ticks(fe);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsxs(le.motion.svg,{width:`${te}px`,height:`${ie}px`,viewBox:`0 0 ${te} ${ie}`,direction:"ltr",ref:j,children:[R?i.jsxRuntimeExports.jsx("defs",{children:i.jsxRuntimeExports.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsxRuntimeExports.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,i.jsxRuntimeExports.jsxs("g",{transform:`translate(${m.left},${m.top})`,children:[Z?i.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:a.filter((t,n)=>n!==0),x:a.filter((t,n)=>n!==0).map(t=>f(t)),y1:0-N,y2:W+m.bottom,styles:{gridLines:d?.xAxis?.gridLines,labels:d?.xAxis?.labels},classNames:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},suffix:_,prefix:z,labelType:"secondary",showGridLines:!0,precision:M}):null,i.jsxRuntimeExports.jsx(qe.AxisTitle,{x:H/2,y:0-m.top+15,style:d?.xAxis?.title,className:h?.xAxis?.title,text:U}),i.jsxRuntimeExports.jsx(Fe.YTicksAndGridLines,{y:Y.map(t=>T(`${t.id}`)+T.bandwidth()/2),x1:0,x2:H,styles:{gridLines:d?.yAxis?.gridLines},classNames:{gridLines:h?.yAxis?.gridLines},labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:M}),G.filter(t=>t.position==="before").map(t=>t.layer),i.jsxRuntimeExports.jsxs(Ue.AnimatePresence,{children:[Y.map(t=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{x:0,y:T(`${t.id}`)+T.bandwidth()/2,opacity:X.length!==0?X.indexOf(t.label)!==-1?.85:L:.85},whileInView:{x:0,y:T(`${t.id}`)+T.bandwidth()/2,opacity:X.length!==0?X.indexOf(t.label)!==-1?.85:L:.85,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",exit:{opacity:0,transition:{duration:u.duration}},children:[xe?i.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${t.label}`.length<ce?`${t.label}`:`${`${t.label}`.substring(0,ce)}...`,y:0-T.bandwidth()/2,x:0-m.left,width:m.left,height:T.bandwidth(),alignment:"right",style:d?.yAxis?.labels,className:h?.yAxis?.labels,animate:u,isInView:p}):null,i.jsxRuntimeExports.jsx(le.motion.line,{y1:0,y2:0,style:{strokeWidth:pe,...d?.dataConnectors||{},opacity:I?.3:1},className:i.mo("stroke-primary-gray-600 dark:stroke-primary-gray-300",h?.dataConnectors),markerEnd:R&&t.x.indexOf(Math.min(...t.x.filter(n=>n!==null)))===0?"url(#arrow)":"",markerStart:R&&t.x.indexOf(Math.min(...t.x.filter(n=>n!==null)))===t.x.length-1?"url(#arrow)":"",exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x1:0,x2:0},whileInView:{x1:f(Math.min(...t.x.filter(n=>n!==null)))+q,x2:f(Math.max(...t.x.filter(n=>n!==null)))-q,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}),t.x.map((n,o)=>i.jsxRuntimeExports.jsx(le.motion.g,{onMouseEnter:de=>{P({...t,xIndex:o}),$(de.clientY),Q(de.clientX),F?.({...t,xIndex:o})},onClick:()=>{(B||v)&&(Le.isEqual(C,{...t,xIndex:o})&&ge?(b(void 0),B?.(void 0)):(b({...t,xIndex:o}),B&&B({...t,xIndex:o})))},onMouseMove:de=>{P({...t,xIndex:o}),$(de.clientY),Q(de.clientX)},onMouseLeave:()=>{P(void 0),Q(void 0),$(void 0),F?.(void 0)},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{opacity:I?g[o]===I?1:.3:1},whileInView:{opacity:I?g[o]===I?1:.3:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:A.checkIfNullOrUndefined(n)?null:i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.circle,{cy:0,r:q,style:{fill:g[o],fillOpacity:.85,stroke:g[o],strokeWidth:1,opacity:A.checkIfNullOrUndefined(n)?0:1},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{cx:f(0),opacity:0},whileInView:{cx:f(n||0),opacity:A.checkIfNullOrUndefined(n)?0:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}),ue?i.jsxRuntimeExports.jsx(le.motion.text,{y:0,style:{fill:se||g[o],textAnchor:"middle",...d?.graphObjectValues||{}},dx:0,dy:0-q-3,className:i.mo("graph-value text-sm font-bold",A.checkIfNullOrUndefined(n)?"0opacity-0":"opacity-100",h?.graphObjectValues),exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x:f(0),opacity:0},whileInView:{x:f(n||0),opacity:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:Te.numberFormattingFunction(n,"NA",M,z,_)}):null]})},o))]},t.label)),oe?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:oe.map((t,n)=>i.jsxRuntimeExports.jsx(Pe.RefLineX,{text:t.text,color:t.color,x:f(t.value),y1:0-m.top,y2:W+m.bottom,textSide:f(t.value)>H*.75||y?"left":"right",classNames:t.classNames,styles:t.styles,animate:u,isInView:p},n))}):null]}),G.filter(t=>t.position==="after").map(t=>t.layer)]})]}),K&&O&&S&&V?i.jsxRuntimeExports.jsx($e.Tooltip,{data:K,body:O,xPos:S,yPos:V,backgroundStyle:d?.tooltip,className:h?.tooltip}):null,v&&C!==void 0?i.jsxRuntimeExports.jsx(Ve.X,{open:C!==void 0,onClose:()=>{b(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof v=="string"?{__html:Ae.string2HTML(v,C)}:void 0,children:typeof v=="function"?v(C):null})}):null]})}function rt(ye){const{data:l,graphTitle:g,colors:_=_e.Colors.light.categoricalColors.colors,sources:z,graphDescription:w,barPadding:ue=.25,showTicks:Z=!0,leftMargin:ee=100,rightMargin:ce=40,topMargin:te=20,bottomMargin:ie=10,truncateBy:J=999,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E=!1,radius:ae=3,showLabels:B=!0,tooltip:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne="",prefix:ge="",maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se=!1,dataDownload:d=!1,showValues:h=!0,sortParameter:D,arrowConnector:oe=!1,connectorStrokeWidth:y=2,language:u="en",minHeight:M=0,theme:G="light",labelOrder:X,maxBarThickness:L,maxNumberOfBars:j,minBarThickness:p,ariaLabel:m,resetSelectionOnDoubleClick:H=!0,detailsOnClick:W,axisTitle:K,noOfTicks:P=5,valueColor:C,styles:b,classNames:S,refValues:Q,filterNA:V=!0,animate:$=!1,precision:Y=2,customLayers:k=[],showColorScale:f=!0,highlightedDataPoints:T=[],dimmedOpacity:a=.3,timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},sortData:n}=ye,[o,de]=x.useState(0),[ke,Ee]=x.useState(0),[me,Ie]=x.useState(t.autoplay),c=Ke.sort(Je.uniqBy(l,"date",!0).map(e=>ve.parse(`${e}`,t.dateFormat||"yyyy",new Date).getTime()),(e,r)=>Qe.ascending(e,r)),[be,we]=x.useState(t.autoplay?0:c.length-1),[De,Se]=x.useState(void 0),he=x.useRef(null),Re=x.useRef(null);x.useEffect(()=>{const e=new ResizeObserver(r=>{de(s||r[0].target.clientWidth||620),Ee(N||r[0].target.clientHeight||480)});return he.current&&(Ee(he.current.clientHeight||480),de(he.current.clientWidth||620),s||e.observe(he.current)),()=>e.disconnect()},[s,N]),x.useEffect(()=>{const e=setInterval(()=>{we(r=>r<c.length-1?r+1:0)},(t.speed||2)*1e3);return me||clearInterval(e),()=>clearInterval(e)},[c,me,t.speed]);const Ce=Oe.getSliderMarks(c,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:u==="he"||u==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${E?E===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${u||"en"}`,s?"w-fit":"w-full",S?.graphContainer),style:{...b?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:re,ref:Re,"aria-label":m||`${g?`The graph shows ${g}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${w?` ${w}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?F||"1rem":F||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[g||w||se||d?i.jsxRuntimeExports.jsx(Ge.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:S?.title,description:S?.description},graphTitle:g,graphDescription:w,width:s,graphDownload:se?Re.current:void 0,dataDownload:d?l.map(e=>e.data).filter(e=>e!==void 0).length>0?l.map(e=>e.data).filter(e=>e!==void 0):l.filter(e=>e!==void 0):null}):null,t.enabled&&c.length>0&&Ce?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ie(!me)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":me?"Click to pause animation":"Click to play animation",children:me?i.jsxRuntimeExports.jsx(Ne.Pause,{}):i.jsxRuntimeExports.jsx(Ne.Play,{})}),i.jsxRuntimeExports.jsx(Oe.xr,{min:c[0],max:c[c.length-1],marks:Ce,step:null,defaultValue:c[c.length-1],value:c[be],onChangeComplete:e=>{we(c.indexOf(e))},onChange:e=>{we(c.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?i.jsxRuntimeExports.jsx(ze.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[f?i.jsxRuntimeExports.jsx(Ye.ColorLegendWithMouseOver,{width:s,colorDomain:xe,colors:_,colorLegendTitle:O,setSelectedColor:Se,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:he,"aria-label":"Graph area",children:(s||o)&&(N||ke)?i.jsxRuntimeExports.jsx(at,{data:D!==void 0?D==="diff"?Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[e.x.length-1])||A.checkIfNullOrUndefined(e.x[0])?-1/0:e.x[e.x.length-1]-e.x[0],[n||"asc"]).filter((e,r)=>j?r<j:!0):Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[D])?-1/0:e.x[D],[n||"asc"]).filter((e,r)=>j?r<j:!0):je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>V?!e.x.every(r=>r==null):e).filter((e,r)=>j?r<j:!0),dotColors:_,width:s||o,height:Math.max(M,N||(R?M?(s||o)*R>M?(s||o)*R:M:(s||o)*R:ke)),suffix:ne,prefix:ge,radius:ae,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,showLabels:B,showValues:h,tooltip:I,onSeriesMouseOver:pe,maxValue:A.checkIfNullOrUndefined(v)?Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null))))<0?0:Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null)))):v,minValue:A.checkIfNullOrUndefined(U)?Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null))))>0?0:Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null)))):U,onSeriesMouseClick:fe,selectedColor:De,arrowConnector:oe,connectorStrokeWidth:y,maxBarThickness:L,minBarThickness:p,resetSelectionOnDoubleClick:H,detailsOnClick:W,axisTitle:K,noOfTicks:P,valueColor:C,styles:b,classNames:S,labelOrder:X,refValues:Q,rtl:u==="he"||u==="ar",animate:$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},precision:Y,customLayers:k,highlightedDataPoints:T,dimmedOpacity:a}):null})]})}),z||q?i.jsxRuntimeExports.jsx(Xe.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:S?.footnote,source:S?.source},sources:z,footNote:q,width:s}):null]})})})})}function nt(ye){const{data:l,dotColors:g,barPadding:_,showTicks:z,leftMargin:w,truncateBy:ue,width:Z,height:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,radius:J,showLabels:N,tooltip:s,onSeriesMouseOver:q,maxValue:xe,minValue:O,onSeriesMouseClick:F,showValues:E,suffix:ae,prefix:B,selectedColor:I,arrowConnector:R,connectorStrokeWidth:pe,maxBarThickness:re,minBarThickness:ne,resetSelectionOnDoubleClick:ge,detailsOnClick:v,axisTitle:U,noOfTicks:fe,valueColor:se,styles:d,classNames:h,labelOrder:D,refValues:oe,animate:y,precision:u,customLayers:M,highlightedDataPoints:G,dimmedOpacity:X}=ye,L=x.useRef(null),j=We.useInView(L,{once:y.once,amount:y.amount}),p={top:te,bottom:ie,left:U?w+30:w,right:ce},m=Z-p.left-p.right,H=ee-p.top-p.bottom,[W,K]=x.useState(void 0),[P,C]=x.useState(void 0),[b,S]=x.useState(void 0),[Q,V]=x.useState(void 0),$=l.map((a,t)=>({...a,id:D?`${a.label}`:`${t}`})),Y=D||$.map(a=>`${a.id}`),k=Be.linear().domain([O,xe]).range([H,0]).nice(),f=He.band().domain(Y).range([0,ne?Math.max(m,ne*$.length):re?Math.min(m,re*$.length):m]).paddingInner(_),T=k.ticks(fe);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsxs(le.motion.svg,{width:`${Z}px`,height:`${ee}px`,viewBox:`0 0 ${Z} ${ee}`,direction:"ltr",ref:L,children:[R?i.jsxRuntimeExports.jsx("defs",{children:i.jsxRuntimeExports.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsxRuntimeExports.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,i.jsxRuntimeExports.jsxs("g",{transform:`translate(${p.left},${p.top})`,children:[i.jsxRuntimeExports.jsx(tt.Axis,{y1:k(O<0?0:O),y2:k(O<0?0:O),x1:0-w,x2:m+p.right,label:Te.numberFormattingFunction(O<0?0:O,"NA",u,B,ae),labelPos:{x:0-w,dx:0,dy:xe<0?"1em":-5,y:k(O<0?0:O)},classNames:{axis:h?.xAxis?.axis,label:h?.yAxis?.labels},styles:{axis:d?.xAxis?.axis,label:d?.yAxis?.labels}}),z?i.jsxRuntimeExports.jsx(Fe.YTicksAndGridLines,{values:T.filter(a=>a!==0),y:T.filter(a=>a!==0).map(a=>k(a)),x1:0-w,x2:m+p.right,styles:{gridLines:d?.yAxis?.gridLines,labels:d?.yAxis?.labels},classNames:{gridLines:h?.yAxis?.gridLines,labels:h?.yAxis?.labels},suffix:ae,prefix:B,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:u}):null,i.jsxRuntimeExports.jsx(qe.AxisTitle,{x:0-w-15,y:H/2,style:d?.yAxis?.title,className:h?.yAxis?.title,text:U,rotate90:!0}),M.filter(a=>a.position==="before").map(a=>a.layer),i.jsxRuntimeExports.jsxs(Ue.AnimatePresence,{children:[$.map(a=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{x:f(`${a.id}`)+f.bandwidth()/2,y:0,opacity:G.length!==0?G.indexOf(a.label)!==-1?.85:X:.85},whileInView:{x:f(`${a.id}`)+f.bandwidth()/2,y:0,opacity:G.length!==0?G.indexOf(a.label)!==-1?.85:X:.85,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:y.duration}},children:[N?i.jsxRuntimeExports.jsx(it.XAxesLabels,{value:`${a.label}`.length<ue?`${a.label}`:`${`${a.label}`.substring(0,ue)}...`,y:H+5,x:0-f.bandwidth()/2,width:f.bandwidth(),height:p.bottom,style:d?.xAxis?.labels,className:h?.xAxis?.labels,alignment:"top",animate:y,isInView:j}):null,i.jsxRuntimeExports.jsx(le.motion.line,{x1:0,x2:0,style:{strokeWidth:pe,...d?.dataConnectors||{},opacity:I?.3:1},className:i.mo("stroke-primary-gray-600 dark:stroke-primary-gray-300",h?.dataConnectors),markerEnd:R&&a.x.indexOf(Math.min(...a.x.filter(t=>t!==null)))===0?"url(#arrow)":"",markerStart:R&&a.x.indexOf(Math.min(...a.x.filter(t=>t!==null)))===a.x.length-1?"url(#arrow)":"",exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{y1:0,y2:0},whileInView:{y1:k(Math.min(...a.x.filter(t=>t!==null)))+J,y2:k(Math.max(...a.x.filter(t=>t!==null)))-J,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial"}),a.x.map((t,n)=>i.jsxRuntimeExports.jsx(le.motion.g,{onMouseEnter:o=>{K({...a,xIndex:n}),V(o.clientY),S(o.clientX),q?.({...a,xIndex:n})},onClick:()=>{(F||v)&&(Le.isEqual(P,{...a,xIndex:n})&&ge?(C(void 0),F?.(void 0)):(C({...a,xIndex:n}),F&&F({...a,xIndex:n})))},onMouseMove:o=>{K({...a,xIndex:n}),V(o.clientY),S(o.clientX)},onMouseLeave:()=>{K(void 0),S(void 0),V(void 0),q?.(void 0)},exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{opacity:I?g[n]===I?1:.3:1},whileInView:{opacity:I?g[n]===I?1:.3:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",children:A.checkIfNullOrUndefined(t)?null:i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.circle,{cx:0,r:J,style:{fill:g[n],fillOpacity:.85,stroke:g[n],strokeWidth:1},exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{cy:k(0),opacity:0},whileInView:{cy:k(t||0),opacity:A.checkIfNullOrUndefined(t)?0:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial"}),E?i.jsxRuntimeExports.jsx(le.motion.text,{x:0,style:{fill:se||g[n],textAnchor:"start",...d?.graphObjectValues||{}},className:i.mo("graph-value text-sm font-bold",A.checkIfNullOrUndefined(t)?"opacity-0":"opacity-100",h?.graphObjectValues),dx:J+3,dy:"0.33em",exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{y:k(0),opacity:0},whileInView:{y:k(t||0),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",children:Te.numberFormattingFunction(t,"NA",u,B,ae)}):null]})},n))]},a.label)),oe?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:oe.map((a,t)=>i.jsxRuntimeExports.jsx(Pe.RefLineY,{text:a.text,color:a.color,y:k(a.value),x1:0-w,x2:m+p.right,classNames:a.classNames,styles:a.styles,animate:y,isInView:j},t))}):null]}),M.filter(a=>a.position==="after").map(a=>a.layer)]})]}),W&&s&&b&&Q?i.jsxRuntimeExports.jsx($e.Tooltip,{data:W,body:s,xPos:b,yPos:Q,backgroundStyle:d?.tooltip,className:h?.tooltip}):null,v&&P!==void 0?i.jsxRuntimeExports.jsx(Ve.X,{open:P!==void 0,onClose:()=>{C(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof v=="string"?{__html:Ae.string2HTML(v,P)}:void 0,children:typeof v=="function"?v(P):null})}):null]})}function st(ye){const{data:l,graphTitle:g,colors:_=_e.Colors.light.categoricalColors.colors,sources:z,graphDescription:w,barPadding:ue=.25,showTicks:Z=!0,leftMargin:ee=20,rightMargin:ce=20,topMargin:te=20,bottomMargin:ie=25,truncateBy:J=999,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E=!1,radius:ae=3,tooltip:B,showLabels:I=!0,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne="",prefix:ge="",maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se=!1,dataDownload:d=!1,showValues:h=!0,sortParameter:D,arrowConnector:oe=!1,connectorStrokeWidth:y=2,language:u="en",minHeight:M=0,theme:G="light",maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m=!0,detailsOnClick:H,axisTitle:W,noOfTicks:K=5,valueColor:P,styles:C,classNames:b,labelOrder:S,refValues:Q,filterNA:V=!0,animate:$=!1,precision:Y=2,customLayers:k=[],showColorScale:f=!0,highlightedDataPoints:T=[],dimmedOpacity:a=.3,timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},sortData:n}=ye,[o,de]=x.useState(0),[ke,Ee]=x.useState(0),[me,Ie]=x.useState(t.autoplay),c=Ke.sort(Je.uniqBy(l,"date",!0).map(e=>ve.parse(`${e}`,t.dateFormat||"yyyy",new Date).getTime()),(e,r)=>Qe.ascending(e,r)),[be,we]=x.useState(t.autoplay?0:c.length-1),[De,Se]=x.useState(void 0),he=x.useRef(null),Re=x.useRef(null);x.useEffect(()=>{const e=new ResizeObserver(r=>{de(s||r[0].target.clientWidth||620),Ee(N||r[0].target.clientHeight||480)});return he.current&&(Ee(he.current.clientHeight||480),de(he.current.clientWidth||620),s||e.observe(he.current)),()=>e.disconnect()},[s,N]),x.useEffect(()=>{const e=setInterval(()=>{we(r=>r<c.length-1?r+1:0)},(t.speed||2)*1e3);return me||clearInterval(e),()=>clearInterval(e)},[c,me,t.speed]);const Ce=Oe.getSliderMarks(c,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:u==="he"||u==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${E?E===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${u||"en"}`,s?"w-fit":"w-full",b?.graphContainer),style:{...C?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:re,ref:Re,"aria-label":p||`${g?`The graph shows ${g}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${w?` ${w}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?F||"1rem":F||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[g||w||se||d?i.jsxRuntimeExports.jsx(Ge.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:b?.title,description:b?.description},graphTitle:g,graphDescription:w,width:s,graphDownload:se?Re.current:void 0,dataDownload:d?l.map(e=>e.data).filter(e=>e!==void 0).length>0?l.map(e=>e.data).filter(e=>e!==void 0):l.filter(e=>e!==void 0):null}):null,t.enabled&&c.length>0&&Ce?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ie(!me)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":me?"Click to pause animation":"Click to play animation",children:me?i.jsxRuntimeExports.jsx(Ne.Pause,{}):i.jsxRuntimeExports.jsx(Ne.Play,{})}),i.jsxRuntimeExports.jsx(Oe.xr,{min:c[0],max:c[c.length-1],marks:Ce,step:null,defaultValue:c[c.length-1],value:c[be],onChangeComplete:e=>{we(c.indexOf(e))},onChange:e=>{we(c.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?i.jsxRuntimeExports.jsx(ze.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[f?i.jsxRuntimeExports.jsx(Ye.ColorLegendWithMouseOver,{width:s,colorDomain:xe,colors:_,colorLegendTitle:O,setSelectedColor:Se,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:he,"aria-label":"Graph area",children:(s||o)&&(N||ke)?i.jsxRuntimeExports.jsx(nt,{data:D!==void 0?D==="diff"?Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[e.x.length-1])||A.checkIfNullOrUndefined(e.x[0])?-1/0:e.x[e.x.length-1]-e.x[0],[n||"asc"]).filter((e,r)=>L?r<L:!0):Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[D])?-1/0:e.x[D],[n||"asc"]).filter((e,r)=>L?r<L:!0):je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>V?!e.x.every(r=>r==null):e).filter((e,r)=>L?r<L:!0),dotColors:_,width:s||o,height:Math.max(M,N||(R?M?(s||o)*R>M?(s||o)*R:M:(s||o)*R:ke)),radius:ae,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,showLabels:I,showValues:h,tooltip:B,suffix:ne,prefix:ge,onSeriesMouseOver:pe,maxValue:A.checkIfNullOrUndefined(v)?Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null))))<0?0:Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null)))):v,minValue:A.checkIfNullOrUndefined(U)?Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null))))>0?0:Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null)))):U,onSeriesMouseClick:fe,selectedColor:De,arrowConnector:oe,connectorStrokeWidth:y,maxBarThickness:X,minBarThickness:j,resetSelectionOnDoubleClick:m,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,styles:C,classNames:b,labelOrder:S,refValues:Q,animate:$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},precision:Y,customLayers:k,highlightedDataPoints:T,dimmedOpacity:a}):null})]})}),z||q?i.jsxRuntimeExports.jsx(Xe.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:b?.footnote,source:b?.source},sources:z,footNote:q,width:s}):null]})})})})}function ot(ye){const{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,orientation:C="vertical",styles:b,classNames:S,labelOrder:Q,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o}=ye;return C==="vertical"?i.jsxRuntimeExports.jsx(st,{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,styles:b,detailsOnClick:H,axisTitle:W,noOfTicks:K,labelOrder:Q,valueColor:P,classNames:S,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o}):i.jsxRuntimeExports.jsx(rt,{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,styles:b,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,classNames:S,labelOrder:Q,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o})}exports.DumbbellChart=ot;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),x=require("react"),ve=require("./parse-hMnG_lRV.cjs"),Oe=require("./getSliderMarks-CRIbTGYV.cjs"),Me=require("./index-CQ3e6Ewi.cjs"),Le=require("./index-DQA8q5sC.cjs"),Ve=require("./Modal-tXZlLE5s.cjs"),Te=require("./numberFormattingFunction-02t-wJta.cjs"),$e=require("./Tooltip-De16GWhY.cjs"),A=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ae=require("./string2HTML-z7CwHXcx.cjs"),Ze=require("./XTicksAndGridLines-CCzXIV8d.cjs"),qe=require("./AxisTitle-CK9YeovX.cjs"),et=require("./YAxesLabels-yRFFdx1s.cjs"),Fe=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Pe=require("./ReferenceLine-CFVBBN__.cjs"),Be=require("./linear-BVckp9RD.cjs"),He=require("./band-CAApY4Pd.cjs"),We=require("./use-in-view-sQJZ_xDO.cjs"),le=require("./proxy-BHRoeZgd.cjs"),Ue=require("./index-BW8iNx7E.cjs"),Ge=require("./GraphHeader.cjs"),Xe=require("./GraphFooter.cjs"),Ye=require("./ColorLegendWithMouseOver.cjs"),_e=require("./Colors.cjs"),ze=require("./EmptyState-d8_8SxeW.cjs"),Ne=require("./index-BW_-wD2k.cjs"),je=require("./ensureCompleteData-DkQYPeDa.cjs"),Je=require("./uniqBy-O05lp2S5.cjs"),Ke=require("./sort-O96oMZLb.cjs"),Qe=require("./init-DU0ybBc_.cjs"),tt=require("./Axis-DE7dSn1_.cjs"),it=require("./XAxesLabels-Drf7M3YK.cjs");function at(ye){const{data:l,dotColors:g,suffix:_,prefix:z,barPadding:w,showValues:ue,showTicks:Z,leftMargin:ee,truncateBy:ce,width:te,height:ie,rightMargin:J,topMargin:N,bottomMargin:s,radius:q,showLabels:xe,tooltip:O,onSeriesMouseOver:F,maxValue:E,minValue:ae,onSeriesMouseClick:B,selectedColor:I,arrowConnector:R,connectorStrokeWidth:pe,maxBarThickness:re,minBarThickness:ne,resetSelectionOnDoubleClick:ge,detailsOnClick:v,axisTitle:U,noOfTicks:fe,valueColor:se,styles:d,classNames:h,labelOrder:D,refValues:oe,rtl:y,animate:u,precision:M,customLayers:G,highlightedDataPoints:X,dimmedOpacity:L}=ye,j=x.useRef(null),p=We.useInView(j,{once:u.once,amount:u.amount}),m={top:U?N+25:N,bottom:s,left:ee,right:J},H=te-m.left-m.right,W=ie-m.top-m.bottom,[K,P]=x.useState(void 0),[C,b]=x.useState(void 0),[S,Q]=x.useState(void 0),[V,$]=x.useState(void 0),Y=l.map((t,n)=>({...t,id:D?`${t.label}`:`${n}`})),k=D||Y.map(t=>`${t.id}`),f=Be.linear().domain([ae,E]).range([0,H]).nice(),T=He.band().domain(k).range([0,ne?Math.max(W,ne*Y.length):re?Math.min(W,re*Y.length):W]).paddingInner(w),a=f.ticks(fe);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsxs(le.motion.svg,{width:`${te}px`,height:`${ie}px`,viewBox:`0 0 ${te} ${ie}`,direction:"ltr",ref:j,children:[R?i.jsxRuntimeExports.jsx("defs",{children:i.jsxRuntimeExports.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsxRuntimeExports.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,i.jsxRuntimeExports.jsxs("g",{transform:`translate(${m.left},${m.top})`,children:[Z?i.jsxRuntimeExports.jsx(Ze.XTicksAndGridLines,{values:a.filter((t,n)=>n!==0),x:a.filter((t,n)=>n!==0).map(t=>f(t)),y1:0-N,y2:W+m.bottom,styles:{gridLines:d?.xAxis?.gridLines,labels:d?.xAxis?.labels},classNames:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},suffix:_,prefix:z,labelType:"secondary",showGridLines:!0,precision:M}):null,i.jsxRuntimeExports.jsx(qe.AxisTitle,{x:H/2,y:0-m.top+15,style:d?.xAxis?.title,className:h?.xAxis?.title,text:U}),i.jsxRuntimeExports.jsx(Fe.YTicksAndGridLines,{y:Y.map(t=>T(`${t.id}`)+T.bandwidth()/2),x1:0,x2:H,styles:{gridLines:d?.yAxis?.gridLines},classNames:{gridLines:h?.yAxis?.gridLines},labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:M}),G.filter(t=>t.position==="before").map(t=>t.layer),i.jsxRuntimeExports.jsxs(Ue.AnimatePresence,{children:[Y.map(t=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{x:0,y:T(`${t.id}`)+T.bandwidth()/2,opacity:X.length!==0?X.indexOf(t.label)!==-1?.85:L:.85},whileInView:{x:0,y:T(`${t.id}`)+T.bandwidth()/2,opacity:X.length!==0?X.indexOf(t.label)!==-1?.85:L:.85,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",exit:{opacity:0,transition:{duration:u.duration}},children:[xe?i.jsxRuntimeExports.jsx(et.YAxesLabels,{value:`${t.label}`.length<ce?`${t.label}`:`${`${t.label}`.substring(0,ce)}...`,y:0-T.bandwidth()/2,x:0-m.left,width:m.left,height:T.bandwidth(),alignment:"right",style:d?.yAxis?.labels,className:h?.yAxis?.labels,animate:u,isInView:p}):null,i.jsxRuntimeExports.jsx(le.motion.line,{y1:0,y2:0,style:{strokeWidth:pe,...d?.dataConnectors||{},opacity:I?.3:1},className:i.mo("stroke-primary-gray-600 dark:stroke-primary-gray-300",h?.dataConnectors),markerEnd:R&&t.x.indexOf(Math.min(...t.x.filter(n=>n!==null)))===0?"url(#arrow)":"",markerStart:R&&t.x.indexOf(Math.min(...t.x.filter(n=>n!==null)))===t.x.length-1?"url(#arrow)":"",exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x1:0,x2:0},whileInView:{x1:f(Math.min(...t.x.filter(n=>n!==null)))+q,x2:f(Math.max(...t.x.filter(n=>n!==null)))-q,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}),t.x.map((n,o)=>i.jsxRuntimeExports.jsx(le.motion.g,{onMouseEnter:de=>{P({...t,xIndex:o}),$(de.clientY),Q(de.clientX),F?.({...t,xIndex:o})},onClick:()=>{(B||v)&&(Le.isEqual(C,{...t,xIndex:o})&&ge?(b(void 0),B?.(void 0)):(b({...t,xIndex:o}),B&&B({...t,xIndex:o})))},onMouseMove:de=>{P({...t,xIndex:o}),$(de.clientY),Q(de.clientX)},onMouseLeave:()=>{P(void 0),Q(void 0),$(void 0),F?.(void 0)},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{opacity:I?g[o]===I?1:.3:1},whileInView:{opacity:I?g[o]===I?1:.3:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:A.checkIfNullOrUndefined(n)?null:i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.circle,{cy:0,r:q,style:{fill:g[o],fillOpacity:.85,stroke:g[o],strokeWidth:1,opacity:A.checkIfNullOrUndefined(n)?0:1},exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{cx:f(0),opacity:0},whileInView:{cx:f(n||0),opacity:A.checkIfNullOrUndefined(n)?0:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial"}),ue?i.jsxRuntimeExports.jsx(le.motion.text,{y:0,style:{fill:se||g[o],textAnchor:"middle",...d?.graphObjectValues||{}},dx:0,dy:0-q-3,className:i.mo("graph-value text-sm font-bold",A.checkIfNullOrUndefined(n)?"0opacity-0":"opacity-100",h?.graphObjectValues),exit:{opacity:0,transition:{duration:u.duration}},variants:{initial:{x:f(0),opacity:0},whileInView:{x:f(n||0),opacity:1,transition:{duration:u.duration}}},initial:"initial",animate:p?"whileInView":"initial",children:Te.numberFormattingFunction(n,"NA",M,z,_)}):null]})},o))]},t.label)),oe?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:oe.map((t,n)=>i.jsxRuntimeExports.jsx(Pe.RefLineX,{text:t.text,color:t.color,x:f(t.value),y1:0-m.top,y2:W+m.bottom,textSide:f(t.value)>H*.75||y?"left":"right",classNames:t.classNames,styles:t.styles,animate:u,isInView:p},n))}):null]}),G.filter(t=>t.position==="after").map(t=>t.layer)]})]}),K&&O&&S&&V?i.jsxRuntimeExports.jsx($e.Tooltip,{data:K,body:O,xPos:S,yPos:V,backgroundStyle:d?.tooltip,className:h?.tooltip}):null,v&&C!==void 0?i.jsxRuntimeExports.jsx(Ve.X,{open:C!==void 0,onClose:()=>{b(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof v=="string"?{__html:Ae.string2HTML(v,C)}:void 0,children:typeof v=="function"?v(C):null})}):null]})}function rt(ye){const{data:l,graphTitle:g,colors:_=_e.Colors.light.categoricalColors.colors,sources:z,graphDescription:w,barPadding:ue=.25,showTicks:Z=!0,leftMargin:ee=100,rightMargin:ce=40,topMargin:te=20,bottomMargin:ie=10,truncateBy:J=999,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E=!1,radius:ae=3,showLabels:B=!0,tooltip:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne="",prefix:ge="",maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se=!1,dataDownload:d=!1,showValues:h=!0,sortParameter:D,arrowConnector:oe=!1,connectorStrokeWidth:y=2,language:u="en",minHeight:M=0,theme:G="light",labelOrder:X,maxBarThickness:L,maxNumberOfBars:j,minBarThickness:p,ariaLabel:m,resetSelectionOnDoubleClick:H=!0,detailsOnClick:W,axisTitle:K,noOfTicks:P=5,valueColor:C,styles:b,classNames:S,refValues:Q,filterNA:V=!0,animate:$=!1,precision:Y=2,customLayers:k=[],showColorScale:f=!0,highlightedDataPoints:T=[],dimmedOpacity:a=.3,timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},sortData:n}=ye,[o,de]=x.useState(0),[ke,Ee]=x.useState(0),[me,Ie]=x.useState(t.autoplay),c=Ke.sort(Je.uniqBy(l,"date",!0).map(e=>ve.parse(`${e}`,t.dateFormat||"yyyy",new Date).getTime()),(e,r)=>Qe.ascending(e,r)),[be,we]=x.useState(t.autoplay?0:c.length-1),[De,Se]=x.useState(void 0),he=x.useRef(null),Re=x.useRef(null);x.useEffect(()=>{const e=new ResizeObserver(r=>{de(s||r[0].target.clientWidth||620),Ee(N||r[0].target.clientHeight||480)});return he.current&&(Ee(he.current.clientHeight||480),de(he.current.clientWidth||620),s||e.observe(he.current)),()=>e.disconnect()},[s,N]),x.useEffect(()=>{const e=setInterval(()=>{we(r=>r<c.length-1?r+1:0)},(t.speed||2)*1e3);return me||clearInterval(e),()=>clearInterval(e)},[c,me,t.speed]);const Ce=Oe.getSliderMarks(c,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:u==="he"||u==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${E?E===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${u||"en"}`,s?"w-fit":"w-full",S?.graphContainer),style:{...b?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:re,ref:Re,"aria-label":m||`${g?`The graph shows ${g}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${w?` ${w}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?F||"1rem":F||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[g||w||se||d?i.jsxRuntimeExports.jsx(Ge.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:S?.title,description:S?.description},graphTitle:g,graphDescription:w,width:s,graphDownload:se?Re.current:void 0,dataDownload:d?l.map(e=>e.data).filter(e=>e!==void 0).length>0?l.map(e=>e.data).filter(e=>e!==void 0):l.filter(e=>e!==void 0):null}):null,t.enabled&&c.length>0&&Ce?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ie(!me)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":me?"Click to pause animation":"Click to play animation",children:me?i.jsxRuntimeExports.jsx(Ne.Pause,{}):i.jsxRuntimeExports.jsx(Ne.Play,{})}),i.jsxRuntimeExports.jsx(Oe.xr,{min:c[0],max:c[c.length-1],marks:Ce,step:null,defaultValue:c[c.length-1],value:c[be],onChangeComplete:e=>{we(c.indexOf(e))},onChange:e=>{we(c.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?i.jsxRuntimeExports.jsx(ze.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[f?i.jsxRuntimeExports.jsx(Ye.ColorLegendWithMouseOver,{width:s,colorDomain:xe,colors:_,colorLegendTitle:O,setSelectedColor:Se,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:he,"aria-label":"Graph area",children:(s||o)&&(N||ke)?i.jsxRuntimeExports.jsx(at,{data:D!==void 0?D==="diff"?Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[e.x.length-1])||A.checkIfNullOrUndefined(e.x[0])?-1/0:e.x[e.x.length-1]-e.x[0],[n||"asc"]).filter((e,r)=>j?r<j:!0):Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[D])?-1/0:e.x[D],[n||"asc"]).filter((e,r)=>j?r<j:!0):je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>V?!e.x.every(r=>r==null):e).filter((e,r)=>j?r<j:!0),dotColors:_,width:s||o,height:Math.max(M,N||(R?M?(s||o)*R>M?(s||o)*R:M:(s||o)*R:ke)),suffix:ne,prefix:ge,radius:ae,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,showLabels:B,showValues:h,tooltip:I,onSeriesMouseOver:pe,maxValue:A.checkIfNullOrUndefined(v)?Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null))))<0?0:Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null)))):v,minValue:A.checkIfNullOrUndefined(U)?Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null))))>0?0:Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null)))):U,onSeriesMouseClick:fe,selectedColor:De,arrowConnector:oe,connectorStrokeWidth:y,maxBarThickness:L,minBarThickness:p,resetSelectionOnDoubleClick:H,detailsOnClick:W,axisTitle:K,noOfTicks:P,valueColor:C,styles:b,classNames:S,labelOrder:X,refValues:Q,rtl:u==="he"||u==="ar",animate:$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},precision:Y,customLayers:k,highlightedDataPoints:T,dimmedOpacity:a}):null})]})}),z||q?i.jsxRuntimeExports.jsx(Xe.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:S?.footnote,source:S?.source},sources:z,footNote:q,width:s}):null]})})})})}function nt(ye){const{data:l,dotColors:g,barPadding:_,showTicks:z,leftMargin:w,truncateBy:ue,width:Z,height:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,radius:J,showLabels:N,tooltip:s,onSeriesMouseOver:q,maxValue:xe,minValue:O,onSeriesMouseClick:F,showValues:E,suffix:ae,prefix:B,selectedColor:I,arrowConnector:R,connectorStrokeWidth:pe,maxBarThickness:re,minBarThickness:ne,resetSelectionOnDoubleClick:ge,detailsOnClick:v,axisTitle:U,noOfTicks:fe,valueColor:se,styles:d,classNames:h,labelOrder:D,refValues:oe,animate:y,precision:u,customLayers:M,highlightedDataPoints:G,dimmedOpacity:X}=ye,L=x.useRef(null),j=We.useInView(L,{once:y.once,amount:y.amount}),p={top:te,bottom:ie,left:U?w+30:w,right:ce},m=Z-p.left-p.right,H=ee-p.top-p.bottom,[W,K]=x.useState(void 0),[P,C]=x.useState(void 0),[b,S]=x.useState(void 0),[Q,V]=x.useState(void 0),$=l.map((a,t)=>({...a,id:D?`${a.label}`:`${t}`})),Y=D||$.map(a=>`${a.id}`),k=Be.linear().domain([O,xe]).range([H,0]).nice(),f=He.band().domain(Y).range([0,ne?Math.max(m,ne*$.length):re?Math.min(m,re*$.length):m]).paddingInner(_),T=k.ticks(fe);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsxs(le.motion.svg,{width:`${Z}px`,height:`${ee}px`,viewBox:`0 0 ${Z} ${ee}`,direction:"ltr",ref:L,children:[R?i.jsxRuntimeExports.jsx("defs",{children:i.jsxRuntimeExports.jsx("marker",{id:"arrow",viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:i.jsxRuntimeExports.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",className:"fill-primary-gray-600 dark:fill-primary-gray-300"})})}):null,i.jsxRuntimeExports.jsxs("g",{transform:`translate(${p.left},${p.top})`,children:[i.jsxRuntimeExports.jsx(tt.Axis,{y1:k(O<0?0:O),y2:k(O<0?0:O),x1:0-w,x2:m+p.right,label:Te.numberFormattingFunction(O<0?0:O,"NA",u,B,ae),labelPos:{x:0-w,dx:0,dy:xe<0?"1em":-5,y:k(O<0?0:O)},classNames:{axis:h?.xAxis?.axis,label:h?.yAxis?.labels},styles:{axis:d?.xAxis?.axis,label:d?.yAxis?.labels}}),z?i.jsxRuntimeExports.jsx(Fe.YTicksAndGridLines,{values:T.filter(a=>a!==0),y:T.filter(a=>a!==0).map(a=>k(a)),x1:0-w,x2:m+p.right,styles:{gridLines:d?.yAxis?.gridLines,labels:d?.yAxis?.labels},classNames:{gridLines:h?.yAxis?.gridLines,labels:h?.yAxis?.labels},suffix:ae,prefix:B,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:u}):null,i.jsxRuntimeExports.jsx(qe.AxisTitle,{x:0-w-15,y:H/2,style:d?.yAxis?.title,className:h?.yAxis?.title,text:U,rotate90:!0}),M.filter(a=>a.position==="before").map(a=>a.layer),i.jsxRuntimeExports.jsxs(Ue.AnimatePresence,{children:[$.map(a=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{x:f(`${a.id}`)+f.bandwidth()/2,y:0,opacity:G.length!==0?G.indexOf(a.label)!==-1?.85:X:.85},whileInView:{x:f(`${a.id}`)+f.bandwidth()/2,y:0,opacity:G.length!==0?G.indexOf(a.label)!==-1?.85:X:.85,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:y.duration}},children:[N?i.jsxRuntimeExports.jsx(it.XAxesLabels,{value:`${a.label}`.length<ue?`${a.label}`:`${`${a.label}`.substring(0,ue)}...`,y:H+5,x:0-f.bandwidth()/2,width:f.bandwidth(),height:p.bottom,style:d?.xAxis?.labels,className:h?.xAxis?.labels,alignment:"top",animate:y,isInView:j}):null,i.jsxRuntimeExports.jsx(le.motion.line,{x1:0,x2:0,style:{strokeWidth:pe,...d?.dataConnectors||{},opacity:I?.3:1},className:i.mo("stroke-primary-gray-600 dark:stroke-primary-gray-300",h?.dataConnectors),markerEnd:R&&a.x.indexOf(Math.min(...a.x.filter(t=>t!==null)))===0?"url(#arrow)":"",markerStart:R&&a.x.indexOf(Math.min(...a.x.filter(t=>t!==null)))===a.x.length-1?"url(#arrow)":"",exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{y1:0,y2:0},whileInView:{y1:k(Math.min(...a.x.filter(t=>t!==null)))+J,y2:k(Math.max(...a.x.filter(t=>t!==null)))-J,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial"}),a.x.map((t,n)=>i.jsxRuntimeExports.jsx(le.motion.g,{onMouseEnter:o=>{K({...a,xIndex:n}),V(o.clientY),S(o.clientX),q?.({...a,xIndex:n})},onClick:()=>{(F||v)&&(Le.isEqual(P,{...a,xIndex:n})&&ge?(C(void 0),F?.(void 0)):(C({...a,xIndex:n}),F&&F({...a,xIndex:n})))},onMouseMove:o=>{K({...a,xIndex:n}),V(o.clientY),S(o.clientX)},onMouseLeave:()=>{K(void 0),S(void 0),V(void 0),q?.(void 0)},exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{opacity:I?g[n]===I?1:.3:1},whileInView:{opacity:I?g[n]===I?1:.3:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",children:A.checkIfNullOrUndefined(t)?null:i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.circle,{cx:0,r:J,style:{fill:g[n],fillOpacity:.85,stroke:g[n],strokeWidth:1},exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{cy:k(0),opacity:0},whileInView:{cy:k(t||0),opacity:A.checkIfNullOrUndefined(t)?0:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial"}),E?i.jsxRuntimeExports.jsx(le.motion.text,{x:0,style:{fill:se||g[n],textAnchor:"start",...d?.graphObjectValues||{}},className:i.mo("graph-value text-sm font-bold",A.checkIfNullOrUndefined(t)?"opacity-0":"opacity-100",h?.graphObjectValues),dx:J+3,dy:"0.33em",exit:{opacity:0,transition:{duration:y.duration}},variants:{initial:{y:k(0),opacity:0},whileInView:{y:k(t||0),opacity:1,transition:{duration:y.duration}}},initial:"initial",animate:j?"whileInView":"initial",children:Te.numberFormattingFunction(t,"NA",u,B,ae)}):null]})},n))]},a.label)),oe?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:oe.map((a,t)=>i.jsxRuntimeExports.jsx(Pe.RefLineY,{text:a.text,color:a.color,y:k(a.value),x1:0-w,x2:m+p.right,classNames:a.classNames,styles:a.styles,animate:y,isInView:j},t))}):null]}),M.filter(a=>a.position==="after").map(a=>a.layer)]})]}),W&&s&&b&&Q?i.jsxRuntimeExports.jsx($e.Tooltip,{data:W,body:s,xPos:b,yPos:Q,backgroundStyle:d?.tooltip,className:h?.tooltip}):null,v&&P!==void 0?i.jsxRuntimeExports.jsx(Ve.X,{open:P!==void 0,onClose:()=>{C(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof v=="string"?{__html:Ae.string2HTML(v,P)}:void 0,children:typeof v=="function"?v(P):null})}):null]})}function st(ye){const{data:l,graphTitle:g,colors:_=_e.Colors.light.categoricalColors.colors,sources:z,graphDescription:w,barPadding:ue=.25,showTicks:Z=!0,leftMargin:ee=20,rightMargin:ce=20,topMargin:te=20,bottomMargin:ie=25,truncateBy:J=999,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E=!1,radius:ae=3,tooltip:B,showLabels:I=!0,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne="",prefix:ge="",maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se=!1,dataDownload:d=!1,showValues:h=!0,sortParameter:D,arrowConnector:oe=!1,connectorStrokeWidth:y=2,language:u="en",minHeight:M=0,theme:G="light",maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m=!0,detailsOnClick:H,axisTitle:W,noOfTicks:K=5,valueColor:P,styles:C,classNames:b,labelOrder:S,refValues:Q,filterNA:V=!0,animate:$=!1,precision:Y=2,customLayers:k=[],showColorScale:f=!0,highlightedDataPoints:T=[],dimmedOpacity:a=.3,timeline:t={enabled:!1,autoplay:!1,showOnlyActiveDate:!0},sortData:n}=ye,[o,de]=x.useState(0),[ke,Ee]=x.useState(0),[me,Ie]=x.useState(t.autoplay),c=Ke.sort(Je.uniqBy(l,"date",!0).map(e=>ve.parse(`${e}`,t.dateFormat||"yyyy",new Date).getTime()),(e,r)=>Qe.ascending(e,r)),[be,we]=x.useState(t.autoplay?0:c.length-1),[De,Se]=x.useState(void 0),he=x.useRef(null),Re=x.useRef(null);x.useEffect(()=>{const e=new ResizeObserver(r=>{de(s||r[0].target.clientWidth||620),Ee(N||r[0].target.clientHeight||480)});return he.current&&(Ee(he.current.clientHeight||480),de(he.current.clientWidth||620),s||e.observe(he.current)),()=>e.disconnect()},[s,N]),x.useEffect(()=>{const e=setInterval(()=>{we(r=>r<c.length-1?r+1:0)},(t.speed||2)*1e3);return me||clearInterval(e),()=>clearInterval(e)},[c,me,t.speed]);const Ce=Oe.getSliderMarks(c,be,t.showOnlyActiveDate,t.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:u==="he"||u==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${E?E===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${u||"en"}`,s?"w-fit":"w-full",b?.graphContainer),style:{...C?.graphContainer||{},...E&&E!==!0?{backgroundColor:E}:{}},id:re,ref:Re,"aria-label":p||`${g?`The graph shows ${g}. `:""}This is a dumbbell chart that shows comparisons between two or more data points across categories. ${w?` ${w}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:E?F||"1rem":F||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[g||w||se||d?i.jsxRuntimeExports.jsx(Ge.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:b?.title,description:b?.description},graphTitle:g,graphDescription:w,width:s,graphDownload:se?Re.current:void 0,dataDownload:d?l.map(e=>e.data).filter(e=>e!==void 0).length>0?l.map(e=>e.data).filter(e=>e!==void 0):l.filter(e=>e!==void 0):null}):null,t.enabled&&c.length>0&&Ce?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{Ie(!me)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":me?"Click to pause animation":"Click to play animation",children:me?i.jsxRuntimeExports.jsx(Ne.Pause,{}):i.jsxRuntimeExports.jsx(Ne.Play,{})}),i.jsxRuntimeExports.jsx(Oe.xr,{min:c[0],max:c[c.length-1],marks:Ce,step:null,defaultValue:c[c.length-1],value:c[be],onChangeComplete:e=>{we(c.indexOf(e))},onChange:e=>{we(c.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:l.length===0?i.jsxRuntimeExports.jsx(ze.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[f?i.jsxRuntimeExports.jsx(Ye.ColorLegendWithMouseOver,{width:s,colorDomain:xe,colors:_,colorLegendTitle:O,setSelectedColor:Se,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow w-full justify-center leading-0",ref:he,"aria-label":"Graph area",children:(s||o)&&(N||ke)?i.jsxRuntimeExports.jsx(nt,{data:D!==void 0?D==="diff"?Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[e.x.length-1])||A.checkIfNullOrUndefined(e.x[0])?-1/0:e.x[e.x.length-1]-e.x[0],[n||"asc"]).filter((e,r)=>L?r<L:!0):Me.orderBy(je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>t.enabled?e.date===ve.format(new Date(c[be]),t.dateFormat||"yyyy"):e).filter(e=>V?!e.x.every(r=>r==null):e),e=>A.checkIfNullOrUndefined(e.x[D])?-1/0:e.x[D],[n||"asc"]).filter((e,r)=>L?r<L:!0):je.ensureCompleteDataForDumbbellChart(l,t.dateFormat||"yyyy").filter(e=>V?!e.x.every(r=>r==null):e).filter((e,r)=>L?r<L:!0),dotColors:_,width:s||o,height:Math.max(M,N||(R?M?(s||o)*R>M?(s||o)*R:M:(s||o)*R:ke)),radius:ae,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,showLabels:I,showValues:h,tooltip:B,suffix:ne,prefix:ge,onSeriesMouseOver:pe,maxValue:A.checkIfNullOrUndefined(v)?Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null))))<0?0:Math.max(...l.map(e=>Math.max(...e.x.filter(r=>r!==null)))):v,minValue:A.checkIfNullOrUndefined(U)?Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null))))>0?0:Math.min(...l.map(e=>Math.min(...e.x.filter(r=>r!==null)))):U,onSeriesMouseClick:fe,selectedColor:De,arrowConnector:oe,connectorStrokeWidth:y,maxBarThickness:X,minBarThickness:j,resetSelectionOnDoubleClick:m,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,styles:C,classNames:b,labelOrder:S,refValues:Q,animate:$===!0?{duration:.5,once:!0,amount:.5}:$||{duration:0,once:!0,amount:0},precision:Y,customLayers:k,highlightedDataPoints:T,dimmedOpacity:a}):null})]})}),z||q?i.jsxRuntimeExports.jsx(Xe.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:b?.footnote,source:b?.source},sources:z,footNote:q,width:s}):null]})})})})}function ot(ye){const{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,orientation:C="vertical",styles:b,classNames:S,labelOrder:Q,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o}=ye;return C==="vertical"?i.jsxRuntimeExports.jsx(st,{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,styles:b,detailsOnClick:H,axisTitle:W,noOfTicks:K,labelOrder:Q,valueColor:P,classNames:S,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o}):i.jsxRuntimeExports.jsx(rt,{data:l,graphTitle:g,colors:_,sources:z,graphDescription:w,barPadding:ue,showTicks:Z,leftMargin:ee,rightMargin:ce,topMargin:te,bottomMargin:ie,truncateBy:J,height:N,width:s,footNote:q,colorDomain:xe,colorLegendTitle:O,padding:F,backgroundColor:E,radius:ae,tooltip:B,showLabels:I,relativeHeight:R,onSeriesMouseOver:pe,graphID:re,suffix:ne,prefix:ge,maxValue:v,minValue:U,onSeriesMouseClick:fe,graphDownload:se,dataDownload:d,showValues:h,sortParameter:D,arrowConnector:oe,connectorStrokeWidth:y,language:u,minHeight:M,theme:G,maxBarThickness:X,maxNumberOfBars:L,minBarThickness:j,ariaLabel:p,resetSelectionOnDoubleClick:m,styles:b,detailsOnClick:H,axisTitle:W,noOfTicks:K,valueColor:P,classNames:S,labelOrder:Q,refValues:V,filterNA:$,animate:Y,precision:k,showColorScale:f,customLayers:T,highlightedDataPoints:a,dimmedOpacity:t,timeline:n,sortData:o})}exports.DumbbellChart=ot;
2
2
  //# sourceMappingURL=DumbbellChart.cjs.map
@@ -11,7 +11,7 @@ import { c as F } from "./checkIfNullOrUndefined-DmfiKkNw.js";
11
11
  import { s as Xe } from "./string2HTML-oFCROsus.js";
12
12
  import { X as rt } from "./XTicksAndGridLines-Bn9u5gOM.js";
13
13
  import { A as Ye } from "./AxisTitle-BmHLMRJZ.js";
14
- import { Y as lt } from "./YAxesLabels-CPGZjmZJ.js";
14
+ import { Y as lt } from "./YAxesLabels-DECkMgq8.js";
15
15
  import { Y as Ee } from "./YTicksAndGridLines-B6ah7CRf.js";
16
16
  import { a as nt, R as ot } from "./ReferenceLine-CfAW3vKJ.js";
17
17
  import { a as _e } from "./linear-DUdu7l2G.js";
@@ -30,7 +30,7 @@ import { u as tt } from "./uniqBy-BHy4I8PK.js";
30
30
  import { s as it } from "./sort-DfK1b0F5.js";
31
31
  import { c as at } from "./init-BhZylTFx.js";
32
32
  import { A as st } from "./Axis-Ddg-seDi.js";
33
- import { X as ct } from "./XAxesLabels-CaV2q-6H.js";
33
+ import { X as ct } from "./XAxesLabels-loO78vUO.js";
34
34
  function dt(ye) {
35
35
  const {
36
36
  data: s,
package/dist/HeatMap.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),x=require("react"),ue=require("./index-DQA8q5sC.cjs"),ce=require("./Modal-tXZlLE5s.cjs"),xe=require("./numberFormattingFunction-02t-wJta.cjs"),he=require("./Tooltip-De16GWhY.cjs"),de=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),re=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ge=require("./string2HTML-z7CwHXcx.cjs"),me=require("./XAxesLabels-OjBNl_lS.cjs"),pe=require("./YAxesLabels-D8IydyZj.cjs"),le=require("./uniqBy-O05lp2S5.cjs"),ae=require("./band-CAApY4Pd.cjs"),fe=require("./ordinal-BOeNbyae.cjs"),je=require("./threshold-DNsSUf8Q.cjs"),Ce=require("./linear-BVckp9RD.cjs"),ye=require("./use-in-view-sQJZ_xDO.cjs"),se=require("./proxy-BHRoeZgd.cjs"),ve=require("./GraphHeader.cjs"),we=require("./GraphFooter.cjs"),be=require("./ColorLegendWithMouseOver.cjs"),Ee=require("./LinearColorLegend.cjs"),Re=require("./ThresholdColorLegendWithMouseOver.cjs"),i=require("./Colors.cjs"),qe=require("./EmptyState-d8_8SxeW.cjs");function $e(U){const{data:m,showColumnLabels:N,leftMargin:O,rightMargin:F,truncateBy:p,width:H,height:I,topMargin:z,bottomMargin:_,tooltip:q,onSeriesMouseOver:r,suffix:J,prefix:s,showValues:G,colorDomain:$,colors:S,noDataColor:f,scaleType:X,showRowLabels:K,selectedColor:Y,onSeriesMouseClick:V,resetSelectionOnDoubleClick:Q,detailsOnClick:y,styles:L,classNames:j,animate:v,precision:Z}=U,W=x.useRef(null),D=ye.useInView(W,{once:v.once,amount:v.amount}),l={top:z,bottom:_,left:O,right:F},[w,T]=x.useState(void 0),[a,M]=x.useState(void 0),[A,b]=x.useState(void 0),[o,B]=x.useState(void 0),ee=H-l.left-l.right,te=I-l.top-l.bottom,h=le.uniqBy(m,"column",!0),d=le.uniqBy(m,"row",!0),E=ae.band().domain(d).range([0,te]),k=E.bandwidth(),u=ae.band().domain(h).range([0,ee]),R=u.bandwidth(),P=X==="categorical"?fe.ordinal().domain($).range(S):X==="threshold"?je.threshold().domain($).range(S):Ce.linear().domain($).range(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(se.motion.svg,{width:`${H}px`,height:`${I}px`,viewBox:`0 0 ${H} ${I}`,style:{marginLeft:"auto",marginRight:"auto"},direction:"ltr",ref:W,children:[e.jsxRuntimeExports.jsx("g",{transform:`translate(${l.left},0)`,children:N?h.map((t,C)=>e.jsxRuntimeExports.jsx(me.XAxesLabels,{y:0,x:u(t),width:R,height:l.top-5,value:`${t}`.length<p?`${t}`:`${`${t}`.substring(0,p)}...`,style:L?.xAxis?.labels,className:j?.xAxis?.labels,alignment:"bottom",animate:{duration:0,once:!0,amount:0},isInView:D},C)):null}),e.jsxRuntimeExports.jsx("g",{transform:`translate(0,${l.top})`,children:K?d.map((t,C)=>e.jsxRuntimeExports.jsx(pe.YAxesLabels,{value:`${t}`.length<p?`${t}`:`${`${t}`.substring(0,p)}...`,y:E(t),x:0,width:l.left,height:k,alignment:"right",style:L?.yAxis?.labels,className:j?.yAxis?.labels,animate:{duration:0,once:!0,amount:0},isInView:D},C)):null}),e.jsxRuntimeExports.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[d.map((t,C)=>e.jsxRuntimeExports.jsx("g",{transform:`translate(0,${E(t)})`,children:h.map(g=>e.jsxRuntimeExports.jsx("rect",{x:u(g),y:0,width:R,height:k,style:{fill:f},className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700"},`${t}-${g}`))},C)),m.filter(t=>!re.checkIfNullOrUndefined(t.value)).map((t,C)=>{const g=re.checkIfNullOrUndefined(t.value)?f:P(t.value);return e.jsxRuntimeExports.jsxs("g",{transform:`translate(${u(t.column)},${E(t.row)})`,onMouseEnter:c=>{M(t),B(c.clientY),b(c.clientX),r?.(t)},onClick:()=>{(V||y)&&(ue.isEqual(w,t)&&Q?(T(void 0),V?.(void 0)):(T(t),V?.(t)))},onMouseMove:c=>{M(t),B(c.clientY),b(c.clientX)},onMouseLeave:()=>{M(void 0),b(void 0),B(void 0),r?.(void 0)},opacity:Y?Y===g?1:.3:1,children:[e.jsxRuntimeExports.jsx(se.motion.rect,{x:0,y:0,width:R,height:k,className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700",exit:{opacity:0,transition:{duration:v.duration}},variants:{initial:{fill:g,opacity:0},whileInView:{fill:g,opacity:1,transition:{duration:v.duration}}},initial:"initial",animate:D?"whileInView":"initial"}),G&&!re.checkIfNullOrUndefined(t.value)?e.jsxRuntimeExports.jsx(se.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:v.duration}}},initial:"initial",animate:D?"whileInView":"initial",exit:{opacity:0,transition:{duration:v.duration}},children:e.jsxRuntimeExports.jsx("foreignObject",{y:0,x:0,width:R,height:k,children:e.jsxRuntimeExports.jsx("div",{className:"flex flex-col justify-center items-center h-inherit p-1",children:e.jsxRuntimeExports.jsx("p",{className:e.mo("text-xs text-center m-0 leading-[1.25] graph-value",j?.graphObjectValues),style:{color:de.getTextColorBasedOnBgColor(g),...L?.graphObjectValues||{}},children:xe.numberFormattingFunction(t.value,"NA",Z,s,J)})})},C)}):null]},`${t.column}-${t.row}`)}),a?e.jsxRuntimeExports.jsx("rect",{x:u(a.column),y:E(a.row),width:R,height:k,style:{fill:"none",fillOpacity:0,strokeWidth:1.5},className:"stroke-primary-gray-700 dark:stroke-primary-gray-300"}):null]})]}),a&&q&&A&&o?e.jsxRuntimeExports.jsx(he.Tooltip,{data:a,body:q,xPos:A,yPos:o,backgroundStyle:L?.tooltip,className:j?.tooltip}):null,y&&w!==void 0?e.jsxRuntimeExports.jsx(ce.X,{open:w!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof y=="string"?{__html:ge.string2HTML(y,w)}:void 0,children:typeof y=="function"?y(w):null})}):null]})}function Me(U){const{data:m,graphTitle:N,colors:O,sources:F,graphDescription:p,showColumnLabels:H=!0,leftMargin:I=100,rightMargin:z=10,truncateBy:_=999,height:q,width:r,scaleType:J,colorDomain:s,footNote:G,colorLegendTitle:$,padding:S,backgroundColor:f=!1,topMargin:X=30,bottomMargin:K=10,tooltip:Y,onSeriesMouseOver:V,suffix:Q="",prefix:y="",showRowLabels:L=!0,relativeHeight:j,showValues:v,graphID:Z,noDataColor:W=i.Colors.gray,showColorScale:D=!0,onSeriesMouseClick:l,graphDownload:w=!1,dataDownload:T=!1,fillContainer:a=!0,language:M="en",showNAColor:A=!0,minHeight:b=0,theme:o="light",ariaLabel:B,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:te,styles:h,classNames:d,animate:E=!1,precision:k=2}=U,[u,R]=x.useState(0),[P,t]=x.useState(0),[C,g]=x.useState(void 0),c=x.useRef(null),ie=x.useRef(null);x.useEffect(()=>{const n=new ResizeObserver(ne=>{R(r||ne[0].target.clientWidth||620),t(q||ne[0].target.clientHeight||480)});return c.current&&(t(c.current.clientHeight||480),R(c.current.clientWidth||620),r||n.observe(c.current)),()=>n.disconnect()},[r,q]);const oe=J||(typeof s[0]=="string"?"categorical":s.length===2?"linear":"threshold");return e.jsxRuntimeExports.jsx("div",{className:`${o||"light"} flex ${r?"grow-0":"grow"} ${a?"w-full":"w-fit"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${f?f===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,a?"w-full":"w-fit",d?.graphContainer),style:{...h?.graphContainer||{},...f&&f!==!0?{backgroundColor:f}:{}},id:Z,ref:ie,"aria-label":B||`${N?`The graph shows ${N}. `:""}This is a heatmap. ${p?` ${p}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:f?S||"1rem":S||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[N||p||w||T?e.jsxRuntimeExports.jsx(ve.GraphHeader,{styles:{title:h?.title,description:h?.description},classNames:{title:d?.title,description:d?.description},graphTitle:N,graphDescription:p,width:r,graphDownload:w?ie.current:void 0,dataDownload:T?m.map(n=>n.data).filter(n=>n!==void 0).length>0?m.map(n=>n.data).filter(n=>n!==void 0):m.filter(n=>n!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:m.length===0?e.jsxRuntimeExports.jsx(qe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[D?oe==="categorical"?e.jsxRuntimeExports.jsx(be.ColorLegendWithMouseOver,{width:a?void 0:r,colorLegendTitle:$,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),colorDomain:s.map(n=>`${n}`),setSelectedColor:g,showNAColor:A}):oe==="threshold"?e.jsxRuntimeExports.jsx(Re.ThresholdColorLegendWithMouseOver,{width:a?void 0:r,colorLegendTitle:$,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),colorDomain:s,setSelectedColor:g,naColor:W,showNAColor:A}):e.jsxRuntimeExports.jsx(Ee.LinearColorLegend,{width:a?void 0:r,colorLegendTitle:$,colors:O||[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]],colorDomain:s}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:c,"aria-label":"Graph area",children:(r||u)&&(q||P)?e.jsxRuntimeExports.jsx($e,{data:m,colorDomain:s,width:r||u,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),noDataColor:W,scaleType:oe,height:Math.max(b,q||(j?b?(r||u)*j>b?(r||u)*j:b:(r||u)*j:P)),showColumnLabels:H,leftMargin:I,rightMargin:z,topMargin:X,bottomMargin:K,selectedColor:C,truncateBy:_,showRowLabels:L,tooltip:Y,onSeriesMouseOver:V,showValues:v,suffix:Q,prefix:y,onSeriesMouseClick:l,resetSelectionOnDoubleClick:ee,detailsOnClick:te,styles:h,classNames:d,animate:E===!0?{duration:.5,once:!0,amount:.5}:E||{duration:0,once:!0,amount:0},precision:k}):null})]})}),F||G?e.jsxRuntimeExports.jsx(we.GraphFooter,{styles:{footnote:h?.footnote,source:h?.source},classNames:{footnote:d?.footnote,source:d?.source},sources:F,footNote:G,width:r}):null]})})})})}exports.HeatMap=Me;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),x=require("react"),ue=require("./index-DQA8q5sC.cjs"),ce=require("./Modal-tXZlLE5s.cjs"),xe=require("./numberFormattingFunction-02t-wJta.cjs"),he=require("./Tooltip-De16GWhY.cjs"),de=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),re=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ge=require("./string2HTML-z7CwHXcx.cjs"),me=require("./XAxesLabels-Drf7M3YK.cjs"),pe=require("./YAxesLabels-yRFFdx1s.cjs"),le=require("./uniqBy-O05lp2S5.cjs"),ae=require("./band-CAApY4Pd.cjs"),fe=require("./ordinal-BOeNbyae.cjs"),je=require("./threshold-DNsSUf8Q.cjs"),Ce=require("./linear-BVckp9RD.cjs"),ye=require("./use-in-view-sQJZ_xDO.cjs"),se=require("./proxy-BHRoeZgd.cjs"),ve=require("./GraphHeader.cjs"),we=require("./GraphFooter.cjs"),be=require("./ColorLegendWithMouseOver.cjs"),Ee=require("./LinearColorLegend.cjs"),Re=require("./ThresholdColorLegendWithMouseOver.cjs"),i=require("./Colors.cjs"),qe=require("./EmptyState-d8_8SxeW.cjs");function $e(U){const{data:m,showColumnLabels:N,leftMargin:O,rightMargin:F,truncateBy:p,width:H,height:I,topMargin:z,bottomMargin:_,tooltip:q,onSeriesMouseOver:r,suffix:J,prefix:s,showValues:G,colorDomain:$,colors:S,noDataColor:f,scaleType:X,showRowLabels:K,selectedColor:Y,onSeriesMouseClick:V,resetSelectionOnDoubleClick:Q,detailsOnClick:y,styles:L,classNames:j,animate:v,precision:Z}=U,W=x.useRef(null),D=ye.useInView(W,{once:v.once,amount:v.amount}),l={top:z,bottom:_,left:O,right:F},[w,T]=x.useState(void 0),[a,M]=x.useState(void 0),[A,b]=x.useState(void 0),[o,B]=x.useState(void 0),ee=H-l.left-l.right,te=I-l.top-l.bottom,h=le.uniqBy(m,"column",!0),d=le.uniqBy(m,"row",!0),E=ae.band().domain(d).range([0,te]),k=E.bandwidth(),u=ae.band().domain(h).range([0,ee]),R=u.bandwidth(),P=X==="categorical"?fe.ordinal().domain($).range(S):X==="threshold"?je.threshold().domain($).range(S):Ce.linear().domain($).range(S);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(se.motion.svg,{width:`${H}px`,height:`${I}px`,viewBox:`0 0 ${H} ${I}`,style:{marginLeft:"auto",marginRight:"auto"},direction:"ltr",ref:W,children:[e.jsxRuntimeExports.jsx("g",{transform:`translate(${l.left},0)`,children:N?h.map((t,C)=>e.jsxRuntimeExports.jsx(me.XAxesLabels,{y:0,x:u(t),width:R,height:l.top-5,value:`${t}`.length<p?`${t}`:`${`${t}`.substring(0,p)}...`,style:L?.xAxis?.labels,className:j?.xAxis?.labels,alignment:"bottom",animate:{duration:0,once:!0,amount:0},isInView:D},C)):null}),e.jsxRuntimeExports.jsx("g",{transform:`translate(0,${l.top})`,children:K?d.map((t,C)=>e.jsxRuntimeExports.jsx(pe.YAxesLabels,{value:`${t}`.length<p?`${t}`:`${`${t}`.substring(0,p)}...`,y:E(t),x:0,width:l.left,height:k,alignment:"right",style:L?.yAxis?.labels,className:j?.yAxis?.labels,animate:{duration:0,once:!0,amount:0},isInView:D},C)):null}),e.jsxRuntimeExports.jsxs("g",{transform:`translate(${l.left},${l.top})`,children:[d.map((t,C)=>e.jsxRuntimeExports.jsx("g",{transform:`translate(0,${E(t)})`,children:h.map(g=>e.jsxRuntimeExports.jsx("rect",{x:u(g),y:0,width:R,height:k,style:{fill:f},className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700"},`${t}-${g}`))},C)),m.filter(t=>!re.checkIfNullOrUndefined(t.value)).map((t,C)=>{const g=re.checkIfNullOrUndefined(t.value)?f:P(t.value);return e.jsxRuntimeExports.jsxs("g",{transform:`translate(${u(t.column)},${E(t.row)})`,onMouseEnter:c=>{M(t),B(c.clientY),b(c.clientX),r?.(t)},onClick:()=>{(V||y)&&(ue.isEqual(w,t)&&Q?(T(void 0),V?.(void 0)):(T(t),V?.(t)))},onMouseMove:c=>{M(t),B(c.clientY),b(c.clientX)},onMouseLeave:()=>{M(void 0),b(void 0),B(void 0),r?.(void 0)},opacity:Y?Y===g?1:.3:1,children:[e.jsxRuntimeExports.jsx(se.motion.rect,{x:0,y:0,width:R,height:k,className:"stroke-1 stroke-primary-white dark:stroke-primary-gray-700",exit:{opacity:0,transition:{duration:v.duration}},variants:{initial:{fill:g,opacity:0},whileInView:{fill:g,opacity:1,transition:{duration:v.duration}}},initial:"initial",animate:D?"whileInView":"initial"}),G&&!re.checkIfNullOrUndefined(t.value)?e.jsxRuntimeExports.jsx(se.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:v.duration}}},initial:"initial",animate:D?"whileInView":"initial",exit:{opacity:0,transition:{duration:v.duration}},children:e.jsxRuntimeExports.jsx("foreignObject",{y:0,x:0,width:R,height:k,children:e.jsxRuntimeExports.jsx("div",{className:"flex flex-col justify-center items-center h-inherit p-1",children:e.jsxRuntimeExports.jsx("p",{className:e.mo("text-xs text-center m-0 leading-[1.25] graph-value",j?.graphObjectValues),style:{color:de.getTextColorBasedOnBgColor(g),...L?.graphObjectValues||{}},children:xe.numberFormattingFunction(t.value,"NA",Z,s,J)})})},C)}):null]},`${t.column}-${t.row}`)}),a?e.jsxRuntimeExports.jsx("rect",{x:u(a.column),y:E(a.row),width:R,height:k,style:{fill:"none",fillOpacity:0,strokeWidth:1.5},className:"stroke-primary-gray-700 dark:stroke-primary-gray-300"}):null]})]}),a&&q&&A&&o?e.jsxRuntimeExports.jsx(he.Tooltip,{data:a,body:q,xPos:A,yPos:o,backgroundStyle:L?.tooltip,className:j?.tooltip}):null,y&&w!==void 0?e.jsxRuntimeExports.jsx(ce.X,{open:w!==void 0,onClose:()=>{T(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof y=="string"?{__html:ge.string2HTML(y,w)}:void 0,children:typeof y=="function"?y(w):null})}):null]})}function Me(U){const{data:m,graphTitle:N,colors:O,sources:F,graphDescription:p,showColumnLabels:H=!0,leftMargin:I=100,rightMargin:z=10,truncateBy:_=999,height:q,width:r,scaleType:J,colorDomain:s,footNote:G,colorLegendTitle:$,padding:S,backgroundColor:f=!1,topMargin:X=30,bottomMargin:K=10,tooltip:Y,onSeriesMouseOver:V,suffix:Q="",prefix:y="",showRowLabels:L=!0,relativeHeight:j,showValues:v,graphID:Z,noDataColor:W=i.Colors.gray,showColorScale:D=!0,onSeriesMouseClick:l,graphDownload:w=!1,dataDownload:T=!1,fillContainer:a=!0,language:M="en",showNAColor:A=!0,minHeight:b=0,theme:o="light",ariaLabel:B,resetSelectionOnDoubleClick:ee=!0,detailsOnClick:te,styles:h,classNames:d,animate:E=!1,precision:k=2}=U,[u,R]=x.useState(0),[P,t]=x.useState(0),[C,g]=x.useState(void 0),c=x.useRef(null),ie=x.useRef(null);x.useEffect(()=>{const n=new ResizeObserver(ne=>{R(r||ne[0].target.clientWidth||620),t(q||ne[0].target.clientHeight||480)});return c.current&&(t(c.current.clientHeight||480),R(c.current.clientWidth||620),r||n.observe(c.current)),()=>n.disconnect()},[r,q]);const oe=J||(typeof s[0]=="string"?"categorical":s.length===2?"linear":"threshold");return e.jsxRuntimeExports.jsx("div",{className:`${o||"light"} flex ${r?"grow-0":"grow"} ${a?"w-full":"w-fit"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${f?f===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,a?"w-full":"w-fit",d?.graphContainer),style:{...h?.graphContainer||{},...f&&f!==!0?{backgroundColor:f}:{}},id:Z,ref:ie,"aria-label":B||`${N?`The graph shows ${N}. `:""}This is a heatmap. ${p?` ${p}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:f?S||"1rem":S||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[N||p||w||T?e.jsxRuntimeExports.jsx(ve.GraphHeader,{styles:{title:h?.title,description:h?.description},classNames:{title:d?.title,description:d?.description},graphTitle:N,graphDescription:p,width:r,graphDownload:w?ie.current:void 0,dataDownload:T?m.map(n=>n.data).filter(n=>n!==void 0).length>0?m.map(n=>n.data).filter(n=>n!==void 0):m.filter(n=>n!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:m.length===0?e.jsxRuntimeExports.jsx(qe.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[D?oe==="categorical"?e.jsxRuntimeExports.jsx(be.ColorLegendWithMouseOver,{width:a?void 0:r,colorLegendTitle:$,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),colorDomain:s.map(n=>`${n}`),setSelectedColor:g,showNAColor:A}):oe==="threshold"?e.jsxRuntimeExports.jsx(Re.ThresholdColorLegendWithMouseOver,{width:a?void 0:r,colorLegendTitle:$,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),colorDomain:s,setSelectedColor:g,naColor:W,showNAColor:A}):e.jsxRuntimeExports.jsx(Ee.LinearColorLegend,{width:a?void 0:r,colorLegendTitle:$,colors:O||[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]],colorDomain:s}):null,e.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:c,"aria-label":"Graph area",children:(r||u)&&(q||P)?e.jsxRuntimeExports.jsx($e,{data:m,colorDomain:s,width:r||u,colors:O||(typeof s[0]=="string"?i.Colors[o].categoricalColors.colors:s.length===2?[i.Colors[o].sequentialColors.neutralColorsx09[0],i.Colors[o].sequentialColors.neutralColorsx09[8]]:i.Colors[o].sequentialColors[`neutralColorsx0${s.length+1}`]),noDataColor:W,scaleType:oe,height:Math.max(b,q||(j?b?(r||u)*j>b?(r||u)*j:b:(r||u)*j:P)),showColumnLabels:H,leftMargin:I,rightMargin:z,topMargin:X,bottomMargin:K,selectedColor:C,truncateBy:_,showRowLabels:L,tooltip:Y,onSeriesMouseOver:V,showValues:v,suffix:Q,prefix:y,onSeriesMouseClick:l,resetSelectionOnDoubleClick:ee,detailsOnClick:te,styles:h,classNames:d,animate:E===!0?{duration:.5,once:!0,amount:.5}:E||{duration:0,once:!0,amount:0},precision:k}):null})]})}),F||G?e.jsxRuntimeExports.jsx(we.GraphFooter,{styles:{footnote:h?.footnote,source:h?.source},classNames:{footnote:d?.footnote,source:d?.source},sources:F,footNote:G,width:r}):null]})})})})}exports.HeatMap=Me;
2
2
  //# sourceMappingURL=HeatMap.cjs.map
package/dist/HeatMap.js CHANGED
@@ -7,8 +7,8 @@ import { T as pe } from "./Tooltip-CVCGWyzw.js";
7
7
  import { g as fe } from "./getTextColorBasedOnBgColor-B6Nk2WBf.js";
8
8
  import { c as re } from "./checkIfNullOrUndefined-DmfiKkNw.js";
9
9
  import { s as xe } from "./string2HTML-oFCROsus.js";
10
- import { X as ye } from "./XAxesLabels-CaV2q-6H.js";
11
- import { Y as ve } from "./YAxesLabels-CPGZjmZJ.js";
10
+ import { X as ye } from "./XAxesLabels-loO78vUO.js";
11
+ import { Y as ve } from "./YAxesLabels-DECkMgq8.js";
12
12
  import { u as ne } from "./uniqBy-BHy4I8PK.js";
13
13
  import { b as ce } from "./band-BEjh2CHI.js";
14
14
  import { o as we } from "./ordinal-w9Lu4Stb.js";
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),j=require("react"),gt=require("./index-DQA8q5sC.cjs"),wt=require("./Modal-tXZlLE5s.cjs"),ot=require("./numberFormattingFunction-02t-wJta.cjs"),Et=require("./Tooltip-De16GWhY.cjs"),Rt=require("./string2HTML-z7CwHXcx.cjs"),pt=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),dt=require("./Axis-DE7dSn1_.cjs"),ft=require("./AxisTitle-CK9YeovX.cjs"),At=require("./XAxesLabels-OjBNl_lS.cjs"),Mt=require("./band-CAApY4Pd.cjs"),yt=require("./linear-BVckp9RD.cjs"),jt=require("./line-DHV4JwCR.cjs"),lt=require("./step-BZ3C8QFW.cjs"),Ct=require("./use-in-view-sQJZ_xDO.cjs"),P=require("./proxy-BHRoeZgd.cjs"),Nt=require("./index-BW8iNx7E.cjs"),kt=require("./GraphFooter.cjs"),$t=require("./GraphHeader.cjs"),St=require("./ColorLegend.cjs"),xt=require("./Colors.cjs"),qt=require("./EmptyState-d8_8SxeW.cjs");function It(ct){const{data:q,width:M,height:V,barColor:d,lineColor:u,axisTitles:s,sameAxes:b,rightMargin:U,leftMargin:z,topMargin:_,bottomMargin:ut,tooltip:v,showValues:J,onSeriesMouseOver:D,barPadding:mt,truncateBy:K,showLabels:Q,onSeriesMouseClick:w,resetSelectionOnDoubleClick:Z,detailsOnClick:m,noOfTicks:tt,lineSuffix:et,barSuffix:Y,linePrefix:X,barPrefix:it,curveType:F,styles:o,classNames:l,animate:r,precision:H,customLayers:I,naLabel:C,showAxisLabels:st}=ct,nt=j.useRef(null),N=Ct.useInView(nt,{once:r.once,amount:r.amount}),ht=F==="linear"?jt.curveLinear:F==="step"?lt.curveStep:F==="stepAfter"?lt.stepAfter:F==="stepBefore"?lt.stepBefore:lt.monotoneX,[at,k]=j.useState(void 0),[$,L]=j.useState(void 0),[rt,S]=j.useState(void 0),[E,c]=j.useState(void 0),h={top:_,bottom:ut,left:z+50,right:U+65},p=M-h.left-h.right,g=V-h.top-h.bottom,n=q.map((t,A)=>({...t,id:`${A}`})),x=Mt.band().domain(n.map(t=>`${t.id}`)).range([0,p]).paddingInner(mt),W=Math.min(...n.map(t=>t.bar).filter(t=>t!=null))!==1/0?Math.min(...n.map(t=>t.bar).filter(t=>t!=null))>0?0:Math.min(...n.map(t=>t.bar).filter(t=>t!=null)):0,R=Math.min(...n.map(t=>t.line).filter(t=>t!=null))!==1/0?Math.min(...n.map(t=>t.line).filter(t=>t!=null))>0?0:Math.min(...n.map(t=>t.line).filter(t=>t!=null)):0,T=Math.max(...n.map(t=>t.bar).filter(t=>t!=null))!==1/0?Math.max(...n.map(t=>t.bar).filter(t=>t!=null)):0,O=Math.max(...n.map(t=>t.line).filter(t=>t!=null))!==1/0?Math.max(...n.map(t=>t.line).filter(t=>t!=null)):0,G=W<R?W:R,y=T>O?T:O,a=yt.linear().domain([b?G:W,b?y>0?y:0:T>0?T:0]).range([g,0]).nice(),i=yt.linear().domain([b?G:R,b?y>0?y:0:O>0?O:0]).range([g,0]).nice(),B=jt.line().defined(t=>!pt.checkIfNullOrUndefined(t.line)).x(t=>x(`${t.id}`)+x.bandwidth()/2).y(t=>i(t.line)).curve(ht),bt=a.ticks(tt),vt=i.ticks(tt);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(P.motion.svg,{width:`${M}px`,height:`${V}px`,viewBox:`0 0 ${M} ${V}`,direction:"ltr",ref:nt,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${h.left},${h.top})`,children:[e.jsxRuntimeExports.jsxs("g",{children:[bt.map((t,A)=>e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx("line",{y1:a(t),y2:a(t),x1:-15,x2:-20,style:{stroke:d,strokeWidth:1,...o?.yAxis?.gridLines||{}},className:l?.yAxis?.gridLines}),e.jsxRuntimeExports.jsx("text",{x:-25,y:a(t),dy:"0.33em",className:e.mo("text-xs",l?.yAxis?.labels),style:{textAnchor:"end",fill:d,...o?.yAxis?.labels||{}},children:ot.numberFormattingFunction(t,C,H,it,Y)})]},A)),e.jsxRuntimeExports.jsx(dt.Axis,{y1:0,y2:g,x1:-15,x2:-15,classNames:{axis:l?.xAxis?.axis},styles:{axis:{stroke:d,...o?.xAxis?.axis||{}}}}),st?e.jsxRuntimeExports.jsx(ft.AxisTitle,{x:10-h.left,y:g/2,style:{fill:d,...o?.yAxis?.title||{}},className:l?.yAxis?.title,text:s[0].length>100?`${s[0].substring(0,100)}...`:s[0],rotate90:!0}):null]}),e.jsxRuntimeExports.jsxs("g",{children:[vt.map((t,A)=>e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx("line",{y1:i(t),y2:i(t),x1:p+15,x2:p+20,style:{stroke:u,strokeWidth:1,...o?.yAxis?.gridLines||{}},className:l?.yAxis?.gridLines}),e.jsxRuntimeExports.jsx("text",{x:p+25,y:i(t),dy:"0.33em",dx:-2,style:{textAnchor:"start",fill:u,...o?.yAxis?.labels||{}},className:e.mo("text-xs",l?.yAxis?.labels),children:ot.numberFormattingFunction(t,C,H,X,et)})]},A)),e.jsxRuntimeExports.jsx(dt.Axis,{y1:0,y2:g,x1:p+15,x2:p+15,classNames:{axis:l?.xAxis?.axis},styles:{axis:{stroke:u,...o?.xAxis?.axis||{}}}}),st?e.jsxRuntimeExports.jsx(ft.AxisTitle,{x:p+h.right-15,y:g/2,style:{fill:u,...o?.yAxis?.title||{}},className:l?.yAxis?.title,text:s[1].length>100?`${s[1].substring(0,100)}...`:s[1],rotate90:!0}):null]}),e.jsxRuntimeExports.jsx(dt.Axis,{y1:b?a(0):g,y2:b?a(0):g,x1:-15,x2:p+15,classNames:{axis:l?.xAxis?.axis},styles:{axis:o?.xAxis?.axis}}),I.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(Nt.AnimatePresence,{children:[n.map((t,A)=>e.jsxRuntimeExports.jsxs(P.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{k(t),c(f.clientY),S(f.clientX),D?.(t)},onClick:()=>{(w||m)&&(gt.isEqual($,t)&&Z?(L(void 0),w?.(void 0)):(L(t),w?.(t)))},onMouseMove:f=>{k(t),c(f.clientY),S(f.clientX)},onMouseLeave:()=>{k(void 0),S(void 0),c(void 0),D?.(void 0)},children:[e.jsxRuntimeExports.jsx(P.motion.rect,{variants:{initial:{attrY:a(0),height:0,opacity:1},whileInView:{attrY:t.bar?t.bar>0?a(t.bar):a(0):0,height:t.bar?Math.abs(a(t.bar)-a(0)):0,opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",exit:{attrY:a(0),height:0,opacity:0,transition:{duration:r.duration}},x:x(`${A}`),width:x.bandwidth(),style:{fill:d}}),J&&!pt.checkIfNullOrUndefined(t.bar)?e.jsxRuntimeExports.jsx(P.motion.text,{x:x(`${t.id}`)+x.bandwidth()/2,exit:{attrY:a(0),opacity:0,transition:{duration:r.duration}},variants:{initial:{attrY:a(0),opacity:0},whileInView:{attrY:a(t.bar||0),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",style:{fill:d,textAnchor:"middle",...o?.graphObjectValues||{}},className:e.mo("graph-value text-sm",l?.graphObjectValues),dy:t.bar?t.bar>=0?"-5px":"1em":"-5px",children:ot.numberFormattingFunction(t.bar,C,H,it,Y)}):null,Q?e.jsxRuntimeExports.jsx(At.XAxesLabels,{value:`${t.label}`.length<K?`${t.label}`:`${`${t.label}`.substring(0,K)}...`,y:g+5,x:x(`${t.id}`),width:x.bandwidth(),height:h.bottom,style:o?.xAxis?.labels,className:l?.xAxis?.labels,alignment:"top",animate:r,isInView:N}):null]},t.label)),e.jsxRuntimeExports.jsx(P.motion.path,{exit:{opacity:0,transition:{duration:r.duration}},variants:{initial:{d:B(n.map(t=>({...t,line:0}))),opacity:0},whileInView:{d:B(n),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",style:{stroke:u,fill:"none",strokeWidth:2}}),n.map((t,A)=>e.jsxRuntimeExports.jsx("g",{children:pt.checkIfNullOrUndefined(t.line)?null:e.jsxRuntimeExports.jsxs("g",{onMouseEnter:f=>{k(t),c(f.clientY),S(f.clientX),D?.(t)},onClick:()=>{(w||m)&&(gt.isEqual($,t)&&Z?(L(void 0),w?.(void 0)):(L(t),w?.(t)))},onMouseMove:f=>{k(t),c(f.clientY),S(f.clientX)},onMouseLeave:()=>{k(void 0),S(void 0),c(void 0),D?.(void 0)},children:[e.jsxRuntimeExports.jsx(P.motion.circle,{exit:{cy:i(0),opacity:0,transition:{duration:r.duration}},variants:{initial:{cy:i(0),opacity:0},whileInView:{cy:i(t.line),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",cx:x(t.id)+x.bandwidth()/2,r:p/n.length<5?0:p/n.length<20?2:4,style:{fill:u}}),J?e.jsxRuntimeExports.jsx(P.motion.text,{x:x(`${t.id}`)+x.bandwidth()/2,exit:{y:i(0),opacity:0,transition:{duration:r.duration}},style:{fill:u,textAnchor:"middle",...o?.graphObjectValues||{}},variants:{initial:{y:i(0),opacity:0},whileInView:{y:i(t.line),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",className:e.mo("graph-value text-sm",l?.graphObjectValues),dy:"-5px",children:ot.numberFormattingFunction(t.line,C,H,X,et)}):null]})},A))]}),I.filter(t=>t.position==="after").map(t=>t.layer)]})}),at&&v&&rt&&E?e.jsxRuntimeExports.jsx(Et.Tooltip,{data:at,body:v,xPos:rt,yPos:E,backgroundStyle:o?.tooltip,className:l?.tooltip}):null,m&&$!==void 0?e.jsxRuntimeExports.jsx(wt.X,{open:$!==void 0,onClose:()=>{L(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof m=="string"?{__html:Rt.string2HTML(m,$)}:void 0,children:typeof m=="function"?m($):null})}):null]})}function Lt(ct){const{data:q,graphTitle:M,sources:V,graphDescription:d,height:u,width:s,footNote:b,padding:U,lineColor:z=xt.Colors.light.categoricalColors.colors[1],barColor:_=xt.Colors.light.categoricalColors.colors[0],sameAxes:ut=!1,backgroundColor:v=!1,leftMargin:J=80,rightMargin:D=80,topMargin:mt=20,bottomMargin:K=25,lineAxisTitle:Q="Line chart",barAxisTitle:w="Bar graph",tooltip:Z,relativeHeight:m,onSeriesMouseOver:tt,graphID:et,graphDownload:Y=!1,dataDownload:X=!1,barPadding:it=.25,truncateBy:F=999,showLabels:o=!0,onSeriesMouseClick:l,language:r="en",colorLegendTitle:H,minHeight:I=0,theme:C="light",ariaLabel:st,resetSelectionOnDoubleClick:nt=!0,detailsOnClick:N,showValues:ht=!0,noOfTicks:at=5,lineSuffix:k="",barSuffix:$="",linePrefix:L="",barPrefix:rt="",curveType:S="curve",styles:E,classNames:c,animate:h=!1,precision:p=2,customLayers:g=[],naLabel:n="NA",showColorScale:x=!0,showAxisLabels:W=!0}=ct,[R,T]=j.useState(0),[O,G]=j.useState(0),y=j.useRef(null),a=j.useRef(null);return j.useEffect(()=>{const i=new ResizeObserver(B=>{T(s||B[0].target.clientWidth||620),G(u||B[0].target.clientHeight||480)});return y.current&&(G(y.current.clientHeight||480),T(y.current.clientWidth||620),s||i.observe(y.current)),()=>i.disconnect()},[s,u]),e.jsxRuntimeExports.jsx("div",{className:`${C||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:r==="he"||r==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.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 ${r||"en"}`,s?"w-fit":"w-full",c?.graphContainer),style:{...E?.graphContainer||{},...v&&v!==!0?{backgroundColor:v}:{}},id:et,ref:a,"aria-label":st||`${M?`The graph shows ${M}. `:""}This is a pareto chart that shows a variable as bars and another as line chart.${d?` ${d}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:v?U||"1rem":U||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[M||d||Y||X?e.jsxRuntimeExports.jsx($t.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:c?.title,description:c?.description},graphTitle:M,graphDescription:d,width:s,graphDownload:Y?a.current:void 0,dataDownload:X?q.map(i=>i.data).filter(i=>i!==void 0).length>0?q.map(i=>i.data).filter(i=>i!==void 0):q.filter(i=>i!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:q.length===0?e.jsxRuntimeExports.jsx(qt.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x?e.jsxRuntimeExports.jsx(St.ColorLegend,{colorDomain:[w,Q],colors:[_||xt.Colors[C].categoricalColors.colors[0],z||xt.Colors[C].categoricalColors.colors[1]],colorLegendTitle:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:y,"aria-label":"Graph area",children:(s||R)&&(u||O)?e.jsxRuntimeExports.jsx(It,{data:q,sameAxes:ut,lineColor:z,barColor:_,width:s||R,height:Math.max(I,u||(m?I?(s||R)*m>I?(s||R)*m:I:(s||R)*m:O)),truncateBy:F,leftMargin:J,rightMargin:D,topMargin:mt,bottomMargin:K,axisTitles:[w,Q],tooltip:Z,onSeriesMouseOver:tt,barPadding:it,showLabels:o,onSeriesMouseClick:l,resetSelectionOnDoubleClick:nt,detailsOnClick:N,noOfTicks:at,lineSuffix:k,barSuffix:$,linePrefix:L,barPrefix:rt,curveType:S,showValues:ht,styles:E,classNames:c,animate:h===!0?{duration:.5,once:!0,amount:.5}:h||{duration:0,once:!0,amount:0},precision:p,customLayers:g,naLabel:n,showAxisLabels:W}):null})]})}),V||b?e.jsxRuntimeExports.jsx(kt.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:c?.footnote,source:c?.source},sources:V,footNote:b,width:s}):null]})})})})}exports.ParetoChart=Lt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),j=require("react"),gt=require("./index-DQA8q5sC.cjs"),wt=require("./Modal-tXZlLE5s.cjs"),ot=require("./numberFormattingFunction-02t-wJta.cjs"),Et=require("./Tooltip-De16GWhY.cjs"),Rt=require("./string2HTML-z7CwHXcx.cjs"),pt=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),dt=require("./Axis-DE7dSn1_.cjs"),ft=require("./AxisTitle-CK9YeovX.cjs"),At=require("./XAxesLabels-Drf7M3YK.cjs"),Mt=require("./band-CAApY4Pd.cjs"),yt=require("./linear-BVckp9RD.cjs"),jt=require("./line-DHV4JwCR.cjs"),lt=require("./step-BZ3C8QFW.cjs"),Ct=require("./use-in-view-sQJZ_xDO.cjs"),P=require("./proxy-BHRoeZgd.cjs"),Nt=require("./index-BW8iNx7E.cjs"),kt=require("./GraphFooter.cjs"),$t=require("./GraphHeader.cjs"),St=require("./ColorLegend.cjs"),xt=require("./Colors.cjs"),qt=require("./EmptyState-d8_8SxeW.cjs");function It(ct){const{data:q,width:M,height:V,barColor:d,lineColor:u,axisTitles:s,sameAxes:b,rightMargin:U,leftMargin:z,topMargin:_,bottomMargin:ut,tooltip:v,showValues:J,onSeriesMouseOver:D,barPadding:mt,truncateBy:K,showLabels:Q,onSeriesMouseClick:w,resetSelectionOnDoubleClick:Z,detailsOnClick:m,noOfTicks:tt,lineSuffix:et,barSuffix:Y,linePrefix:X,barPrefix:it,curveType:F,styles:o,classNames:l,animate:r,precision:H,customLayers:I,naLabel:C,showAxisLabels:st}=ct,nt=j.useRef(null),N=Ct.useInView(nt,{once:r.once,amount:r.amount}),ht=F==="linear"?jt.curveLinear:F==="step"?lt.curveStep:F==="stepAfter"?lt.stepAfter:F==="stepBefore"?lt.stepBefore:lt.monotoneX,[at,k]=j.useState(void 0),[$,L]=j.useState(void 0),[rt,S]=j.useState(void 0),[E,c]=j.useState(void 0),h={top:_,bottom:ut,left:z+50,right:U+65},p=M-h.left-h.right,g=V-h.top-h.bottom,n=q.map((t,A)=>({...t,id:`${A}`})),x=Mt.band().domain(n.map(t=>`${t.id}`)).range([0,p]).paddingInner(mt),W=Math.min(...n.map(t=>t.bar).filter(t=>t!=null))!==1/0?Math.min(...n.map(t=>t.bar).filter(t=>t!=null))>0?0:Math.min(...n.map(t=>t.bar).filter(t=>t!=null)):0,R=Math.min(...n.map(t=>t.line).filter(t=>t!=null))!==1/0?Math.min(...n.map(t=>t.line).filter(t=>t!=null))>0?0:Math.min(...n.map(t=>t.line).filter(t=>t!=null)):0,T=Math.max(...n.map(t=>t.bar).filter(t=>t!=null))!==1/0?Math.max(...n.map(t=>t.bar).filter(t=>t!=null)):0,O=Math.max(...n.map(t=>t.line).filter(t=>t!=null))!==1/0?Math.max(...n.map(t=>t.line).filter(t=>t!=null)):0,G=W<R?W:R,y=T>O?T:O,a=yt.linear().domain([b?G:W,b?y>0?y:0:T>0?T:0]).range([g,0]).nice(),i=yt.linear().domain([b?G:R,b?y>0?y:0:O>0?O:0]).range([g,0]).nice(),B=jt.line().defined(t=>!pt.checkIfNullOrUndefined(t.line)).x(t=>x(`${t.id}`)+x.bandwidth()/2).y(t=>i(t.line)).curve(ht),bt=a.ticks(tt),vt=i.ticks(tt);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(P.motion.svg,{width:`${M}px`,height:`${V}px`,viewBox:`0 0 ${M} ${V}`,direction:"ltr",ref:nt,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${h.left},${h.top})`,children:[e.jsxRuntimeExports.jsxs("g",{children:[bt.map((t,A)=>e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx("line",{y1:a(t),y2:a(t),x1:-15,x2:-20,style:{stroke:d,strokeWidth:1,...o?.yAxis?.gridLines||{}},className:l?.yAxis?.gridLines}),e.jsxRuntimeExports.jsx("text",{x:-25,y:a(t),dy:"0.33em",className:e.mo("text-xs",l?.yAxis?.labels),style:{textAnchor:"end",fill:d,...o?.yAxis?.labels||{}},children:ot.numberFormattingFunction(t,C,H,it,Y)})]},A)),e.jsxRuntimeExports.jsx(dt.Axis,{y1:0,y2:g,x1:-15,x2:-15,classNames:{axis:l?.xAxis?.axis},styles:{axis:{stroke:d,...o?.xAxis?.axis||{}}}}),st?e.jsxRuntimeExports.jsx(ft.AxisTitle,{x:10-h.left,y:g/2,style:{fill:d,...o?.yAxis?.title||{}},className:l?.yAxis?.title,text:s[0].length>100?`${s[0].substring(0,100)}...`:s[0],rotate90:!0}):null]}),e.jsxRuntimeExports.jsxs("g",{children:[vt.map((t,A)=>e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx("line",{y1:i(t),y2:i(t),x1:p+15,x2:p+20,style:{stroke:u,strokeWidth:1,...o?.yAxis?.gridLines||{}},className:l?.yAxis?.gridLines}),e.jsxRuntimeExports.jsx("text",{x:p+25,y:i(t),dy:"0.33em",dx:-2,style:{textAnchor:"start",fill:u,...o?.yAxis?.labels||{}},className:e.mo("text-xs",l?.yAxis?.labels),children:ot.numberFormattingFunction(t,C,H,X,et)})]},A)),e.jsxRuntimeExports.jsx(dt.Axis,{y1:0,y2:g,x1:p+15,x2:p+15,classNames:{axis:l?.xAxis?.axis},styles:{axis:{stroke:u,...o?.xAxis?.axis||{}}}}),st?e.jsxRuntimeExports.jsx(ft.AxisTitle,{x:p+h.right-15,y:g/2,style:{fill:u,...o?.yAxis?.title||{}},className:l?.yAxis?.title,text:s[1].length>100?`${s[1].substring(0,100)}...`:s[1],rotate90:!0}):null]}),e.jsxRuntimeExports.jsx(dt.Axis,{y1:b?a(0):g,y2:b?a(0):g,x1:-15,x2:p+15,classNames:{axis:l?.xAxis?.axis},styles:{axis:o?.xAxis?.axis}}),I.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(Nt.AnimatePresence,{children:[n.map((t,A)=>e.jsxRuntimeExports.jsxs(P.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{k(t),c(f.clientY),S(f.clientX),D?.(t)},onClick:()=>{(w||m)&&(gt.isEqual($,t)&&Z?(L(void 0),w?.(void 0)):(L(t),w?.(t)))},onMouseMove:f=>{k(t),c(f.clientY),S(f.clientX)},onMouseLeave:()=>{k(void 0),S(void 0),c(void 0),D?.(void 0)},children:[e.jsxRuntimeExports.jsx(P.motion.rect,{variants:{initial:{attrY:a(0),height:0,opacity:1},whileInView:{attrY:t.bar?t.bar>0?a(t.bar):a(0):0,height:t.bar?Math.abs(a(t.bar)-a(0)):0,opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",exit:{attrY:a(0),height:0,opacity:0,transition:{duration:r.duration}},x:x(`${A}`),width:x.bandwidth(),style:{fill:d}}),J&&!pt.checkIfNullOrUndefined(t.bar)?e.jsxRuntimeExports.jsx(P.motion.text,{x:x(`${t.id}`)+x.bandwidth()/2,exit:{attrY:a(0),opacity:0,transition:{duration:r.duration}},variants:{initial:{attrY:a(0),opacity:0},whileInView:{attrY:a(t.bar||0),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",style:{fill:d,textAnchor:"middle",...o?.graphObjectValues||{}},className:e.mo("graph-value text-sm",l?.graphObjectValues),dy:t.bar?t.bar>=0?"-5px":"1em":"-5px",children:ot.numberFormattingFunction(t.bar,C,H,it,Y)}):null,Q?e.jsxRuntimeExports.jsx(At.XAxesLabels,{value:`${t.label}`.length<K?`${t.label}`:`${`${t.label}`.substring(0,K)}...`,y:g+5,x:x(`${t.id}`),width:x.bandwidth(),height:h.bottom,style:o?.xAxis?.labels,className:l?.xAxis?.labels,alignment:"top",animate:r,isInView:N}):null]},t.label)),e.jsxRuntimeExports.jsx(P.motion.path,{exit:{opacity:0,transition:{duration:r.duration}},variants:{initial:{d:B(n.map(t=>({...t,line:0}))),opacity:0},whileInView:{d:B(n),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",style:{stroke:u,fill:"none",strokeWidth:2}}),n.map((t,A)=>e.jsxRuntimeExports.jsx("g",{children:pt.checkIfNullOrUndefined(t.line)?null:e.jsxRuntimeExports.jsxs("g",{onMouseEnter:f=>{k(t),c(f.clientY),S(f.clientX),D?.(t)},onClick:()=>{(w||m)&&(gt.isEqual($,t)&&Z?(L(void 0),w?.(void 0)):(L(t),w?.(t)))},onMouseMove:f=>{k(t),c(f.clientY),S(f.clientX)},onMouseLeave:()=>{k(void 0),S(void 0),c(void 0),D?.(void 0)},children:[e.jsxRuntimeExports.jsx(P.motion.circle,{exit:{cy:i(0),opacity:0,transition:{duration:r.duration}},variants:{initial:{cy:i(0),opacity:0},whileInView:{cy:i(t.line),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",cx:x(t.id)+x.bandwidth()/2,r:p/n.length<5?0:p/n.length<20?2:4,style:{fill:u}}),J?e.jsxRuntimeExports.jsx(P.motion.text,{x:x(`${t.id}`)+x.bandwidth()/2,exit:{y:i(0),opacity:0,transition:{duration:r.duration}},style:{fill:u,textAnchor:"middle",...o?.graphObjectValues||{}},variants:{initial:{y:i(0),opacity:0},whileInView:{y:i(t.line),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",className:e.mo("graph-value text-sm",l?.graphObjectValues),dy:"-5px",children:ot.numberFormattingFunction(t.line,C,H,X,et)}):null]})},A))]}),I.filter(t=>t.position==="after").map(t=>t.layer)]})}),at&&v&&rt&&E?e.jsxRuntimeExports.jsx(Et.Tooltip,{data:at,body:v,xPos:rt,yPos:E,backgroundStyle:o?.tooltip,className:l?.tooltip}):null,m&&$!==void 0?e.jsxRuntimeExports.jsx(wt.X,{open:$!==void 0,onClose:()=>{L(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof m=="string"?{__html:Rt.string2HTML(m,$)}:void 0,children:typeof m=="function"?m($):null})}):null]})}function Lt(ct){const{data:q,graphTitle:M,sources:V,graphDescription:d,height:u,width:s,footNote:b,padding:U,lineColor:z=xt.Colors.light.categoricalColors.colors[1],barColor:_=xt.Colors.light.categoricalColors.colors[0],sameAxes:ut=!1,backgroundColor:v=!1,leftMargin:J=80,rightMargin:D=80,topMargin:mt=20,bottomMargin:K=25,lineAxisTitle:Q="Line chart",barAxisTitle:w="Bar graph",tooltip:Z,relativeHeight:m,onSeriesMouseOver:tt,graphID:et,graphDownload:Y=!1,dataDownload:X=!1,barPadding:it=.25,truncateBy:F=999,showLabels:o=!0,onSeriesMouseClick:l,language:r="en",colorLegendTitle:H,minHeight:I=0,theme:C="light",ariaLabel:st,resetSelectionOnDoubleClick:nt=!0,detailsOnClick:N,showValues:ht=!0,noOfTicks:at=5,lineSuffix:k="",barSuffix:$="",linePrefix:L="",barPrefix:rt="",curveType:S="curve",styles:E,classNames:c,animate:h=!1,precision:p=2,customLayers:g=[],naLabel:n="NA",showColorScale:x=!0,showAxisLabels:W=!0}=ct,[R,T]=j.useState(0),[O,G]=j.useState(0),y=j.useRef(null),a=j.useRef(null);return j.useEffect(()=>{const i=new ResizeObserver(B=>{T(s||B[0].target.clientWidth||620),G(u||B[0].target.clientHeight||480)});return y.current&&(G(y.current.clientHeight||480),T(y.current.clientWidth||620),s||i.observe(y.current)),()=>i.disconnect()},[s,u]),e.jsxRuntimeExports.jsx("div",{className:`${C||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:r==="he"||r==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.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 ${r||"en"}`,s?"w-fit":"w-full",c?.graphContainer),style:{...E?.graphContainer||{},...v&&v!==!0?{backgroundColor:v}:{}},id:et,ref:a,"aria-label":st||`${M?`The graph shows ${M}. `:""}This is a pareto chart that shows a variable as bars and another as line chart.${d?` ${d}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:v?U||"1rem":U||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[M||d||Y||X?e.jsxRuntimeExports.jsx($t.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:c?.title,description:c?.description},graphTitle:M,graphDescription:d,width:s,graphDownload:Y?a.current:void 0,dataDownload:X?q.map(i=>i.data).filter(i=>i!==void 0).length>0?q.map(i=>i.data).filter(i=>i!==void 0):q.filter(i=>i!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:q.length===0?e.jsxRuntimeExports.jsx(qt.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x?e.jsxRuntimeExports.jsx(St.ColorLegend,{colorDomain:[w,Q],colors:[_||xt.Colors[C].categoricalColors.colors[0],z||xt.Colors[C].categoricalColors.colors[1]],colorLegendTitle:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:y,"aria-label":"Graph area",children:(s||R)&&(u||O)?e.jsxRuntimeExports.jsx(It,{data:q,sameAxes:ut,lineColor:z,barColor:_,width:s||R,height:Math.max(I,u||(m?I?(s||R)*m>I?(s||R)*m:I:(s||R)*m:O)),truncateBy:F,leftMargin:J,rightMargin:D,topMargin:mt,bottomMargin:K,axisTitles:[w,Q],tooltip:Z,onSeriesMouseOver:tt,barPadding:it,showLabels:o,onSeriesMouseClick:l,resetSelectionOnDoubleClick:nt,detailsOnClick:N,noOfTicks:at,lineSuffix:k,barSuffix:$,linePrefix:L,barPrefix:rt,curveType:S,showValues:ht,styles:E,classNames:c,animate:h===!0?{duration:.5,once:!0,amount:.5}:h||{duration:0,once:!0,amount:0},precision:p,customLayers:g,naLabel:n,showAxisLabels:W}):null})]})}),V||b?e.jsxRuntimeExports.jsx(kt.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:c?.footnote,source:c?.source},sources:V,footNote:b,width:s}):null]})})})})}exports.ParetoChart=Lt;
2
2
  //# sourceMappingURL=ParetoChart.cjs.map
@@ -8,7 +8,7 @@ import { s as Ni } from "./string2HTML-oFCROsus.js";
8
8
  import { c as di } from "./checkIfNullOrUndefined-DmfiKkNw.js";
9
9
  import { A as pi } from "./Axis-Ddg-seDi.js";
10
10
  import { A as yi } from "./AxisTitle-BmHLMRJZ.js";
11
- import { X as ki } from "./XAxesLabels-CaV2q-6H.js";
11
+ import { X as ki } from "./XAxesLabels-loO78vUO.js";
12
12
  import { b as Ci } from "./band-BEjh2CHI.js";
13
13
  import { a as bi } from "./linear-DUdu7l2G.js";
14
14
  import { l as $i, c as Li } from "./line-CPfhohvF.js";
@@ -0,0 +1,2 @@
1
+ "use strict";const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),u=require("./proxy-BHRoeZgd.cjs");function d(s){const{value:r,y:t,x:e,style:a,className:l,width:x,height:o,alignment:c="top",animate:n,isInView:m}=s;return i.jsxRuntimeExports.jsx(u.motion.g,{variants:{initial:{x:e,y:t},whileInView:{x:e,y:t,transition:{duration:n.duration}}},initial:"initial",animate:m?"whileInView":"initial",exit:{opacity:0,transition:{duration:n.duration}},children:i.jsxRuntimeExports.jsx("foreignObject",{width:x,height:o,y:0,x:0,children:i.jsxRuntimeExports.jsx("div",{className:`flex flex-col items-center h-inherit ${c==="top"?"justify-start":"justify-end"}`,children:i.jsxRuntimeExports.jsx("p",{className:i.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 text-center leading-none",l),style:a,children:r})})})},t)}exports.XAxesLabels=d;
2
+ //# sourceMappingURL=XAxesLabels-Drf7M3YK.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XAxesLabels-Drf7M3YK.cjs","sources":["../src/Components/Elements/Axes/XAxesLabels.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\n\r\ninterface Props {\r\n value: number | string;\r\n y: number;\r\n x: number;\r\n width: number;\r\n height: number;\r\n style?: React.CSSProperties;\r\n className?: string;\r\n alignment?: 'top' | 'bottom';\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function XAxesLabels(props: Props) {\r\n const {\r\n value,\r\n y,\r\n x,\r\n style,\r\n className,\r\n width,\r\n height,\r\n alignment = 'top',\r\n animate,\r\n isInView,\r\n } = props;\r\n return (\r\n <motion.g\r\n key={y}\r\n variants={{\r\n initial: {\r\n x,\r\n y,\r\n },\r\n whileInView: {\r\n x,\r\n y,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <foreignObject width={width} height={height} y={0} x={0}>\r\n <div\r\n className={`flex flex-col items-center h-inherit ${\r\n alignment === 'top' ? 'justify-start' : 'justify-end'\r\n }`}\r\n >\r\n <p\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 text-center leading-none',\r\n className,\r\n )}\r\n style={style}\r\n >\r\n {value}\r\n </p>\r\n </div>\r\n </foreignObject>\r\n </motion.g>\r\n );\r\n}\r\n"],"names":["XAxesLabels","props","value","y","x","style","className","width","height","alignment","animate","isInView","jsx","motion","cn"],"mappings":"gGAkBO,SAASA,EAAYC,EAAc,CACxC,KAAM,CACJ,MAAAC,EACA,EAAAC,EACA,EAAAC,EACA,MAAAC,EACA,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,UAAAC,EAAY,MACZ,QAAAC,EACA,SAAAC,CAAA,EACEV,EACJ,OACEW,EAAAA,kBAAAA,IAACC,EAAAA,OAAO,EAAP,CAEC,SAAU,CACR,QAAS,CACP,EAAAT,EACA,EAAAD,CAAA,EAEF,YAAa,CACX,EAAAC,EACA,EAAAD,EACA,WAAY,CAAE,SAAUO,EAAQ,QAAA,CAAS,CAC3C,EAEF,QAAQ,UACR,QAASC,EAAW,cAAgB,UACpC,KAAM,CAAE,QAAS,EAAG,WAAY,CAAE,SAAUD,EAAQ,SAAS,EAE7D,iCAAC,gBAAA,CAAc,MAAAH,EAAc,OAAAC,EAAgB,EAAG,EAAG,EAAG,EACpD,SAAAI,EAAAA,kBAAAA,IAAC,MAAA,CACC,UAAW,wCACTH,IAAc,MAAQ,gBAAkB,aAC1C,GAEA,SAAAG,EAAAA,kBAAAA,IAAC,IAAA,CACC,UAAWE,EAAAA,GACT,oGACAR,CAAA,EAEF,MAAAD,EAEC,SAAAH,CAAA,CAAA,CACH,CAAA,CACF,CACF,CAAA,EAhCKC,CAAA,CAmCX"}
@@ -1,37 +1,36 @@
1
1
  import { j as i, m as d } from "./index-CHPV5EwG-BPSP-7Jg.js";
2
2
  import { m as p } from "./proxy-CkpFesk1.js";
3
- function u(a) {
3
+ function f(a) {
4
4
  const {
5
- value: n,
6
- y: r,
7
- x: t,
5
+ value: r,
6
+ y: t,
7
+ x: e,
8
8
  style: s,
9
9
  className: l,
10
10
  width: o,
11
11
  height: m,
12
12
  alignment: x = "top",
13
- animate: e,
13
+ animate: n,
14
14
  isInView: c
15
15
  } = a;
16
16
  return /* @__PURE__ */ i.jsx(
17
- p.foreignObject,
17
+ p.g,
18
18
  {
19
- width: o,
20
- height: m,
21
- y: r,
22
19
  variants: {
23
20
  initial: {
24
- x: t
21
+ x: e,
22
+ y: t
25
23
  },
26
24
  whileInView: {
27
- x: t,
28
- transition: { duration: e.duration }
25
+ x: e,
26
+ y: t,
27
+ transition: { duration: n.duration }
29
28
  }
30
29
  },
31
30
  initial: "initial",
32
31
  animate: c ? "whileInView" : "initial",
33
- exit: { opacity: 0, transition: { duration: e.duration } },
34
- children: /* @__PURE__ */ i.jsx(
32
+ exit: { opacity: 0, transition: { duration: n.duration } },
33
+ children: /* @__PURE__ */ i.jsx("foreignObject", { width: o, height: m, y: 0, x: 0, children: /* @__PURE__ */ i.jsx(
35
34
  "div",
36
35
  {
37
36
  className: `flex flex-col items-center h-inherit ${x === "top" ? "justify-start" : "justify-end"}`,
@@ -43,15 +42,16 @@ function u(a) {
43
42
  l
44
43
  ),
45
44
  style: s,
46
- children: n
45
+ children: r
47
46
  }
48
47
  )
49
48
  }
50
- )
51
- }
49
+ ) })
50
+ },
51
+ t
52
52
  );
53
53
  }
54
54
  export {
55
- u as X
55
+ f as X
56
56
  };
57
- //# sourceMappingURL=XAxesLabels-CaV2q-6H.js.map
57
+ //# sourceMappingURL=XAxesLabels-loO78vUO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XAxesLabels-loO78vUO.js","sources":["../src/Components/Elements/Axes/XAxesLabels.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\n\r\ninterface Props {\r\n value: number | string;\r\n y: number;\r\n x: number;\r\n width: number;\r\n height: number;\r\n style?: React.CSSProperties;\r\n className?: string;\r\n alignment?: 'top' | 'bottom';\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function XAxesLabels(props: Props) {\r\n const {\r\n value,\r\n y,\r\n x,\r\n style,\r\n className,\r\n width,\r\n height,\r\n alignment = 'top',\r\n animate,\r\n isInView,\r\n } = props;\r\n return (\r\n <motion.g\r\n key={y}\r\n variants={{\r\n initial: {\r\n x,\r\n y,\r\n },\r\n whileInView: {\r\n x,\r\n y,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <foreignObject width={width} height={height} y={0} x={0}>\r\n <div\r\n className={`flex flex-col items-center h-inherit ${\r\n alignment === 'top' ? 'justify-start' : 'justify-end'\r\n }`}\r\n >\r\n <p\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 text-center leading-none',\r\n className,\r\n )}\r\n style={style}\r\n >\r\n {value}\r\n </p>\r\n </div>\r\n </foreignObject>\r\n </motion.g>\r\n );\r\n}\r\n"],"names":["XAxesLabels","props","value","y","x","style","className","width","height","alignment","animate","isInView","jsx","motion","cn"],"mappings":";;AAkBO,SAASA,EAAYC,GAAc;AACxC,QAAM;AAAA,IACJ,OAAAC;AAAA,IACA,GAAAC;AAAA,IACA,GAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,SAAAC;AAAA,IACA,UAAAC;AAAA,EAAA,IACEV;AACJ,SACEW,gBAAAA,EAAAA;AAAAA,IAACC,EAAO;AAAA,IAAP;AAAA,MAEC,UAAU;AAAA,QACR,SAAS;AAAA,UACP,GAAAT;AAAA,UACA,GAAAD;AAAA,QAAA;AAAA,QAEF,aAAa;AAAA,UACX,GAAAC;AAAA,UACA,GAAAD;AAAA,UACA,YAAY,EAAE,UAAUO,EAAQ,SAAA;AAAA,QAAS;AAAA,MAC3C;AAAA,MAEF,SAAQ;AAAA,MACR,SAASC,IAAW,gBAAgB;AAAA,MACpC,MAAM,EAAE,SAAS,GAAG,YAAY,EAAE,UAAUD,EAAQ,WAAS;AAAA,MAE7D,gCAAC,iBAAA,EAAc,OAAAH,GAAc,QAAAC,GAAgB,GAAG,GAAG,GAAG,GACpD,UAAAI,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW,wCACTH,MAAc,QAAQ,kBAAkB,aAC1C;AAAA,UAEA,UAAAG,gBAAAA,EAAAA;AAAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWE;AAAAA,gBACT;AAAA,gBACAR;AAAA,cAAA;AAAA,cAEF,OAAAD;AAAA,cAEC,UAAAH;AAAA,YAAA;AAAA,UAAA;AAAA,QACH;AAAA,MAAA,EACF,CACF;AAAA,IAAA;AAAA,IAhCKC;AAAA,EAAA;AAmCX;"}
@@ -1,37 +1,36 @@
1
1
  import { j as i, m as d } from "./index-CHPV5EwG-BPSP-7Jg.js";
2
2
  import { m as h } from "./proxy-CkpFesk1.js";
3
- function u(n) {
3
+ function f(e) {
4
4
  const {
5
- value: e,
6
- y: t,
7
- x: r,
5
+ value: r,
6
+ y: a,
7
+ x: t,
8
8
  style: s,
9
9
  className: l,
10
10
  width: o,
11
11
  height: m,
12
12
  alignment: x = "right",
13
- animate: a,
13
+ animate: n,
14
14
  isInView: c
15
- } = n;
15
+ } = e;
16
16
  return /* @__PURE__ */ i.jsx(
17
- h.foreignObject,
17
+ h.g,
18
18
  {
19
- width: o,
20
- height: m,
21
- x: r,
22
19
  variants: {
23
20
  initial: {
24
- y: t
21
+ y: a,
22
+ x: t
25
23
  },
26
24
  whileInView: {
27
- y: t,
28
- transition: { duration: a.duration }
25
+ y: a,
26
+ x: t,
27
+ transition: { duration: n.duration }
29
28
  }
30
29
  },
31
30
  initial: "initial",
32
31
  animate: c ? "whileInView" : "initial",
33
- exit: { opacity: 0, transition: { duration: a.duration } },
34
- children: /* @__PURE__ */ i.jsx("div", { className: "flex flex-col justify-center h-inherit", children: /* @__PURE__ */ i.jsx(
32
+ exit: { opacity: 0, transition: { duration: n.duration } },
33
+ children: /* @__PURE__ */ i.jsx("foreignObject", { y: 0, x: 0, width: o, height: m, children: /* @__PURE__ */ i.jsx("div", { className: "flex flex-col justify-center h-inherit", children: /* @__PURE__ */ i.jsx(
35
34
  "p",
36
35
  {
37
36
  className: d(
@@ -40,13 +39,14 @@ function u(n) {
40
39
  l
41
40
  ),
42
41
  style: s,
43
- children: e
42
+ children: r
44
43
  }
45
- ) })
46
- }
44
+ ) }) })
45
+ },
46
+ t
47
47
  );
48
48
  }
49
49
  export {
50
- u as Y
50
+ f as Y
51
51
  };
52
- //# sourceMappingURL=YAxesLabels-CPGZjmZJ.js.map
52
+ //# sourceMappingURL=YAxesLabels-DECkMgq8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YAxesLabels-DECkMgq8.js","sources":["../src/Components/Elements/Axes/YAxesLabels.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\n\r\ninterface Props {\r\n value: number | string;\r\n y: number;\r\n x: number;\r\n width: number;\r\n height: number;\r\n style?: React.CSSProperties;\r\n className?: string;\r\n alignment?: 'left' | 'right' | 'center';\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function YAxesLabels(props: Props) {\r\n const {\r\n value,\r\n y,\r\n x,\r\n style,\r\n className,\r\n width,\r\n height,\r\n alignment = 'right',\r\n animate,\r\n isInView,\r\n } = props;\r\n return (\r\n <motion.g\r\n key={x}\r\n variants={{\r\n initial: {\r\n y,\r\n x,\r\n },\r\n whileInView: {\r\n y,\r\n x,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <foreignObject y={0} x={0} width={width} height={height}>\r\n <div className='flex flex-col justify-center h-inherit'>\r\n <p\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 leading-none',\r\n `text-${alignment}`,\r\n className,\r\n )}\r\n style={style}\r\n >\r\n {value}\r\n </p>\r\n </div>\r\n </foreignObject>\r\n </motion.g>\r\n );\r\n}\r\n"],"names":["YAxesLabels","props","value","y","x","style","className","width","height","alignment","animate","isInView","jsx","motion","cn"],"mappings":";;AAkBO,SAASA,EAAYC,GAAc;AACxC,QAAM;AAAA,IACJ,OAAAC;AAAA,IACA,GAAAC;AAAA,IACA,GAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,SAAAC;AAAA,IACA,UAAAC;AAAA,EAAA,IACEV;AACJ,SACEW,gBAAAA,EAAAA;AAAAA,IAACC,EAAO;AAAA,IAAP;AAAA,MAEC,UAAU;AAAA,QACR,SAAS;AAAA,UACP,GAAAV;AAAA,UACA,GAAAC;AAAA,QAAA;AAAA,QAEF,aAAa;AAAA,UACX,GAAAD;AAAA,UACA,GAAAC;AAAA,UACA,YAAY,EAAE,UAAUM,EAAQ,SAAA;AAAA,QAAS;AAAA,MAC3C;AAAA,MAEF,SAAQ;AAAA,MACR,SAASC,IAAW,gBAAgB;AAAA,MACpC,MAAM,EAAE,SAAS,GAAG,YAAY,EAAE,UAAUD,EAAQ,WAAS;AAAA,MAE7D,UAAAE,gBAAAA,EAAAA,IAAC,iBAAA,EAAc,GAAG,GAAG,GAAG,GAAG,OAAAL,GAAc,QAAAC,GACvC,UAAAI,gBAAAA,EAAAA,IAAC,OAAA,EAAI,WAAU,0CACb,UAAAA,gBAAAA,EAAAA;AAAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAWE;AAAAA,YACT;AAAA,YACA,QAAQL,CAAS;AAAA,YACjBH;AAAA,UAAA;AAAA,UAEF,OAAAD;AAAA,UAEC,UAAAH;AAAA,QAAA;AAAA,MAAA,GAEL,EAAA,CACF;AAAA,IAAA;AAAA,IA7BKE;AAAA,EAAA;AAgCX;"}
@@ -0,0 +1,2 @@
1
+ "use strict";const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),u=require("./proxy-BHRoeZgd.cjs");function d(r){const{value:s,y:e,x:t,style:a,className:l,width:x,height:o,alignment:c="right",animate:n,isInView:m}=r;return i.jsxRuntimeExports.jsx(u.motion.g,{variants:{initial:{y:e,x:t},whileInView:{y:e,x:t,transition:{duration:n.duration}}},initial:"initial",animate:m?"whileInView":"initial",exit:{opacity:0,transition:{duration:n.duration}},children:i.jsxRuntimeExports.jsx("foreignObject",{y:0,x:0,width:x,height:o,children:i.jsxRuntimeExports.jsx("div",{className:"flex flex-col justify-center h-inherit",children:i.jsxRuntimeExports.jsx("p",{className:i.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 leading-none",`text-${c}`,l),style:a,children:s})})})},t)}exports.YAxesLabels=d;
2
+ //# sourceMappingURL=YAxesLabels-yRFFdx1s.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"YAxesLabels-yRFFdx1s.cjs","sources":["../src/Components/Elements/Axes/YAxesLabels.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\n\r\ninterface Props {\r\n value: number | string;\r\n y: number;\r\n x: number;\r\n width: number;\r\n height: number;\r\n style?: React.CSSProperties;\r\n className?: string;\r\n alignment?: 'left' | 'right' | 'center';\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function YAxesLabels(props: Props) {\r\n const {\r\n value,\r\n y,\r\n x,\r\n style,\r\n className,\r\n width,\r\n height,\r\n alignment = 'right',\r\n animate,\r\n isInView,\r\n } = props;\r\n return (\r\n <motion.g\r\n key={x}\r\n variants={{\r\n initial: {\r\n y,\r\n x,\r\n },\r\n whileInView: {\r\n y,\r\n x,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <foreignObject y={0} x={0} width={width} height={height}>\r\n <div className='flex flex-col justify-center h-inherit'>\r\n <p\r\n className={cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 text-xs m-0 py-0 px-1.5 leading-none',\r\n `text-${alignment}`,\r\n className,\r\n )}\r\n style={style}\r\n >\r\n {value}\r\n </p>\r\n </div>\r\n </foreignObject>\r\n </motion.g>\r\n );\r\n}\r\n"],"names":["YAxesLabels","props","value","y","x","style","className","width","height","alignment","animate","isInView","jsx","motion","cn"],"mappings":"gGAkBO,SAASA,EAAYC,EAAc,CACxC,KAAM,CACJ,MAAAC,EACA,EAAAC,EACA,EAAAC,EACA,MAAAC,EACA,UAAAC,EACA,MAAAC,EACA,OAAAC,EACA,UAAAC,EAAY,QACZ,QAAAC,EACA,SAAAC,CAAA,EACEV,EACJ,OACEW,EAAAA,kBAAAA,IAACC,EAAAA,OAAO,EAAP,CAEC,SAAU,CACR,QAAS,CACP,EAAAV,EACA,EAAAC,CAAA,EAEF,YAAa,CACX,EAAAD,EACA,EAAAC,EACA,WAAY,CAAE,SAAUM,EAAQ,QAAA,CAAS,CAC3C,EAEF,QAAQ,UACR,QAASC,EAAW,cAAgB,UACpC,KAAM,CAAE,QAAS,EAAG,WAAY,CAAE,SAAUD,EAAQ,SAAS,EAE7D,SAAAE,EAAAA,kBAAAA,IAAC,gBAAA,CAAc,EAAG,EAAG,EAAG,EAAG,MAAAL,EAAc,OAAAC,EACvC,SAAAI,EAAAA,kBAAAA,IAAC,MAAA,CAAI,UAAU,yCACb,SAAAA,EAAAA,kBAAAA,IAAC,IAAA,CACC,UAAWE,EAAAA,GACT,wFACA,QAAQL,CAAS,GACjBH,CAAA,EAEF,MAAAD,EAEC,SAAAH,CAAA,CAAA,EAEL,CAAA,CACF,CAAA,EA7BKE,CAAA,CAgCX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@undp/data-viz",
3
- "version": "1.5.3",
3
+ "version": "1.5.5",
4
4
  "main": "./dist/index.cjs",
5
5
  "module": "./dist/index.js",
6
6
  "browser": "./dist/index.umd.js",