@undp/data-viz 1.5.7 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BarGraph.cjs +1 -1
- package/dist/BarGraph.cjs.map +1 -1
- package/dist/BarGraph.js +650 -648
- package/dist/BarGraph.js.map +1 -1
- package/dist/BulletChart.cjs +1 -1
- package/dist/BulletChart.cjs.map +1 -1
- package/dist/BulletChart.js +210 -208
- package/dist/BulletChart.js.map +1 -1
- package/dist/ButterflyChart.cjs +1 -1
- package/dist/ButterflyChart.cjs.map +1 -1
- package/dist/ButterflyChart.js +42 -40
- package/dist/ButterflyChart.js.map +1 -1
- package/dist/DifferenceLineChart.cjs +1 -1
- package/dist/DifferenceLineChart.cjs.map +1 -1
- package/dist/DifferenceLineChart.js +122 -120
- package/dist/DifferenceLineChart.js.map +1 -1
- package/dist/DualAxisLineChart.cjs +1 -1
- package/dist/DualAxisLineChart.cjs.map +1 -1
- package/dist/DualAxisLineChart.js +133 -113
- package/dist/DualAxisLineChart.js.map +1 -1
- package/dist/DumbbellChart.cjs +1 -1
- package/dist/DumbbellChart.cjs.map +1 -1
- package/dist/DumbbellChart.js +274 -274
- package/dist/DumbbellChart.js.map +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
- package/dist/LineChartWithConfidenceInterval.js +194 -174
- package/dist/LineChartWithConfidenceInterval.js.map +1 -1
- package/dist/MultiLineAltChart.cjs +1 -1
- package/dist/MultiLineAltChart.cjs.map +1 -1
- package/dist/MultiLineAltChart.js +160 -161
- package/dist/MultiLineAltChart.js.map +1 -1
- package/dist/MultiLineChart.cjs +1 -1
- package/dist/MultiLineChart.cjs.map +1 -1
- package/dist/MultiLineChart.js +77 -66
- package/dist/MultiLineChart.js.map +1 -1
- package/dist/ParetoChart.cjs +1 -1
- package/dist/ParetoChart.cjs.map +1 -1
- package/dist/ParetoChart.js +166 -161
- package/dist/ParetoChart.js.map +1 -1
- package/dist/RadarChart.cjs +1 -1
- package/dist/RadarChart.cjs.map +1 -1
- package/dist/RadarChart.js +253 -241
- package/dist/RadarChart.js.map +1 -1
- package/dist/{RegressionLine-mH7UKOPi.js → RegressionLine-C2--oMQq.js} +10 -9
- package/dist/RegressionLine-C2--oMQq.js.map +1 -0
- package/dist/RegressionLine-Dj0GSiAp.cjs +2 -0
- package/dist/RegressionLine-Dj0GSiAp.cjs.map +1 -0
- package/dist/ScatterPlot.cjs +1 -1
- package/dist/ScatterPlot.cjs.map +1 -1
- package/dist/ScatterPlot.js +130 -129
- package/dist/ScatterPlot.js.map +1 -1
- package/dist/SimpleLineChart.cjs +1 -1
- package/dist/SimpleLineChart.cjs.map +1 -1
- package/dist/SimpleLineChart.js +43 -38
- package/dist/SimpleLineChart.js.map +1 -1
- package/dist/SlopeChart.cjs +1 -1
- package/dist/SlopeChart.cjs.map +1 -1
- package/dist/SlopeChart.js +113 -109
- package/dist/SlopeChart.js.map +1 -1
- package/dist/StripChart.cjs +1 -1
- package/dist/StripChart.cjs.map +1 -1
- package/dist/StripChart.js +282 -270
- package/dist/StripChart.js.map +1 -1
- package/dist/UnitChart.cjs +1 -1
- package/dist/UnitChart.cjs.map +1 -1
- package/dist/UnitChart.js +20 -21
- package/dist/UnitChart.js.map +1 -1
- package/dist/getCentroidCoordinates-Dfk6IqEG.js.map +1 -1
- package/dist/getCentroidCoordinates-DxTBqzp2.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/RegressionLine-mH7UKOPi.js.map +0 -1
- package/dist/RegressionLine-xKdiJ8sw.cjs +0 -2
- package/dist/RegressionLine-xKdiJ8sw.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButterflyChart.js","sources":["../src/Components/Graphs/ButterflyChart/Graph.tsx","../src/Components/Graphs/ButterflyChart/index.tsx"],"sourcesContent":["import isEqual from 'fast-deep-equal';\r\nimport { useRef, useState } from 'react';\r\nimport { scaleBand, scaleLinear } from 'd3-scale';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { Modal } from '@undp/design-system-react/Modal';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport {\r\n AnimateDataType,\r\n ButterflyChartDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\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 { string2HTML } from '@/Utils/string2HTML';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { YAxesLabels } from '@/Components/Elements/Axes/YAxesLabels';\r\nimport { RefLineX } from '@/Components/Elements/ReferenceLine';\r\n\r\ninterface Props {\r\n data: ButterflyChartDataType[];\r\n barColors: [string, string];\r\n centerGap: number;\r\n refValues: ReferenceDataType[];\r\n axisTitles: [string, string];\r\n width: number;\r\n height: number;\r\n rightMargin: number;\r\n leftMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n maxValue: number;\r\n minValue: number;\r\n barPadding: number;\r\n truncateBy: number;\r\n showValues: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n showTicks: boolean;\r\n suffix: string;\r\n prefix: string;\r\n resetSelectionOnDoubleClick: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n noOfTicks: number;\r\n animate: AnimateDataType;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n minValueLeftBar: number;\r\n minValueRightBar: number;\r\n naLabel: string;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n barColors,\r\n centerGap,\r\n refValues,\r\n maxValue,\r\n minValue,\r\n showValues,\r\n axisTitles,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n barPadding,\r\n truncateBy,\r\n onSeriesMouseClick,\r\n showTicks,\r\n suffix,\r\n prefix,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n noOfTicks,\r\n animate,\r\n precision,\r\n customLayers,\r\n minValueLeftBar,\r\n minValueRightBar,\r\n naLabel,\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: leftMargin,\r\n right: rightMargin,\r\n };\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n\r\n const dataWithId = data.map((d, i) => ({ ...d, id: `${i}` }));\r\n const y = scaleBand()\r\n .domain(dataWithId.map(d => `${d.id}`))\r\n .range([graphHeight, 0])\r\n .paddingInner(barPadding);\r\n const xRightBar = scaleLinear()\r\n .domain([minValue, maxValue])\r\n .range([0, (graphWidth - centerGap) / 2])\r\n .nice();\r\n const xRightTicks = xRightBar.ticks(noOfTicks);\r\n const xLeftBar = scaleLinear()\r\n .domain([minValue, maxValue])\r\n .range([(graphWidth - centerGap) / 2, 0])\r\n .nice();\r\n const xLeftTicks = xLeftBar.ticks(noOfTicks);\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 {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g transform={`translate(${0},${0})`}>\r\n {showTicks ? (\r\n <XTicksAndGridLines\r\n values={xLeftTicks.filter(d => d !== 0)}\r\n x={xLeftTicks.filter(d => d !== 0).map(d => xLeftBar(d))}\r\n y1={0 - topMargin}\r\n y2={graphHeight + margin.bottom}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.xAxis?.gridLines,\r\n labels: classNames?.xAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n leftLabel\r\n precision={precision}\r\n />\r\n ) : null}\r\n <AnimatePresence>\r\n {dataWithId.map((d, i) => {\r\n return (\r\n <motion.g\r\n className='undp-viz-g-with-hover'\r\n key={d.label}\r\n opacity={0.85}\r\n onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d);\r\n onSeriesMouseClick?.(d);\r\n }\r\n }\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n >\r\n {d.leftBar ? (\r\n <motion.rect\r\n y={y(`${i}`)}\r\n style={{ fill: barColors[0] }}\r\n height={y.bandwidth()}\r\n variants={{\r\n initial: {\r\n x: xLeftBar(0),\r\n width: 0,\r\n },\r\n whileInView: {\r\n x: d.leftBar < 0 ? xLeftBar(0) : xLeftBar(d.leftBar),\r\n width:\r\n d.leftBar < 0\r\n ? xLeftBar(d.leftBar) - xLeftBar(0)\r\n : xLeftBar(0) - xLeftBar(d.leftBar),\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{\r\n x: xLeftBar(0),\r\n width: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n />\r\n ) : null}\r\n {showValues ? (\r\n <motion.text\r\n y={(y(`${i}`) as number) + y.bandwidth() / 2}\r\n style={{\r\n fill: barColors[0],\r\n textAnchor: d.rightBar ? (d.rightBar > 0 ? 'end' : 'start') : 'start',\r\n ...(styles?.graphObjectValues || {}),\r\n }}\r\n dx={d.rightBar ? (d.rightBar > 0 ? -5 : 5) : 5}\r\n dy='0.33em'\r\n className={cn('graph-value text-sm', classNames?.graphObjectValues)}\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n x: xLeftBar(0),\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n x: d.leftBar\r\n ? xLeftBar(d.leftBar)\r\n : xLeftBar(minValueLeftBar < 0 ? 0 : minValueLeftBar),\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n >\r\n {numberFormattingFunction(d.rightBar, naLabel, precision, prefix, suffix)}\r\n </motion.text>\r\n ) : null}\r\n </motion.g>\r\n );\r\n })}\r\n <Axis\r\n y1={-2.5}\r\n y2={graphHeight + margin.bottom}\r\n x1={xLeftBar(minValueLeftBar < 0 ? 0 : minValueLeftBar)}\r\n x2={xLeftBar(minValueLeftBar < 0 ? 0 : minValueLeftBar)}\r\n classNames={{ axis: classNames?.yAxis?.axis }}\r\n styles={{ axis: styles?.yAxis?.axis }}\r\n />\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineX\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n x={xLeftBar(el.value as number)}\r\n y1={0 - margin.top}\r\n y2={graphHeight + margin.bottom}\r\n textSide='left'\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 </AnimatePresence>\r\n </g>\r\n <g transform={`translate(${(graphWidth + centerGap) / 2},${0})`}>\r\n {showTicks ? (\r\n <XTicksAndGridLines\r\n values={xRightTicks.filter(d => d !== 0)}\r\n x={xRightTicks.filter(d => d !== 0).map(d => xRightBar(d))}\r\n y1={0 - topMargin}\r\n y2={graphHeight + margin.bottom}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.xAxis?.gridLines,\r\n labels: classNames?.xAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n precision={precision}\r\n />\r\n ) : null}\r\n <AnimatePresence>\r\n {dataWithId.map((d, i) => {\r\n return (\r\n <motion.g\r\n className='undp-viz-g-with-hover'\r\n key={i}\r\n opacity={0.85}\r\n onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d);\r\n onSeriesMouseClick?.(d);\r\n }\r\n }\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n >\r\n {d.rightBar ? (\r\n <motion.rect\r\n y={y(`${i}`)}\r\n style={{ fill: barColors[1] }}\r\n height={y.bandwidth()}\r\n exit={{\r\n x: xRightBar(0),\r\n width: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n x: xRightBar(0),\r\n width: 0,\r\n },\r\n whileInView: {\r\n x: d.rightBar >= 0 ? xRightBar(0) : xRightBar(d.rightBar),\r\n width:\r\n d.rightBar >= 0\r\n ? xRightBar(d.rightBar) - xRightBar(0)\r\n : xRightBar(0) - xRightBar(d.rightBar),\r\n transition: { duration: animate.duration },\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 y={(y(`${i}`) as number) + y.bandwidth() / 2}\r\n style={{\r\n fill: barColors[1],\r\n textAnchor: d.rightBar ? (d.rightBar < 0 ? 'end' : 'start') : 'start',\r\n ...(styles?.graphObjectValues || {}),\r\n }}\r\n className={cn('graph-value text-sm', classNames?.graphObjectValues)}\r\n dx={d.rightBar ? (d.rightBar < 0 ? -5 : 5) : 5}\r\n dy='0.33em'\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n x: xRightBar(0),\r\n opacity: 0,\r\n },\r\n whileInView: {\r\n x: d.rightBar\r\n ? xRightBar(d.rightBar)\r\n : xRightBar(minValueRightBar < 0 ? 0 : minValueRightBar),\r\n opacity: 1,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n >\r\n {numberFormattingFunction(d.rightBar, naLabel, precision, prefix, suffix)}\r\n </motion.text>\r\n ) : null}\r\n </motion.g>\r\n );\r\n })}\r\n <Axis\r\n y1={-2.5}\r\n y2={graphHeight + margin.bottom}\r\n x1={xRightBar(minValueRightBar < 0 ? 0 : minValueRightBar)}\r\n x2={xRightBar(minValueRightBar < 0 ? 0 : minValueRightBar)}\r\n classNames={{ axis: classNames?.yAxis?.axis }}\r\n styles={{ axis: styles?.yAxis?.axis }}\r\n />\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineX\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n x={xRightBar(el.value as number)}\r\n y1={0 - margin.top}\r\n y2={graphHeight + margin.bottom}\r\n textSide='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 </AnimatePresence>\r\n </g>\r\n <AnimatePresence>\r\n <motion.g transform={`translate(${graphWidth / 2},${0})`}>\r\n {dataWithId.map((d, i) => (\r\n <YAxesLabels\r\n key={i}\r\n value={\r\n `${d.label}`.length < truncateBy\r\n ? `${d.label}`\r\n : `${`${d.label}`.substring(0, truncateBy)}...`\r\n }\r\n y={y(`${d.id}`) as number}\r\n x={0 - centerGap / 2}\r\n width={centerGap}\r\n height={y.bandwidth()}\r\n alignment='center'\r\n style={styles?.yAxis?.labels}\r\n className={classNames?.yAxis?.labels}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n ))}\r\n </motion.g>\r\n </AnimatePresence>\r\n <g transform={`translate(${0},${graphHeight})`}>\r\n <text\r\n style={{\r\n fill: barColors[0],\r\n textAnchor: 'end',\r\n ...styles?.yAxis?.title,\r\n }}\r\n className={cn('text-base', classNames?.yAxis?.title)}\r\n x={graphWidth / 2 - centerGap / 2}\r\n y={0}\r\n dx={-5}\r\n dy={20}\r\n >\r\n {axisTitles[0]}\r\n </text>\r\n <text\r\n style={{\r\n fill: barColors[1],\r\n textAnchor: 'start',\r\n ...styles?.yAxis?.title,\r\n }}\r\n className={cn('text-base', classNames?.yAxis?.title)}\r\n x={graphWidth / 2 + centerGap / 2}\r\n y={0}\r\n dx={5}\r\n dy={20}\r\n >\r\n {axisTitles[1]}\r\n </text>\r\n </g>\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\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 {detailsOnClick && mouseClickData !== undefined ? (\r\n <Modal\r\n open={mouseClickData !== undefined}\r\n onClose={() => {\r\n setMouseClickData(undefined);\r\n }}\r\n >\r\n <div\r\n className='graph-modal-content m-0'\r\n dangerouslySetInnerHTML={\r\n typeof detailsOnClick === 'string'\r\n ? { __html: string2HTML(detailsOnClick, mouseClickData) }\r\n : undefined\r\n }\r\n >\r\n {typeof detailsOnClick === 'function' ? detailsOnClick(mouseClickData) : null}\r\n </div>\r\n </Modal>\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\nimport { SliderUI } from '@undp/design-system-react/SliderUI';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { ascending, sort } from 'd3-array';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { ColorLegend } from '@/Components/Elements/ColorLegend';\r\nimport {\r\n ButterflyChartDataType,\r\n Languages,\r\n ReferenceDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n AnimateDataType,\r\n TimelineDataType,\r\n} from '@/Types';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\nimport { Pause, Play } from '@/Components/Icons';\r\nimport { getSliderMarks } from '@/Utils/getSliderMarks';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { ensureCompleteDataForButterFlyChart } from '@/Utils/ensureCompleteData';\r\nimport { uniqBy } from '@/Utils/uniqBy';\r\n\r\nfunction getMinMax(\r\n data: ButterflyChartDataType[],\r\n key: 'leftBar' | 'rightBar',\r\n minValue?: number | null,\r\n maxValue?: number | null,\r\n) {\r\n const values = data.map(d => d[key]).filter(v => !checkIfNullOrUndefined(v)) as number[];\r\n\r\n const min = !checkIfNullOrUndefined(minValue)\r\n ? (minValue as number)\r\n : Math.min(...values) >= 0\r\n ? 0\r\n : Math.min(...values);\r\n\r\n const max = !checkIfNullOrUndefined(maxValue)\r\n ? (maxValue as number)\r\n : Math.max(...values) < 0\r\n ? 0\r\n : Math.max(...values);\r\n\r\n return { min, max };\r\n}\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: ButterflyChartDataType[];\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 /** Color for the left and right bars */\r\n barColors?: [string, string];\r\n /** Title for the color legend */\r\n colorLegendTitle?: string;\r\n /** Background color of the graph */\r\n backgroundColor?: string | boolean;\r\n /** Custom styles for the graph. Each object should be a valid React CSS style object. */\r\n styles?: StyleObject;\r\n /** Custom class names */\r\n classNames?: ClassNameObject;\r\n\r\n // Size and Spacing\r\n /** Width of the graph */\r\n width?: number;\r\n /** Height of the graph */\r\n height?: number;\r\n /** Minimum height of the graph */\r\n minHeight?: number;\r\n /** Relative height scaling factor. This overwrites the height props */\r\n relativeHeight?: number;\r\n /** Padding around the graph. Defaults to 0 if no backgroundColor is mentioned else defaults to 1rem */\r\n padding?: string;\r\n /** Left margin of the graph */\r\n leftMargin?: number;\r\n /** Right margin of the graph */\r\n rightMargin?: number;\r\n /** Top margin of the graph */\r\n topMargin?: number;\r\n /** Bottom margin of the graph */\r\n bottomMargin?: number;\r\n /** Padding between bars */\r\n barPadding?: number;\r\n /** Spacing between the left and right bars */\r\n centerGap?: 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 /** Truncate labels by specified length */\r\n truncateBy?: number;\r\n /** Reference values for comparison */\r\n refValues?: ReferenceDataType[];\r\n /** Number of ticks on the axis */\r\n noOfTicks?: number;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of values */\r\n showValues?: boolean;\r\n /** Toggle visibility of axis ticks */\r\n showTicks?: boolean;\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Title for the left bars */\r\n leftBarTitle?: string;\r\n /** Title for the right bars */\r\n rightBarTitle?: string;\r\n /** Defines how “NA” values should be displayed/labelled in the graph */\r\n naLabel?: string;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\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 /** Configures playback and slider controls for animating the chart over time. The data must have a key date for it to work properly. */\r\n timeline?: TimelineDataType;\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 /** Reset selection on double-click. Only applicable when used in a dashboard context with filters. */\r\n resetSelectionOnDoubleClick?: 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 /** Details displayed on the modal when user clicks of a data point. 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 detailsOnClick?: 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 /** Callback for mouse click event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_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 ButterflyChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n padding,\r\n barColors = [\r\n Colors.light.categoricalColors.colors[0],\r\n Colors.light.categoricalColors.colors[1],\r\n ],\r\n backgroundColor = false,\r\n leftMargin = 20,\r\n rightMargin = 20,\r\n topMargin = 25,\r\n bottomMargin = 30,\r\n rightBarTitle = 'Right bar graph',\r\n leftBarTitle = 'Left bar graph',\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n graphID,\r\n barPadding = 0.25,\r\n truncateBy = 999,\r\n onSeriesMouseClick,\r\n centerGap = 100,\r\n showValues = true,\r\n maxValue,\r\n minValue,\r\n refValues = [],\r\n suffix = '',\r\n prefix = '',\r\n showTicks = true,\r\n showColorScale = false,\r\n graphDownload = false,\r\n dataDownload = false,\r\n language = 'en',\r\n colorLegendTitle,\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n noOfTicks = 5,\r\n animate = false,\r\n precision = 2,\r\n customLayers = [],\r\n timeline = { enabled: false, autoplay: false, showOnlyActiveDate: true },\r\n naLabel = 'NA',\r\n } = props;\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [play, setPlay] = useState(timeline.autoplay);\r\n const uniqDatesSorted = sort(\r\n uniqBy(data, 'date', true).map(d =>\r\n parse(`${d}`, timeline.dateFormat || 'yyyy', new Date()).getTime(),\r\n ),\r\n (a, b) => ascending(a, b),\r\n );\r\n const [index, setIndex] = useState(timeline.autoplay ? 0 : uniqDatesSorted.length - 1);\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 useEffect(() => {\r\n const interval = setInterval(\r\n () => {\r\n setIndex(i => (i < uniqDatesSorted.length - 1 ? i + 1 : 0));\r\n },\r\n (timeline.speed || 2) * 1000,\r\n );\r\n if (!play) clearInterval(interval);\r\n return () => clearInterval(interval);\r\n }, [uniqDatesSorted, play, timeline.speed]);\r\n\r\n const markObj = getSliderMarks(\r\n uniqDatesSorted,\r\n index,\r\n timeline.showOnlyActiveDate,\r\n timeline.dateFormat || 'yyyy',\r\n );\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 `${graphTitle ? `The graph shows ${graphTitle}. ` : ''}This is a diverging bar chart. ${\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 {timeline.enabled && uniqDatesSorted.length > 0 && markObj ? (\r\n <div className='flex gap-6 items-center' dir='ltr'>\r\n <button\r\n type='button'\r\n onClick={() => {\r\n setPlay(!play);\r\n }}\r\n className='p-0 border-0 cursor-pointer bg-transparent'\r\n aria-label={play ? 'Click to pause animation' : 'Click to play animation'}\r\n >\r\n {play ? <Pause /> : <Play />}\r\n </button>\r\n <SliderUI\r\n min={uniqDatesSorted[0]}\r\n max={uniqDatesSorted[uniqDatesSorted.length - 1]}\r\n marks={markObj}\r\n step={null}\r\n defaultValue={uniqDatesSorted[uniqDatesSorted.length - 1]}\r\n value={uniqDatesSorted[index]}\r\n onChangeComplete={nextValue => {\r\n setIndex(uniqDatesSorted.indexOf(nextValue as number));\r\n }}\r\n onChange={nextValue => {\r\n setIndex(uniqDatesSorted.indexOf(nextValue as number));\r\n }}\r\n aria-label='Time slider. Use arrow keys to adjust selected time period.'\r\n />\r\n </div>\r\n ) : null}\r\n <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n {data.length === 0 ? (\r\n <EmptyState />\r\n ) : (\r\n <>\r\n {showColorScale ? (\r\n <ColorLegend\r\n colorLegendTitle={colorLegendTitle}\r\n colorDomain={[leftBarTitle, rightBarTitle]}\r\n colors={barColors}\r\n showNAColor={false}\r\n />\r\n ) : null}\r\n <div\r\n className='flex flex-col grow justify-center leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={ensureCompleteDataForButterFlyChart(\r\n data,\r\n timeline.dateFormat || 'yyyy',\r\n ).filter(d =>\r\n timeline.enabled\r\n ? d.date ===\r\n format(\r\n new Date(uniqDatesSorted[index]),\r\n timeline.dateFormat || 'yyyy',\r\n )\r\n : d,\r\n )}\r\n barColors={barColors}\r\n width={width || svgWidth}\r\n centerGap={centerGap}\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 truncateBy={truncateBy}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n axisTitles={[leftBarTitle, rightBarTitle]}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n barPadding={barPadding}\r\n refValues={refValues}\r\n maxValue={Math.max(\r\n getMinMax(data, 'leftBar', minValue, maxValue).max,\r\n getMinMax(data, 'rightBar', minValue, maxValue).max,\r\n )}\r\n minValue={Math.min(\r\n getMinMax(data, 'leftBar', minValue, maxValue).min,\r\n getMinMax(data, 'rightBar', minValue, maxValue).min,\r\n )}\r\n minValueLeftBar={getMinMax(data, 'leftBar', minValue, maxValue).min}\r\n minValueRightBar={getMinMax(data, 'rightBar', minValue, maxValue).min}\r\n showValues={showValues}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n showTicks={showTicks}\r\n suffix={suffix}\r\n prefix={prefix}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n detailsOnClick={detailsOnClick}\r\n styles={styles}\r\n classNames={classNames}\r\n noOfTicks={noOfTicks}\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 precision={precision}\r\n customLayers={customLayers}\r\n naLabel={naLabel}\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","barColors","centerGap","refValues","maxValue","minValue","showValues","axisTitles","rightMargin","leftMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","barPadding","truncateBy","onSeriesMouseClick","showTicks","suffix","prefix","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","noOfTicks","animate","precision","customLayers","minValueLeftBar","minValueRightBar","naLabel","svgRef","useRef","isInView","useInView","mouseOverData","setMouseOverData","useState","mouseClickData","setMouseClickData","eventX","setEventX","eventY","setEventY","margin","graphWidth","graphHeight","dataWithId","d","i","y","scaleBand","xRightBar","scaleLinear","xRightTicks","xLeftBar","xLeftTicks","jsxs","Fragment","jsx","motion","XTicksAndGridLines","AnimatePresence","event","isEqual","cn","Axis","el","RefLineX","YAxesLabels","Tooltip","Modal","string2HTML","getMinMax","key","values","v","checkIfNullOrUndefined","min","max","ButterflyChart","graphTitle","sources","graphDescription","footNote","padding","Colors","backgroundColor","rightBarTitle","leftBarTitle","relativeHeight","graphID","showColorScale","graphDownload","dataDownload","language","colorLegendTitle","minHeight","theme","ariaLabel","timeline","svgWidth","setSvgWidth","svgHeight","setSvgHeight","play","setPlay","uniqDatesSorted","sort","uniqBy","parse","a","b","ascending","index","setIndex","graphDiv","graphParentDiv","useEffect","resizeObserver","entries","interval","markObj","getSliderMarks","GraphHeader","Pause","Play","SliderUI","nextValue","EmptyState","ColorLegend","ensureCompleteDataForButterFlyChart","format","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DO,SAASA,GAAMC,GAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,6BAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,iBAAAC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WO,GAAUD,CAAQ,EAAE;AAAA,0BAChE,kBAAkBqE,EAAU3E,GAAM,YAAYO,GAAUD,CAAQ,EAAE;AAAA,0BAClE,YAAAE;AAAA,0BACA,oBAAAU;AAAA,0BACA,WAAAC;AAAA,0BACA,QAAAC;AAAA,0BACA,QAAAC;AAAA,0BACA,6BAAAC;AAAA,0BACA,gBAAAC;AAAA,0BACA,QAAAC;AAAA,0BACA,YAAAC;AAAA,0BACA,WAAAC;AAAA,0BACA,SACEC,MAAY,KACR,EAAE,UAAU,KAAK,MAAM,IAAM,QAAQ,IAAA,IACrCA,KAAW,EAAE,UAAU,GAAG,MAAM,IAAM,QAAQ,EAAA;AAAA,0BAEpD,WAAAC;AAAA,0BACA,cAAAC;AAAA,0BACA,SAAAG;AAAA,wBAAA;AAAA,sBAAA,IAEA;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACN,EAAA,CACF,EAAA,CAEJ;AAAA,gBACCoD,KAAWE,IACVzB,gBAAAA,EAAAA;AAAAA,kBAAC0E;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAU/G,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAA2D;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAArF;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":"ButterflyChart.js","sources":["../src/Components/Graphs/ButterflyChart/Graph.tsx","../src/Components/Graphs/ButterflyChart/index.tsx"],"sourcesContent":["import isEqual from 'fast-deep-equal';\r\nimport { useRef, useState } from 'react';\r\nimport { scaleBand, scaleLinear } from 'd3-scale';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { Modal } from '@undp/design-system-react/Modal';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\n\r\nimport {\r\n AnimateDataType,\r\n ButterflyChartDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\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 { string2HTML } from '@/Utils/string2HTML';\r\nimport { XTicksAndGridLines } from '@/Components/Elements/Axes/XTicksAndGridLines';\r\nimport { Axis } from '@/Components/Elements/Axes/Axis';\r\nimport { YAxesLabels } from '@/Components/Elements/Axes/YAxesLabels';\r\nimport { RefLineX } from '@/Components/Elements/ReferenceLine';\r\n\r\ninterface Props {\r\n data: ButterflyChartDataType[];\r\n barColors: [string, string];\r\n centerGap: number;\r\n refValues: ReferenceDataType[];\r\n axisTitles: [string, string];\r\n width: number;\r\n height: number;\r\n rightMargin: number;\r\n leftMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n maxValue: number;\r\n minValue: number;\r\n barPadding: number;\r\n truncateBy: number;\r\n showValues: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n showTicks: boolean;\r\n suffix: string;\r\n prefix: string;\r\n resetSelectionOnDoubleClick: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n detailsOnClick?: string | ((_d: any) => React.ReactNode);\r\n styles?: StyleObject;\r\n classNames?: ClassNameObject;\r\n noOfTicks: number;\r\n animate: AnimateDataType;\r\n precision: number;\r\n customLayers: CustomLayerDataType[];\r\n minValueLeftBar: number;\r\n minValueRightBar: number;\r\n naLabel: string;\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n width,\r\n height,\r\n barColors,\r\n centerGap,\r\n refValues,\r\n maxValue,\r\n minValue,\r\n showValues,\r\n axisTitles,\r\n rightMargin,\r\n leftMargin,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n barPadding,\r\n truncateBy,\r\n onSeriesMouseClick,\r\n showTicks,\r\n suffix,\r\n prefix,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n noOfTicks,\r\n animate,\r\n precision,\r\n customLayers,\r\n minValueLeftBar,\r\n minValueRightBar,\r\n naLabel,\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseOverData, setMouseOverData] = useState<any>(undefined);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [mouseClickData, setMouseClickData] = useState<any>(undefined);\r\n const [eventX, setEventX] = useState<number | undefined>(undefined);\r\n const [eventY, setEventY] = useState<number | undefined>(undefined);\r\n const margin = {\r\n top: topMargin,\r\n bottom: bottomMargin,\r\n left: leftMargin,\r\n right: rightMargin,\r\n };\r\n const graphWidth = width - margin.left - margin.right;\r\n const graphHeight = height - margin.top - margin.bottom;\r\n\r\n const dataWithId = data.map((d, i) => ({ ...d, id: `${i}` }));\r\n const y = scaleBand()\r\n .domain(dataWithId.map(d => `${d.id}`))\r\n .range([graphHeight, 0])\r\n .paddingInner(barPadding);\r\n const xRightBar = scaleLinear()\r\n .domain([minValue, maxValue])\r\n .range([0, (graphWidth - centerGap) / 2])\r\n .nice();\r\n const xRightTicks = xRightBar.ticks(noOfTicks);\r\n const xLeftBar = scaleLinear()\r\n .domain([minValue, maxValue])\r\n .range([(graphWidth - centerGap) / 2, 0])\r\n .nice();\r\n const xLeftTicks = xLeftBar.ticks(noOfTicks);\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 {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n <g transform={`translate(${0},${0})`}>\r\n {showTicks ? (\r\n <XTicksAndGridLines\r\n values={xLeftTicks.filter(d => d !== 0)}\r\n x={xLeftTicks.filter(d => d !== 0).map(d => xLeftBar(d))}\r\n y1={0 - topMargin}\r\n y2={graphHeight + margin.bottom}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.xAxis?.gridLines,\r\n labels: classNames?.xAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n leftLabel\r\n precision={precision}\r\n />\r\n ) : null}\r\n <AnimatePresence>\r\n {dataWithId.map((d, i) => {\r\n return (\r\n <motion.g\r\n className='undp-viz-g-with-hover'\r\n key={d.label}\r\n opacity={0.85}\r\n onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d);\r\n onSeriesMouseClick?.(d);\r\n }\r\n }\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n >\r\n {d.leftBar ? (\r\n <motion.rect\r\n y={y(`${i}`)}\r\n style={{ fill: barColors[0] }}\r\n height={y.bandwidth()}\r\n variants={{\r\n initial: {\r\n x: xLeftBar(0),\r\n width: 0,\r\n },\r\n whileInView: {\r\n x: d.leftBar < 0 ? xLeftBar(0) : xLeftBar(d.leftBar),\r\n width:\r\n d.leftBar < 0\r\n ? xLeftBar(d.leftBar) - xLeftBar(0)\r\n : xLeftBar(0) - xLeftBar(d.leftBar),\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{\r\n x: xLeftBar(0),\r\n width: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n />\r\n ) : null}\r\n {showValues ? (\r\n <motion.text\r\n y={(y(`${i}`) as number) + y.bandwidth() / 2}\r\n style={{\r\n textAnchor: d.rightBar ? (d.rightBar > 0 ? 'end' : 'start') : 'start',\r\n ...(styles?.graphObjectValues || {}),\r\n }}\r\n dx={d.rightBar ? (d.rightBar > 0 ? -5 : 5) : 5}\r\n dy='0.33em'\r\n className={cn('graph-value text-sm', classNames?.graphObjectValues)}\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n x: xLeftBar(0),\r\n opacity: 0,\r\n fill: barColors[0],\r\n },\r\n whileInView: {\r\n x: d.leftBar\r\n ? xLeftBar(d.leftBar)\r\n : xLeftBar(minValueLeftBar < 0 ? 0 : minValueLeftBar),\r\n opacity: 1,\r\n fill: barColors[0],\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n >\r\n {numberFormattingFunction(d.rightBar, naLabel, precision, prefix, suffix)}\r\n </motion.text>\r\n ) : null}\r\n </motion.g>\r\n );\r\n })}\r\n <Axis\r\n y1={-2.5}\r\n y2={graphHeight + margin.bottom}\r\n x1={xLeftBar(minValueLeftBar < 0 ? 0 : minValueLeftBar)}\r\n x2={xLeftBar(minValueLeftBar < 0 ? 0 : minValueLeftBar)}\r\n classNames={{ axis: classNames?.yAxis?.axis }}\r\n styles={{ axis: styles?.yAxis?.axis }}\r\n />\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineX\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n x={xLeftBar(el.value as number)}\r\n y1={0 - margin.top}\r\n y2={graphHeight + margin.bottom}\r\n textSide='left'\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 </AnimatePresence>\r\n </g>\r\n <g transform={`translate(${(graphWidth + centerGap) / 2},${0})`}>\r\n {showTicks ? (\r\n <XTicksAndGridLines\r\n values={xRightTicks.filter(d => d !== 0)}\r\n x={xRightTicks.filter(d => d !== 0).map(d => xRightBar(d))}\r\n y1={0 - topMargin}\r\n y2={graphHeight + margin.bottom}\r\n styles={{\r\n gridLines: styles?.xAxis?.gridLines,\r\n labels: styles?.xAxis?.labels,\r\n }}\r\n classNames={{\r\n gridLines: classNames?.xAxis?.gridLines,\r\n labels: classNames?.xAxis?.labels,\r\n }}\r\n suffix={suffix}\r\n prefix={prefix}\r\n labelType='secondary'\r\n showGridLines\r\n precision={precision}\r\n />\r\n ) : null}\r\n <AnimatePresence>\r\n {dataWithId.map((d, i) => {\r\n return (\r\n <motion.g\r\n className='undp-viz-g-with-hover'\r\n key={i}\r\n opacity={0.85}\r\n onMouseEnter={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (isEqual(mouseClickData, d) && resetSelectionOnDoubleClick) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n setMouseClickData(d);\r\n onSeriesMouseClick?.(d);\r\n }\r\n }\r\n }}\r\n onMouseMove={event => {\r\n setMouseOverData(d);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onMouseLeave={() => {\r\n setMouseOverData(undefined);\r\n setEventX(undefined);\r\n setEventY(undefined);\r\n onSeriesMouseOver?.(undefined);\r\n }}\r\n >\r\n {d.rightBar ? (\r\n <motion.rect\r\n y={y(`${i}`)}\r\n style={{ fill: barColors[1] }}\r\n height={y.bandwidth()}\r\n exit={{\r\n x: xRightBar(0),\r\n width: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n x: xRightBar(0),\r\n width: 0,\r\n },\r\n whileInView: {\r\n x: d.rightBar >= 0 ? xRightBar(0) : xRightBar(d.rightBar),\r\n width:\r\n d.rightBar >= 0\r\n ? xRightBar(d.rightBar) - xRightBar(0)\r\n : xRightBar(0) - xRightBar(d.rightBar),\r\n transition: { duration: animate.duration },\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 y={(y(`${i}`) as number) + y.bandwidth() / 2}\r\n style={{\r\n textAnchor: d.rightBar ? (d.rightBar < 0 ? 'end' : 'start') : 'start',\r\n ...(styles?.graphObjectValues || {}),\r\n }}\r\n className={cn('graph-value text-sm', classNames?.graphObjectValues)}\r\n dx={d.rightBar ? (d.rightBar < 0 ? -5 : 5) : 5}\r\n dy='0.33em'\r\n exit={{\r\n opacity: 0,\r\n transition: { duration: animate.duration },\r\n }}\r\n variants={{\r\n initial: {\r\n x: xRightBar(0),\r\n opacity: 0,\r\n fill: barColors[1],\r\n },\r\n whileInView: {\r\n x: d.rightBar\r\n ? xRightBar(d.rightBar)\r\n : xRightBar(minValueRightBar < 0 ? 0 : minValueRightBar),\r\n opacity: 1,\r\n fill: barColors[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 {numberFormattingFunction(d.rightBar, naLabel, precision, prefix, suffix)}\r\n </motion.text>\r\n ) : null}\r\n </motion.g>\r\n );\r\n })}\r\n <Axis\r\n y1={-2.5}\r\n y2={graphHeight + margin.bottom}\r\n x1={xRightBar(minValueRightBar < 0 ? 0 : minValueRightBar)}\r\n x2={xRightBar(minValueRightBar < 0 ? 0 : minValueRightBar)}\r\n classNames={{ axis: classNames?.yAxis?.axis }}\r\n styles={{ axis: styles?.yAxis?.axis }}\r\n />\r\n {refValues ? (\r\n <>\r\n {refValues.map((el, i) => (\r\n <RefLineX\r\n key={i}\r\n text={el.text}\r\n color={el.color}\r\n x={xRightBar(el.value as number)}\r\n y1={0 - margin.top}\r\n y2={graphHeight + margin.bottom}\r\n textSide='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 </AnimatePresence>\r\n </g>\r\n <AnimatePresence>\r\n <motion.g transform={`translate(${graphWidth / 2},${0})`}>\r\n {dataWithId.map((d, i) => (\r\n <YAxesLabels\r\n key={i}\r\n value={\r\n `${d.label}`.length < truncateBy\r\n ? `${d.label}`\r\n : `${`${d.label}`.substring(0, truncateBy)}...`\r\n }\r\n y={y(`${d.id}`) as number}\r\n x={0 - centerGap / 2}\r\n width={centerGap}\r\n height={y.bandwidth()}\r\n alignment='center'\r\n style={styles?.yAxis?.labels}\r\n className={classNames?.yAxis?.labels}\r\n animate={animate}\r\n isInView={isInView}\r\n />\r\n ))}\r\n </motion.g>\r\n </AnimatePresence>\r\n <g transform={`translate(${0},${graphHeight})`}>\r\n <text\r\n style={{\r\n fill: barColors[0],\r\n textAnchor: 'end',\r\n ...styles?.yAxis?.title,\r\n }}\r\n className={cn('text-base', classNames?.yAxis?.title)}\r\n x={graphWidth / 2 - centerGap / 2}\r\n y={0}\r\n dx={-5}\r\n dy={20}\r\n >\r\n {axisTitles[0]}\r\n </text>\r\n <text\r\n style={{\r\n fill: barColors[1],\r\n textAnchor: 'start',\r\n ...styles?.yAxis?.title,\r\n }}\r\n className={cn('text-base', classNames?.yAxis?.title)}\r\n x={graphWidth / 2 + centerGap / 2}\r\n y={0}\r\n dx={5}\r\n dy={20}\r\n >\r\n {axisTitles[1]}\r\n </text>\r\n </g>\r\n {customLayers.filter(d => d.position === 'after').map(d => d.layer)}\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 {detailsOnClick && mouseClickData !== undefined ? (\r\n <Modal\r\n open={mouseClickData !== undefined}\r\n onClose={() => {\r\n setMouseClickData(undefined);\r\n }}\r\n >\r\n <div\r\n className='graph-modal-content m-0'\r\n dangerouslySetInnerHTML={\r\n typeof detailsOnClick === 'string'\r\n ? { __html: string2HTML(detailsOnClick, mouseClickData) }\r\n : undefined\r\n }\r\n >\r\n {typeof detailsOnClick === 'function' ? detailsOnClick(mouseClickData) : null}\r\n </div>\r\n </Modal>\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\nimport { SliderUI } from '@undp/design-system-react/SliderUI';\r\nimport { format } from 'date-fns/format';\r\nimport { parse } from 'date-fns/parse';\r\nimport { ascending, sort } from 'd3-array';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { ColorLegend } from '@/Components/Elements/ColorLegend';\r\nimport {\r\n ButterflyChartDataType,\r\n Languages,\r\n ReferenceDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n AnimateDataType,\r\n TimelineDataType,\r\n} from '@/Types';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\nimport { Pause, Play } from '@/Components/Icons';\r\nimport { getSliderMarks } from '@/Utils/getSliderMarks';\r\nimport { checkIfNullOrUndefined } from '@/Utils/checkIfNullOrUndefined';\r\nimport { ensureCompleteDataForButterFlyChart } from '@/Utils/ensureCompleteData';\r\nimport { uniqBy } from '@/Utils/uniqBy';\r\n\r\nfunction getMinMax(\r\n data: ButterflyChartDataType[],\r\n key: 'leftBar' | 'rightBar',\r\n minValue?: number | null,\r\n maxValue?: number | null,\r\n) {\r\n const values = data.map(d => d[key]).filter(v => !checkIfNullOrUndefined(v)) as number[];\r\n\r\n const min = !checkIfNullOrUndefined(minValue)\r\n ? (minValue as number)\r\n : Math.min(...values) >= 0\r\n ? 0\r\n : Math.min(...values);\r\n\r\n const max = !checkIfNullOrUndefined(maxValue)\r\n ? (maxValue as number)\r\n : Math.max(...values) < 0\r\n ? 0\r\n : Math.max(...values);\r\n\r\n return { min, max };\r\n}\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: ButterflyChartDataType[];\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 /** Color for the left and right bars */\r\n barColors?: [string, string];\r\n /** Title for the color legend */\r\n colorLegendTitle?: string;\r\n /** Background color of the graph */\r\n backgroundColor?: string | boolean;\r\n /** Custom styles for the graph. Each object should be a valid React CSS style object. */\r\n styles?: StyleObject;\r\n /** Custom class names */\r\n classNames?: ClassNameObject;\r\n\r\n // Size and Spacing\r\n /** Width of the graph */\r\n width?: number;\r\n /** Height of the graph */\r\n height?: number;\r\n /** Minimum height of the graph */\r\n minHeight?: number;\r\n /** Relative height scaling factor. This overwrites the height props */\r\n relativeHeight?: number;\r\n /** Padding around the graph. Defaults to 0 if no backgroundColor is mentioned else defaults to 1rem */\r\n padding?: string;\r\n /** Left margin of the graph */\r\n leftMargin?: number;\r\n /** Right margin of the graph */\r\n rightMargin?: number;\r\n /** Top margin of the graph */\r\n topMargin?: number;\r\n /** Bottom margin of the graph */\r\n bottomMargin?: number;\r\n /** Padding between bars */\r\n barPadding?: number;\r\n /** Spacing between the left and right bars */\r\n centerGap?: 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 /** Truncate labels by specified length */\r\n truncateBy?: number;\r\n /** Reference values for comparison */\r\n refValues?: ReferenceDataType[];\r\n /** Number of ticks on the axis */\r\n noOfTicks?: number;\r\n\r\n // Graph Parameters\r\n /** Toggle visibility of values */\r\n showValues?: boolean;\r\n /** Toggle visibility of axis ticks */\r\n showTicks?: boolean;\r\n /** Toggle visibility of color scale. This is only applicable if the data props hae color parameter */\r\n showColorScale?: boolean;\r\n /** Title for the left bars */\r\n leftBarTitle?: string;\r\n /** Title for the right bars */\r\n rightBarTitle?: string;\r\n /** Defines how “NA” values should be displayed/labelled in the graph */\r\n naLabel?: string;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\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 /** Configures playback and slider controls for animating the chart over time. The data must have a key date for it to work properly. */\r\n timeline?: TimelineDataType;\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 /** Reset selection on double-click. Only applicable when used in a dashboard context with filters. */\r\n resetSelectionOnDoubleClick?: 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 /** Details displayed on the modal when user clicks of a data point. 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 detailsOnClick?: 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 /** Callback for mouse click event */\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_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 ButterflyChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n sources,\r\n graphDescription,\r\n height,\r\n width,\r\n footNote,\r\n padding,\r\n barColors = [\r\n Colors.light.categoricalColors.colors[0],\r\n Colors.light.categoricalColors.colors[1],\r\n ],\r\n backgroundColor = false,\r\n leftMargin = 20,\r\n rightMargin = 20,\r\n topMargin = 25,\r\n bottomMargin = 30,\r\n rightBarTitle = 'Right bar graph',\r\n leftBarTitle = 'Left bar graph',\r\n tooltip,\r\n relativeHeight,\r\n onSeriesMouseOver,\r\n graphID,\r\n barPadding = 0.25,\r\n truncateBy = 999,\r\n onSeriesMouseClick,\r\n centerGap = 100,\r\n showValues = true,\r\n maxValue,\r\n minValue,\r\n refValues = [],\r\n suffix = '',\r\n prefix = '',\r\n showTicks = true,\r\n showColorScale = false,\r\n graphDownload = false,\r\n dataDownload = false,\r\n language = 'en',\r\n colorLegendTitle,\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n noOfTicks = 5,\r\n animate = false,\r\n precision = 2,\r\n customLayers = [],\r\n timeline = { enabled: false, autoplay: false, showOnlyActiveDate: true },\r\n naLabel = 'NA',\r\n } = props;\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [play, setPlay] = useState(timeline.autoplay);\r\n const uniqDatesSorted = sort(\r\n uniqBy(data, 'date', true).map(d =>\r\n parse(`${d}`, timeline.dateFormat || 'yyyy', new Date()).getTime(),\r\n ),\r\n (a, b) => ascending(a, b),\r\n );\r\n const [index, setIndex] = useState(timeline.autoplay ? 0 : uniqDatesSorted.length - 1);\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 useEffect(() => {\r\n const interval = setInterval(\r\n () => {\r\n setIndex(i => (i < uniqDatesSorted.length - 1 ? i + 1 : 0));\r\n },\r\n (timeline.speed || 2) * 1000,\r\n );\r\n if (!play) clearInterval(interval);\r\n return () => clearInterval(interval);\r\n }, [uniqDatesSorted, play, timeline.speed]);\r\n\r\n const markObj = getSliderMarks(\r\n uniqDatesSorted,\r\n index,\r\n timeline.showOnlyActiveDate,\r\n timeline.dateFormat || 'yyyy',\r\n );\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 `${graphTitle ? `The graph shows ${graphTitle}. ` : ''}This is a diverging bar chart. ${\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 {timeline.enabled && uniqDatesSorted.length > 0 && markObj ? (\r\n <div className='flex gap-6 items-center' dir='ltr'>\r\n <button\r\n type='button'\r\n onClick={() => {\r\n setPlay(!play);\r\n }}\r\n className='p-0 border-0 cursor-pointer bg-transparent'\r\n aria-label={play ? 'Click to pause animation' : 'Click to play animation'}\r\n >\r\n {play ? <Pause /> : <Play />}\r\n </button>\r\n <SliderUI\r\n min={uniqDatesSorted[0]}\r\n max={uniqDatesSorted[uniqDatesSorted.length - 1]}\r\n marks={markObj}\r\n step={null}\r\n defaultValue={uniqDatesSorted[uniqDatesSorted.length - 1]}\r\n value={uniqDatesSorted[index]}\r\n onChangeComplete={nextValue => {\r\n setIndex(uniqDatesSorted.indexOf(nextValue as number));\r\n }}\r\n onChange={nextValue => {\r\n setIndex(uniqDatesSorted.indexOf(nextValue as number));\r\n }}\r\n aria-label='Time slider. Use arrow keys to adjust selected time period.'\r\n />\r\n </div>\r\n ) : null}\r\n <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n {data.length === 0 ? (\r\n <EmptyState />\r\n ) : (\r\n <>\r\n {showColorScale ? (\r\n <ColorLegend\r\n colorLegendTitle={colorLegendTitle}\r\n colorDomain={[leftBarTitle, rightBarTitle]}\r\n colors={barColors}\r\n showNAColor={false}\r\n />\r\n ) : null}\r\n <div\r\n className='flex flex-col grow justify-center leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) ? (\r\n <Graph\r\n data={ensureCompleteDataForButterFlyChart(\r\n data,\r\n timeline.dateFormat || 'yyyy',\r\n ).filter(d =>\r\n timeline.enabled\r\n ? d.date ===\r\n format(\r\n new Date(uniqDatesSorted[index]),\r\n timeline.dateFormat || 'yyyy',\r\n )\r\n : d,\r\n )}\r\n barColors={barColors}\r\n width={width || svgWidth}\r\n centerGap={centerGap}\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 truncateBy={truncateBy}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n axisTitles={[leftBarTitle, rightBarTitle]}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n barPadding={barPadding}\r\n refValues={refValues}\r\n maxValue={Math.max(\r\n getMinMax(data, 'leftBar', minValue, maxValue).max,\r\n getMinMax(data, 'rightBar', minValue, maxValue).max,\r\n )}\r\n minValue={Math.min(\r\n getMinMax(data, 'leftBar', minValue, maxValue).min,\r\n getMinMax(data, 'rightBar', minValue, maxValue).min,\r\n )}\r\n minValueLeftBar={getMinMax(data, 'leftBar', minValue, maxValue).min}\r\n minValueRightBar={getMinMax(data, 'rightBar', minValue, maxValue).min}\r\n showValues={showValues}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n showTicks={showTicks}\r\n suffix={suffix}\r\n prefix={prefix}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n detailsOnClick={detailsOnClick}\r\n styles={styles}\r\n classNames={classNames}\r\n noOfTicks={noOfTicks}\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 precision={precision}\r\n customLayers={customLayers}\r\n naLabel={naLabel}\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","barColors","centerGap","refValues","maxValue","minValue","showValues","axisTitles","rightMargin","leftMargin","topMargin","bottomMargin","tooltip","onSeriesMouseOver","barPadding","truncateBy","onSeriesMouseClick","showTicks","suffix","prefix","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","noOfTicks","animate","precision","customLayers","minValueLeftBar","minValueRightBar","naLabel","svgRef","useRef","isInView","useInView","mouseOverData","setMouseOverData","useState","mouseClickData","setMouseClickData","eventX","setEventX","eventY","setEventY","margin","graphWidth","graphHeight","dataWithId","d","i","y","scaleBand","xRightBar","scaleLinear","xRightTicks","xLeftBar","xLeftTicks","jsxs","Fragment","jsx","motion","XTicksAndGridLines","AnimatePresence","event","isEqual","cn","Axis","el","RefLineX","YAxesLabels","Tooltip","Modal","string2HTML","getMinMax","key","values","v","checkIfNullOrUndefined","min","max","ButterflyChart","graphTitle","sources","graphDescription","footNote","padding","Colors","backgroundColor","rightBarTitle","leftBarTitle","relativeHeight","graphID","showColorScale","graphDownload","dataDownload","language","colorLegendTitle","minHeight","theme","ariaLabel","timeline","svgWidth","setSvgWidth","svgHeight","setSvgHeight","play","setPlay","uniqDatesSorted","sort","uniqBy","parse","a","b","ascending","index","setIndex","graphDiv","graphParentDiv","useEffect","resizeObserver","entries","interval","markObj","getSliderMarks","GraphHeader","Pause","Play","SliderUI","nextValue","EmptyState","ColorLegend","ensureCompleteDataForButterFlyChart","format","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DO,SAASA,GAAMC,GAAc;AAClC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,WAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,SAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,QAAAC;AAAA,IACA,6BAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,WAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC;AAAA,IACA,cAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,SAAAC;AA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AAiBqE,EAAU3E,GAAM,WAAWO,GAAUD,CAAQ,EAAE;AAAA,0BAChE,kBAAkBqE,EAAU3E,GAAM,YAAYO,GAAUD,CAAQ,EAAE;AAAA,0BAClE,YAAAE;AAAA,0BACA,oBAAAU;AAAA,0BACA,WAAAC;AAAA,0BACA,QAAAC;AAAA,0BACA,QAAAC;AAAA,0BACA,6BAAAC;AAAA,0BACA,gBAAAC;AAAA,0BACA,QAAAC;AAAA,0BACA,YAAAC;AAAA,0BACA,WAAAC;AAAA,0BACA,SACEC,MAAY,KACR,EAAE,UAAU,KAAK,MAAM,IAAM,QAAQ,IAAA,IACrCA,KAAW,EAAE,UAAU,GAAG,MAAM,IAAM,QAAQ,EAAA;AAAA,0BAEpD,WAAAC;AAAA,0BACA,cAAAC;AAAA,0BACA,SAAAG;AAAA,wBAAA;AAAA,sBAAA,IAEA;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBACN,EAAA,CACF,EAAA,CAEJ;AAAA,gBACCoD,KAAWE,IACVzB,gBAAAA,EAAAA;AAAAA,kBAAC0E;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAU/G,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAA2D;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAArF;AAAA,kBAAA;AAAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),d=require("react"),m=require("./parse-hMnG_lRV.cjs"),qt=require("./index-CQ3e6Ewi.cjs"),Et=require("./numberFormattingFunction-02t-wJta.cjs"),Tt=require("./Tooltip-De16GWhY.cjs"),T=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),bt=require("./customArea-CK768gCn.cjs"),Mt=require("./AxisTitle-CK9YeovX.cjs"),Ft=require("./Axis-DE7dSn1_.cjs"),Pt=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Gt=require("./ReferenceLine-CFVBBN__.cjs"),Ht=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Wt=require("./index-BYzIB5V6.cjs"),Yt=require("./time-Byw_jYQ7.cjs"),Xt=require("./linear-BVckp9RD.cjs"),At=require("./line-DHV4JwCR.cjs"),ht=require("./step-BZ3C8QFW.cjs"),Ct=require("./area-D3Qx7k7K.cjs"),Ut=require("./select-Bnfk0lJx.cjs"),Bt=require("./init-DU0ybBc_.cjs"),zt=require("./pointer-Dkq5NV1q.cjs"),Jt=require("./use-in-view-sQJZ_xDO.cjs"),f=require("./proxy-BHRoeZgd.cjs"),Kt=require("./GraphFooter.cjs"),Qt=require("./GraphHeader.cjs"),Zt=require("./ColorLegend.cjs"),pt=require("./Colors.cjs"),_t=require("./generateRandomString-B5zBiJzS.cjs"),te=require("./EmptyState-d8_8SxeW.cjs");function ee(dt){const{data:V,width:O,height:G,lineColors:j,suffix:D,prefix:w,dateFormat:o,showValues:l,noOfXTicks:z,rightMargin:yt,leftMargin:R,topMargin:gt,bottomMargin:J,tooltip:H,highlightAreaSettings:N,onSeriesMouseOver:W,animate:n,rtl:K,showColorLegendAtTop:ft,colorDomain:M,diffAreaColors:Q,idSuffix:E,strokeWidth:Z,showDots:_,refValues:Y,minValue:k,maxValue:X,annotations:L,customHighlightAreaSettings:F,yAxisTitle:U,noOfYTicks:tt,minDate:et,maxDate:it,curveType:P,styles:h,classNames:p,precision:S,customLayers:nt}=dt,at=d.useRef(null),r=Jt.useInView(at,{once:n.once,amount:n.amount}),[c,jt]=d.useState(!1);d.useEffect(()=>{if(r&&!c){const t=setTimeout(()=>{jt(!0)},(n.duration+.5)*1e3);return()=>clearTimeout(t)}},[r,c,n.duration]);const $=P==="linear"?At.curveLinear:P==="step"?ht.curveStep:P==="stepAfter"?ht.stepAfter:P==="stepBefore"?ht.stepBefore:ht.monotoneX,[q,st]=d.useState(void 0),[ot,rt]=d.useState(void 0),[b,A]=d.useState(void 0),y={top:gt,bottom:J,left:U?R+30:R,right:yt},lt=d.useRef(null),i=qt.orderBy(V.map(t=>({...t,date:m.parse(`${t.date}`,o,new Date)})),["date"],["asc"]),ct=N.map(t=>({...t,coordinates:[t.coordinates[0]===null?null:m.parse(`${t.coordinates[0]}`,o,new Date),t.coordinates[1]===null?null:m.parse(`${t.coordinates[1]}`,o,new Date)]})),xt=F.map(t=>({...t,coordinates:t.coordinates.map((v,I)=>I%2===0?m.parse(`${v}`,o,new Date):v)})),x=O-y.left-y.right,g=G-y.top-y.bottom,ut=et?m.parse(`${et}`,o,new Date):i[0].date,u=it?m.parse(`${it}`,o,new Date):i[i.length-1].date,B=Math.min(...i.map(t=>t.y1))!==1/0?Math.min(...i.map(t=>t.y1))>0?0:Math.min(...i.map(t=>t.y1)):0,Ot=Math.min(...i.map(t=>t.y2))!==1/0?Math.min(...i.map(t=>t.y2))>0?0:Math.min(...i.map(t=>t.y2)):0,Nt=Math.max(...i.map(t=>t.y1))!==1/0?Math.max(...i.map(t=>t.y1)):0,It=Math.max(...i.map(t=>t.y2))!==1/0?Math.max(...i.map(t=>t.y2)):0,C=T.checkIfNullOrUndefined(k)?B<Ot?B:Ot:k,wt=Nt>It?Nt:It,a=Yt.time().domain([ut,u]).range([0,x]),s=Xt.linear().domain([T.checkIfNullOrUndefined(k)?C:k,T.checkIfNullOrUndefined(X)?wt>0?wt:0:X]).range([g,0]).nice(),vt=At.line().x(t=>a(t.date)).y(t=>s(t.y1)).curve($),Vt=At.line().x(t=>a(t.date)).y(t=>s(t.y2)).curve($),Dt=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(t=>s(t.y2)).curve($),St=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(0).curve($),$t=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y2)).y0(0).curve($),kt=s.ticks(tt),Lt=a.ticks(z);return d.useEffect(()=>{const t=I=>{const mt=i[Bt.bisectCenter(i.map(Rt=>Rt.date),a.invert(zt.pointer(I)[0]),0)];st(mt||i[i.length-1]),W?.(mt||i[i.length-1]),A(I.clientY),rt(I.clientX)},v=()=>{st(void 0),rt(void 0),A(void 0),W?.(void 0)};Ut.select(lt.current).on("mousemove",t).on("mouseout",v)},[a,i,W]),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(f.motion.svg,{width:`${O}px`,height:`${G}px`,viewBox:`0 0 ${O} ${G}`,direction:"ltr",ref:at,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${y.left},${y.top})`,children:[e.jsxRuntimeExports.jsx("clipPath",{id:`above${E}`,children:e.jsxRuntimeExports.jsx("path",{d:$t(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx("clipPath",{id:`below${E}`,children:e.jsxRuntimeExports.jsx("path",{d:St(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx(Wt.HighlightArea,{areaSettings:ct,width:x,height:g,scale:a,animate:n,isInView:r}),e.jsxRuntimeExports.jsx(bt.CustomArea,{areaSettings:xt,scaleX:a,scaleY:s,animate:n,isInView:r}),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(Ht.YTicksAndGridLines,{values:kt.filter(t=>t!==0),y:kt.filter(t=>t!==0).map(t=>s(t)),x1:0-R,x2:x+y.right,styles:{gridLines:h?.yAxis?.gridLines,labels:h?.yAxis?.labels},classNames:{gridLines:p?.yAxis?.gridLines,labels:p?.yAxis?.labels},suffix:D,prefix:w,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:S}),e.jsxRuntimeExports.jsx(Ft.Axis,{y1:s(C<0?0:C),y2:s(C<0?0:C),x1:0-R,x2:x+y.right,label:Et.numberFormattingFunction(C<0?0:C,"NA",S,w,D),labelPos:{x:0-R,y:s(C<0?0:C),dx:0,dy:wt<0?"1rem":-5},classNames:{axis:p?.xAxis?.axis,label:p?.yAxis?.labels},styles:{axis:h?.xAxis?.axis,label:h?.yAxis?.labels}}),e.jsxRuntimeExports.jsx(Mt.AxisTitle,{x:0-R-15,y:g/2,style:h?.yAxis?.title,className:p?.yAxis?.title,text:U,rotate90:!0})]})}),e.jsxRuntimeExports.jsx(Pt.XTicksAndGridLines,{values:Lt.map(t=>m.format(t,o)),x:Lt.map(t=>a(t)),y1:0,y2:g,styles:{gridLines:h?.xAxis?.gridLines,labels:h?.xAxis?.labels},classNames:{gridLines:e.mo("opacity-0",p?.xAxis?.gridLines),labels:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs",p?.xAxis?.labels)},suffix:D,prefix:w,labelType:"primary",showGridLines:!0,precision:S}),nt.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.path,{clipPath:`url(#below${E})`,d:Dt(i)||"",style:{fill:Q[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:1},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{clipPath:`url(#above${E})`,d:Dt(i)||"",style:{fill:Q[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.path,{d:vt(i)||"",style:{fill:"none",stroke:j[0],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:vt(i)||"",opacity:1},whileInView:{pathLength:1,d:vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(f.motion.path,{style:{fill:"none",stroke:j[1],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:Vt(i)||"",opacity:1},whileInView:{pathLength:1,d:Vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),ft?null:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(f.motion.text,{style:{fill:j[0]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y1)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[0]},M[0]),e.jsxRuntimeExports.jsx(f.motion.text,{style:{fill:j[1]},className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y2)},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[1]},M[1])]}),q?e.jsxRuntimeExports.jsx("line",{y1:0,y2:g,x1:a(q.date),x2:a(q.date),className:e.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",p?.mouseOverLine),style:h?.mouseOverLine}):null,i.map((t,v)=>e.jsxRuntimeExports.jsxs(f.motion.g,{children:[T.checkIfNullOrUndefined(t.y1)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(f.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:j[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y1)},whileInView:{opacity:1,transition:{duration:.5,delay:n.duration},cx:a(t.date),cy:s(t.y1)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(f.motion.text,{dy:t.y2<t.y1?-8:"1em",style:{fill:j[0],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-1 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y1)},whileInView:{opacity:1,x:a(t.date),y:s(t.y1),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y1,"NA",S,w,D)}):null]}),T.checkIfNullOrUndefined(t.y2)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(f.motion.circle,{r:x/i.length<5?0:x/i.length<20?2:4,style:{fill:j[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y2)},whileInView:{opacity:1,transition:{duration:c?n.duration:.5,delay:c?0:n.duration},cx:a(t.date),cy:s(t.y2)}},initial:"initial",animate:r?"whileInView":"initial"}):null,l?e.jsxRuntimeExports.jsx(f.motion.text,{dy:t.y2>t.y1?-8:"1em",style:{fill:j[1],textAnchor:"middle",...h?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-2 text-xs font-bold",p?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y2)},whileInView:{opacity:1,x:a(t.date),y:s(t.y2),transition:{duration:c?n.duration:.5,delay:c?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y2,"NA",S,w,D)}):null]})]},v))]}),Y?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Y.map((t,v)=>e.jsxRuntimeExports.jsx(Gt.RefLineY,{text:t.text,color:t.color,y:s(t.value),x1:0-R,x2:x+y.right,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v))}):null,e.jsxRuntimeExports.jsx("g",{children:L.map((t,v)=>{const I=bt.getLineEndPoint({x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8},{x:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,y:t.yCoordinate?s(t.yCoordinate):0},T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius),mt=t.showConnector?{y1:I.y,x1:I.x,y2:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0):0+(t.yOffset||0),x2:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),cy:t.yCoordinate?s(t.yCoordinate):0,cx:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date)):0,circleRadius:T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius,strokeWidth:t.showConnector===!0?2:Math.min(t.showConnector||0,1)}:void 0,Rt={y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8,x:K?0:t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),width:K?t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0):x+y.right-(t.xCoordinate?a(m.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0)),maxWidth:t.maxWidth,fontWeight:t.fontWeight,align:t.align};return e.jsxRuntimeExports.jsx(bt.Annotation,{color:t.color,connectorsSettings:mt,labelSettings:Rt,text:t.text,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v)})}),nt.filter(t=>t.position==="after").map(t=>t.layer),e.jsxRuntimeExports.jsx("rect",{ref:lt,style:{fill:"none",pointerEvents:"all"},width:x,height:g})]})}),q&&H&&ot&&b?e.jsxRuntimeExports.jsx(Tt.Tooltip,{data:q,body:H,xPos:ot,yPos:b,backgroundStyle:h?.tooltip,className:p?.tooltip}):null]})}function ie(dt){const{data:V,graphTitle:O,suffix:G="",sources:j,prefix:D="",graphDescription:w,height:o,width:l,footNote:z,noOfXTicks:yt=10,dateFormat:R="yyyy",showValues:gt=!1,padding:J,lineColors:H=[pt.Colors.light.categoricalColors.colors[0],pt.Colors.light.categoricalColors.colors[1]],backgroundColor:N=!1,leftMargin:W=30,rightMargin:n=50,topMargin:K=20,bottomMargin:ft=25,tooltip:M,highlightAreaSettings:Q=[],relativeHeight:E,onSeriesMouseOver:Z,graphID:_,graphDownload:Y=!1,dataDownload:k=!1,animate:X=!1,language:L="en",minHeight:F=0,labels:U,showColorLegendAtTop:tt=!1,colorLegendTitle:et,diffAreaColors:it=[pt.Colors.alerts.red,pt.Colors.alerts.darkGreen],strokeWidth:P=2,showDots:h=!0,refValues:p=[],minValue:S,maxValue:nt,annotations:at=[],customHighlightAreaSettings:r=[],theme:c="light",ariaLabel:jt,yAxisTitle:$,noOfYTicks:q=5,minDate:st,maxDate:ot,curveType:rt="curve",styles:b,classNames:A,precision:y=2,customLayers:lt=[]}=dt,[i,ct]=d.useState(0),[xt,x]=d.useState(0),g=d.useRef(null),ut=d.useRef(null);return d.useEffect(()=>{const u=new ResizeObserver(B=>{ct(l||B[0].target.clientWidth||620),x(o||B[0].target.clientHeight||480)});return g.current&&(x(g.current.clientHeight||480),ct(g.current.clientWidth||620),l||u.observe(g.current)),()=>u.disconnect()},[l,o]),e.jsxRuntimeExports.jsx("div",{className:`${c||"light"} flex ${l?"w-fit grow-0":"w-full grow"}`,dir:L==="he"||L==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${N?N===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${L||"en"}`,l?"w-fit":"w-full",A?.graphContainer),style:{...b?.graphContainer||{},...N&&N!==!0?{backgroundColor:N}:{}},id:_,ref:ut,"aria-label":jt||`${O?`The graph shows ${O}. `:""}This is a line chart that highlights the difference between two datasets over time.${w?` ${w}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:N?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[O||w||Y||k?e.jsxRuntimeExports.jsx(Qt.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:A?.title,description:A?.description},graphTitle:O,graphDescription:w,width:l,graphDownload:Y?ut.current:void 0,dataDownload:k?V.map(u=>u.data).filter(u=>u!==void 0).length>0?V.map(u=>u.data).filter(u=>u!==void 0):V.filter(u=>u!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:V.length===0?e.jsxRuntimeExports.jsx(te.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[tt?e.jsxRuntimeExports.jsx(Zt.ColorLegend,{colorDomain:U,colorLegendTitle:et,colors:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:g,"aria-label":"Graph area",children:(l||i)&&(o||xt)?e.jsxRuntimeExports.jsx(ee,{data:V,lineColors:H,colorDomain:U,width:l||i,height:Math.max(F,o||(E?F?(l||i)*E>F?(l||i)*E:F:(l||i)*E:xt)),suffix:G,prefix:D,dateFormat:R,showValues:gt,noOfXTicks:yt,leftMargin:W,rightMargin:n,topMargin:K,bottomMargin:ft,highlightAreaSettings:Q,tooltip:M,onSeriesMouseOver:Z,showColorLegendAtTop:tt,animate:X===!0?{duration:.5,once:!0,amount:.5}:X||{duration:0,once:!0,amount:0},rtl:L==="he"||L==="ar",diffAreaColors:it,idSuffix:_t.generateRandomString(8),strokeWidth:P,showDots:h,refValues:p,minValue:S,maxValue:nt,annotations:at,customHighlightAreaSettings:r,yAxisTitle:$,noOfYTicks:q,minDate:st,maxDate:ot,curveType:rt,styles:b,classNames:A,precision:y,customLayers:lt}):null})]})}),j||z?e.jsxRuntimeExports.jsx(Kt.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:j,footNote:z,width:l}):null]})})})})}exports.DifferenceLineChart=ie;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CHPV5EwG-DDoeWRVt.cjs"),y=require("react"),h=require("./parse-hMnG_lRV.cjs"),qt=require("./index-CQ3e6Ewi.cjs"),Et=require("./numberFormattingFunction-02t-wJta.cjs"),Tt=require("./Tooltip-De16GWhY.cjs"),T=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),bt=require("./customArea-CK768gCn.cjs"),Mt=require("./AxisTitle-CK9YeovX.cjs"),Ft=require("./Axis-DE7dSn1_.cjs"),Pt=require("./XTicksAndGridLines-CCzXIV8d.cjs"),Gt=require("./ReferenceLine-CFVBBN__.cjs"),Ht=require("./YTicksAndGridLines-DBDuz6vb.cjs"),Wt=require("./index-BYzIB5V6.cjs"),Yt=require("./time-Byw_jYQ7.cjs"),Xt=require("./linear-BVckp9RD.cjs"),At=require("./line-DHV4JwCR.cjs"),ht=require("./step-BZ3C8QFW.cjs"),Ct=require("./area-D3Qx7k7K.cjs"),Ut=require("./select-Bnfk0lJx.cjs"),Bt=require("./init-DU0ybBc_.cjs"),zt=require("./pointer-Dkq5NV1q.cjs"),Jt=require("./use-in-view-sQJZ_xDO.cjs"),j=require("./proxy-BHRoeZgd.cjs"),Kt=require("./GraphFooter.cjs"),Qt=require("./GraphHeader.cjs"),Zt=require("./ColorLegend.cjs"),pt=require("./Colors.cjs"),_t=require("./generateRandomString-B5zBiJzS.cjs"),te=require("./EmptyState-d8_8SxeW.cjs");function ee(dt){const{data:V,width:O,height:G,lineColors:l,suffix:D,prefix:w,dateFormat:o,showValues:c,noOfXTicks:z,rightMargin:yt,leftMargin:R,topMargin:gt,bottomMargin:J,tooltip:H,highlightAreaSettings:N,onSeriesMouseOver:W,animate:n,rtl:K,showColorLegendAtTop:ft,colorDomain:M,diffAreaColors:Q,idSuffix:E,strokeWidth:Z,showDots:_,refValues:Y,minValue:k,maxValue:X,annotations:L,customHighlightAreaSettings:F,yAxisTitle:U,noOfYTicks:tt,minDate:et,maxDate:it,curveType:P,styles:p,classNames:d,precision:S,customLayers:nt}=dt,at=y.useRef(null),r=Jt.useInView(at,{once:n.once,amount:n.amount}),[x,jt]=y.useState(!1);y.useEffect(()=>{if(r&&!x){const t=setTimeout(()=>{jt(!0)},(n.duration+.5)*1e3);return()=>clearTimeout(t)}},[r,x,n.duration]);const $=P==="linear"?At.curveLinear:P==="step"?ht.curveStep:P==="stepAfter"?ht.stepAfter:P==="stepBefore"?ht.stepBefore:ht.monotoneX,[q,st]=y.useState(void 0),[ot,rt]=y.useState(void 0),[b,A]=y.useState(void 0),g={top:gt,bottom:J,left:U?R+30:R,right:yt},lt=y.useRef(null),i=qt.orderBy(V.map(t=>({...t,date:h.parse(`${t.date}`,o,new Date)})),["date"],["asc"]),ct=N.map(t=>({...t,coordinates:[t.coordinates[0]===null?null:h.parse(`${t.coordinates[0]}`,o,new Date),t.coordinates[1]===null?null:h.parse(`${t.coordinates[1]}`,o,new Date)]})),xt=F.map(t=>({...t,coordinates:t.coordinates.map((v,I)=>I%2===0?h.parse(`${v}`,o,new Date):v)})),u=O-g.left-g.right,f=G-g.top-g.bottom,ut=et?h.parse(`${et}`,o,new Date):i[0].date,m=it?h.parse(`${it}`,o,new Date):i[i.length-1].date,B=Math.min(...i.map(t=>t.y1))!==1/0?Math.min(...i.map(t=>t.y1))>0?0:Math.min(...i.map(t=>t.y1)):0,Ot=Math.min(...i.map(t=>t.y2))!==1/0?Math.min(...i.map(t=>t.y2))>0?0:Math.min(...i.map(t=>t.y2)):0,Nt=Math.max(...i.map(t=>t.y1))!==1/0?Math.max(...i.map(t=>t.y1)):0,It=Math.max(...i.map(t=>t.y2))!==1/0?Math.max(...i.map(t=>t.y2)):0,C=T.checkIfNullOrUndefined(k)?B<Ot?B:Ot:k,wt=Nt>It?Nt:It,a=Yt.time().domain([ut,m]).range([0,u]),s=Xt.linear().domain([T.checkIfNullOrUndefined(k)?C:k,T.checkIfNullOrUndefined(X)?wt>0?wt:0:X]).range([f,0]).nice(),vt=At.line().x(t=>a(t.date)).y(t=>s(t.y1)).curve($),Vt=At.line().x(t=>a(t.date)).y(t=>s(t.y2)).curve($),Dt=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(t=>s(t.y2)).curve($),St=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y1)).y0(0).curve($),$t=Ct.area().x(t=>a(t.date)).y1(t=>s(t.y2)).y0(0).curve($),kt=s.ticks(tt),Lt=a.ticks(z);return y.useEffect(()=>{const t=I=>{const mt=i[Bt.bisectCenter(i.map(Rt=>Rt.date),a.invert(zt.pointer(I)[0]),0)];st(mt||i[i.length-1]),W?.(mt||i[i.length-1]),A(I.clientY),rt(I.clientX)},v=()=>{st(void 0),rt(void 0),A(void 0),W?.(void 0)};Ut.select(lt.current).on("mousemove",t).on("mouseout",v)},[a,i,W]),e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsx(j.motion.svg,{width:`${O}px`,height:`${G}px`,viewBox:`0 0 ${O} ${G}`,direction:"ltr",ref:at,children:e.jsxRuntimeExports.jsxs("g",{transform:`translate(${g.left},${g.top})`,children:[e.jsxRuntimeExports.jsx("clipPath",{id:`above${E}`,children:e.jsxRuntimeExports.jsx("path",{d:$t(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx("clipPath",{id:`below${E}`,children:e.jsxRuntimeExports.jsx("path",{d:St(i),style:{fill:"none"}})}),e.jsxRuntimeExports.jsx(Wt.HighlightArea,{areaSettings:ct,width:u,height:f,scale:a,animate:n,isInView:r}),e.jsxRuntimeExports.jsx(bt.CustomArea,{areaSettings:xt,scaleX:a,scaleY:s,animate:n,isInView:r}),e.jsxRuntimeExports.jsx("g",{children:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(Ht.YTicksAndGridLines,{values:kt.filter(t=>t!==0),y:kt.filter(t=>t!==0).map(t=>s(t)),x1:0-R,x2:u+g.right,styles:{gridLines:p?.yAxis?.gridLines,labels:p?.yAxis?.labels},classNames:{gridLines:d?.yAxis?.gridLines,labels:d?.yAxis?.labels},suffix:D,prefix:w,labelType:"secondary",showGridLines:!0,labelPos:"vertical",precision:S}),e.jsxRuntimeExports.jsx(Ft.Axis,{y1:s(C<0?0:C),y2:s(C<0?0:C),x1:0-R,x2:u+g.right,label:Et.numberFormattingFunction(C<0?0:C,"NA",S,w,D),labelPos:{x:0-R,y:s(C<0?0:C),dx:0,dy:wt<0?"1rem":-5},classNames:{axis:d?.xAxis?.axis,label:d?.yAxis?.labels},styles:{axis:p?.xAxis?.axis,label:p?.yAxis?.labels}}),e.jsxRuntimeExports.jsx(Mt.AxisTitle,{x:0-R-15,y:f/2,style:p?.yAxis?.title,className:d?.yAxis?.title,text:U,rotate90:!0})]})}),e.jsxRuntimeExports.jsx(Pt.XTicksAndGridLines,{values:Lt.map(t=>h.format(t,o)),x:Lt.map(t=>a(t)),y1:0,y2:f,styles:{gridLines:p?.xAxis?.gridLines,labels:p?.xAxis?.labels},classNames:{gridLines:e.mo("opacity-0",d?.xAxis?.gridLines),labels:e.mo("fill-primary-gray-700 dark:fill-primary-gray-300 xs:max-[360px]:hidden text-[9px] md:text-[10px] lg:text-xs",d?.xAxis?.labels)},suffix:D,prefix:w,labelType:"primary",showGridLines:!0,precision:S}),nt.filter(t=>t.position==="before").map(t=>t.layer),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(j.motion.path,{clipPath:`url(#below${E})`,d:Dt(i)||"",style:{fill:Q[1]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:1},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(j.motion.path,{clipPath:`url(#above${E})`,d:Dt(i)||"",style:{fill:Q[0]},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0},whileInView:{opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"})]}),e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(j.motion.path,{d:vt(i)||"",style:{fill:"none",stroke:l[0],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:vt(i)||"",opacity:1},whileInView:{pathLength:1,d:vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),e.jsxRuntimeExports.jsx(j.motion.path,{style:{fill:"none",stroke:l[1],strokeWidth:Z},exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{pathLength:0,d:Vt(i)||"",opacity:1},whileInView:{pathLength:1,d:Vt(i)||"",opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:r?"whileInView":"initial"}),ft?null:e.jsxRuntimeExports.jsxs("g",{children:[e.jsxRuntimeExports.jsx(j.motion.text,{className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y1),fill:l[0]},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y1),fill:l[0],transition:{duration:x?n.duration:.5,delay:x?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[0]},M[0]),e.jsxRuntimeExports.jsx(j.motion.text,{className:"text-xs",dx:5,dy:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(i[i.length-1].date),y:s(i[i.length-1].y2),fill:l[1]},whileInView:{opacity:1,x:a(i[i.length-1].date),y:s(i[i.length-1].y2),fill:l[1],transition:{duration:x?n.duration:.5,delay:x?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:M[1]},M[1])]}),q?e.jsxRuntimeExports.jsx("line",{y1:0,y2:f,x1:a(q.date),x2:a(q.date),className:e.mo("undp-tick-line stroke-primary-gray-700 dark:stroke-primary-gray-100",d?.mouseOverLine),style:p?.mouseOverLine}):null,i.map((t,v)=>e.jsxRuntimeExports.jsxs(j.motion.g,{children:[T.checkIfNullOrUndefined(t.y1)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(j.motion.circle,{r:u/i.length<5?0:u/i.length<20?2:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y1),fill:l[0]},whileInView:{opacity:1,fill:l[0],transition:{duration:.5,delay:n.duration},cx:a(t.date),cy:s(t.y1)}},initial:"initial",animate:r?"whileInView":"initial"}):null,c?e.jsxRuntimeExports.jsx(j.motion.text,{dy:t.y2<t.y1?-8:"1em",style:{textAnchor:"middle",...p?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-1 text-xs font-bold",d?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y1),fill:l[0]},whileInView:{opacity:1,fill:l[0],x:a(t.date),y:s(t.y1),transition:{duration:x?n.duration:.5,delay:x?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y1,"NA",S,w,D)}):null]}),T.checkIfNullOrUndefined(t.y2)?null:e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[_?e.jsxRuntimeExports.jsx(j.motion.circle,{r:u/i.length<5?0:u/i.length<20?2:4,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,cx:a(t.date),cy:s(t.y2),fill:l[1]},whileInView:{opacity:1,fill:l[1],transition:{duration:x?n.duration:.5,delay:x?0:n.duration},cx:a(t.date),cy:s(t.y2)}},initial:"initial",animate:r?"whileInView":"initial"}):null,c?e.jsxRuntimeExports.jsx(j.motion.text,{dy:t.y2>t.y1?-8:"1em",style:{textAnchor:"middle",...p?.graphObjectValues||{}},className:e.mo("graph-value graph-value-line-2 text-xs font-bold",d?.graphObjectValues),exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{opacity:0,x:a(t.date),y:s(t.y2),fill:l[1]},whileInView:{opacity:1,x:a(t.date),y:s(t.y2),fill:l[1],transition:{duration:x?n.duration:.5,delay:x?0:n.duration}}},initial:"initial",animate:r?"whileInView":"initial",children:Et.numberFormattingFunction(t.y2,"NA",S,w,D)}):null]})]},v))]}),Y?e.jsxRuntimeExports.jsx(e.jsxRuntimeExports.Fragment,{children:Y.map((t,v)=>e.jsxRuntimeExports.jsx(Gt.RefLineY,{text:t.text,color:t.color,y:s(t.value),x1:0-R,x2:u+g.right,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v))}):null,e.jsxRuntimeExports.jsx("g",{children:L.map((t,v)=>{const I=bt.getLineEndPoint({x:t.xCoordinate?a(h.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8},{x:t.xCoordinate?a(h.parse(`${t.xCoordinate}`,o,new Date)):0,y:t.yCoordinate?s(t.yCoordinate):0},T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius),mt=t.showConnector?{y1:I.y,x1:I.x,y2:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0):0+(t.yOffset||0),x2:t.xCoordinate?a(h.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),cy:t.yCoordinate?s(t.yCoordinate):0,cx:t.xCoordinate?a(h.parse(`${t.xCoordinate}`,o,new Date)):0,circleRadius:T.checkIfNullOrUndefined(t.connectorRadius)?3.5:t.connectorRadius,strokeWidth:t.showConnector===!0?2:Math.min(t.showConnector||0,1)}:void 0,Rt={y:t.yCoordinate?s(t.yCoordinate)+(t.yOffset||0)-8:0+(t.yOffset||0)-8,x:K?0:t.xCoordinate?a(h.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0),width:K?t.xCoordinate?a(h.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0):u+g.right-(t.xCoordinate?a(h.parse(`${t.xCoordinate}`,o,new Date))+(t.xOffset||0):0+(t.xOffset||0)),maxWidth:t.maxWidth,fontWeight:t.fontWeight,align:t.align};return e.jsxRuntimeExports.jsx(bt.Annotation,{color:t.color,connectorsSettings:mt,labelSettings:Rt,text:t.text,classNames:t.classNames,styles:t.styles,animate:n,isInView:r},v)})}),nt.filter(t=>t.position==="after").map(t=>t.layer),e.jsxRuntimeExports.jsx("rect",{ref:lt,style:{fill:"none",pointerEvents:"all"},width:u,height:f})]})}),q&&H&&ot&&b?e.jsxRuntimeExports.jsx(Tt.Tooltip,{data:q,body:H,xPos:ot,yPos:b,backgroundStyle:p?.tooltip,className:d?.tooltip}):null]})}function ie(dt){const{data:V,graphTitle:O,suffix:G="",sources:l,prefix:D="",graphDescription:w,height:o,width:c,footNote:z,noOfXTicks:yt=10,dateFormat:R="yyyy",showValues:gt=!1,padding:J,lineColors:H=[pt.Colors.light.categoricalColors.colors[0],pt.Colors.light.categoricalColors.colors[1]],backgroundColor:N=!1,leftMargin:W=30,rightMargin:n=50,topMargin:K=20,bottomMargin:ft=25,tooltip:M,highlightAreaSettings:Q=[],relativeHeight:E,onSeriesMouseOver:Z,graphID:_,graphDownload:Y=!1,dataDownload:k=!1,animate:X=!1,language:L="en",minHeight:F=0,labels:U,showColorLegendAtTop:tt=!1,colorLegendTitle:et,diffAreaColors:it=[pt.Colors.alerts.red,pt.Colors.alerts.darkGreen],strokeWidth:P=2,showDots:p=!0,refValues:d=[],minValue:S,maxValue:nt,annotations:at=[],customHighlightAreaSettings:r=[],theme:x="light",ariaLabel:jt,yAxisTitle:$,noOfYTicks:q=5,minDate:st,maxDate:ot,curveType:rt="curve",styles:b,classNames:A,precision:g=2,customLayers:lt=[]}=dt,[i,ct]=y.useState(0),[xt,u]=y.useState(0),f=y.useRef(null),ut=y.useRef(null);return y.useEffect(()=>{const m=new ResizeObserver(B=>{ct(c||B[0].target.clientWidth||620),u(o||B[0].target.clientHeight||480)});return f.current&&(u(f.current.clientHeight||480),ct(f.current.clientWidth||620),c||m.observe(f.current)),()=>m.disconnect()},[c,o]),e.jsxRuntimeExports.jsx("div",{className:`${x||"light"} flex ${c?"w-fit grow-0":"w-full grow"}`,dir:L==="he"||L==="ar"?"rtl":void 0,children:e.jsxRuntimeExports.jsx("div",{className:e.mo(`${N?N===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${L||"en"}`,c?"w-fit":"w-full",A?.graphContainer),style:{...b?.graphContainer||{},...N&&N!==!0?{backgroundColor:N}:{}},id:_,ref:ut,"aria-label":jt||`${O?`The graph shows ${O}. `:""}This is a line chart that highlights the difference between two datasets over time.${w?` ${w}`:""}`,children:e.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:N?J||"1rem":J||0},children:e.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[O||w||Y||k?e.jsxRuntimeExports.jsx(Qt.GraphHeader,{styles:{title:b?.title,description:b?.description},classNames:{title:A?.title,description:A?.description},graphTitle:O,graphDescription:w,width:c,graphDownload:Y?ut.current:void 0,dataDownload:k?V.map(m=>m.data).filter(m=>m!==void 0).length>0?V.map(m=>m.data).filter(m=>m!==void 0):V.filter(m=>m!==void 0):null}):null,e.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:V.length===0?e.jsxRuntimeExports.jsx(te.EmptyState,{}):e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[tt?e.jsxRuntimeExports.jsx(Zt.ColorLegend,{colorDomain:U,colorLegendTitle:et,colors:H,showNAColor:!1}):null,e.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center leading-0",ref:f,"aria-label":"Graph area",children:(c||i)&&(o||xt)?e.jsxRuntimeExports.jsx(ee,{data:V,lineColors:H,colorDomain:U,width:c||i,height:Math.max(F,o||(E?F?(c||i)*E>F?(c||i)*E:F:(c||i)*E:xt)),suffix:G,prefix:D,dateFormat:R,showValues:gt,noOfXTicks:yt,leftMargin:W,rightMargin:n,topMargin:K,bottomMargin:ft,highlightAreaSettings:Q,tooltip:M,onSeriesMouseOver:Z,showColorLegendAtTop:tt,animate:X===!0?{duration:.5,once:!0,amount:.5}:X||{duration:0,once:!0,amount:0},rtl:L==="he"||L==="ar",diffAreaColors:it,idSuffix:_t.generateRandomString(8),strokeWidth:P,showDots:p,refValues:d,minValue:S,maxValue:nt,annotations:at,customHighlightAreaSettings:r,yAxisTitle:$,noOfYTicks:q,minDate:st,maxDate:ot,curveType:rt,styles:b,classNames:A,precision:g,customLayers:lt}):null})]})}),l||z?e.jsxRuntimeExports.jsx(Kt.GraphFooter,{styles:{footnote:b?.footnote,source:b?.source},classNames:{footnote:A?.footnote,source:A?.source},sources:l,footNote:z,width:c}):null]})})})})}exports.DifferenceLineChart=ie;
|
|
2
2
|
//# sourceMappingURL=DifferenceLineChart.cjs.map
|