@undp/data-viz 1.4.13 → 1.4.14
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 +25 -24
- package/dist/AreaChart.js.map +1 -1
- package/dist/BarGraph.cjs +1 -1
- package/dist/BarGraph.cjs.map +1 -1
- package/dist/BarGraph.js +638 -632
- package/dist/BarGraph.js.map +1 -1
- package/dist/BeeSwarmChart.cjs +1 -1
- package/dist/BeeSwarmChart.cjs.map +1 -1
- package/dist/BeeSwarmChart.js +134 -132
- package/dist/BeeSwarmChart.js.map +1 -1
- 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.cjs.map +1 -1
- package/dist/BulletChart.js +226 -224
- package/dist/BulletChart.js.map +1 -1
- package/dist/ButterflyChart.cjs +1 -1
- package/dist/ButterflyChart.cjs.map +1 -1
- package/dist/ButterflyChart.js +48 -47
- package/dist/ButterflyChart.js.map +1 -1
- package/dist/ChoroplethMap.cjs +1 -1
- package/dist/ChoroplethMap.cjs.map +1 -1
- package/dist/ChoroplethMap.js +56 -55
- package/dist/ChoroplethMap.js.map +1 -1
- package/dist/CirclePackingGraph.cjs +1 -1
- package/dist/CirclePackingGraph.js +1 -1
- package/dist/DataCards.cjs +3 -3
- package/dist/DataCards.cjs.map +1 -1
- package/dist/DataCards.js +2 -1
- package/dist/DataCards.js.map +1 -1
- package/dist/DataTable.cjs +1 -1
- package/dist/DataTable.cjs.map +1 -1
- package/dist/DataTable.js +9 -8
- package/dist/DataTable.js.map +1 -1
- package/dist/DifferenceLineChart.cjs +1 -1
- package/dist/DifferenceLineChart.cjs.map +1 -1
- package/dist/DifferenceLineChart.js +1 -0
- package/dist/DifferenceLineChart.js.map +1 -1
- package/dist/DonutChart.cjs +1 -1
- package/dist/DonutChart.cjs.map +1 -1
- package/dist/DonutChart.js +77 -76
- package/dist/DonutChart.js.map +1 -1
- package/dist/DotDensityMap.cjs +1 -1
- package/dist/DotDensityMap.cjs.map +1 -1
- package/dist/DotDensityMap.js +1 -0
- package/dist/DotDensityMap.js.map +1 -1
- package/dist/{DropdownSelect-CeHog_ih.js → DropdownSelect-CtOKZHD0.js} +22 -20
- package/dist/{DropdownSelect-CeHog_ih.js.map → DropdownSelect-CtOKZHD0.js.map} +1 -1
- package/dist/{DropdownSelect-BmE5JaeE.cjs → DropdownSelect-DBDM64B5.cjs} +2 -2
- package/dist/{DropdownSelect-BmE5JaeE.cjs.map → DropdownSelect-DBDM64B5.cjs.map} +1 -1
- package/dist/DualAxisLineChart.cjs +1 -1
- package/dist/DualAxisLineChart.cjs.map +1 -1
- package/dist/DualAxisLineChart.js +52 -51
- package/dist/DualAxisLineChart.js.map +1 -1
- package/dist/DumbbellChart.cjs +1 -1
- package/dist/DumbbellChart.cjs.map +1 -1
- package/dist/DumbbellChart.js +216 -214
- package/dist/DumbbellChart.js.map +1 -1
- package/dist/GeoHubCompareMaps.cjs +1 -1
- package/dist/GeoHubCompareMaps.cjs.map +1 -1
- package/dist/GeoHubCompareMaps.js +1 -0
- package/dist/GeoHubCompareMaps.js.map +1 -1
- package/dist/GeoHubMap.cjs +1 -1
- package/dist/GeoHubMap.cjs.map +1 -1
- package/dist/GeoHubMap.js +29 -28
- package/dist/GeoHubMap.js.map +1 -1
- package/dist/GeoHubMapWithLayerSelection.cjs +1 -1
- package/dist/GeoHubMapWithLayerSelection.cjs.map +1 -1
- package/dist/GeoHubMapWithLayerSelection.js +34 -33
- package/dist/GeoHubMapWithLayerSelection.js.map +1 -1
- package/dist/{GraphEl-B3xVlimz.js → GraphEl-N6vuMRw_.js} +2 -2
- package/dist/{GraphEl-B3xVlimz.js.map → GraphEl-N6vuMRw_.js.map} +1 -1
- package/dist/{GraphEl-DO-juRN8.cjs → GraphEl-Zl0W-LK9.cjs} +2 -2
- package/dist/{GraphEl-DO-juRN8.cjs.map → GraphEl-Zl0W-LK9.cjs.map} +1 -1
- package/dist/GriddedGraphs.cjs +1 -1
- package/dist/GriddedGraphs.js +2 -2
- package/dist/HeatMap.cjs +1 -1
- package/dist/HeatMap.cjs.map +1 -1
- package/dist/HeatMap.js +55 -54
- 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 +22 -21
- package/dist/LineChartWithConfidenceInterval.js.map +1 -1
- package/dist/MultiGraphDashboard.cjs +1 -1
- package/dist/MultiGraphDashboard.js +1 -1
- package/dist/MultiGraphDashboardWideToLongFormat.cjs +1 -1
- package/dist/MultiGraphDashboardWideToLongFormat.js +1 -1
- package/dist/MultiLineAltChart.cjs +1 -1
- package/dist/MultiLineAltChart.cjs.map +1 -1
- package/dist/MultiLineAltChart.js +34 -33
- package/dist/MultiLineAltChart.js.map +1 -1
- package/dist/MultiLineChart.cjs +1 -1
- package/dist/MultiLineChart.cjs.map +1 -1
- package/dist/MultiLineChart.js +72 -71
- package/dist/MultiLineChart.js.map +1 -1
- package/dist/ParetoChart.cjs +1 -1
- package/dist/ParetoChart.cjs.map +1 -1
- package/dist/ParetoChart.js +22 -21
- package/dist/ParetoChart.js.map +1 -1
- package/dist/PerformanceIntensiveMultiGraphDashboard.cjs +1 -1
- package/dist/PerformanceIntensiveMultiGraphDashboard.js +1 -1
- package/dist/RadarChart.cjs +1 -1
- package/dist/RadarChart.cjs.map +1 -1
- package/dist/RadarChart.js +27 -26
- package/dist/RadarChart.js.map +1 -1
- package/dist/SankeyChart.cjs +1 -1
- package/dist/SankeyChart.cjs.map +1 -1
- package/dist/SankeyChart.js +30 -29
- package/dist/SankeyChart.js.map +1 -1
- package/dist/ScatterPlot.cjs +1 -1
- package/dist/ScatterPlot.cjs.map +1 -1
- package/dist/ScatterPlot.js +119 -118
- package/dist/ScatterPlot.js.map +1 -1
- package/dist/SimpleLineChart.cjs +1 -1
- package/dist/SimpleLineChart.cjs.map +1 -1
- package/dist/SimpleLineChart.js +16 -15
- package/dist/SimpleLineChart.js.map +1 -1
- package/dist/SingleGraphDashboard.cjs +1 -1
- package/dist/SingleGraphDashboard.js +2 -2
- package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
- package/dist/SingleGraphDashboardThreeDGraphs.js +1 -1
- package/dist/SlopeChart.cjs +1 -1
- package/dist/SlopeChart.cjs.map +1 -1
- package/dist/SlopeChart.js +46 -45
- package/dist/SlopeChart.js.map +1 -1
- package/dist/SparkLine.cjs +1 -1
- package/dist/SparkLine.cjs.map +1 -1
- package/dist/SparkLine.js +12 -11
- package/dist/SparkLine.js.map +1 -1
- package/dist/StripChart.cjs +1 -1
- package/dist/StripChart.cjs.map +1 -1
- package/dist/StripChart.js +81 -79
- package/dist/StripChart.js.map +1 -1
- package/dist/ThreeDGlobe.cjs +1 -1
- package/dist/ThreeDGlobe.cjs.map +1 -1
- package/dist/ThreeDGlobe.js +1 -0
- package/dist/ThreeDGlobe.js.map +1 -1
- package/dist/TreeMapGraph.cjs +1 -1
- package/dist/TreeMapGraph.cjs.map +1 -1
- package/dist/TreeMapGraph.js +114 -113
- package/dist/TreeMapGraph.js.map +1 -1
- package/dist/UnitChart.cjs +1 -1
- package/dist/UnitChart.cjs.map +1 -1
- package/dist/UnitChart.js +10 -9
- package/dist/UnitChart.js.map +1 -1
- package/dist/{index-CZLvTu6p.cjs → index-BbNoLJ_w.cjs} +2 -2
- package/dist/{index-CZLvTu6p.cjs.map → index-BbNoLJ_w.cjs.map} +1 -1
- package/dist/{index-DGAaLNu9.js → index-Bc5VF70V.js} +46 -45
- package/dist/{index-DGAaLNu9.js.map → index-Bc5VF70V.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleLineChart.js","sources":["../src/Components/Graphs/LineCharts/LineChart/Graph.tsx","../src/Components/Graphs/LineCharts/LineChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveMonotoneX,\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 { linearRegression, linearRegressionLine } from 'simple-statistics';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { motion, useInView } from 'motion/react';\r\n\r\nimport {\r\n AnimateDataType,\r\n AnnotationSettingsDataType,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomHighlightAreaSettingsDataType,\r\n CustomLayerDataType,\r\n HighlightAreaSettingsDataType,\r\n LineChartDataType,\r\n ReferenceDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { getLineEndPoint } from '@/Utils/getLineEndPoint';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { RefLineY } from '@/Components/Elements/ReferenceLine';\r\nimport { RegressionLine } from '@/Components/Elements/RegressionLine';\r\nimport { Annotation } from '@/Components/Elements/Annotations';\r\nimport { YTicksAndGridLines } from '@/Components/Elements/Axes/YTicksAndGridLines';\r\nimport { HighlightArea } from '@/Components/Elements/HighlightArea';\r\nimport { CustomArea } from '@/Components/Elements/HighlightArea/customArea';\r\n\r\ninterface Props {\r\n data: LineChartDataType[];\r\n lineColor: string;\r\n width: number;\r\n height: number;\r\n suffix: string;\r\n prefix: string;\r\n dateFormat: string;\r\n showValues: boolean;\r\n noOfXTicks: number;\r\n rightMargin: number;\r\n leftMargin: 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 refValues: ReferenceDataType[];\r\n highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n animate: AnimateDataType;\r\n rtl: boolean;\r\n strokeWidth: number;\r\n showDots: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n regressionLine: boolean | string;\r\n yAxisTitle?: string;\r\n noOfYTicks: number;\r\n minDate?: string | number;\r\n maxDate?: string | number;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\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 suffix,\r\n prefix,\r\n dateFormat,\r\n highlightAreaSettings,\r\n showValues,\r\n noOfXTicks,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n refValues,\r\n minValue,\r\n maxValue,\r\n animate,\r\n rtl,\r\n strokeWidth,\r\n showDots,\r\n annotations,\r\n customHighlightAreaSettings,\r\n regressionLine,\r\n yAxisTitle,\r\n noOfYTicks,\r\n maxDate,\r\n minDate,\r\n curveType,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const [hasAnimatedOnce, setHasAnimatedOnce] = useState(false);\r\n\r\n useEffect(() => {\r\n if (isInView && !hasAnimatedOnce) {\r\n const timeout = setTimeout(\r\n () => {\r\n setHasAnimatedOnce(true);\r\n },\r\n (animate.duration + 0.5) * 1000,\r\n );\r\n return () => clearTimeout(timeout);\r\n }\r\n }, [isInView, hasAnimatedOnce, animate.duration]);\r\n const curve =\r\n curveType === 'linear'\r\n ? curveLinear\r\n : curveType === 'step'\r\n ? curveStep\r\n : curveType === 'stepAfter'\r\n ? curveStepAfter\r\n : curveType === 'stepBefore'\r\n ? curveStepBefore\r\n : curveMonotoneX;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: yAxisTitle ? leftMargin + 30 : leftMargin,\r\n right: rightMargin,\r\n };\r\n const MouseoverRectRef = useRef(null);\r\n const 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 highlightAreaSettingsFormatted = highlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: [\r\n d.coordinates[0] === null ? null : parse(`${d.coordinates[0]}`, dateFormat, new Date()),\r\n d.coordinates[1] === null ? null : parse(`${d.coordinates[1]}`, dateFormat, new Date()),\r\n ],\r\n }));\r\n const customHighlightAreaSettingsFormatted = customHighlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: d.coordinates.map((el, j) =>\r\n j % 2 === 0 ? parse(`${el}`, dateFormat, new Date()) : (el as number),\r\n ),\r\n }));\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minYear = minDate ? parse(`${minDate}`, dateFormat, new Date()) : dataFormatted[0].date;\r\n const maxYear = maxDate\r\n ? parse(`${maxDate}`, dateFormat, new Date())\r\n : dataFormatted[dataFormatted.length - 1].date;\r\n const minParam: number = !checkIfNullOrUndefined(minValue)\r\n ? (minValue as number)\r\n : Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !==\r\n 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 const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n minParam,\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 lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n const yTicks = y.ticks(noOfYTicks);\r\n const xTicks = x.ticks(noOfXTicks);\r\n useEffect(() => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const mousemove = (event: any) => {\r\n const selectedData =\r\n dataFormatted[\r\n bisectCenter(\r\n dataFormatted.map(d => d.date),\r\n x.invert(pointer(event)[0]),\r\n 0,\r\n )\r\n ];\r\n setMouseOverData(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n 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 setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n const regressionLineParam = linearRegression(\r\n dataFormatted\r\n .filter(d => !checkIfNullOrUndefined(d.date) && !checkIfNullOrUndefined(d.y))\r\n .map(d => [x(d.date), y(d.y as number)]),\r\n );\r\n const predict = linearRegressionLine(regressionLineParam);\r\n return (\r\n <>\r\n <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n <HighlightArea\r\n areaSettings={highlightAreaSettingsFormatted}\r\n width={graphWidth}\r\n height={graphHeight}\r\n scale={x}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n <CustomArea\r\n areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n <g>\r\n <YTicksAndGridLines\r\n values={yTicks.filter(d => d !== 0)}\r\n y={yTicks.filter(d => d !== 0).map(d => y(d))}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n styles={{\r\n gridLines: styles?.yAxis?.gridLines,\r\n labels: styles?.yAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.yAxis?.gridLines,\r\n labels: classNames?.yAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n labelPos='vertical'\r\n precision={precision}\r\n />\r\n <Axis\r\n y1={y(minParam < 0 ? 0 : minParam)}\r\n y2={y(minParam < 0 ? 0 : minParam)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n label={numberFormattingFunction(\r\n minParam < 0 ? 0 : minParam,\r\n 'NA',\r\n precision,\r\n prefix,\r\n suffix,\r\n )}\r\n labelPos={{\r\n x: 0 - leftMargin,\r\n y: y(minParam < 0 ? 0 : minParam),\r\n dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\r\n }}\r\n classNames={{\r\n axis: classNames?.xAxis?.axis,\r\n label: classNames?.yAxis?.labels,\r\n }}\r\n styles={{\r\n axis: styles?.xAxis?.axis,\r\n label: styles?.yAxis?.labels,\r\n }}\r\n />\r\n <AxisTitle\r\n x={0 - leftMargin - 15}\r\n y={graphHeight / 2}\r\n style={styles?.yAxis?.title}\r\n className={classNames?.yAxis?.title}\r\n text={yAxisTitle}\r\n rotate90\r\n />\r\n </g>\r\n <XTicksAndGridLines\r\n values={xTicks.map(d => format(d, dateFormat))}\r\n x={xTicks.map(d => x(d))}\r\n y1={0}\r\n y2={graphHeight}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: cn('opacity-0', classNames?.xAxis?.gridLines),\r\n labels: cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n ),\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='primary'\r\n showGridLines\r\n precision={precision}\r\n />\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g>\r\n <motion.path\r\n style={{\r\n stroke: lineColor,\r\n fill: 'none',\r\n strokeWidth,\r\n }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n d: lineShape(dataFormatted) || '',\r\n opacity: 1,\r\n },\r\n whileInView: {\r\n pathLength: 1,\r\n d: lineShape(dataFormatted) || '',\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n {mouseOverData ? (\r\n <line\r\n y1={0}\r\n y2={graphHeight}\r\n x1={x(mouseOverData.date)}\r\n x2={x(mouseOverData.date)}\r\n className={cn(\r\n 'undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100',\r\n classNames?.mouseOverLine,\r\n )}\r\n style={styles?.mouseOverLine}\r\n />\r\n ) : null}\r\n </g>\r\n <g>\r\n {dataFormatted.map((d, i) => (\r\n <motion.g key={i}>\r\n {!checkIfNullOrUndefined(d.y) ? (\r\n <>\r\n {showDots ? (\r\n <motion.circle\r\n r={\r\n graphWidth / dataFormatted.length < 5\r\n ? 0\r\n : graphWidth / dataFormatted.length < 20\r\n ? 2\r\n : 4\r\n }\r\n style={{ fill: lineColor }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: { opacity: 0, cx: x(d.date), cy: y(d.y as number) },\r\n whileInView: {\r\n opacity: 1,\r\n transition: {\r\n duration: hasAnimatedOnce ? animate.duration : 0.5,\r\n delay: hasAnimatedOnce ? 0 : animate.duration,\r\n },\r\n cx: x(d.date),\r\n cy: y(d.y as number),\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n ) : null}\r\n {showValues ? (\r\n <motion.text\r\n dy={-8}\r\n style={{\r\n textAnchor: 'middle',\r\n ...(styles?.graphObjectValues || {}),\r\n }}\r\n className={cn(\r\n 'graph-value text-xs font-bold',\r\n classNames?.graphObjectValues,\r\n )}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: { opacity: 0, x: x(d.date), y: y(d.y) },\r\n whileInView: {\r\n opacity: 1,\r\n x: x(d.date),\r\n y: y(d.y),\r\n transition: {\r\n duration: hasAnimatedOnce ? animate.duration : 0.5,\r\n delay: hasAnimatedOnce ? 0 : animate.duration,\r\n },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n >\r\n {numberFormattingFunction(d.y, 'NA', precision, prefix, suffix)}\r\n </motion.text>\r\n ) : null}\r\n </>\r\n ) : null}\r\n </motion.g>\r\n ))}\r\n </g>\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineY\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n y={y(el.value as number)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n classNames={el.classNames}\r\n styles={el.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n ))}\r\n </>\r\n ) : null}\r\n <g>\r\n {annotations.map((d, i) => {\r\n const endPoints = getLineEndPoint(\r\n {\r\n x: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n },\r\n {\r\n x: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n y: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n },\r\n checkIfNullOrUndefined(d.connectorRadius) ? 3.5 : (d.connectorRadius as number),\r\n );\r\n const connectorSettings = d.showConnector\r\n ? {\r\n y1: endPoints.y,\r\n x1: endPoints.x,\r\n y2: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0)\r\n : 0 + (d.yOffset || 0),\r\n x2: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n cy: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n circleRadius: checkIfNullOrUndefined(d.connectorRadius)\r\n ? 3.5\r\n : (d.connectorRadius as number),\r\n strokeWidth: d.showConnector === true ? 2 : Math.min(d.showConnector || 0, 1),\r\n }\r\n : undefined;\r\n const labelSettings = {\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n x: rtl\r\n ? 0\r\n : d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n width: rtl\r\n ? d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)\r\n : graphWidth +\r\n margin.right -\r\n (d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)),\r\n maxWidth: d.maxWidth,\r\n fontWeight: d.fontWeight,\r\n align: d.align,\r\n };\r\n return (\r\n <Annotation\r\n key={i}\r\n color={d.color}\r\n connectorsSettings={connectorSettings}\r\n labelSettings={labelSettings}\r\n text={d.text}\r\n classNames={d.classNames}\r\n styles={d.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n );\r\n })}\r\n </g>\r\n <g>\r\n {regressionLine ? (\r\n <RegressionLine\r\n x1={0}\r\n x2={graphWidth}\r\n y1={predict(0)}\r\n y2={predict(graphWidth)}\r\n graphHeight={graphHeight}\r\n graphWidth={graphWidth}\r\n className={classNames?.regLine}\r\n style={styles?.regLine}\r\n color={typeof regressionLine === 'string' ? regressionLine : undefined}\r\n animate={animate}\r\n isInView={isInView}\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 </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n AnnotationSettingsDataType,\r\n CustomHighlightAreaSettingsDataType,\r\n Languages,\r\n LineChartDataType,\r\n ReferenceDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n HighlightAreaSettingsDataType,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\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 /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n /** Reference values for comparison */\r\n refValues?: ReferenceDataType[];\r\n /** Maximum value of the date for the chart */\r\n maxDate?: string | number;\r\n /** Minimum value of the date for the chart */\r\n minDate?: string | number;\r\n /** No. of ticks on the x-axis */\r\n noOfXTicks?: number;\r\n /** No. of ticks on the y-axis */\r\n noOfYTicks?: number;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of values */\r\n showValues?: boolean;\r\n /** Toggle visibility of dots on the line */\r\n showDots?: boolean;\r\n /** Stroke width of the line */\r\n strokeWidth?: number;\r\n /** Toggle the initial animation of the line. If the type is number then it uses the number as the time in seconds for animation. */\r\n animate?: boolean | AnimateDataType;\r\n /** Format of the date in the data object. Available formats can be found [here](https://date-fns.org/docs/format) */\r\n dateFormat?: string;\r\n /** Title for the Y-axis */\r\n yAxisTitle?: string;\r\n /** Annotations on the chart */\r\n annotations?: AnnotationSettingsDataType[];\r\n /** Highlighted area(square) on the chart */\r\n highlightAreaSettings?: HighlightAreaSettingsDataType[];\r\n /** Highlighted area(custom shape) on the chart */\r\n customHighlightAreaSettings?: CustomHighlightAreaSettingsDataType[];\r\n /** Toggles the visibility of the regression line for the data. If the type is string then string is use to define the color of the line. */\r\n regressionLine?: boolean | string;\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function SimpleLineChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n lineColor,\r\n suffix = '',\r\n sources,\r\n prefix = '',\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n showValues = false,\r\n padding,\r\n backgroundColor = false,\r\n leftMargin = 30,\r\n rightMargin = 30,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n relativeHeight,\r\n tooltip,\r\n onSeriesMouseOver,\r\n highlightAreaSettings = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n maxDate,\r\n minDate,\r\n graphDownload = false,\r\n dataDownload = false,\r\n animate = false,\r\n language = 'en',\r\n refValues = [],\r\n minHeight = 0,\r\n strokeWidth = 2,\r\n showDots = true,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n regressionLine = false,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n precision = 2,\r\n customLayers = [],\r\n } = props;\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 return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a line chart that shows trends over time.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n {data.length === 0 ? (\r\n <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n <EmptyState />\r\n </div>\r\n ) : (\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 suffix={suffix}\r\n prefix={prefix}\r\n dateFormat={dateFormat}\r\n showValues={showValues}\r\n noOfXTicks={noOfXTicks}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n highlightAreaSettings={highlightAreaSettings}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n animate={\r\n animate === true\r\n ? { duration: 0.5, once: true, amount: 0.5 }\r\n : animate || { duration: 0, once: true, amount: 0 }\r\n }\r\n rtl={language === 'he' || language === 'ar'}\r\n strokeWidth={strokeWidth}\r\n showDots={showDots}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n regressionLine={regressionLine}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n maxDate={maxDate}\r\n minDate={minDate}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n precision={precision}\r\n customLayers={customLayers}\r\n />\r\n ) : null}\r\n </div>\r\n )}\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","suffix","prefix","dateFormat","highlightAreaSettings","showValues","noOfXTicks","rightMargin","leftMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","refValues","minValue","maxValue","animate","rtl","strokeWidth","showDots","annotations","customHighlightAreaSettings","regressionLine","yAxisTitle","noOfYTicks","maxDate","minDate","curveType","styles","classNames","precision","customLayers","svgRef","useRef","isInView","useInView","hasAnimatedOnce","setHasAnimatedOnce","useState","useEffect","timeout","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","dataFormatted","sortBy","d","parse","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","el","j","graphWidth","graphHeight","minYear","maxYear","minParam","checkIfNullOrUndefined","maxParam","x","scaleTime","y","scaleLinear","lineShape","line","yTicks","xTicks","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","regressionLineParam","linearRegression","predict","linearRegressionLine","jsxs","Fragment","jsx","motion","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","i","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","RegressionLine","Tooltip","SimpleLineChart","graphTitle","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","Colors","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FO,SAASA,GAAMC,IAAc;AAClC,QAAM;AAAA,IACJ,MAA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AAU,GAAG,MAAM,IAAM,QAAQ,EAAA;AAAA,wBAEpD,KAAK0G,MAAa,QAAQA,MAAa;AAAA,wBACvC,aAAAxG;AAAA,wBACA,UAAAC;AAAA,wBACA,aAAAC;AAAA,wBACA,6BAAAC;AAAA,wBACA,gBAAAC;AAAA,wBACA,YAAAC;AAAA,wBACA,YAAAC;AAAA,wBACA,SAAAC;AAAA,wBACA,SAAAC;AAAA,wBACA,WAAAC;AAAA,wBACA,QAAAC;AAAA,wBACA,YAAAC;AAAA,wBACA,WAAAC;AAAA,wBACA,cAAAC;AAAA,sBAAA;AAAA,oBAAA,IAEA;AAAA,kBAAA;AAAA,gBAAA;AAAA,gBAGPkF,KAAWE,IACVxB,gBAAAA,EAAAA;AAAAA,kBAAC8C;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAU7G,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAAoF;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAArH;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":"SimpleLineChart.js","sources":["../src/Components/Graphs/LineCharts/LineChart/Graph.tsx","../src/Components/Graphs/LineCharts/LineChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveMonotoneX,\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 { linearRegression, linearRegressionLine } from 'simple-statistics';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { motion, useInView } from 'motion/react';\r\n\r\nimport {\r\n AnimateDataType,\r\n AnnotationSettingsDataType,\r\n ClassNameObject,\r\n CurveTypes,\r\n CustomHighlightAreaSettingsDataType,\r\n CustomLayerDataType,\r\n HighlightAreaSettingsDataType,\r\n LineChartDataType,\r\n ReferenceDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\nimport { Tooltip } from '@/Components/Elements/Tooltip';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { getLineEndPoint } from '@/Utils/getLineEndPoint';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { RefLineY } from '@/Components/Elements/ReferenceLine';\r\nimport { RegressionLine } from '@/Components/Elements/RegressionLine';\r\nimport { Annotation } from '@/Components/Elements/Annotations';\r\nimport { YTicksAndGridLines } from '@/Components/Elements/Axes/YTicksAndGridLines';\r\nimport { HighlightArea } from '@/Components/Elements/HighlightArea';\r\nimport { CustomArea } from '@/Components/Elements/HighlightArea/customArea';\r\n\r\ninterface Props {\r\n data: LineChartDataType[];\r\n lineColor: string;\r\n width: number;\r\n height: number;\r\n suffix: string;\r\n prefix: string;\r\n dateFormat: string;\r\n showValues: boolean;\r\n noOfXTicks: number;\r\n rightMargin: number;\r\n leftMargin: 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 refValues: ReferenceDataType[];\r\n highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n animate: AnimateDataType;\r\n rtl: boolean;\r\n strokeWidth: number;\r\n showDots: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n regressionLine: boolean | string;\r\n yAxisTitle?: string;\r\n noOfYTicks: number;\r\n minDate?: string | number;\r\n maxDate?: string | number;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\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 suffix,\r\n prefix,\r\n dateFormat,\r\n highlightAreaSettings,\r\n showValues,\r\n noOfXTicks,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n refValues,\r\n minValue,\r\n maxValue,\r\n animate,\r\n rtl,\r\n strokeWidth,\r\n showDots,\r\n annotations,\r\n customHighlightAreaSettings,\r\n regressionLine,\r\n yAxisTitle,\r\n noOfYTicks,\r\n maxDate,\r\n minDate,\r\n curveType,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n const [hasAnimatedOnce, setHasAnimatedOnce] = useState(false);\r\n\r\n useEffect(() => {\r\n if (isInView && !hasAnimatedOnce) {\r\n const timeout = setTimeout(\r\n () => {\r\n setHasAnimatedOnce(true);\r\n },\r\n (animate.duration + 0.5) * 1000,\r\n );\r\n return () => clearTimeout(timeout);\r\n }\r\n }, [isInView, hasAnimatedOnce, animate.duration]);\r\n const curve =\r\n curveType === 'linear'\r\n ? curveLinear\r\n : curveType === 'step'\r\n ? curveStep\r\n : curveType === 'stepAfter'\r\n ? curveStepAfter\r\n : curveType === 'stepBefore'\r\n ? curveStepBefore\r\n : curveMonotoneX;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: yAxisTitle ? leftMargin + 30 : leftMargin,\r\n right: rightMargin,\r\n };\r\n const MouseoverRectRef = useRef(null);\r\n const 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 highlightAreaSettingsFormatted = highlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: [\r\n d.coordinates[0] === null ? null : parse(`${d.coordinates[0]}`, dateFormat, new Date()),\r\n d.coordinates[1] === null ? null : parse(`${d.coordinates[1]}`, dateFormat, new Date()),\r\n ],\r\n }));\r\n const customHighlightAreaSettingsFormatted = customHighlightAreaSettings.map(d => ({\r\n ...d,\r\n coordinates: d.coordinates.map((el, j) =>\r\n j % 2 === 0 ? parse(`${el}`, dateFormat, new Date()) : (el as number),\r\n ),\r\n }));\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n const minYear = minDate ? parse(`${minDate}`, dateFormat, new Date()) : dataFormatted[0].date;\r\n const maxYear = maxDate\r\n ? parse(`${maxDate}`, dateFormat, new Date())\r\n : dataFormatted[dataFormatted.length - 1].date;\r\n const minParam: number = !checkIfNullOrUndefined(minValue)\r\n ? (minValue as number)\r\n : Math.min(...dataFormatted.map(d => d.y).filter(d => d !== undefined && d !== null)) !==\r\n 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 const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n minParam,\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 lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n const yTicks = y.ticks(noOfYTicks);\r\n const xTicks = x.ticks(noOfXTicks);\r\n useEffect(() => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const mousemove = (event: any) => {\r\n const selectedData =\r\n dataFormatted[\r\n bisectCenter(\r\n dataFormatted.map(d => d.date),\r\n x.invert(pointer(event)[0]),\r\n 0,\r\n )\r\n ];\r\n setMouseOverData(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n 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 setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n const regressionLineParam = linearRegression(\r\n dataFormatted\r\n .filter(d => !checkIfNullOrUndefined(d.date) && !checkIfNullOrUndefined(d.y))\r\n .map(d => [x(d.date), y(d.y as number)]),\r\n );\r\n const predict = linearRegressionLine(regressionLineParam);\r\n return (\r\n <>\r\n <motion.svg\r\n width={`${width}px`}\r\n height={`${height}px`}\r\n viewBox={`0 0 ${width} ${height}`}\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n <HighlightArea\r\n areaSettings={highlightAreaSettingsFormatted}\r\n width={graphWidth}\r\n height={graphHeight}\r\n scale={x}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n <CustomArea\r\n areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n <g>\r\n <YTicksAndGridLines\r\n values={yTicks.filter(d => d !== 0)}\r\n y={yTicks.filter(d => d !== 0).map(d => y(d))}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n styles={{\r\n gridLines: styles?.yAxis?.gridLines,\r\n labels: styles?.yAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.yAxis?.gridLines,\r\n labels: classNames?.yAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n labelPos='vertical'\r\n precision={precision}\r\n />\r\n <Axis\r\n y1={y(minParam < 0 ? 0 : minParam)}\r\n y2={y(minParam < 0 ? 0 : minParam)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n label={numberFormattingFunction(\r\n minParam < 0 ? 0 : minParam,\r\n 'NA',\r\n precision,\r\n prefix,\r\n suffix,\r\n )}\r\n labelPos={{\r\n x: 0 - leftMargin,\r\n y: y(minParam < 0 ? 0 : minParam),\r\n dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\r\n }}\r\n classNames={{\r\n axis: classNames?.xAxis?.axis,\r\n label: classNames?.yAxis?.labels,\r\n }}\r\n styles={{\r\n axis: styles?.xAxis?.axis,\r\n label: styles?.yAxis?.labels,\r\n }}\r\n />\r\n <AxisTitle\r\n x={0 - leftMargin - 15}\r\n y={graphHeight / 2}\r\n style={styles?.yAxis?.title}\r\n className={classNames?.yAxis?.title}\r\n text={yAxisTitle}\r\n rotate90\r\n />\r\n </g>\r\n <XTicksAndGridLines\r\n values={xTicks.map(d => format(d, dateFormat))}\r\n x={xTicks.map(d => x(d))}\r\n y1={0}\r\n y2={graphHeight}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: cn('opacity-0', classNames?.xAxis?.gridLines),\r\n labels: cn(\r\n 'fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs',\r\n classNames?.xAxis?.labels,\r\n ),\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='primary'\r\n showGridLines\r\n precision={precision}\r\n />\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g>\r\n <motion.path\r\n style={{\r\n stroke: lineColor,\r\n fill: 'none',\r\n strokeWidth,\r\n }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n d: lineShape(dataFormatted) || '',\r\n opacity: 1,\r\n },\r\n whileInView: {\r\n pathLength: 1,\r\n d: lineShape(dataFormatted) || '',\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n {mouseOverData ? (\r\n <line\r\n y1={0}\r\n y2={graphHeight}\r\n x1={x(mouseOverData.date)}\r\n x2={x(mouseOverData.date)}\r\n className={cn(\r\n 'undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100',\r\n classNames?.mouseOverLine,\r\n )}\r\n style={styles?.mouseOverLine}\r\n />\r\n ) : null}\r\n </g>\r\n <g>\r\n {dataFormatted.map((d, i) => (\r\n <motion.g key={i}>\r\n {!checkIfNullOrUndefined(d.y) ? (\r\n <>\r\n {showDots ? (\r\n <motion.circle\r\n r={\r\n graphWidth / dataFormatted.length < 5\r\n ? 0\r\n : graphWidth / dataFormatted.length < 20\r\n ? 2\r\n : 4\r\n }\r\n style={{ fill: lineColor }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: { opacity: 0, cx: x(d.date), cy: y(d.y as number) },\r\n whileInView: {\r\n opacity: 1,\r\n transition: {\r\n duration: hasAnimatedOnce ? animate.duration : 0.5,\r\n delay: hasAnimatedOnce ? 0 : animate.duration,\r\n },\r\n cx: x(d.date),\r\n cy: y(d.y as number),\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n ) : null}\r\n {showValues ? (\r\n <motion.text\r\n dy={-8}\r\n style={{\r\n textAnchor: 'middle',\r\n ...(styles?.graphObjectValues || {}),\r\n }}\r\n className={cn(\r\n 'graph-value text-xs font-bold',\r\n classNames?.graphObjectValues,\r\n )}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: { opacity: 0, x: x(d.date), y: y(d.y) },\r\n whileInView: {\r\n opacity: 1,\r\n x: x(d.date),\r\n y: y(d.y),\r\n transition: {\r\n duration: hasAnimatedOnce ? animate.duration : 0.5,\r\n delay: hasAnimatedOnce ? 0 : animate.duration,\r\n },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n >\r\n {numberFormattingFunction(d.y, 'NA', precision, prefix, suffix)}\r\n </motion.text>\r\n ) : null}\r\n </>\r\n ) : null}\r\n </motion.g>\r\n ))}\r\n </g>\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineY\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n y={y(el.value as number)}\r\n x1={0 - leftMargin}\r\n x2={graphWidth + margin.right}\r\n classNames={el.classNames}\r\n styles={el.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n ))}\r\n </>\r\n ) : null}\r\n <g>\r\n {annotations.map((d, i) => {\r\n const endPoints = getLineEndPoint(\r\n {\r\n x: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n },\r\n {\r\n x: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n y: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n },\r\n checkIfNullOrUndefined(d.connectorRadius) ? 3.5 : (d.connectorRadius as number),\r\n );\r\n const connectorSettings = d.showConnector\r\n ? {\r\n y1: endPoints.y,\r\n x1: endPoints.x,\r\n y2: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0)\r\n : 0 + (d.yOffset || 0),\r\n x2: d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n cy: d.yCoordinate ? y(d.yCoordinate as number) : 0,\r\n cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n circleRadius: checkIfNullOrUndefined(d.connectorRadius)\r\n ? 3.5\r\n : (d.connectorRadius as number),\r\n strokeWidth: d.showConnector === true ? 2 : Math.min(d.showConnector || 0, 1),\r\n }\r\n : undefined;\r\n const labelSettings = {\r\n y: d.yCoordinate\r\n ? y(d.yCoordinate as number) + (d.yOffset || 0) - 8\r\n : 0 + (d.yOffset || 0) - 8,\r\n x: rtl\r\n ? 0\r\n : d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0),\r\n width: rtl\r\n ? d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)\r\n : graphWidth +\r\n margin.right -\r\n (d.xCoordinate\r\n ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) + (d.xOffset || 0)\r\n : 0 + (d.xOffset || 0)),\r\n maxWidth: d.maxWidth,\r\n fontWeight: d.fontWeight,\r\n align: d.align,\r\n };\r\n return (\r\n <Annotation\r\n key={i}\r\n color={d.color}\r\n connectorsSettings={connectorSettings}\r\n labelSettings={labelSettings}\r\n text={d.text}\r\n classNames={d.classNames}\r\n styles={d.styles}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n );\r\n })}\r\n </g>\r\n <g>\r\n {regressionLine ? (\r\n <RegressionLine\r\n x1={0}\r\n x2={graphWidth}\r\n y1={predict(0)}\r\n y2={predict(graphWidth)}\r\n graphHeight={graphHeight}\r\n graphWidth={graphWidth}\r\n className={classNames?.regLine}\r\n style={styles?.regLine}\r\n color={typeof regressionLine === 'string' ? regressionLine : undefined}\r\n animate={animate}\r\n isInView={isInView}\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 </motion.svg>\r\n {mouseOverData && tooltip && eventX && eventY ? (\r\n <Tooltip\r\n data={mouseOverData}\r\n body={tooltip}\r\n xPos={eventX}\r\n yPos={eventY}\r\n backgroundStyle={styles?.tooltip}\r\n className={classNames?.tooltip}\r\n />\r\n ) : null}\r\n </>\r\n );\r\n}\r\n","import { useState, useRef, useEffect } from 'react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport {\r\n AnnotationSettingsDataType,\r\n CustomHighlightAreaSettingsDataType,\r\n Languages,\r\n LineChartDataType,\r\n ReferenceDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n HighlightAreaSettingsDataType,\r\n CurveTypes,\r\n CustomLayerDataType,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\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 /** Prefix for values */\r\n prefix?: string;\r\n /** Suffix for values */\r\n suffix?: string;\r\n /** Maximum value for the chart */\r\n maxValue?: number;\r\n /** Minimum value for the chart */\r\n minValue?: number;\r\n /** Reference values for comparison */\r\n refValues?: ReferenceDataType[];\r\n /** Maximum value of the date for the chart */\r\n maxDate?: string | number;\r\n /** Minimum value of the date for the chart */\r\n minDate?: string | number;\r\n /** No. of ticks on the x-axis */\r\n noOfXTicks?: number;\r\n /** No. of ticks on the y-axis */\r\n noOfYTicks?: number;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of values */\r\n showValues?: boolean;\r\n /** Toggle visibility of dots on the line */\r\n showDots?: boolean;\r\n /** Stroke width of the line */\r\n strokeWidth?: number;\r\n /** Toggle the initial animation of the line. If the type is number then it uses the number as the time in seconds for animation. */\r\n animate?: boolean | AnimateDataType;\r\n /** Format of the date in the data object. Available formats can be found [here](https://date-fns.org/docs/format) */\r\n dateFormat?: string;\r\n /** Title for the Y-axis */\r\n yAxisTitle?: string;\r\n /** Annotations on the chart */\r\n annotations?: AnnotationSettingsDataType[];\r\n /** Highlighted area(square) on the chart */\r\n highlightAreaSettings?: HighlightAreaSettingsDataType[];\r\n /** Highlighted area(custom shape) on the chart */\r\n customHighlightAreaSettings?: CustomHighlightAreaSettingsDataType[];\r\n /** Toggles the visibility of the regression line for the data. If the type is string then string is use to define the color of the line. */\r\n regressionLine?: boolean | string;\r\n /** Curve type for the line */\r\n curveType?: CurveTypes;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\r\n /** Optional SVG <g> element or function that renders custom content behind or in front of the graph. */\r\n customLayers?: CustomLayerDataType[];\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n\r\n // Interactions and Callbacks\r\n /** Tooltip content. If the type is string then this uses the [handlebar](../?path=/docs/misc-handlebars-templates-and-custom-helpers--docs) template to display the data */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n /** Callback for mouse over event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n\r\n // Configuration and Options\r\n /** Language setting */\r\n language?: Languages;\r\n /** Color theme */\r\n theme?: 'light' | 'dark';\r\n /** Unique ID for the graph */\r\n graphID?: string;\r\n}\r\n\r\nexport function SimpleLineChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n lineColor,\r\n suffix = '',\r\n sources,\r\n prefix = '',\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n showValues = false,\r\n padding,\r\n backgroundColor = false,\r\n leftMargin = 30,\r\n rightMargin = 30,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n relativeHeight,\r\n tooltip,\r\n onSeriesMouseOver,\r\n highlightAreaSettings = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n maxDate,\r\n minDate,\r\n graphDownload = false,\r\n dataDownload = false,\r\n animate = false,\r\n language = 'en',\r\n refValues = [],\r\n minHeight = 0,\r\n strokeWidth = 2,\r\n showDots = true,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n regressionLine = false,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n precision = 2,\r\n customLayers = [],\r\n } = props;\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 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 shows trends over time.${\r\n graphDescription ? ` ${graphDescription}` : ''\r\n }`\r\n }\r\n >\r\n <div\r\n className='flex grow'\r\n style={{ padding: backgroundColor ? padding || '1rem' : padding || 0 }}\r\n >\r\n <div className='flex flex-col w-full gap-4 grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n {data.length === 0 ? (\r\n <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n <EmptyState />\r\n </div>\r\n ) : (\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 suffix={suffix}\r\n prefix={prefix}\r\n dateFormat={dateFormat}\r\n showValues={showValues}\r\n noOfXTicks={noOfXTicks}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n highlightAreaSettings={highlightAreaSettings}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n animate={\r\n animate === true\r\n ? { duration: 0.5, once: true, amount: 0.5 }\r\n : animate || { duration: 0, once: true, amount: 0 }\r\n }\r\n rtl={language === 'he' || language === 'ar'}\r\n strokeWidth={strokeWidth}\r\n showDots={showDots}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n regressionLine={regressionLine}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n maxDate={maxDate}\r\n minDate={minDate}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n precision={precision}\r\n customLayers={customLayers}\r\n />\r\n ) : null}\r\n </div>\r\n )}\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","suffix","prefix","dateFormat","highlightAreaSettings","showValues","noOfXTicks","rightMargin","leftMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","refValues","minValue","maxValue","animate","rtl","strokeWidth","showDots","annotations","customHighlightAreaSettings","regressionLine","yAxisTitle","noOfYTicks","maxDate","minDate","curveType","styles","classNames","precision","customLayers","svgRef","useRef","isInView","useInView","hasAnimatedOnce","setHasAnimatedOnce","useState","useEffect","timeout","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","dataFormatted","sortBy","d","parse","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","el","j","graphWidth","graphHeight","minYear","maxYear","minParam","checkIfNullOrUndefined","maxParam","x","scaleTime","y","scaleLinear","lineShape","line","yTicks","xTicks","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","regressionLineParam","linearRegression","predict","linearRegressionLine","jsxs","Fragment","jsx","motion","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","i","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","RegressionLine","Tooltip","SimpleLineChart","graphTitle","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","Colors","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0FO,SAASA,GAAMC,IAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,SAAAC;AAAA,IACA,KAAAC;AAAA,IACA,aAAAC;AAAA,IACA,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,6BAAAC;AAAA,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BAGPkF,KAAWE,IACVxB,gBAAAA,EAAAA;AAAAA,kBAAC8C;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAU7G,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAAoF;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAArH;AAAA,kBAAA;AAAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index-CHPV5EwG-DDoeWRVt.cjs"),o=require("react"),ae=require("./index-Ds0uHjK9.cjs"),A=require("./index-B0rbzOoC.cjs"),te=require("./index-BXns0-ng.cjs"),C=require("./DropdownSelect-BmE5JaeE.cjs"),h=require("./checkIfMultiple-BXbHUCWM.cjs"),le=require("./Typography-k-kOjICQ.cjs"),ne=require("./Spinner-DA6Z5E4n.cjs"),re=require("./GraphEl-DO-juRN8.cjs"),G=require("./fetchAndParseData-CQyVGCul.cjs"),U=require("./transformDataForAggregation-Du-Hei-W.cjs"),z=require("./getUniqValue-CHqgSss5.cjs"),ie=require("./GraphHeader.cjs"),W=require("./filterData-DN6py7y_.cjs"),oe=require("./getGraphList-gf02xgT2.cjs"),Z=require("./transformDataForSelect-YmStusCI.cjs"),se=s=>{if(s.findIndex(r=>r.chartConfigId==="yMin")!==-1&&s.findIndex(r=>r.chartConfigId==="yMax")!==-1)return s;const l=[...s];return s.findIndex(r=>r.chartConfigId==="yMin")===-1&&l.push({chartConfigId:"yMin",columnId:`${s[s.findIndex(r=>r.chartConfigId==="y")].columnId}Min`}),s.findIndex(r=>r.chartConfigId==="yMax")===-1&&l.push({chartConfigId:"yMax",columnId:`${s[s.findIndex(r=>r.chartConfigId==="y")].columnId}Max`}),l},F=(s,l)=>{const r=l?.map(y=>{const f=s?.findIndex(i=>i.chartConfigId===y.chartConfigId);if(f===-1)return{};const v=s[f]?.allowedColumnIds?.findIndex(i=>i.value===y.columnId);return v===-1?{}:s[f].allowedColumnIds[v].graphSettings||{}})||[];return Object.assign({},...r)};function ue(s){const{graphSettings:l,dataSettings:r,filters:y,graphType:f,dataTransform:v,graphDataConfiguration:i,dataFilters:q,debugMode:D,dataSelectionOptions:j,advancedDataSelectionOptions:N,readableHeader:J,noOfFiltersPerRow:p=4,updateFilters:B,uiMode:g="normal",highlightDataPointSettings:I}=s,[b,K]=o.useState(void 0),[S,Q]=o.useState(void 0),[m,w]=o.useState(i),[x,R]=o.useState({}),[V,X]=o.useState(void 0),[Y,_]=o.useState([]),P=o.useRef(null),H=o.useRef(i),[E,O]=o.useState([]),k=o.useMemo(()=>({ignoreCase:!0,ignoreAccents:!0,trim:!0}),[]),L=o.useCallback(async()=>{if(r)try{const d=await(r.dataURL?typeof r.dataURL=="string"?r.fileType==="json"?G.fetchAndParseJSON(r.dataURL,r.columnsToArray,r.dataTransformation,D):r.fileType==="api"?G.fetchAndTransformDataFromAPI(r.dataURL,r.apiHeaders,r.columnsToArray,r.dataTransformation,D):G.fetchAndParseCSV(r.dataURL,r.dataTransformation,r.columnsToArray,D,r.delimiter,!0):G.fetchAndParseMultipleDataSources(r.dataURL,r.idColumnTitle):G.transformColumnsToArray(r.data,r.columnsToArray));Q(d);const a=(y||[]).map(t=>({filter:t.column,label:t.label||`Filter by ${t.column}`,singleSelect:t.singleSelect,clearable:t.clearable,defaultValue:Z.transformDefaultValue(t.defaultValue),value:Z.transformDefaultValue(t.defaultValue),availableValues:z.getUniqValue(d,t.column).filter(u=>!t.excludeValues?.includes(`${u}`)).map(u=>({value:u,label:u})),allowSelectAll:t.allowSelectAll,width:t.width}));O(a)}catch(e){console.error("Data fetching error:",e)}},[r,y,D]);o.useEffect(()=>{L()},[L]);const $=o.useMemo(()=>!S||E.length===0?S:S.filter(d=>E.every(a=>a.value&&A.flattenDeep([a.value]).length>0?ae.intersection(A.flattenDeep([d[a.filter]]),A.flattenDeep([a.value]).map(t=>t.value)).length>0:!0)),[E,S]);o.useEffect(()=>{j&&R(F(j,i))},[j,i]),o.useEffect(()=>{S&&K($)},[$,f,S]),o.useEffect(()=>{I?.column&&$&&_(z.getUniqValue($,I.column).filter(e=>!I?.excludeValues?.includes(`${e}`)).map(e=>({value:e,label:e})))},[$,I]),o.useEffect(()=>{te.isEqual(H.current,i)||(w(i),H.current=i)},[i]);const M=o.useCallback((e,d)=>{O(a=>a.map(t=>t.filter===e?{...t,value:d}:t))},[]),ee=o.useMemo(()=>{if(!b)return;const e=f==="lineChartWithConfidenceInterval"&&m?se(m):m;return U.transformDataForGraph(v?U.transformDataForAggregation(W.filterData(b,q||[]),v.keyColumn,v.aggregationColumnsSetting):W.filterData(b,q||[]),f,e)},[f,m,b,q,v]);return r?n.jsxRuntimeExports.jsx("div",{className:`${l?.theme||"light"} flex ${l?.width?"w-fit grow-0":"w-full grow"}${l?.height?"":" h-full"}`,dir:l?.language==="he"||l?.language==="ar"?"rtl":void 0,children:n.jsxRuntimeExports.jsx("div",{className:n.mo(`${l?.backgroundColor?l?.backgroundColor===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${l?.language||"en"}`,l?.classNames?.graphContainer),style:{...l?.styles?.graphContainer||{},...l?.backgroundColor&&l?.backgroundColor!==!0?{backgroundColor:l?.backgroundColor}:{}},id:l?.graphID,ref:P,children:n.jsxRuntimeExports.jsx("div",{style:{padding:l?.backgroundColor?l?.padding||"1rem":l?.padding||0,flexGrow:1,display:"flex"},children:n.jsxRuntimeExports.jsx("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:b||oe.graphList.filter(e=>e.geoHubMapPresentation).map(e=>e.graphID).indexOf(f)!==-1?n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[x?.graphTitle||x?.graphDescription||l?.graphTitle||l?.graphDescription||l?.graphDownload||l?.dataDownload?n.jsxRuntimeExports.jsx(ie.GraphHeader,{styles:{title:x?.styles?.title||l?.styles?.title,description:x?.styles?.description||l?.styles?.description},classNames:{title:x?.classNames?.title||l?.classNames?.title,description:x?.classNames?.description||l?.classNames?.description},graphTitle:x?.graphTitle||l?.graphTitle,graphDescription:x?.graphDescription||l?.graphDescription,width:x?.width||l?.width,graphDownload:l?.graphDownload?P.current:void 0,dataDownload:l?.dataDownload&&b&&b.length>0?b:null}):null,E.length!==0||(j||[]).length!==0||(N||[]).length!==0||I?n.jsxRuntimeExports.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",alignItems:"flex-start",width:"100%"},children:[N?.map((e,d)=>n.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/p}% - ${(p-1)/p}rem)`,flexGrow:1,flexShrink:e.ui!=="radio"?0:1,minWidth:"240px"},children:[n.jsxRuntimeExports.jsx(h.f,{className:"mb-2",children:e.label||"Graph by"}),e.ui!=="radio"?n.jsxRuntimeExports.jsx(C.Za,{options:e.options.map(a=>({...a,value:a.label})),size:"sm",isClearable:!1,isSearchable:!0,variant:g,controlShouldRenderValue:!0,defaultValue:e.defaultValue?{...e.defaultValue,value:e.defaultValue?.label}:{...e.options[0],value:e.options[0].label},onChange:a=>{R(a?.graphSettings||{}),w(a?.dataConfiguration)}}):n.jsxRuntimeExports.jsx(h.fe,{defaultValue:e.defaultValue?.label||e.options[0].label,variant:g,onValueChange:a=>{const t=e.options[e.options.findIndex(u=>u.label===a)];R(t.graphSettings||{}),w(t.dataConfiguration)},children:e.options.map((a,t)=>n.jsxRuntimeExports.jsx(h.ve,{label:a.label,value:a.label},t))})]},d)),j?.map((e,d)=>n.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/p}% - ${(p-1)/p}rem)`,flexGrow:1,flexShrink:e.ui!=="radio"?0:1,minWidth:"240px"},children:[n.jsxRuntimeExports.jsx(h.f,{className:"mb-2",children:e.label||`Visualize ${e.chartConfigId} by`}),h.checkIfMultiple(e.chartConfigId,m||[])?e.ui!=="radio"?n.jsxRuntimeExports.jsx(C.Za,{options:e.allowedColumnIds,size:"sm",isMulti:!0,isSearchable:!0,variant:g,controlShouldRenderValue:!0,defaultValue:i?i[i.findIndex(a=>a.chartConfigId===e.chartConfigId)].columnId.map(a=>e.allowedColumnIds[e.allowedColumnIds.findIndex(t=>t.value===a)]):void 0,filterOption:C.Hu(k),onChange:a=>{const t={columnId:(a||[]).map(c=>c.value),chartConfigId:e.chartConfigId},u=m?.map(c=>c.chartConfigId===t.chartConfigId?t:c);w(u)}}):n.jsxRuntimeExports.jsx(h.w,{variant:g,defaultValue:i?i[i.findIndex(a=>a.chartConfigId===e.chartConfigId)].columnId.map(a=>e.allowedColumnIds[e.allowedColumnIds.findIndex(t=>t.value===a)]).map(a=>a.value):[],onValueChange:a=>{const t={columnId:a||[],chartConfigId:e.chartConfigId},u=m?.map(c=>c.chartConfigId===t.chartConfigId?t:c);w(u)},children:e.allowedColumnIds.map((a,t)=>n.jsxRuntimeExports.jsx(h.G,{label:a.label,value:a.label},t))}):e.ui!=="radio"?n.jsxRuntimeExports.jsx(C.Za,{options:e.allowedColumnIds,size:"sm",isClearable:!1,isSearchable:!0,variant:g,controlShouldRenderValue:!0,defaultValue:i?e.allowedColumnIds[e.allowedColumnIds.findIndex(a=>a.value===i[i.findIndex(t=>t.chartConfigId===e.chartConfigId)].columnId)]:void 0,onChange:a=>{const t={columnId:a?.value,chartConfigId:e.chartConfigId},u=m?.map(c=>c.chartConfigId===t.chartConfigId?t:c);R(F(j,u)),w(u)}}):n.jsxRuntimeExports.jsx(h.fe,{variant:g,defaultValue:i?e.allowedColumnIds[e.allowedColumnIds.findIndex(a=>a.value===i[i.findIndex(t=>t.chartConfigId===e.chartConfigId)].columnId)].label:"",onValueChange:a=>{const u={columnId:e.allowedColumnIds[e.allowedColumnIds.findIndex(T=>T.label===a)].value,chartConfigId:e.chartConfigId},c=m?.map(T=>T.chartConfigId===u.chartConfigId?u:T);R(F(j,c)),w(c)},children:e.allowedColumnIds.map((a,t)=>n.jsxRuntimeExports.jsx(h.ve,{label:a.label,value:a.label},t))})]},d)),E?.map((e,d)=>n.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/p}% - ${(p-1)/p}rem)`,flexGrow:1,flexShrink:0,minWidth:"240px"},children:[n.jsxRuntimeExports.jsx(h.f,{className:"mb-2",children:e.label}),e.singleSelect?n.jsxRuntimeExports.jsx(C.Za,{options:e.availableValues,variant:g,isClearable:e.clearable===void 0?!0:e.clearable,isSearchable:!0,controlShouldRenderValue:!0,filterOption:C.Hu(k),onChange:a=>{M(e.filter,a)},value:e.value,defaultValue:e.defaultValue}):n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[e.ui!=="radio"?n.jsxRuntimeExports.jsx(C.Za,{options:e.availableValues,variant:g,size:"sm",isMulti:!0,isClearable:e.clearable===void 0?!0:e.clearable,isSearchable:!0,controlShouldRenderValue:!0,filterOption:C.Hu(k),onChange:a=>{M(e.filter,a)},value:e.value,defaultValue:e.defaultValue}):n.jsxRuntimeExports.jsx(h.w,{variant:g,defaultValue:e.defaultValue?e.defaultValue.map(a=>`${a.value}`):[],value:e.value?e.value.map(a=>`${a.value}`):void 0,onValueChange:a=>{M(e.filter,e.availableValues.filter(t=>a.indexOf(`${t.value}`)!==-1))},children:e.availableValues.map((a,t)=>n.jsxRuntimeExports.jsx(h.G,{label:`${a.label}`,value:`${a.value}`},t))}),e.allowSelectAll?n.jsxRuntimeExports.jsx("button",{type:"button",className:"bg-transparent border-0 p-0 mt-2 cursor-pointer text-primary-blue-600 dark:text-primary-blue-400",onClick:()=>{M(e.filter,e.availableValues)},children:"Select all options"}):null]})]},d)),I?n.jsxRuntimeExports.jsxs("div",{style:{width:I.width||`calc(${100/p}% - ${(p-1)/p}rem)`,flexGrow:1,flexShrink:0,minWidth:"240px"},children:[n.jsxRuntimeExports.jsx(h.f,{className:"mb-2",children:I.label||"Highlight data"}),n.jsxRuntimeExports.jsx(C.Za,{options:Y,variant:g,size:"sm",isMulti:!0,isClearable:!0,isSearchable:!0,controlShouldRenderValue:!0,filterOption:C.Hu(k),onChange:e=>{X(e?.map(d=>d.value))},value:V?.map(e=>({label:e,value:e})),defaultValue:I.defaultValues?.map(e=>({label:e,value:e}))})]}):null]}):null,n.jsxRuntimeExports.jsx(re.GraphEl,{graph:f,graphData:ee,graphDataConfiguration:m,debugMode:D,readableHeader:J||[],updateFilters:B,settings:{...l||{},...x,graphTitle:void 0,graphDescription:void 0,graphDownload:!1,dataDownload:!1,backgroundColor:void 0,padding:"0",theme:l?.theme,...V?{highlightedDataPoints:V,highlightedIds:V?.map(e=>`${e}`),highlightedLines:V?.map(e=>e)}:{}}})]}):n.jsxRuntimeExports.jsx("div",{className:"w-full flex justify-center p-4",children:n.jsxRuntimeExports.jsx(ne.y,{})})})})})}):n.jsxRuntimeExports.jsx(le.u,{size:"xs",className:"text-center text-accent-dark-red dark:text-accent-red p-2",children:"Please make sure either `dataSettings` props are present as they are required for data."})}exports.SingleGraphDashboard=ue;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index-CHPV5EwG-DDoeWRVt.cjs"),o=require("react"),ae=require("./index-Ds0uHjK9.cjs"),A=require("./index-B0rbzOoC.cjs"),te=require("./index-BXns0-ng.cjs"),C=require("./DropdownSelect-DBDM64B5.cjs"),h=require("./checkIfMultiple-BXbHUCWM.cjs"),le=require("./Typography-k-kOjICQ.cjs"),ne=require("./Spinner-DA6Z5E4n.cjs"),re=require("./GraphEl-Zl0W-LK9.cjs"),G=require("./fetchAndParseData-CQyVGCul.cjs"),U=require("./transformDataForAggregation-Du-Hei-W.cjs"),z=require("./getUniqValue-CHqgSss5.cjs"),ie=require("./GraphHeader.cjs"),W=require("./filterData-DN6py7y_.cjs"),oe=require("./getGraphList-gf02xgT2.cjs"),Z=require("./transformDataForSelect-YmStusCI.cjs"),se=s=>{if(s.findIndex(r=>r.chartConfigId==="yMin")!==-1&&s.findIndex(r=>r.chartConfigId==="yMax")!==-1)return s;const l=[...s];return s.findIndex(r=>r.chartConfigId==="yMin")===-1&&l.push({chartConfigId:"yMin",columnId:`${s[s.findIndex(r=>r.chartConfigId==="y")].columnId}Min`}),s.findIndex(r=>r.chartConfigId==="yMax")===-1&&l.push({chartConfigId:"yMax",columnId:`${s[s.findIndex(r=>r.chartConfigId==="y")].columnId}Max`}),l},F=(s,l)=>{const r=l?.map(y=>{const f=s?.findIndex(i=>i.chartConfigId===y.chartConfigId);if(f===-1)return{};const v=s[f]?.allowedColumnIds?.findIndex(i=>i.value===y.columnId);return v===-1?{}:s[f].allowedColumnIds[v].graphSettings||{}})||[];return Object.assign({},...r)};function ue(s){const{graphSettings:l,dataSettings:r,filters:y,graphType:f,dataTransform:v,graphDataConfiguration:i,dataFilters:q,debugMode:D,dataSelectionOptions:j,advancedDataSelectionOptions:N,readableHeader:J,noOfFiltersPerRow:p=4,updateFilters:B,uiMode:g="normal",highlightDataPointSettings:I}=s,[b,K]=o.useState(void 0),[S,Q]=o.useState(void 0),[m,w]=o.useState(i),[x,R]=o.useState({}),[V,X]=o.useState(void 0),[Y,_]=o.useState([]),P=o.useRef(null),H=o.useRef(i),[E,O]=o.useState([]),k=o.useMemo(()=>({ignoreCase:!0,ignoreAccents:!0,trim:!0}),[]),L=o.useCallback(async()=>{if(r)try{const d=await(r.dataURL?typeof r.dataURL=="string"?r.fileType==="json"?G.fetchAndParseJSON(r.dataURL,r.columnsToArray,r.dataTransformation,D):r.fileType==="api"?G.fetchAndTransformDataFromAPI(r.dataURL,r.apiHeaders,r.columnsToArray,r.dataTransformation,D):G.fetchAndParseCSV(r.dataURL,r.dataTransformation,r.columnsToArray,D,r.delimiter,!0):G.fetchAndParseMultipleDataSources(r.dataURL,r.idColumnTitle):G.transformColumnsToArray(r.data,r.columnsToArray));Q(d);const a=(y||[]).map(t=>({filter:t.column,label:t.label||`Filter by ${t.column}`,singleSelect:t.singleSelect,clearable:t.clearable,defaultValue:Z.transformDefaultValue(t.defaultValue),value:Z.transformDefaultValue(t.defaultValue),availableValues:z.getUniqValue(d,t.column).filter(u=>!t.excludeValues?.includes(`${u}`)).map(u=>({value:u,label:u})),allowSelectAll:t.allowSelectAll,width:t.width}));O(a)}catch(e){console.error("Data fetching error:",e)}},[r,y,D]);o.useEffect(()=>{L()},[L]);const $=o.useMemo(()=>!S||E.length===0?S:S.filter(d=>E.every(a=>a.value&&A.flattenDeep([a.value]).length>0?ae.intersection(A.flattenDeep([d[a.filter]]),A.flattenDeep([a.value]).map(t=>t.value)).length>0:!0)),[E,S]);o.useEffect(()=>{j&&R(F(j,i))},[j,i]),o.useEffect(()=>{S&&K($)},[$,f,S]),o.useEffect(()=>{I?.column&&$&&_(z.getUniqValue($,I.column).filter(e=>!I?.excludeValues?.includes(`${e}`)).map(e=>({value:e,label:e})))},[$,I]),o.useEffect(()=>{te.isEqual(H.current,i)||(w(i),H.current=i)},[i]);const M=o.useCallback((e,d)=>{O(a=>a.map(t=>t.filter===e?{...t,value:d}:t))},[]),ee=o.useMemo(()=>{if(!b)return;const e=f==="lineChartWithConfidenceInterval"&&m?se(m):m;return U.transformDataForGraph(v?U.transformDataForAggregation(W.filterData(b,q||[]),v.keyColumn,v.aggregationColumnsSetting):W.filterData(b,q||[]),f,e)},[f,m,b,q,v]);return r?n.jsxRuntimeExports.jsx("div",{className:`${l?.theme||"light"} flex ${l?.width?"w-fit grow-0":"w-full grow"}${l?.height?"":" h-full"}`,dir:l?.language==="he"||l?.language==="ar"?"rtl":void 0,children:n.jsxRuntimeExports.jsx("div",{className:n.mo(`${l?.backgroundColor?l?.backgroundColor===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${l?.language||"en"}`,l?.classNames?.graphContainer),style:{...l?.styles?.graphContainer||{},...l?.backgroundColor&&l?.backgroundColor!==!0?{backgroundColor:l?.backgroundColor}:{}},id:l?.graphID,ref:P,children:n.jsxRuntimeExports.jsx("div",{style:{padding:l?.backgroundColor?l?.padding||"1rem":l?.padding||0,flexGrow:1,display:"flex"},children:n.jsxRuntimeExports.jsx("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:b||oe.graphList.filter(e=>e.geoHubMapPresentation).map(e=>e.graphID).indexOf(f)!==-1?n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[x?.graphTitle||x?.graphDescription||l?.graphTitle||l?.graphDescription||l?.graphDownload||l?.dataDownload?n.jsxRuntimeExports.jsx(ie.GraphHeader,{styles:{title:x?.styles?.title||l?.styles?.title,description:x?.styles?.description||l?.styles?.description},classNames:{title:x?.classNames?.title||l?.classNames?.title,description:x?.classNames?.description||l?.classNames?.description},graphTitle:x?.graphTitle||l?.graphTitle,graphDescription:x?.graphDescription||l?.graphDescription,width:x?.width||l?.width,graphDownload:l?.graphDownload?P.current:void 0,dataDownload:l?.dataDownload&&b&&b.length>0?b:null}):null,E.length!==0||(j||[]).length!==0||(N||[]).length!==0||I?n.jsxRuntimeExports.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",alignItems:"flex-start",width:"100%"},children:[N?.map((e,d)=>n.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/p}% - ${(p-1)/p}rem)`,flexGrow:1,flexShrink:e.ui!=="radio"?0:1,minWidth:"240px"},children:[n.jsxRuntimeExports.jsx(h.f,{className:"mb-2",children:e.label||"Graph by"}),e.ui!=="radio"?n.jsxRuntimeExports.jsx(C.Za,{options:e.options.map(a=>({...a,value:a.label})),size:"sm",isClearable:!1,isSearchable:!0,variant:g,controlShouldRenderValue:!0,defaultValue:e.defaultValue?{...e.defaultValue,value:e.defaultValue?.label}:{...e.options[0],value:e.options[0].label},onChange:a=>{R(a?.graphSettings||{}),w(a?.dataConfiguration)}}):n.jsxRuntimeExports.jsx(h.fe,{defaultValue:e.defaultValue?.label||e.options[0].label,variant:g,onValueChange:a=>{const t=e.options[e.options.findIndex(u=>u.label===a)];R(t.graphSettings||{}),w(t.dataConfiguration)},children:e.options.map((a,t)=>n.jsxRuntimeExports.jsx(h.ve,{label:a.label,value:a.label},t))})]},d)),j?.map((e,d)=>n.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/p}% - ${(p-1)/p}rem)`,flexGrow:1,flexShrink:e.ui!=="radio"?0:1,minWidth:"240px"},children:[n.jsxRuntimeExports.jsx(h.f,{className:"mb-2",children:e.label||`Visualize ${e.chartConfigId} by`}),h.checkIfMultiple(e.chartConfigId,m||[])?e.ui!=="radio"?n.jsxRuntimeExports.jsx(C.Za,{options:e.allowedColumnIds,size:"sm",isMulti:!0,isSearchable:!0,variant:g,controlShouldRenderValue:!0,defaultValue:i?i[i.findIndex(a=>a.chartConfigId===e.chartConfigId)].columnId.map(a=>e.allowedColumnIds[e.allowedColumnIds.findIndex(t=>t.value===a)]):void 0,filterOption:C.Hu(k),onChange:a=>{const t={columnId:(a||[]).map(c=>c.value),chartConfigId:e.chartConfigId},u=m?.map(c=>c.chartConfigId===t.chartConfigId?t:c);w(u)}}):n.jsxRuntimeExports.jsx(h.w,{variant:g,defaultValue:i?i[i.findIndex(a=>a.chartConfigId===e.chartConfigId)].columnId.map(a=>e.allowedColumnIds[e.allowedColumnIds.findIndex(t=>t.value===a)]).map(a=>a.value):[],onValueChange:a=>{const t={columnId:a||[],chartConfigId:e.chartConfigId},u=m?.map(c=>c.chartConfigId===t.chartConfigId?t:c);w(u)},children:e.allowedColumnIds.map((a,t)=>n.jsxRuntimeExports.jsx(h.G,{label:a.label,value:a.label},t))}):e.ui!=="radio"?n.jsxRuntimeExports.jsx(C.Za,{options:e.allowedColumnIds,size:"sm",isClearable:!1,isSearchable:!0,variant:g,controlShouldRenderValue:!0,defaultValue:i?e.allowedColumnIds[e.allowedColumnIds.findIndex(a=>a.value===i[i.findIndex(t=>t.chartConfigId===e.chartConfigId)].columnId)]:void 0,onChange:a=>{const t={columnId:a?.value,chartConfigId:e.chartConfigId},u=m?.map(c=>c.chartConfigId===t.chartConfigId?t:c);R(F(j,u)),w(u)}}):n.jsxRuntimeExports.jsx(h.fe,{variant:g,defaultValue:i?e.allowedColumnIds[e.allowedColumnIds.findIndex(a=>a.value===i[i.findIndex(t=>t.chartConfigId===e.chartConfigId)].columnId)].label:"",onValueChange:a=>{const u={columnId:e.allowedColumnIds[e.allowedColumnIds.findIndex(T=>T.label===a)].value,chartConfigId:e.chartConfigId},c=m?.map(T=>T.chartConfigId===u.chartConfigId?u:T);R(F(j,c)),w(c)},children:e.allowedColumnIds.map((a,t)=>n.jsxRuntimeExports.jsx(h.ve,{label:a.label,value:a.label},t))})]},d)),E?.map((e,d)=>n.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/p}% - ${(p-1)/p}rem)`,flexGrow:1,flexShrink:0,minWidth:"240px"},children:[n.jsxRuntimeExports.jsx(h.f,{className:"mb-2",children:e.label}),e.singleSelect?n.jsxRuntimeExports.jsx(C.Za,{options:e.availableValues,variant:g,isClearable:e.clearable===void 0?!0:e.clearable,isSearchable:!0,controlShouldRenderValue:!0,filterOption:C.Hu(k),onChange:a=>{M(e.filter,a)},value:e.value,defaultValue:e.defaultValue}):n.jsxRuntimeExports.jsxs(n.jsxRuntimeExports.Fragment,{children:[e.ui!=="radio"?n.jsxRuntimeExports.jsx(C.Za,{options:e.availableValues,variant:g,size:"sm",isMulti:!0,isClearable:e.clearable===void 0?!0:e.clearable,isSearchable:!0,controlShouldRenderValue:!0,filterOption:C.Hu(k),onChange:a=>{M(e.filter,a)},value:e.value,defaultValue:e.defaultValue}):n.jsxRuntimeExports.jsx(h.w,{variant:g,defaultValue:e.defaultValue?e.defaultValue.map(a=>`${a.value}`):[],value:e.value?e.value.map(a=>`${a.value}`):void 0,onValueChange:a=>{M(e.filter,e.availableValues.filter(t=>a.indexOf(`${t.value}`)!==-1))},children:e.availableValues.map((a,t)=>n.jsxRuntimeExports.jsx(h.G,{label:`${a.label}`,value:`${a.value}`},t))}),e.allowSelectAll?n.jsxRuntimeExports.jsx("button",{type:"button",className:"bg-transparent border-0 p-0 mt-2 cursor-pointer text-primary-blue-600 dark:text-primary-blue-400",onClick:()=>{M(e.filter,e.availableValues)},children:"Select all options"}):null]})]},d)),I?n.jsxRuntimeExports.jsxs("div",{style:{width:I.width||`calc(${100/p}% - ${(p-1)/p}rem)`,flexGrow:1,flexShrink:0,minWidth:"240px"},children:[n.jsxRuntimeExports.jsx(h.f,{className:"mb-2",children:I.label||"Highlight data"}),n.jsxRuntimeExports.jsx(C.Za,{options:Y,variant:g,size:"sm",isMulti:!0,isClearable:!0,isSearchable:!0,controlShouldRenderValue:!0,filterOption:C.Hu(k),onChange:e=>{X(e?.map(d=>d.value))},value:V?.map(e=>({label:e,value:e})),defaultValue:I.defaultValues?.map(e=>({label:e,value:e}))})]}):null]}):null,n.jsxRuntimeExports.jsx(re.GraphEl,{graph:f,graphData:ee,graphDataConfiguration:m,debugMode:D,readableHeader:J||[],updateFilters:B,settings:{...l||{},...x,graphTitle:void 0,graphDescription:void 0,graphDownload:!1,dataDownload:!1,backgroundColor:void 0,padding:"0",theme:l?.theme,...V?{highlightedDataPoints:V,highlightedIds:V?.map(e=>`${e}`),highlightedLines:V?.map(e=>e)}:{}}})]}):n.jsxRuntimeExports.jsx("div",{className:"w-full flex justify-center p-4",children:n.jsxRuntimeExports.jsx(ne.y,{})})})})})}):n.jsxRuntimeExports.jsx(le.u,{size:"xs",className:"text-center text-accent-dark-red dark:text-accent-red p-2",children:"Please make sure either `dataSettings` props are present as they are required for data."})}exports.SingleGraphDashboard=ue;
|
|
2
2
|
//# sourceMappingURL=SingleGraphDashboard.cjs.map
|
|
@@ -3,11 +3,11 @@ import { useState as b, useRef as q, useMemo as O, useCallback as Z, useEffect a
|
|
|
3
3
|
import { i as da } from "./index-C1rRk_50.js";
|
|
4
4
|
import { f as P } from "./index-UV9hjG_S.js";
|
|
5
5
|
import { i as ua } from "./index-27yTRcko.js";
|
|
6
|
-
import { Z as y, H as N } from "./DropdownSelect-
|
|
6
|
+
import { Z as y, H as N } from "./DropdownSelect-CtOKZHD0.js";
|
|
7
7
|
import { f as F, a as J, v as B, c as ca, w as K, G as Q } from "./checkIfMultiple-ChTJk2Tk.js";
|
|
8
8
|
import { u as ha } from "./Typography-Ctgfl1J5.js";
|
|
9
9
|
import { y as fa } from "./Spinner-C85UF28E.js";
|
|
10
|
-
import { G as ga } from "./GraphEl-
|
|
10
|
+
import { G as ga } from "./GraphEl-N6vuMRw_.js";
|
|
11
11
|
import { f as pa, a as ma, b as Ca, c as xa, t as Ia } from "./fetchAndParseData-4gsYTy6_.js";
|
|
12
12
|
import { a as va, t as ba } from "./transformDataForAggregation-CdcwlnNe.js";
|
|
13
13
|
import { g as X } from "./getUniqValue-BtUENB2H.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-CHPV5EwG-DDoeWRVt.cjs"),i=require("react"),te=require("./index-Ds0uHjK9.cjs"),H=require("./index-B0rbzOoC.cjs"),le=require("./index-BXns0-ng.cjs"),x=require("./DropdownSelect-BmE5JaeE.cjs"),c=require("./checkIfMultiple-BXbHUCWM.cjs"),M=require("./Typography-k-kOjICQ.cjs"),re=require("./Spinner-DA6Z5E4n.cjs"),oe=require("./ThreeDGlobe.cjs"),$=require("./fetchAndParseData-CQyVGCul.cjs"),W=require("./transformDataForAggregation-Du-Hei-W.cjs"),B=require("./getUniqValue-CHqgSss5.cjs"),ne=require("./GraphHeader.cjs"),J=require("./filterData-DN6py7y_.cjs"),ie=require("./getGraphList-gf02xgT2.cjs"),K=require("./transformDataForSelect-YmStusCI.cjs");function se(I){const{settings:a,graph:o,graphData:g,debugMode:p,graphDataConfiguration:C,readableHeader:n,updateFilters:R}=I;if(p&&(console.log(`Graph: ${o}`),console.log("Transformed data:",g),console.log("Settings:",a)),typeof g=="string")return r.jsxRuntimeExports.jsx("div",{className:`flex my-0 mx-auto grow flex-col justify-center ${a?.width?"w-fit":"w-full"}`,style:{height:"inherit"},children:r.jsxRuntimeExports.jsx(M.u,{size:"sm",marginBottom:"none",className:"p-2 text-center text-accent-dark-red dark:text-accent-red",children:g})});const D={threeDGlobe:oe.ThreeDGlobe},b=d=>{switch(d){case"threeDGlobe":return{globeOffset:a?.globeOffset,polygonAltitude:a?.polygonAltitude,highlightedIds:a?.highlightedIds,scale:a?.scale,theme:a?.theme,resetSelectionOnDoubleClick:a?.resetSelectionOnDoubleClick,graphTitle:a?.graphTitle,mapData:a?.mapData,graphDescription:a?.graphDescription,footNote:a?.footNote,width:a?.width,height:a?.height,sources:a?.sources,colorDomain:a?.colorDomain,colors:a?.colors,colorLegendTitle:Object.keys(a||{}).indexOf("colorLegendTitle")!==-1?a?.colorLegendTitle:c.getValues("x",C||[],n||[]),scaleType:a?.scaleType,data:g,centerPoint:a?.centerPoint,backgroundColor:a?.backgroundColor,mapNoDataColor:a?.mapNoDataColor,mapBorderColor:a?.mapBorderColor,relativeHeight:a?.relativeHeight,padding:a?.padding,tooltip:a?.tooltip,showColorScale:a?.showColorScale,graphID:a?.graphID,dataDownload:a?.dataDownload,mapProperty:a?.mapProperty,language:a?.language,minHeight:a?.minHeight,ariaLabel:a?.ariaLabel,onSeriesMouseClick:A=>{R?.(A.id)},detailsOnClick:a?.detailsOnClick,styles:a?.styles,classNames:a?.classNames,categorical:a?.categorical,autoRotate:a?.autoRotate,globeMaterial:a?.globeMaterial,atmosphereColor:a?.atmosphereColor,enableZoom:a?.enableZoom,atmosphereAltitude:a?.atmosphereAltitude,globeCurvatureResolution:a?.globeCurvatureResolution,lightColor:a?.lightColor,fogSettings:a?.fogSetting};default:return{}}},E=D[o],q=b(o);return r.jsxRuntimeExports.jsx("div",{className:`grow my-0 mx-auto flex flex-col h-inherit ${a?.width?"w-fit":"w-full"} justify-center ${a?.theme||"light"}`,style:{minHeight:"inherit"},children:E?r.jsxRuntimeExports.jsx(E,{...q}):r.jsxRuntimeExports.jsx(M.u,{size:"sm",marginBottom:"none",className:"p-2 text-center text-accent-dark-red dark:text-accent-red",children:`Invalid chart type: ${o}`})})}const F=(I,a)=>{const o=a?.map(g=>{const p=I?.findIndex(n=>n.chartConfigId===g.chartConfigId);if(p===-1)return{};const C=I[p]?.allowedColumnIds?.findIndex(n=>n.value===g.columnId);return C===-1?{}:I[p].allowedColumnIds[C].graphSettings||{}})||[];return Object.assign({},...o)};function ue(I){const{graphSettings:a,dataSettings:o,filters:g,graphType:p,dataTransform:C,graphDataConfiguration:n,dataFilters:R,debugMode:D,dataSelectionOptions:b,advancedDataSelectionOptions:E,readableHeader:q,noOfFiltersPerRow:d=4,updateFilters:A,uiMode:f="normal",highlightDataPointSettings:v}=I,[j,Q]=i.useState(void 0),[S,X]=i.useState(void 0),[w,y]=i.useState(n),[m,V]=i.useState({}),[k,Y]=i.useState(void 0),[_,ee]=i.useState([]),L=i.useRef(null),z=i.useRef(n),[T,U]=i.useState([]),N=i.useMemo(()=>({ignoreCase:!0,ignoreAccents:!0,trim:!0}),[]),Z=i.useCallback(async()=>{try{const u=await(o.dataURL?typeof o.dataURL=="string"?o.fileType==="json"?$.fetchAndParseJSON(o.dataURL,o.columnsToArray,o.dataTransformation,D):o.fileType==="api"?$.fetchAndTransformDataFromAPI(o.dataURL,o.apiHeaders,o.columnsToArray,o.dataTransformation,D):$.fetchAndParseCSV(o.dataURL,o.dataTransformation,o.columnsToArray,D,o.delimiter,!0):$.fetchAndParseMultipleDataSources(o.dataURL,o.idColumnTitle):$.transformColumnsToArray(o.data,o.columnsToArray));X(u);const t=(g||[]).map(l=>({filter:l.column,label:l.label||`Filter by ${l.column}`,singleSelect:l.singleSelect,clearable:l.clearable,defaultValue:K.transformDefaultValue(l.defaultValue),value:K.transformDefaultValue(l.defaultValue),availableValues:B.getUniqValue(u,l.column).filter(s=>!l.excludeValues?.includes(`${s}`)).map(s=>({value:s,label:s})),allowSelectAll:l.allowSelectAll,width:l.width}));U(t)}catch(e){console.error("Data fetching error:",e)}},[o,g,D]);i.useEffect(()=>{Z()},[Z]);const G=i.useMemo(()=>!S||T.length===0?S:S.filter(u=>T.every(t=>t.value&&H.flattenDeep([t.value]).length>0?te.intersection(H.flattenDeep([u[t.filter]]),H.flattenDeep([t.value]).map(l=>l.value)).length>0:!0)),[T,S]);i.useEffect(()=>{b&&V(F(b,n))},[b,n]),i.useEffect(()=>{S&&Q(G)},[G,S]),i.useEffect(()=>{v?.column&&G&&ee(B.getUniqValue(G,v.column).filter(e=>!v?.excludeValues?.includes(`${e}`)).map(e=>({value:e,label:e})))},[G,v]),i.useEffect(()=>{le.isEqual(z.current,n)||(y(n),z.current=n)},[n]);const O=i.useCallback((e,u)=>{U(t=>t.map(l=>l.filter===e?{...l,value:u}:l))},[]),ae=i.useMemo(()=>{if(!j)return;const e=w;return W.transformDataForGraph(C?W.transformDataForAggregation(J.filterData(j,R||[]),C.keyColumn,C.aggregationColumnsSetting):J.filterData(j,R||[]),p,e)},[p,w,j,R,C]);return o?r.jsxRuntimeExports.jsx("div",{className:`${a?.theme||"light"} flex ${a?.width?"w-fit grow-0":"w-full grow"}${a?.height?"":" h-full"}`,dir:a?.language==="he"||a?.language==="ar"?"rtl":void 0,children:r.jsxRuntimeExports.jsx("div",{className:r.mo(`${a?.backgroundColor?a?.backgroundColor===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${a?.language||"en"}`,a?.classNames?.graphContainer),style:{...a?.styles?.graphContainer||{},...a?.backgroundColor&&a?.backgroundColor!==!0?{backgroundColor:a?.backgroundColor}:{}},id:a?.graphID,ref:L,children:r.jsxRuntimeExports.jsx("div",{style:{padding:a?.backgroundColor?a?.padding||"1rem":a?.padding||0,flexGrow:1,display:"flex"},children:r.jsxRuntimeExports.jsx("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:j||ie.graphList.filter(e=>e.geoHubMapPresentation).map(e=>e.graphID).indexOf(p)!==-1?r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[m?.graphTitle||m?.graphDescription||a?.graphTitle||a?.graphDescription||a?.graphDownload||a?.dataDownload?r.jsxRuntimeExports.jsx(ne.GraphHeader,{styles:{title:m?.styles?.title||a?.styles?.title,description:m?.styles?.description||a?.styles?.description},classNames:{title:m?.classNames?.title||a?.classNames?.title,description:m?.classNames?.description||a?.classNames?.description},graphTitle:m?.graphTitle||a?.graphTitle,graphDescription:m?.graphDescription||a?.graphDescription,width:m?.width||a?.width,graphDownload:a?.graphDownload?L.current:void 0,dataDownload:a?.dataDownload&&j&&j.length>0?j:null}):null,T.length!==0||(b||[]).length!==0||(E||[]).length!==0||v?r.jsxRuntimeExports.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",alignItems:"flex-start",width:"100%"},children:[E?.map((e,u)=>r.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/d}% - ${(d-1)/d}rem)`,flexGrow:1,flexShrink:e.ui!=="radio"?0:1,minWidth:"240px"},children:[r.jsxRuntimeExports.jsx(c.f,{className:"mb-2",children:e.label||"Graph by"}),e.ui!=="radio"?r.jsxRuntimeExports.jsx(x.Za,{options:e.options.map(t=>({...t,value:t.label})),size:"sm",isClearable:!1,isSearchable:!0,variant:f,controlShouldRenderValue:!0,defaultValue:e.defaultValue?{...e.defaultValue,value:e.defaultValue?.label}:{...e.options[0],value:e.options[0].label},onChange:t=>{V(t?.graphSettings||{}),y(t?.dataConfiguration)}}):r.jsxRuntimeExports.jsx(c.fe,{defaultValue:e.defaultValue?.label||e.options[0].label,variant:f,onValueChange:t=>{const l=e.options[e.options.findIndex(s=>s.label===t)];V(l.graphSettings||{}),y(l.dataConfiguration)},children:e.options.map((t,l)=>r.jsxRuntimeExports.jsx(c.ve,{label:t.label,value:t.label},l))})]},u)),b?.map((e,u)=>r.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/d}% - ${(d-1)/d}rem)`,flexGrow:1,flexShrink:e.ui!=="radio"?0:1,minWidth:"240px"},children:[r.jsxRuntimeExports.jsx(c.f,{className:"mb-2",children:e.label||`Visualize ${e.chartConfigId} by`}),c.checkIfMultiple(e.chartConfigId,w||[])?e.ui!=="radio"?r.jsxRuntimeExports.jsx(x.Za,{options:e.allowedColumnIds,size:"sm",isMulti:!0,isSearchable:!0,variant:f,controlShouldRenderValue:!0,defaultValue:n?n[n.findIndex(t=>t.chartConfigId===e.chartConfigId)].columnId.map(t=>e.allowedColumnIds[e.allowedColumnIds.findIndex(l=>l.value===t)]):void 0,filterOption:x.Hu(N),onChange:t=>{const l={columnId:(t||[]).map(h=>h.value),chartConfigId:e.chartConfigId},s=w?.map(h=>h.chartConfigId===l.chartConfigId?l:h);y(s)}}):r.jsxRuntimeExports.jsx(c.w,{variant:f,defaultValue:n?n[n.findIndex(t=>t.chartConfigId===e.chartConfigId)].columnId.map(t=>e.allowedColumnIds[e.allowedColumnIds.findIndex(l=>l.value===t)]).map(t=>t.value):[],onValueChange:t=>{const l={columnId:t||[],chartConfigId:e.chartConfigId},s=w?.map(h=>h.chartConfigId===l.chartConfigId?l:h);y(s)},children:e.allowedColumnIds.map((t,l)=>r.jsxRuntimeExports.jsx(c.G,{label:t.label,value:t.label},l))}):e.ui!=="radio"?r.jsxRuntimeExports.jsx(x.Za,{options:e.allowedColumnIds,size:"sm",isClearable:!1,isSearchable:!0,variant:f,controlShouldRenderValue:!0,defaultValue:n?e.allowedColumnIds[e.allowedColumnIds.findIndex(t=>t.value===n[n.findIndex(l=>l.chartConfigId===e.chartConfigId)].columnId)]:void 0,onChange:t=>{const l={columnId:t?.value,chartConfigId:e.chartConfigId},s=w?.map(h=>h.chartConfigId===l.chartConfigId?l:h);V(F(b,s)),y(s)}}):r.jsxRuntimeExports.jsx(c.fe,{variant:f,defaultValue:n?e.allowedColumnIds[e.allowedColumnIds.findIndex(t=>t.value===n[n.findIndex(l=>l.chartConfigId===e.chartConfigId)].columnId)].label:"",onValueChange:t=>{const s={columnId:e.allowedColumnIds[e.allowedColumnIds.findIndex(P=>P.label===t)].value,chartConfigId:e.chartConfigId},h=w?.map(P=>P.chartConfigId===s.chartConfigId?s:P);V(F(b,h)),y(h)},children:e.allowedColumnIds.map((t,l)=>r.jsxRuntimeExports.jsx(c.ve,{label:t.label,value:t.label},l))})]},u)),T?.map((e,u)=>r.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/d}% - ${(d-1)/d}rem)`,flexGrow:1,flexShrink:0,minWidth:"240px"},children:[r.jsxRuntimeExports.jsx(c.f,{className:"mb-2",children:e.label}),e.singleSelect?r.jsxRuntimeExports.jsx(x.Za,{options:e.availableValues,variant:f,isClearable:e.clearable===void 0?!0:e.clearable,isSearchable:!0,controlShouldRenderValue:!0,filterOption:x.Hu(N),onChange:t=>{O(e.filter,t)},value:e.value,defaultValue:e.defaultValue}):r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[e.ui!=="radio"?r.jsxRuntimeExports.jsx(x.Za,{options:e.availableValues,variant:f,size:"sm",isMulti:!0,isClearable:e.clearable===void 0?!0:e.clearable,isSearchable:!0,controlShouldRenderValue:!0,filterOption:x.Hu(N),onChange:t=>{O(e.filter,t)},value:e.value,defaultValue:e.defaultValue}):r.jsxRuntimeExports.jsx(c.w,{variant:f,defaultValue:e.defaultValue?e.defaultValue.map(t=>`${t.value}`):[],value:e.value?e.value.map(t=>`${t.value}`):void 0,onValueChange:t=>{O(e.filter,e.availableValues.filter(l=>t.indexOf(`${l.value}`)!==-1))},children:e.availableValues.map((t,l)=>r.jsxRuntimeExports.jsx(c.G,{label:`${t.label}`,value:`${t.value}`},l))}),e.allowSelectAll?r.jsxRuntimeExports.jsx("button",{type:"button",className:"bg-transparent border-0 p-0 mt-2 cursor-pointer text-primary-blue-600 dark:text-primary-blue-400",onClick:()=>{O(e.filter,e.availableValues)},children:"Select all options"}):null]})]},u)),v?r.jsxRuntimeExports.jsxs("div",{style:{width:v.width||`calc(${100/d}% - ${(d-1)/d}rem)`,flexGrow:1,flexShrink:0,minWidth:"240px"},children:[r.jsxRuntimeExports.jsx(c.f,{className:"mb-2",children:v.label||"Highlight data"}),r.jsxRuntimeExports.jsx(x.Za,{options:_,variant:f,size:"sm",isMulti:!0,isClearable:!0,isSearchable:!0,controlShouldRenderValue:!0,filterOption:x.Hu(N),onChange:e=>{Y(e?.map(u=>u.value))},value:k?.map(e=>({label:e,value:e})),defaultValue:v.defaultValues?.map(e=>({label:e,value:e}))})]}):null]}):null,r.jsxRuntimeExports.jsx(se,{graph:p,graphData:ae,graphDataConfiguration:w,debugMode:D,readableHeader:q||[],updateFilters:A,settings:{...a||{},...m,graphTitle:void 0,graphDescription:void 0,graphDownload:!1,dataDownload:!1,backgroundColor:void 0,padding:"0",theme:a?.theme,...k?{highlightedDataPoints:k,highlightedIds:k?.map(e=>`${e}`),highlightedLines:k?.map(e=>e)}:{}}})]}):r.jsxRuntimeExports.jsx("div",{className:"w-full flex justify-center p-4",children:r.jsxRuntimeExports.jsx(re.y,{})})})})})}):r.jsxRuntimeExports.jsx(M.u,{size:"xs",className:"text-center text-accent-dark-red dark:text-accent-red p-2",children:"Please make sure either `dataSettings` props are present as they are required for data."})}exports.SingleGraphDashboardThreeDGraphs=ue;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-CHPV5EwG-DDoeWRVt.cjs"),i=require("react"),te=require("./index-Ds0uHjK9.cjs"),H=require("./index-B0rbzOoC.cjs"),le=require("./index-BXns0-ng.cjs"),x=require("./DropdownSelect-DBDM64B5.cjs"),c=require("./checkIfMultiple-BXbHUCWM.cjs"),M=require("./Typography-k-kOjICQ.cjs"),re=require("./Spinner-DA6Z5E4n.cjs"),oe=require("./ThreeDGlobe.cjs"),$=require("./fetchAndParseData-CQyVGCul.cjs"),W=require("./transformDataForAggregation-Du-Hei-W.cjs"),B=require("./getUniqValue-CHqgSss5.cjs"),ne=require("./GraphHeader.cjs"),J=require("./filterData-DN6py7y_.cjs"),ie=require("./getGraphList-gf02xgT2.cjs"),K=require("./transformDataForSelect-YmStusCI.cjs");function se(I){const{settings:a,graph:o,graphData:g,debugMode:p,graphDataConfiguration:C,readableHeader:n,updateFilters:R}=I;if(p&&(console.log(`Graph: ${o}`),console.log("Transformed data:",g),console.log("Settings:",a)),typeof g=="string")return r.jsxRuntimeExports.jsx("div",{className:`flex my-0 mx-auto grow flex-col justify-center ${a?.width?"w-fit":"w-full"}`,style:{height:"inherit"},children:r.jsxRuntimeExports.jsx(M.u,{size:"sm",marginBottom:"none",className:"p-2 text-center text-accent-dark-red dark:text-accent-red",children:g})});const D={threeDGlobe:oe.ThreeDGlobe},b=d=>{switch(d){case"threeDGlobe":return{globeOffset:a?.globeOffset,polygonAltitude:a?.polygonAltitude,highlightedIds:a?.highlightedIds,scale:a?.scale,theme:a?.theme,resetSelectionOnDoubleClick:a?.resetSelectionOnDoubleClick,graphTitle:a?.graphTitle,mapData:a?.mapData,graphDescription:a?.graphDescription,footNote:a?.footNote,width:a?.width,height:a?.height,sources:a?.sources,colorDomain:a?.colorDomain,colors:a?.colors,colorLegendTitle:Object.keys(a||{}).indexOf("colorLegendTitle")!==-1?a?.colorLegendTitle:c.getValues("x",C||[],n||[]),scaleType:a?.scaleType,data:g,centerPoint:a?.centerPoint,backgroundColor:a?.backgroundColor,mapNoDataColor:a?.mapNoDataColor,mapBorderColor:a?.mapBorderColor,relativeHeight:a?.relativeHeight,padding:a?.padding,tooltip:a?.tooltip,showColorScale:a?.showColorScale,graphID:a?.graphID,dataDownload:a?.dataDownload,mapProperty:a?.mapProperty,language:a?.language,minHeight:a?.minHeight,ariaLabel:a?.ariaLabel,onSeriesMouseClick:A=>{R?.(A.id)},detailsOnClick:a?.detailsOnClick,styles:a?.styles,classNames:a?.classNames,categorical:a?.categorical,autoRotate:a?.autoRotate,globeMaterial:a?.globeMaterial,atmosphereColor:a?.atmosphereColor,enableZoom:a?.enableZoom,atmosphereAltitude:a?.atmosphereAltitude,globeCurvatureResolution:a?.globeCurvatureResolution,lightColor:a?.lightColor,fogSettings:a?.fogSetting};default:return{}}},E=D[o],q=b(o);return r.jsxRuntimeExports.jsx("div",{className:`grow my-0 mx-auto flex flex-col h-inherit ${a?.width?"w-fit":"w-full"} justify-center ${a?.theme||"light"}`,style:{minHeight:"inherit"},children:E?r.jsxRuntimeExports.jsx(E,{...q}):r.jsxRuntimeExports.jsx(M.u,{size:"sm",marginBottom:"none",className:"p-2 text-center text-accent-dark-red dark:text-accent-red",children:`Invalid chart type: ${o}`})})}const F=(I,a)=>{const o=a?.map(g=>{const p=I?.findIndex(n=>n.chartConfigId===g.chartConfigId);if(p===-1)return{};const C=I[p]?.allowedColumnIds?.findIndex(n=>n.value===g.columnId);return C===-1?{}:I[p].allowedColumnIds[C].graphSettings||{}})||[];return Object.assign({},...o)};function ue(I){const{graphSettings:a,dataSettings:o,filters:g,graphType:p,dataTransform:C,graphDataConfiguration:n,dataFilters:R,debugMode:D,dataSelectionOptions:b,advancedDataSelectionOptions:E,readableHeader:q,noOfFiltersPerRow:d=4,updateFilters:A,uiMode:f="normal",highlightDataPointSettings:v}=I,[j,Q]=i.useState(void 0),[S,X]=i.useState(void 0),[w,y]=i.useState(n),[m,V]=i.useState({}),[k,Y]=i.useState(void 0),[_,ee]=i.useState([]),L=i.useRef(null),z=i.useRef(n),[T,U]=i.useState([]),N=i.useMemo(()=>({ignoreCase:!0,ignoreAccents:!0,trim:!0}),[]),Z=i.useCallback(async()=>{try{const u=await(o.dataURL?typeof o.dataURL=="string"?o.fileType==="json"?$.fetchAndParseJSON(o.dataURL,o.columnsToArray,o.dataTransformation,D):o.fileType==="api"?$.fetchAndTransformDataFromAPI(o.dataURL,o.apiHeaders,o.columnsToArray,o.dataTransformation,D):$.fetchAndParseCSV(o.dataURL,o.dataTransformation,o.columnsToArray,D,o.delimiter,!0):$.fetchAndParseMultipleDataSources(o.dataURL,o.idColumnTitle):$.transformColumnsToArray(o.data,o.columnsToArray));X(u);const t=(g||[]).map(l=>({filter:l.column,label:l.label||`Filter by ${l.column}`,singleSelect:l.singleSelect,clearable:l.clearable,defaultValue:K.transformDefaultValue(l.defaultValue),value:K.transformDefaultValue(l.defaultValue),availableValues:B.getUniqValue(u,l.column).filter(s=>!l.excludeValues?.includes(`${s}`)).map(s=>({value:s,label:s})),allowSelectAll:l.allowSelectAll,width:l.width}));U(t)}catch(e){console.error("Data fetching error:",e)}},[o,g,D]);i.useEffect(()=>{Z()},[Z]);const G=i.useMemo(()=>!S||T.length===0?S:S.filter(u=>T.every(t=>t.value&&H.flattenDeep([t.value]).length>0?te.intersection(H.flattenDeep([u[t.filter]]),H.flattenDeep([t.value]).map(l=>l.value)).length>0:!0)),[T,S]);i.useEffect(()=>{b&&V(F(b,n))},[b,n]),i.useEffect(()=>{S&&Q(G)},[G,S]),i.useEffect(()=>{v?.column&&G&&ee(B.getUniqValue(G,v.column).filter(e=>!v?.excludeValues?.includes(`${e}`)).map(e=>({value:e,label:e})))},[G,v]),i.useEffect(()=>{le.isEqual(z.current,n)||(y(n),z.current=n)},[n]);const O=i.useCallback((e,u)=>{U(t=>t.map(l=>l.filter===e?{...l,value:u}:l))},[]),ae=i.useMemo(()=>{if(!j)return;const e=w;return W.transformDataForGraph(C?W.transformDataForAggregation(J.filterData(j,R||[]),C.keyColumn,C.aggregationColumnsSetting):J.filterData(j,R||[]),p,e)},[p,w,j,R,C]);return o?r.jsxRuntimeExports.jsx("div",{className:`${a?.theme||"light"} flex ${a?.width?"w-fit grow-0":"w-full grow"}${a?.height?"":" h-full"}`,dir:a?.language==="he"||a?.language==="ar"?"rtl":void 0,children:r.jsxRuntimeExports.jsx("div",{className:r.mo(`${a?.backgroundColor?a?.backgroundColor===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${a?.language||"en"}`,a?.classNames?.graphContainer),style:{...a?.styles?.graphContainer||{},...a?.backgroundColor&&a?.backgroundColor!==!0?{backgroundColor:a?.backgroundColor}:{}},id:a?.graphID,ref:L,children:r.jsxRuntimeExports.jsx("div",{style:{padding:a?.backgroundColor?a?.padding||"1rem":a?.padding||0,flexGrow:1,display:"flex"},children:r.jsxRuntimeExports.jsx("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:j||ie.graphList.filter(e=>e.geoHubMapPresentation).map(e=>e.graphID).indexOf(p)!==-1?r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[m?.graphTitle||m?.graphDescription||a?.graphTitle||a?.graphDescription||a?.graphDownload||a?.dataDownload?r.jsxRuntimeExports.jsx(ne.GraphHeader,{styles:{title:m?.styles?.title||a?.styles?.title,description:m?.styles?.description||a?.styles?.description},classNames:{title:m?.classNames?.title||a?.classNames?.title,description:m?.classNames?.description||a?.classNames?.description},graphTitle:m?.graphTitle||a?.graphTitle,graphDescription:m?.graphDescription||a?.graphDescription,width:m?.width||a?.width,graphDownload:a?.graphDownload?L.current:void 0,dataDownload:a?.dataDownload&&j&&j.length>0?j:null}):null,T.length!==0||(b||[]).length!==0||(E||[]).length!==0||v?r.jsxRuntimeExports.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",alignItems:"flex-start",width:"100%"},children:[E?.map((e,u)=>r.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/d}% - ${(d-1)/d}rem)`,flexGrow:1,flexShrink:e.ui!=="radio"?0:1,minWidth:"240px"},children:[r.jsxRuntimeExports.jsx(c.f,{className:"mb-2",children:e.label||"Graph by"}),e.ui!=="radio"?r.jsxRuntimeExports.jsx(x.Za,{options:e.options.map(t=>({...t,value:t.label})),size:"sm",isClearable:!1,isSearchable:!0,variant:f,controlShouldRenderValue:!0,defaultValue:e.defaultValue?{...e.defaultValue,value:e.defaultValue?.label}:{...e.options[0],value:e.options[0].label},onChange:t=>{V(t?.graphSettings||{}),y(t?.dataConfiguration)}}):r.jsxRuntimeExports.jsx(c.fe,{defaultValue:e.defaultValue?.label||e.options[0].label,variant:f,onValueChange:t=>{const l=e.options[e.options.findIndex(s=>s.label===t)];V(l.graphSettings||{}),y(l.dataConfiguration)},children:e.options.map((t,l)=>r.jsxRuntimeExports.jsx(c.ve,{label:t.label,value:t.label},l))})]},u)),b?.map((e,u)=>r.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/d}% - ${(d-1)/d}rem)`,flexGrow:1,flexShrink:e.ui!=="radio"?0:1,minWidth:"240px"},children:[r.jsxRuntimeExports.jsx(c.f,{className:"mb-2",children:e.label||`Visualize ${e.chartConfigId} by`}),c.checkIfMultiple(e.chartConfigId,w||[])?e.ui!=="radio"?r.jsxRuntimeExports.jsx(x.Za,{options:e.allowedColumnIds,size:"sm",isMulti:!0,isSearchable:!0,variant:f,controlShouldRenderValue:!0,defaultValue:n?n[n.findIndex(t=>t.chartConfigId===e.chartConfigId)].columnId.map(t=>e.allowedColumnIds[e.allowedColumnIds.findIndex(l=>l.value===t)]):void 0,filterOption:x.Hu(N),onChange:t=>{const l={columnId:(t||[]).map(h=>h.value),chartConfigId:e.chartConfigId},s=w?.map(h=>h.chartConfigId===l.chartConfigId?l:h);y(s)}}):r.jsxRuntimeExports.jsx(c.w,{variant:f,defaultValue:n?n[n.findIndex(t=>t.chartConfigId===e.chartConfigId)].columnId.map(t=>e.allowedColumnIds[e.allowedColumnIds.findIndex(l=>l.value===t)]).map(t=>t.value):[],onValueChange:t=>{const l={columnId:t||[],chartConfigId:e.chartConfigId},s=w?.map(h=>h.chartConfigId===l.chartConfigId?l:h);y(s)},children:e.allowedColumnIds.map((t,l)=>r.jsxRuntimeExports.jsx(c.G,{label:t.label,value:t.label},l))}):e.ui!=="radio"?r.jsxRuntimeExports.jsx(x.Za,{options:e.allowedColumnIds,size:"sm",isClearable:!1,isSearchable:!0,variant:f,controlShouldRenderValue:!0,defaultValue:n?e.allowedColumnIds[e.allowedColumnIds.findIndex(t=>t.value===n[n.findIndex(l=>l.chartConfigId===e.chartConfigId)].columnId)]:void 0,onChange:t=>{const l={columnId:t?.value,chartConfigId:e.chartConfigId},s=w?.map(h=>h.chartConfigId===l.chartConfigId?l:h);V(F(b,s)),y(s)}}):r.jsxRuntimeExports.jsx(c.fe,{variant:f,defaultValue:n?e.allowedColumnIds[e.allowedColumnIds.findIndex(t=>t.value===n[n.findIndex(l=>l.chartConfigId===e.chartConfigId)].columnId)].label:"",onValueChange:t=>{const s={columnId:e.allowedColumnIds[e.allowedColumnIds.findIndex(P=>P.label===t)].value,chartConfigId:e.chartConfigId},h=w?.map(P=>P.chartConfigId===s.chartConfigId?s:P);V(F(b,h)),y(h)},children:e.allowedColumnIds.map((t,l)=>r.jsxRuntimeExports.jsx(c.ve,{label:t.label,value:t.label},l))})]},u)),T?.map((e,u)=>r.jsxRuntimeExports.jsxs("div",{style:{width:e.width||`calc(${100/d}% - ${(d-1)/d}rem)`,flexGrow:1,flexShrink:0,minWidth:"240px"},children:[r.jsxRuntimeExports.jsx(c.f,{className:"mb-2",children:e.label}),e.singleSelect?r.jsxRuntimeExports.jsx(x.Za,{options:e.availableValues,variant:f,isClearable:e.clearable===void 0?!0:e.clearable,isSearchable:!0,controlShouldRenderValue:!0,filterOption:x.Hu(N),onChange:t=>{O(e.filter,t)},value:e.value,defaultValue:e.defaultValue}):r.jsxRuntimeExports.jsxs(r.jsxRuntimeExports.Fragment,{children:[e.ui!=="radio"?r.jsxRuntimeExports.jsx(x.Za,{options:e.availableValues,variant:f,size:"sm",isMulti:!0,isClearable:e.clearable===void 0?!0:e.clearable,isSearchable:!0,controlShouldRenderValue:!0,filterOption:x.Hu(N),onChange:t=>{O(e.filter,t)},value:e.value,defaultValue:e.defaultValue}):r.jsxRuntimeExports.jsx(c.w,{variant:f,defaultValue:e.defaultValue?e.defaultValue.map(t=>`${t.value}`):[],value:e.value?e.value.map(t=>`${t.value}`):void 0,onValueChange:t=>{O(e.filter,e.availableValues.filter(l=>t.indexOf(`${l.value}`)!==-1))},children:e.availableValues.map((t,l)=>r.jsxRuntimeExports.jsx(c.G,{label:`${t.label}`,value:`${t.value}`},l))}),e.allowSelectAll?r.jsxRuntimeExports.jsx("button",{type:"button",className:"bg-transparent border-0 p-0 mt-2 cursor-pointer text-primary-blue-600 dark:text-primary-blue-400",onClick:()=>{O(e.filter,e.availableValues)},children:"Select all options"}):null]})]},u)),v?r.jsxRuntimeExports.jsxs("div",{style:{width:v.width||`calc(${100/d}% - ${(d-1)/d}rem)`,flexGrow:1,flexShrink:0,minWidth:"240px"},children:[r.jsxRuntimeExports.jsx(c.f,{className:"mb-2",children:v.label||"Highlight data"}),r.jsxRuntimeExports.jsx(x.Za,{options:_,variant:f,size:"sm",isMulti:!0,isClearable:!0,isSearchable:!0,controlShouldRenderValue:!0,filterOption:x.Hu(N),onChange:e=>{Y(e?.map(u=>u.value))},value:k?.map(e=>({label:e,value:e})),defaultValue:v.defaultValues?.map(e=>({label:e,value:e}))})]}):null]}):null,r.jsxRuntimeExports.jsx(se,{graph:p,graphData:ae,graphDataConfiguration:w,debugMode:D,readableHeader:q||[],updateFilters:A,settings:{...a||{},...m,graphTitle:void 0,graphDescription:void 0,graphDownload:!1,dataDownload:!1,backgroundColor:void 0,padding:"0",theme:a?.theme,...k?{highlightedDataPoints:k,highlightedIds:k?.map(e=>`${e}`),highlightedLines:k?.map(e=>e)}:{}}})]}):r.jsxRuntimeExports.jsx("div",{className:"w-full flex justify-center p-4",children:r.jsxRuntimeExports.jsx(re.y,{})})})})})}):r.jsxRuntimeExports.jsx(M.u,{size:"xs",className:"text-center text-accent-dark-red dark:text-accent-red p-2",children:"Please make sure either `dataSettings` props are present as they are required for data."})}exports.SingleGraphDashboardThreeDGraphs=ue;
|
|
2
2
|
//# sourceMappingURL=SingleGraphDashboardThreeDGraphs.cjs.map
|
|
@@ -3,7 +3,7 @@ import { useState as D, useRef as J, useMemo as M, useCallback as K, useEffect a
|
|
|
3
3
|
import { i as ue } from "./index-C1rRk_50.js";
|
|
4
4
|
import { f as z } from "./index-UV9hjG_S.js";
|
|
5
5
|
import { i as ce } from "./index-27yTRcko.js";
|
|
6
|
-
import { Z as S, H as R } from "./DropdownSelect-
|
|
6
|
+
import { Z as S, H as R } from "./DropdownSelect-CtOKZHD0.js";
|
|
7
7
|
import { g as he, f as F, a as Q, v as X, c as ge, w as Y, G as _ } from "./checkIfMultiple-ChTJk2Tk.js";
|
|
8
8
|
import { u as W } from "./Typography-Ctgfl1J5.js";
|
|
9
9
|
import { y as pe } from "./Spinner-C85UF28E.js";
|
package/dist/SlopeChart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),oi=require("./index-CZbIGs8q.cjs"),f=require("react"),si=require("./index-BXns0-ng.cjs"),ci=require("./Modal-tXZlLE5s.cjs"),xi=require("./Tooltip-n8z5bfav.cjs"),_=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),a=require("./Colors.cjs"),ui=require("./string2HTML-D2Avudmb.cjs"),ri=require("./Axis-DE7dSn1_.cjs"),li=require("./AxisTitle-CK9YeovX.cjs"),mi=require("./linear-BVckp9RD.cjs"),yi=require("./use-in-view-sQJZ_xDO.cjs"),b=require("./proxy-BHRoeZgd.cjs"),hi=require("./index-BW8iNx7E.cjs"),gi=require("./GraphFooter.cjs"),fi=require("./GraphHeader.cjs"),pi=require("./ColorLegendWithMouseOver.cjs"),di=require("./EmptyState-d8_8SxeW.cjs");function ji(J){const{data:r,width:O,height:E,showLabels:V,colors:o,colorDomain:n,radius:c,leftMargin:m,rightMargin:P,topMargin:W,bottomMargin:K,tooltip:G,onSeriesMouseOver:Y,axisTitles:q,highlightedDataPoints:u,selectedColor:A,minValue:U,maxValue:X,onSeriesMouseClick:D,resetSelectionOnDoubleClick:Q,detailsOnClick:g,styles:p,classNames:y,animate:s,dimmedOpacity:d,customLayers:F}=J,B=f.useRef(null),j=yi.useInView(B,{once:s.once,amount:s.amount}),[w,I]=f.useState(void 0),[k,M]=f.useState(void 0),[z,R]=f.useState(void 0),[S,T]=f.useState(void 0),$={top:W,bottom:K,left:m,right:P},v=O-$.left-$.right,h=E-$.top-$.bottom,C=Math.min(Math.min(...r.map(i=>i.y1)),Math.min(...r.map(i=>i.y2))),H=Math.max(Math.max(...r.map(i=>i.y1)),Math.max(...r.map(i=>i.y2))),x=mi.linear().domain([_.checkIfNullOrUndefined(U)?C>0?0:C:U,_.checkIfNullOrUndefined(X)?H>0?H:0:X]).range([h,0]).nice();return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(b.motion.svg,{width:`${O}px`,height:`${E}px`,viewBox:`0 0 ${O} ${E}`,className:"mx-auto",direction:"ltr",ref:B,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${$.left},${$.top})`,children:[e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(ri.Axis,{y1:0,y2:h,x1:c,x2:c,classNames:{axis:e.mo("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",y?.yAxis?.axis)}}),e.jsxRuntimeExports.jsx(li.AxisTitle,{x:c,y:h+15,style:p?.yAxis?.title,className:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",y?.yAxis?.title),text:q[0]})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(ri.Axis,{y1:0,y2:h,x1:v-c,x2:v-c,classNames:{axis:e.mo("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",y?.yAxis?.axis)}}),e.jsxRuntimeExports.jsx(li.AxisTitle,{x:v-c,y:h+15,style:p?.yAxis?.title,className:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",y?.yAxis?.title),text:q[1]})]}),F.filter(i=>i.position==="before").map(i=>i.layer),e.jsxRuntimeExports.jsx(hi.AnimatePresence,{children:r.map((i,N)=>e.jsxRuntimeExports.jsxs(b.motion.g,{variants:{initial:{opacity:A?i.color&&o[n.indexOf(`${i.color}`)]===A?1:d:w?w.label===i.label?1:d:u.length!==0?u.indexOf(i.label)!==-1?1:d:1},whileInView:{opacity:A?i.color&&o[n.indexOf(`${i.color}`)]===A?1:d:w?w.label===i.label?1:d:u.length!==0?u.indexOf(i.label)!==-1?1:d:1,transition:{duration:s.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},onMouseEnter:t=>{I(i),T(t.clientY),R(t.clientX),Y?.(i)},onMouseMove:t=>{I(i),T(t.clientY),R(t.clientX)},onMouseLeave:()=>{I(void 0),R(void 0),T(void 0),Y?.(void 0)},onClick:()=>{(D||g)&&(si.isEqual(k,i)&&Q?(M(void 0),D?.(void 0)):(M(i),D?.(i)))},children:[e.jsxRuntimeExports.jsx(b.motion.circle,{cx:c,variants:{initial:{cy:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{cy:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},r:c,style:{fillOpacity:.6}}),V?e.jsxRuntimeExports.jsx(b.motion.text,{variants:{initial:{y:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{y:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},style:{textAnchor:"end",...p?.yAxis?.labels||{}},className:e.mo("text-xs",y?.yAxis?.labels),x:5,dy:"0.33em",textAnchor:"end",dx:0-c-3,children:i.label}):u.length!==0&&u.indexOf(i.label)!==-1?e.jsxRuntimeExports.jsx(b.motion.text,{variants:{initial:{y:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{y:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},style:{textAnchor:"end",...p?.yAxis?.labels||{}},className:e.mo("text-xs",y?.yAxis?.labels),x:5,dy:"0.33em",dx:-3,children:i.label}):null,e.jsxRuntimeExports.jsx(b.motion.circle,{cx:v-c,variants:{initial:{cy:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{cy:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},r:c,style:{fillOpacity:.6}}),V?e.jsxRuntimeExports.jsx(b.motion.text,{variants:{initial:{y:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{y:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},style:{textAnchor:"start",...p?.yAxis?.labels||{}},className:e.mo("text-xs",y?.yAxis?.labels),x:v-5,dy:"0.33em",dx:c+3,children:i.label}):u.length!==0&&u.indexOf(i.label)!==-1?e.jsxRuntimeExports.jsx(b.motion.text,{variants:{initial:{y:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{y:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},style:{textAnchor:"start",...p?.yAxis?.labels||{}},className:e.mo("text-xs",y?.yAxis?.labels),x:v-5,dy:"0.33em",dx:3,children:i.label}):null,e.jsxRuntimeExports.jsx(b.motion.line,{x1:c,x2:v-c,variants:{initial:{y1:x(i.y1),y2:x(i.y1),stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray},whileInView:{y1:x(i.y1),y2:x(i.y2),stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,transition:{duration:s.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},className:y?.dataConnectors,style:{fill:"none",strokeWidth:1,...p?.dataConnectors}})]},N))}),F.filter(i=>i.position==="after").map(i=>i.layer)]})}),w&&G&&z&&S?e.jsxRuntimeExports.jsx(xi.Tooltip,{data:w,body:G,xPos:z,yPos:S,backgroundStyle:p?.tooltip,className:y?.tooltip}):null,g&&k!==void 0?e.jsxRuntimeExports.jsx(ci.X,{open:k!==void 0,onClose:()=>{M(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof g=="string"?{__html:ui.string2HTML(g,k)}:void 0,children:typeof g=="function"?g(k):null})}):null]})}function wi(J){const{data:r,graphTitle:O,colors:E,sources:V,graphDescription:o,showLabels:n=!1,height:c,width:m,footNote:P,colorDomain:W,colorLegendTitle:K,radius:G=5,axisTitles:Y=["",""],padding:q,backgroundColor:u=!1,leftMargin:A=50,rightMargin:U=50,topMargin:X=20,bottomMargin:D=20,tooltip:Q,relativeHeight:g,onSeriesMouseOver:p,showColorScale:y=!0,highlightedDataPoints:s=[],graphID:d,minValue:F,maxValue:B,onSeriesMouseClick:j,graphDownload:w=!1,dataDownload:I=!1,fillContainer:k=!0,language:M="en",showNAColor:z=!0,minHeight:R=0,theme:S="light",ariaLabel:T,resetSelectionOnDoubleClick:$=!0,detailsOnClick:v,styles:h,classNames:C,animate:H=!1,dimmedOpacity:x=.3,customLayers:i=[]}=J,[N,t]=f.useState(0),[Z,ii]=f.useState(0),[ni,ai]=f.useState(void 0),L=f.useRef(null),ti=f.useRef(null);return f.useEffect(()=>{const l=new ResizeObserver(ei=>{t(m||ei[0].target.clientWidth||620),ii(c||ei[0].target.clientHeight||480)});return L.current&&(ii(L.current.clientHeight||480),t(L.current.clientWidth||620),m||l.observe(L.current)),()=>l.disconnect()},[m,c]),e.jsxRuntimeExports.jsx("div",{className:`${S||"light"} flex ${m?"grow-0":"grow"} ${k?"w-full":"w-fit"} `,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${u?u===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,C?.graphContainer),style:{...h?.graphContainer||{},...u&&u!==!0?{backgroundColor:u}:{}},id:d,ref:ti,"aria-label":T||`${O?`The graph shows ${O}. `:""}This is a slope chart showing changes in data between two category or starting and ending time. Each line represents a different row in data, with lines sloping up or down to show increase or decrease over two categories or time.${o?` ${o}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:u?q||"1rem":q||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[O||o||w||I?e.jsxRuntimeExports.jsx(fi.GraphHeader,{styles:{title:h?.title,description:h?.description},classNames:{title:C?.title,description:C?.description},graphTitle:O,graphDescription:o,width:m,graphDownload:w?ti.current:void 0,dataDownload:I?r.map(l=>l.data).filter(l=>l!==void 0).length>0?r.map(l=>l.data).filter(l=>l!==void 0):r.filter(l=>l!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:r.length===0?e.jsxRuntimeExports.jsx(di.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[y&&r.filter(l=>l.color).length!==0?e.jsxRuntimeExports.jsx(pi.ColorLegendWithMouseOver,{width:m,colorLegendTitle:K,colors:E||a.Colors[S].categoricalColors.colors,colorDomain:W||oi.uniqBy(r.filter(l=>l.color),"color").map(l=>l.color),setSelectedColor:ai,showNAColor:z}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:L,"aria-label":"Graph area",children:(m||N)&&(c||Z)?e.jsxRuntimeExports.jsx(ji,{data:r.filter(l=>!_.checkIfNullOrUndefined(l.y1)&&!_.checkIfNullOrUndefined(l.y2)),width:m||N,height:Math.max(R,c||(g?R?(m||N)*g>R?(m||N)*g:R:(m||N)*g:Z)),colorDomain:r.filter(l=>l.color).length===0?[]:W||oi.uniqBy(r.filter(l=>l.color),"color").map(l=>l.color),colors:r.filter(l=>l.color).length===0?E?[E]:[a.Colors.primaryColors["blue-600"]]:E||a.Colors[S].categoricalColors.colors,selectedColor:ni,axisTitles:Y,showLabels:n,radius:G,leftMargin:A,rightMargin:U,topMargin:X,bottomMargin:D,tooltip:Q,onSeriesMouseOver:p,highlightedDataPoints:s,minValue:F,maxValue:B,onSeriesMouseClick:j,resetSelectionOnDoubleClick:$,detailsOnClick:v,styles:h,classNames:C,animate:H===!0?{duration:.5,once:!0,amount:.5}:H||{duration:0,once:!0,amount:0},dimmedOpacity:x,customLayers:i}):null})]})}),V||P?e.jsxRuntimeExports.jsx(gi.GraphFooter,{styles:{footnote:h?.footnote,source:h?.source},classNames:{footnote:C?.footnote,source:C?.source},sources:V,footNote:P,width:m}):null]})})})})}exports.SlopeChart=wi;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),oi=require("./index-CZbIGs8q.cjs"),f=require("react"),si=require("./index-BXns0-ng.cjs"),ci=require("./Modal-tXZlLE5s.cjs"),xi=require("./Tooltip-n8z5bfav.cjs"),_=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),a=require("./Colors.cjs"),ui=require("./string2HTML-D2Avudmb.cjs"),ri=require("./Axis-DE7dSn1_.cjs"),li=require("./AxisTitle-CK9YeovX.cjs"),mi=require("./linear-BVckp9RD.cjs"),yi=require("./use-in-view-sQJZ_xDO.cjs"),b=require("./proxy-BHRoeZgd.cjs"),hi=require("./index-BW8iNx7E.cjs"),gi=require("./GraphFooter.cjs"),fi=require("./GraphHeader.cjs"),pi=require("./ColorLegendWithMouseOver.cjs"),di=require("./EmptyState-d8_8SxeW.cjs");function wi(J){const{data:r,width:O,height:E,showLabels:V,colors:o,colorDomain:n,radius:c,leftMargin:m,rightMargin:P,topMargin:W,bottomMargin:K,tooltip:G,onSeriesMouseOver:Y,axisTitles:q,highlightedDataPoints:u,selectedColor:A,minValue:U,maxValue:X,onSeriesMouseClick:D,resetSelectionOnDoubleClick:Q,detailsOnClick:g,styles:p,classNames:y,animate:s,dimmedOpacity:d,customLayers:F}=J,B=f.useRef(null),w=yi.useInView(B,{once:s.once,amount:s.amount}),[j,I]=f.useState(void 0),[R,M]=f.useState(void 0),[z,$]=f.useState(void 0),[S,T]=f.useState(void 0),k={top:W,bottom:K,left:m,right:P},v=O-k.left-k.right,h=E-k.top-k.bottom,C=Math.min(Math.min(...r.map(i=>i.y1)),Math.min(...r.map(i=>i.y2))),H=Math.max(Math.max(...r.map(i=>i.y1)),Math.max(...r.map(i=>i.y2))),x=mi.linear().domain([_.checkIfNullOrUndefined(U)?C>0?0:C:U,_.checkIfNullOrUndefined(X)?H>0?H:0:X]).range([h,0]).nice();return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(b.motion.svg,{width:`${O}px`,height:`${E}px`,viewBox:`0 0 ${O} ${E}`,className:"mx-auto",direction:"ltr",ref:B,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${k.left},${k.top})`,children:[e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(ri.Axis,{y1:0,y2:h,x1:c,x2:c,classNames:{axis:e.mo("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",y?.yAxis?.axis)}}),e.jsxRuntimeExports.jsx(li.AxisTitle,{x:c,y:h+15,style:p?.yAxis?.title,className:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",y?.yAxis?.title),text:q[0]})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(ri.Axis,{y1:0,y2:h,x1:v-c,x2:v-c,classNames:{axis:e.mo("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",y?.yAxis?.axis)}}),e.jsxRuntimeExports.jsx(li.AxisTitle,{x:v-c,y:h+15,style:p?.yAxis?.title,className:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",y?.yAxis?.title),text:q[1]})]}),F.filter(i=>i.position==="before").map(i=>i.layer),e.jsxRuntimeExports.jsx(hi.AnimatePresence,{children:r.map((i,N)=>e.jsxRuntimeExports.jsxs(b.motion.g,{variants:{initial:{opacity:A?i.color&&o[n.indexOf(`${i.color}`)]===A?1:d:j?j.label===i.label?1:d:u.length!==0?u.indexOf(i.label)!==-1?1:d:1},whileInView:{opacity:A?i.color&&o[n.indexOf(`${i.color}`)]===A?1:d:j?j.label===i.label?1:d:u.length!==0?u.indexOf(i.label)!==-1?1:d:1,transition:{duration:s.duration}}},initial:"initial",animate:w?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},onMouseEnter:t=>{I(i),T(t.clientY),$(t.clientX),Y?.(i)},onMouseMove:t=>{I(i),T(t.clientY),$(t.clientX)},onMouseLeave:()=>{I(void 0),$(void 0),T(void 0),Y?.(void 0)},onClick:()=>{(D||g)&&(si.isEqual(R,i)&&Q?(M(void 0),D?.(void 0)):(M(i),D?.(i)))},children:[e.jsxRuntimeExports.jsx(b.motion.circle,{cx:c,variants:{initial:{cy:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{cy:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:w?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},r:c,style:{fillOpacity:.6}}),V?e.jsxRuntimeExports.jsx(b.motion.text,{variants:{initial:{y:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{y:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:w?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},style:{textAnchor:"end",...p?.yAxis?.labels||{}},className:e.mo("text-xs",y?.yAxis?.labels),x:5,dy:"0.33em",textAnchor:"end",dx:0-c-3,children:i.label}):u.length!==0&&u.indexOf(i.label)!==-1?e.jsxRuntimeExports.jsx(b.motion.text,{variants:{initial:{y:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{y:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:w?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},style:{textAnchor:"end",...p?.yAxis?.labels||{}},className:e.mo("text-xs",y?.yAxis?.labels),x:5,dy:"0.33em",dx:-3,children:i.label}):null,e.jsxRuntimeExports.jsx(b.motion.circle,{cx:v-c,variants:{initial:{cy:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{cy:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:w?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},r:c,style:{fillOpacity:.6}}),V?e.jsxRuntimeExports.jsx(b.motion.text,{variants:{initial:{y:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{y:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:w?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},style:{textAnchor:"start",...p?.yAxis?.labels||{}},className:e.mo("text-xs",y?.yAxis?.labels),x:v-5,dy:"0.33em",dx:c+3,children:i.label}):u.length!==0&&u.indexOf(i.label)!==-1?e.jsxRuntimeExports.jsx(b.motion.text,{variants:{initial:{y:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:0},whileInView:{y:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,opacity:1,transition:{duration:s.duration}}},initial:"initial",animate:w?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},style:{textAnchor:"start",...p?.yAxis?.labels||{}},className:e.mo("text-xs",y?.yAxis?.labels),x:v-5,dy:"0.33em",dx:3,children:i.label}):null,e.jsxRuntimeExports.jsx(b.motion.line,{x1:c,x2:v-c,variants:{initial:{y1:x(i.y1),y2:x(i.y1),stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray},whileInView:{y1:x(i.y1),y2:x(i.y2),stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:a.Colors.gray,transition:{duration:s.duration}}},initial:"initial",animate:w?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},className:y?.dataConnectors,style:{fill:"none",strokeWidth:1,...p?.dataConnectors}})]},N))}),F.filter(i=>i.position==="after").map(i=>i.layer)]})}),j&&G&&z&&S?e.jsxRuntimeExports.jsx(xi.Tooltip,{data:j,body:G,xPos:z,yPos:S,backgroundStyle:p?.tooltip,className:y?.tooltip}):null,g&&R!==void 0?e.jsxRuntimeExports.jsx(ci.X,{open:R!==void 0,onClose:()=>{M(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof g=="string"?{__html:ui.string2HTML(g,R)}:void 0,children:typeof g=="function"?g(R):null})}):null]})}function ji(J){const{data:r,graphTitle:O,colors:E,sources:V,graphDescription:o,showLabels:n=!1,height:c,width:m,footNote:P,colorDomain:W,colorLegendTitle:K,radius:G=5,axisTitles:Y=["",""],padding:q,backgroundColor:u=!1,leftMargin:A=50,rightMargin:U=50,topMargin:X=20,bottomMargin:D=20,tooltip:Q,relativeHeight:g,onSeriesMouseOver:p,showColorScale:y=!0,highlightedDataPoints:s=[],graphID:d,minValue:F,maxValue:B,onSeriesMouseClick:w,graphDownload:j=!1,dataDownload:I=!1,fillContainer:R=!0,language:M="en",showNAColor:z=!0,minHeight:$=0,theme:S="light",ariaLabel:T,resetSelectionOnDoubleClick:k=!0,detailsOnClick:v,styles:h,classNames:C,animate:H=!1,dimmedOpacity:x=.3,customLayers:i=[]}=J,[N,t]=f.useState(0),[Z,ii]=f.useState(0),[ni,ai]=f.useState(void 0),L=f.useRef(null),ti=f.useRef(null);return f.useEffect(()=>{const l=new ResizeObserver(ei=>{t(m||ei[0].target.clientWidth||620),ii(c||ei[0].target.clientHeight||480)});return L.current&&(ii(L.current.clientHeight||480),t(L.current.clientWidth||620),m||l.observe(L.current)),()=>l.disconnect()},[m,c]),e.jsxRuntimeExports.jsx("div",{className:`${S||"light"} flex ${m?"grow-0":"grow"} ${R?"w-full":"w-fit"} `,dir:M==="he"||M==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${u?u===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${M||"en"}`,R?"w-full":"w-fit",C?.graphContainer),style:{...h?.graphContainer||{},...u&&u!==!0?{backgroundColor:u}:{}},id:d,ref:ti,"aria-label":T||`${O?`The graph shows ${O}. `:""}This is a slope chart showing changes in data between two category or starting and ending time. Each line represents a different row in data, with lines sloping up or down to show increase or decrease over two categories or time.${o?` ${o}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:u?q||"1rem":q||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[O||o||j||I?e.jsxRuntimeExports.jsx(fi.GraphHeader,{styles:{title:h?.title,description:h?.description},classNames:{title:C?.title,description:C?.description},graphTitle:O,graphDescription:o,width:m,graphDownload:j?ti.current:void 0,dataDownload:I?r.map(l=>l.data).filter(l=>l!==void 0).length>0?r.map(l=>l.data).filter(l=>l!==void 0):r.filter(l=>l!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:r.length===0?e.jsxRuntimeExports.jsx(di.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[y&&r.filter(l=>l.color).length!==0?e.jsxRuntimeExports.jsx(pi.ColorLegendWithMouseOver,{width:m,colorLegendTitle:K,colors:E||a.Colors[S].categoricalColors.colors,colorDomain:W||oi.uniqBy(r.filter(l=>l.color),"color").map(l=>l.color),setSelectedColor:ai,showNAColor:z}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:L,"aria-label":"Graph area",children:(m||N)&&(c||Z)?e.jsxRuntimeExports.jsx(wi,{data:r.filter(l=>!_.checkIfNullOrUndefined(l.y1)&&!_.checkIfNullOrUndefined(l.y2)),width:m||N,height:Math.max($,c||(g?$?(m||N)*g>$?(m||N)*g:$:(m||N)*g:Z)),colorDomain:r.filter(l=>l.color).length===0?[]:W||oi.uniqBy(r.filter(l=>l.color),"color").map(l=>l.color),colors:r.filter(l=>l.color).length===0?E?[E]:[a.Colors.primaryColors["blue-600"]]:E||a.Colors[S].categoricalColors.colors,selectedColor:ni,axisTitles:Y,showLabels:n,radius:G,leftMargin:A,rightMargin:U,topMargin:X,bottomMargin:D,tooltip:Q,onSeriesMouseOver:p,highlightedDataPoints:s,minValue:F,maxValue:B,onSeriesMouseClick:w,resetSelectionOnDoubleClick:k,detailsOnClick:v,styles:h,classNames:C,animate:H===!0?{duration:.5,once:!0,amount:.5}:H||{duration:0,once:!0,amount:0},dimmedOpacity:x,customLayers:i}):null})]})}),V||P?e.jsxRuntimeExports.jsx(gi.GraphFooter,{styles:{footnote:h?.footnote,source:h?.source},classNames:{footnote:C?.footnote,source:C?.source},sources:V,footNote:P,width:m}):null]})})})})}exports.SlopeChart=ji;
|
|
2
2
|
//# sourceMappingURL=SlopeChart.cjs.map
|