@undp/data-viz 1.4.7 → 1.4.9
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 +58 -58
- package/dist/AreaChart.js.map +1 -1
- package/dist/DifferenceLineChart.cjs +1 -1
- package/dist/DifferenceLineChart.cjs.map +1 -1
- package/dist/DifferenceLineChart.js +44 -44
- package/dist/DifferenceLineChart.js.map +1 -1
- package/dist/DualAxisLineChart.cjs +1 -1
- package/dist/DualAxisLineChart.cjs.map +1 -1
- package/dist/DualAxisLineChart.js +1 -1
- package/dist/DualAxisLineChart.js.map +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
- package/dist/LineChartWithConfidenceInterval.js +33 -33
- package/dist/LineChartWithConfidenceInterval.js.map +1 -1
- package/dist/MultiLineAltChart.cjs +1 -1
- package/dist/MultiLineAltChart.cjs.map +1 -1
- package/dist/MultiLineAltChart.js +78 -78
- package/dist/MultiLineAltChart.js.map +1 -1
- package/dist/MultiLineChart.cjs +1 -1
- package/dist/MultiLineChart.cjs.map +1 -1
- package/dist/MultiLineChart.js +28 -28
- package/dist/MultiLineChart.js.map +1 -1
- package/dist/ScatterPlot.cjs +1 -1
- package/dist/ScatterPlot.cjs.map +1 -1
- package/dist/ScatterPlot.js +43 -43
- package/dist/ScatterPlot.js.map +1 -1
- package/dist/SimpleLineChart.cjs +1 -1
- package/dist/SimpleLineChart.cjs.map +1 -1
- package/dist/SimpleLineChart.js +17 -17
- package/dist/SimpleLineChart.js.map +1 -1
- package/dist/SparkLine.cjs +1 -1
- package/dist/SparkLine.cjs.map +1 -1
- package/dist/SparkLine.js +1 -1
- package/dist/SparkLine.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/AreaChart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AreaChart.js","sources":["../src/Components/Graphs/StackedAreaChart/Graph.tsx","../src/Components/Graphs/StackedAreaChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n curveMonotoneX,\r\n area,\r\n curveLinear,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport sortBy from 'lodash.sortby';\r\nimport sum from 'lodash.sum';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { AnimatePresence, 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 MultiLineChartDataType,\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 { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { RefLineY } from '@/Components/Elements/ReferenceLine';\r\nimport { Annotation } from '@/Components/Elements/Annotations';\r\nimport { YTicksAndGridLines } from '@/Components/Elements/Axes/YTicksAndGridLines';\r\nimport { CustomArea } from '@/Components/Elements/HighlightArea/customArea';\r\nimport { HighlightArea } from '@/Components/Elements/HighlightArea';\r\n\r\ninterface Props {\r\n data: MultiLineChartDataType[];\r\n colors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n rightMargin: number;\r\n leftMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n yAxisTitle?: string;\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 rtl: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n noOfYTicks: number;\r\n prefix: string;\r\n suffix: string;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n animate: AnimateDataType;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n colors,\r\n dateFormat,\r\n noOfXTicks,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n yAxisTitle,\r\n tooltip,\r\n onSeriesMouseOver,\r\n highlightAreaSettings,\r\n refValues,\r\n minValue,\r\n maxValue,\r\n rtl,\r\n annotations,\r\n customHighlightAreaSettings,\r\n noOfYTicks,\r\n prefix,\r\n suffix,\r\n curveType,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n animate,\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 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 dataArray = dataFormatted[0].y.map((_d, i) => {\r\n return dataFormatted.map(el => ({\r\n date: el.date,\r\n y0: i === 0 ? 0 : sum(el.y.filter((_element, k) => k < i)),\r\n y1: sum(el.y.filter((_element, k) => k <= i)),\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 = dataFormatted[0].date;\r\n const maxYear = dataFormatted[dataFormatted.length - 1].date;\r\n const minParam = checkIfNullOrUndefined(minValue) ? 0 : (minValue as number);\r\n const maxParam: number = checkIfNullOrUndefined(maxValue)\r\n ? Math.max(...data.map(d => sum(d.y) || 0))\r\n : (maxValue as number);\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear().domain([minParam, maxParam]).range([graphHeight, 0]).nice();\r\n\r\n const areaShape = area()\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .x((d: any) => x(d.date))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y0((d: any) => y(d.y0))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y1((d: any) => y(d.y1))\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 1,\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 onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\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 <AnimatePresence>\r\n <motion.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 animate={animate}\r\n areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\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 dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\r\n y: y(minParam < 0 ? 0 : minParam),\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-[8px] sm: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 <motion.g>\r\n {dataArray.map((d, i) => {\r\n return (\r\n <motion.path\r\n key={i}\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d={areaShape(d as any) as string}\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n d: areaShape(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.map(el => ({ ...el, y0: 0, y1: 0 })) as any,\r\n ) as string as string,\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d: areaShape(d as any) as string,\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 style={{\r\n fill: colors[i],\r\n opacity: 0.8,\r\n }}\r\n />\r\n );\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 </motion.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 cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n cy: d.yCoordinate ? y(d.yCoordinate as number) : 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 (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 {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 </motion.g>\r\n </AnimatePresence>\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 AreaChartDataType,\r\n CustomHighlightAreaSettingsDataType,\r\n Languages,\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 { ColorLegend } from '@/Components/Elements/ColorLegend';\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: AreaChartDataType[];\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 /** array of colors for different lines and areas */\r\n colors?: string[];\r\n /** Domain of colors for the graph */\r\n colorDomain: string[];\r\n /** Title for the color legend */\r\n colorLegendTitle?: 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 /** 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 /** 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 /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\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 /** 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 /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\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 AreaChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n colorDomain,\r\n padding,\r\n backgroundColor = false,\r\n colorLegendTitle,\r\n leftMargin = 50,\r\n rightMargin = 20,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n highlightAreaSettings = [],\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n refValues = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n showColorScale = true,\r\n language = 'en',\r\n minHeight = 0,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n prefix = '',\r\n suffix = '',\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n precision = 2,\r\n customLayers = [],\r\n animate = false,\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n 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 stacked area 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 <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n {data.length === 0 ? (\r\n <EmptyState />\r\n ) : (\r\n <>\r\n {showColorScale !== false ? (\r\n <ColorLegend\r\n colorDomain={colorDomain}\r\n colors={colors}\r\n colorLegendTitle={colorLegendTitle}\r\n showNAColor={false}\r\n />\r\n ) : null}\r\n <div className='w-full grow leading-0' ref={graphDiv} aria-label='Graph area'>\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n colors={colors}\r\n width={width || svgWidth}\r\n height={Math.max(\r\n minHeight,\r\n height ||\r\n (relativeHeight\r\n ? minHeight\r\n ? (width || svgWidth) * relativeHeight > minHeight\r\n ? (width || svgWidth) * relativeHeight\r\n : minHeight\r\n : (width || svgWidth) * relativeHeight\r\n : svgHeight),\r\n )}\r\n dateFormat={dateFormat}\r\n noOfXTicks={noOfXTicks}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n rtl={language === 'he' || language === 'ar'}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n prefix={prefix}\r\n suffix={suffix}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n precision={precision}\r\n customLayers={customLayers}\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 />\r\n ) : null}\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n"],"names":["Graph","props","data","width","height","colors","dateFormat","noOfXTicks","rightMargin","leftMargin","topMargin","bottomMargin","yAxisTitle","tooltip","onSeriesMouseOver","highlightAreaSettings","refValues","minValue","maxValue","rtl","annotations","customHighlightAreaSettings","noOfYTicks","prefix","suffix","curveType","styles","classNames","precision","customLayers","animate","svgRef","useRef","isInView","useInView","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","dataFormatted","sortBy","d","parse","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","el","j","dataArray","_d","i","sum","_element","k","graphWidth","graphHeight","minYear","maxYear","minParam","checkIfNullOrUndefined","maxParam","x","scaleTime","y","scaleLinear","areaShape","area","yTicks","xTicks","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","AnimatePresence","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","AreaChart","graphTitle","Colors","sources","graphDescription","footNote","colorDomain","padding","backgroundColor","colorLegendTitle","relativeHeight","graphID","graphDownload","dataDownload","showColorScale","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","ColorLegend","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EO,SAASA,GAAMC,IAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,KAAAC;AAAA,IACA,aAAAC;AAAA,IACA,6BAAAC;AAAA,IACA,YAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,SAAAC;AAAA,EAAA,IACE7B,IACE8B,IAASC,GAAO,IAAI,GACpBC,IAAWC,GAAUH,GAAQ;AAAA,IACjC,MAAMD,EAAQ;AAAA,IACd,QAAQA,EAAQ;AAAA,EAAA,CACjB,GACKK,KACJV,MAAc,WACVW,KACAX,MAAc,SACZY,KACAZ,MAAc,cACZa,KACAb,MAAc,eACZc,KACAC,IAEN,CAACC,GAAeC,CAAgB,IAAIC,EAAc,MAAS,GAC3D,CAACC,GAAQC,CAAS,IAAIF,EAA6B,MAAS,GAC5D,CAACG,GAAQC,CAAS,IAAIJ,E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,YAAAU;AAAA,sBACA,QAAAC;AAAA,sBACA,QAAAC;AAAA,sBACA,WAAAC;AAAA,sBACA,QAAAC;AAAA,sBACA,YAAAC;AAAA,sBACA,WAAAC;AAAA,sBACA,cAAAC;AAAA,sBACA,SACEC,MAAY,KACR,EAAE,UAAU,KAAK,MAAM,IAAM,QAAQ,IAAA,IACrCA,KAAW,EAAE,UAAU,GAAG,MAAM,IAAM,QAAQ,EAAA;AAAA,oBAAE;AAAA,kBAAA,IAGtD,KAAA,CACN;AAAA,gBAAA,EAAA,CACF,EAAA,CAEJ;AAAA,gBACCiF,KAAWE,IACVxB,gBAAAA,EAAAA;AAAAA,kBAACiD;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAUhH,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,OAAA9G;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":"AreaChart.js","sources":["../src/Components/Graphs/StackedAreaChart/Graph.tsx","../src/Components/Graphs/StackedAreaChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n curveMonotoneX,\r\n area,\r\n curveLinear,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport sortBy from 'lodash.sortby';\r\nimport sum from 'lodash.sum';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { AnimatePresence, 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 MultiLineChartDataType,\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 { AxisTitle } from '@/Components/Elements/Axes/AxisTitle';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { RefLineY } from '@/Components/Elements/ReferenceLine';\r\nimport { Annotation } from '@/Components/Elements/Annotations';\r\nimport { YTicksAndGridLines } from '@/Components/Elements/Axes/YTicksAndGridLines';\r\nimport { CustomArea } from '@/Components/Elements/HighlightArea/customArea';\r\nimport { HighlightArea } from '@/Components/Elements/HighlightArea';\r\n\r\ninterface Props {\r\n data: MultiLineChartDataType[];\r\n colors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n rightMargin: number;\r\n leftMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n yAxisTitle?: string;\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 rtl: boolean;\r\n annotations: AnnotationSettingsDataType[];\r\n customHighlightAreaSettings: CustomHighlightAreaSettingsDataType[];\r\n noOfYTicks: number;\r\n prefix: string;\r\n suffix: string;\r\n curveType: CurveTypes;\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n animate: AnimateDataType;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n colors,\r\n dateFormat,\r\n noOfXTicks,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n yAxisTitle,\r\n tooltip,\r\n onSeriesMouseOver,\r\n highlightAreaSettings,\r\n refValues,\r\n minValue,\r\n maxValue,\r\n rtl,\r\n annotations,\r\n customHighlightAreaSettings,\r\n noOfYTicks,\r\n prefix,\r\n suffix,\r\n curveType,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n animate,\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 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 dataArray = dataFormatted[0].y.map((_d, i) => {\r\n return dataFormatted.map(el => ({\r\n date: el.date,\r\n y0: i === 0 ? 0 : sum(el.y.filter((_element, k) => k < i)),\r\n y1: sum(el.y.filter((_element, k) => k <= i)),\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 = dataFormatted[0].date;\r\n const maxYear = dataFormatted[dataFormatted.length - 1].date;\r\n const minParam = checkIfNullOrUndefined(minValue) ? 0 : (minValue as number);\r\n const maxParam: number = checkIfNullOrUndefined(maxValue)\r\n ? Math.max(...data.map(d => sum(d.y) || 0))\r\n : (maxValue as number);\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear().domain([minParam, maxParam]).range([graphHeight, 0]).nice();\r\n\r\n const areaShape = area()\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .x((d: any) => x(d.date))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y0((d: any) => y(d.y0))\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .y1((d: any) => y(d.y1))\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 onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\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 <AnimatePresence>\r\n <motion.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 animate={animate}\r\n areaSettings={customHighlightAreaSettingsFormatted}\r\n scaleX={x}\r\n scaleY={y}\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 dx: 0,\r\n dy: maxParam < 0 ? '1em' : -5,\r\n y: y(minParam < 0 ? 0 : minParam),\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-[8px] sm: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 <motion.g>\r\n {dataArray.map((d, i) => {\r\n return (\r\n <motion.path\r\n key={i}\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d={areaShape(d as any) as string}\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n d: areaShape(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d.map(el => ({ ...el, y0: 0, y1: 0 })) as any,\r\n ) as string as string,\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n d: areaShape(d as any) as string,\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 style={{\r\n fill: colors[i],\r\n opacity: 0.8,\r\n }}\r\n />\r\n );\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 </motion.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 cx: d.xCoordinate ? x(parse(`${d.xCoordinate}`, dateFormat, new Date())) : 0,\r\n cy: d.yCoordinate ? y(d.yCoordinate as number) : 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 {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 </motion.g>\r\n </AnimatePresence>\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 AreaChartDataType,\r\n CustomHighlightAreaSettingsDataType,\r\n Languages,\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 { ColorLegend } from '@/Components/Elements/ColorLegend';\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: AreaChartDataType[];\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 /** array of colors for different lines and areas */\r\n colors?: string[];\r\n /** Domain of colors for the graph */\r\n colorDomain: string[];\r\n /** Title for the color legend */\r\n colorLegendTitle?: 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 /** 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 /** 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 /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\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 /** 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 /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\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 AreaChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n colors = Colors.light.categoricalColors.colors,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n noOfXTicks = 10,\r\n dateFormat = 'yyyy',\r\n colorDomain,\r\n padding,\r\n backgroundColor = false,\r\n colorLegendTitle,\r\n leftMargin = 50,\r\n rightMargin = 20,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n highlightAreaSettings = [],\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n refValues = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n graphDownload = false,\r\n dataDownload = false,\r\n showColorScale = true,\r\n language = 'en',\r\n minHeight = 0,\r\n annotations = [],\r\n customHighlightAreaSettings = [],\r\n theme = 'light',\r\n ariaLabel,\r\n yAxisTitle,\r\n noOfYTicks = 5,\r\n prefix = '',\r\n suffix = '',\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n precision = 2,\r\n customLayers = [],\r\n animate = false,\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n 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 stacked area 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 <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n {data.length === 0 ? (\r\n <EmptyState />\r\n ) : (\r\n <>\r\n {showColorScale !== false ? (\r\n <ColorLegend\r\n colorDomain={colorDomain}\r\n colors={colors}\r\n colorLegendTitle={colorLegendTitle}\r\n showNAColor={false}\r\n />\r\n ) : null}\r\n <div className='w-full grow leading-0' ref={graphDiv} aria-label='Graph area'>\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={data}\r\n colors={colors}\r\n width={width || svgWidth}\r\n height={Math.max(\r\n minHeight,\r\n height ||\r\n (relativeHeight\r\n ? minHeight\r\n ? (width || svgWidth) * relativeHeight > minHeight\r\n ? (width || svgWidth) * relativeHeight\r\n : minHeight\r\n : (width || svgWidth) * relativeHeight\r\n : svgHeight),\r\n )}\r\n dateFormat={dateFormat}\r\n noOfXTicks={noOfXTicks}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n rtl={language === 'he' || language === 'ar'}\r\n annotations={annotations}\r\n customHighlightAreaSettings={customHighlightAreaSettings}\r\n yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n prefix={prefix}\r\n suffix={suffix}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n precision={precision}\r\n customLayers={customLayers}\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 />\r\n ) : null}\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{ footnote: styles?.footnote, source: styles?.source }}\r\n classNames={{\r\n footnote: classNames?.footnote,\r\n source: classNames?.source,\r\n }}\r\n sources={sources}\r\n footNote={footNote}\r\n width={width}\r\n />\r\n ) : null}\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n );\r\n}\r\n"],"names":["Graph","props","data","width","height","colors","dateFormat","noOfXTicks","rightMargin","leftMargin","topMargin","bottomMargin","yAxisTitle","tooltip","onSeriesMouseOver","highlightAreaSettings","refValues","minValue","maxValue","rtl","annotations","customHighlightAreaSettings","noOfYTicks","prefix","suffix","curveType","styles","classNames","precision","customLayers","animate","svgRef","useRef","isInView","useInView","curve","curveLinear","curveStep","curveStepAfter","curveStepBefore","curveMonotoneX","mouseOverData","setMouseOverData","useState","eventX","setEventX","eventY","setEventY","margin","MouseoverRectRef","dataFormatted","sortBy","d","parse","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","el","j","dataArray","_d","i","sum","_element","k","graphWidth","graphHeight","minYear","maxYear","minParam","checkIfNullOrUndefined","maxParam","x","scaleTime","y","scaleLinear","areaShape","area","yTicks","xTicks","useEffect","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","AnimatePresence","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","AreaChart","graphTitle","Colors","sources","graphDescription","footNote","colorDomain","padding","backgroundColor","colorLegendTitle","relativeHeight","graphID","graphDownload","dataDownload","showColorScale","language","minHeight","theme","ariaLabel","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","ColorLegend","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EO,SAASA,GAAMC,IAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,I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AAA;AAAA,oBACC,QAAQ,EAAE,UAAUhH,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,OAAA9G;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 e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),m=require("./parse-hMnG_lRV.cjs"),qt=require("./index-BzeLQvXk.cjs"),Et=require("./numberFormattingFunction-02t-wJta.cjs"),Tt=require("./Tooltip-n8z5bfav.cjs"),T=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),bt=require("./customArea-CK768gCn.cjs"),Mt=require("./AxisTitle-CK9YeovX.cjs"),Ft=require("./Axis-DE7dSn1_.cjs"),Pt=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Gt=require("./ReferenceLine-CFVBBN__.cjs"),Ht=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Wt=require("./index-DNj994Pv.cjs"),Yt=require("./time-Byw_jYQ7.cjs"),Xt=require("./linear-BVckp9RD.cjs"),At=require("./line-DHV4JwCR.cjs"),ht=require("./step-BZ3C8QFW.cjs"),Ct=require("./area-D3Qx7k7K.cjs"),Ut=require("./select-Bnfk0lJx.cjs"),Bt=require("./init-DU0ybBc_.cjs"),zt=require("./pointer-Dkq5NV1q.cjs"),Jt=require("./use-in-view-sQJZ_xDO.cjs"),g=require("./proxy-BHRoeZgd.cjs"),Kt=require("./GraphFooter.cjs"),Qt=require("./GraphHeader.cjs"),Zt=require("./ColorLegend.cjs"),pt=require("./Colors.cjs"),_t=require("./generateRandomString-B5zBiJzS.cjs"),te=require("./EmptyState-d8_8SxeW.cjs");function ee(dt){const{data:V,width:O,height:G,lineColors:f,suffix:D,prefix:w,dateFormat:o,showValues:l,noOfXTicks:z,rightMargin:yt,leftMargin:R,topMargin:gt,bottomMargin:J,tooltip:H,highlightAreaSettings:N,onSeriesMouseOver:W,animate:n,rtl:K,showColorLegendAtTop:ft,colorDomain:M,diffAreaColors:Q,idSuffix:E,strokeWidth:Z,showDots:_,refValues:Y,minValue:k,maxValue:X,annotations:L,customHighlightAreaSettings:F,yAxisTitle:U,noOfYTicks:tt,minDate:et,maxDate:it,curveType:P,styles:h,classNames:p,precision:S,customLayers:nt}=dt,at=d.useRef(null),r=Jt.useInView(at,{once:n.once,amount:n.amount}),[c,jt]=d.useState(!1);d.useEffect(()=>{if(r&&!c){const t=setTimeout(()=>{jt(!0)},(n.duration+.5)*1e3);return()=>clearTimeout(t)}},[r,c,n.duration]);const $=P==="linear"?At.curveLinear:P==="step"?ht.curveStep:P==="stepAfter"?ht.stepAfter:P==="stepBefore"?ht.stepBefore:ht.monotoneX,[q,st]=d.useState(void 0),[ot,rt]=d.useState(void 0),[b,A]=d.useState(void 0),j={top:gt,bottom:J,left:U?R+30:R,right:yt},lt=d.useRef(null),i=qt.sortBy(V.map(t=>({...t,date:m.parse(`${t.date}`,o,new Date)})),"date"),ct=N.map(t=>({...t,coordinates:[t.coordinates[0]===null?null:m.parse(`${t.coordinates[0]}`,o,new Date),t.coordinates[1]===null?null:m.parse(`${t.coordinates[1]}`,o,new Date)]})),xt=F.map(t=>({...t,coordinates:t.coordinates.map((v,I)=>I%2===0?m.parse(`${v}`,o,new Date):v)})),x=O-j.left-j.right,y=G-j.top-j.bottom,ut=et?m.parse(`${et}`,o,new Date):i[0].date,u=it?m.parse(`${it}`,o,new Date):i[i.length-1].date,B=Math.min(...i.map(t=>t.y1))!==1/0?Math.min(...i.map(t=>t.y1))>0?0:Math.min(...i.map(t=>t.y1)):0,Ot=Math.min(...i.map(t=>t.y2))!==1/0?Math.min(...i.map(t=>t.y2))>0?0:Math.min(...i.map(t=>t.y2)):0,Nt=Math.max(...i.map(t=>t.y1))!==1/0?Math.max(...i.map(t=>t.y1)):0,It=Math.max(...i.map(t=>t.y2))!==1/0?Math.max(...i.map(t=>t.y2)):0,C=T.checkIfNullOrUndefined(k)?B<Ot?B:Ot:k,wt=Nt>It?Nt:It,a=Yt.time().domain([ut,u]).range([0,x]),s=Xt.linear().domain([T.checkIfNullOrUndefined(k)?C:k,T.checkIfNullOrUndefined(X)?wt>0?wt:0:X]).range([y,0]).nice(),vt=At.line().x(t=>a(t.date)).y(t=>s(t.y1)).curve($),Vt=At.line().x(t=>a(t.date)).y(t=>s(t.y2)).curve($),Dt=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(t=>s(t.y2)).curve($),St=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(0).curve($),$t=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y2)).y0(0).curve($),kt=s.ticks(tt),Lt=a.ticks(z);return d.useEffect(()=>{const t=I=>{const mt=i[Bt.bisectCenter(i.map(Rt=>Rt.date),a.invert(zt.pointer(I)[0]),1)];st(mt||i[i.length-1]),W?.(mt||i[i.length-1]),A(I.clientY),rt(I.clientX)},v=()=>{st(void 0),rt(void 0),A(void 0),W?.(void 0)};Ut.select(lt.current).on("mousemove",t).on("mouseout",v)},[a,i,W]),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(g.motion.svg,{width:`${O}px`,height:`${G}px`,viewBox:`0 0 ${O} ${G}`,direction:"ltr",ref:at,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${j.left},${j.top})`,children:[e.jsxRuntimeExports.jsx("clipPath",{id:`above${E}`,children:e.jsxRuntimeExports.jsx("path",{d:$t(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx("clipPath",{id:`below${E}`,children:e.jsxRuntimeExports.jsx("path",{d:St(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx(Wt.HighlightArea,{areaSettings:ct,width:x,height:y,scale:a,animate:n,isInView:r}),e.jsxRuntimeExports.jsx(bt.CustomArea,{areaSettings:xt,scaleX:a,scaleY:s,animate:n,isInView:r}),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(Ht.YTicksAndGridLines,{values:kt.filter(t=>t!==0),y:kt.filter(t=>t!==0).map(t=>s(t)),x1:0-R,x2:x+j.right,styles:{gridLines:h?.yAxis?.gridLines,labels:h?.yAxis?.labels},classNames:{gridLines:p?.yAxis?.gridLines,labels:p?.yAxis?.labels},suffix:D,prefix:w,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:S}),e.jsxRuntimeExports.jsx(Ft.Axis,{y1:s(C<0?0:C),y2:s(C<0?0:C),x1:0-R,x2:x+j.right,label:Et.numberFormattingFunction(C<0?0:C,"NA",S,w,D),labelPos:{x:0-R,y:s(C<0?0:C),dx:0,dy:wt<0?"1rem":-5},classNames:{axis:p?.xAxis?.axis,label:p?.yAxis?.labels},styles:{axis:h?.xAxis?.axis,label:h?.yAxis?.labels}}),e.jsxRuntimeExports.jsx(Mt.AxisTitle,{x:0-R-15,y:y/2,style:h?.yAxis?.title,className:p?.yAxis?.title,text:U,rotate90:!0})]})}),e.jsxRuntimeExports.jsx(Pt.XTicksAndGridLines,{values:Lt.map(t=>m.format(t,o)),x:Lt.map(t=>a(t)),y1:0,y2:y,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:e.mo("opacity-0",p?.xAxis?.gridLines),labels:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs",p?.xAxis?.labels)},suffix:D,prefix:w,labelType:"primary",showGridLines:!0,precision:S}),nt.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(g.motion.path,{clipPath:`url(#below${E})`,d:Dt(i)||"",style:{fill:Q[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:1},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(g.motion.path,{clipPath:`url(#above${E})`,d:Dt(i)||"",style:{fill:Q[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(g.motion.path,{d:vt(i)||"",style:{fill:"none",stroke:f[0],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:vt(i)||"",opacity:1},whileInView:{pathLength:1,d:vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(g.motion.path,{style:{fill:"none",stroke:f[1],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:Vt(i)||"",opacity:1},whileInView:{pathLength:1,d:Vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),ft?null:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(g.motion.text,{style:{fill:f[0]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y1)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[0]},M[0]),e.jsxRuntimeExports.jsx(g.motion.text,{style:{fill:f[1]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y2)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[1]},M[1])]}),q?e.jsxRuntimeExports.jsx("line",{y1:0,y2:y,x1:a(q.date),x2:a(q.date),className:e.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",p?.mouseOverLine),style:h?.mouseOverLine}):null,i.map((t,v)=>e.jsxRuntimeExports.jsxs(g.motion.g,{children:[T.checkIfNullOrUndefined(t.y1)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(g.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:f[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y1)},whileInView:{opacity:1,transition:{duration:.5,delay:n.duration},cx:a(t.date),cy:s(t.y1)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(g.motion.text,{dy:t.y2<t.y1?-8:"1em",style:{fill:f[0],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-1 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y1)},whileInView:{opacity:1,x:a(t.date),y:s(t.y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y1,"NA",S,w,D)}):null]}),T.checkIfNullOrUndefined(t.y2)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(g.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:f[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y2)},whileInView:{opacity:1,transition:{duration:c?n.duration:.5,delay:c?0:n.duration},cx:a(t.date),cy:s(t.y2)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(g.motion.text,{dy:t.y2>t.y1?-8:"1em",style:{fill:f[1],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-2 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y2)},whileInView:{opacity:1,x:a(t.date),y:s(t.y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y2,"NA",S,w,D)}):null]})]},v))]}),Y?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Y.map((t,v)=>e.jsxRuntimeExports.jsx(Gt.RefLineY,{text:t.text,color:t.color,y:s(t.value),x1:0-R,x2:x+j.right,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v))}):null,e.jsxRuntimeExports.jsx("g",{children:L.map((t,v)=>{const I=bt.getLineEndPoint({x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8},{x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,y:t.yCoordinate?s(t.yCoordinate):0},T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius),mt=t.showConnector?{y1:I.y,x1:I.x,y2:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0):0+(t.yOffset||0),x2:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),cy:t.yCoordinate?s(t.yCoordinate):0,cx:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,circleRadius:T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius,strokeWidth:t.showConnector===!0?2:Math.min(t.showConnector||0,1)}:void 0,Rt={y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8,x:K?0:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),width:K?t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0):x-(t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0)),maxWidth:t.maxWidth,fontWeight:t.fontWeight,align:t.align};return e.jsxRuntimeExports.jsx(bt.Annotation,{color:t.color,connectorsSettings:mt,labelSettings:Rt,text:t.text,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v)})}),nt.filter(t=>t.position==="after").map(t=>t.layer),e.jsxRuntimeExports.jsx("rect",{ref:lt,style:{fill:"none",pointerEvents:"all"},width:x,height:y})]})}),q&&H&&ot&&b?e.jsxRuntimeExports.jsx(Tt.Tooltip,{data:q,body:H,xPos:ot,yPos:b,backgroundStyle:h?.tooltip,className:p?.tooltip}):null]})}function ie(dt){const{data:V,graphTitle:O,suffix:G="",sources:f,prefix:D="",graphDescription:w,height:o,width:l,footNote:z,noOfXTicks:yt=10,dateFormat:R="yyyy",showValues:gt=!1,padding:J,lineColors:H=[pt.Colors.light.categoricalColors.colors[0],pt.Colors.light.categoricalColors.colors[1]],backgroundColor:N=!1,leftMargin:W=30,rightMargin:n=50,topMargin:K=20,bottomMargin:ft=25,tooltip:M,highlightAreaSettings:Q=[],relativeHeight:E,onSeriesMouseOver:Z,graphID:_,graphDownload:Y=!1,dataDownload:k=!1,animate:X=!1,language:L="en",minHeight:F=0,labels:U,showColorLegendAtTop:tt=!1,colorLegendTitle:et,diffAreaColors:it=[pt.Colors.alerts.red,pt.Colors.alerts.darkGreen],strokeWidth:P=2,showDots:h=!0,refValues:p=[],minValue:S,maxValue:nt,annotations:at=[],customHighlightAreaSettings:r=[],theme:c="light",ariaLabel:jt,yAxisTitle:$,noOfYTicks:q=5,minDate:st,maxDate:ot,curveType:rt="curve",styles:b,classNames:A,precision:j=2,customLayers:lt=[]}=dt,[i,ct]=d.useState(0),[xt,x]=d.useState(0),y=d.useRef(null),ut=d.useRef(null);return d.useEffect(()=>{const u=new ResizeObserver(B=>{ct(l||B[0].target.clientWidth||620),x(o||B[0].target.clientHeight||480)});return y.current&&(x(y.current.clientHeight||480),ct(y.current.clientWidth||620),l||u.observe(y.current)),()=>u.disconnect()},[l,o]),e.jsxRuntimeExports.jsx("div",{className:`${c||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:L==="he"||L==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${N?N===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${L||"en"}`,A?.graphContainer),style:{...b?.graphContainer||{},...N&&N!==!0?{backgroundColor:N}:{}},id:_,ref:ut,"aria-label":jt||`${O?`The graph shows ${O}. `:""}This is a line chart that highlights the difference between two datasets over time.${w?` ${w}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:N?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[O||w||Y||k?e.jsxRuntimeExports.jsx(Qt.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:A?.title,description:A?.description},graphTitle:O,graphDescription:w,width:l,graphDownload:Y?ut.current:void 0,dataDownload:k?V.map(u=>u.data).filter(u=>u!==void 0).length>0?V.map(u=>u.data).filter(u=>u!==void 0):V.filter(u=>u!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:V.length===0?e.jsxRuntimeExports.jsx(te.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[tt?e.jsxRuntimeExports.jsx(Zt.ColorLegend,{colorDomain:U,colorLegendTitle:et,colors:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:y,"aria-label":"Graph area",children:(l||i)&&(o||xt)?e.jsxRuntimeExports.jsx(ee,{data:V,lineColors:H,colorDomain:U,width:l||i,height:Math.max(F,o||(E?F?(l||i)*E>F?(l||i)*E:F:(l||i)*E:xt)),suffix:G,prefix:D,dateFormat:R,showValues:gt,noOfXTicks:yt,leftMargin:W,rightMargin:n,topMargin:K,bottomMargin:ft,highlightAreaSettings:Q,tooltip:M,onSeriesMouseOver:Z,showColorLegendAtTop:tt,animate:X===!0?{duration:.5,once:!0,amount:.5}:X||{duration:0,once:!0,amount:0},rtl:L==="he"||L==="ar",diffAreaColors:it,idSuffix:_t.generateRandomString(8),strokeWidth:P,showDots:h,refValues:p,minValue:S,maxValue:nt,annotations:at,customHighlightAreaSettings:r,yAxisTitle:$,noOfYTicks:q,minDate:st,maxDate:ot,curveType:rt,styles:b,classNames:A,precision:j,customLayers:lt}):null})]})}),f||z?e.jsxRuntimeExports.jsx(Kt.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:f,footNote:z,width:l}):null]})})})})}exports.DifferenceLineChart=ie;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),m=require("./parse-hMnG_lRV.cjs"),qt=require("./index-BzeLQvXk.cjs"),Et=require("./numberFormattingFunction-02t-wJta.cjs"),Tt=require("./Tooltip-n8z5bfav.cjs"),T=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),bt=require("./customArea-CK768gCn.cjs"),Mt=require("./AxisTitle-CK9YeovX.cjs"),Ft=require("./Axis-DE7dSn1_.cjs"),Pt=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Gt=require("./ReferenceLine-CFVBBN__.cjs"),Ht=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Wt=require("./index-DNj994Pv.cjs"),Yt=require("./time-Byw_jYQ7.cjs"),Xt=require("./linear-BVckp9RD.cjs"),At=require("./line-DHV4JwCR.cjs"),ht=require("./step-BZ3C8QFW.cjs"),Ct=require("./area-D3Qx7k7K.cjs"),Ut=require("./select-Bnfk0lJx.cjs"),Bt=require("./init-DU0ybBc_.cjs"),zt=require("./pointer-Dkq5NV1q.cjs"),Jt=require("./use-in-view-sQJZ_xDO.cjs"),f=require("./proxy-BHRoeZgd.cjs"),Kt=require("./GraphFooter.cjs"),Qt=require("./GraphHeader.cjs"),Zt=require("./ColorLegend.cjs"),pt=require("./Colors.cjs"),_t=require("./generateRandomString-B5zBiJzS.cjs"),te=require("./EmptyState-d8_8SxeW.cjs");function ee(dt){const{data:V,width:O,height:G,lineColors:j,suffix:D,prefix:w,dateFormat:o,showValues:l,noOfXTicks:z,rightMargin:yt,leftMargin:R,topMargin:gt,bottomMargin:J,tooltip:H,highlightAreaSettings:N,onSeriesMouseOver:W,animate:n,rtl:K,showColorLegendAtTop:ft,colorDomain:M,diffAreaColors:Q,idSuffix:E,strokeWidth:Z,showDots:_,refValues:Y,minValue:k,maxValue:X,annotations:L,customHighlightAreaSettings:F,yAxisTitle:U,noOfYTicks:tt,minDate:et,maxDate:it,curveType:P,styles:h,classNames:p,precision:S,customLayers:nt}=dt,at=d.useRef(null),r=Jt.useInView(at,{once:n.once,amount:n.amount}),[c,jt]=d.useState(!1);d.useEffect(()=>{if(r&&!c){const t=setTimeout(()=>{jt(!0)},(n.duration+.5)*1e3);return()=>clearTimeout(t)}},[r,c,n.duration]);const $=P==="linear"?At.curveLinear:P==="step"?ht.curveStep:P==="stepAfter"?ht.stepAfter:P==="stepBefore"?ht.stepBefore:ht.monotoneX,[q,st]=d.useState(void 0),[ot,rt]=d.useState(void 0),[b,A]=d.useState(void 0),y={top:gt,bottom:J,left:U?R+30:R,right:yt},lt=d.useRef(null),i=qt.sortBy(V.map(t=>({...t,date:m.parse(`${t.date}`,o,new Date)})),"date"),ct=N.map(t=>({...t,coordinates:[t.coordinates[0]===null?null:m.parse(`${t.coordinates[0]}`,o,new Date),t.coordinates[1]===null?null:m.parse(`${t.coordinates[1]}`,o,new Date)]})),xt=F.map(t=>({...t,coordinates:t.coordinates.map((v,I)=>I%2===0?m.parse(`${v}`,o,new Date):v)})),x=O-y.left-y.right,g=G-y.top-y.bottom,ut=et?m.parse(`${et}`,o,new Date):i[0].date,u=it?m.parse(`${it}`,o,new Date):i[i.length-1].date,B=Math.min(...i.map(t=>t.y1))!==1/0?Math.min(...i.map(t=>t.y1))>0?0:Math.min(...i.map(t=>t.y1)):0,Ot=Math.min(...i.map(t=>t.y2))!==1/0?Math.min(...i.map(t=>t.y2))>0?0:Math.min(...i.map(t=>t.y2)):0,Nt=Math.max(...i.map(t=>t.y1))!==1/0?Math.max(...i.map(t=>t.y1)):0,It=Math.max(...i.map(t=>t.y2))!==1/0?Math.max(...i.map(t=>t.y2)):0,C=T.checkIfNullOrUndefined(k)?B<Ot?B:Ot:k,wt=Nt>It?Nt:It,a=Yt.time().domain([ut,u]).range([0,x]),s=Xt.linear().domain([T.checkIfNullOrUndefined(k)?C:k,T.checkIfNullOrUndefined(X)?wt>0?wt:0:X]).range([g,0]).nice(),vt=At.line().x(t=>a(t.date)).y(t=>s(t.y1)).curve($),Vt=At.line().x(t=>a(t.date)).y(t=>s(t.y2)).curve($),Dt=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(t=>s(t.y2)).curve($),St=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(0).curve($),$t=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y2)).y0(0).curve($),kt=s.ticks(tt),Lt=a.ticks(z);return d.useEffect(()=>{const t=I=>{const mt=i[Bt.bisectCenter(i.map(Rt=>Rt.date),a.invert(zt.pointer(I)[0]),0)];st(mt||i[i.length-1]),W?.(mt||i[i.length-1]),A(I.clientY),rt(I.clientX)},v=()=>{st(void 0),rt(void 0),A(void 0),W?.(void 0)};Ut.select(lt.current).on("mousemove",t).on("mouseout",v)},[a,i,W]),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.svg,{width:`${O}px`,height:`${G}px`,viewBox:`0 0 ${O} ${G}`,direction:"ltr",ref:at,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${y.left},${y.top})`,children:[e.jsxRuntimeExports.jsx("clipPath",{id:`above${E}`,children:e.jsxRuntimeExports.jsx("path",{d:$t(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx("clipPath",{id:`below${E}`,children:e.jsxRuntimeExports.jsx("path",{d:St(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx(Wt.HighlightArea,{areaSettings:ct,width:x,height:g,scale:a,animate:n,isInView:r}),e.jsxRuntimeExports.jsx(bt.CustomArea,{areaSettings:xt,scaleX:a,scaleY:s,animate:n,isInView:r}),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(Ht.YTicksAndGridLines,{values:kt.filter(t=>t!==0),y:kt.filter(t=>t!==0).map(t=>s(t)),x1:0-R,x2:x+y.right,styles:{gridLines:h?.yAxis?.gridLines,labels:h?.yAxis?.labels},classNames:{gridLines:p?.yAxis?.gridLines,labels:p?.yAxis?.labels},suffix:D,prefix:w,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:S}),e.jsxRuntimeExports.jsx(Ft.Axis,{y1:s(C<0?0:C),y2:s(C<0?0:C),x1:0-R,x2:x+y.right,label:Et.numberFormattingFunction(C<0?0:C,"NA",S,w,D),labelPos:{x:0-R,y:s(C<0?0:C),dx:0,dy:wt<0?"1rem":-5},classNames:{axis:p?.xAxis?.axis,label:p?.yAxis?.labels},styles:{axis:h?.xAxis?.axis,label:h?.yAxis?.labels}}),e.jsxRuntimeExports.jsx(Mt.AxisTitle,{x:0-R-15,y:g/2,style:h?.yAxis?.title,className:p?.yAxis?.title,text:U,rotate90:!0})]})}),e.jsxRuntimeExports.jsx(Pt.XTicksAndGridLines,{values:Lt.map(t=>m.format(t,o)),x:Lt.map(t=>a(t)),y1:0,y2:g,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:e.mo("opacity-0",p?.xAxis?.gridLines),labels:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs",p?.xAxis?.labels)},suffix:D,prefix:w,labelType:"primary",showGridLines:!0,precision:S}),nt.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.path,{clipPath:`url(#below${E})`,d:Dt(i)||"",style:{fill:Q[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:1},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{clipPath:`url(#above${E})`,d:Dt(i)||"",style:{fill:Q[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.path,{d:vt(i)||"",style:{fill:"none",stroke:j[0],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:vt(i)||"",opacity:1},whileInView:{pathLength:1,d:vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{style:{fill:"none",stroke:j[1],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:Vt(i)||"",opacity:1},whileInView:{pathLength:1,d:Vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),ft?null:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.text,{style:{fill:j[0]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y1)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[0]},M[0]),e.jsxRuntimeExports.jsx(f.motion.text,{style:{fill:j[1]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y2)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[1]},M[1])]}),q?e.jsxRuntimeExports.jsx("line",{y1:0,y2:g,x1:a(q.date),x2:a(q.date),className:e.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",p?.mouseOverLine),style:h?.mouseOverLine}):null,i.map((t,v)=>e.jsxRuntimeExports.jsxs(f.motion.g,{children:[T.checkIfNullOrUndefined(t.y1)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(f.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:j[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y1)},whileInView:{opacity:1,transition:{duration:.5,delay:n.duration},cx:a(t.date),cy:s(t.y1)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(f.motion.text,{dy:t.y2<t.y1?-8:"1em",style:{fill:j[0],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-1 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y1)},whileInView:{opacity:1,x:a(t.date),y:s(t.y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y1,"NA",S,w,D)}):null]}),T.checkIfNullOrUndefined(t.y2)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(f.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:j[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y2)},whileInView:{opacity:1,transition:{duration:c?n.duration:.5,delay:c?0:n.duration},cx:a(t.date),cy:s(t.y2)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(f.motion.text,{dy:t.y2>t.y1?-8:"1em",style:{fill:j[1],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-2 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y2)},whileInView:{opacity:1,x:a(t.date),y:s(t.y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y2,"NA",S,w,D)}):null]})]},v))]}),Y?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Y.map((t,v)=>e.jsxRuntimeExports.jsx(Gt.RefLineY,{text:t.text,color:t.color,y:s(t.value),x1:0-R,x2:x+y.right,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v))}):null,e.jsxRuntimeExports.jsx("g",{children:L.map((t,v)=>{const I=bt.getLineEndPoint({x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8},{x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,y:t.yCoordinate?s(t.yCoordinate):0},T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius),mt=t.showConnector?{y1:I.y,x1:I.x,y2:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0):0+(t.yOffset||0),x2:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),cy:t.yCoordinate?s(t.yCoordinate):0,cx:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,circleRadius:T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius,strokeWidth:t.showConnector===!0?2:Math.min(t.showConnector||0,1)}:void 0,Rt={y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8,x:K?0:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),width:K?t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0):x+y.right-(t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0)),maxWidth:t.maxWidth,fontWeight:t.fontWeight,align:t.align};return e.jsxRuntimeExports.jsx(bt.Annotation,{color:t.color,connectorsSettings:mt,labelSettings:Rt,text:t.text,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v)})}),nt.filter(t=>t.position==="after").map(t=>t.layer),e.jsxRuntimeExports.jsx("rect",{ref:lt,style:{fill:"none",pointerEvents:"all"},width:x,height:g})]})}),q&&H&&ot&&b?e.jsxRuntimeExports.jsx(Tt.Tooltip,{data:q,body:H,xPos:ot,yPos:b,backgroundStyle:h?.tooltip,className:p?.tooltip}):null]})}function ie(dt){const{data:V,graphTitle:O,suffix:G="",sources:j,prefix:D="",graphDescription:w,height:o,width:l,footNote:z,noOfXTicks:yt=10,dateFormat:R="yyyy",showValues:gt=!1,padding:J,lineColors:H=[pt.Colors.light.categoricalColors.colors[0],pt.Colors.light.categoricalColors.colors[1]],backgroundColor:N=!1,leftMargin:W=30,rightMargin:n=50,topMargin:K=20,bottomMargin:ft=25,tooltip:M,highlightAreaSettings:Q=[],relativeHeight:E,onSeriesMouseOver:Z,graphID:_,graphDownload:Y=!1,dataDownload:k=!1,animate:X=!1,language:L="en",minHeight:F=0,labels:U,showColorLegendAtTop:tt=!1,colorLegendTitle:et,diffAreaColors:it=[pt.Colors.alerts.red,pt.Colors.alerts.darkGreen],strokeWidth:P=2,showDots:h=!0,refValues:p=[],minValue:S,maxValue:nt,annotations:at=[],customHighlightAreaSettings:r=[],theme:c="light",ariaLabel:jt,yAxisTitle:$,noOfYTicks:q=5,minDate:st,maxDate:ot,curveType:rt="curve",styles:b,classNames:A,precision:y=2,customLayers:lt=[]}=dt,[i,ct]=d.useState(0),[xt,x]=d.useState(0),g=d.useRef(null),ut=d.useRef(null);return d.useEffect(()=>{const u=new ResizeObserver(B=>{ct(l||B[0].target.clientWidth||620),x(o||B[0].target.clientHeight||480)});return g.current&&(x(g.current.clientHeight||480),ct(g.current.clientWidth||620),l||u.observe(g.current)),()=>u.disconnect()},[l,o]),e.jsxRuntimeExports.jsx("div",{className:`${c||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:L==="he"||L==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${N?N===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${L||"en"}`,A?.graphContainer),style:{...b?.graphContainer||{},...N&&N!==!0?{backgroundColor:N}:{}},id:_,ref:ut,"aria-label":jt||`${O?`The graph shows ${O}. `:""}This is a line chart that highlights the difference between two datasets over time.${w?` ${w}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:N?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[O||w||Y||k?e.jsxRuntimeExports.jsx(Qt.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:A?.title,description:A?.description},graphTitle:O,graphDescription:w,width:l,graphDownload:Y?ut.current:void 0,dataDownload:k?V.map(u=>u.data).filter(u=>u!==void 0).length>0?V.map(u=>u.data).filter(u=>u!==void 0):V.filter(u=>u!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:V.length===0?e.jsxRuntimeExports.jsx(te.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[tt?e.jsxRuntimeExports.jsx(Zt.ColorLegend,{colorDomain:U,colorLegendTitle:et,colors:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:g,"aria-label":"Graph area",children:(l||i)&&(o||xt)?e.jsxRuntimeExports.jsx(ee,{data:V,lineColors:H,colorDomain:U,width:l||i,height:Math.max(F,o||(E?F?(l||i)*E>F?(l||i)*E:F:(l||i)*E:xt)),suffix:G,prefix:D,dateFormat:R,showValues:gt,noOfXTicks:yt,leftMargin:W,rightMargin:n,topMargin:K,bottomMargin:ft,highlightAreaSettings:Q,tooltip:M,onSeriesMouseOver:Z,showColorLegendAtTop:tt,animate:X===!0?{duration:.5,once:!0,amount:.5}:X||{duration:0,once:!0,amount:0},rtl:L==="he"||L==="ar",diffAreaColors:it,idSuffix:_t.generateRandomString(8),strokeWidth:P,showDots:h,refValues:p,minValue:S,maxValue:nt,annotations:at,customHighlightAreaSettings:r,yAxisTitle:$,noOfYTicks:q,minDate:st,maxDate:ot,curveType:rt,styles:b,classNames:A,precision:y,customLayers:lt}):null})]})}),j||z?e.jsxRuntimeExports.jsx(Kt.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:j,footNote:z,width:l}):null]})})})})}exports.DifferenceLineChart=ie;
|
|
2
2
|
//# sourceMappingURL=DifferenceLineChart.cjs.map
|