@undp/data-viz 1.4.15 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AreaChart.cjs +1 -1
- package/dist/AreaChart.js +4 -4
- package/dist/BarGraph.cjs +1 -1
- package/dist/BarGraph.js +8 -8
- package/dist/BeeSwarmChart.cjs +1 -1
- package/dist/BeeSwarmChart.js +5 -5
- package/dist/BiVariateChoroplethMap.cjs +1 -1
- package/dist/BiVariateChoroplethMap.cjs.map +1 -1
- package/dist/BiVariateChoroplethMap.js +35 -34
- package/dist/BiVariateChoroplethMap.js.map +1 -1
- package/dist/BulletChart.cjs +1 -1
- package/dist/BulletChart.js +5 -5
- package/dist/ButterflyChart.cjs +1 -1
- package/dist/ButterflyChart.js +5 -5
- package/dist/ChoroplethMap.cjs +1 -1
- package/dist/ChoroplethMap.cjs.map +1 -1
- package/dist/ChoroplethMap.js +52 -51
- package/dist/ChoroplethMap.js.map +1 -1
- package/dist/CirclePackingGraph.cjs +1 -1
- package/dist/CirclePackingGraph.js +3 -3
- package/dist/DataCards.cjs +1 -1
- package/dist/DataCards.js +5 -5
- package/dist/DataTable.cjs +1 -1
- package/dist/DataTable.js +3 -3
- package/dist/DifferenceLineChart.cjs +1 -1
- package/dist/DifferenceLineChart.js +3 -3
- package/dist/DonutChart.cjs +1 -1
- package/dist/DonutChart.js +4 -4
- package/dist/DotDensityMap.cjs +1 -1
- package/dist/DotDensityMap.cjs.map +1 -1
- package/dist/DotDensityMap.js +39 -38
- package/dist/DotDensityMap.js.map +1 -1
- package/dist/DualAxisLineChart.cjs +1 -1
- package/dist/DualAxisLineChart.js +3 -3
- package/dist/DumbbellChart.cjs +1 -1
- package/dist/DumbbellChart.js +6 -6
- package/dist/GeoHubCompareMaps.cjs +1 -1
- package/dist/GeoHubCompareMaps.js +1 -1
- package/dist/GeoHubMap.cjs +1 -1
- package/dist/GeoHubMap.js +3 -3
- package/dist/GeoHubMapWithLayerSelection.cjs +1 -1
- package/dist/GeoHubMapWithLayerSelection.js +4 -4
- package/dist/{GraphEl-Bz2jatkM.cjs → GraphEl-4RUlclvW.cjs} +2 -2
- package/dist/{GraphEl-Bz2jatkM.cjs.map → GraphEl-4RUlclvW.cjs.map} +1 -1
- package/dist/{GraphEl-zNOHBYrK.js → GraphEl-ClIxlWa3.js} +2 -2
- package/dist/{GraphEl-zNOHBYrK.js.map → GraphEl-ClIxlWa3.js.map} +1 -1
- package/dist/GriddedGraphs.cjs +1 -1
- package/dist/GriddedGraphs.d.ts +58 -1
- package/dist/GriddedGraphs.js +7 -7
- package/dist/GriddedGraphsFromConfig.cjs +1 -1
- package/dist/GriddedGraphsFromConfig.d.ts +58 -1
- package/dist/GriddedGraphsFromConfig.js +1 -1
- package/dist/HeatMap.cjs +1 -1
- package/dist/HeatMap.js +4 -4
- package/dist/Histogram.cjs +1 -1
- package/dist/Histogram.js +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs +1 -1
- package/dist/LineChartWithConfidenceInterval.js +3 -3
- package/dist/MultiGraphDashboard.cjs +1 -1
- package/dist/MultiGraphDashboard.d.ts +58 -1
- package/dist/MultiGraphDashboard.js +5 -5
- package/dist/MultiGraphDashboardFromConfig.cjs +1 -1
- package/dist/MultiGraphDashboardFromConfig.d.ts +58 -1
- package/dist/MultiGraphDashboardFromConfig.js +1 -1
- package/dist/MultiGraphDashboardWideToLongFormat.cjs +1 -1
- package/dist/MultiGraphDashboardWideToLongFormat.js +2 -2
- package/dist/MultiGraphDashboardWideToLongFormatFromConfig.cjs +1 -1
- package/dist/MultiGraphDashboardWideToLongFormatFromConfig.js +1 -1
- package/dist/MultiLineAltChart.cjs +1 -1
- package/dist/MultiLineAltChart.js +4 -4
- package/dist/MultiLineChart.cjs +1 -1
- package/dist/MultiLineChart.js +3 -3
- package/dist/ParetoChart.cjs +1 -1
- package/dist/ParetoChart.js +3 -3
- package/dist/PerformanceIntensiveMultiGraphDashboard.cjs +1 -1
- package/dist/PerformanceIntensiveMultiGraphDashboard.d.ts +58 -1
- package/dist/PerformanceIntensiveMultiGraphDashboard.js +5 -5
- package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.cjs +1 -1
- package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.d.ts +58 -1
- package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.js +1 -1
- package/dist/PerformanceIntensiveScrollStory.d.ts +58 -1
- package/dist/RadarChart.cjs +1 -1
- package/dist/RadarChart.js +4 -4
- package/dist/SankeyChart.cjs +1 -1
- package/dist/SankeyChart.js +6 -6
- package/dist/ScatterPlot.cjs +1 -1
- package/dist/ScatterPlot.cjs.map +1 -1
- package/dist/ScatterPlot.js +31 -29
- package/dist/ScatterPlot.js.map +1 -1
- package/dist/ScrollStory.d.ts +58 -1
- package/dist/SimpleLineChart.cjs +1 -1
- package/dist/SimpleLineChart.js +3 -3
- package/dist/SingleGraphDashboard.cjs +1 -1
- package/dist/SingleGraphDashboard.d.ts +58 -1
- package/dist/SingleGraphDashboard.js +8 -8
- package/dist/SingleGraphDashboardFromConfig.cjs +1 -1
- package/dist/SingleGraphDashboardFromConfig.d.ts +58 -1
- package/dist/SingleGraphDashboardFromConfig.js +1 -1
- package/dist/SingleGraphDashboardGeoHubMaps.d.ts +58 -1
- package/dist/SingleGraphDashboardGeoHubMapsFromConfig.cjs +1 -1
- package/dist/SingleGraphDashboardGeoHubMapsFromConfig.d.ts +58 -1
- package/dist/SingleGraphDashboardGeoHubMapsFromConfig.js +1 -1
- package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
- package/dist/SingleGraphDashboardThreeDGraphs.cjs.map +1 -1
- package/dist/SingleGraphDashboardThreeDGraphs.d.ts +58 -1
- package/dist/SingleGraphDashboardThreeDGraphs.js +20 -19
- package/dist/SingleGraphDashboardThreeDGraphs.js.map +1 -1
- package/dist/SingleGraphDashboardThreeDGraphsFromConfig.cjs +1 -1
- package/dist/SingleGraphDashboardThreeDGraphsFromConfig.d.ts +58 -1
- package/dist/SingleGraphDashboardThreeDGraphsFromConfig.js +1 -1
- package/dist/SlopeChart.cjs +1 -1
- package/dist/SlopeChart.js +4 -4
- package/dist/SparkLine.cjs +1 -1
- package/dist/SparkLine.js +2 -2
- package/dist/StatCardFromData.cjs +1 -1
- package/dist/StatCardFromData.js +1 -1
- package/dist/StripChart.cjs +1 -1
- package/dist/StripChart.js +5 -5
- package/dist/ThreeDGlobe.cjs +1 -1
- package/dist/ThreeDGlobe.cjs.map +1 -1
- package/dist/ThreeDGlobe.d.ts +61 -6
- package/dist/ThreeDGlobe.js +385 -314
- package/dist/ThreeDGlobe.js.map +1 -1
- package/dist/{Tooltip-DyM5snqx.js → Tooltip-CVCGWyzw.js} +2 -2
- package/dist/{Tooltip-DyM5snqx.js.map → Tooltip-CVCGWyzw.js.map} +1 -1
- package/dist/{Tooltip-n8z5bfav.cjs → Tooltip-De16GWhY.cjs} +2 -2
- package/dist/{Tooltip-n8z5bfav.cjs.map → Tooltip-De16GWhY.cjs.map} +1 -1
- package/dist/TreeMapGraph.cjs +1 -1
- package/dist/TreeMapGraph.js +3 -3
- package/dist/Types.d.ts +58 -1
- package/dist/UnitChart.cjs +1 -1
- package/dist/UnitChart.js +1 -1
- package/dist/_commonjsHelpers-BH3jXuIh.cjs +2 -0
- package/dist/_commonjsHelpers-BH3jXuIh.cjs.map +1 -0
- package/dist/_commonjsHelpers-ByX85dGu.js +34 -0
- package/dist/_commonjsHelpers-ByX85dGu.js.map +1 -0
- package/dist/{ensureCompleteData-BBDZbDCE.js → ensureCompleteData-BALdOrsS.js} +2 -2
- package/dist/{ensureCompleteData-BBDZbDCE.js.map → ensureCompleteData-BALdOrsS.js.map} +1 -1
- package/dist/{ensureCompleteData-DqWQ2Zbi.cjs → ensureCompleteData-BU5Zlccy.cjs} +2 -2
- package/dist/{ensureCompleteData-DqWQ2Zbi.cjs.map → ensureCompleteData-BU5Zlccy.cjs.map} +1 -1
- package/dist/{fetchAndParseData-4gsYTy6_.js → fetchAndParseData-DBOl1Icl.js} +2 -2
- package/dist/{fetchAndParseData-4gsYTy6_.js.map → fetchAndParseData-DBOl1Icl.js.map} +1 -1
- package/dist/{fetchAndParseData-CQyVGCul.cjs → fetchAndParseData-Dcy7AS_0.cjs} +2 -2
- package/dist/{fetchAndParseData-CQyVGCul.cjs.map → fetchAndParseData-Dcy7AS_0.cjs.map} +1 -1
- package/dist/fetchAndParseData.cjs +1 -1
- package/dist/fetchAndParseData.js +1 -1
- package/dist/{filterData-B8ocT57s.js → filterData-9nEcQ-Jp.js} +3 -3
- package/dist/{filterData-B8ocT57s.js.map → filterData-9nEcQ-Jp.js.map} +1 -1
- package/dist/{filterData-DN6py7y_.cjs → filterData-BoYadk0l.cjs} +2 -2
- package/dist/{filterData-DN6py7y_.cjs.map → filterData-BoYadk0l.cjs.map} +1 -1
- package/dist/{getJenks-VhM3GIoC.js → getJenks-DW96UYNE.js} +2 -2
- package/dist/{getJenks-VhM3GIoC.js.map → getJenks-DW96UYNE.js.map} +1 -1
- package/dist/{getJenks-TWQvbuOz.cjs → getJenks-vofIZmeb.cjs} +2 -2
- package/dist/{getJenks-TWQvbuOz.cjs.map → getJenks-vofIZmeb.cjs.map} +1 -1
- package/dist/{getUniqValue-CHqgSss5.cjs → getUniqValue-CfuE_l9c.cjs} +2 -2
- package/dist/{getUniqValue-CHqgSss5.cjs.map → getUniqValue-CfuE_l9c.cjs.map} +1 -1
- package/dist/{getUniqValue-BtUENB2H.js → getUniqValue-CttuU_wn.js} +4 -4
- package/dist/{getUniqValue-BtUENB2H.js.map → getUniqValue-CttuU_wn.js.map} +1 -1
- package/dist/{index-CaAIPGZo.js → index-AqnpA7_O.js} +2 -2
- package/dist/{index-CaAIPGZo.js.map → index-AqnpA7_O.js.map} +1 -1
- package/dist/{index-CZbIGs8q.cjs → index-BJOeaYTk.cjs} +2 -2
- package/dist/{index-CZbIGs8q.cjs.map → index-BJOeaYTk.cjs.map} +1 -1
- package/dist/{index-Bc5VF70V.js → index-BMgDMxKJ.js} +6 -6
- package/dist/{index-Bc5VF70V.js.map → index-BMgDMxKJ.js.map} +1 -1
- package/dist/{index-B0rbzOoC.cjs → index-BS2TADPj.cjs} +2 -2
- package/dist/{index-B0rbzOoC.cjs.map → index-BS2TADPj.cjs.map} +1 -1
- package/dist/{index-DNj994Pv.cjs → index-BYzIB5V6.cjs} +2 -2
- package/dist/index-BYzIB5V6.cjs.map +1 -0
- package/dist/{index-27yTRcko.js → index-Bwrro8-q.js} +2 -2
- package/dist/{index-27yTRcko.js.map → index-Bwrro8-q.js.map} +1 -1
- package/dist/{index-BczVvEBZ.cjs → index-CQ3e6Ewi.cjs} +2 -2
- package/dist/{index-BczVvEBZ.cjs.map → index-CQ3e6Ewi.cjs.map} +1 -1
- package/dist/{index-C21TvELx.cjs → index-CSNtgibC.cjs} +2 -2
- package/dist/{index-C21TvELx.cjs.map → index-CSNtgibC.cjs.map} +1 -1
- package/dist/{index-D7ltPi18.js → index-CeVNqhMO.js} +2 -2
- package/dist/{index-D7ltPi18.js.map → index-CeVNqhMO.js.map} +1 -1
- package/dist/index-D05lK1Te.cjs +2 -0
- package/dist/index-D05lK1Te.cjs.map +1 -0
- package/dist/{index-Ds0uHjK9.cjs → index-D72cOtq7.cjs} +2 -2
- package/dist/{index-Ds0uHjK9.cjs.map → index-D72cOtq7.cjs.map} +1 -1
- package/dist/{index-Cdcfp4nk.js → index-DKCxu1Gh.js} +2 -2
- package/dist/index-DKCxu1Gh.js.map +1 -0
- package/dist/{index-BXns0-ng.cjs → index-DQA8q5sC.cjs} +2 -2
- package/dist/{index-BXns0-ng.cjs.map → index-DQA8q5sC.cjs.map} +1 -1
- package/dist/{index-BzeLQvXk.cjs → index-DYH8g9WA.cjs} +2 -2
- package/dist/{index-BzeLQvXk.cjs.map → index-DYH8g9WA.cjs.map} +1 -1
- package/dist/{index-BbNoLJ_w.cjs → index-Da2GUKrr.cjs} +2 -2
- package/dist/{index-BbNoLJ_w.cjs.map → index-Da2GUKrr.cjs.map} +1 -1
- package/dist/{index-BLizQDlg.js → index-DvVprvy6.js} +2 -2
- package/dist/{index-BLizQDlg.js.map → index-DvVprvy6.js.map} +1 -1
- package/dist/{index-UV9hjG_S.js → index-EArKRVKg.js} +2 -2
- package/dist/{index-UV9hjG_S.js.map → index-EArKRVKg.js.map} +1 -1
- package/dist/{index-C1rRk_50.js → index-V_JXij1_.js} +2 -2
- package/dist/{index-C1rRk_50.js.map → index-V_JXij1_.js.map} +1 -1
- package/dist/{index-DxagiOHo.js → index-fwdktvAS.js} +2 -2
- package/dist/{index-DxagiOHo.js.map → index-fwdktvAS.js.map} +1 -1
- package/dist/index-qfWCwobm.js +682 -0
- package/dist/index-qfWCwobm.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +63 -7
- package/dist/index.js +6 -6
- package/dist/{string2HTML-CWHGfz_d.js → string2HTML-oFCROsus.js} +2 -2
- package/dist/{string2HTML-CWHGfz_d.js.map → string2HTML-oFCROsus.js.map} +1 -1
- package/dist/{string2HTML-D2Avudmb.cjs → string2HTML-z7CwHXcx.cjs} +2 -2
- package/dist/{string2HTML-D2Avudmb.cjs.map → string2HTML-z7CwHXcx.cjs.map} +1 -1
- package/dist/transformData.cjs +1 -1
- package/dist/transformData.js +3 -3
- package/dist/{transformDataForAggregation-CdcwlnNe.js → transformDataForAggregation-1BYVFqvF.js} +4 -4
- package/dist/{transformDataForAggregation-CdcwlnNe.js.map → transformDataForAggregation-1BYVFqvF.js.map} +1 -1
- package/dist/{transformDataForAggregation-Du-Hei-W.cjs → transformDataForAggregation-BVxVu4yY.cjs} +2 -2
- package/dist/{transformDataForAggregation-Du-Hei-W.cjs.map → transformDataForAggregation-BVxVu4yY.cjs.map} +1 -1
- package/dist/{transformDataForGraphFromFile-BCjsizvb.js → transformDataForGraphFromFile-BC9Ha8hF.js} +3 -3
- package/dist/{transformDataForGraphFromFile-BCjsizvb.js.map → transformDataForGraphFromFile-BC9Ha8hF.js.map} +1 -1
- package/dist/{transformDataForGraphFromFile-B1A0AS-Z.cjs → transformDataForGraphFromFile-b41aNQYY.cjs} +2 -2
- package/dist/{transformDataForGraphFromFile-B1A0AS-Z.cjs.map → transformDataForGraphFromFile-b41aNQYY.cjs.map} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +2 -2
- package/dist/zoom-Bsbhil-K.cjs +2 -0
- package/dist/zoom-Bsbhil-K.cjs.map +1 -0
- package/dist/zoom-DAu91HKr.js +1864 -0
- package/dist/zoom-DAu91HKr.js.map +1 -0
- package/package.json +2 -2
- package/dist/_commonjsHelpers-DKOUU3wS.cjs +0 -2
- package/dist/_commonjsHelpers-DKOUU3wS.cjs.map +0 -1
- package/dist/_commonjsHelpers-DaMA6jEr.js +0 -9
- package/dist/_commonjsHelpers-DaMA6jEr.js.map +0 -1
- package/dist/index-Cdcfp4nk.js.map +0 -1
- package/dist/index-DNj994Pv.cjs.map +0 -1
- package/dist/zoom-Lo7IAUfC.cjs +0 -2
- package/dist/zoom-Lo7IAUfC.cjs.map +0 -1
- package/dist/zoom-_lqdiGoI.js +0 -1983
- package/dist/zoom-_lqdiGoI.js.map +0 -1
package/dist/BulletChart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),j=require("react"),Me=require("./index-BzeLQvXk.cjs"),ke=require("./index-BXns0-ng.cjs"),Ce=require("./Modal-tXZlLE5s.cjs"),Re=require("./index-C21TvELx.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),Ee=require("./Tooltip-n8z5bfav.cjs"),o=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Oe=require("./string2HTML-D2Avudmb.cjs"),Fe=require("./XTicksAndGridLines-CCzXIV8d.cjs"),He=require("./YAxesLabels-D8IydyZj.cjs"),Ie=require("./AxisTitle-CK9YeovX.cjs"),Ve=require("./Axis-DE7dSn1_.cjs"),ze=require("./ReferenceLine-CFVBBN__.cjs"),Te=require("./linear-BVckp9RD.cjs"),qe=require("./band-CAApY4Pd.cjs"),Ae=require("./use-in-view-sQJZ_xDO.cjs"),_=require("./proxy-BHRoeZgd.cjs"),Le=require("./index-BW8iNx7E.cjs"),$e=require("./GraphFooter.cjs"),Se=require("./GraphHeader.cjs"),ve=require("./Colors.cjs"),De=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./ColorLegend.cjs"),Pe=require("./XAxesLabels-OjBNl_lS.cjs"),Ge=require("./YTicksAndGridLines-DBDuz6vb.cjs");function We(we){const{data:s,barColor:b,suffix:J,prefix:K,barPadding:Q,showValues:re,showTicks:Z,leftMargin:ye,truncateBy:de,width:ee,height:te,rightMargin:be,topMargin:C,bottomMargin:ie,showLabels:u,tooltip:D,onSeriesMouseOver:V,refValues:q,highlightedDataPoints:h,maxValue:B,minValue:w,onSeriesMouseClick:U,labelOrder:ae,rtl:F,maxBarThickness:A,minBarThickness:me,resetSelectionOnDoubleClick:L,detailsOnClick:z,barAxisTitle:ne,valueColor:le,noOfTicks:E,styles:g,classNames:M,targetStyle:se,targetColor:H,qualitativeRangeColors:P,measureBarWidthFactor:c,animate:l,dimmedOpacity:O,precision:G,customLayers:$,naLabel:T}=we,f=j.useRef(null),d=Ae.useInView(f,{once:l.once,amount:l.amount}),[oe,W]=j.useState(void 0),[N,X]=j.useState(void 0),[ue,k]=j.useState(void 0),[p,y]=j.useState(void 0),x={top:ne?C+25:C,bottom:ie,left:ye,right:be},S=ee-x.left-x.right,I=te-x.top-x.bottom,ce=Math.max(...s.filter(e=>!o.checkIfNullOrUndefined(e.size)).map(e=>e.size))<0?0:Math.max(...s.filter(e=>!o.checkIfNullOrUndefined(e.size)).map(e=>e.size)),Y=Math.max(...s.filter(e=>!o.checkIfNullOrUndefined(e.target)).map(e=>e.target))<0?0:Math.max(...s.filter(e=>!o.checkIfNullOrUndefined(e.target)).map(e=>e.target)),xe=Math.max(...s.map(e=>Re.sum((e.qualitativeRange||[]).filter(r=>!o.checkIfNullOrUndefined(r)))||0)),ge=o.checkIfNullOrUndefined(B)?Math.max(...[ce,Y,xe].filter(Number.isFinite))<0?0:Math.max(...[ce,Y,xe].filter(Number.isFinite)):B,he=Math.min(...s.filter(e=>!o.checkIfNullOrUndefined(e.size)).map(e=>e.size))>=0?0:Math.min(...s.filter(e=>!o.checkIfNullOrUndefined(e.size)).map(e=>e.size)),R=Math.min(...s.filter(e=>!o.checkIfNullOrUndefined(e.target)).map(e=>e.target))>=0?0:Math.min(...s.filter(e=>!o.checkIfNullOrUndefined(e.target)).map(e=>e.target)),a=o.checkIfNullOrUndefined(w)?Math.min(...[he,R].filter(Number.isFinite))>=0?0:Math.min(...[he,R].filter(Number.isFinite)):w,fe=s.map((e,r)=>({...e,id:ae?`${e.label}`:`${r}`})),n=Te.linear().domain([a,ge]).range([0,S]).nice(),v=ae||fe.map(e=>`${e.id}`),m=qe.band().domain(v).range([0,me?Math.max(I,me*v.length):A?Math.min(I,A*v.length):I]).paddingInner(Q),t=n.ticks(E);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(_.motion.svg,{width:`${ee}px`,height:`${te}px`,viewBox:`0 0 ${ee} ${te}`,direction:"ltr",ref:f,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${x.left},${x.top})`,children:[Z?i.jsxRuntimeExports.jsx(Fe.XTicksAndGridLines,{values:t.filter(e=>e!==0),x:t.filter(e=>e!==0).map(e=>n(e)),y1:0-C,y2:I+x.bottom,styles:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},classNames:{gridLines:M?.xAxis?.gridLines,labels:M?.xAxis?.labels},suffix:J,prefix:K,labelType:"secondary",showGridLines:!0,precision:G}):null,i.jsxRuntimeExports.jsx(Ie.AxisTitle,{x:S/2,y:0-x.top+15,style:g?.xAxis?.title,className:M?.xAxis?.title,text:ne}),i.jsxRuntimeExports.jsx(Ve.Axis,{x1:n(a<0?0:a),x2:n(a<0?0:a),y1:-2.5,y2:I+x.bottom,classNames:{axis:M?.yAxis?.axis},styles:{axis:g?.yAxis?.axis}}),$.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(Le.AnimatePresence,{children:[fe.map(e=>o.checkIfNullOrUndefined(m(e.id))?null:i.jsxRuntimeExports.jsxs(_.motion.g,{className:"undp-viz-g-with-hover",onMouseEnter:r=>{W(e),y(r.clientY),k(r.clientX),V?.(e)},onClick:()=>{(U||z)&&(ke.isEqual(N,e)&&L?(X(void 0),U?.(void 0)):(X(e),U?.(e)))},onMouseMove:r=>{W(e),y(r.clientY),k(r.clientX)},onMouseLeave:()=>{W(void 0),k(void 0),y(void 0),V?.(void 0)},exit:{opacity:0,transition:{duration:l.duration}},variants:{initial:{x:0,y:m(`${e.id}`),opacity:h.length!==0?h.indexOf(e.label)!==-1?.85:O:.85},whileInView:{x:0,y:m(`${e.id}`),opacity:h.length!==0?h.indexOf(e.label)!==-1?.85:O:.85,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:[e.qualitativeRange?e.qualitativeRange.map((r,pe)=>i.jsxRuntimeExports.jsx(_.motion.rect,{exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0,fill:P[pe]},whileInView:{x:n(pe===0?0:Re.sum(e.qualitativeRange.filter((je,Ue)=>Ue<pe&&je))),width:n(r),fill:P[pe],transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",y:0,height:m.bandwidth()},pe)):null,e.target&&se==="background"?i.jsxRuntimeExports.jsx(_.motion.rect,{y:0,x:e.target>=0?n(0):n(e.target),height:m.bandwidth(),style:{fill:H},exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0},whileInView:{x:e.target>=0?n(0):n(e.target),width:e.target>=0?n(e.target)-n(0):n(0)-n(e.target),transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,e.size?i.jsxRuntimeExports.jsx(_.motion.rect,{y:m.bandwidth()*((1-c)/2),style:{fill:b},height:m.bandwidth()*c,exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0},whileInView:{x:e.size>=0?n(0):n(e.size),width:e.size>=0?n(e.size)-n(0):n(0)-n(e.size),transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,e.target&&se==="line"?i.jsxRuntimeExports.jsx(_.motion.rect,{y:0,height:m.bandwidth(),style:{fill:H},width:2,exit:{opacity:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),opacity:0},whileInView:{x:n(e.target)-1,opacity:1,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,u?i.jsxRuntimeExports.jsx(He.YAxesLabels,{value:`${e.label}`.length<de?`${e.label}`:`${`${e.label}`.substring(0,de)}...`,y:0,x:(e.size||0)<0?n(0):0-x.left,width:(e.size||0)<0?ee-n(0):n(0)+x.left,height:m.bandwidth(),alignment:e.size&&e.size<0?"left":"right",style:g?.yAxis?.labels,className:M?.yAxis?.labels,animate:l,isInView:d}):null,re?i.jsxRuntimeExports.jsx(_.motion.text,{y:m.bandwidth()/2,style:{...le?{fill:le}:{fill:b},textAnchor:e.size&&e.size<0?"end":"start",...g?.graphObjectValues||{}},className:i.mo("graph-value text-sm",!le&&b.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",M?.graphObjectValues),dx:e.size&&e.size<0?-5:5,dy:"0.33em",exit:{opacity:0,transition:{duration:l.duration}},variants:{initial:{x:n(0),opacity:0},whileInView:{x:e.size?n(e.size):n(0),opacity:1,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:Ne.numberFormattingFunction(e.size,T,G,K,J)}):null]},e.label)),q?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:q.map((e,r)=>i.jsxRuntimeExports.jsx(ze.RefLineX,{text:e.text,color:e.color,x:n(e.value),y1:0-x.top,y2:I+x.bottom,textSide:n(e.value)>S*.75||F?"left":"right",classNames:e.classNames,styles:e.styles,animate:l,isInView:d},r))}):null]}),$.filter(e=>e.position==="after").map(e=>e.layer)]})}),oe&&D&&ue&&p?i.jsxRuntimeExports.jsx(Ee.Tooltip,{data:oe,body:D,xPos:ue,yPos:p,backgroundStyle:g?.tooltip,className:M?.tooltip}):null,z&&N!==void 0?i.jsxRuntimeExports.jsx(Ce.X,{open:N!==void 0,onClose:()=>{X(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof z=="string"?{__html:Oe.string2HTML(z,N)}:void 0,children:typeof z=="function"?z(N):null})}):null]})}function Xe(we){const{data:s,graphTitle:b,barColor:J=ve.Colors.primaryColors["blue-600"],suffix:K="",sources:Q,prefix:re="",graphDescription:Z,barPadding:ye=.25,showValues:de=!0,showTicks:ee=!0,leftMargin:te=100,rightMargin:be=40,truncateBy:C=999,height:ie,width:u,footNote:D,colorDomain:V,colorLegendTitle:q,highlightedDataPoints:h=[],padding:B,backgroundColor:w=!1,topMargin:U=25,bottomMargin:ae=10,showLabels:F=!0,relativeHeight:A,tooltip:me,onSeriesMouseOver:L,refValues:z,showColorScale:ne=!0,graphID:le,maxValue:E,minValue:g,onSeriesMouseClick:M,graphDownload:se=!1,dataDownload:H=!1,sortData:P,labelOrder:c,language:l="en",minHeight:O=0,theme:G="light",maxBarThickness:$,maxNumberOfBars:T,minBarThickness:f,ariaLabel:d,resetSelectionOnDoubleClick:oe=!0,detailsOnClick:W,barAxisTitle:N,noOfTicks:X=5,valueColor:ue,styles:k,classNames:p,filterNA:y=!0,targetStyle:x="line",targetColor:S=ve.Colors.light.grays["gray-700"],qualitativeRangeColors:I,measureBarWidthFactor:ce=.4,animate:Y=!1,dimmedOpacity:xe=.3,precision:ge=2,customLayers:he=[],naLabel:R="NA"}=we,[a,fe]=j.useState(0),[n,v]=j.useState(0),m=j.useRef(null),t=j.useRef(null);return j.useEffect(()=>{const e=new ResizeObserver(r=>{fe(u||r[0].target.clientWidth||620),v(ie||r[0].target.clientHeight||480)});return m.current&&(v(m.current.clientHeight||480),fe(m.current.clientWidth||620),u||e.observe(m.current)),()=>e.disconnect()},[u,ie]),i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${u?"w-fit grow-0":"w-full grow"}`,dir:l==="he"||l==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${l||"en"}`,u?"w-fit":"w-full",p?.graphContainer),style:{...k?.graphContainer||{},...w&&w!==!0?{backgroundColor:w}:{}},id:le,ref:t,"aria-label":d||`${b?`The graph shows ${b}. `:""}This is a bar chart. ${Z?` ${Z}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:w?B||"1rem":B||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[b||Z||se||H?i.jsxRuntimeExports.jsx(Se.GraphHeader,{styles:{title:k?.title,description:k?.description},classNames:{title:p?.title,description:p?.description},graphTitle:b,graphDescription:Z,width:u,graphDownload:se?t.current:void 0,dataDownload:H?s.map(e=>e.data).filter(e=>e!==void 0).length>0?s.map(e=>e.data).filter(e=>e!==void 0):s.filter(e=>e!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(De.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[ne&&s.filter(e=>e.qualitativeRange).length!==0&&V?i.jsxRuntimeExports.jsx(Be.ColorLegend,{width:u,colorLegendTitle:q,colors:I||ve.Colors[G].sequentialColors.positiveColorsx10,colorDomain:V,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:m,"aria-label":"Graph area",children:(u||a)&&(ie||n)?i.jsxRuntimeExports.jsx(We,{data:P==="asc"?Me.sortBy(s.filter(e=>y?!o.checkIfNullOrUndefined(e.size):e),e=>e.size).filter((e,r)=>T?r<T:!0):P==="desc"?Me.sortBy(s.filter(e=>y?!o.checkIfNullOrUndefined(e.size):e),e=>e.size).reverse().filter((e,r)=>T?r<T:!0):s.filter(e=>y?!o.checkIfNullOrUndefined(e.size):e).filter((e,r)=>T?r<T:!0),barColor:J,targetColor:S,width:u||a,height:Math.max(O,ie||(A?O?(u||a)*A>O?(u||a)*A:O:(u||a)*A:n)),suffix:K,prefix:re,barPadding:ye,showValues:de,showTicks:ee,leftMargin:te,rightMargin:be,topMargin:U,bottomMargin:ae,truncateBy:C,showLabels:F,tooltip:me,onSeriesMouseOver:L,refValues:z,maxValue:E,minValue:g,highlightedDataPoints:h,onSeriesMouseClick:M,labelOrder:c,rtl:l==="he"||l==="ar",maxBarThickness:$,minBarThickness:f,resetSelectionOnDoubleClick:oe,detailsOnClick:W,barAxisTitle:N,noOfTicks:X,valueColor:ue,classNames:p,styles:k,targetStyle:x,qualitativeRangeColors:I||ve.Colors[G].sequentialColors.positiveColorsx10,measureBarWidthFactor:ce,animate:Y===!0?{duration:.5,once:!0,amount:.5}:Y||{duration:0,once:!0,amount:0},dimmedOpacity:xe,precision:ge,customLayers:he,naLabel:R}):null})]})}),Q||D?i.jsxRuntimeExports.jsx($e.GraphFooter,{sources:Q,footNote:D,width:u,styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:p?.footnote,source:p?.source}}):null]})})})})}function Ye(we){const{data:s,width:b,height:J,barColor:K,suffix:Q,prefix:re,barPadding:Z,showLabels:ye,showValues:de,showTicks:ee,truncateBy:te,rightMargin:be,topMargin:C,bottomMargin:ie,leftMargin:u,tooltip:D,onSeriesMouseOver:V,refValues:q,maxValue:h,minValue:B,highlightedDataPoints:w,onSeriesMouseClick:U,labelOrder:ae,maxBarThickness:F,minBarThickness:A,resetSelectionOnDoubleClick:me,detailsOnClick:L,barAxisTitle:z,valueColor:ne,noOfTicks:le,styles:E,classNames:g,targetStyle:M,targetColor:se,qualitativeRangeColors:H,measureBarWidthFactor:P,animate:c,dimmedOpacity:l,precision:O,customLayers:G,naLabel:$}=we,T=j.useRef(null),f=Ae.useInView(T,{once:c.once,amount:c.amount}),d={top:C,bottom:ie,left:z?u+30:u,right:be},[oe,W]=j.useState(void 0),[N,X]=j.useState(void 0),[ue,k]=j.useState(void 0),[p,y]=j.useState(void 0),x=b-d.left-d.right,S=J-d.top-d.bottom,I=Math.max(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.size))<0?0:Math.max(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.size)),ce=Math.max(...s.filter(t=>!o.checkIfNullOrUndefined(t.target)).map(t=>t.target))<0?0:Math.max(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.target)),Y=Math.max(...s.map(t=>Re.sum((t.qualitativeRange||[]).filter(e=>!o.checkIfNullOrUndefined(e)))||0)),xe=o.checkIfNullOrUndefined(h)?Math.max(...[I,ce,Y].filter(Number.isFinite))<0?0:Math.max(...[I,ce,Y].filter(Number.isFinite)):h,ge=Math.min(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.size))>=0?0:Math.min(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.size)),he=Math.min(...s.filter(t=>!o.checkIfNullOrUndefined(t.target)).map(t=>t.target))>=0?0:Math.min(...s.filter(t=>!o.checkIfNullOrUndefined(t.target)).map(t=>t.target)),R=o.checkIfNullOrUndefined(B)?Math.min(...[ge,he].filter(Number.isFinite))>=0?0:Math.min(...[ge,he].filter(Number.isFinite)):B,a=Te.linear().domain([R,xe]).range([S,0]).nice(),fe=s.map((t,e)=>({...t,id:ae?`${t.label}`:`${e}`})),n=ae||fe.map(t=>`${t.id}`),v=qe.band().domain(n).range([0,A?Math.max(x,A*n.length):F?Math.min(x,F*n.length):x]).paddingInner(Z),m=a.ticks(le);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(_.motion.svg,{width:`${b}px`,height:`${J}px`,viewBox:`0 0 ${b} ${J}`,direction:"ltr",ref:T,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[i.jsxRuntimeExports.jsx(Ve.Axis,{y1:a(R<0?0:R),y2:a(R<0?0:R),x1:0-u,x2:x+d.right,label:Ne.numberFormattingFunction(R<0?0:R,$,O,re,Q),labelPos:{x:0-u,dx:0,dy:xe<0?"1em":-5,y:a(R<0?0:R)},classNames:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels},styles:{axis:E?.xAxis?.axis,label:E?.yAxis?.labels}}),ee?i.jsxRuntimeExports.jsx(Ge.YTicksAndGridLines,{values:m.filter(t=>t!==0),y:m.filter(t=>t!==0).map(t=>a(t)),x1:0-u,x2:x+d.right,styles:{gridLines:E?.yAxis?.gridLines,labels:E?.yAxis?.labels},classNames:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},suffix:Q,prefix:re,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:O}):null,i.jsxRuntimeExports.jsx(Ie.AxisTitle,{x:0-u-15,y:S/2,style:E?.yAxis?.title,className:g?.yAxis?.title,text:z,rotate90:!0}),G.filter(t=>t.position==="before").map(t=>t.layer),i.jsxRuntimeExports.jsxs(Le.AnimatePresence,{children:[fe.map(t=>o.checkIfNullOrUndefined(v(t.id))?null:i.jsxRuntimeExports.jsxs(_.motion.g,{className:"undp-viz-g-with-hover",onMouseEnter:e=>{W(t),y(e.clientY),k(e.clientX),V?.(t)},onClick:()=>{(U||L)&&(ke.isEqual(N,t)&&me?(X(void 0),U?.(void 0)):(X(t),U?.(t)))},onMouseMove:e=>{W(t),y(e.clientY),k(e.clientX)},onMouseLeave:()=>{W(void 0),k(void 0),y(void 0),V?.(void 0)},exit:{opacity:0,transition:{duration:c.duration}},variants:{initial:{x:v(`${t.id}`),y:0,opacity:w.length!==0?w.indexOf(t.label)!==-1?.85:l:.85},whileInView:{x:v(`${t.id}`),y:0,opacity:w.length!==0?w.indexOf(t.label)!==-1?.85:l:.85,transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial",children:[t.qualitativeRange?t.qualitativeRange.map((e,r)=>i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,exit:{height:0,y:a(0),transition:{duration:c.duration}},variants:{initial:{height:0,y:a(0),fill:H[r]},whileInView:{height:Math.abs(a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<=r&&pe)))-a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<r&&pe)))),y:a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<=r&&pe))),fill:H[r],transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial",width:v.bandwidth()},r)):null,t.target&&M==="background"?i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,width:v.bandwidth(),style:{fill:se},exit:{height:0,y:a(0),transition:{duration:c.duration}},variants:{initial:{height:0,y:a(0)},whileInView:{height:Math.abs(a(t.target)-a(0)),y:t.target>0?a(t.target):a(0),transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial"}):null,t.size?i.jsxRuntimeExports.jsx(_.motion.rect,{x:v.bandwidth()*((1-P)/2),width:v.bandwidth()*P,style:{fill:K},exit:{height:0,y:a(0),transition:{duration:c.duration}},variants:{initial:{height:0,y:a(0)},whileInView:{height:Math.abs(a(t.size)-a(0)),y:t.size>0?a(t.size):a(0),transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial"}):null,t.target&&M==="line"?i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,width:v.bandwidth(),style:{fill:se},exit:{y:a(0),opacity:0,transition:{duration:c.duration}},variants:{initial:{y:a(0),opacity:0},whileInView:{y:a(t.target)-1,opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial",height:2}):null,ye?i.jsxRuntimeExports.jsx(Pe.XAxesLabels,{value:`${t.label}`.length<te?`${t.label}`:`${`${t.label}`.substring(0,te)}...`,y:(t.size||0)<0?0:a(0)+5,x:0,width:v.bandwidth(),height:(t.size||0)<0?a(0)-5:d.bottom,style:E?.xAxis?.labels,className:g?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:c,isInView:f}):null,de?i.jsxRuntimeExports.jsx(_.motion.text,{x:v.bandwidth()/2,style:{...ne?{fill:ne}:{fill:K},textAnchor:"middle",...E?.graphObjectValues||{}},className:i.mo("graph-value text-sm",!ne&&K.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",g?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",exit:{opacity:0,transition:{duration:c.duration}},variants:{initial:{y:a(0),opacity:0},whileInView:{y:a(t.size||0),opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial",children:Ne.numberFormattingFunction(t.size,$,O,re,Q)}):null]},t.label)),q?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:q.map((t,e)=>i.jsxRuntimeExports.jsx(ze.RefLineY,{text:t.text,color:t.color,y:a(t.value),x1:0-u,x2:x+d.right,classNames:t.classNames,styles:t.styles,animate:c,isInView:f},e))}):null]}),G.filter(t=>t.position==="after").map(t=>t.layer)]})}),oe&&D&&ue&&p?i.jsxRuntimeExports.jsx(Ee.Tooltip,{data:oe,body:D,xPos:ue,yPos:p,backgroundStyle:E?.tooltip,className:g?.tooltip}):null,L&&N!==void 0?i.jsxRuntimeExports.jsx(Ce.X,{open:N!==void 0,onClose:()=>{X(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof L=="string"?{__html:Oe.string2HTML(L,N)}:void 0,children:typeof L=="function"?L(N):null})}):null]})}function _e(we){const{data:s,graphTitle:b,barColor:J=ve.Colors.primaryColors["blue-600"],barPadding:K=.25,showTicks:Q=!0,leftMargin:re=20,rightMargin:Z=20,topMargin:ye=20,bottomMargin:de=25,truncateBy:ee=999,showLabels:te=!0,showValues:be=!0,backgroundColor:C=!1,suffix:ie="",prefix:u="",sources:D,graphDescription:V,height:q,width:h,footNote:B,colorDomain:w,colorLegendTitle:U,padding:ae,relativeHeight:F,tooltip:A,onSeriesMouseOver:me,refValues:L,showColorScale:z=!0,graphID:ne,maxValue:le,minValue:E,highlightedDataPoints:g=[],qualitativeRangeColors:M,onSeriesMouseClick:se,graphDownload:H=!1,dataDownload:P=!1,language:c="en",theme:l="light",sortData:O,labelOrder:G,minHeight:$=0,maxBarThickness:T,maxNumberOfBars:f,minBarThickness:d,ariaLabel:oe,resetSelectionOnDoubleClick:W=!0,detailsOnClick:N,barAxisTitle:X,noOfTicks:ue=5,valueColor:k,styles:p,classNames:y,targetColor:x=ve.Colors.light.grays["gray-700"],filterNA:S=!0,targetStyle:I="line",measureBarWidthFactor:ce=.4,animate:Y=!1,dimmedOpacity:xe=.3,precision:ge=2,customLayers:he=[],naLabel:R="NA"}=we,[a,fe]=j.useState(0),[n,v]=j.useState(0),m=j.useRef(null),t=j.useRef(null);return j.useEffect(()=>{const e=new ResizeObserver(r=>{fe(h||r[0].target.clientWidth||620),v(q||r[0].target.clientHeight||480)});return m.current&&(v(m.current.clientHeight||480),fe(m.current.clientWidth||620),h||e.observe(m.current)),()=>e.disconnect()},[h,q]),i.jsxRuntimeExports.jsx("div",{className:`${l||"light"} flex ${h?"w-fit grow-0":"w-full grow"}`,dir:c==="he"||c==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${c||"en"}`,h?"w-fit":"w-full",y?.graphContainer),style:{...p?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:ne,ref:t,"aria-label":oe||`${b?`The graph shows ${b}. `:""}This is a grouped bar chart. ${V?` ${V}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:C?ae||"1rem":ae||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[b||V||H||P?i.jsxRuntimeExports.jsx(Se.GraphHeader,{styles:{title:p?.title,description:p?.description},classNames:{title:y?.title,description:y?.description},graphTitle:b,graphDescription:V,width:h,graphDownload:H?t.current:void 0,dataDownload:P?s.map(e=>e.data).filter(e=>e!==void 0).length>0?s.map(e=>e.data).filter(e=>e!==void 0):s.filter(e=>e!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(De.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[z&&s.filter(e=>e.qualitativeRange).length!==0&&w?i.jsxRuntimeExports.jsx(Be.ColorLegend,{width:h,colorLegendTitle:U,colors:M||ve.Colors[l].sequentialColors.positiveColorsx10,colorDomain:w,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:m,"aria-label":"Graph area",children:(h||a)&&(q||n)?i.jsxRuntimeExports.jsx(Ye,{data:O==="asc"?Me.sortBy(s.filter(e=>S?!o.checkIfNullOrUndefined(e.size):e),e=>e.size).filter((e,r)=>f?r<f:!0):O==="desc"?Me.sortBy(s.filter(e=>S?!o.checkIfNullOrUndefined(e.size):e),e=>e.size).reverse().filter((e,r)=>f?r<f:!0):s.filter(e=>S?!o.checkIfNullOrUndefined(e.size):e).filter((e,r)=>f?r<f:!0),barColor:J,targetColor:x,width:h||a,refValues:L,height:Math.max($,q||(F?$?(h||a)*F>$?(h||a)*F:$:(h||a)*F:n)),suffix:ie,prefix:u,barPadding:K,showLabels:te,showValues:be,showTicks:Q,truncateBy:ee,leftMargin:re,rightMargin:Z,qualitativeRangeColors:M||ve.Colors[l].sequentialColors.positiveColorsx10,topMargin:ye,bottomMargin:de,tooltip:A,onSeriesMouseOver:me,maxValue:le,minValue:E,highlightedDataPoints:g,onSeriesMouseClick:se,labelOrder:G,maxBarThickness:T,minBarThickness:d,resetSelectionOnDoubleClick:W,detailsOnClick:N,barAxisTitle:X,noOfTicks:ue,valueColor:k,styles:p,classNames:y,targetStyle:I,dimmedOpacity:xe,measureBarWidthFactor:ce,animate:Y===!0?{duration:.5,once:!0,amount:.5}:Y||{duration:0,once:!0,amount:0},precision:ge,customLayers:he,naLabel:R}):null})]})}),D||B?i.jsxRuntimeExports.jsx($e.GraphFooter,{styles:{footnote:p?.footnote,source:p?.source},classNames:{footnote:y?.footnote,source:y?.source},sources:D,footNote:B,width:h}):null]})})})})}function Je(we){const{data:s,graphTitle:b,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:C,suffix:ie,prefix:u,sources:D,graphDescription:V,height:q,width:h,footNote:B,colorDomain:w,colorLegendTitle:U,padding:ae,relativeHeight:F,tooltip:A,onSeriesMouseOver:me,refValues:L,showColorScale:z,graphID:ne,maxValue:le,minValue:E,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:H,language:P,theme:c,sortData:l,labelOrder:O,minHeight:G,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:f,ariaLabel:d,resetSelectionOnDoubleClick:oe,detailsOnClick:W,barAxisTitle:N,noOfTicks:X,valueColor:ue,orientation:k="vertical",styles:p,classNames:y,filterNA:x,targetStyle:S,targetColor:I,qualitativeRangeColors:ce,measureBarWidthFactor:Y,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R}=we;return k==="vertical"?i.jsxRuntimeExports.jsx(_e,{data:s,graphTitle:b,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:C,suffix:ie,prefix:u,sources:D,graphDescription:V,height:q,width:h,footNote:B,colorDomain:w,colorLegendTitle:U,padding:ae,relativeHeight:F,tooltip:A,onSeriesMouseOver:me,refValues:L,showColorScale:z,graphID:ne,maxValue:le,minValue:E,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:H,language:P,theme:c,sortData:l,labelOrder:O,minHeight:G,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:f,ariaLabel:d,resetSelectionOnDoubleClick:oe,styles:p,detailsOnClick:W,barAxisTitle:N,noOfTicks:X,valueColor:ue,classNames:y,filterNA:x,targetStyle:S,targetColor:I,measureBarWidthFactor:Y,qualitativeRangeColors:ce,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R}):i.jsxRuntimeExports.jsx(Xe,{data:s,graphTitle:b,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:C,suffix:ie,prefix:u,sources:D,graphDescription:V,height:q,width:h,footNote:B,colorDomain:w,colorLegendTitle:U,padding:ae,relativeHeight:F,tooltip:A,onSeriesMouseOver:me,refValues:L,showColorScale:z,graphID:ne,maxValue:le,minValue:E,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:H,language:P,theme:c,sortData:l,labelOrder:O,minHeight:G,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:f,ariaLabel:d,resetSelectionOnDoubleClick:oe,styles:p,detailsOnClick:W,barAxisTitle:N,noOfTicks:X,valueColor:ue,classNames:y,filterNA:x,targetStyle:S,targetColor:I,measureBarWidthFactor:Y,qualitativeRangeColors:ce,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R})}exports.BulletChart=Je;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),j=require("react"),Me=require("./index-DYH8g9WA.cjs"),ke=require("./index-DQA8q5sC.cjs"),Ce=require("./Modal-tXZlLE5s.cjs"),Re=require("./index-CSNtgibC.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),Ee=require("./Tooltip-De16GWhY.cjs"),o=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Oe=require("./string2HTML-z7CwHXcx.cjs"),Fe=require("./XTicksAndGridLines-CCzXIV8d.cjs"),He=require("./YAxesLabels-D8IydyZj.cjs"),Ie=require("./AxisTitle-CK9YeovX.cjs"),Ve=require("./Axis-DE7dSn1_.cjs"),ze=require("./ReferenceLine-CFVBBN__.cjs"),Te=require("./linear-BVckp9RD.cjs"),qe=require("./band-CAApY4Pd.cjs"),Ae=require("./use-in-view-sQJZ_xDO.cjs"),_=require("./proxy-BHRoeZgd.cjs"),Le=require("./index-BW8iNx7E.cjs"),$e=require("./GraphFooter.cjs"),Se=require("./GraphHeader.cjs"),ve=require("./Colors.cjs"),De=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./ColorLegend.cjs"),Pe=require("./XAxesLabels-OjBNl_lS.cjs"),Ge=require("./YTicksAndGridLines-DBDuz6vb.cjs");function We(we){const{data:s,barColor:b,suffix:J,prefix:K,barPadding:Q,showValues:re,showTicks:Z,leftMargin:ye,truncateBy:de,width:ee,height:te,rightMargin:be,topMargin:C,bottomMargin:ie,showLabels:u,tooltip:D,onSeriesMouseOver:V,refValues:q,highlightedDataPoints:h,maxValue:B,minValue:w,onSeriesMouseClick:U,labelOrder:ae,rtl:F,maxBarThickness:A,minBarThickness:me,resetSelectionOnDoubleClick:L,detailsOnClick:z,barAxisTitle:ne,valueColor:le,noOfTicks:E,styles:g,classNames:M,targetStyle:se,targetColor:H,qualitativeRangeColors:P,measureBarWidthFactor:c,animate:l,dimmedOpacity:O,precision:G,customLayers:$,naLabel:T}=we,f=j.useRef(null),d=Ae.useInView(f,{once:l.once,amount:l.amount}),[oe,W]=j.useState(void 0),[N,X]=j.useState(void 0),[ue,k]=j.useState(void 0),[p,y]=j.useState(void 0),x={top:ne?C+25:C,bottom:ie,left:ye,right:be},S=ee-x.left-x.right,I=te-x.top-x.bottom,ce=Math.max(...s.filter(e=>!o.checkIfNullOrUndefined(e.size)).map(e=>e.size))<0?0:Math.max(...s.filter(e=>!o.checkIfNullOrUndefined(e.size)).map(e=>e.size)),Y=Math.max(...s.filter(e=>!o.checkIfNullOrUndefined(e.target)).map(e=>e.target))<0?0:Math.max(...s.filter(e=>!o.checkIfNullOrUndefined(e.target)).map(e=>e.target)),xe=Math.max(...s.map(e=>Re.sum((e.qualitativeRange||[]).filter(r=>!o.checkIfNullOrUndefined(r)))||0)),ge=o.checkIfNullOrUndefined(B)?Math.max(...[ce,Y,xe].filter(Number.isFinite))<0?0:Math.max(...[ce,Y,xe].filter(Number.isFinite)):B,he=Math.min(...s.filter(e=>!o.checkIfNullOrUndefined(e.size)).map(e=>e.size))>=0?0:Math.min(...s.filter(e=>!o.checkIfNullOrUndefined(e.size)).map(e=>e.size)),R=Math.min(...s.filter(e=>!o.checkIfNullOrUndefined(e.target)).map(e=>e.target))>=0?0:Math.min(...s.filter(e=>!o.checkIfNullOrUndefined(e.target)).map(e=>e.target)),a=o.checkIfNullOrUndefined(w)?Math.min(...[he,R].filter(Number.isFinite))>=0?0:Math.min(...[he,R].filter(Number.isFinite)):w,fe=s.map((e,r)=>({...e,id:ae?`${e.label}`:`${r}`})),n=Te.linear().domain([a,ge]).range([0,S]).nice(),v=ae||fe.map(e=>`${e.id}`),m=qe.band().domain(v).range([0,me?Math.max(I,me*v.length):A?Math.min(I,A*v.length):I]).paddingInner(Q),t=n.ticks(E);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(_.motion.svg,{width:`${ee}px`,height:`${te}px`,viewBox:`0 0 ${ee} ${te}`,direction:"ltr",ref:f,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${x.left},${x.top})`,children:[Z?i.jsxRuntimeExports.jsx(Fe.XTicksAndGridLines,{values:t.filter(e=>e!==0),x:t.filter(e=>e!==0).map(e=>n(e)),y1:0-C,y2:I+x.bottom,styles:{gridLines:g?.xAxis?.gridLines,labels:g?.xAxis?.labels},classNames:{gridLines:M?.xAxis?.gridLines,labels:M?.xAxis?.labels},suffix:J,prefix:K,labelType:"secondary",showGridLines:!0,precision:G}):null,i.jsxRuntimeExports.jsx(Ie.AxisTitle,{x:S/2,y:0-x.top+15,style:g?.xAxis?.title,className:M?.xAxis?.title,text:ne}),i.jsxRuntimeExports.jsx(Ve.Axis,{x1:n(a<0?0:a),x2:n(a<0?0:a),y1:-2.5,y2:I+x.bottom,classNames:{axis:M?.yAxis?.axis},styles:{axis:g?.yAxis?.axis}}),$.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(Le.AnimatePresence,{children:[fe.map(e=>o.checkIfNullOrUndefined(m(e.id))?null:i.jsxRuntimeExports.jsxs(_.motion.g,{className:"undp-viz-g-with-hover",onMouseEnter:r=>{W(e),y(r.clientY),k(r.clientX),V?.(e)},onClick:()=>{(U||z)&&(ke.isEqual(N,e)&&L?(X(void 0),U?.(void 0)):(X(e),U?.(e)))},onMouseMove:r=>{W(e),y(r.clientY),k(r.clientX)},onMouseLeave:()=>{W(void 0),k(void 0),y(void 0),V?.(void 0)},exit:{opacity:0,transition:{duration:l.duration}},variants:{initial:{x:0,y:m(`${e.id}`),opacity:h.length!==0?h.indexOf(e.label)!==-1?.85:O:.85},whileInView:{x:0,y:m(`${e.id}`),opacity:h.length!==0?h.indexOf(e.label)!==-1?.85:O:.85,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:[e.qualitativeRange?e.qualitativeRange.map((r,pe)=>i.jsxRuntimeExports.jsx(_.motion.rect,{exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0,fill:P[pe]},whileInView:{x:n(pe===0?0:Re.sum(e.qualitativeRange.filter((je,Ue)=>Ue<pe&&je))),width:n(r),fill:P[pe],transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",y:0,height:m.bandwidth()},pe)):null,e.target&&se==="background"?i.jsxRuntimeExports.jsx(_.motion.rect,{y:0,x:e.target>=0?n(0):n(e.target),height:m.bandwidth(),style:{fill:H},exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0},whileInView:{x:e.target>=0?n(0):n(e.target),width:e.target>=0?n(e.target)-n(0):n(0)-n(e.target),transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,e.size?i.jsxRuntimeExports.jsx(_.motion.rect,{y:m.bandwidth()*((1-c)/2),style:{fill:b},height:m.bandwidth()*c,exit:{width:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),width:0},whileInView:{x:e.size>=0?n(0):n(e.size),width:e.size>=0?n(e.size)-n(0):n(0)-n(e.size),transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,e.target&&se==="line"?i.jsxRuntimeExports.jsx(_.motion.rect,{y:0,height:m.bandwidth(),style:{fill:H},width:2,exit:{opacity:0,x:n(0),transition:{duration:l.duration}},variants:{initial:{x:n(0),opacity:0},whileInView:{x:n(e.target)-1,opacity:1,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial"}):null,u?i.jsxRuntimeExports.jsx(He.YAxesLabels,{value:`${e.label}`.length<de?`${e.label}`:`${`${e.label}`.substring(0,de)}...`,y:0,x:(e.size||0)<0?n(0):0-x.left,width:(e.size||0)<0?ee-n(0):n(0)+x.left,height:m.bandwidth(),alignment:e.size&&e.size<0?"left":"right",style:g?.yAxis?.labels,className:M?.yAxis?.labels,animate:l,isInView:d}):null,re?i.jsxRuntimeExports.jsx(_.motion.text,{y:m.bandwidth()/2,style:{...le?{fill:le}:{fill:b},textAnchor:e.size&&e.size<0?"end":"start",...g?.graphObjectValues||{}},className:i.mo("graph-value text-sm",!le&&b.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",M?.graphObjectValues),dx:e.size&&e.size<0?-5:5,dy:"0.33em",exit:{opacity:0,transition:{duration:l.duration}},variants:{initial:{x:n(0),opacity:0},whileInView:{x:e.size?n(e.size):n(0),opacity:1,transition:{duration:l.duration}}},initial:"initial",animate:d?"whileInView":"initial",children:Ne.numberFormattingFunction(e.size,T,G,K,J)}):null]},e.label)),q?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:q.map((e,r)=>i.jsxRuntimeExports.jsx(ze.RefLineX,{text:e.text,color:e.color,x:n(e.value),y1:0-x.top,y2:I+x.bottom,textSide:n(e.value)>S*.75||F?"left":"right",classNames:e.classNames,styles:e.styles,animate:l,isInView:d},r))}):null]}),$.filter(e=>e.position==="after").map(e=>e.layer)]})}),oe&&D&&ue&&p?i.jsxRuntimeExports.jsx(Ee.Tooltip,{data:oe,body:D,xPos:ue,yPos:p,backgroundStyle:g?.tooltip,className:M?.tooltip}):null,z&&N!==void 0?i.jsxRuntimeExports.jsx(Ce.X,{open:N!==void 0,onClose:()=>{X(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof z=="string"?{__html:Oe.string2HTML(z,N)}:void 0,children:typeof z=="function"?z(N):null})}):null]})}function Xe(we){const{data:s,graphTitle:b,barColor:J=ve.Colors.primaryColors["blue-600"],suffix:K="",sources:Q,prefix:re="",graphDescription:Z,barPadding:ye=.25,showValues:de=!0,showTicks:ee=!0,leftMargin:te=100,rightMargin:be=40,truncateBy:C=999,height:ie,width:u,footNote:D,colorDomain:V,colorLegendTitle:q,highlightedDataPoints:h=[],padding:B,backgroundColor:w=!1,topMargin:U=25,bottomMargin:ae=10,showLabels:F=!0,relativeHeight:A,tooltip:me,onSeriesMouseOver:L,refValues:z,showColorScale:ne=!0,graphID:le,maxValue:E,minValue:g,onSeriesMouseClick:M,graphDownload:se=!1,dataDownload:H=!1,sortData:P,labelOrder:c,language:l="en",minHeight:O=0,theme:G="light",maxBarThickness:$,maxNumberOfBars:T,minBarThickness:f,ariaLabel:d,resetSelectionOnDoubleClick:oe=!0,detailsOnClick:W,barAxisTitle:N,noOfTicks:X=5,valueColor:ue,styles:k,classNames:p,filterNA:y=!0,targetStyle:x="line",targetColor:S=ve.Colors.light.grays["gray-700"],qualitativeRangeColors:I,measureBarWidthFactor:ce=.4,animate:Y=!1,dimmedOpacity:xe=.3,precision:ge=2,customLayers:he=[],naLabel:R="NA"}=we,[a,fe]=j.useState(0),[n,v]=j.useState(0),m=j.useRef(null),t=j.useRef(null);return j.useEffect(()=>{const e=new ResizeObserver(r=>{fe(u||r[0].target.clientWidth||620),v(ie||r[0].target.clientHeight||480)});return m.current&&(v(m.current.clientHeight||480),fe(m.current.clientWidth||620),u||e.observe(m.current)),()=>e.disconnect()},[u,ie]),i.jsxRuntimeExports.jsx("div",{className:`${G||"light"} flex ${u?"w-fit grow-0":"w-full grow"}`,dir:l==="he"||l==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${w?w===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${l||"en"}`,u?"w-fit":"w-full",p?.graphContainer),style:{...k?.graphContainer||{},...w&&w!==!0?{backgroundColor:w}:{}},id:le,ref:t,"aria-label":d||`${b?`The graph shows ${b}. `:""}This is a bar chart. ${Z?` ${Z}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:w?B||"1rem":B||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[b||Z||se||H?i.jsxRuntimeExports.jsx(Se.GraphHeader,{styles:{title:k?.title,description:k?.description},classNames:{title:p?.title,description:p?.description},graphTitle:b,graphDescription:Z,width:u,graphDownload:se?t.current:void 0,dataDownload:H?s.map(e=>e.data).filter(e=>e!==void 0).length>0?s.map(e=>e.data).filter(e=>e!==void 0):s.filter(e=>e!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(De.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[ne&&s.filter(e=>e.qualitativeRange).length!==0&&V?i.jsxRuntimeExports.jsx(Be.ColorLegend,{width:u,colorLegendTitle:q,colors:I||ve.Colors[G].sequentialColors.positiveColorsx10,colorDomain:V,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:m,"aria-label":"Graph area",children:(u||a)&&(ie||n)?i.jsxRuntimeExports.jsx(We,{data:P==="asc"?Me.sortBy(s.filter(e=>y?!o.checkIfNullOrUndefined(e.size):e),e=>e.size).filter((e,r)=>T?r<T:!0):P==="desc"?Me.sortBy(s.filter(e=>y?!o.checkIfNullOrUndefined(e.size):e),e=>e.size).reverse().filter((e,r)=>T?r<T:!0):s.filter(e=>y?!o.checkIfNullOrUndefined(e.size):e).filter((e,r)=>T?r<T:!0),barColor:J,targetColor:S,width:u||a,height:Math.max(O,ie||(A?O?(u||a)*A>O?(u||a)*A:O:(u||a)*A:n)),suffix:K,prefix:re,barPadding:ye,showValues:de,showTicks:ee,leftMargin:te,rightMargin:be,topMargin:U,bottomMargin:ae,truncateBy:C,showLabels:F,tooltip:me,onSeriesMouseOver:L,refValues:z,maxValue:E,minValue:g,highlightedDataPoints:h,onSeriesMouseClick:M,labelOrder:c,rtl:l==="he"||l==="ar",maxBarThickness:$,minBarThickness:f,resetSelectionOnDoubleClick:oe,detailsOnClick:W,barAxisTitle:N,noOfTicks:X,valueColor:ue,classNames:p,styles:k,targetStyle:x,qualitativeRangeColors:I||ve.Colors[G].sequentialColors.positiveColorsx10,measureBarWidthFactor:ce,animate:Y===!0?{duration:.5,once:!0,amount:.5}:Y||{duration:0,once:!0,amount:0},dimmedOpacity:xe,precision:ge,customLayers:he,naLabel:R}):null})]})}),Q||D?i.jsxRuntimeExports.jsx($e.GraphFooter,{sources:Q,footNote:D,width:u,styles:{footnote:k?.footnote,source:k?.source},classNames:{footnote:p?.footnote,source:p?.source}}):null]})})})})}function Ye(we){const{data:s,width:b,height:J,barColor:K,suffix:Q,prefix:re,barPadding:Z,showLabels:ye,showValues:de,showTicks:ee,truncateBy:te,rightMargin:be,topMargin:C,bottomMargin:ie,leftMargin:u,tooltip:D,onSeriesMouseOver:V,refValues:q,maxValue:h,minValue:B,highlightedDataPoints:w,onSeriesMouseClick:U,labelOrder:ae,maxBarThickness:F,minBarThickness:A,resetSelectionOnDoubleClick:me,detailsOnClick:L,barAxisTitle:z,valueColor:ne,noOfTicks:le,styles:E,classNames:g,targetStyle:M,targetColor:se,qualitativeRangeColors:H,measureBarWidthFactor:P,animate:c,dimmedOpacity:l,precision:O,customLayers:G,naLabel:$}=we,T=j.useRef(null),f=Ae.useInView(T,{once:c.once,amount:c.amount}),d={top:C,bottom:ie,left:z?u+30:u,right:be},[oe,W]=j.useState(void 0),[N,X]=j.useState(void 0),[ue,k]=j.useState(void 0),[p,y]=j.useState(void 0),x=b-d.left-d.right,S=J-d.top-d.bottom,I=Math.max(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.size))<0?0:Math.max(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.size)),ce=Math.max(...s.filter(t=>!o.checkIfNullOrUndefined(t.target)).map(t=>t.target))<0?0:Math.max(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.target)),Y=Math.max(...s.map(t=>Re.sum((t.qualitativeRange||[]).filter(e=>!o.checkIfNullOrUndefined(e)))||0)),xe=o.checkIfNullOrUndefined(h)?Math.max(...[I,ce,Y].filter(Number.isFinite))<0?0:Math.max(...[I,ce,Y].filter(Number.isFinite)):h,ge=Math.min(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.size))>=0?0:Math.min(...s.filter(t=>!o.checkIfNullOrUndefined(t.size)).map(t=>t.size)),he=Math.min(...s.filter(t=>!o.checkIfNullOrUndefined(t.target)).map(t=>t.target))>=0?0:Math.min(...s.filter(t=>!o.checkIfNullOrUndefined(t.target)).map(t=>t.target)),R=o.checkIfNullOrUndefined(B)?Math.min(...[ge,he].filter(Number.isFinite))>=0?0:Math.min(...[ge,he].filter(Number.isFinite)):B,a=Te.linear().domain([R,xe]).range([S,0]).nice(),fe=s.map((t,e)=>({...t,id:ae?`${t.label}`:`${e}`})),n=ae||fe.map(t=>`${t.id}`),v=qe.band().domain(n).range([0,A?Math.max(x,A*n.length):F?Math.min(x,F*n.length):x]).paddingInner(Z),m=a.ticks(le);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(_.motion.svg,{width:`${b}px`,height:`${J}px`,viewBox:`0 0 ${b} ${J}`,direction:"ltr",ref:T,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[i.jsxRuntimeExports.jsx(Ve.Axis,{y1:a(R<0?0:R),y2:a(R<0?0:R),x1:0-u,x2:x+d.right,label:Ne.numberFormattingFunction(R<0?0:R,$,O,re,Q),labelPos:{x:0-u,dx:0,dy:xe<0?"1em":-5,y:a(R<0?0:R)},classNames:{axis:g?.xAxis?.axis,label:g?.yAxis?.labels},styles:{axis:E?.xAxis?.axis,label:E?.yAxis?.labels}}),ee?i.jsxRuntimeExports.jsx(Ge.YTicksAndGridLines,{values:m.filter(t=>t!==0),y:m.filter(t=>t!==0).map(t=>a(t)),x1:0-u,x2:x+d.right,styles:{gridLines:E?.yAxis?.gridLines,labels:E?.yAxis?.labels},classNames:{gridLines:g?.yAxis?.gridLines,labels:g?.yAxis?.labels},suffix:Q,prefix:re,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:O}):null,i.jsxRuntimeExports.jsx(Ie.AxisTitle,{x:0-u-15,y:S/2,style:E?.yAxis?.title,className:g?.yAxis?.title,text:z,rotate90:!0}),G.filter(t=>t.position==="before").map(t=>t.layer),i.jsxRuntimeExports.jsxs(Le.AnimatePresence,{children:[fe.map(t=>o.checkIfNullOrUndefined(v(t.id))?null:i.jsxRuntimeExports.jsxs(_.motion.g,{className:"undp-viz-g-with-hover",onMouseEnter:e=>{W(t),y(e.clientY),k(e.clientX),V?.(t)},onClick:()=>{(U||L)&&(ke.isEqual(N,t)&&me?(X(void 0),U?.(void 0)):(X(t),U?.(t)))},onMouseMove:e=>{W(t),y(e.clientY),k(e.clientX)},onMouseLeave:()=>{W(void 0),k(void 0),y(void 0),V?.(void 0)},exit:{opacity:0,transition:{duration:c.duration}},variants:{initial:{x:v(`${t.id}`),y:0,opacity:w.length!==0?w.indexOf(t.label)!==-1?.85:l:.85},whileInView:{x:v(`${t.id}`),y:0,opacity:w.length!==0?w.indexOf(t.label)!==-1?.85:l:.85,transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial",children:[t.qualitativeRange?t.qualitativeRange.map((e,r)=>i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,exit:{height:0,y:a(0),transition:{duration:c.duration}},variants:{initial:{height:0,y:a(0),fill:H[r]},whileInView:{height:Math.abs(a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<=r&&pe)))-a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<r&&pe)))),y:a(Re.sum(t.qualitativeRange.filter((pe,je)=>je<=r&&pe))),fill:H[r],transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial",width:v.bandwidth()},r)):null,t.target&&M==="background"?i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,width:v.bandwidth(),style:{fill:se},exit:{height:0,y:a(0),transition:{duration:c.duration}},variants:{initial:{height:0,y:a(0)},whileInView:{height:Math.abs(a(t.target)-a(0)),y:t.target>0?a(t.target):a(0),transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial"}):null,t.size?i.jsxRuntimeExports.jsx(_.motion.rect,{x:v.bandwidth()*((1-P)/2),width:v.bandwidth()*P,style:{fill:K},exit:{height:0,y:a(0),transition:{duration:c.duration}},variants:{initial:{height:0,y:a(0)},whileInView:{height:Math.abs(a(t.size)-a(0)),y:t.size>0?a(t.size):a(0),transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial"}):null,t.target&&M==="line"?i.jsxRuntimeExports.jsx(_.motion.rect,{x:0,width:v.bandwidth(),style:{fill:se},exit:{y:a(0),opacity:0,transition:{duration:c.duration}},variants:{initial:{y:a(0),opacity:0},whileInView:{y:a(t.target)-1,opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial",height:2}):null,ye?i.jsxRuntimeExports.jsx(Pe.XAxesLabels,{value:`${t.label}`.length<te?`${t.label}`:`${`${t.label}`.substring(0,te)}...`,y:(t.size||0)<0?0:a(0)+5,x:0,width:v.bandwidth(),height:(t.size||0)<0?a(0)-5:d.bottom,style:E?.xAxis?.labels,className:g?.xAxis?.labels,alignment:(t.size||0)<0?"bottom":"top",animate:c,isInView:f}):null,de?i.jsxRuntimeExports.jsx(_.motion.text,{x:v.bandwidth()/2,style:{...ne?{fill:ne}:{fill:K},textAnchor:"middle",...E?.graphObjectValues||{}},className:i.mo("graph-value text-sm",!ne&&K.length>1?" fill-primary-gray-600 dark:fill-primary-gray-300":"",g?.graphObjectValues),dy:t.size?t.size>=0?"-5px":"1em":"-5px",exit:{opacity:0,transition:{duration:c.duration}},variants:{initial:{y:a(0),opacity:0},whileInView:{y:a(t.size||0),opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:f?"whileInView":"initial",children:Ne.numberFormattingFunction(t.size,$,O,re,Q)}):null]},t.label)),q?i.jsxRuntimeExports.jsx(i.jsxRuntimeExports.Fragment,{children:q.map((t,e)=>i.jsxRuntimeExports.jsx(ze.RefLineY,{text:t.text,color:t.color,y:a(t.value),x1:0-u,x2:x+d.right,classNames:t.classNames,styles:t.styles,animate:c,isInView:f},e))}):null]}),G.filter(t=>t.position==="after").map(t=>t.layer)]})}),oe&&D&&ue&&p?i.jsxRuntimeExports.jsx(Ee.Tooltip,{data:oe,body:D,xPos:ue,yPos:p,backgroundStyle:E?.tooltip,className:g?.tooltip}):null,L&&N!==void 0?i.jsxRuntimeExports.jsx(Ce.X,{open:N!==void 0,onClose:()=>{X(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof L=="string"?{__html:Oe.string2HTML(L,N)}:void 0,children:typeof L=="function"?L(N):null})}):null]})}function _e(we){const{data:s,graphTitle:b,barColor:J=ve.Colors.primaryColors["blue-600"],barPadding:K=.25,showTicks:Q=!0,leftMargin:re=20,rightMargin:Z=20,topMargin:ye=20,bottomMargin:de=25,truncateBy:ee=999,showLabels:te=!0,showValues:be=!0,backgroundColor:C=!1,suffix:ie="",prefix:u="",sources:D,graphDescription:V,height:q,width:h,footNote:B,colorDomain:w,colorLegendTitle:U,padding:ae,relativeHeight:F,tooltip:A,onSeriesMouseOver:me,refValues:L,showColorScale:z=!0,graphID:ne,maxValue:le,minValue:E,highlightedDataPoints:g=[],qualitativeRangeColors:M,onSeriesMouseClick:se,graphDownload:H=!1,dataDownload:P=!1,language:c="en",theme:l="light",sortData:O,labelOrder:G,minHeight:$=0,maxBarThickness:T,maxNumberOfBars:f,minBarThickness:d,ariaLabel:oe,resetSelectionOnDoubleClick:W=!0,detailsOnClick:N,barAxisTitle:X,noOfTicks:ue=5,valueColor:k,styles:p,classNames:y,targetColor:x=ve.Colors.light.grays["gray-700"],filterNA:S=!0,targetStyle:I="line",measureBarWidthFactor:ce=.4,animate:Y=!1,dimmedOpacity:xe=.3,precision:ge=2,customLayers:he=[],naLabel:R="NA"}=we,[a,fe]=j.useState(0),[n,v]=j.useState(0),m=j.useRef(null),t=j.useRef(null);return j.useEffect(()=>{const e=new ResizeObserver(r=>{fe(h||r[0].target.clientWidth||620),v(q||r[0].target.clientHeight||480)});return m.current&&(v(m.current.clientHeight||480),fe(m.current.clientWidth||620),h||e.observe(m.current)),()=>e.disconnect()},[h,q]),i.jsxRuntimeExports.jsx("div",{className:`${l||"light"} flex ${h?"w-fit grow-0":"w-full grow"}`,dir:c==="he"||c==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${C?C===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${c||"en"}`,h?"w-fit":"w-full",y?.graphContainer),style:{...p?.graphContainer||{},...C&&C!==!0?{backgroundColor:C}:{}},id:ne,ref:t,"aria-label":oe||`${b?`The graph shows ${b}. `:""}This is a grouped bar chart. ${V?` ${V}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:C?ae||"1rem":ae||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[b||V||H||P?i.jsxRuntimeExports.jsx(Se.GraphHeader,{styles:{title:p?.title,description:p?.description},classNames:{title:y?.title,description:y?.description},graphTitle:b,graphDescription:V,width:h,graphDownload:H?t.current:void 0,dataDownload:P?s.map(e=>e.data).filter(e=>e!==void 0).length>0?s.map(e=>e.data).filter(e=>e!==void 0):s.filter(e=>e!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(De.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[z&&s.filter(e=>e.qualitativeRange).length!==0&&w?i.jsxRuntimeExports.jsx(Be.ColorLegend,{width:h,colorLegendTitle:U,colors:M||ve.Colors[l].sequentialColors.positiveColorsx10,colorDomain:w,showNAColor:!1}):null,i.jsxRuntimeExports.jsx("div",{className:"flex grow flex-col justify-center w-full leading-0",ref:m,"aria-label":"Graph area",children:(h||a)&&(q||n)?i.jsxRuntimeExports.jsx(Ye,{data:O==="asc"?Me.sortBy(s.filter(e=>S?!o.checkIfNullOrUndefined(e.size):e),e=>e.size).filter((e,r)=>f?r<f:!0):O==="desc"?Me.sortBy(s.filter(e=>S?!o.checkIfNullOrUndefined(e.size):e),e=>e.size).reverse().filter((e,r)=>f?r<f:!0):s.filter(e=>S?!o.checkIfNullOrUndefined(e.size):e).filter((e,r)=>f?r<f:!0),barColor:J,targetColor:x,width:h||a,refValues:L,height:Math.max($,q||(F?$?(h||a)*F>$?(h||a)*F:$:(h||a)*F:n)),suffix:ie,prefix:u,barPadding:K,showLabels:te,showValues:be,showTicks:Q,truncateBy:ee,leftMargin:re,rightMargin:Z,qualitativeRangeColors:M||ve.Colors[l].sequentialColors.positiveColorsx10,topMargin:ye,bottomMargin:de,tooltip:A,onSeriesMouseOver:me,maxValue:le,minValue:E,highlightedDataPoints:g,onSeriesMouseClick:se,labelOrder:G,maxBarThickness:T,minBarThickness:d,resetSelectionOnDoubleClick:W,detailsOnClick:N,barAxisTitle:X,noOfTicks:ue,valueColor:k,styles:p,classNames:y,targetStyle:I,dimmedOpacity:xe,measureBarWidthFactor:ce,animate:Y===!0?{duration:.5,once:!0,amount:.5}:Y||{duration:0,once:!0,amount:0},precision:ge,customLayers:he,naLabel:R}):null})]})}),D||B?i.jsxRuntimeExports.jsx($e.GraphFooter,{styles:{footnote:p?.footnote,source:p?.source},classNames:{footnote:y?.footnote,source:y?.source},sources:D,footNote:B,width:h}):null]})})})})}function Je(we){const{data:s,graphTitle:b,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:C,suffix:ie,prefix:u,sources:D,graphDescription:V,height:q,width:h,footNote:B,colorDomain:w,colorLegendTitle:U,padding:ae,relativeHeight:F,tooltip:A,onSeriesMouseOver:me,refValues:L,showColorScale:z,graphID:ne,maxValue:le,minValue:E,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:H,language:P,theme:c,sortData:l,labelOrder:O,minHeight:G,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:f,ariaLabel:d,resetSelectionOnDoubleClick:oe,detailsOnClick:W,barAxisTitle:N,noOfTicks:X,valueColor:ue,orientation:k="vertical",styles:p,classNames:y,filterNA:x,targetStyle:S,targetColor:I,qualitativeRangeColors:ce,measureBarWidthFactor:Y,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R}=we;return k==="vertical"?i.jsxRuntimeExports.jsx(_e,{data:s,graphTitle:b,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:C,suffix:ie,prefix:u,sources:D,graphDescription:V,height:q,width:h,footNote:B,colorDomain:w,colorLegendTitle:U,padding:ae,relativeHeight:F,tooltip:A,onSeriesMouseOver:me,refValues:L,showColorScale:z,graphID:ne,maxValue:le,minValue:E,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:H,language:P,theme:c,sortData:l,labelOrder:O,minHeight:G,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:f,ariaLabel:d,resetSelectionOnDoubleClick:oe,styles:p,detailsOnClick:W,barAxisTitle:N,noOfTicks:X,valueColor:ue,classNames:y,filterNA:x,targetStyle:S,targetColor:I,measureBarWidthFactor:Y,qualitativeRangeColors:ce,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R}):i.jsxRuntimeExports.jsx(Xe,{data:s,graphTitle:b,barColor:J,barPadding:K,showTicks:Q,leftMargin:re,rightMargin:Z,topMargin:ye,bottomMargin:de,truncateBy:ee,showLabels:te,showValues:be,backgroundColor:C,suffix:ie,prefix:u,sources:D,graphDescription:V,height:q,width:h,footNote:B,colorDomain:w,colorLegendTitle:U,padding:ae,relativeHeight:F,tooltip:A,onSeriesMouseOver:me,refValues:L,showColorScale:z,graphID:ne,maxValue:le,minValue:E,highlightedDataPoints:g,onSeriesMouseClick:M,graphDownload:se,dataDownload:H,language:P,theme:c,sortData:l,labelOrder:O,minHeight:G,maxBarThickness:$,maxNumberOfBars:T,minBarThickness:f,ariaLabel:d,resetSelectionOnDoubleClick:oe,styles:p,detailsOnClick:W,barAxisTitle:N,noOfTicks:X,valueColor:ue,classNames:y,filterNA:x,targetStyle:S,targetColor:I,measureBarWidthFactor:Y,qualitativeRangeColors:ce,animate:xe,dimmedOpacity:ge,precision:he,naLabel:R})}exports.BulletChart=Je;
|
|
2
2
|
//# sourceMappingURL=BulletChart.cjs.map
|
package/dist/BulletChart.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { j as e, m as Ni } from "./index-CHPV5EwG-BPSP-7Jg.js";
|
|
2
2
|
import { useRef as ji, useState as gi, useEffect as ki } from "react";
|
|
3
|
-
import { s as Vi } from "./index-
|
|
4
|
-
import { i as Oi } from "./index-
|
|
3
|
+
import { s as Vi } from "./index-fwdktvAS.js";
|
|
4
|
+
import { i as Oi } from "./index-Bwrro8-q.js";
|
|
5
5
|
import { X as Ti } from "./Modal-DVVwpKhP.js";
|
|
6
|
-
import { s as Ci } from "./index-
|
|
6
|
+
import { s as Ci } from "./index-CeVNqhMO.js";
|
|
7
7
|
import { n as zi } from "./numberFormattingFunction-14YCbkN2.js";
|
|
8
|
-
import { T as $i } from "./Tooltip-
|
|
8
|
+
import { T as $i } from "./Tooltip-CVCGWyzw.js";
|
|
9
9
|
import { c as o } from "./checkIfNullOrUndefined-DmfiKkNw.js";
|
|
10
|
-
import { s as Ai } from "./string2HTML-
|
|
10
|
+
import { s as Ai } from "./string2HTML-oFCROsus.js";
|
|
11
11
|
import { X as Xi } from "./XTicksAndGridLines-Bn9u5gOM.js";
|
|
12
12
|
import { Y as Yi } from "./YAxesLabels-CPGZjmZJ.js";
|
|
13
13
|
import { A as Di } from "./AxisTitle-BmHLMRJZ.js";
|
package/dist/ButterflyChart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),y=require("react"),me=require("./getSliderMarks-CtsEXiLV.cjs"),fe=require("./parse-hMnG_lRV.cjs"),Me=require("./index-CZbIGs8q.cjs"),ye=require("./index-BXns0-ng.cjs"),Ae=require("./Modal-tXZlLE5s.cjs"),je=require("./numberFormattingFunction-02t-wJta.cjs"),Ce=require("./Tooltip-n8z5bfav.cjs"),Le=require("./string2HTML-D2Avudmb.cjs"),be=require("./XTicksAndGridLines-CCzXIV8d.cjs"),ve=require("./Axis-DE7dSn1_.cjs"),$e=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"),de=require("./index-BW8iNx7E.cjs"),qe=require("./GraphFooter.cjs"),Ve=require("./GraphHeader.cjs"),Se=require("./ColorLegend.cjs"),Ee=require("./Colors.cjs"),Te=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./index-BW_-wD2k.cjs"),he=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Oe=require("./ensureCompleteData-DqWQ2Zbi.cjs"),Ie=require("./init-DU0ybBc_.cjs");function De(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:$,showTicks:te,suffix:G,prefix:H,resetSelectionOnDoubleClick:ie,detailsOnClick:M,styles:h,classNames:n,noOfTicks:A,animate:m,precision:P,customLayers:se,minValueLeftBar:k,minValueRightBar:N,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(de.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:()=>{($||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),$?.(void 0)):(D(e),$?.(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(k<0?0:k),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(k<0?0:k),x2:o(k<0?0:k),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(de.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:()=>{($||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),$?.(void 0)):(D(e),$?.(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(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]},r)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:l(N<0?0:N),x2:l(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: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(de.AnimatePresence,{children:t.jsxRuntimeExports.jsx(T.motion.g,{transform:`translate(${L/2},0)`,children:X.map((e,r)=>t.jsxRuntimeExports.jsx($e.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(Ce.Tooltip,{data:re,body:J,xPos:ae,yPos:C,backgroundStyle:h?.tooltip,className:n?.tooltip}):null,M&&q!==void 0?t.jsxRuntimeExports.jsx(Ae.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:Le.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=>!he.checkIfNullOrUndefined(E)),d=he.checkIfNullOrUndefined(j)?Math.min(...u)>=0?0:Math.min(...u):j,a=he.checkIfNullOrUndefined(R)?Math.max(...u)<0?0:Math.max(...u):R;return{min:d,max:a}}function Fe(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:$,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:k=!0,showColorScale:N=!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=me.sort(Me.uniqBy(x.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>fe.parse(`${i.date}`,s.dateFormat||"yyyy",new Date).getTime()),(i,F)=>Ie.ascending(i,F)),[ue,ce]=y.useState(s.autoplay?0:g.length-1),ee=y.useRef(null),ge=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 pe=me.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:ge,"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(Ve.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:p?.title,description:p?.description},graphTitle:j,graphDescription:u,width:a,graphDownload:K?ge.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&&pe?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(me.xr,{min:g[0],max:g[g.length-1],marks:pe,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(Te.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[N?t.jsxRuntimeExports.jsx(Se.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(De,{data:Oe.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:$,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:k,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(qe.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:p?.footnote,source:p?.source},sources:R,footNote:E,width:a}):null]})})})})}exports.ButterflyChart=Fe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),y=require("react"),me=require("./getSliderMarks-CtsEXiLV.cjs"),fe=require("./parse-hMnG_lRV.cjs"),Me=require("./index-BJOeaYTk.cjs"),ye=require("./index-DQA8q5sC.cjs"),Ae=require("./Modal-tXZlLE5s.cjs"),je=require("./numberFormattingFunction-02t-wJta.cjs"),Ce=require("./Tooltip-De16GWhY.cjs"),Le=require("./string2HTML-z7CwHXcx.cjs"),be=require("./XTicksAndGridLines-CCzXIV8d.cjs"),ve=require("./Axis-DE7dSn1_.cjs"),$e=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"),de=require("./index-BW8iNx7E.cjs"),qe=require("./GraphFooter.cjs"),Ve=require("./GraphHeader.cjs"),Se=require("./ColorLegend.cjs"),Ee=require("./Colors.cjs"),Te=require("./EmptyState-d8_8SxeW.cjs"),Be=require("./index-BW_-wD2k.cjs"),he=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Oe=require("./ensureCompleteData-BU5Zlccy.cjs"),Ie=require("./init-DU0ybBc_.cjs");function De(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:$,showTicks:te,suffix:G,prefix:H,resetSelectionOnDoubleClick:ie,detailsOnClick:M,styles:h,classNames:n,noOfTicks:A,animate:m,precision:P,customLayers:se,minValueLeftBar:k,minValueRightBar:N,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(de.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:()=>{($||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),$?.(void 0)):(D(e),$?.(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(k<0?0:k),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(k<0?0:k),x2:o(k<0?0:k),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(de.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:()=>{($||M)&&(ye.isEqual(q,e)&&ie?(D(void 0),$?.(void 0)):(D(e),$?.(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(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]},r)),t.jsxRuntimeExports.jsx(ve.Axis,{y1:-2.5,y2:w+c.bottom,x1:l(N<0?0:N),x2:l(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: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(de.AnimatePresence,{children:t.jsxRuntimeExports.jsx(T.motion.g,{transform:`translate(${L/2},0)`,children:X.map((e,r)=>t.jsxRuntimeExports.jsx($e.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(Ce.Tooltip,{data:re,body:J,xPos:ae,yPos:C,backgroundStyle:h?.tooltip,className:n?.tooltip}):null,M&&q!==void 0?t.jsxRuntimeExports.jsx(Ae.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:Le.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=>!he.checkIfNullOrUndefined(E)),d=he.checkIfNullOrUndefined(j)?Math.min(...u)>=0?0:Math.min(...u):j,a=he.checkIfNullOrUndefined(R)?Math.max(...u)<0?0:Math.max(...u):R;return{min:d,max:a}}function Fe(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:$,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:k=!0,showColorScale:N=!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=me.sort(Me.uniqBy(x.filter(i=>i.date!==void 0&&i.date!==null),i=>i.date).map(i=>fe.parse(`${i.date}`,s.dateFormat||"yyyy",new Date).getTime()),(i,F)=>Ie.ascending(i,F)),[ue,ce]=y.useState(s.autoplay?0:g.length-1),ee=y.useRef(null),ge=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 pe=me.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:ge,"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(Ve.GraphHeader,{styles:{title:C?.title,description:C?.description},classNames:{title:p?.title,description:p?.description},graphTitle:j,graphDescription:u,width:a,graphDownload:K?ge.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&&pe?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(me.xr,{min:g[0],max:g[g.length-1],marks:pe,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(Te.EmptyState,{}):t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[N?t.jsxRuntimeExports.jsx(Se.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(De,{data:Oe.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:$,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:k,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(qe.GraphFooter,{styles:{footnote:C?.footnote,source:C?.source},classNames:{footnote:p?.footnote,source:p?.source},sources:R,footNote:E,width:a}):null]})})})})}exports.ButterflyChart=Fe;
|
|
2
2
|
//# sourceMappingURL=ButterflyChart.cjs.map
|
package/dist/ButterflyChart.js
CHANGED
|
@@ -2,12 +2,12 @@ import { j as e, m as et } from "./index-CHPV5EwG-BPSP-7Jg.js";
|
|
|
2
2
|
import { useRef as gt, useState as S, useEffect as yt } from "react";
|
|
3
3
|
import { s as Nt, g as At, x as Ct } from "./getSliderMarks-C0jptXeP.js";
|
|
4
4
|
import { p as kt, f as Lt } from "./parse-DlCRUFh_.js";
|
|
5
|
-
import { u as Vt } from "./index-
|
|
6
|
-
import { i as vt } from "./index-
|
|
5
|
+
import { u as Vt } from "./index-AqnpA7_O.js";
|
|
6
|
+
import { i as vt } from "./index-Bwrro8-q.js";
|
|
7
7
|
import { X as Tt } from "./Modal-DVVwpKhP.js";
|
|
8
8
|
import { n as bt } from "./numberFormattingFunction-14YCbkN2.js";
|
|
9
|
-
import { T as Ot } from "./Tooltip-
|
|
10
|
-
import { s as Dt } from "./string2HTML-
|
|
9
|
+
import { T as Ot } from "./Tooltip-CVCGWyzw.js";
|
|
10
|
+
import { s as Dt } from "./string2HTML-oFCROsus.js";
|
|
11
11
|
import { X as wt } from "./XTicksAndGridLines-Bn9u5gOM.js";
|
|
12
12
|
import { A as jt } from "./Axis-Ddg-seDi.js";
|
|
13
13
|
import { Y as It } from "./YAxesLabels-CPGZjmZJ.js";
|
|
@@ -24,7 +24,7 @@ import { Colors as $t } from "./Colors.js";
|
|
|
24
24
|
import { E as Xt } from "./EmptyState-DdTp-Mdn.js";
|
|
25
25
|
import { P as Et, f as Gt } from "./index-BmCqpO1B.js";
|
|
26
26
|
import { c as ut } from "./checkIfNullOrUndefined-DmfiKkNw.js";
|
|
27
|
-
import { a as Yt } from "./ensureCompleteData-
|
|
27
|
+
import { a as Yt } from "./ensureCompleteData-BALdOrsS.js";
|
|
28
28
|
import { c as Wt } from "./init-BhZylTFx.js";
|
|
29
29
|
function zt(z) {
|
|
30
30
|
const {
|
package/dist/ChoroplethMap.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),je=require("./getSliderMarks-CtsEXiLV.cjs"),we=require("./Spinner-DA6Z5E4n.cjs"),be=require("./parse-hMnG_lRV.cjs"),Re=require("./index-CZbIGs8q.cjs"),$e=require("./index-BXns0-ng.cjs"),T=require("./zoom-Lo7IAUfC.cjs"),Ce=require("./Modal-tXZlLE5s.cjs"),ke=require("./Typography-k-kOjICQ.cjs"),Ne=require("./numberFormattingFunction-02t-wJta.cjs"),Se=require("./Tooltip-n8z5bfav.cjs"),Me=require("./string2HTML-D2Avudmb.cjs"),qe=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ee=require("./index-BW_-wD2k.cjs"),De=require("./ordinal-BOeNbyae.cjs"),Oe=require("./threshold-DNsSUf8Q.cjs"),ve=require("./select-Bnfk0lJx.cjs"),Pe=require("./use-in-view-sQJZ_xDO.cjs"),ue=require("./proxy-BHRoeZgd.cjs"),Ie=require("./index-BW8iNx7E.cjs"),Le=require("./GraphFooter.cjs"),Te=require("./GraphHeader.cjs"),de=require("./Colors.cjs"),ze=require("./fetchAndParseData-CQyVGCul.cjs"),We=require("./getUniqValue-CHqgSss5.cjs"),Ve=require("./getJenks-TWQvbuOz.cjs"),Be=require("./init-DU0ybBc_.cjs");function Fe(pe){const{data:E,colorDomain:h,colors:c,mapData:j,colorLegendTitle:B,categorical:q,height:x,width:n,scale:ae,centerPoint:z,tooltip:ie,mapBorderWidth:D,mapBorderColor:F,mapNoDataColor:Y,onSeriesMouseOver:J,showColorScale:me,zoomScaleExtend:xe,zoomTranslateExtend:O,highlightedIds:H,onSeriesMouseClick:y,mapProperty:A,resetSelectionOnDoubleClick:he,detailsOnClick:$,styles:ge,classNames:ye,mapProjection:U,zoomInteraction:W,animate:b,dimmedOpacity:G,customLayers:se}=pe,[k,C]=d.useState(void 0),K=d.useRef(null),[Z,v]=d.useState(!(n<680)),[N,Q]=d.useState(void 0),[X,ee]=d.useState(void 0),[S,w]=d.useState(void 0),[ne,te]=d.useState(void 0),P=d.useRef(null),re=Pe.useInView(P,{once:b.once,amount:b.amount}),le=d.useRef(null),f=q?De.ordinal().domain(h).range(c):Oe.threshold().domain(h).range(c);d.useEffect(()=>{const r=ve.select(le.current),l=ve.select(P.current),p=a=>{if(W==="noZoom")return!1;if(W==="button")return!a.type.includes("wheel");const s=a.type==="wheel",e=a.type.startsWith("touch"),o=a.type==="mousedown"||a.type==="mousemove";return e?!0:s?W==="scroll"?!0:a.ctrlKey:o&&!a.button&&!a.ctrlKey},i=T.zoom().scaleExtent(xe).translateExtent(O||[[-20,-20],[n+20,x+20]]).filter(p).on("zoom",({transform:a})=>{r.attr("transform",a)});l.call(i),K.current=i},[x,n,W]);const g=T.turf_bbox_default(j),I=T.turf_centroid_default(j),oe=g[2]-g[0],ce=g[3]-g[1],V=n*190/960*360/oe,fe=x*190/678*180/ce,u=ae*Math.min(V,fe),R=U==="mercator"?T.geoMercator().rotate([0,0]).center(z||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="equalEarth"?T.geoEqualEarth().rotate([0,0]).center(z||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="naturalEarth"?T.geoNaturalEarth1().rotate([0,0]).center(z||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="orthographic"?T.geoOrthographic().rotate([0,0]).center(z||I.geometry.coordinates).translate([n/2,x/2]).scale(u):T.geoAlbersUsa().rotate([0,0]).center(z||I.geometry.coordinates).translate([n/2,x/2]).scale(u),_=r=>{if(!P.current||!K.current)return;ve.select(P.current).call(K.current.scaleBy,r==="in"?1.2:1/1.2)};return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"relative",children:[t.jsxRuntimeExports.jsx(ue.motion.svg,{width:`${n}px`,height:`${x}px`,viewBox:`0 0 ${n} ${x}`,ref:P,direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{ref:le,children:[se.filter(r=>r.position==="before").map(r=>r.layer),j.features.map((r,l)=>E.findIndex(i=>i.id===r.properties[A])!==-1?null:t.jsxRuntimeExports.jsx("g",{opacity:k?G:H.length!==0?H.indexOf(r.properties[A])!==-1?1:G:1,children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((i,a)=>{let s="";return i.forEach(e=>{let o=" M";e.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==e.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),s+=o}),t.jsxRuntimeExports.jsx("path",{d:s,style:{stroke:F,strokeWidth:D,fill:Y}},a)}):r.geometry.coordinates.map((i,a)=>{let s="M";return i.forEach((e,o)=>{const m=R([e[0],e[1]]);o!==i.length-1?s=`${s}${m[0]} ${m[1]}L`:s=`${s}${m[0]} ${m[1]}`}),t.jsxRuntimeExports.jsx("path",{d:s,style:{stroke:F,strokeWidth:D,fill:Y}},a)})},l)),t.jsxRuntimeExports.jsx(Ie.AnimatePresence,{children:E.map(r=>{const l=j.features.findIndex(i=>r.id===i.properties[A]),p=qe.checkIfNullOrUndefined(r.x)?Y:f(r.x);return t.jsxRuntimeExports.jsx(ue.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:k?k===p?1:G:H.length!==0?H.indexOf(r.id)!==-1?1:G:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},onMouseEnter:i=>{ee(r),te(i.clientY),w(i.clientX),J?.(r)},onMouseMove:i=>{ee(r),te(i.clientY),w(i.clientX)},onMouseLeave:()=>{ee(void 0),w(void 0),te(void 0),J?.(void 0)},onClick:()=>{(y||$)&&($e.isEqual(N,r)&&he?(Q(void 0),y?.(void 0)):(Q(r),y?.(r)))},children:l===-1?null:j.features[l].geometry.type==="MultiPolygon"?j.features[l].geometry.coordinates.map((i,a)=>{let s="";return i.forEach(e=>{let o=" M";e.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==e.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),s+=o}),t.jsxRuntimeExports.jsx(ue.motion.path,{d:s,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)}):j.features[l].geometry.coordinates.map((i,a)=>{let s="M";return i.forEach((e,o)=>{const m=R([e[0],e[1]]);o!==i.length-1?s=`${s}${m[0]} ${m[1]}L`:s=`${s}${m[0]} ${m[1]}`}),t.jsxRuntimeExports.jsx(ue.motion.path,{d:s,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)})},r.id)})}),X?j.features.filter(r=>r.properties[A]===X.id).map((r,l)=>t.jsxRuntimeExports.jsx("g",{children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((p,i)=>{let a="";return p.forEach(s=>{let e=" M";s.forEach((o,m)=>{const L=R([o[0],o[1]]);m!==s.length-1?e=`${e}${L[0]} ${L[1]}L`:e=`${e}${L[0]} ${L[1]}`}),a+=e}),t.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},i)}):r.geometry.coordinates.map((p,i)=>{let a="M";return p.forEach((s,e)=>{const o=R([s[0],s[1]]);e!==p.length-1?a=`${a}${o[0]} ${o[1]}L`:a=`${a}${o[0]} ${o[1]}`}),t.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},i)})},l)):null,se.filter(r=>r.position==="after").map(r=>r.layer)]})}),me===!1?null:t.jsxRuntimeExports.jsx("div",{className:"absolute left-4 bottom-4",children:Z?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{style:{backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"absolute",right:"-0.75rem",top:"-0.75rem"},onClick:()=>{v(!1)},children:t.jsxRuntimeExports.jsx(Ee.X,{})}),t.jsxRuntimeExports.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.7)",width:q?void 0:"340px"},children:[B&&B!==""?t.jsxRuntimeExports.jsx(ke.u,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:B}):null,q?t.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-3",children:h.map((r,l)=>t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{C(c[l%c.length])},onMouseLeave:()=>{C(void 0)},children:[t.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:c[l%c.length]}}),t.jsxRuntimeExports.jsx(ke.u,{size:"sm",marginBottom:"none",leading:"none",children:r})]},l))}):t.jsxRuntimeExports.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{children:[h.map((r,l)=>t.jsxRuntimeExports.jsxs("g",{onMouseOver:()=>{C(c[l])},onMouseLeave:()=>{C(void 0)},className:"cursor-pointer",children:[t.jsxRuntimeExports.jsx("rect",{x:l*320/c.length+1,y:1,width:320/c.length-2,height:8,className:k===c[l]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:c[l],...k===c[l]?{}:{stroke:c[l]}}}),t.jsxRuntimeExports.jsx("text",{x:(l+1)*320/c.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:Ne.numberFormattingFunction(r,"NA")})]},l)),t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx("rect",{onMouseOver:()=>{C(c[h.length])},onMouseLeave:()=>{C(void 0)},x:h.length*320/c.length+1,y:1,width:320/c.length-2,height:8,className:`cursor-pointer ${k===c[h.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:c[h.length],...k===c[h.length]?{}:{stroke:c[h.length]}}})})]})})]})]}):t.jsxRuntimeExports.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{v(!0)},children:t.jsxRuntimeExports.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})}),W==="button"&&t.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col",children:[t.jsxRuntimeExports.jsx("button",{onClick:()=>_("in"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),t.jsxRuntimeExports.jsx("button",{onClick:()=>_("out"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]})]}),$&&N!==void 0?t.jsxRuntimeExports.jsx(Ce.X,{open:N!==void 0,onClose:()=>{Q(void 0)},children:t.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof $=="string"?{__html:Me.string2HTML($,N)}:void 0,children:typeof $=="function"?$(N):null})}):null,X&&ie&&S&&ne?t.jsxRuntimeExports.jsx(Se.Tooltip,{data:X,body:ie,xPos:S,yPos:ne,backgroundStyle:ge?.tooltip,className:ye?.tooltip}):null]})}function He(pe){const{data:E,mapData:h="https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap.json",graphTitle:c,colors:j,sources:B,graphDescription:q,height:x,width:n,footNote:ae="The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.",colorDomain:z,colorLegendTitle:ie,scaleType:D="threshold",scale:F=.95,centerPoint:Y,padding:J,mapBorderWidth:me=.5,mapNoDataColor:xe=de.Colors.light.graphNoData,backgroundColor:O=!1,mapBorderColor:H=de.Colors.light.grays["gray-500"],relativeHeight:y,tooltip:A,onSeriesMouseOver:he,isWorldMap:$=!0,showColorScale:ge=!0,zoomScaleExtend:ye=[.8,6],zoomTranslateExtend:U,graphID:W,highlightedIds:b=[],onSeriesMouseClick:G,mapProperty:se="ISO3",graphDownload:k=!1,dataDownload:C=!1,showAntarctica:K=!1,language:Z="en",minHeight:v=0,theme:N="light",ariaLabel:Q,resetSelectionOnDoubleClick:X=!0,detailsOnClick:ee,styles:S,classNames:w,mapProjection:ne,zoomInteraction:te="button",animate:P=!1,dimmedOpacity:re=.3,customLayers:le=[],timeline:f={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=pe,[g,I]=d.useState(0),[oe,ce]=d.useState(0),[V,fe]=d.useState(f.autoplay),u=je.sort(Re.uniqBy(E.filter(e=>e.date!==void 0&&e.date!==null),e=>e.date).map(e=>be.parse(`${e.date}`,f.dateFormat||"yyyy",new Date).getTime()),(e,o)=>Be.ascending(e,o)),[R,_]=d.useState(f.autoplay?0:u.length-1),[r,l]=d.useState(void 0),p=d.useRef(null),i=d.useRef(null);d.useEffect(()=>{const e=new ResizeObserver(o=>{I(n||o[0].target.clientWidth||760),ce(x||o[0].target.clientHeight||480)});return p.current&&(ce(p.current.clientHeight||480),I(p.current.clientWidth||760),n||e.observe(p.current)),()=>e.disconnect()},[n,x]),d.useEffect(()=>{typeof h=="string"?ze.fetchAndParseJSON(h).then(o=>{l(o)}):l(h)},[h]);const a=z||(D==="categorical"?We.getUniqValue(E,"x"):Ve.getJenks(E.map(e=>e.x),j?.length||4));d.useEffect(()=>{const e=setInterval(()=>{_(o=>o<u.length-1?o+1:0)},(f.speed||2)*1e3);return V||clearInterval(e),()=>clearInterval(e)},[u,V,f.speed]);const s=je.getSliderMarks(u,R,f.showOnlyActiveDate,f.dateFormat||"yyyy");return t.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${n?"w-fit grow-0":"w-full grow"}`,dir:Z==="he"||Z==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${O?O===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${Z||"en"}`,n?"w-fit":"w-full",w?.graphContainer),style:{...S?.graphContainer||{},...O&&O!==!0?{backgroundColor:O}:{}},id:W,ref:i,"aria-label":Q||`${c?`The graph shows ${c}. `:""}This is a choropleth map where geographic areas are colored in proportion to a specific variable.${q?` ${q}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:O?J||"1rem":J||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[c||q||k||C?t.jsxRuntimeExports.jsx(Te.GraphHeader,{styles:{title:S?.title,description:S?.description},classNames:{title:w?.title,description:w?.description},graphTitle:c,graphDescription:q,width:n,graphDownload:k?i.current:void 0,dataDownload:C?E.map(e=>e.data).filter(e=>e!==void 0).length>0?E.map(e=>e.data).filter(e=>e!==void 0):E.filter(e=>e!==void 0):null}):null,f.enabled&&u.length>0&&s?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{fe(!V)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":V?"Click to pause animation":"Click to play animation",children:V?t.jsxRuntimeExports.jsx(Ee.Pause,{}):t.jsxRuntimeExports.jsx(Ee.Play,{})}),t.jsxRuntimeExports.jsx(je.xr,{min:u[0],max:u[u.length-1],marks:s,step:null,defaultValue:u[u.length-1],value:u[R],onChangeComplete:e=>{_(u.indexOf(e))},onChange:e=>{_(u.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:p,"aria-label":"Map area",children:(n||g)&&(x||oe)&&r?t.jsxRuntimeExports.jsx(Fe,{data:E.filter(e=>f.enabled?e.date===be.format(new Date(u[R]),f.dateFormat||"yyyy"):e),mapData:K?r:{...r,features:r.features.filter(e=>e.properties.NAME!=="Antarctica")},colorDomain:a,width:n||g,height:Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe)),scale:F,centerPoint:Y,colors:j||(D==="categorical"?de.Colors[N].sequentialColors[`neutralColorsx0${a.length}`]:de.Colors[N].sequentialColors[`neutralColorsx0${a.length+1}`]),colorLegendTitle:ie,mapBorderWidth:me,mapNoDataColor:xe,categorical:D==="categorical",mapBorderColor:H,tooltip:A,onSeriesMouseOver:he,isWorldMap:$,showColorScale:ge,zoomScaleExtend:ye,zoomTranslateExtend:U,onSeriesMouseClick:G,mapProperty:se,highlightedIds:b,resetSelectionOnDoubleClick:X,styles:S,classNames:w,detailsOnClick:ee,mapProjection:ne||($?"naturalEarth":"mercator"),zoomInteraction:te,dimmedOpacity:re,animate:P===!0?{duration:.5,once:!0,amount:.5}:P||{duration:0,once:!0,amount:0},customLayers:le}):t.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe))}px`},className:"flex items-center justify-center",children:t.jsxRuntimeExports.jsx(we.y,{"aria-label":"Loading graph"})})}),B||ae?t.jsxRuntimeExports.jsx(Le.GraphFooter,{styles:{footnote:S?.footnote,source:S?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:B,footNote:ae,width:n}):null]})})})})}exports.ChoroplethMap=He;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),je=require("./getSliderMarks-CtsEXiLV.cjs"),we=require("./Spinner-DA6Z5E4n.cjs"),be=require("./parse-hMnG_lRV.cjs"),Re=require("./index-BJOeaYTk.cjs"),$e=require("./index-DQA8q5sC.cjs"),V=require("./zoom-Bsbhil-K.cjs"),Ce=require("./Modal-tXZlLE5s.cjs"),ke=require("./Typography-k-kOjICQ.cjs"),Ne=require("./index-D05lK1Te.cjs"),Se=require("./numberFormattingFunction-02t-wJta.cjs"),Me=require("./Tooltip-De16GWhY.cjs"),qe=require("./string2HTML-z7CwHXcx.cjs"),De=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),Ee=require("./index-BW_-wD2k.cjs"),Oe=require("./ordinal-BOeNbyae.cjs"),Pe=require("./threshold-DNsSUf8Q.cjs"),ve=require("./select-Bnfk0lJx.cjs"),Ie=require("./use-in-view-sQJZ_xDO.cjs"),ue=require("./proxy-BHRoeZgd.cjs"),Le=require("./index-BW8iNx7E.cjs"),Te=require("./GraphFooter.cjs"),ze=require("./GraphHeader.cjs"),de=require("./Colors.cjs"),We=require("./fetchAndParseData-Dcy7AS_0.cjs"),Ve=require("./getUniqValue-CfuE_l9c.cjs"),Be=require("./getJenks-vofIZmeb.cjs"),Fe=require("./init-DU0ybBc_.cjs");function He(pe){const{data:E,colorDomain:h,colors:c,mapData:j,colorLegendTitle:B,categorical:q,height:x,width:n,scale:ae,centerPoint:T,tooltip:ie,mapBorderWidth:D,mapBorderColor:F,mapNoDataColor:Y,onSeriesMouseOver:J,showColorScale:me,zoomScaleExtend:xe,zoomTranslateExtend:O,highlightedIds:H,onSeriesMouseClick:y,mapProperty:A,resetSelectionOnDoubleClick:he,detailsOnClick:$,styles:ge,classNames:ye,mapProjection:U,zoomInteraction:z,animate:b,dimmedOpacity:G,customLayers:se}=pe,[k,C]=d.useState(void 0),K=d.useRef(null),[Z,v]=d.useState(!(n<680)),[N,Q]=d.useState(void 0),[_,ee]=d.useState(void 0),[S,w]=d.useState(void 0),[ne,te]=d.useState(void 0),P=d.useRef(null),re=Ie.useInView(P,{once:b.once,amount:b.amount}),le=d.useRef(null),f=q?Oe.ordinal().domain(h).range(c):Pe.threshold().domain(h).range(c);d.useEffect(()=>{const r=ve.select(le.current),l=ve.select(P.current),p=a=>{if(z==="noZoom")return!1;if(z==="button")return!a.type.includes("wheel");const s=a.type==="wheel",e=a.type.startsWith("touch"),o=a.type==="mousedown"||a.type==="mousemove";return e?!0:s?z==="scroll"?!0:a.ctrlKey:o&&!a.button&&!a.ctrlKey},i=V.zoom().scaleExtent(xe).translateExtent(O||[[-20,-20],[n+20,x+20]]).filter(p).on("zoom",({transform:a})=>{r.attr("transform",a)});l.call(i),K.current=i},[x,n,z]);const g=V.turf_bbox_default(j),I=Ne.turf_center_of_mass_default(j),oe=g[2]-g[0],ce=g[3]-g[1],W=n*190/960*360/oe,fe=x*190/678*180/ce,u=ae*Math.min(W,fe),R=U==="mercator"?V.geoMercator().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="equalEarth"?V.geoEqualEarth().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="naturalEarth"?V.geoNaturalEarth1().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):U==="orthographic"?V.geoOrthographic().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u):V.geoAlbersUsa().rotate([0,0]).center(T||I.geometry.coordinates).translate([n/2,x/2]).scale(u),X=r=>{if(!P.current||!K.current)return;ve.select(P.current).call(K.current.scaleBy,r==="in"?1.2:1/1.2)};return t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsxs("div",{className:"relative",children:[t.jsxRuntimeExports.jsx(ue.motion.svg,{width:`${n}px`,height:`${x}px`,viewBox:`0 0 ${n} ${x}`,ref:P,direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{ref:le,children:[se.filter(r=>r.position==="before").map(r=>r.layer),j.features.map((r,l)=>E.findIndex(i=>i.id===r.properties[A])!==-1?null:t.jsxRuntimeExports.jsx("g",{opacity:k?G:H.length!==0?H.indexOf(r.properties[A])!==-1?1:G:1,children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((i,a)=>{let s="";return i.forEach(e=>{let o=" M";e.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==e.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),s+=o}),t.jsxRuntimeExports.jsx("path",{d:s,style:{stroke:F,strokeWidth:D,fill:Y}},a)}):r.geometry.coordinates.map((i,a)=>{let s="M";return i.forEach((e,o)=>{const m=R([e[0],e[1]]);o!==i.length-1?s=`${s}${m[0]} ${m[1]}L`:s=`${s}${m[0]} ${m[1]}`}),t.jsxRuntimeExports.jsx("path",{d:s,style:{stroke:F,strokeWidth:D,fill:Y}},a)})},l)),t.jsxRuntimeExports.jsx(Le.AnimatePresence,{children:E.map(r=>{const l=j.features.findIndex(i=>r.id===i.properties[A]),p=De.checkIfNullOrUndefined(r.x)?Y:f(r.x);return t.jsxRuntimeExports.jsx(ue.motion.g,{variants:{initial:{opacity:0},whileInView:{opacity:k?k===p?1:G:H.length!==0?H.indexOf(r.id)!==-1?1:G:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},onMouseEnter:i=>{ee(r),te(i.clientY),w(i.clientX),J?.(r)},onMouseMove:i=>{ee(r),te(i.clientY),w(i.clientX)},onMouseLeave:()=>{ee(void 0),w(void 0),te(void 0),J?.(void 0)},onClick:()=>{(y||$)&&($e.isEqual(N,r)&&he?(Q(void 0),y?.(void 0)):(Q(r),y?.(r)))},children:l===-1?null:j.features[l].geometry.type==="MultiPolygon"?j.features[l].geometry.coordinates.map((i,a)=>{let s="";return i.forEach(e=>{let o=" M";e.forEach((m,L)=>{const M=R([m[0],m[1]]);L!==e.length-1?o=`${o}${M[0]} ${M[1]}L`:o=`${o}${M[0]} ${M[1]}`}),s+=o}),t.jsxRuntimeExports.jsx(ue.motion.path,{d:s,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)}):j.features[l].geometry.coordinates.map((i,a)=>{let s="M";return i.forEach((e,o)=>{const m=R([e[0],e[1]]);o!==i.length-1?s=`${s}${m[0]} ${m[1]}L`:s=`${s}${m[0]} ${m[1]}`}),t.jsxRuntimeExports.jsx(ue.motion.path,{d:s,variants:{initial:{fill:p,opacity:0},whileInView:{fill:p,opacity:1,transition:{duration:b.duration}}},initial:"initial",animate:re?"whileInView":"initial",exit:{opacity:0,transition:{duration:b.duration}},style:{stroke:F,strokeWidth:D}},`${r.id}-${a}`)})},r.id)})}),_?j.features.filter(r=>r.properties[A]===_.id).map((r,l)=>t.jsxRuntimeExports.jsx("g",{children:r.geometry.type==="MultiPolygon"?r.geometry.coordinates.map((p,i)=>{let a="";return p.forEach(s=>{let e=" M";s.forEach((o,m)=>{const L=R([o[0],o[1]]);m!==s.length-1?e=`${e}${L[0]} ${L[1]}L`:e=`${e}${L[0]} ${L[1]}`}),a+=e}),t.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},i)}):r.geometry.coordinates.map((p,i)=>{let a="M";return p.forEach((s,e)=>{const o=R([s[0],s[1]]);e!==p.length-1?a=`${a}${o[0]} ${o[1]}L`:a=`${a}${o[0]} ${o[1]}`}),t.jsxRuntimeExports.jsx("path",{d:a,className:"stroke-primary-gray-700 dark:stroke-primary-gray-300",style:{fill:"none",fillOpacity:0,strokeWidth:"0.5"}},i)})},l)):null,se.filter(r=>r.position==="after").map(r=>r.layer)]})}),me===!1?null:t.jsxRuntimeExports.jsx("div",{className:"absolute left-4 bottom-4",children:Z?t.jsxRuntimeExports.jsxs(t.jsxRuntimeExports.Fragment,{children:[t.jsxRuntimeExports.jsx("div",{style:{backgroundColor:"rgba(240,240,240, 0.7)",border:"1px solid var(--gray-400)",borderRadius:"999px",width:"24px",height:"24px",padding:"3px",cursor:"pointer",zIndex:10,position:"absolute",right:"-0.75rem",top:"-0.75rem"},onClick:()=>{v(!1)},children:t.jsxRuntimeExports.jsx(Ee.X,{})}),t.jsxRuntimeExports.jsxs("div",{className:"p-2",style:{backgroundColor:"rgba(240,240,240, 0.7)",width:q?void 0:"340px"},children:[B&&B!==""?t.jsxRuntimeExports.jsx(ke.u,{size:"xs",marginBottom:"xs",className:"p-0 leading-normal overflow-hidden text-primary-gray-700 dark:text-primary-gray-300",style:{display:"-webkit-box",WebkitLineClamp:"1",WebkitBoxOrient:"vertical"},children:B}):null,q?t.jsxRuntimeExports.jsx("div",{className:"flex flex-col gap-3",children:h.map((r,l)=>t.jsxRuntimeExports.jsxs("div",{className:"flex gap-2 items-center",onMouseOver:()=>{C(c[l%c.length])},onMouseLeave:()=>{C(void 0)},children:[t.jsxRuntimeExports.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:c[l%c.length]}}),t.jsxRuntimeExports.jsx(ke.u,{size:"sm",marginBottom:"none",leading:"none",children:r})]},l))}):t.jsxRuntimeExports.jsx("svg",{width:"100%",viewBox:"0 0 320 30",direction:"ltr",children:t.jsxRuntimeExports.jsxs("g",{children:[h.map((r,l)=>t.jsxRuntimeExports.jsxs("g",{onMouseOver:()=>{C(c[l])},onMouseLeave:()=>{C(void 0)},className:"cursor-pointer",children:[t.jsxRuntimeExports.jsx("rect",{x:l*320/c.length+1,y:1,width:320/c.length-2,height:8,className:k===c[l]?"stroke-primary-gray-700 dark:stroke-primary-gray-300":"",style:{fill:c[l],...k===c[l]?{}:{stroke:c[l]}}}),t.jsxRuntimeExports.jsx("text",{x:(l+1)*320/c.length,y:25,className:"fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",style:{textAnchor:"middle"},children:Se.numberFormattingFunction(r,"NA")})]},l)),t.jsxRuntimeExports.jsx("g",{children:t.jsxRuntimeExports.jsx("rect",{onMouseOver:()=>{C(c[h.length])},onMouseLeave:()=>{C(void 0)},x:h.length*320/c.length+1,y:1,width:320/c.length-2,height:8,className:`cursor-pointer ${k===c[h.length]?"stroke-1 stroke-primary-gray-700 dark:stroke-primary-gray-300":""}`,style:{fill:c[h.length],...k===c[h.length]?{}:{stroke:c[h.length]}}})})]})})]})]}):t.jsxRuntimeExports.jsx("button",{type:"button",className:"mb-0 border-0 bg-transparent p-0 self-start",onClick:()=>{v(!0)},children:t.jsxRuntimeExports.jsx("div",{className:"items-start text-sm font-medium cursor-pointer p-2 mb-0 flex text-primary-black dark:text-primary-gray-300 bg-primary-gray-300 dark:bg-primary-gray-550 border-primary-gray-400 dark:border-primary-gray-500",children:"Show Legend"})})}),z==="button"&&t.jsxRuntimeExports.jsxs("div",{className:"absolute left-4 top-4 flex flex-col",children:[t.jsxRuntimeExports.jsx("button",{onClick:()=>X("in"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"+"}),t.jsxRuntimeExports.jsx("button",{onClick:()=>X("out"),className:"leading-0 px-2 py-3.5 text-primary-gray-700 border border-t-0 border-primary-gray-400 bg-primary-gray-200 dark:border-primary-gray-400 dark:bg-primary-gray-600 dark:text-primary-gray-100",children:"–"})]})]}),$&&N!==void 0?t.jsxRuntimeExports.jsx(Ce.X,{open:N!==void 0,onClose:()=>{Q(void 0)},children:t.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof $=="string"?{__html:qe.string2HTML($,N)}:void 0,children:typeof $=="function"?$(N):null})}):null,_&&ie&&S&&ne?t.jsxRuntimeExports.jsx(Me.Tooltip,{data:_,body:ie,xPos:S,yPos:ne,backgroundStyle:ge?.tooltip,className:ye?.tooltip}):null]})}function Ae(pe){const{data:E,mapData:h="https://raw.githubusercontent.com/UNDP-Data/dv-country-geojson/refs/heads/main/worldMap.json",graphTitle:c,colors:j,sources:B,graphDescription:q,height:x,width:n,footNote:ae="The designations employed and the presentation of material on this map do not imply the expression of any opinion whatsoever on the part of the Secretariat of the United Nations or UNDP concerning the legal status of any country, territory, city or area or its authorities, or concerning the delimitation of its frontiers or boundaries.",colorDomain:T,colorLegendTitle:ie,scaleType:D="threshold",scale:F=.95,centerPoint:Y,padding:J,mapBorderWidth:me=.5,mapNoDataColor:xe=de.Colors.light.graphNoData,backgroundColor:O=!1,mapBorderColor:H=de.Colors.light.grays["gray-500"],relativeHeight:y,tooltip:A,onSeriesMouseOver:he,isWorldMap:$=!0,showColorScale:ge=!0,zoomScaleExtend:ye=[.8,6],zoomTranslateExtend:U,graphID:z,highlightedIds:b=[],onSeriesMouseClick:G,mapProperty:se="ISO3",graphDownload:k=!1,dataDownload:C=!1,showAntarctica:K=!1,language:Z="en",minHeight:v=0,theme:N="light",ariaLabel:Q,resetSelectionOnDoubleClick:_=!0,detailsOnClick:ee,styles:S,classNames:w,mapProjection:ne,zoomInteraction:te="button",animate:P=!1,dimmedOpacity:re=.3,customLayers:le=[],timeline:f={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=pe,[g,I]=d.useState(0),[oe,ce]=d.useState(0),[W,fe]=d.useState(f.autoplay),u=je.sort(Re.uniqBy(E.filter(e=>e.date!==void 0&&e.date!==null),e=>e.date).map(e=>be.parse(`${e.date}`,f.dateFormat||"yyyy",new Date).getTime()),(e,o)=>Fe.ascending(e,o)),[R,X]=d.useState(f.autoplay?0:u.length-1),[r,l]=d.useState(void 0),p=d.useRef(null),i=d.useRef(null);d.useEffect(()=>{const e=new ResizeObserver(o=>{I(n||o[0].target.clientWidth||760),ce(x||o[0].target.clientHeight||480)});return p.current&&(ce(p.current.clientHeight||480),I(p.current.clientWidth||760),n||e.observe(p.current)),()=>e.disconnect()},[n,x]),d.useEffect(()=>{typeof h=="string"?We.fetchAndParseJSON(h).then(o=>{l(o)}):l(h)},[h]);const a=T||(D==="categorical"?Ve.getUniqValue(E,"x"):Be.getJenks(E.map(e=>e.x),j?.length||4));d.useEffect(()=>{const e=setInterval(()=>{X(o=>o<u.length-1?o+1:0)},(f.speed||2)*1e3);return W||clearInterval(e),()=>clearInterval(e)},[u,W,f.speed]);const s=je.getSliderMarks(u,R,f.showOnlyActiveDate,f.dateFormat||"yyyy");return t.jsxRuntimeExports.jsx("div",{className:`${N||"light"} flex ${n?"w-fit grow-0":"w-full grow"}`,dir:Z==="he"||Z==="ar"?"rtl":void 0,children:t.jsxRuntimeExports.jsx("div",{className:t.mo(`${O?O===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${Z||"en"}`,n?"w-fit":"w-full",w?.graphContainer),style:{...S?.graphContainer||{},...O&&O!==!0?{backgroundColor:O}:{}},id:z,ref:i,"aria-label":Q||`${c?`The graph shows ${c}. `:""}This is a choropleth map where geographic areas are colored in proportion to a specific variable.${q?` ${q}`:""}`,children:t.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:O?J||"1rem":J||0},children:t.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[c||q||k||C?t.jsxRuntimeExports.jsx(ze.GraphHeader,{styles:{title:S?.title,description:S?.description},classNames:{title:w?.title,description:w?.description},graphTitle:c,graphDescription:q,width:n,graphDownload:k?i.current:void 0,dataDownload:C?E.map(e=>e.data).filter(e=>e!==void 0).length>0?E.map(e=>e.data).filter(e=>e!==void 0):E.filter(e=>e!==void 0):null}):null,f.enabled&&u.length>0&&s?t.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[t.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{fe(!W)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":W?"Click to pause animation":"Click to play animation",children:W?t.jsxRuntimeExports.jsx(Ee.Pause,{}):t.jsxRuntimeExports.jsx(Ee.Play,{})}),t.jsxRuntimeExports.jsx(je.xr,{min:u[0],max:u[u.length-1],marks:s,step:null,defaultValue:u[u.length-1],value:u[R],onChangeComplete:e=>{X(u.indexOf(e))},onChange:e=>{X(u.indexOf(e))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,t.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:p,"aria-label":"Map area",children:(n||g)&&(x||oe)&&r?t.jsxRuntimeExports.jsx(He,{data:E.filter(e=>f.enabled?e.date===be.format(new Date(u[R]),f.dateFormat||"yyyy"):e),mapData:K?r:{...r,features:r.features.filter(e=>e.properties.NAME!=="Antarctica")},colorDomain:a,width:n||g,height:Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe)),scale:F,centerPoint:Y,colors:j||(D==="categorical"?de.Colors[N].sequentialColors[`neutralColorsx0${a.length}`]:de.Colors[N].sequentialColors[`neutralColorsx0${a.length+1}`]),colorLegendTitle:ie,mapBorderWidth:me,mapNoDataColor:xe,categorical:D==="categorical",mapBorderColor:H,tooltip:A,onSeriesMouseOver:he,isWorldMap:$,showColorScale:ge,zoomScaleExtend:ye,zoomTranslateExtend:U,onSeriesMouseClick:G,mapProperty:se,highlightedIds:b,resetSelectionOnDoubleClick:_,styles:S,classNames:w,detailsOnClick:ee,mapProjection:ne||($?"naturalEarth":"mercator"),zoomInteraction:te,dimmedOpacity:re,animate:P===!0?{duration:.5,once:!0,amount:.5}:P||{duration:0,once:!0,amount:0},customLayers:le}):t.jsxRuntimeExports.jsx("div",{style:{height:`${Math.max(v,x||(y?v?(n||g)*y>v?(n||g)*y:v:(n||g)*y:oe))}px`},className:"flex items-center justify-center",children:t.jsxRuntimeExports.jsx(we.y,{"aria-label":"Loading graph"})})}),B||ae?t.jsxRuntimeExports.jsx(Te.GraphFooter,{styles:{footnote:S?.footnote,source:S?.source},classNames:{footnote:w?.footnote,source:w?.source},sources:B,footNote:ae,width:n}):null]})})})})}exports.ChoroplethMap=Ae;
|
|
2
2
|
//# sourceMappingURL=ChoroplethMap.cjs.map
|