@undp/data-viz 1.5.2 → 1.5.4
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.cjs.map +1 -1
- package/dist/AreaChart.js +3 -2
- package/dist/AreaChart.js.map +1 -1
- package/dist/BarGraph.cjs +1 -1
- package/dist/BarGraph.cjs.map +1 -1
- package/dist/BarGraph.js +1196 -1224
- package/dist/BarGraph.js.map +1 -1
- package/dist/BeeSwarmChart.cjs +1 -1
- package/dist/BeeSwarmChart.cjs.map +1 -1
- package/dist/BeeSwarmChart.js +130 -142
- package/dist/BeeSwarmChart.js.map +1 -1
- package/dist/BiVariateChoroplethMap.cjs +1 -1
- package/dist/BiVariateChoroplethMap.cjs.map +1 -1
- package/dist/BiVariateChoroplethMap.js +41 -41
- package/dist/BiVariateChoroplethMap.js.map +1 -1
- package/dist/BulletChart.cjs +1 -1
- package/dist/BulletChart.cjs.map +1 -1
- package/dist/BulletChart.js +484 -488
- package/dist/BulletChart.js.map +1 -1
- package/dist/ButterflyChart.cjs +1 -1
- package/dist/ButterflyChart.cjs.map +1 -1
- package/dist/ButterflyChart.js +99 -99
- package/dist/ButterflyChart.js.map +1 -1
- package/dist/ChoroplethMap.cjs +1 -1
- package/dist/ChoroplethMap.cjs.map +1 -1
- package/dist/ChoroplethMap.js +125 -125
- package/dist/ChoroplethMap.js.map +1 -1
- package/dist/CirclePackingGraph.cjs +1 -1
- package/dist/CirclePackingGraph.js +2 -2
- package/dist/DataCards.cjs +2 -2
- package/dist/DataCards.cjs.map +1 -1
- package/dist/DataCards.js +6 -6
- package/dist/DataCards.js.map +1 -1
- package/dist/DataTable.cjs +1 -1
- package/dist/DataTable.cjs.map +1 -1
- package/dist/DataTable.js +66 -68
- package/dist/DataTable.js.map +1 -1
- package/dist/DifferenceLineChart.cjs +1 -1
- package/dist/DifferenceLineChart.cjs.map +1 -1
- package/dist/DifferenceLineChart.js +3 -2
- package/dist/DifferenceLineChart.js.map +1 -1
- package/dist/DonutChart.cjs +1 -1
- package/dist/DonutChart.cjs.map +1 -1
- package/dist/DonutChart.js +205 -205
- package/dist/DonutChart.js.map +1 -1
- package/dist/DotDensityMap.cjs +1 -1
- package/dist/DotDensityMap.cjs.map +1 -1
- package/dist/DotDensityMap.js +78 -81
- package/dist/DotDensityMap.js.map +1 -1
- package/dist/DualAxisLineChart.cjs +1 -1
- package/dist/DualAxisLineChart.cjs.map +1 -1
- package/dist/DualAxisLineChart.js +3 -2
- package/dist/DualAxisLineChart.js.map +1 -1
- package/dist/DumbbellChart.cjs +1 -1
- package/dist/DumbbellChart.cjs.map +1 -1
- package/dist/DumbbellChart.js +66 -67
- package/dist/DumbbellChart.js.map +1 -1
- package/dist/GeoHubMap.cjs +1 -1
- package/dist/GeoHubMap.js +1 -1
- package/dist/GeoHubMapWithLayerSelection.cjs +1 -1
- package/dist/GeoHubMapWithLayerSelection.js +1 -1
- package/dist/{GraphEl-4RUlclvW.cjs → GraphEl-BcYgMnN2.cjs} +2 -2
- package/dist/{GraphEl-4RUlclvW.cjs.map → GraphEl-BcYgMnN2.cjs.map} +1 -1
- package/dist/{GraphEl-ClIxlWa3.js → GraphEl-CMWeARJ3.js} +2 -2
- package/dist/{GraphEl-ClIxlWa3.js.map → GraphEl-CMWeARJ3.js.map} +1 -1
- package/dist/GriddedGraphs.cjs +1 -1
- package/dist/GriddedGraphs.js +4 -4
- package/dist/GriddedGraphsFromConfig.cjs +1 -1
- package/dist/GriddedGraphsFromConfig.js +1 -1
- package/dist/HeatMap.cjs +1 -1
- package/dist/HeatMap.cjs.map +1 -1
- package/dist/HeatMap.js +83 -83
- package/dist/HeatMap.js.map +1 -1
- package/dist/Histogram.cjs +1 -1
- package/dist/Histogram.js +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
- package/dist/LineChartWithConfidenceInterval.js +7 -6
- package/dist/LineChartWithConfidenceInterval.js.map +1 -1
- package/dist/MultiGraphDashboard.cjs +1 -1
- package/dist/MultiGraphDashboard.js +2 -2
- package/dist/MultiGraphDashboardFromConfig.cjs +1 -1
- package/dist/MultiGraphDashboardFromConfig.js +1 -1
- package/dist/MultiGraphDashboardWideToLongFormat.cjs +1 -1
- package/dist/MultiGraphDashboardWideToLongFormat.js +1 -1
- package/dist/MultiGraphDashboardWideToLongFormatFromConfig.cjs +1 -1
- package/dist/MultiGraphDashboardWideToLongFormatFromConfig.js +1 -1
- package/dist/MultiLineAltChart.cjs +1 -1
- package/dist/MultiLineAltChart.cjs.map +1 -1
- package/dist/MultiLineAltChart.js +82 -91
- package/dist/MultiLineAltChart.js.map +1 -1
- package/dist/MultiLineChart.cjs +1 -1
- package/dist/MultiLineChart.cjs.map +1 -1
- package/dist/MultiLineChart.js +3 -2
- package/dist/MultiLineChart.js.map +1 -1
- package/dist/ParetoChart.cjs +1 -1
- package/dist/ParetoChart.js +1 -1
- package/dist/PerformanceIntensiveMultiGraphDashboard.cjs +1 -1
- package/dist/PerformanceIntensiveMultiGraphDashboard.js +2 -2
- package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.cjs +1 -1
- package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.js +1 -1
- package/dist/RadarChart.cjs +1 -1
- package/dist/RadarChart.cjs.map +1 -1
- package/dist/RadarChart.js +124 -130
- package/dist/RadarChart.js.map +1 -1
- package/dist/SankeyChart.cjs +1 -1
- package/dist/SankeyChart.cjs.map +1 -1
- package/dist/SankeyChart.js +200 -200
- package/dist/SankeyChart.js.map +1 -1
- package/dist/ScatterPlot.cjs +1 -1
- package/dist/ScatterPlot.cjs.map +1 -1
- package/dist/ScatterPlot.js +149 -155
- package/dist/ScatterPlot.js.map +1 -1
- package/dist/SimpleLineChart.cjs +1 -1
- package/dist/SimpleLineChart.cjs.map +1 -1
- package/dist/SimpleLineChart.js +44 -43
- package/dist/SimpleLineChart.js.map +1 -1
- package/dist/SingleGraphDashboard.cjs +1 -1
- package/dist/SingleGraphDashboard.js +4 -4
- package/dist/SingleGraphDashboardFromConfig.cjs +1 -1
- package/dist/SingleGraphDashboardFromConfig.js +1 -1
- package/dist/SingleGraphDashboardGeoHubMapsFromConfig.cjs +1 -1
- package/dist/SingleGraphDashboardGeoHubMapsFromConfig.js +1 -1
- package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
- package/dist/SingleGraphDashboardThreeDGraphs.js +3 -3
- package/dist/SingleGraphDashboardThreeDGraphsFromConfig.cjs +1 -1
- package/dist/SingleGraphDashboardThreeDGraphsFromConfig.js +1 -1
- package/dist/SlopeChart.cjs +1 -1
- package/dist/SlopeChart.cjs.map +1 -1
- package/dist/SlopeChart.js +107 -113
- package/dist/SlopeChart.js.map +1 -1
- package/dist/SparkLine.cjs +1 -1
- package/dist/SparkLine.cjs.map +1 -1
- package/dist/SparkLine.js +3 -2
- package/dist/SparkLine.js.map +1 -1
- package/dist/StripChart.cjs +1 -1
- package/dist/StripChart.cjs.map +1 -1
- package/dist/StripChart.js +159 -159
- package/dist/StripChart.js.map +1 -1
- package/dist/ThreeDGlobe.cjs +1 -1
- package/dist/ThreeDGlobe.cjs.map +1 -1
- package/dist/ThreeDGlobe.js +3 -3
- package/dist/ThreeDGlobe.js.map +1 -1
- package/dist/TreeMapGraph.cjs +1 -1
- package/dist/TreeMapGraph.cjs.map +1 -1
- package/dist/TreeMapGraph.js +194 -200
- package/dist/TreeMapGraph.js.map +1 -1
- package/dist/XAxesLabels-Drf7M3YK.cjs +2 -0
- package/dist/XAxesLabels-Drf7M3YK.cjs.map +1 -0
- package/dist/{XAxesLabels-CaV2q-6H.js → XAxesLabels-loO78vUO.js} +19 -19
- package/dist/XAxesLabels-loO78vUO.js.map +1 -0
- package/dist/YAxesLabels-CctDydGR.cjs +2 -0
- package/dist/YAxesLabels-CctDydGR.cjs.map +1 -0
- package/dist/{YAxesLabels-CPGZjmZJ.js → YAxesLabels-DSm6I5zG.js} +16 -17
- package/dist/YAxesLabels-DSm6I5zG.js.map +1 -0
- package/dist/ensureCompleteData-DkQYPeDa.cjs +2 -0
- package/dist/ensureCompleteData-DkQYPeDa.cjs.map +1 -0
- package/dist/{ensureCompleteData-BALdOrsS.js → ensureCompleteData-DlmibgaI.js} +28 -8
- package/dist/ensureCompleteData-DlmibgaI.js.map +1 -0
- package/dist/fetchAndParseData-Ba-_CgxS.cjs +16 -0
- package/dist/fetchAndParseData-Ba-_CgxS.cjs.map +1 -0
- package/dist/fetchAndParseData-sapWbnYk.js +583 -0
- package/dist/fetchAndParseData-sapWbnYk.js.map +1 -0
- package/dist/fetchAndParseData.cjs +1 -1
- package/dist/fetchAndParseData.js +1 -1
- package/dist/getJenks-BbngDoBQ.js +19 -0
- package/dist/getJenks-BbngDoBQ.js.map +1 -0
- package/dist/getJenks-GYmdwBqm.cjs +2 -0
- package/dist/getJenks-GYmdwBqm.cjs.map +1 -0
- package/dist/getSliderMarks-9cNoRkDx.js +1023 -0
- package/dist/getSliderMarks-9cNoRkDx.js.map +1 -0
- package/dist/getSliderMarks-CRIbTGYV.cjs +6 -0
- package/dist/getSliderMarks-CRIbTGYV.cjs.map +1 -0
- package/dist/getUniqValue-DiCh_MOD.js +13 -0
- package/dist/getUniqValue-DiCh_MOD.js.map +1 -0
- package/dist/getUniqValue-RViz8tTw.cjs +2 -0
- package/dist/getUniqValue-RViz8tTw.cjs.map +1 -0
- package/dist/{index-BMgDMxKJ.js → index-37q0ULNQ.js} +44 -50
- package/dist/index-37q0ULNQ.js.map +1 -0
- package/dist/index-CVlCtJbC.cjs +2 -0
- package/dist/index-CVlCtJbC.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/sort-DfK1b0F5.js +34 -0
- package/dist/sort-DfK1b0F5.js.map +1 -0
- package/dist/sort-O96oMZLb.cjs +2 -0
- package/dist/sort-O96oMZLb.cjs.map +1 -0
- package/dist/transformData.cjs +1 -1
- package/dist/transformData.js +3 -3
- package/dist/transformDataForAggregation-KXGm6flX.cjs +2 -0
- package/dist/{transformDataForAggregation-BVxVu4yY.cjs.map → transformDataForAggregation-KXGm6flX.cjs.map} +1 -1
- package/dist/{transformDataForAggregation-1BYVFqvF.js → transformDataForAggregation-sBpdlX8n.js} +40 -44
- package/dist/{transformDataForAggregation-1BYVFqvF.js.map → transformDataForAggregation-sBpdlX8n.js.map} +1 -1
- package/dist/{transformDataForGraphFromFile-BC9Ha8hF.js → transformDataForGraphFromFile-ComYvzuz.js} +3 -3
- package/dist/{transformDataForGraphFromFile-BC9Ha8hF.js.map → transformDataForGraphFromFile-ComYvzuz.js.map} +1 -1
- package/dist/{transformDataForGraphFromFile-b41aNQYY.cjs → transformDataForGraphFromFile-DVZodTHd.cjs} +2 -2
- package/dist/{transformDataForGraphFromFile-b41aNQYY.cjs.map → transformDataForGraphFromFile-DVZodTHd.cjs.map} +1 -1
- package/dist/uniqBy-BHy4I8PK.js +8 -0
- package/dist/uniqBy-BHy4I8PK.js.map +1 -0
- package/dist/uniqBy-O05lp2S5.cjs +2 -0
- package/dist/uniqBy-O05lp2S5.cjs.map +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +2 -2
- package/package.json +1 -7
- package/dist/XAxesLabels-CaV2q-6H.js.map +0 -1
- package/dist/XAxesLabels-OjBNl_lS.cjs +0 -2
- package/dist/XAxesLabels-OjBNl_lS.cjs.map +0 -1
- package/dist/YAxesLabels-CPGZjmZJ.js.map +0 -1
- package/dist/YAxesLabels-D8IydyZj.cjs +0 -2
- package/dist/YAxesLabels-D8IydyZj.cjs.map +0 -1
- package/dist/ensureCompleteData-BALdOrsS.js.map +0 -1
- package/dist/ensureCompleteData-BU5Zlccy.cjs +0 -2
- package/dist/ensureCompleteData-BU5Zlccy.cjs.map +0 -1
- package/dist/fetchAndParseData-DBOl1Icl.js +0 -1196
- package/dist/fetchAndParseData-DBOl1Icl.js.map +0 -1
- package/dist/fetchAndParseData-Dcy7AS_0.cjs +0 -16
- package/dist/fetchAndParseData-Dcy7AS_0.cjs.map +0 -1
- package/dist/getJenks-DW96UYNE.js +0 -23
- package/dist/getJenks-DW96UYNE.js.map +0 -1
- package/dist/getJenks-vofIZmeb.cjs +0 -2
- package/dist/getJenks-vofIZmeb.cjs.map +0 -1
- package/dist/getSliderMarks-C0jptXeP.js +0 -1054
- package/dist/getSliderMarks-C0jptXeP.js.map +0 -1
- package/dist/getSliderMarks-CtsEXiLV.cjs +0 -6
- package/dist/getSliderMarks-CtsEXiLV.cjs.map +0 -1
- package/dist/getUniqValue-CfuE_l9c.cjs +0 -2
- package/dist/getUniqValue-CfuE_l9c.cjs.map +0 -1
- package/dist/getUniqValue-CttuU_wn.js +0 -20
- package/dist/getUniqValue-CttuU_wn.js.map +0 -1
- package/dist/index-AqnpA7_O.js +0 -631
- package/dist/index-AqnpA7_O.js.map +0 -1
- package/dist/index-BJOeaYTk.cjs +0 -2
- package/dist/index-BJOeaYTk.cjs.map +0 -1
- package/dist/index-BMgDMxKJ.js.map +0 -1
- package/dist/index-DYH8g9WA.cjs +0 -2
- package/dist/index-DYH8g9WA.cjs.map +0 -1
- package/dist/index-Da2GUKrr.cjs +0 -2
- package/dist/index-Da2GUKrr.cjs.map +0 -1
- package/dist/index-fwdktvAS.js +0 -707
- package/dist/index-fwdktvAS.js.map +0 -1
- package/dist/transformDataForAggregation-BVxVu4yY.cjs +0 -2
package/dist/SparkLine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SparkLine.js","sources":["../src/Components/Graphs/LineCharts/SparkLine/Graph.tsx","../src/Components/Graphs/LineCharts/SparkLine/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveMonotoneX,\r\n area,\r\n curveLinear,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport sortBy from 'lodash.sortby';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport {\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n LineChartDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\n\r\ninterface Props {\r\n data: LineChartDataType[];\r\n lineColor: string;\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n areaId?: string;\r\n leftMargin: number;\r\n rightMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n maxValue?: number;\r\n minValue?: number;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n customLayers: CustomLayerDataType[];\r\n}\r\n\r\ninterface FormattedDataType {\r\n y: number;\r\n date: Date;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n lineColor,\r\n dateFormat,\r\n areaId,\r\n leftMargin,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n minValue,\r\n maxValue,\r\n curveType,\r\n styles,\r\n classNames,\r\n customLayers,\r\n } = props;\r\n const curve =\r\n curveType === 'linear'\r\n ? curveLinear\r\n : curveType === 'step'\r\n ? curveStep\r\n : curveType === 'stepAfter'\r\n ? curveStepAfter\r\n : curveType === 'stepBefore'\r\n ? curveStepBefore\r\n : curveMonotoneX;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: leftMargin,\r\n right: rightMargin,\r\n };\r\n const MouseoverRectRef = useRef(null);\r\n const dataFormatted = sortBy(\r\n data.map(d => ({\r\n ...d,\r\n date: parse(`${d.date}`, dateFormat, new Date()),\r\n })),\r\n 'date',\r\n );\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minYear = dataFormatted[0].date;\r\n const maxYear = dataFormatted[dataFormatted.length - 1].date;\r\n const minParam: number =\r\n Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !== Infinity\r\n ? Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) > 0\r\n ? 0\r\n : Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null))\r\n : 0;\r\n const maxParam: number =\r\n Math.max(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !== Infinity\r\n ? Math.max(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null))\r\n : 0;\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? minParam : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxParam > 0 ? maxParam : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n\r\n const mainGraphArea = area<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y1(d => y(d.y))\r\n .y0(graphHeight)\r\n .curve(curve);\r\n const lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n useEffect(() => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const mousemove = (event: any) => {\r\n const selectedData =\r\n dataFormatted[\r\n bisectCenter(\r\n dataFormatted.map(d => d.date),\r\n x.invert(pointer(event)[0]),\r\n 0,\r\n )\r\n ];\r\n setMouseOverData(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n onSeriesMouseOver?.(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n };\r\n const mouseout = () => {\r\n setMouseOverData(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n return (\r\n <>\r\n <svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n >\r\n {areaId ? (\r\n <linearGradient id={areaId} x1='0' x2='0' y1='0' y2='1'>\r\n <stop style={{ stopColor: lineColor }} stopOpacity='0.1' offset='0%' />\r\n <stop style={{ stopColor: lineColor }} stopOpacity='0' offset='100%' />\r\n </linearGradient>\r\n ) : null}\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g>\r\n <text\r\n className={cn(\r\n 'xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n )}\r\n y={graphHeight}\r\n x={x(dataFormatted[dataFormatted.length - 1].date)}\r\n style={{\r\n textAnchor: 'end',\r\n ...styles?.xAxis?.labels,\r\n }}\r\n dy='1em'\r\n >\r\n {format(dataFormatted[dataFormatted.length - 1].date, dateFormat)}\r\n </text>\r\n <text\r\n y={graphHeight}\r\n x={x(dataFormatted[0].date)}\r\n style={{\r\n textAnchor: 'start',\r\n ...styles?.xAxis?.labels,\r\n }}\r\n className={cn(\r\n 'xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n )}\r\n dy='1em'\r\n >\r\n {format(dataFormatted[0].date, dateFormat)}\r\n </text>\r\n </g>\r\n <g>\r\n <path\r\n d={mainGraphArea(dataFormatted) || ''}\r\n style={{\r\n fill: `url(#${areaId})`,\r\n clipPath: 'url(#clip)',\r\n }}\r\n />\r\n <path\r\n d={lineShape(dataFormatted) || ''}\r\n style={{\r\n stroke: lineColor,\r\n fill: 'none',\r\n strokeWidth: 2,\r\n }}\r\n />\r\n {mouseOverData ? (\r\n <circle\r\n y1={0}\r\n cy={y(mouseOverData.y)}\r\n cx={x(mouseOverData.date)}\r\n r={5}\r\n style={{ fill: lineColor }}\r\n />\r\n ) : null}\r\n </g>\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\r\n <rect\r\n ref={MouseoverRectRef}\r\n style={{\r\n fill: 'none',\r\n pointerEvents: 'all',\r\n }}\r\n width={graphWidth}\r\n height={graphHeight}\r\n />\r\n </g>\r\n </svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n Languages,\r\n LineChartDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: LineChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Colors of the lines */\r\n lineColor?: string;\r\n /** Background color of the graph */\r\n backgroundColor?: string | boolean;\r\n /** Custom styles for the graph. Each object should be a valid React CSS style object. */\r\n styles?: StyleObject;\r\n /** Custom class names */\r\n classNames?: ClassNameObject;\r\n\r\n // Size and Spacing\r\n /** Width of the graph */\r\n width?: number;\r\n /** Height of the graph */\r\n height?: number;\r\n /** Minimum height of the graph */\r\n minHeight?: number;\r\n /** Relative height scaling factor. This overwrites the height props */\r\n relativeHeight?: number;\r\n /** Padding around the graph. Defaults to 0 if no backgroundColor is mentioned else defaults to 1rem */\r\n padding?: string;\r\n /** Left margin of the graph */\r\n leftMargin?: number;\r\n /** Right margin of the graph */\r\n rightMargin?: number;\r\n /** Top margin of the graph */\r\n topMargin?: number;\r\n /** Bottom margin of the graph */\r\n bottomMargin?: number;\r\n\r\n // Values and Ticks\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n\r\n // Graph Parameters\r\n /** Format of the date in the data object. Available formats can be found [here](https://date-fns.org/docs/format) */\r\n dateFormat?: string;\r\n /** Toggles the visibility of the area below the line */\r\n area?: boolean;\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function SparkLine(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n lineColor,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n dateFormat = 'yyyy',\r\n area = false,\r\n padding,\r\n backgroundColor,\r\n leftMargin = 5,\r\n rightMargin = 5,\r\n topMargin = 10,\r\n bottomMargin = 20,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n customLayers = [],\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n width ? 'w-fit' : 'w-full',\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a line chart that show trends over time.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n <div\r\n className='flex flex-col grow justify-center leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n lineColor={lineColor || Colors.primaryColors['blue-600']}\r\n width={width || svgWidth}\r\n height={Math.max(\r\n minHeight,\r\n height ||\r\n (relativeHeight\r\n ? minHeight\r\n ? (width || svgWidth) * relativeHeight > minHeight\r\n ? (width || svgWidth) * relativeHeight\r\n : minHeight\r\n : (width || svgWidth) * relativeHeight\r\n : svgHeight),\r\n )}\r\n dateFormat={dateFormat}\r\n areaId={area ? generateRandomString(8) : undefined}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n customLayers={customLayers}\r\n />\r\n ) : null}\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n"],"names":["Graph","props","data","width","height","lineColor","dateFormat","areaId","leftMargin","rightMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","minValue","maxValue","curveType","styles","classNames","customLayers","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","useRef","dataFormatted","sortBy","d","parse","graphWidth","graphHeight","minYear","maxYear","minParam","maxParam","x","scaleTime","y","scaleLinear","checkIfNullOrUndefined","mainGraphArea","area","lineShape","line","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","cn","format","Tooltip","SparkLine","graphTitle","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver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A;AAAA,oBACC,QAAQ,EAAE,UAAU9E,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAAqD;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAAtE;AAAA,kBAAA;AAAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"SparkLine.js","sources":["../src/Components/Graphs/LineCharts/SparkLine/Graph.tsx","../src/Components/Graphs/LineCharts/SparkLine/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveMonotoneX,\r\n area,\r\n curveLinear,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport orderBy from 'lodash.orderby';\r\n\r\nimport {\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n LineChartDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\n\r\ninterface Props {\r\n data: LineChartDataType[];\r\n lineColor: string;\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n areaId?: string;\r\n leftMargin: number;\r\n rightMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n maxValue?: number;\r\n minValue?: number;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n customLayers: CustomLayerDataType[];\r\n}\r\n\r\ninterface FormattedDataType {\r\n y: number;\r\n date: Date;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n lineColor,\r\n dateFormat,\r\n areaId,\r\n leftMargin,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n minValue,\r\n maxValue,\r\n curveType,\r\n styles,\r\n classNames,\r\n customLayers,\r\n } = props;\r\n const curve =\r\n curveType === 'linear'\r\n ? curveLinear\r\n : curveType === 'step'\r\n ? curveStep\r\n : curveType === 'stepAfter'\r\n ? curveStepAfter\r\n : curveType === 'stepBefore'\r\n ? curveStepBefore\r\n : curveMonotoneX;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: leftMargin,\r\n right: rightMargin,\r\n };\r\n const MouseoverRectRef = useRef(null);\r\n const dataFormatted = orderBy(\r\n data.map(d => ({\r\n ...d,\r\n date: parse(`${d.date}`, dateFormat, new Date()),\r\n })),\r\n ['date'],\r\n ['asc'],\r\n );\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minYear = dataFormatted[0].date;\r\n const maxYear = dataFormatted[dataFormatted.length - 1].date;\r\n const minParam: number =\r\n Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !== Infinity\r\n ? Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) > 0\r\n ? 0\r\n : Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null))\r\n : 0;\r\n const maxParam: number =\r\n Math.max(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !== Infinity\r\n ? Math.max(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null))\r\n : 0;\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? minParam : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxParam > 0 ? maxParam : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n\r\n const mainGraphArea = area<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y1(d => y(d.y))\r\n .y0(graphHeight)\r\n .curve(curve);\r\n const lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n useEffect(() => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const mousemove = (event: any) => {\r\n const selectedData =\r\n dataFormatted[\r\n bisectCenter(\r\n dataFormatted.map(d => d.date),\r\n x.invert(pointer(event)[0]),\r\n 0,\r\n )\r\n ];\r\n setMouseOverData(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n onSeriesMouseOver?.(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n };\r\n const mouseout = () => {\r\n setMouseOverData(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n return (\r\n <>\r\n <svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n >\r\n {areaId ? (\r\n <linearGradient id={areaId} x1='0' x2='0' y1='0' y2='1'>\r\n <stop style={{ stopColor: lineColor }} stopOpacity='0.1' offset='0%' />\r\n <stop style={{ stopColor: lineColor }} stopOpacity='0' offset='100%' />\r\n </linearGradient>\r\n ) : null}\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g>\r\n <text\r\n className={cn(\r\n 'xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n )}\r\n y={graphHeight}\r\n x={x(dataFormatted[dataFormatted.length - 1].date)}\r\n style={{\r\n textAnchor: 'end',\r\n ...styles?.xAxis?.labels,\r\n }}\r\n dy='1em'\r\n >\r\n {format(dataFormatted[dataFormatted.length - 1].date, dateFormat)}\r\n </text>\r\n <text\r\n y={graphHeight}\r\n x={x(dataFormatted[0].date)}\r\n style={{\r\n textAnchor: 'start',\r\n ...styles?.xAxis?.labels,\r\n }}\r\n className={cn(\r\n 'xs:max-[360px]:hidden fill-primary-gray-700 dark:fill-primary-gray-300 text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n )}\r\n dy='1em'\r\n >\r\n {format(dataFormatted[0].date, dateFormat)}\r\n </text>\r\n </g>\r\n <g>\r\n <path\r\n d={mainGraphArea(dataFormatted) || ''}\r\n style={{\r\n fill: `url(#${areaId})`,\r\n clipPath: 'url(#clip)',\r\n }}\r\n />\r\n <path\r\n d={lineShape(dataFormatted) || ''}\r\n style={{\r\n stroke: lineColor,\r\n fill: 'none',\r\n strokeWidth: 2,\r\n }}\r\n />\r\n {mouseOverData ? (\r\n <circle\r\n y1={0}\r\n cy={y(mouseOverData.y)}\r\n cx={x(mouseOverData.date)}\r\n r={5}\r\n style={{ fill: lineColor }}\r\n />\r\n ) : null}\r\n </g>\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\r\n <rect\r\n ref={MouseoverRectRef}\r\n style={{\r\n fill: 'none',\r\n pointerEvents: 'all',\r\n }}\r\n width={graphWidth}\r\n height={graphHeight}\r\n />\r\n </g>\r\n </svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n Languages,\r\n LineChartDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: LineChartDataType[];\r\n\r\n // Titles, Labels, and Sources\r\n /** Title of the graph */\r\n graphTitle?: string | React.ReactNode;\r\n /** Description of the graph */\r\n graphDescription?: string | React.ReactNode;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Colors of the lines */\r\n lineColor?: string;\r\n /** Background color of the graph */\r\n backgroundColor?: string | boolean;\r\n /** Custom styles for the graph. Each object should be a valid React CSS style object. */\r\n styles?: StyleObject;\r\n /** Custom class names */\r\n classNames?: ClassNameObject;\r\n\r\n // Size and Spacing\r\n /** Width of the graph */\r\n width?: number;\r\n /** Height of the graph */\r\n height?: number;\r\n /** Minimum height of the graph */\r\n minHeight?: number;\r\n /** Relative height scaling factor. This overwrites the height props */\r\n relativeHeight?: number;\r\n /** Padding around the graph. Defaults to 0 if no backgroundColor is mentioned else defaults to 1rem */\r\n padding?: string;\r\n /** Left margin of the graph */\r\n leftMargin?: number;\r\n /** Right margin of the graph */\r\n rightMargin?: number;\r\n /** Top margin of the graph */\r\n topMargin?: number;\r\n /** Bottom margin of the graph */\r\n bottomMargin?: number;\r\n\r\n // Values and Ticks\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n\r\n // Graph Parameters\r\n /** Format of the date in the data object. Available formats can be found [here](https://date-fns.org/docs/format) */\r\n dateFormat?: string;\r\n /** Toggles the visibility of the area below the line */\r\n area?: boolean;\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function SparkLine(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n lineColor,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n dateFormat = 'yyyy',\r\n area = false,\r\n padding,\r\n backgroundColor,\r\n leftMargin = 5,\r\n rightMargin = 5,\r\n topMargin = 10,\r\n bottomMargin = 20,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n customLayers = [],\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n width ? 'w-fit' : 'w-full',\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a line chart that show trends over time.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n <div\r\n className='flex flex-col grow justify-center leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n lineColor={lineColor || Colors.primaryColors['blue-600']}\r\n width={width || svgWidth}\r\n height={Math.max(\r\n minHeight,\r\n height ||\r\n (relativeHeight\r\n ? minHeight\r\n ? (width || svgWidth) * relativeHeight > minHeight\r\n ? (width || svgWidth) * relativeHeight\r\n : minHeight\r\n : (width || svgWidth) * relativeHeight\r\n : svgHeight),\r\n )}\r\n dateFormat={dateFormat}\r\n areaId={area ? generateRandomString(8) : undefined}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n customLayers={customLayers}\r\n />\r\n ) : null}\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n"],"names":["Graph","props","data","width","height","lineColor","dateFormat","areaId","leftMargin","rightMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","minValue","maxValue","curveType","styles","classNames","customLayers","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","useRef","dataFormatted","orderBy","d","parse","graphWidth","graphHeight","minYear","maxYear","minParam","maxParam","x","scaleTime","y","scaleLinear","checkIfNullOrUndefined","mainGraphArea","area","lineShape","line","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","cn","format","Tooltip","SparkLine","graphTitle","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","Colors","generateRandomString","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;AAwDO,SAASA,GAAMC,GAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,YAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,cAAAC;AAAA,EAAA,IACElB,GACEmB,IACJJ,MAAc,WACVK,KACAL,MAAc,SACZM,KACAN,MAAc,cACZO,KACAP,MAAc,eACZQ,KACAC,IAEN,CAACC,GAAeC,CAAgB,IAAIC,EAAc,MAAS,GAC3D,CAACC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A,wBACA,WAAWG,KAAawF,GAAO,cAAc,UAAU;AAAA,wBACvD,OAAO1F,KAASiF;AAAA,wBAChB,QAAQ,KAAK;AAAA,0BACXH;AAAA,0BACA7E,MACGwE,IACGK,KACG9E,KAASiF,KAAYR,IAAiBK,KACpC9E,KAASiF,KAAYR,IACtBK,KACD9E,KAASiF,KAAYR,IACxBU;AAAA,wBAAA;AAAA,wBAER,YAAAhF;AAAA,wBACA,QAAQ8C,IAAO0C,GAAqB,CAAC,IAAI;AAAA,wBACzC,YAAAtF;AAAA,wBACA,aAAAC;AAAA,wBACA,WAAAC;AAAA,wBACA,cAAAC;AAAA,wBACA,SAAAC;AAAA,wBACA,mBAAAC;AAAA,wBACA,UAAAC;AAAA,wBACA,UAAAC;AAAA,wBACA,WAAAC;AAAA,wBACA,QAAAC;AAAA,wBACA,YAAAC;AAAA,wBACA,cAAAC;AAAA,sBAAA;AAAA,oBAAA,IAEA;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAELoD,KAAWE,IACVR,gBAAAA,EAAAA;AAAAA,kBAAC8B;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAU9E,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAAqD;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAAtE;AAAA,kBAAA;AAAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
package/dist/StripChart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),ce=require("./index-BJOeaYTk.cjs"),p=require("react"),xe=require("./index-DQA8q5sC.cjs"),de=require("./index-DYH8g9WA.cjs"),ge=require("./Modal-tXZlLE5s.cjs"),pe=require("./Tooltip-De16GWhY.cjs"),J=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ue=require("./numberFormattingFunction-02t-wJta.cjs"),c=require("./Colors.cjs"),fe=require("./string2HTML-z7CwHXcx.cjs"),me=require("./linear-BVckp9RD.cjs"),ye=require("./use-in-view-sQJZ_xDO.cjs"),le=require("./proxy-BHRoeZgd.cjs"),ve=require("./index-BW8iNx7E.cjs"),je=require("./GraphFooter.cjs"),we=require("./GraphHeader.cjs"),Oe=require("./ColorLegendWithMouseOver.cjs"),Ce=require("./EmptyState-d8_8SxeW.cjs");function be(L,o){if(L<2)return[];const x=o/(L-1);return Array.from({length:L},(f,r)=>r*x)}function Ee(L){const{data:o,width:x,height:f,colors:r,colorDomain:a,radius:u,leftMargin:s,rightMargin:P,topMargin:W,bottomMargin:ee,tooltip:U,onSeriesMouseOver:k,highlightedDataPoints:l,selectedColor:z,minValue:G,maxValue:X,onSeriesMouseClick:D,prefix:K,suffix:C,stripType:Q,highlightColor:v,dotOpacity:j,resetSelectionOnDoubleClick:te,detailsOnClick:N,styles:E,classNames:I,valueColor:V,animate:m,noOfTicks:w,dimmedOpacity:$,precision:B,customLayers:M}=L,Y=p.useRef(null),R=ye.useInView(Y,{once:m.once,amount:m.amount}),[T,y]=p.useState(void 0),[d,H]=p.useState(void 0),[_,q]=p.useState(void 0),[g,h]=p.useState(void 0),O={top:W,bottom:ee,left:s,right:P},S=x-O.left-O.right,A=f-O.top-O.bottom,ie=o.map((e,t)=>({...e,id:`${t}`})),oe=de.sortBy(ie,e=>{const t=(l||[]).indexOf(e.label);return t===-1?1/0:t}).reverse(),re=J.checkIfNullOrUndefined(X)?Math.max(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position))<0?0:Math.max(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position)):X,b=J.checkIfNullOrUndefined(G)?Math.min(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position))>=0?0:Math.min(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position)):G,F=me.linear().domain([b,re]).range([0,S]).nice(),ne=be(w,S);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.svg,{width:`${x}px`,height:`${f}px`,viewBox:`0 0 ${x} ${f}`,direction:"ltr",ref:Y,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${O.left},${O.top})`,children:[M.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(ve.AnimatePresence,{children:[oe.map(e=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:0,x:F(0),y:A/2},whileInView:{x:F(e.position),y:A/2,opacity:z?e.color&&r[a.indexOf(e.color)]===z?.95:$:l.length!==0?l.indexOf(e.label)!==-1?.95:$:j,transition:{duration:m.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:m.duration}},onMouseEnter:t=>{y(e),h(t.clientY),q(t.clientX),k?.(e)},onClick:()=>{(D||N)&&(xe.isEqual(d,e)&&te?(H(void 0),D?.(void 0)):(H(e),D?.(e)))},onMouseMove:t=>{y(e),h(t.clientY),q(t.clientX)},onMouseLeave:()=>{y(void 0),q(void 0),h(void 0),k?.(void 0)},children:[Q==="dot"?i.jsxRuntimeExports.jsx(le.motion.circle,{cy:0,cx:0,variants:{initial:{fill:v&&l?l.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray},whileInView:{fill:v&&l?l.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray,transition:{duration:m.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:m.duration}},r:u}):i.jsxRuntimeExports.jsx(le.motion.rect,{y:0-u,x:-1,height:u*2,width:2,variants:{initial:{fill:v&&l?l.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray},whileInView:{fill:v&&l?l.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray,transition:{duration:m.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:m.duration}}}),l.length!==0&&l.indexOf(e.label)!==-1?i.jsxRuntimeExports.jsx(le.motion.text,{x:0,y:0-u-5,variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:m.duration}},style:{fill:V||(v&&l?l.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray),textAnchor:"middle",...E?.graphObjectValues||{}},className:i.mo("graph-value text-sm font-bold",I?.graphObjectValues),children:ue.numberFormattingFunction(e.position,"NA",B,K,C)}):null]},e.label)),ne.map((e,t)=>i.jsxRuntimeExports.jsx("text",{x:e,y:A/2+u,style:{textAnchor:t===0?"start":t===ne.length-1?"end":"middle",...E?.xAxis?.labels||{}},className:i.mo("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",I?.xAxis?.labels),dy:"1em",children:ue.numberFormattingFunction(F.invert(e),"NA",B,K,C)},t))]}),M.filter(e=>e.position==="after").map(e=>e.layer)]})}),T&&U&&_&&g?i.jsxRuntimeExports.jsx(pe.Tooltip,{data:T,body:U,xPos:_,yPos:g,backgroundStyle:E?.tooltip,className:I?.tooltip}):null,N&&d!==void 0?i.jsxRuntimeExports.jsx(ge.X,{open:d!==void 0,onClose:()=>{H(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof N=="string"?{__html:fe.string2HTML(N,d)}:void 0,children:typeof N=="function"?N(d):null})}):null]})}function Me(L){const{data:o,graphTitle:x,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U=5,padding:k,backgroundColor:l=!1,leftMargin:z=5,rightMargin:G=5,topMargin:X=10,bottomMargin:D=10,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v=!0,highlightedDataPoints:j=[],graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,graphDownload:V=!1,dataDownload:m=!1,prefix:w="",suffix:$="",stripType:B="dot",language:M="en",highlightColor:Y,dotOpacity:R=.3,showNAColor:T=!0,minHeight:y=0,theme:d="light",ariaLabel:H,resetSelectionOnDoubleClick:_=!0,detailsOnClick:q,styles:g,classNames:h,valueColor:O,animate:S=!1,noOfTicks:A=2,dimmedOpacity:ie=.3,precision:oe=2,customLayers:re=[]}=L,[b,F]=p.useState(0),[ne,e]=p.useState(0),[t,he]=p.useState(void 0),Z=p.useRef(null),ae=p.useRef(null);return p.useEffect(()=>{const n=new ResizeObserver(se=>{F(s||se[0].target.clientWidth||620),e(u||se[0].target.clientHeight||480)});return Z.current&&(e(Z.current.clientHeight||480),F(Z.current.clientWidth||620),s||n.observe(Z.current)),()=>n.disconnect()},[s,u]),i.jsxRuntimeExports.jsx("div",{className:`${d||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${l?l===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,s?"w-fit":"w-full",h?.graphContainer),style:{...g?.graphContainer||{},...l&&l!==!0?{backgroundColor:l}:{}},id:te,ref:ae,"aria-label":H||`${x?`The graph shows ${x}. `:""}This is a strip chart showing distribution of data along the horizontal axis. Each dot represents an individual data point, helping to visualize the spread and clustering of values.${a?` ${a}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:l?k||"1rem":k||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[x||a||V||m?i.jsxRuntimeExports.jsx(we.GraphHeader,{styles:{title:g?.title,description:g?.description},classNames:{title:h?.title,description:h?.description},graphTitle:x,graphDescription:a,width:s,graphDownload:V?ae.current:void 0,dataDownload:m?o.map(n=>n.data).filter(n=>n!==void 0).length>0?o.map(n=>n.data).filter(n=>n!==void 0):o.filter(n=>n!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?i.jsxRuntimeExports.jsx(Ce.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[v!==!1&&o.filter(n=>n.color).length!==0?i.jsxRuntimeExports.jsx(Oe.ColorLegendWithMouseOver,{width:s,colorLegendTitle:ee,colors:f||c.Colors[d].categoricalColors.colors,colorDomain:W||ce.uniqBy(o.filter(n=>n.color),"color").map(n=>n.color),setSelectedColor:he,showNAColor:T??!0}):null,i.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:Z,"aria-label":"Graph area",children:(s||b)&&(u||ne)?i.jsxRuntimeExports.jsx(Ee,{data:o,width:s||b,height:Math.max(y,u||(C?y?(s||b)*C>y?(s||b)*C:y:(s||b)*C:ne)),colorDomain:o.filter(n=>n.color).length===0?[]:W||ce.uniqBy(o.filter(n=>n.color),"color").map(n=>n.color),colors:o.filter(n=>n.color).length===0?f?[f]:[c.Colors.primaryColors["blue-600"]]:f||c.Colors[d].categoricalColors.colors,selectedColor:t,radius:U,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,onSeriesMouseOver:Q,highlightedDataPoints:j,minValue:N,maxValue:E,onSeriesMouseClick:I,prefix:w,suffix:$,stripType:B,highlightColor:Y,dotOpacity:R,resetSelectionOnDoubleClick:_,detailsOnClick:q,styles:g,classNames:h,valueColor:O,animate:S===!0?{duration:.5,once:!0,amount:.5}:S||{duration:0,once:!0,amount:0},noOfTicks:A,dimmedOpacity:ie,precision:oe,customLayers:re}):null})]})}),r||P?i.jsxRuntimeExports.jsx(je.GraphFooter,{styles:{footnote:g?.footnote,source:g?.source},classNames:{footnote:h?.footnote,source:h?.source},sources:r,footNote:P,width:s}):null]})})})})}function Re(L){const{data:o,width:x,height:f,colors:r,colorDomain:a,radius:u,leftMargin:s,rightMargin:P,topMargin:W,bottomMargin:ee,tooltip:U,onSeriesMouseOver:k,highlightedDataPoints:l,selectedColor:z,minValue:G,maxValue:X,onSeriesMouseClick:D,noOfTicks:K,prefix:C,suffix:Q,stripType:v,highlightColor:j,dotOpacity:te,resetSelectionOnDoubleClick:N,detailsOnClick:E,styles:I,classNames:V,valueColor:m,animate:w,dimmedOpacity:$,precision:B,customLayers:M}=L,Y=p.useRef(null),R=ye.useInView(Y,{once:w.once,amount:w.amount}),[T,y]=p.useState(void 0),[d,H]=p.useState(void 0),[_,q]=p.useState(void 0),[g,h]=p.useState(void 0),O={top:W,bottom:ee,left:s,right:P},S=x-O.left-O.right,A=f-O.top-O.bottom,ie=o.map((e,t)=>({...e,id:`${t}`})),oe=de.sortBy(ie,e=>{const t=(l||[]).indexOf(e.label);return t===-1?1/0:t}).reverse(),re=J.checkIfNullOrUndefined(X)?Math.max(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position))<0?0:Math.max(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position)):X,b=J.checkIfNullOrUndefined(G)?Math.min(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position))>=0?0:Math.min(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position)):G,F=me.linear().domain([b,re]).range([A,0]).nice(),ne=be(K,A);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.svg,{width:`${x}px`,height:`${f}px`,viewBox:`0 0 ${x} ${f}`,direction:"ltr",ref:Y,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${O.left},${O.top})`,children:[M.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(ve.AnimatePresence,{children:[oe.map(e=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:0,x:S/2,y:F(0)},whileInView:{x:S/2,y:F(e.position),opacity:z?e.color&&r[a.indexOf(e.color)]===z?.95:$:l.length!==0?l.indexOf(e.label)!==-1?.95:$:te,transition:{duration:w.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},onMouseEnter:t=>{y(e),h(t.clientY),q(t.clientX),k?.(e)},onClick:()=>{(D||E)&&(xe.isEqual(d,e)&&N?(H(void 0),D?.(void 0)):(H(e),D?.(e)))},onMouseMove:t=>{y(e),h(t.clientY),q(t.clientX)},onMouseLeave:()=>{y(void 0),q(void 0),h(void 0),k?.(void 0)},children:[v==="dot"?i.jsxRuntimeExports.jsx(le.motion.circle,{cy:0,cx:0,variants:{initial:{fill:j&&l?l.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray},whileInView:{fill:j&&l?l.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray,transition:{duration:w.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},r:u}):i.jsxRuntimeExports.jsx(le.motion.rect,{x:0-u,y:-1,width:u*2,height:2,variants:{initial:{fill:j&&l?l.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray},whileInView:{fill:j&&l?l.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray,transition:{duration:w.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}}}),l.length!==0&&l.indexOf(e.label)!==-1?i.jsxRuntimeExports.jsx(le.motion.text,{y:0,dy:"0.33em",x:0+u+3,variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:w.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},style:{fill:m||(j&&l?l.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray),textAnchor:"start",...I?.graphObjectValues||{}},className:i.mo("graph-value text-sm font-bold",V?.graphObjectValues),children:ue.numberFormattingFunction(e.position,"NA",B,C,Q)}):null]},e.label)),ne.map((e,t)=>i.jsxRuntimeExports.jsx("text",{y:e,x:S/2+u+5,style:{textAnchor:"start",...I?.yAxis?.labels||{}},className:i.mo("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",V?.yAxis?.labels),children:ue.numberFormattingFunction(F.invert(e),"NA",B,C,Q)},t))]}),M.filter(e=>e.position==="after").map(e=>e.layer)]})}),T&&U&&_&&g?i.jsxRuntimeExports.jsx(pe.Tooltip,{data:T,body:U,xPos:_,yPos:g,backgroundStyle:I?.tooltip,className:V?.tooltip}):null,E&&d!==void 0?i.jsxRuntimeExports.jsx(ge.X,{open:d!==void 0,onClose:()=>{H(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof E=="string"?{__html:fe.string2HTML(E,d)}:void 0,children:typeof E=="function"?E(d):null})}):null]})}function Ne(L){const{data:o,graphTitle:x,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U=5,padding:k,backgroundColor:l=!1,leftMargin:z=20,rightMargin:G=20,topMargin:X=10,bottomMargin:D=10,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v=!0,highlightedDataPoints:j=[],graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,graphDownload:V=!1,dataDownload:m=!1,prefix:w="",suffix:$="",stripType:B="dot",language:M="en",highlightColor:Y,dotOpacity:R=.3,showNAColor:T=!0,minHeight:y=0,theme:d="light",ariaLabel:H,resetSelectionOnDoubleClick:_=!0,detailsOnClick:q,styles:g,classNames:h,valueColor:O,animate:S=!1,noOfTicks:A=2,dimmedOpacity:ie=.3,precision:oe=2,customLayers:re=[]}=L,[b,F]=p.useState(0),[ne,e]=p.useState(0),[t,he]=p.useState(void 0),Z=p.useRef(null),ae=p.useRef(null);return p.useEffect(()=>{const n=new ResizeObserver(se=>{F(s||se[0].target.clientWidth||620),e(u||se[0].target.clientHeight||480)});return Z.current&&(e(Z.current.clientHeight||480),F(Z.current.clientWidth||620),s||n.observe(Z.current)),()=>n.disconnect()},[s,u]),i.jsxRuntimeExports.jsx("div",{className:`${d||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${l?l===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,s?"w-fit":"w-full",h?.graphContainer),style:{...g?.graphContainer||{},...l&&l!==!0?{backgroundColor:l}:{}},id:te,ref:ae,"aria-label":H||`${x?`The graph shows ${x}. `:""}This is a strip chart showing distribution of data along the vertical axis. Each dot represents an individual data point, helping to visualize the spread and clustering of values.${a?` ${a}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:l?k||"1rem":k||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[x||a||V||m?i.jsxRuntimeExports.jsx(we.GraphHeader,{styles:{title:g?.title,description:g?.description},classNames:{title:h?.title,description:h?.description},graphTitle:x,graphDescription:a,width:s,graphDownload:V?ae.current:void 0,dataDownload:m?o.map(n=>n.data).filter(n=>n!==void 0).length>0?o.map(n=>n.data).filter(n=>n!==void 0):o.filter(n=>n!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?i.jsxRuntimeExports.jsx(Ce.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[v!==!1&&o.filter(n=>n.color).length!==0?i.jsxRuntimeExports.jsx(Oe.ColorLegendWithMouseOver,{width:s,colorLegendTitle:ee,colors:f||c.Colors[d].categoricalColors.colors,colorDomain:W||ce.uniqBy(o.filter(n=>n.color),"color").map(n=>n.color),setSelectedColor:he,showNAColor:T}):null,i.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:Z,children:(s||b)&&(u||ne)?i.jsxRuntimeExports.jsx(Re,{data:o,width:s||b,height:Math.max(y,u||(C?y?(s||b)*C>y?(s||b)*C:y:(s||b)*C:ne)),colorDomain:o.filter(n=>n.color).length===0?[]:W||ce.uniqBy(o.filter(n=>n.color),"color").map(n=>n.color),colors:o.filter(n=>n.color).length===0?f?[f]:[c.Colors.primaryColors["blue-600"]]:f||c.Colors[d].categoricalColors.colors,selectedColor:t,radius:U,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,onSeriesMouseOver:Q,highlightedDataPoints:j,minValue:N,maxValue:E,onSeriesMouseClick:I,prefix:w,suffix:$,stripType:B,highlightColor:Y,dotOpacity:R,resetSelectionOnDoubleClick:_,detailsOnClick:q,styles:g,classNames:h,valueColor:O,animate:S===!0?{duration:.5,once:!0,amount:.5}:S||{duration:0,once:!0,amount:0},noOfTicks:A,dimmedOpacity:ie,precision:oe,customLayers:re}):null})]})}),r||P?i.jsxRuntimeExports.jsx(je.GraphFooter,{styles:{footnote:g?.footnote,source:g?.source},classNames:{footnote:h?.footnote,source:h?.source},sources:r,footNote:P,width:s}):null]})})})})}function Se(L){const{data:o,graphTitle:x,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U,padding:k,backgroundColor:l,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v,highlightedDataPoints:j,graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,noOfTicks:V,graphDownload:m,dataDownload:w,prefix:$,suffix:B,stripType:M,language:Y,highlightColor:R,dotOpacity:T,showNAColor:y,minHeight:d,theme:H,ariaLabel:_,valueColor:q,resetSelectionOnDoubleClick:g,detailsOnClick:h,orientation:O="vertical",styles:S,classNames:A,animate:ie,dimmedOpacity:oe=.3,precision:re,customLayers:b}=L;return O==="vertical"?i.jsxRuntimeExports.jsx(Ne,{data:o,graphTitle:x,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U,padding:k,backgroundColor:l,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v,highlightedDataPoints:j,graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,noOfTicks:V,graphDownload:m,dataDownload:w,prefix:$,suffix:B,stripType:M,language:Y,highlightColor:R,dotOpacity:T,showNAColor:y,minHeight:d,theme:H,ariaLabel:_,resetSelectionOnDoubleClick:g,styles:S,valueColor:q,detailsOnClick:h,classNames:A,animate:ie,dimmedOpacity:oe,precision:re,customLayers:b}):i.jsxRuntimeExports.jsx(Me,{data:o,graphTitle:x,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U,padding:k,backgroundColor:l,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v,highlightedDataPoints:j,graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,noOfTicks:V,graphDownload:m,dataDownload:w,prefix:$,suffix:B,stripType:M,language:Y,highlightColor:R,dotOpacity:T,showNAColor:y,minHeight:d,theme:H,ariaLabel:_,resetSelectionOnDoubleClick:g,styles:S,valueColor:q,detailsOnClick:h,classNames:A,animate:ie,dimmedOpacity:oe,precision:re,customLayers:b})}exports.StripChart=Se;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),p=require("react"),de=require("./index-DQA8q5sC.cjs"),xe=require("./Modal-tXZlLE5s.cjs"),ge=require("./index-CQ3e6Ewi.cjs"),pe=require("./Tooltip-De16GWhY.cjs"),J=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),ce=require("./numberFormattingFunction-02t-wJta.cjs"),c=require("./Colors.cjs"),fe=require("./string2HTML-z7CwHXcx.cjs"),me=require("./linear-BVckp9RD.cjs"),ye=require("./use-in-view-sQJZ_xDO.cjs"),le=require("./proxy-BHRoeZgd.cjs"),ve=require("./index-BW8iNx7E.cjs"),je=require("./GraphFooter.cjs"),we=require("./GraphHeader.cjs"),Oe=require("./ColorLegendWithMouseOver.cjs"),Ce=require("./EmptyState-d8_8SxeW.cjs"),ue=require("./uniqBy-O05lp2S5.cjs");function be(L,o){if(L<2)return[];const d=o/(L-1);return Array.from({length:L},(f,r)=>r*d)}function Ee(L){const{data:o,width:d,height:f,colors:r,colorDomain:a,radius:u,leftMargin:s,rightMargin:P,topMargin:W,bottomMargin:ee,tooltip:U,onSeriesMouseOver:k,highlightedDataPoints:n,selectedColor:z,minValue:G,maxValue:X,onSeriesMouseClick:D,prefix:K,suffix:C,stripType:Q,highlightColor:v,dotOpacity:j,resetSelectionOnDoubleClick:te,detailsOnClick:N,styles:E,classNames:I,valueColor:V,animate:m,noOfTicks:w,dimmedOpacity:$,precision:B,customLayers:M}=L,Y=p.useRef(null),R=ye.useInView(Y,{once:m.once,amount:m.amount}),[T,y]=p.useState(void 0),[x,q]=p.useState(void 0),[_,H]=p.useState(void 0),[g,h]=p.useState(void 0),O={top:W,bottom:ee,left:s,right:P},S=d-O.left-O.right,A=f-O.top-O.bottom,ie=o.map((e,t)=>({...e,id:`${t}`})),oe=ge.orderBy(ie,[e=>{const t=(n||[]).indexOf(e.label);return t===-1?1/0:t}],["desc"]),re=J.checkIfNullOrUndefined(X)?Math.max(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position))<0?0:Math.max(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position)):X,b=J.checkIfNullOrUndefined(G)?Math.min(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position))>=0?0:Math.min(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position)):G,F=me.linear().domain([b,re]).range([0,S]).nice(),ne=be(w,S);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.svg,{width:`${d}px`,height:`${f}px`,viewBox:`0 0 ${d} ${f}`,direction:"ltr",ref:Y,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${O.left},${O.top})`,children:[M.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(ve.AnimatePresence,{children:[oe.map(e=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:0,x:F(0),y:A/2},whileInView:{x:F(e.position),y:A/2,opacity:z?e.color&&r[a.indexOf(e.color)]===z?.95:$:n.length!==0?n.indexOf(e.label)!==-1?.95:$:j,transition:{duration:m.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:m.duration}},onMouseEnter:t=>{y(e),h(t.clientY),H(t.clientX),k?.(e)},onClick:()=>{(D||N)&&(de.isEqual(x,e)&&te?(q(void 0),D?.(void 0)):(q(e),D?.(e)))},onMouseMove:t=>{y(e),h(t.clientY),H(t.clientX)},onMouseLeave:()=>{y(void 0),H(void 0),h(void 0),k?.(void 0)},children:[Q==="dot"?i.jsxRuntimeExports.jsx(le.motion.circle,{cy:0,cx:0,variants:{initial:{fill:v&&n?n.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray},whileInView:{fill:v&&n?n.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray,transition:{duration:m.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:m.duration}},r:u}):i.jsxRuntimeExports.jsx(le.motion.rect,{y:0-u,x:-1,height:u*2,width:2,variants:{initial:{fill:v&&n?n.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray},whileInView:{fill:v&&n?n.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray,transition:{duration:m.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:m.duration}}}),n.length!==0&&n.indexOf(e.label)!==-1?i.jsxRuntimeExports.jsx(le.motion.text,{x:0,y:0-u-5,variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:m.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:m.duration}},style:{fill:V||(v&&n?n.indexOf(e.label)!==-1?v:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray),textAnchor:"middle",...E?.graphObjectValues||{}},className:i.mo("graph-value text-sm font-bold",I?.graphObjectValues),children:ce.numberFormattingFunction(e.position,"NA",B,K,C)}):null]},e.label)),ne.map((e,t)=>i.jsxRuntimeExports.jsx("text",{x:e,y:A/2+u,style:{textAnchor:t===0?"start":t===ne.length-1?"end":"middle",...E?.xAxis?.labels||{}},className:i.mo("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",I?.xAxis?.labels),dy:"1em",children:ce.numberFormattingFunction(F.invert(e),"NA",B,K,C)},t))]}),M.filter(e=>e.position==="after").map(e=>e.layer)]})}),T&&U&&_&&g?i.jsxRuntimeExports.jsx(pe.Tooltip,{data:T,body:U,xPos:_,yPos:g,backgroundStyle:E?.tooltip,className:I?.tooltip}):null,N&&x!==void 0?i.jsxRuntimeExports.jsx(xe.X,{open:x!==void 0,onClose:()=>{q(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof N=="string"?{__html:fe.string2HTML(N,x)}:void 0,children:typeof N=="function"?N(x):null})}):null]})}function Me(L){const{data:o,graphTitle:d,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U=5,padding:k,backgroundColor:n=!1,leftMargin:z=5,rightMargin:G=5,topMargin:X=10,bottomMargin:D=10,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v=!0,highlightedDataPoints:j=[],graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,graphDownload:V=!1,dataDownload:m=!1,prefix:w="",suffix:$="",stripType:B="dot",language:M="en",highlightColor:Y,dotOpacity:R=.3,showNAColor:T=!0,minHeight:y=0,theme:x="light",ariaLabel:q,resetSelectionOnDoubleClick:_=!0,detailsOnClick:H,styles:g,classNames:h,valueColor:O,animate:S=!1,noOfTicks:A=2,dimmedOpacity:ie=.3,precision:oe=2,customLayers:re=[]}=L,[b,F]=p.useState(0),[ne,e]=p.useState(0),[t,he]=p.useState(void 0),Z=p.useRef(null),ae=p.useRef(null);return p.useEffect(()=>{const l=new ResizeObserver(se=>{F(s||se[0].target.clientWidth||620),e(u||se[0].target.clientHeight||480)});return Z.current&&(e(Z.current.clientHeight||480),F(Z.current.clientWidth||620),s||l.observe(Z.current)),()=>l.disconnect()},[s,u]),i.jsxRuntimeExports.jsx("div",{className:`${x||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${n?n===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,s?"w-fit":"w-full",h?.graphContainer),style:{...g?.graphContainer||{},...n&&n!==!0?{backgroundColor:n}:{}},id:te,ref:ae,"aria-label":q||`${d?`The graph shows ${d}. `:""}This is a strip chart showing distribution of data along the horizontal axis. Each dot represents an individual data point, helping to visualize the spread and clustering of values.${a?` ${a}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:n?k||"1rem":k||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[d||a||V||m?i.jsxRuntimeExports.jsx(we.GraphHeader,{styles:{title:g?.title,description:g?.description},classNames:{title:h?.title,description:h?.description},graphTitle:d,graphDescription:a,width:s,graphDownload:V?ae.current:void 0,dataDownload:m?o.map(l=>l.data).filter(l=>l!==void 0).length>0?o.map(l=>l.data).filter(l=>l!==void 0):o.filter(l=>l!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?i.jsxRuntimeExports.jsx(Ce.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[v!==!1&&o.filter(l=>l.color).length!==0?i.jsxRuntimeExports.jsx(Oe.ColorLegendWithMouseOver,{width:s,colorLegendTitle:ee,colors:f||c.Colors[x].categoricalColors.colors,colorDomain:W||ue.uniqBy(o,"color",!0),setSelectedColor:he,showNAColor:T??!0}):null,i.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:Z,"aria-label":"Graph area",children:(s||b)&&(u||ne)?i.jsxRuntimeExports.jsx(Ee,{data:o,width:s||b,height:Math.max(y,u||(C?y?(s||b)*C>y?(s||b)*C:y:(s||b)*C:ne)),colorDomain:o.filter(l=>l.color).length===0?[]:W||ue.uniqBy(o,"color",!0),colors:o.filter(l=>l.color).length===0?f?[f]:[c.Colors.primaryColors["blue-600"]]:f||c.Colors[x].categoricalColors.colors,selectedColor:t,radius:U,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,onSeriesMouseOver:Q,highlightedDataPoints:j,minValue:N,maxValue:E,onSeriesMouseClick:I,prefix:w,suffix:$,stripType:B,highlightColor:Y,dotOpacity:R,resetSelectionOnDoubleClick:_,detailsOnClick:H,styles:g,classNames:h,valueColor:O,animate:S===!0?{duration:.5,once:!0,amount:.5}:S||{duration:0,once:!0,amount:0},noOfTicks:A,dimmedOpacity:ie,precision:oe,customLayers:re}):null})]})}),r||P?i.jsxRuntimeExports.jsx(je.GraphFooter,{styles:{footnote:g?.footnote,source:g?.source},classNames:{footnote:h?.footnote,source:h?.source},sources:r,footNote:P,width:s}):null]})})})})}function Re(L){const{data:o,width:d,height:f,colors:r,colorDomain:a,radius:u,leftMargin:s,rightMargin:P,topMargin:W,bottomMargin:ee,tooltip:U,onSeriesMouseOver:k,highlightedDataPoints:n,selectedColor:z,minValue:G,maxValue:X,onSeriesMouseClick:D,noOfTicks:K,prefix:C,suffix:Q,stripType:v,highlightColor:j,dotOpacity:te,resetSelectionOnDoubleClick:N,detailsOnClick:E,styles:I,classNames:V,valueColor:m,animate:w,dimmedOpacity:$,precision:B,customLayers:M}=L,Y=p.useRef(null),R=ye.useInView(Y,{once:w.once,amount:w.amount}),[T,y]=p.useState(void 0),[x,q]=p.useState(void 0),[_,H]=p.useState(void 0),[g,h]=p.useState(void 0),O={top:W,bottom:ee,left:s,right:P},S=d-O.left-O.right,A=f-O.top-O.bottom,ie=o.map((e,t)=>({...e,id:`${t}`})),oe=ge.orderBy(ie,[e=>{const t=(n||[]).indexOf(e.label);return t===-1?1/0:t}],["desc"]),re=J.checkIfNullOrUndefined(X)?Math.max(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position))<0?0:Math.max(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position)):X,b=J.checkIfNullOrUndefined(G)?Math.min(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position))>=0?0:Math.min(...o.filter(e=>!J.checkIfNullOrUndefined(e.position)).map(e=>e.position)):G,F=me.linear().domain([b,re]).range([A,0]).nice(),ne=be(K,A);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(le.motion.svg,{width:`${d}px`,height:`${f}px`,viewBox:`0 0 ${d} ${f}`,direction:"ltr",ref:Y,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${O.left},${O.top})`,children:[M.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(ve.AnimatePresence,{children:[oe.map(e=>i.jsxRuntimeExports.jsxs(le.motion.g,{className:"undp-viz-g-with-hover",variants:{initial:{opacity:0,x:S/2,y:F(0)},whileInView:{x:S/2,y:F(e.position),opacity:z?e.color&&r[a.indexOf(e.color)]===z?.95:$:n.length!==0?n.indexOf(e.label)!==-1?.95:$:te,transition:{duration:w.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},onMouseEnter:t=>{y(e),h(t.clientY),H(t.clientX),k?.(e)},onClick:()=>{(D||E)&&(de.isEqual(x,e)&&N?(q(void 0),D?.(void 0)):(q(e),D?.(e)))},onMouseMove:t=>{y(e),h(t.clientY),H(t.clientX)},onMouseLeave:()=>{y(void 0),H(void 0),h(void 0),k?.(void 0)},children:[v==="dot"?i.jsxRuntimeExports.jsx(le.motion.circle,{cy:0,cx:0,variants:{initial:{fill:j&&n?n.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray},whileInView:{fill:j&&n?n.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray,transition:{duration:w.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},r:u}):i.jsxRuntimeExports.jsx(le.motion.rect,{x:0-u,y:-1,width:u*2,height:2,variants:{initial:{fill:j&&n?n.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray},whileInView:{fill:j&&n?n.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray,transition:{duration:w.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}}}),n.length!==0&&n.indexOf(e.label)!==-1?i.jsxRuntimeExports.jsx(le.motion.text,{y:0,dy:"0.33em",x:0+u+3,variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:w.duration}}},initial:"initial",animate:R?"whileInView":"initial",exit:{opacity:0,transition:{duration:w.duration}},style:{fill:m||(j&&n?n.indexOf(e.label)!==-1?j:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray:o.filter(t=>t.color).length===0?r[0]:e.color?r[a.indexOf(e.color)]:c.Colors.gray),textAnchor:"start",...I?.graphObjectValues||{}},className:i.mo("graph-value text-sm font-bold",V?.graphObjectValues),children:ce.numberFormattingFunction(e.position,"NA",B,C,Q)}):null]},e.label)),ne.map((e,t)=>i.jsxRuntimeExports.jsx("text",{y:e,x:S/2+u+5,style:{textAnchor:"start",...I?.yAxis?.labels||{}},className:i.mo("fill-primary-gray-550 dark:fill-primary-gray-500 text-xs",V?.yAxis?.labels),children:ce.numberFormattingFunction(F.invert(e),"NA",B,C,Q)},t))]}),M.filter(e=>e.position==="after").map(e=>e.layer)]})}),T&&U&&_&&g?i.jsxRuntimeExports.jsx(pe.Tooltip,{data:T,body:U,xPos:_,yPos:g,backgroundStyle:I?.tooltip,className:V?.tooltip}):null,E&&x!==void 0?i.jsxRuntimeExports.jsx(xe.X,{open:x!==void 0,onClose:()=>{q(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof E=="string"?{__html:fe.string2HTML(E,x)}:void 0,children:typeof E=="function"?E(x):null})}):null]})}function Ne(L){const{data:o,graphTitle:d,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U=5,padding:k,backgroundColor:n=!1,leftMargin:z=20,rightMargin:G=20,topMargin:X=10,bottomMargin:D=10,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v=!0,highlightedDataPoints:j=[],graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,graphDownload:V=!1,dataDownload:m=!1,prefix:w="",suffix:$="",stripType:B="dot",language:M="en",highlightColor:Y,dotOpacity:R=.3,showNAColor:T=!0,minHeight:y=0,theme:x="light",ariaLabel:q,resetSelectionOnDoubleClick:_=!0,detailsOnClick:H,styles:g,classNames:h,valueColor:O,animate:S=!1,noOfTicks:A=2,dimmedOpacity:ie=.3,precision:oe=2,customLayers:re=[]}=L,[b,F]=p.useState(0),[ne,e]=p.useState(0),[t,he]=p.useState(void 0),Z=p.useRef(null),ae=p.useRef(null);return p.useEffect(()=>{const l=new ResizeObserver(se=>{F(s||se[0].target.clientWidth||620),e(u||se[0].target.clientHeight||480)});return Z.current&&(e(Z.current.clientHeight||480),F(Z.current.clientWidth||620),s||l.observe(Z.current)),()=>l.disconnect()},[s,u]),i.jsxRuntimeExports.jsx("div",{className:`${x||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:M==="he"||M==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${n?n===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,s?"w-fit":"w-full",h?.graphContainer),style:{...g?.graphContainer||{},...n&&n!==!0?{backgroundColor:n}:{}},id:te,ref:ae,"aria-label":q||`${d?`The graph shows ${d}. `:""}This is a strip chart showing distribution of data along the vertical axis. Each dot represents an individual data point, helping to visualize the spread and clustering of values.${a?` ${a}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:n?k||"1rem":k||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[d||a||V||m?i.jsxRuntimeExports.jsx(we.GraphHeader,{styles:{title:g?.title,description:g?.description},classNames:{title:h?.title,description:h?.description},graphTitle:d,graphDescription:a,width:s,graphDownload:V?ae.current:void 0,dataDownload:m?o.map(l=>l.data).filter(l=>l!==void 0).length>0?o.map(l=>l.data).filter(l=>l!==void 0):o.filter(l=>l!==void 0):null}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:o.length===0?i.jsxRuntimeExports.jsx(Ce.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[v!==!1&&o.filter(l=>l.color).length!==0?i.jsxRuntimeExports.jsx(Oe.ColorLegendWithMouseOver,{width:s,colorLegendTitle:ee,colors:f||c.Colors[x].categoricalColors.colors,colorDomain:W||ue.uniqBy(o,"color",!0),setSelectedColor:he,showNAColor:T}):null,i.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:Z,children:(s||b)&&(u||ne)?i.jsxRuntimeExports.jsx(Re,{data:o,width:s||b,height:Math.max(y,u||(C?y?(s||b)*C>y?(s||b)*C:y:(s||b)*C:ne)),colorDomain:o.filter(l=>l.color).length===0?[]:W||ue.uniqBy(o,"color",!0),colors:o.filter(l=>l.color).length===0?f?[f]:[c.Colors.primaryColors["blue-600"]]:f||c.Colors[x].categoricalColors.colors,selectedColor:t,radius:U,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,onSeriesMouseOver:Q,highlightedDataPoints:j,minValue:N,maxValue:E,onSeriesMouseClick:I,prefix:w,suffix:$,stripType:B,highlightColor:Y,dotOpacity:R,resetSelectionOnDoubleClick:_,detailsOnClick:H,styles:g,classNames:h,valueColor:O,animate:S===!0?{duration:.5,once:!0,amount:.5}:S||{duration:0,once:!0,amount:0},noOfTicks:A,dimmedOpacity:ie,precision:oe,customLayers:re}):null})]})}),r||P?i.jsxRuntimeExports.jsx(je.GraphFooter,{styles:{footnote:g?.footnote,source:g?.source},classNames:{footnote:h?.footnote,source:h?.source},sources:r,footNote:P,width:s}):null]})})})})}function Se(L){const{data:o,graphTitle:d,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U,padding:k,backgroundColor:n,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v,highlightedDataPoints:j,graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,noOfTicks:V,graphDownload:m,dataDownload:w,prefix:$,suffix:B,stripType:M,language:Y,highlightColor:R,dotOpacity:T,showNAColor:y,minHeight:x,theme:q,ariaLabel:_,valueColor:H,resetSelectionOnDoubleClick:g,detailsOnClick:h,orientation:O="vertical",styles:S,classNames:A,animate:ie,dimmedOpacity:oe=.3,precision:re,customLayers:b}=L;return O==="vertical"?i.jsxRuntimeExports.jsx(Ne,{data:o,graphTitle:d,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U,padding:k,backgroundColor:n,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v,highlightedDataPoints:j,graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,noOfTicks:V,graphDownload:m,dataDownload:w,prefix:$,suffix:B,stripType:M,language:Y,highlightColor:R,dotOpacity:T,showNAColor:y,minHeight:x,theme:q,ariaLabel:_,resetSelectionOnDoubleClick:g,styles:S,valueColor:H,detailsOnClick:h,classNames:A,animate:ie,dimmedOpacity:oe,precision:re,customLayers:b}):i.jsxRuntimeExports.jsx(Me,{data:o,graphTitle:d,colors:f,sources:r,graphDescription:a,height:u,width:s,footNote:P,colorDomain:W,colorLegendTitle:ee,radius:U,padding:k,backgroundColor:n,leftMargin:z,rightMargin:G,topMargin:X,bottomMargin:D,tooltip:K,relativeHeight:C,onSeriesMouseOver:Q,showColorScale:v,highlightedDataPoints:j,graphID:te,minValue:N,maxValue:E,onSeriesMouseClick:I,noOfTicks:V,graphDownload:m,dataDownload:w,prefix:$,suffix:B,stripType:M,language:Y,highlightColor:R,dotOpacity:T,showNAColor:y,minHeight:x,theme:q,ariaLabel:_,resetSelectionOnDoubleClick:g,styles:S,valueColor:H,detailsOnClick:h,classNames:A,animate:ie,dimmedOpacity:oe,precision:re,customLayers:b})}exports.StripChart=Se;
|
|
2
2
|
//# sourceMappingURL=StripChart.cjs.map
|