@undp/data-viz 1.5.7 → 1.5.8
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/BarGraph.cjs +1 -1
- package/dist/BarGraph.cjs.map +1 -1
- package/dist/BarGraph.js +650 -648
- package/dist/BarGraph.js.map +1 -1
- package/dist/BulletChart.cjs +1 -1
- package/dist/BulletChart.cjs.map +1 -1
- package/dist/BulletChart.js +210 -208
- package/dist/BulletChart.js.map +1 -1
- package/dist/ButterflyChart.cjs +1 -1
- package/dist/ButterflyChart.cjs.map +1 -1
- package/dist/ButterflyChart.js +42 -40
- package/dist/ButterflyChart.js.map +1 -1
- package/dist/DifferenceLineChart.cjs +1 -1
- package/dist/DifferenceLineChart.cjs.map +1 -1
- package/dist/DifferenceLineChart.js +122 -120
- package/dist/DifferenceLineChart.js.map +1 -1
- package/dist/DualAxisLineChart.cjs +1 -1
- package/dist/DualAxisLineChart.cjs.map +1 -1
- package/dist/DualAxisLineChart.js +133 -113
- package/dist/DualAxisLineChart.js.map +1 -1
- package/dist/DumbbellChart.cjs +1 -1
- package/dist/DumbbellChart.cjs.map +1 -1
- package/dist/DumbbellChart.js +274 -274
- package/dist/DumbbellChart.js.map +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
- package/dist/LineChartWithConfidenceInterval.js +194 -174
- package/dist/LineChartWithConfidenceInterval.js.map +1 -1
- package/dist/MultiLineAltChart.cjs +1 -1
- package/dist/MultiLineAltChart.cjs.map +1 -1
- package/dist/MultiLineAltChart.js +160 -161
- package/dist/MultiLineAltChart.js.map +1 -1
- package/dist/MultiLineChart.cjs +1 -1
- package/dist/MultiLineChart.cjs.map +1 -1
- package/dist/MultiLineChart.js +77 -66
- package/dist/MultiLineChart.js.map +1 -1
- package/dist/ParetoChart.cjs +1 -1
- package/dist/ParetoChart.cjs.map +1 -1
- package/dist/ParetoChart.js +166 -161
- package/dist/ParetoChart.js.map +1 -1
- package/dist/RadarChart.cjs +1 -1
- package/dist/RadarChart.cjs.map +1 -1
- package/dist/RadarChart.js +253 -241
- package/dist/RadarChart.js.map +1 -1
- package/dist/{RegressionLine-mH7UKOPi.js → RegressionLine-C2--oMQq.js} +10 -9
- package/dist/RegressionLine-C2--oMQq.js.map +1 -0
- package/dist/RegressionLine-Dj0GSiAp.cjs +2 -0
- package/dist/RegressionLine-Dj0GSiAp.cjs.map +1 -0
- package/dist/ScatterPlot.cjs +1 -1
- package/dist/ScatterPlot.cjs.map +1 -1
- package/dist/ScatterPlot.js +130 -129
- package/dist/ScatterPlot.js.map +1 -1
- package/dist/SimpleLineChart.cjs +1 -1
- package/dist/SimpleLineChart.cjs.map +1 -1
- package/dist/SimpleLineChart.js +43 -38
- package/dist/SimpleLineChart.js.map +1 -1
- package/dist/SlopeChart.cjs +1 -1
- package/dist/SlopeChart.cjs.map +1 -1
- package/dist/SlopeChart.js +113 -109
- package/dist/SlopeChart.js.map +1 -1
- package/dist/StripChart.cjs +1 -1
- package/dist/StripChart.cjs.map +1 -1
- package/dist/StripChart.js +282 -270
- package/dist/StripChart.js.map +1 -1
- package/dist/UnitChart.cjs +1 -1
- package/dist/UnitChart.cjs.map +1 -1
- package/dist/UnitChart.js +20 -21
- package/dist/UnitChart.js.map +1 -1
- package/dist/getCentroidCoordinates-Dfk6IqEG.js.map +1 -1
- package/dist/getCentroidCoordinates-DxTBqzp2.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/RegressionLine-mH7UKOPi.js.map +0 -1
- package/dist/RegressionLine-xKdiJ8sw.cjs +0 -2
- package/dist/RegressionLine-xKdiJ8sw.cjs.map +0 -1
|
@@ -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 { linearRegression, linearRegressionLine } from 'simple-statistics';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { motion, useInView } from 'motion/react';\r\nimport orderBy from 'lodash.orderby';\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 = orderBy(\r\n data.map(d => ({\r\n ...d,\r\n date: parse(`${d.date}`, dateFormat, new Date()),\r\n })),\r\n ['date'],\r\n ['asc'],\r\n );\r\n const 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","orderBy","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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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 { linearRegression, linearRegressionLine } from 'simple-statistics';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { motion, useInView } from 'motion/react';\r\nimport orderBy from 'lodash.orderby';\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 = orderBy(\r\n data.map(d => ({\r\n ...d,\r\n date: parse(`${d.date}`, dateFormat, new Date()),\r\n })),\r\n ['date'],\r\n ['asc'],\r\n );\r\n const 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 exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity: 0,\r\n cx: x(d.date),\r\n cy: y(d.y as number),\r\n fill: lineColor,\r\n },\r\n whileInView: {\r\n opacity: 1,\r\n fill: lineColor,\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","orderBy","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,IACA,gBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,SAAAC;AAAA,IACA,W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A;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;"}
|
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"),f=require("react"),si=require("./index-DQA8q5sC.cjs"),ci=require("./Modal-tXZlLE5s.cjs"),xi=require("./Tooltip-De16GWhY.cjs"),_=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),a=require("./Colors.cjs"),ui=require("./string2HTML-z7CwHXcx.cjs"),oi=require("./Axis-DE7dSn1_.cjs"),ri=require("./AxisTitle-CK9YeovX.cjs"),yi=require("./linear-BVckp9RD.cjs"),mi=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"),li=require("./uniqBy-O05lp2S5.cjs");function wi(J){const{data:r,width:O,height:E,showLabels:V,colors:o,colorDomain:l,radius:c,leftMargin:y,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:m,animate:s,dimmedOpacity:d,customLayers:B}=J,F=f.useRef(null),w=mi.useInView(F,{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:y,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=yi.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:F,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${k.left},${k.top})`,children:[e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(oi.Axis,{y1:0,y2:h,x1:c,x2:c,classNames:{axis:e.mo("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",m?.yAxis?.axis)}}),e.jsxRuntimeExports.jsx(ri.AxisTitle,{x:c,y:h+15,style:p?.yAxis?.title,className:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",m?.yAxis?.title),text:q[0]})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(oi.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",m?.yAxis?.axis)}}),e.jsxRuntimeExports.jsx(ri.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",m?.yAxis?.title),text:q[1]})]}),B.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[l.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[l.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[l.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[l.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[l.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[l.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[l.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[l.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",m?.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[l.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[l.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",m?.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[l.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[l.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[l.indexOf(`${i.color}`)]:a.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[l.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[l.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[l.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",m?.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[l.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[l.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",m?.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[l.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[l.indexOf(`${i.color}`)]:a.Colors.gray,transition:{duration:s.duration}}},initial:"initial",animate:w?"whileInView":"initial",exit:{opacity:0,transition:{duration:s.duration}},className:m?.dataConnectors,style:{fill:"none",strokeWidth:1,...p?.dataConnectors}})]},N))}),B.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:m?.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:l=!1,height:c,width:y,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:m=!0,highlightedDataPoints:s=[],graphID:d,minValue:B,maxValue:F,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 n=new ResizeObserver(ei=>{t(y||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),y||n.observe(L.current)),()=>n.disconnect()},[y,c]),e.jsxRuntimeExports.jsx("div",{className:`${S||"light"} flex ${y?"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:y,graphDownload:j?ti.current:void 0,dataDownload:I?r.map(n=>n.data).filter(n=>n!==void 0).length>0?r.map(n=>n.data).filter(n=>n!==void 0):r.filter(n=>n!==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:[m&&r.filter(n=>n.color).length!==0?e.jsxRuntimeExports.jsx(pi.ColorLegendWithMouseOver,{width:y,colorLegendTitle:K,colors:E||a.Colors[S].categoricalColors.colors,colorDomain:W||li.uniqBy(r,"color",!0),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:(y||N)&&(c||Z)?e.jsxRuntimeExports.jsx(wi,{data:r.filter(n=>!_.checkIfNullOrUndefined(n.y1)&&!_.checkIfNullOrUndefined(n.y2)),width:y||N,height:Math.max($,c||(g?$?(y||N)*g>$?(y||N)*g:$:(y||N)*g:Z)),colorDomain:r.filter(n=>n.color).length===0?[]:W||li.uniqBy(r,"color",!0),colors:r.filter(n=>n.color).length===0?E?[E]:[a.Colors.primaryColors["blue-600"]]:E||a.Colors[S].categoricalColors.colors,selectedColor:ni,axisTitles:Y,showLabels:l,radius:G,leftMargin:A,rightMargin:U,topMargin:X,bottomMargin:D,tooltip:Q,onSeriesMouseOver:p,highlightedDataPoints:s,minValue:B,maxValue:F,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:y}):null]})})})})}exports.SlopeChart=ji;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),p=require("react"),si=require("./index-DQA8q5sC.cjs"),ci=require("./Modal-tXZlLE5s.cjs"),xi=require("./Tooltip-De16GWhY.cjs"),_=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),s=require("./Colors.cjs"),ui=require("./string2HTML-z7CwHXcx.cjs"),oi=require("./Axis-DE7dSn1_.cjs"),ri=require("./AxisTitle-CK9YeovX.cjs"),yi=require("./linear-BVckp9RD.cjs"),mi=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"),li=require("./uniqBy-O05lp2S5.cjs");function wi(J){const{data:r,width:O,height:E,showLabels:V,colors:o,colorDomain:n,radius:l,leftMargin:y,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:d,classNames:m,animate:c,dimmedOpacity:w,customLayers:B}=J,F=p.useRef(null),j=mi.useInView(F,{once:c.once,amount:c.amount}),[v,I]=p.useState(void 0),[R,M]=p.useState(void 0),[z,$]=p.useState(void 0),[S,T]=p.useState(void 0),k={top:W,bottom:K,left:y,right:P},f=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=yi.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:F,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${k.left},${k.top})`,children:[e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(oi.Axis,{y1:0,y2:h,x1:l,x2:l,classNames:{axis:e.mo("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",m?.yAxis?.axis)}}),e.jsxRuntimeExports.jsx(ri.AxisTitle,{x:l,y:h+15,style:d?.yAxis?.title,className:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",m?.yAxis?.title),text:q[0]})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(oi.Axis,{y1:0,y2:h,x1:f-l,x2:f-l,classNames:{axis:e.mo("stroke-1 stroke-primary-gray-500 dark:stroke-primary-gray-550",m?.yAxis?.axis)}}),e.jsxRuntimeExports.jsx(ri.AxisTitle,{x:f-l,y:h+15,style:d?.yAxis?.title,className:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 text-xs",m?.yAxis?.title),text:q[1]})]}),B.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:w:v?v.label===i.label?1:w:u.length!==0?u.indexOf(i.label)!==-1?1:w:1},whileInView:{opacity:A?i.color&&o[n.indexOf(`${i.color}`)]===A?1:w:v?v.label===i.label?1:w:u.length!==0?u.indexOf(i.label)!==-1?1:w:1,transition:{duration:c.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:c.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,{variants:{initial:{cx:l,cy:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:s.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:s.Colors.gray,opacity:0},whileInView:{cx:l,cy:x(i.y1),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:s.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:s.Colors.gray,opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:c.duration}},r:l,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}`)]:s.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}`)]:s.Colors.gray,opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:c.duration}},style:{textAnchor:"end",...d?.yAxis?.labels||{}},className:e.mo("text-xs",m?.yAxis?.labels),x:5,dy:"0.33em",textAnchor:"end",dx:0-l-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}`)]:s.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}`)]:s.Colors.gray,opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:c.duration}},style:{textAnchor:"end",...d?.yAxis?.labels||{}},className:e.mo("text-xs",m?.yAxis?.labels),x:5,dy:"0.33em",dx:-3,children:i.label}):null,e.jsxRuntimeExports.jsx(b.motion.circle,{variants:{initial:{cx:f-l,cy:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:s.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:s.Colors.gray,opacity:0},whileInView:{cx:f-l,cy:x(i.y2),fill:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:s.Colors.gray,stroke:r.filter(t=>t.color).length===0?o[0]:i.color?o[n.indexOf(`${i.color}`)]:s.Colors.gray,opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:c.duration}},r:l,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}`)]:s.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}`)]:s.Colors.gray,opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:c.duration}},style:{textAnchor:"start",...d?.yAxis?.labels||{}},className:e.mo("text-xs",m?.yAxis?.labels),x:f-5,dy:"0.33em",dx:l+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}`)]:s.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}`)]:s.Colors.gray,opacity:1,transition:{duration:c.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:c.duration}},style:{textAnchor:"start",...d?.yAxis?.labels||{}},className:e.mo("text-xs",m?.yAxis?.labels),x:f-5,dy:"0.33em",dx:3,children:i.label}):null,e.jsxRuntimeExports.jsx(b.motion.line,{variants:{initial:{x1:l,x2:f-l,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}`)]:s.Colors.gray},whileInView:{x1:l,x2:f-l,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}`)]:s.Colors.gray,transition:{duration:c.duration}}},initial:"initial",animate:j?"whileInView":"initial",exit:{opacity:0,transition:{duration:c.duration}},className:m?.dataConnectors,style:{fill:"none",strokeWidth:1,...d?.dataConnectors}})]},N))}),B.filter(i=>i.position==="after").map(i=>i.layer)]})}),v&&G&&z&&S?e.jsxRuntimeExports.jsx(xi.Tooltip,{data:v,body:G,xPos:z,yPos:S,backgroundStyle:d?.tooltip,className:m?.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:l,width:y,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:d,showColorScale:m=!0,highlightedDataPoints:c=[],graphID:w,minValue:B,maxValue:F,onSeriesMouseClick:j,graphDownload:v=!1,dataDownload:I=!1,fillContainer:R=!0,language:M="en",showNAColor:z=!0,minHeight:$=0,theme:S="light",ariaLabel:T,resetSelectionOnDoubleClick:k=!0,detailsOnClick:f,styles:h,classNames:C,animate:H=!1,dimmedOpacity:x=.3,customLayers:i=[]}=J,[N,t]=p.useState(0),[Z,ii]=p.useState(0),[ni,ai]=p.useState(void 0),L=p.useRef(null),ti=p.useRef(null);return p.useEffect(()=>{const a=new ResizeObserver(ei=>{t(y||ei[0].target.clientWidth||620),ii(l||ei[0].target.clientHeight||480)});return L.current&&(ii(L.current.clientHeight||480),t(L.current.clientWidth||620),y||a.observe(L.current)),()=>a.disconnect()},[y,l]),e.jsxRuntimeExports.jsx("div",{className:`${S||"light"} flex ${y?"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:w,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||v||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:y,graphDownload:v?ti.current:void 0,dataDownload:I?r.map(a=>a.data).filter(a=>a!==void 0).length>0?r.map(a=>a.data).filter(a=>a!==void 0):r.filter(a=>a!==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:[m&&r.filter(a=>a.color).length!==0?e.jsxRuntimeExports.jsx(pi.ColorLegendWithMouseOver,{width:y,colorLegendTitle:K,colors:E||s.Colors[S].categoricalColors.colors,colorDomain:W||li.uniqBy(r,"color",!0),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:(y||N)&&(l||Z)?e.jsxRuntimeExports.jsx(wi,{data:r.filter(a=>!_.checkIfNullOrUndefined(a.y1)&&!_.checkIfNullOrUndefined(a.y2)),width:y||N,height:Math.max($,l||(g?$?(y||N)*g>$?(y||N)*g:$:(y||N)*g:Z)),colorDomain:r.filter(a=>a.color).length===0?[]:W||li.uniqBy(r,"color",!0),colors:r.filter(a=>a.color).length===0?E?[E]:[s.Colors.primaryColors["blue-600"]]:E||s.Colors[S].categoricalColors.colors,selectedColor:ni,axisTitles:Y,showLabels:n,radius:G,leftMargin:A,rightMargin:U,topMargin:X,bottomMargin:D,tooltip:Q,onSeriesMouseOver:d,highlightedDataPoints:c,minValue:B,maxValue:F,onSeriesMouseClick:j,resetSelectionOnDoubleClick:k,detailsOnClick:f,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:y}):null]})})})})}exports.SlopeChart=ji;
|
|
2
2
|
//# sourceMappingURL=SlopeChart.cjs.map
|