@undp/data-viz 1.5.6 → 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/ThreeDGlobe.cjs +1 -1
- package/dist/ThreeDGlobe.cjs.map +1 -1
- package/dist/ThreeDGlobe.js +284 -349
- package/dist/ThreeDGlobe.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 +70 -0
- package/dist/getCentroidCoordinates-Dfk6IqEG.js.map +1 -0
- package/dist/getCentroidCoordinates-DxTBqzp2.cjs +2 -0
- package/dist/getCentroidCoordinates-DxTBqzp2.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +34 -32
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +16 -14
- package/dist/utils.js.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":"MultiLineChart.js","sources":["../src/Components/Graphs/LineCharts/MultiLineChart/Graph.tsx","../src/Components/Graphs/LineCharts/MultiLineChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveLinear,\r\n curveMonotoneX,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { 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 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\r\n /** Array of data objects */\r\n data: MultiLineChartDataType[];\r\n lineColors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n labels: (string | number)[];\r\n topMargin: number;\r\n bottomMargin: number;\r\n leftMargin: number;\r\n rightMargin: number;\r\n suffix: string;\r\n prefix: string;\r\n showValues: boolean;\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 showColorLegendAtTop: boolean;\r\n highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n refValues: ReferenceDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n highlightedLines: (string | 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 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 dimmedOpacity: number;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n dashedLines: (string | number)[];\r\n dashSettings: string[];\r\n labelsToBeHidden: (string | number)[];\r\n revealClipId: string;\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 lineColors,\r\n dateFormat,\r\n noOfXTicks,\r\n labels,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n suffix,\r\n prefix,\r\n leftMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n showValues,\r\n showColorLegendAtTop,\r\n refValues,\r\n highlightAreaSettings,\r\n minValue,\r\n maxValue,\r\n highlightedLines,\r\n animate,\r\n rtl,\r\n strokeWidth,\r\n showDots,\r\n annotations,\r\n customHighlightAreaSettings,\r\n yAxisTitle,\r\n noOfYTicks,\r\n minDate,\r\n maxDate,\r\n curveType,\r\n styles,\r\n classNames,\r\n dimmedOpacity,\r\n precision,\r\n customLayers,\r\n dashedLines,\r\n dashSettings,\r\n labelsToBeHidden,\r\n revealClipId,\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 dataArray = dataFormatted[0].y.map((_d, i) => {\r\n return dataFormatted\r\n .map(el => ({\r\n ...el,\r\n y: el.y[i],\r\n }))\r\n .filter(el => !checkIfNullOrUndefined(el.y));\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 ? Math.min(\r\n ...dataFormatted.map(d =>\r\n Math.min(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n )\r\n ? Math.min(\r\n ...dataFormatted.map(d =>\r\n Math.min(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n ) > 0\r\n ? 0\r\n : Math.min(\r\n ...dataFormatted.map(d =>\r\n Math.min(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n )\r\n : 0\r\n : (minValue as number);\r\n const maxParam: number = Math.max(\r\n ...dataFormatted.map(d =>\r\n Math.max(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n )\r\n ? Math.max(\r\n ...dataFormatted.map(d =>\r\n Math.max(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n )\r\n : 0;\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? minParam : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxParam > 0 ? maxParam : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n\r\n const lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n\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 setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n };\r\n const mouseout = () => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n return (\r\n <>\r\n <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 <defs>\r\n <clipPath id={revealClipId}>\r\n <motion.rect\r\n x={0}\r\n y={0}\r\n height={graphHeight}\r\n variants={{\r\n initial: { width: 0 },\r\n whileInView: {\r\n width: graphWidth,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n </clipPath>\r\n </defs>\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 <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 </g>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g>\r\n {dataArray.map((d, i) => (\r\n <motion.g\r\n key={labels[i]}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity:\r\n highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(labels[i]) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n },\r\n whileInView: {\r\n opacity:\r\n highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(labels[i]) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 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 <motion.path\r\n style={{\r\n fill: 'none',\r\n strokeWidth,\r\n }}\r\n clipPath={`url(#${revealClipId})`}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n ...(dashedLines.length === 0 ? { pathLength: 0 } : {}),\r\n d:\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || '',\r\n opacity: 1,\r\n stroke: lineColors[i],\r\n },\r\n whileInView: {\r\n ...(dashedLines.length === 0 ? { pathLength: 1 } : {}),\r\n d:\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || '',\r\n opacity: 1,\r\n stroke: lineColors[i],\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n strokeDasharray={\r\n dashedLines.includes(labels[i])\r\n ? dashSettings[i % dashSettings.length]\r\n : undefined\r\n }\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n {d.map((el, j) => (\r\n <g key={j}>\r\n {!checkIfNullOrUndefined(el.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: lineColors[i] }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: { opacity: 0, cx: x(el.date), cy: y(el.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(el.date),\r\n cy: y(el.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 fill: lineColors[i],\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(el.date), y: y(el.y as number) },\r\n whileInView: {\r\n opacity: 1,\r\n x: x(el.date),\r\n y: y(el.y as number),\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(el.y, 'NA', precision, prefix, suffix)}\r\n </motion.text>\r\n ) : null}\r\n </>\r\n ) : null}\r\n </g>\r\n ))}\r\n {showColorLegendAtTop || labelsToBeHidden.includes(labels[i]) ? null : (\r\n <motion.text\r\n style={{ fill: lineColors[i] }}\r\n className='text-xs'\r\n dx={5}\r\n dy={4}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity: 0,\r\n x: x(d[d.length - 1].date),\r\n y: y(d[d.length - 1].y as number),\r\n },\r\n whileInView: {\r\n opacity: 1,\r\n x: x(d[d.length - 1].date),\r\n y: y(d[d.length - 1].y as number),\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 {labels[i]}\r\n </motion.text>\r\n )}\r\n </motion.g>\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 {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 {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 MultiLineChartDataType,\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\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: MultiLineChartDataType[];\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 of the lines */\r\n lineColors?: string[];\r\n /** Toggle the visibility of color legend between the top of the graphs and next to the line */\r\n showColorLegendAtTop?: boolean;\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 /** Array of labels of line which are dashed */\r\n dashedLines?: (string | number)[];\r\n /** Array of dash settings that define the dash style for the dashed line. If the length of the array is less than length of dashedLines then it loop around. */\r\n dashSettings?: string[];\r\n /** Defines which labels are hidden from the color scale and the graph */\r\n labelsToBeHidden?: (string | 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 /** Toggle visibility of color scale. */\r\n showColorScale?: 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 /** Labels for the lines */\r\n labels: (string | number)[];\r\n /** Data points to highlight. Use the label value from data to highlight the data point */\r\n highlightedLines?: (string | number)[];\r\n /** Defines the opacity of the non-highlighted data */\r\n dimmedOpacity?: number;\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 /** 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 MultiLineChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n lineColors = Colors.light.categoricalColors.colors,\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 labels,\r\n padding,\r\n showValues = false,\r\n backgroundColor = false,\r\n leftMargin = 30,\r\n rightMargin = 50,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n showColorLegendAtTop = false,\r\n refValues = [],\r\n highlightAreaSettings = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n highlightedLines = [],\r\n graphDownload = false,\r\n dataDownload = false,\r\n animate = false,\r\n language = 'en',\r\n colorLegendTitle,\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 yAxisTitle,\r\n noOfYTicks = 5,\r\n minDate,\r\n maxDate,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n dimmedOpacity = 0.3,\r\n precision = 2,\r\n customLayers = [],\r\n dashedLines = [],\r\n dashSettings = ['5 5'],\r\n labelsToBeHidden = [],\r\n showColorScale = true,\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n width ? 'w-fit' : 'w-full',\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a multi-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 <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 {showColorLegendAtTop && showColorScale ? (\r\n <ColorLegend\r\n colorDomain={labels}\r\n colorLegendTitle={colorLegendTitle}\r\n labelsToBeHidden={labelsToBeHidden}\r\n colors={lineColors}\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 lineColors={lineColors}\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 labels={labels}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n showColorLegendAtTop={showColorScale ? showColorLegendAtTop : true}\r\n showValues={showValues}\r\n suffix={suffix}\r\n prefix={prefix}\r\n highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n highlightedLines={highlightedLines}\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 yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n minDate={minDate}\r\n maxDate={maxDate}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n dimmedOpacity={dimmedOpacity}\r\n precision={precision}\r\n customLayers={customLayers}\r\n labelsToBeHidden={labelsToBeHidden}\r\n dashedLines={dashedLines}\r\n dashSettings={dashSettings}\r\n revealClipId={generateRandomString(8)}\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","lineColors","dateFormat","noOfXTicks","labels","rightMargin","topMargin","bottomMargin","suffix","prefix","leftMargin","tooltip","onSeriesMouseOver","showValues","showColorLegendAtTop","refValues","highlightAreaSettings","minValue","maxValue","highlightedLines","animate","rtl","strokeWidth","showDots","annotations","customHighlightAreaSettings","yAxisTitle","noOfYTicks","minDate","maxDate","curveType","styles","classNames","dimmedOpacity","precision","customLayers","dashedLines","dashSettings","labelsToBeHidden","revealClipId","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","dataArray","_d","el","checkIfNullOrUndefined","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","j","graphWidth","graphHeight","minYear","maxYear","minParam","maxParam","x","scaleTime","y","scaleLinear","lineShape","line","yTicks","xTicks","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","MultiLineChart","graphTitle","Colors","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","language","colorLegendTitle","minHeight","theme","ariaLabel","showColorScale","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","ColorLegend","generateRandomString","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGO,SAASA,GAAMC,IAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,QAAAC;AAAA,IACA,aAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,SAAAC;AAAA,IACA,KAAAC;AAAA,IACA,aAAAC;AAAA,IACA,UAAAC;AAAA,IACA,aAAAC;AAAA,IACA,6BAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,eAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,aAAAC;AAAA,IACA,cAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,cAAAC;AAAA,EAAA,IACE1C,IACE2C,KAASC,GAAO,IAAI,GACpBC,IAAWC,GAAUH,IAAQ;AAAA,IACjC,MAAMpB,EAAQ;AAAA,IACd,QAAQA,EAAQ;AAAA,EAAA,CACjB,GACK,CAACwB,GAAiBC,EAAkB,IAAIC,EAAS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ACA,QAAAC;AAAA,sBACA,YAAAC;AAAA,sBACA,eAAAC;AAAA,sBACA,WAAAC;AAAA,sBACA,cAAAC;AAAA,sBACA,kBAAAG;AAAA,sBACA,aAAAF;AAAA,sBACA,cAAAC;AAAA,sBACA,cAAc2G,GAAqB,CAAC;AAAA,oBAAA;AAAA,kBAAA,IAEpC,KAAA,CACN;AAAA,gBAAA,EAAA,CACF,EAAA,CAEJ;AAAA,gBACC1B,KAAWE,IACVvB,gBAAAA,EAAAA;AAAAA,kBAACgD;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAUlH,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAAsF;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAAzH;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":"MultiLineChart.js","sources":["../src/Components/Graphs/LineCharts/MultiLineChart/Graph.tsx","../src/Components/Graphs/LineCharts/MultiLineChart/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\r\nimport {\r\n line,\r\n curveLinear,\r\n curveMonotoneX,\r\n curveStep,\r\n curveStepAfter,\r\n curveStepBefore,\r\n} from 'd3-shape';\r\nimport { scaleLinear, scaleTime } from 'd3-scale';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { bisectCenter } from 'd3-array';\r\nimport { pointer, select } from 'd3-selection';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { 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 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\r\n /** Array of data objects */\r\n data: MultiLineChartDataType[];\r\n lineColors: string[];\r\n width: number;\r\n height: number;\r\n dateFormat: string;\r\n noOfXTicks: number;\r\n labels: (string | number)[];\r\n topMargin: number;\r\n bottomMargin: number;\r\n leftMargin: number;\r\n rightMargin: number;\r\n suffix: string;\r\n prefix: string;\r\n showValues: boolean;\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 showColorLegendAtTop: boolean;\r\n highlightAreaSettings: HighlightAreaSettingsDataType[];\r\n refValues: ReferenceDataType[];\r\n maxValue?: number;\r\n minValue?: number;\r\n highlightedLines: (string | 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 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 dimmedOpacity: number;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n dashedLines: (string | number)[];\r\n dashSettings: string[];\r\n labelsToBeHidden: (string | number)[];\r\n revealClipId: string;\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 lineColors,\r\n dateFormat,\r\n noOfXTicks,\r\n labels,\r\n rightMargin,\r\n topMargin,\r\n bottomMargin,\r\n suffix,\r\n prefix,\r\n leftMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n showValues,\r\n showColorLegendAtTop,\r\n refValues,\r\n highlightAreaSettings,\r\n minValue,\r\n maxValue,\r\n highlightedLines,\r\n animate,\r\n rtl,\r\n strokeWidth,\r\n showDots,\r\n annotations,\r\n customHighlightAreaSettings,\r\n yAxisTitle,\r\n noOfYTicks,\r\n minDate,\r\n maxDate,\r\n curveType,\r\n styles,\r\n classNames,\r\n dimmedOpacity,\r\n precision,\r\n customLayers,\r\n dashedLines,\r\n dashSettings,\r\n labelsToBeHidden,\r\n revealClipId,\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 dataArray = dataFormatted[0].y.map((_d, i) => {\r\n return dataFormatted\r\n .map(el => ({\r\n ...el,\r\n y: el.y[i],\r\n }))\r\n .filter(el => !checkIfNullOrUndefined(el.y));\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 ? Math.min(\r\n ...dataFormatted.map(d =>\r\n Math.min(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n )\r\n ? Math.min(\r\n ...dataFormatted.map(d =>\r\n Math.min(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n ) > 0\r\n ? 0\r\n : Math.min(\r\n ...dataFormatted.map(d =>\r\n Math.min(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n )\r\n : 0\r\n : (minValue as number);\r\n const maxParam: number = Math.max(\r\n ...dataFormatted.map(d =>\r\n Math.max(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n )\r\n ? Math.max(\r\n ...dataFormatted.map(d =>\r\n Math.max(...(d.y.filter(el => !checkIfNullOrUndefined(el)) as number[])),\r\n ),\r\n )\r\n : 0;\r\n\r\n const x = scaleTime().domain([minYear, maxYear]).range([0, graphWidth]);\r\n const y = scaleLinear()\r\n .domain([\r\n checkIfNullOrUndefined(minValue) ? minParam : (minValue as number),\r\n checkIfNullOrUndefined(maxValue) ? (maxParam > 0 ? maxParam : 0) : (maxValue as number),\r\n ])\r\n .range([graphHeight, 0])\r\n .nice();\r\n\r\n const lineShape = line<FormattedDataType>()\r\n .x(d => x(d.date))\r\n .y(d => y(d.y))\r\n .curve(curve);\r\n\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 setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(selectedData || dataFormatted[dataFormatted.length - 1]);\r\n };\r\n const mouseout = () => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n };\r\n select(MouseoverRectRef.current).on('mousemove', mousemove).on('mouseout', mouseout);\r\n onSeriesMouseOver?.(undefined);\r\n }, [x, dataFormatted, onSeriesMouseOver]);\r\n return (\r\n <>\r\n <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 <defs>\r\n <clipPath id={revealClipId}>\r\n <motion.rect\r\n x={0}\r\n y={0}\r\n height={graphHeight}\r\n variants={{\r\n initial: { width: 0 },\r\n whileInView: {\r\n width: graphWidth,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n </clipPath>\r\n </defs>\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 <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 </g>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g>\r\n {dataArray.map((d, i) => (\r\n <motion.g\r\n key={labels[i]}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity:\r\n highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(labels[i]) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 1,\r\n },\r\n whileInView: {\r\n opacity:\r\n highlightedLines.length !== 0\r\n ? highlightedLines.indexOf(labels[i]) !== -1\r\n ? 1\r\n : dimmedOpacity\r\n : 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 <motion.path\r\n style={{\r\n fill: 'none',\r\n strokeWidth,\r\n }}\r\n clipPath={`url(#${revealClipId})`}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n ...(dashedLines.length === 0 ? { pathLength: 0 } : {}),\r\n d:\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || '',\r\n opacity: 1,\r\n stroke: lineColors[i],\r\n },\r\n whileInView: {\r\n ...(dashedLines.length === 0 ? { pathLength: 1 } : {}),\r\n d:\r\n lineShape(\r\n d.filter((el): el is FormattedDataType => !checkIfNullOrUndefined(el.y)),\r\n ) || '',\r\n opacity: 1,\r\n stroke: lineColors[i],\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n strokeDasharray={\r\n dashedLines.includes(labels[i])\r\n ? dashSettings[i % dashSettings.length]\r\n : undefined\r\n }\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n {d.map((el, j) => (\r\n <g key={j}>\r\n {!checkIfNullOrUndefined(el.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 fill: lineColors[i],\r\n cx: x(el.date),\r\n cy: y(el.y as number),\r\n },\r\n whileInView: {\r\n opacity: 1,\r\n fill: lineColors[i],\r\n transition: {\r\n duration: hasAnimatedOnce ? animate.duration : 0.5,\r\n delay: hasAnimatedOnce ? 0 : animate.duration,\r\n },\r\n cx: x(el.date),\r\n cy: y(el.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: {\r\n opacity: 0,\r\n fill: lineColors[i],\r\n x: x(el.date),\r\n y: y(el.y as number),\r\n },\r\n whileInView: {\r\n opacity: 1,\r\n fill: lineColors[i],\r\n x: x(el.date),\r\n y: y(el.y as number),\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(el.y, 'NA', precision, prefix, suffix)}\r\n </motion.text>\r\n ) : null}\r\n </>\r\n ) : null}\r\n </g>\r\n ))}\r\n {showColorLegendAtTop || labelsToBeHidden.includes(labels[i]) ? null : (\r\n <motion.text\r\n className='text-xs'\r\n dx={5}\r\n dy={4}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n opacity: 0,\r\n fill: lineColors[i],\r\n x: x(d[d.length - 1].date),\r\n y: y(d[d.length - 1].y as number),\r\n },\r\n whileInView: {\r\n opacity: 1,\r\n fill: lineColors[i],\r\n x: x(d[d.length - 1].date),\r\n y: y(d[d.length - 1].y as number),\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 {labels[i]}\r\n </motion.text>\r\n )}\r\n </motion.g>\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 {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 {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 MultiLineChartDataType,\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\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: MultiLineChartDataType[];\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 of the lines */\r\n lineColors?: string[];\r\n /** Toggle the visibility of color legend between the top of the graphs and next to the line */\r\n showColorLegendAtTop?: boolean;\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 /** Array of labels of line which are dashed */\r\n dashedLines?: (string | number)[];\r\n /** Array of dash settings that define the dash style for the dashed line. If the length of the array is less than length of dashedLines then it loop around. */\r\n dashSettings?: string[];\r\n /** Defines which labels are hidden from the color scale and the graph */\r\n labelsToBeHidden?: (string | 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 /** Toggle visibility of color scale. */\r\n showColorScale?: 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 /** Labels for the lines */\r\n labels: (string | number)[];\r\n /** Data points to highlight. Use the label value from data to highlight the data point */\r\n highlightedLines?: (string | number)[];\r\n /** Defines the opacity of the non-highlighted data */\r\n dimmedOpacity?: number;\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 /** 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 MultiLineChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n lineColors = Colors.light.categoricalColors.colors,\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 labels,\r\n padding,\r\n showValues = false,\r\n backgroundColor = false,\r\n leftMargin = 30,\r\n rightMargin = 50,\r\n topMargin = 20,\r\n bottomMargin = 25,\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n showColorLegendAtTop = false,\r\n refValues = [],\r\n highlightAreaSettings = [],\r\n graphID,\r\n minValue,\r\n maxValue,\r\n highlightedLines = [],\r\n graphDownload = false,\r\n dataDownload = false,\r\n animate = false,\r\n language = 'en',\r\n colorLegendTitle,\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 yAxisTitle,\r\n noOfYTicks = 5,\r\n minDate,\r\n maxDate,\r\n curveType = 'curve',\r\n styles,\r\n classNames,\r\n dimmedOpacity = 0.3,\r\n precision = 2,\r\n customLayers = [],\r\n dashedLines = [],\r\n dashSettings = ['5 5'],\r\n labelsToBeHidden = [],\r\n showColorScale = true,\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'w-fit grow-0' : 'w-full grow'}`}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n width ? 'w-fit' : 'w-full',\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a multi-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 <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 {showColorLegendAtTop && showColorScale ? (\r\n <ColorLegend\r\n colorDomain={labels}\r\n colorLegendTitle={colorLegendTitle}\r\n labelsToBeHidden={labelsToBeHidden}\r\n colors={lineColors}\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 lineColors={lineColors}\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 labels={labels}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n showColorLegendAtTop={showColorScale ? showColorLegendAtTop : true}\r\n showValues={showValues}\r\n suffix={suffix}\r\n prefix={prefix}\r\n highlightAreaSettings={highlightAreaSettings}\r\n refValues={refValues}\r\n minValue={minValue}\r\n maxValue={maxValue}\r\n highlightedLines={highlightedLines}\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 yAxisTitle={yAxisTitle}\r\n noOfYTicks={noOfYTicks}\r\n minDate={minDate}\r\n maxDate={maxDate}\r\n curveType={curveType}\r\n styles={styles}\r\n classNames={classNames}\r\n dimmedOpacity={dimmedOpacity}\r\n precision={precision}\r\n customLayers={customLayers}\r\n labelsToBeHidden={labelsToBeHidden}\r\n dashedLines={dashedLines}\r\n dashSettings={dashSettings}\r\n revealClipId={generateRandomString(8)}\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","lineColors","dateFormat","noOfXTicks","labels","rightMargin","topMargin","bottomMargin","suffix","prefix","leftMargin","tooltip","onSeriesMouseOver","showValues","showColorLegendAtTop","refValues","highlightAreaSettings","minValue","maxValue","highlightedLines","animate","rtl","strokeWidth","showDots","annotations","customHighlightAreaSettings","yAxisTitle","noOfYTicks","minDate","maxDate","curveType","styles","classNames","dimmedOpacity","precision","customLayers","dashedLines","dashSettings","labelsToBeHidden","revealClipId","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","dataArray","_d","el","checkIfNullOrUndefined","highlightAreaSettingsFormatted","customHighlightAreaSettingsFormatted","j","graphWidth","graphHeight","minYear","maxYear","minParam","maxParam","x","scaleTime","y","scaleLinear","lineShape","line","yTicks","xTicks","mousemove","event","selectedData","bisectCenter","pointer","mouseout","select","jsxs","Fragment","jsx","motion","HighlightArea","CustomArea","YTicksAndGridLines","Axis","numberFormattingFunction","AxisTitle","XTicksAndGridLines","format","cn","RefLineY","endPoints","getLineEndPoint","connectorSettings","labelSettings","Annotation","Tooltip","MultiLineChart","graphTitle","Colors","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","language","colorLegendTitle","minHeight","theme","ariaLabel","showColorScale","svgWidth","setSvgWidth","svgHeight","setSvgHeight","graphDiv","graphParentDiv","resizeObserver","entries","GraphHeader","EmptyState","ColorLegend","generateRandomString","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGO,SAASA,GAAMC,IAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,QAAAC;AAAA,IACA,aAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,uBAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,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AAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
package/dist/ParetoChart.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),j=require("react"),gt=require("./index-DQA8q5sC.cjs"),wt=require("./Modal-tXZlLE5s.cjs"),ot=require("./numberFormattingFunction-02t-wJta.cjs"),Et=require("./Tooltip-De16GWhY.cjs"),Rt=require("./string2HTML-z7CwHXcx.cjs"),pt=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),dt=require("./Axis-DE7dSn1_.cjs"),ft=require("./AxisTitle-CK9YeovX.cjs"),At=require("./XAxesLabels-Drf7M3YK.cjs"),Mt=require("./band-CAApY4Pd.cjs"),yt=require("./linear-BVckp9RD.cjs"),jt=require("./line-DHV4JwCR.cjs"),lt=require("./step-BZ3C8QFW.cjs"),Ct=require("./use-in-view-sQJZ_xDO.cjs"),P=require("./proxy-BHRoeZgd.cjs"),Nt=require("./index-BW8iNx7E.cjs"),kt=require("./GraphFooter.cjs"),$t=require("./GraphHeader.cjs"),St=require("./ColorLegend.cjs"),xt=require("./Colors.cjs"),qt=require("./EmptyState-d8_8SxeW.cjs");function It(ct){const{data:q,width:M,height:V,barColor:d,lineColor:u,axisTitles:s,sameAxes:b,rightMargin:U,leftMargin:z,topMargin:_,bottomMargin:ut,tooltip:v,showValues:J,onSeriesMouseOver:D,barPadding:mt,truncateBy:K,showLabels:Q,onSeriesMouseClick:w,resetSelectionOnDoubleClick:Z,detailsOnClick:m,noOfTicks:tt,lineSuffix:et,barSuffix:Y,linePrefix:X,barPrefix:it,curveType:F,styles:o,classNames:l,animate:r,precision:H,customLayers:I,naLabel:C,showAxisLabels:st}=ct,nt=j.useRef(null),N=Ct.useInView(nt,{once:r.once,amount:r.amount}),ht=F==="linear"?jt.curveLinear:F==="step"?lt.curveStep:F==="stepAfter"?lt.stepAfter:F==="stepBefore"?lt.stepBefore:lt.monotoneX,[at,k]=j.useState(void 0),[$,L]=j.useState(void 0),[rt,S]=j.useState(void 0),[E,c]=j.useState(void 0),h={top:_,bottom:ut,left:z+50,right:U+65},p=M-h.left-h.right,g=V-h.top-h.bottom,n=q.map((t,A)=>({...t,id:`${A}`})),x=Mt.band().domain(n.map(t=>`${t.id}`)).range([0,p]).paddingInner(mt),W=Math.min(...n.map(t=>t.bar).filter(t=>t!=null))!==1/0?Math.min(...n.map(t=>t.bar).filter(t=>t!=null))>0?0:Math.min(...n.map(t=>t.bar).filter(t=>t!=null)):0,R=Math.min(...n.map(t=>t.line).filter(t=>t!=null))!==1/0?Math.min(...n.map(t=>t.line).filter(t=>t!=null))>0?0:Math.min(...n.map(t=>t.line).filter(t=>t!=null)):0,T=Math.max(...n.map(t=>t.bar).filter(t=>t!=null))!==1/0?Math.max(...n.map(t=>t.bar).filter(t=>t!=null)):0,O=Math.max(...n.map(t=>t.line).filter(t=>t!=null))!==1/0?Math.max(...n.map(t=>t.line).filter(t=>t!=null)):0,G=W<R?W:R,y=T>O?T:O,a=yt.linear().domain([b?G:W,b?y>0?y:0:T>0?T:0]).range([g,0]).nice(),i=yt.linear().domain([b?G:R,b?y>0?y:0:O>0?O:0]).range([g,0]).nice(),B=jt.line().defined(t=>!pt.checkIfNullOrUndefined(t.line)).x(t=>x(`${t.id}`)+x.bandwidth()/2).y(t=>i(t.line)).curve(ht),bt=a.ticks(tt),vt=i.ticks(tt);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(P.motion.svg,{width:`${M}px`,height:`${V}px`,viewBox:`0 0 ${M} ${V}`,direction:"ltr",ref:nt,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${h.left},${h.top})`,children:[e.jsxRuntimeExports.jsxs("g",{children:[bt.map((t,A)=>e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx("line",{y1:a(t),y2:a(t),x1:-15,x2:-20,style:{stroke:d,strokeWidth:1,...o?.yAxis?.gridLines||{}},className:l?.yAxis?.gridLines}),e.jsxRuntimeExports.jsx("text",{x:-25,y:a(t),dy:"0.33em",className:e.mo("text-xs",l?.yAxis?.labels),style:{textAnchor:"end",fill:d,...o?.yAxis?.labels||{}},children:ot.numberFormattingFunction(t,C,H,it,Y)})]},A)),e.jsxRuntimeExports.jsx(dt.Axis,{y1:0,y2:g,x1:-15,x2:-15,classNames:{axis:l?.xAxis?.axis},styles:{axis:{stroke:d,...o?.xAxis?.axis||{}}}}),st?e.jsxRuntimeExports.jsx(ft.AxisTitle,{x:10-h.left,y:g/2,style:{fill:d,...o?.yAxis?.title||{}},className:l?.yAxis?.title,text:s[0].length>100?`${s[0].substring(0,100)}...`:s[0],rotate90:!0}):null]}),e.jsxRuntimeExports.jsxs("g",{children:[vt.map((t,A)=>e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx("line",{y1:i(t),y2:i(t),x1:p+15,x2:p+20,style:{stroke:u,strokeWidth:1,...o?.yAxis?.gridLines||{}},className:l?.yAxis?.gridLines}),e.jsxRuntimeExports.jsx("text",{x:p+25,y:i(t),dy:"0.33em",dx:-2,style:{textAnchor:"start",fill:u,...o?.yAxis?.labels||{}},className:e.mo("text-xs",l?.yAxis?.labels),children:ot.numberFormattingFunction(t,C,H,X,et)})]},A)),e.jsxRuntimeExports.jsx(dt.Axis,{y1:0,y2:g,x1:p+15,x2:p+15,classNames:{axis:l?.xAxis?.axis},styles:{axis:{stroke:u,...o?.xAxis?.axis||{}}}}),st?e.jsxRuntimeExports.jsx(ft.AxisTitle,{x:p+h.right-15,y:g/2,style:{fill:u,...o?.yAxis?.title||{}},className:l?.yAxis?.title,text:s[1].length>100?`${s[1].substring(0,100)}...`:s[1],rotate90:!0}):null]}),e.jsxRuntimeExports.jsx(dt.Axis,{y1:b?a(0):g,y2:b?a(0):g,x1:-15,x2:p+15,classNames:{axis:l?.xAxis?.axis},styles:{axis:o?.xAxis?.axis}}),I.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(Nt.AnimatePresence,{children:[n.map((t,A)=>e.jsxRuntimeExports.jsxs(P.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{k(t),c(f.clientY),S(f.clientX),D?.(t)},onClick:()=>{(w||m)&&(gt.isEqual($,t)&&Z?(L(void 0),w?.(void 0)):(L(t),w?.(t)))},onMouseMove:f=>{k(t),c(f.clientY),S(f.clientX)},onMouseLeave:()=>{k(void 0),S(void 0),c(void 0),D?.(void 0)},children:[e.jsxRuntimeExports.jsx(P.motion.rect,{variants:{initial:{attrY:a(0),height:0,opacity:1},whileInView:{attrY:t.bar?t.bar>0?a(t.bar):a(0):0,height:t.bar?Math.abs(a(t.bar)-a(0)):0,opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",exit:{attrY:a(0),height:0,opacity:0,transition:{duration:r.duration}},x:x(`${A}`),width:x.bandwidth(),style:{fill:d}}),J&&!pt.checkIfNullOrUndefined(t.bar)?e.jsxRuntimeExports.jsx(P.motion.text,{x:x(`${t.id}`)+x.bandwidth()/2,exit:{attrY:a(0),opacity:0,transition:{duration:r.duration}},variants:{initial:{attrY:a(0),opacity:0},whileInView:{attrY:a(t.bar||0),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",style:{fill:d,textAnchor:"middle",...o?.graphObjectValues||{}},className:e.mo("graph-value text-sm",l?.graphObjectValues),dy:t.bar?t.bar>=0?"-5px":"1em":"-5px",children:ot.numberFormattingFunction(t.bar,C,H,it,Y)}):null,Q?e.jsxRuntimeExports.jsx(At.XAxesLabels,{value:`${t.label}`.length<K?`${t.label}`:`${`${t.label}`.substring(0,K)}...`,y:g+5,x:x(`${t.id}`),width:x.bandwidth(),height:h.bottom,style:o?.xAxis?.labels,className:l?.xAxis?.labels,alignment:"top",animate:r,isInView:N}):null]},t.label)),e.jsxRuntimeExports.jsx(P.motion.path,{exit:{opacity:0,transition:{duration:r.duration}},variants:{initial:{d:B(n.map(t=>({...t,line:0}))),opacity:0},whileInView:{d:B(n),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",style:{stroke:u,fill:"none",strokeWidth:2}}),n.map((t,A)=>e.jsxRuntimeExports.jsx("g",{children:pt.checkIfNullOrUndefined(t.line)?null:e.jsxRuntimeExports.jsxs("g",{onMouseEnter:f=>{k(t),c(f.clientY),S(f.clientX),D?.(t)},onClick:()=>{(w||m)&&(gt.isEqual($,t)&&Z?(L(void 0),w?.(void 0)):(L(t),w?.(t)))},onMouseMove:f=>{k(t),c(f.clientY),S(f.clientX)},onMouseLeave:()=>{k(void 0),S(void 0),c(void 0),D?.(void 0)},children:[e.jsxRuntimeExports.jsx(P.motion.circle,{exit:{cy:i(0),opacity:0,transition:{duration:r.duration}},variants:{initial:{cy:i(0),opacity:0},whileInView:{cy:i(t.line),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",cx:x(t.id)+x.bandwidth()/2,r:p/n.length<5?0:p/n.length<20?2:4,style:{fill:u}}),J?e.jsxRuntimeExports.jsx(P.motion.text,{x:x(`${t.id}`)+x.bandwidth()/2,exit:{y:i(0),opacity:0,transition:{duration:r.duration}},style:{fill:u,textAnchor:"middle",...o?.graphObjectValues||{}},variants:{initial:{y:i(0),opacity:0},whileInView:{y:i(t.line),opacity:1,transition:{duration:r.duration}}},initial:"initial",animate:N?"whileInView":"initial",className:e.mo("graph-value text-sm",l?.graphObjectValues),dy:"-5px",children:ot.numberFormattingFunction(t.line,C,H,X,et)}):null]})},A))]}),I.filter(t=>t.position==="after").map(t=>t.layer)]})}),at&&v&&rt&&E?e.jsxRuntimeExports.jsx(Et.Tooltip,{data:at,body:v,xPos:rt,yPos:E,backgroundStyle:o?.tooltip,className:l?.tooltip}):null,m&&$!==void 0?e.jsxRuntimeExports.jsx(wt.X,{open:$!==void 0,onClose:()=>{L(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof m=="string"?{__html:Rt.string2HTML(m,$)}:void 0,children:typeof m=="function"?m($):null})}):null]})}function Lt(ct){const{data:q,graphTitle:M,sources:V,graphDescription:d,height:u,width:s,footNote:b,padding:U,lineColor:z=xt.Colors.light.categoricalColors.colors[1],barColor:_=xt.Colors.light.categoricalColors.colors[0],sameAxes:ut=!1,backgroundColor:v=!1,leftMargin:J=80,rightMargin:D=80,topMargin:mt=20,bottomMargin:K=25,lineAxisTitle:Q="Line chart",barAxisTitle:w="Bar graph",tooltip:Z,relativeHeight:m,onSeriesMouseOver:tt,graphID:et,graphDownload:Y=!1,dataDownload:X=!1,barPadding:it=.25,truncateBy:F=999,showLabels:o=!0,onSeriesMouseClick:l,language:r="en",colorLegendTitle:H,minHeight:I=0,theme:C="light",ariaLabel:st,resetSelectionOnDoubleClick:nt=!0,detailsOnClick:N,showValues:ht=!0,noOfTicks:at=5,lineSuffix:k="",barSuffix:$="",linePrefix:L="",barPrefix:rt="",curveType:S="curve",styles:E,classNames:c,animate:h=!1,precision:p=2,customLayers:g=[],naLabel:n="NA",showColorScale:x=!0,showAxisLabels:W=!0}=ct,[R,T]=j.useState(0),[O,G]=j.useState(0),y=j.useRef(null),a=j.useRef(null);return j.useEffect(()=>{const i=new ResizeObserver(B=>{T(s||B[0].target.clientWidth||620),G(u||B[0].target.clientHeight||480)});return y.current&&(G(y.current.clientHeight||480),T(y.current.clientWidth||620),s||i.observe(y.current)),()=>i.disconnect()},[s,u]),e.jsxRuntimeExports.jsx("div",{className:`${C||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:r==="he"||r==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${v?v===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${r||"en"}`,s?"w-fit":"w-full",c?.graphContainer),style:{...E?.graphContainer||{},...v&&v!==!0?{backgroundColor:v}:{}},id:et,ref:a,"aria-label":st||`${M?`The graph shows ${M}. `:""}This is a pareto chart that shows a variable as bars and another as line chart.${d?` ${d}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:v?U||"1rem":U||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[M||d||Y||X?e.jsxRuntimeExports.jsx($t.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:c?.title,description:c?.description},graphTitle:M,graphDescription:d,width:s,graphDownload:Y?a.current:void 0,dataDownload:X?q.map(i=>i.data).filter(i=>i!==void 0).length>0?q.map(i=>i.data).filter(i=>i!==void 0):q.filter(i=>i!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:q.length===0?e.jsxRuntimeExports.jsx(qt.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[x?e.jsxRuntimeExports.jsx(St.ColorLegend,{colorDomain:[w,Q],colors:[_||xt.Colors[C].categoricalColors.colors[0],z||xt.Colors[C].categoricalColors.colors[1]],colorLegendTitle:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:y,"aria-label":"Graph area",children:(s||R)&&(u||O)?e.jsxRuntimeExports.jsx(It,{data:q,sameAxes:ut,lineColor:z,barColor:_,width:s||R,height:Math.max(I,u||(m?I?(s||R)*m>I?(s||R)*m:I:(s||R)*m:O)),truncateBy:F,leftMargin:J,rightMargin:D,topMargin:mt,bottomMargin:K,axisTitles:[w,Q],tooltip:Z,onSeriesMouseOver:tt,barPadding:it,showLabels:o,onSeriesMouseClick:l,resetSelectionOnDoubleClick:nt,detailsOnClick:N,noOfTicks:at,lineSuffix:k,barSuffix:$,linePrefix:L,barPrefix:rt,curveType:S,showValues:ht,styles:E,classNames:c,animate:h===!0?{duration:.5,once:!0,amount:.5}:h||{duration:0,once:!0,amount:0},precision:p,customLayers:g,naLabel:n,showAxisLabels:W}):null})]})}),V||b?e.jsxRuntimeExports.jsx(kt.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:c?.footnote,source:c?.source},sources:V,footNote:b,width:s}):null]})})})})}exports.ParetoChart=Lt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),j=require("react"),gt=require("./index-DQA8q5sC.cjs"),wt=require("./Modal-tXZlLE5s.cjs"),ot=require("./numberFormattingFunction-02t-wJta.cjs"),Et=require("./Tooltip-De16GWhY.cjs"),Rt=require("./string2HTML-z7CwHXcx.cjs"),pt=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),dt=require("./Axis-DE7dSn1_.cjs"),ft=require("./AxisTitle-CK9YeovX.cjs"),At=require("./XAxesLabels-Drf7M3YK.cjs"),Mt=require("./band-CAApY4Pd.cjs"),yt=require("./linear-BVckp9RD.cjs"),jt=require("./line-DHV4JwCR.cjs"),lt=require("./step-BZ3C8QFW.cjs"),Ct=require("./use-in-view-sQJZ_xDO.cjs"),P=require("./proxy-BHRoeZgd.cjs"),kt=require("./index-BW8iNx7E.cjs"),Nt=require("./GraphFooter.cjs"),$t=require("./GraphHeader.cjs"),St=require("./ColorLegend.cjs"),xt=require("./Colors.cjs"),qt=require("./EmptyState-d8_8SxeW.cjs");function It(ct){const{data:q,width:M,height:V,barColor:u,lineColor:o,axisTitles:s,sameAxes:b,rightMargin:U,leftMargin:z,topMargin:_,bottomMargin:ut,tooltip:v,showValues:J,onSeriesMouseOver:D,barPadding:mt,truncateBy:K,showLabels:Q,onSeriesMouseClick:w,resetSelectionOnDoubleClick:Z,detailsOnClick:h,noOfTicks:tt,lineSuffix:et,barSuffix:Y,linePrefix:X,barPrefix:it,curveType:F,styles:l,classNames:x,animate:r,precision:H,customLayers:I,naLabel:C,showAxisLabels:st}=ct,nt=j.useRef(null),k=Ct.useInView(nt,{once:r.once,amount:r.amount}),ht=F==="linear"?jt.curveLinear:F==="step"?lt.curveStep:F==="stepAfter"?lt.stepAfter:F==="stepBefore"?lt.stepBefore:lt.monotoneX,[at,N]=j.useState(void 0),[$,L]=j.useState(void 0),[rt,S]=j.useState(void 0),[E,m]=j.useState(void 0),p={top:_,bottom:ut,left:z+50,right:U+65},d=M-p.left-p.right,g=V-p.top-p.bottom,n=q.map((t,A)=>({...t,id:`${A}`})),c=Mt.band().domain(n.map(t=>`${t.id}`)).range([0,d]).paddingInner(mt),W=Math.min(...n.map(t=>t.bar).filter(t=>t!=null))!==1/0?Math.min(...n.map(t=>t.bar).filter(t=>t!=null))>0?0:Math.min(...n.map(t=>t.bar).filter(t=>t!=null)):0,R=Math.min(...n.map(t=>t.line).filter(t=>t!=null))!==1/0?Math.min(...n.map(t=>t.line).filter(t=>t!=null))>0?0:Math.min(...n.map(t=>t.line).filter(t=>t!=null)):0,T=Math.max(...n.map(t=>t.bar).filter(t=>t!=null))!==1/0?Math.max(...n.map(t=>t.bar).filter(t=>t!=null)):0,O=Math.max(...n.map(t=>t.line).filter(t=>t!=null))!==1/0?Math.max(...n.map(t=>t.line).filter(t=>t!=null)):0,G=W<R?W:R,y=T>O?T:O,a=yt.linear().domain([b?G:W,b?y>0?y:0:T>0?T:0]).range([g,0]).nice(),i=yt.linear().domain([b?G:R,b?y>0?y:0:O>0?O:0]).range([g,0]).nice(),B=jt.line().defined(t=>!pt.checkIfNullOrUndefined(t.line)).x(t=>c(`${t.id}`)+c.bandwidth()/2).y(t=>i(t.line)).curve(ht),bt=a.ticks(tt),vt=i.ticks(tt);return e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(P.motion.svg,{width:`${M}px`,height:`${V}px`,viewBox:`0 0 ${M} ${V}`,direction:"ltr",ref:nt,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${p.left},${p.top})`,children:[e.jsxRuntimeExports.jsxs("g",{children:[bt.map((t,A)=>e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx("line",{y1:a(t),y2:a(t),x1:-15,x2:-20,style:{stroke:u,strokeWidth:1,...l?.yAxis?.gridLines||{}},className:x?.yAxis?.gridLines}),e.jsxRuntimeExports.jsx("text",{x:-25,y:a(t),dy:"0.33em",className:e.mo("text-xs",x?.yAxis?.labels),style:{textAnchor:"end",fill:u,...l?.yAxis?.labels||{}},children:ot.numberFormattingFunction(t,C,H,it,Y)})]},A)),e.jsxRuntimeExports.jsx(dt.Axis,{y1:0,y2:g,x1:-15,x2:-15,classNames:{axis:x?.xAxis?.axis},styles:{axis:{stroke:u,...l?.xAxis?.axis||{}}}}),st?e.jsxRuntimeExports.jsx(ft.AxisTitle,{x:10-p.left,y:g/2,style:{fill:u,...l?.yAxis?.title||{}},className:x?.yAxis?.title,text:s[0].length>100?`${s[0].substring(0,100)}...`:s[0],rotate90:!0}):null]}),e.jsxRuntimeExports.jsxs("g",{children:[vt.map((t,A)=>e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx("line",{y1:i(t),y2:i(t),x1:d+15,x2:d+20,style:{stroke:o,strokeWidth:1,...l?.yAxis?.gridLines||{}},className:x?.yAxis?.gridLines}),e.jsxRuntimeExports.jsx("text",{x:d+25,y:i(t),dy:"0.33em",dx:-2,style:{textAnchor:"start",fill:o,...l?.yAxis?.labels||{}},className:e.mo("text-xs",x?.yAxis?.labels),children:ot.numberFormattingFunction(t,C,H,X,et)})]},A)),e.jsxRuntimeExports.jsx(dt.Axis,{y1:0,y2:g,x1:d+15,x2:d+15,classNames:{axis:x?.xAxis?.axis},styles:{axis:{stroke:o,...l?.xAxis?.axis||{}}}}),st?e.jsxRuntimeExports.jsx(ft.AxisTitle,{x:d+p.right-15,y:g/2,style:{fill:o,...l?.yAxis?.title||{}},className:x?.yAxis?.title,text:s[1].length>100?`${s[1].substring(0,100)}...`:s[1],rotate90:!0}):null]}),e.jsxRuntimeExports.jsx(dt.Axis,{y1:b?a(0):g,y2:b?a(0):g,x1:-15,x2:d+15,classNames:{axis:x?.xAxis?.axis},styles:{axis:l?.xAxis?.axis}}),I.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs(kt.AnimatePresence,{children:[n.map((t,A)=>e.jsxRuntimeExports.jsxs(P.motion.g,{className:"undp-viz-g-with-hover",opacity:.85,onMouseEnter:f=>{N(t),m(f.clientY),S(f.clientX),D?.(t)},onClick:()=>{(w||h)&&(gt.isEqual($,t)&&Z?(L(void 0),w?.(void 0)):(L(t),w?.(t)))},onMouseMove:f=>{N(t),m(f.clientY),S(f.clientX)},onMouseLeave:()=>{N(void 0),S(void 0),m(void 0),D?.(void 0)},children:[e.jsxRuntimeExports.jsx(P.motion.rect,{variants:{initial:{attrY:a(0),height:0,opacity:1,fill:u},whileInView:{attrY:t.bar?t.bar>0?a(t.bar):a(0):0,height:t.bar?Math.abs(a(t.bar)-a(0)):0,opacity:1,fill:u,transition:{duration:r.duration}}},initial:"initial",animate:k?"whileInView":"initial",exit:{attrY:a(0),height:0,opacity:0,transition:{duration:r.duration}},x:c(`${A}`),width:c.bandwidth()}),J&&!pt.checkIfNullOrUndefined(t.bar)?e.jsxRuntimeExports.jsx(P.motion.text,{x:c(`${t.id}`)+c.bandwidth()/2,exit:{attrY:a(0),opacity:0,transition:{duration:r.duration}},variants:{initial:{attrY:a(0),opacity:0,fill:u},whileInView:{attrY:a(t.bar||0),opacity:1,fill:u,transition:{duration:r.duration}}},initial:"initial",animate:k?"whileInView":"initial",style:{textAnchor:"middle",...l?.graphObjectValues||{}},className:e.mo("graph-value text-sm",x?.graphObjectValues),dy:t.bar?t.bar>=0?"-5px":"1em":"-5px",children:ot.numberFormattingFunction(t.bar,C,H,it,Y)}):null,Q?e.jsxRuntimeExports.jsx(At.XAxesLabels,{value:`${t.label}`.length<K?`${t.label}`:`${`${t.label}`.substring(0,K)}...`,y:g+5,x:c(`${t.id}`),width:c.bandwidth(),height:p.bottom,style:l?.xAxis?.labels,className:x?.xAxis?.labels,alignment:"top",animate:r,isInView:k}):null]},t.label)),e.jsxRuntimeExports.jsx(P.motion.path,{exit:{opacity:0,transition:{duration:r.duration}},variants:{initial:{d:B(n.map(t=>({...t,line:0}))),opacity:0,stroke:o},whileInView:{d:B(n),opacity:1,stroke:o,transition:{duration:r.duration}}},initial:"initial",animate:k?"whileInView":"initial",style:{fill:"none",strokeWidth:2}}),n.map((t,A)=>e.jsxRuntimeExports.jsx("g",{children:pt.checkIfNullOrUndefined(t.line)?null:e.jsxRuntimeExports.jsxs("g",{onMouseEnter:f=>{N(t),m(f.clientY),S(f.clientX),D?.(t)},onClick:()=>{(w||h)&&(gt.isEqual($,t)&&Z?(L(void 0),w?.(void 0)):(L(t),w?.(t)))},onMouseMove:f=>{N(t),m(f.clientY),S(f.clientX)},onMouseLeave:()=>{N(void 0),S(void 0),m(void 0),D?.(void 0)},children:[e.jsxRuntimeExports.jsx(P.motion.circle,{exit:{cy:i(0),opacity:0,transition:{duration:r.duration}},variants:{initial:{cy:i(0),opacity:0,fill:o},whileInView:{cy:i(t.line),opacity:1,fill:o,transition:{duration:r.duration}}},initial:"initial",animate:k?"whileInView":"initial",cx:c(t.id)+c.bandwidth()/2,r:d/n.length<5?0:d/n.length<20?2:4}),J?e.jsxRuntimeExports.jsx(P.motion.text,{x:c(`${t.id}`)+c.bandwidth()/2,exit:{y:i(0),opacity:0,transition:{duration:r.duration}},style:{textAnchor:"middle",...l?.graphObjectValues||{}},variants:{initial:{y:i(0),opacity:0,fill:o},whileInView:{y:i(t.line),opacity:1,fill:o,transition:{duration:r.duration}}},initial:"initial",animate:k?"whileInView":"initial",className:e.mo("graph-value text-sm",x?.graphObjectValues),dy:"-5px",children:ot.numberFormattingFunction(t.line,C,H,X,et)}):null]})},A))]}),I.filter(t=>t.position==="after").map(t=>t.layer)]})}),at&&v&&rt&&E?e.jsxRuntimeExports.jsx(Et.Tooltip,{data:at,body:v,xPos:rt,yPos:E,backgroundStyle:l?.tooltip,className:x?.tooltip}):null,h&&$!==void 0?e.jsxRuntimeExports.jsx(wt.X,{open:$!==void 0,onClose:()=>{L(void 0)},children:e.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof h=="string"?{__html:Rt.string2HTML(h,$)}:void 0,children:typeof h=="function"?h($):null})}):null]})}function Lt(ct){const{data:q,graphTitle:M,sources:V,graphDescription:u,height:o,width:s,footNote:b,padding:U,lineColor:z=xt.Colors.light.categoricalColors.colors[1],barColor:_=xt.Colors.light.categoricalColors.colors[0],sameAxes:ut=!1,backgroundColor:v=!1,leftMargin:J=80,rightMargin:D=80,topMargin:mt=20,bottomMargin:K=25,lineAxisTitle:Q="Line chart",barAxisTitle:w="Bar graph",tooltip:Z,relativeHeight:h,onSeriesMouseOver:tt,graphID:et,graphDownload:Y=!1,dataDownload:X=!1,barPadding:it=.25,truncateBy:F=999,showLabels:l=!0,onSeriesMouseClick:x,language:r="en",colorLegendTitle:H,minHeight:I=0,theme:C="light",ariaLabel:st,resetSelectionOnDoubleClick:nt=!0,detailsOnClick:k,showValues:ht=!0,noOfTicks:at=5,lineSuffix:N="",barSuffix:$="",linePrefix:L="",barPrefix:rt="",curveType:S="curve",styles:E,classNames:m,animate:p=!1,precision:d=2,customLayers:g=[],naLabel:n="NA",showColorScale:c=!0,showAxisLabels:W=!0}=ct,[R,T]=j.useState(0),[O,G]=j.useState(0),y=j.useRef(null),a=j.useRef(null);return j.useEffect(()=>{const i=new ResizeObserver(B=>{T(s||B[0].target.clientWidth||620),G(o||B[0].target.clientHeight||480)});return y.current&&(G(y.current.clientHeight||480),T(y.current.clientWidth||620),s||i.observe(y.current)),()=>i.disconnect()},[s,o]),e.jsxRuntimeExports.jsx("div",{className:`${C||"light"} flex ${s?"w-fit grow-0":"w-full grow"}`,dir:r==="he"||r==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${v?v===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${r||"en"}`,s?"w-fit":"w-full",m?.graphContainer),style:{...E?.graphContainer||{},...v&&v!==!0?{backgroundColor:v}:{}},id:et,ref:a,"aria-label":st||`${M?`The graph shows ${M}. `:""}This is a pareto chart that shows a variable as bars and another as line chart.${u?` ${u}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:v?U||"1rem":U||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[M||u||Y||X?e.jsxRuntimeExports.jsx($t.GraphHeader,{styles:{title:E?.title,description:E?.description},classNames:{title:m?.title,description:m?.description},graphTitle:M,graphDescription:u,width:s,graphDownload:Y?a.current:void 0,dataDownload:X?q.map(i=>i.data).filter(i=>i!==void 0).length>0?q.map(i=>i.data).filter(i=>i!==void 0):q.filter(i=>i!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:q.length===0?e.jsxRuntimeExports.jsx(qt.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[c?e.jsxRuntimeExports.jsx(St.ColorLegend,{colorDomain:[w,Q],colors:[_||xt.Colors[C].categoricalColors.colors[0],z||xt.Colors[C].categoricalColors.colors[1]],colorLegendTitle:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:y,"aria-label":"Graph area",children:(s||R)&&(o||O)?e.jsxRuntimeExports.jsx(It,{data:q,sameAxes:ut,lineColor:z,barColor:_,width:s||R,height:Math.max(I,o||(h?I?(s||R)*h>I?(s||R)*h:I:(s||R)*h:O)),truncateBy:F,leftMargin:J,rightMargin:D,topMargin:mt,bottomMargin:K,axisTitles:[w,Q],tooltip:Z,onSeriesMouseOver:tt,barPadding:it,showLabels:l,onSeriesMouseClick:x,resetSelectionOnDoubleClick:nt,detailsOnClick:k,noOfTicks:at,lineSuffix:N,barSuffix:$,linePrefix:L,barPrefix:rt,curveType:S,showValues:ht,styles:E,classNames:m,animate:p===!0?{duration:.5,once:!0,amount:.5}:p||{duration:0,once:!0,amount:0},precision:d,customLayers:g,naLabel:n,showAxisLabels:W}):null})]})}),V||b?e.jsxRuntimeExports.jsx(Nt.GraphFooter,{styles:{footnote:E?.footnote,source:E?.source},classNames:{footnote:m?.footnote,source:m?.source},sources:V,footNote:b,width:s}):null]})})})})}exports.ParetoChart=Lt;
|
|
2
2
|
//# sourceMappingURL=ParetoChart.cjs.map
|