@undp/data-viz 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BarGraph.cjs +1 -1
- package/dist/BarGraph.cjs.map +1 -1
- package/dist/BarGraph.js +650 -648
- package/dist/BarGraph.js.map +1 -1
- package/dist/BulletChart.cjs +1 -1
- package/dist/BulletChart.cjs.map +1 -1
- package/dist/BulletChart.js +210 -208
- package/dist/BulletChart.js.map +1 -1
- package/dist/ButterflyChart.cjs +1 -1
- package/dist/ButterflyChart.cjs.map +1 -1
- package/dist/ButterflyChart.js +42 -40
- package/dist/ButterflyChart.js.map +1 -1
- package/dist/DifferenceLineChart.cjs +1 -1
- package/dist/DifferenceLineChart.cjs.map +1 -1
- package/dist/DifferenceLineChart.js +122 -120
- package/dist/DifferenceLineChart.js.map +1 -1
- package/dist/DualAxisLineChart.cjs +1 -1
- package/dist/DualAxisLineChart.cjs.map +1 -1
- package/dist/DualAxisLineChart.js +133 -113
- package/dist/DualAxisLineChart.js.map +1 -1
- package/dist/DumbbellChart.cjs +1 -1
- package/dist/DumbbellChart.cjs.map +1 -1
- package/dist/DumbbellChart.js +274 -274
- package/dist/DumbbellChart.js.map +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs +1 -1
- package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
- package/dist/LineChartWithConfidenceInterval.js +194 -174
- package/dist/LineChartWithConfidenceInterval.js.map +1 -1
- package/dist/MultiLineAltChart.cjs +1 -1
- package/dist/MultiLineAltChart.cjs.map +1 -1
- package/dist/MultiLineAltChart.js +160 -161
- package/dist/MultiLineAltChart.js.map +1 -1
- package/dist/MultiLineChart.cjs +1 -1
- package/dist/MultiLineChart.cjs.map +1 -1
- package/dist/MultiLineChart.js +77 -66
- package/dist/MultiLineChart.js.map +1 -1
- package/dist/ParetoChart.cjs +1 -1
- package/dist/ParetoChart.cjs.map +1 -1
- package/dist/ParetoChart.js +166 -161
- package/dist/ParetoChart.js.map +1 -1
- package/dist/RadarChart.cjs +1 -1
- package/dist/RadarChart.cjs.map +1 -1
- package/dist/RadarChart.js +253 -241
- package/dist/RadarChart.js.map +1 -1
- package/dist/{RegressionLine-mH7UKOPi.js → RegressionLine-C2--oMQq.js} +10 -9
- package/dist/RegressionLine-C2--oMQq.js.map +1 -0
- package/dist/RegressionLine-Dj0GSiAp.cjs +2 -0
- package/dist/RegressionLine-Dj0GSiAp.cjs.map +1 -0
- package/dist/ScatterPlot.cjs +1 -1
- package/dist/ScatterPlot.cjs.map +1 -1
- package/dist/ScatterPlot.js +130 -129
- package/dist/ScatterPlot.js.map +1 -1
- package/dist/SimpleLineChart.cjs +1 -1
- package/dist/SimpleLineChart.cjs.map +1 -1
- package/dist/SimpleLineChart.js +43 -38
- package/dist/SimpleLineChart.js.map +1 -1
- package/dist/SlopeChart.cjs +1 -1
- package/dist/SlopeChart.cjs.map +1 -1
- package/dist/SlopeChart.js +113 -109
- package/dist/SlopeChart.js.map +1 -1
- package/dist/StripChart.cjs +1 -1
- package/dist/StripChart.cjs.map +1 -1
- package/dist/StripChart.js +282 -270
- package/dist/StripChart.js.map +1 -1
- package/dist/ThreeDGlobe.cjs +1 -1
- package/dist/ThreeDGlobe.cjs.map +1 -1
- package/dist/ThreeDGlobe.js +284 -349
- package/dist/ThreeDGlobe.js.map +1 -1
- package/dist/UnitChart.cjs +1 -1
- package/dist/UnitChart.cjs.map +1 -1
- package/dist/UnitChart.js +20 -21
- package/dist/UnitChart.js.map +1 -1
- package/dist/getCentroidCoordinates-Dfk6IqEG.js +70 -0
- package/dist/getCentroidCoordinates-Dfk6IqEG.js.map +1 -0
- package/dist/getCentroidCoordinates-DxTBqzp2.cjs +2 -0
- package/dist/getCentroidCoordinates-DxTBqzp2.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +34 -32
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.d.ts +8 -0
- package/dist/utils.js +16 -14
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/RegressionLine-mH7UKOPi.js.map +0 -1
- package/dist/RegressionLine-xKdiJ8sw.cjs +0 -2
- package/dist/RegressionLine-xKdiJ8sw.cjs.map +0 -1
package/dist/UnitChart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitChart.js","sources":["../src/Components/Graphs/UnitChart/index.tsx"],"sourcesContent":["import { useRef } from 'react';\r\nimport sum from 'lodash.sum';\r\nimport { H2, P } from '@undp/design-system-react/Typography';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport {\r\n UnitChartDataType,\r\n SourcesDataType,\r\n Languages,\r\n StyleObject,\r\n ClassNameObject,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: UnitChartDataType[];\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 /** Note with h2 tag just above the graph. Can be used to highlight text */\r\n note?: string;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Colors of the highlighted circles */\r\n colors?: 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\r\n // Graph Parameters\r\n /** Size of the visualization */\r\n size?: number;\r\n /** No. of dots in a single row */\r\n gridSize?: number;\r\n /** Spacing between 2 dots */\r\n unitPadding?: number;\r\n /** Total no. of dot that are rendered in the chart */\r\n totalNoOfDots?: number;\r\n /** Toggle visibility of stroke for the unfilled dots */\r\n showStrokeForWhiteDots?: boolean;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Toggle visibility of color scale */\r\n showColorScale?: boolean;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n\r\n // 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 UnitChart(props: Props) {\r\n const {\r\n data,\r\n size = 200,\r\n graphTitle,\r\n sources,\r\n colors = Colors.light.categoricalColors.colors,\r\n graphDescription,\r\n totalNoOfDots = 100,\r\n unitPadding = 3,\r\n gridSize = 10,\r\n footNote,\r\n padding,\r\n backgroundColor = false,\r\n graphID,\r\n graphDownload = false,\r\n language = 'en',\r\n showColorScale = true,\r\n showStrokeForWhiteDots = true,\r\n note,\r\n dataDownload = false,\r\n theme = 'light',\r\n width,\r\n height,\r\n minHeight = 0,\r\n relativeHeight,\r\n ariaLabel,\r\n styles,\r\n classNames,\r\n animate = false,\r\n precision = 2,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const animateValue =\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 const isInView = useInView(svgRef, {\r\n once: animateValue.once,\r\n amount: animateValue.amount,\r\n });\r\n const totalValue = sum(data.map(d => d.value));\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n const gridDimension = size / gridSize;\r\n const radius = (gridDimension - unitPadding * 2) / 2;\r\n if (radius <= 0) {\r\n console.error(\r\n 'The size of single unit is less than or equal to zero. Check values for ((dimension / gridSize) - (padding * 2)) / 2 is not less than or equal to 0.',\r\n );\r\n return null;\r\n }\r\n\r\n const cellsData: { color: string }[] = [];\r\n data.forEach((item, index) => {\r\n const count = Math.round((item.value / totalValue) * totalNoOfDots);\r\n for (let i = 0; i < count; i += 1) {\r\n cellsData.push({ color: colors[index] });\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 minHeight: 'inherit',\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}. ` : ''}${\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 gap-3 w-full grow'>\r\n {graphTitle || graphDescription || graphDownload ? (\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 {note ? (\r\n <H2\r\n marginBottom='2xs'\r\n className='text-primary-gray-700 dark:text-primary-gray-100 font-bold'\r\n style={{ width: width ? `${width}px` : '100%' }}\r\n >\r\n {note}\r\n </H2>\r\n ) : null}\r\n <div className='flex grow flex-col gap-4 justify-between'>\r\n <div>\r\n {showColorScale ? (\r\n <div\r\n className='mb-4 leading-0'\r\n style={{ width: width ? `${width}px` : '100%' }}\r\n aria-label='Color legend'\r\n >\r\n <div className='flex mb-0 flex-wrap gap-x-4 gap-y-1'>\r\n {data.map((d, i) => (\r\n <div className='flex gap-2 items-center' key={i}>\r\n <div\r\n className='w-3 h-3 rounded-full'\r\n style={{ backgroundColor: colors[i] }}\r\n />\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n className='text-primary-gray-700 dark:text-primary-gray-100'\r\n >\r\n {d.label}:{' '}\r\n <span className='font-bold'>\r\n {numberFormattingFunction(d.value, 'NA', precision)}\r\n </span>\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n ) : null}\r\n <div aria-label='Graph area'>\r\n <svg\r\n width={`${width || size}px`}\r\n height={`${Math.max(\r\n minHeight,\r\n height\r\n ? relativeHeight && width\r\n ? minHeight\r\n ? width * relativeHeight > minHeight\r\n ? width * relativeHeight\r\n : minHeight\r\n : width * relativeHeight\r\n : height\r\n : Math.floor((totalNoOfDots - 1) / gridSize) * gridDimension +\r\n gridDimension / 2 +\r\n radius +\r\n 5,\r\n )}px`}\r\n ref={svgRef}\r\n direction='ltr'\r\n viewBox={`0 0 ${width || size} ${Math.max(\r\n minHeight,\r\n height\r\n ? relativeHeight && width\r\n ? minHeight\r\n ? width * relativeHeight > minHeight\r\n ? width * relativeHeight\r\n : minHeight\r\n : width * relativeHeight\r\n : height\r\n : Math.floor((totalNoOfDots - 1) / gridSize) * gridDimension +\r\n gridDimension / 2 +\r\n radius +\r\n 5,\r\n )}`}\r\n >\r\n <AnimatePresence>\r\n <g>\r\n {cellsData.map((d, i) => (\r\n <motion.circle\r\n key={i}\r\n cx={(i % gridSize) * gridDimension + gridDimension / 2}\r\n cy={Math.floor(i / gridSize) * gridDimension + gridDimension / 2}\r\n style={{\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n }}\r\n variants={{\r\n initial: {\r\n fill: '#fff',\r\n opacity: 0,\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n },\r\n whileInView: {\r\n fill: d.color,\r\n opacity: 1,\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n transition: {\r\n duration: 0,\r\n delay: (animateValue.duration / cellsData.length) * i,\r\n },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n className={\r\n (d.color.toLowerCase() === '#fff' ||\r\n d.color.toLowerCase() === '#ffffff' ||\r\n d.color.toLowerCase() === 'white') &&\r\n showStrokeForWhiteDots\r\n ? 'stroke-primary-gray-400 dark:stroke-primary-gray-500'\r\n : ''\r\n }\r\n r={radius}\r\n />\r\n ))}\r\n </g>\r\n </AnimatePresence>\r\n </svg>\r\n </div>\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{\r\n footnote: styles?.footnote,\r\n source: styles?.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 </div>\r\n );\r\n}\r\n"],"names":["UnitChart","props","data","size","graphTitle","sources","colors","Colors","graphDescription","totalNoOfDots","unitPadding","gridSize","footNote","padding","backgroundColor","graphID","graphDownload","language","showColorScale","showStrokeForWhiteDots","note","dataDownload","theme","width","height","minHeight","relativeHeight","ariaLabel","styles","classNames","animate","precision","svgRef","useRef","animateValue","isInView","useInView","totalValue","sum","d","graphParentDiv","gridDimension","radius","cellsData","item","index","count","i","jsx","cn","jsxs","GraphHeader","H2","P","AnimatePresence","motion","GraphFooter"],"mappings":";;;;;;;;;;;AA2FO,SAASA,GAAUC,GAAc;AACtC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC,IAASC,EAAO,MAAM,kBAAkB;AAAA,IACxC,kBAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,aAAAC,IAAc;AAAA,IACd,UAAAC,IAAW;AAAA,IACX,UAAAC;AAAA,IACA,SAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,SAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,UAAAC,IAAW;AAAA,IACX,gBAAAC,IAAiB;AAAA,IACjB,wBAAAC,IAAyB;AAAA,IACzB,MAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,OAAAC,IAAQ;AAAA,IACR,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,gBAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,YAAAC;AAAA,IACA,SAAAC,IAAU;AAAA,IACV,WAAAC,IAAY;AAAA,EAAA,IACV9B,GACE+B,IAASC,EAAO,IAAI,GACpBC,IACJJ,MAAY,KACR,EAAE,UAAU,KAAK,MAAM,IAAM,QAAQ,QACrCA,KAAW,EAAE,UAAU,GAAG,MAAM,IAAM,QAAQ,EAAA,GAC9CK,IAAWC,EAAUJ,GAAQ;AAAA,IACjC,M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,EAAE,MAAM,YAAA,MAAkB,UACzBA,EAAE,MAAM,YAAA,MAAkB,aAC1BA,EAAE,MAAM,kBAAkB,YAC5BpB,IACI,yDACA;AAAA,4BAEN,GAAGuB;AAAA,0BAAA;AAAA,0BAnCEK;AAAA,wBAAA,CAqCR,GACH,EAAA,CACF;AAAA,sBAAA;AAAA,oBAAA,EACF,CACF;AAAA,kBAAA,GACF;AAAA,kBACC1C,KAAWO,IACVoC,gBAAAA,EAAAA;AAAAA,oBAACQ;AAAA,oBAAA;AAAA,sBACC,QAAQ;AAAA,wBACN,UAAU5B,GAAQ;AAAA,wBAClB,QAAQA,GAAQ;AAAA,sBAAA;AAAA,sBAElB,SAAAvB;AAAA,sBACA,UAAAO;AAAA,sBACA,OAAAW;AAAA,oBAAA;AAAA,kBAAA,IAEA;AAAA,gBAAA,EAAA,CACN;AAAA,cAAA,EAAA,CACF;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"UnitChart.js","sources":["../src/Components/Graphs/UnitChart/index.tsx"],"sourcesContent":["import { useRef } from 'react';\r\nimport sum from 'lodash.sum';\r\nimport { H2, P } from '@undp/design-system-react/Typography';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport {\r\n UnitChartDataType,\r\n SourcesDataType,\r\n Languages,\r\n StyleObject,\r\n ClassNameObject,\r\n AnimateDataType,\r\n} from '@/Types';\r\nimport { numberFormattingFunction } from '@/Utils/numberFormattingFunction';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: UnitChartDataType[];\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 /** Note with h2 tag just above the graph. Can be used to highlight text */\r\n note?: string;\r\n /** Footnote for the graph */\r\n footNote?: string | React.ReactNode;\r\n /** Source data for the graph */\r\n sources?: SourcesDataType[];\r\n /** Accessibility label */\r\n ariaLabel?: string;\r\n\r\n // Colors and Styling\r\n /** Colors of the highlighted circles */\r\n colors?: 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\r\n // Graph Parameters\r\n /** Size of the visualization */\r\n size?: number;\r\n /** No. of dots in a single row */\r\n gridSize?: number;\r\n /** Spacing between 2 dots */\r\n unitPadding?: number;\r\n /** Total no. of dot that are rendered in the chart */\r\n totalNoOfDots?: number;\r\n /** Toggle visibility of stroke for the unfilled dots */\r\n showStrokeForWhiteDots?: boolean;\r\n /** Toggles if the graph animates in when loaded. */\r\n animate?: boolean | AnimateDataType;\r\n /** Toggle visibility of color scale */\r\n showColorScale?: boolean;\r\n /** Specifies the number of decimal places to display in the value. */\r\n precision?: number;\r\n /** Enable graph download option as png */\r\n graphDownload?: boolean;\r\n /** Enable data download option as a csv */\r\n dataDownload?: boolean;\r\n\r\n // 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 UnitChart(props: Props) {\r\n const {\r\n data,\r\n size = 200,\r\n graphTitle,\r\n sources,\r\n colors = Colors.light.categoricalColors.colors,\r\n graphDescription,\r\n totalNoOfDots = 100,\r\n unitPadding = 3,\r\n gridSize = 10,\r\n footNote,\r\n padding,\r\n backgroundColor = false,\r\n graphID,\r\n graphDownload = false,\r\n language = 'en',\r\n showColorScale = true,\r\n showStrokeForWhiteDots = true,\r\n note,\r\n dataDownload = false,\r\n theme = 'light',\r\n width,\r\n height,\r\n minHeight = 0,\r\n relativeHeight,\r\n ariaLabel,\r\n styles,\r\n classNames,\r\n animate = false,\r\n precision = 2,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const animateValue =\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 const isInView = useInView(svgRef, {\r\n once: animateValue.once,\r\n amount: animateValue.amount,\r\n });\r\n const totalValue = sum(data.map(d => d.value));\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n const gridDimension = size / gridSize;\r\n const radius = (gridDimension - unitPadding * 2) / 2;\r\n if (radius <= 0) {\r\n console.error(\r\n 'The size of single unit is less than or equal to zero. Check values for ((dimension / gridSize) - (padding * 2)) / 2 is not less than or equal to 0.',\r\n );\r\n return null;\r\n }\r\n\r\n const cellsData: { color: string }[] = [];\r\n data.forEach((item, index) => {\r\n const count = Math.round((item.value / totalValue) * totalNoOfDots);\r\n for (let i = 0; i < count; i += 1) {\r\n cellsData.push({ color: colors[index] });\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 minHeight: 'inherit',\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}. ` : ''}${\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 gap-3 w-full grow'>\r\n {graphTitle || graphDescription || graphDownload ? (\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 {note ? (\r\n <H2\r\n marginBottom='2xs'\r\n className='text-primary-gray-700 dark:text-primary-gray-100 font-bold'\r\n style={{ width: width ? `${width}px` : '100%' }}\r\n >\r\n {note}\r\n </H2>\r\n ) : null}\r\n <div className='flex grow flex-col gap-4 justify-between'>\r\n <div>\r\n {showColorScale ? (\r\n <div\r\n className='mb-4 leading-0'\r\n style={{ width: width ? `${width}px` : '100%' }}\r\n aria-label='Color legend'\r\n >\r\n <div className='flex mb-0 flex-wrap gap-x-4 gap-y-1'>\r\n {data.map((d, i) => (\r\n <div className='flex gap-2 items-center' key={i}>\r\n <div\r\n className='w-3 h-3 rounded-full'\r\n style={{ backgroundColor: colors[i] }}\r\n />\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n className='text-primary-gray-700 dark:text-primary-gray-100'\r\n >\r\n {d.label}:{' '}\r\n <span className='font-bold'>\r\n {numberFormattingFunction(d.value, 'NA', precision)}\r\n </span>\r\n </P>\r\n </div>\r\n ))}\r\n </div>\r\n </div>\r\n ) : null}\r\n <div aria-label='Graph area'>\r\n <svg\r\n width={`${width || size}px`}\r\n height={`${Math.max(\r\n minHeight,\r\n height\r\n ? relativeHeight && width\r\n ? minHeight\r\n ? width * relativeHeight > minHeight\r\n ? width * relativeHeight\r\n : minHeight\r\n : width * relativeHeight\r\n : height\r\n : Math.floor((totalNoOfDots - 1) / gridSize) * gridDimension +\r\n gridDimension / 2 +\r\n radius +\r\n 5,\r\n )}px`}\r\n ref={svgRef}\r\n direction='ltr'\r\n viewBox={`0 0 ${width || size} ${Math.max(\r\n minHeight,\r\n height\r\n ? relativeHeight && width\r\n ? minHeight\r\n ? width * relativeHeight > minHeight\r\n ? width * relativeHeight\r\n : minHeight\r\n : width * relativeHeight\r\n : height\r\n : Math.floor((totalNoOfDots - 1) / gridSize) * gridDimension +\r\n gridDimension / 2 +\r\n radius +\r\n 5,\r\n )}`}\r\n >\r\n <AnimatePresence>\r\n <g>\r\n {cellsData.map((d, i) => (\r\n <motion.circle\r\n key={i}\r\n style={{\r\n strokeWidth: 1,\r\n }}\r\n variants={{\r\n initial: {\r\n fill: '#fff',\r\n opacity: 0,\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n },\r\n whileInView: {\r\n fill: d.color,\r\n opacity: 1,\r\n ...(!showStrokeForWhiteDots ? { stroke: d.color } : {}),\r\n strokeWidth: 1,\r\n cx: (i % gridSize) * gridDimension + gridDimension / 2,\r\n cy: Math.floor(i / gridSize) * gridDimension + gridDimension / 2,\r\n transition: {\r\n duration: 0,\r\n delay: (animateValue.duration / cellsData.length) * i,\r\n },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n className={\r\n (d.color.toLowerCase() === '#fff' ||\r\n d.color.toLowerCase() === '#ffffff' ||\r\n d.color.toLowerCase() === 'white') &&\r\n showStrokeForWhiteDots\r\n ? 'stroke-primary-gray-400 dark:stroke-primary-gray-500'\r\n : ''\r\n }\r\n r={radius}\r\n />\r\n ))}\r\n </g>\r\n </AnimatePresence>\r\n </svg>\r\n </div>\r\n </div>\r\n {sources || footNote ? (\r\n <GraphFooter\r\n styles={{\r\n footnote: styles?.footnote,\r\n source: styles?.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 </div>\r\n );\r\n}\r\n"],"names":["UnitChart","props","data","size","graphTitle","sources","colors","Colors","graphDescription","totalNoOfDots","unitPadding","gridSize","footNote","padding","backgroundColor","graphID","graphDownload","language","showColorScale","showStrokeForWhiteDots","note","dataDownload","theme","width","height","minHeight","relativeHeight","ariaLabel","styles","classNames","animate","precision","svgRef","useRef","animateValue","isInView","useInView","totalValue","sum","d","graphParentDiv","gridDimension","radius","cellsData","item","index","count","i","jsx","cn","jsxs","GraphHeader","H2","P","AnimatePresence","motion","GraphFooter"],"mappings":";;;;;;;;;;;AA2FO,SAASA,GAAUC,GAAc;AACtC,QAAM;AAAA,IACJ,MAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC,IAASC,EAAO,MAAM,kBAAkB;AAAA,IACxC,kBAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,aAAAC,IAAc;AAAA,IACd,UAAAC,IAAW;AAAA,IACX,UAAAC;AAAA,IACA,SAAAC;AAAA,IACA,iBAAAC,IAAkB;AAAA,IAClB,SAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,UAAAC,IAAW;AAAA,IACX,gBAAAC,IAAiB;AAAA,IACjB,wBAAAC,IAAyB;AAAA,IACzB,MAAAC;AAAA,IACA,cAAAC,IAAe;AAAA,IACf,OAAAC,IAAQ;AAAA,IACR,OAAAC;AAAA,IACA,QAA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AAY8B,IAAgBA,IAAgB;AAAA,gCACrD,IAAI,KAAK,MAAMM,IAAIpC,CAAQ,IAAI8B,IAAgBA,IAAgB;AAAA,gCAC/D,YAAY;AAAA,kCACV,UAAU;AAAA,kCACV,OAAQP,EAAa,WAAWS,EAAU,SAAUI;AAAA,gCAAA;AAAA,8BACtD;AAAA,4BACF;AAAA,4BAEF,SAAQ;AAAA,4BACR,SAASZ,IAAW,gBAAgB;AAAA,4BACpC,YACGI,EAAE,MAAM,YAAA,MAAkB,UACzBA,EAAE,MAAM,YAAA,MAAkB,aAC1BA,EAAE,MAAM,kBAAkB,YAC5BpB,IACI,yDACA;AAAA,4BAEN,GAAGuB;AAAA,0BAAA;AAAA,0BAlCEK;AAAA,wBAAA,CAoCR,GACH,EAAA,CACF;AAAA,sBAAA;AAAA,oBAAA,EACF,CACF;AAAA,kBAAA,GACF;AAAA,kBACC1C,KAAWO,IACVoC,gBAAAA,EAAAA;AAAAA,oBAACQ;AAAA,oBAAA;AAAA,sBACC,QAAQ;AAAA,wBACN,UAAU5B,GAAQ;AAAA,wBAClB,QAAQA,GAAQ;AAAA,sBAAA;AAAA,sBAElB,SAAAvB;AAAA,sBACA,UAAAO;AAAA,sBACA,OAAAW;AAAA,oBAAA;AAAA,kBAAA,IAEA;AAAA,gBAAA,EAAA,CACN;AAAA,cAAA,EAAA,CACF;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { g as d, e as s, t as c } from "./index-9tDEUqOZ.js";
|
|
2
|
+
function h(t) {
|
|
3
|
+
return d(
|
|
4
|
+
t,
|
|
5
|
+
(e, r) => e + m(r),
|
|
6
|
+
0
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function m(t) {
|
|
10
|
+
let e = 0, r;
|
|
11
|
+
switch (t.type) {
|
|
12
|
+
case "Polygon":
|
|
13
|
+
return u(t.coordinates);
|
|
14
|
+
case "MultiPolygon":
|
|
15
|
+
for (r = 0; r < t.coordinates.length; r++)
|
|
16
|
+
e += u(t.coordinates[r]);
|
|
17
|
+
return e;
|
|
18
|
+
case "Point":
|
|
19
|
+
case "MultiPoint":
|
|
20
|
+
case "LineString":
|
|
21
|
+
case "MultiLineString":
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
function u(t) {
|
|
27
|
+
let e = 0;
|
|
28
|
+
if (t && t.length > 0) {
|
|
29
|
+
e += Math.abs(f(t[0]));
|
|
30
|
+
for (let r = 1; r < t.length; r++)
|
|
31
|
+
e -= Math.abs(f(t[r]));
|
|
32
|
+
}
|
|
33
|
+
return e;
|
|
34
|
+
}
|
|
35
|
+
var M = s * s / 2, l = Math.PI / 180;
|
|
36
|
+
function f(t) {
|
|
37
|
+
const e = t.length - 1;
|
|
38
|
+
if (e <= 2) return 0;
|
|
39
|
+
let r = 0, n = 0;
|
|
40
|
+
for (; n < e; ) {
|
|
41
|
+
const i = t[n], o = t[n + 1 === e ? 0 : n + 1], a = t[n + 2 >= e ? (n + 2) % e : n + 2], g = i[0] * l, p = o[1] * l, y = a[0] * l;
|
|
42
|
+
r += (y - g) * Math.sin(p), n++;
|
|
43
|
+
}
|
|
44
|
+
return r * M;
|
|
45
|
+
}
|
|
46
|
+
var _ = h;
|
|
47
|
+
function w(t, e = !0) {
|
|
48
|
+
if (t.geometry.type === "Polygon" || e === !1)
|
|
49
|
+
return c(t).geometry.coordinates;
|
|
50
|
+
if (t.geometry.type === "MultiPolygon") {
|
|
51
|
+
let r = 0, n = null;
|
|
52
|
+
for (const i of t.geometry.coordinates) {
|
|
53
|
+
const o = {
|
|
54
|
+
type: "Feature",
|
|
55
|
+
geometry: {
|
|
56
|
+
type: "Polygon",
|
|
57
|
+
coordinates: i
|
|
58
|
+
},
|
|
59
|
+
properties: {}
|
|
60
|
+
}, a = _(o);
|
|
61
|
+
a > r && (r = a, n = o);
|
|
62
|
+
}
|
|
63
|
+
return c(n).geometry.coordinates;
|
|
64
|
+
}
|
|
65
|
+
throw new Error("Unsupported geometry type");
|
|
66
|
+
}
|
|
67
|
+
export {
|
|
68
|
+
w as g
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=getCentroidCoordinates-Dfk6IqEG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCentroidCoordinates-Dfk6IqEG.js","sources":["../node_modules/@turf/area/dist/esm/index.js","../src/Utils/getCentroidCoordinates.ts"],"sourcesContent":["// index.ts\nimport { earthRadius } from \"@turf/helpers\";\nimport { geomReduce } from \"@turf/meta\";\nfunction area(geojson) {\n return geomReduce(\n geojson,\n (value, geom) => {\n return value + calculateArea(geom);\n },\n 0\n );\n}\nfunction calculateArea(geom) {\n let total = 0;\n let i;\n switch (geom.type) {\n case \"Polygon\":\n return polygonArea(geom.coordinates);\n case \"MultiPolygon\":\n for (i = 0; i < geom.coordinates.length; i++) {\n total += polygonArea(geom.coordinates[i]);\n }\n return total;\n case \"Point\":\n case \"MultiPoint\":\n case \"LineString\":\n case \"MultiLineString\":\n return 0;\n }\n return 0;\n}\nfunction polygonArea(coords) {\n let total = 0;\n if (coords && coords.length > 0) {\n total += Math.abs(ringArea(coords[0]));\n for (let i = 1; i < coords.length; i++) {\n total -= Math.abs(ringArea(coords[i]));\n }\n }\n return total;\n}\nvar FACTOR = earthRadius * earthRadius / 2;\nvar PI_OVER_180 = Math.PI / 180;\nfunction ringArea(coords) {\n const coordsLength = coords.length - 1;\n if (coordsLength <= 2) return 0;\n let total = 0;\n let i = 0;\n while (i < coordsLength) {\n const lower = coords[i];\n const middle = coords[i + 1 === coordsLength ? 0 : i + 1];\n const upper = coords[i + 2 >= coordsLength ? (i + 2) % coordsLength : i + 2];\n const lowerX = lower[0] * PI_OVER_180;\n const middleY = middle[1] * PI_OVER_180;\n const upperX = upper[0] * PI_OVER_180;\n total += (upperX - lowerX) * Math.sin(middleY);\n i++;\n }\n return total * FACTOR;\n}\nvar turf_area_default = area;\nexport {\n area,\n turf_area_default as default\n};\n//# sourceMappingURL=index.js.map","import area from '@turf/area';\r\nimport centerOfMass from '@turf/center-of-mass';\r\nimport { Feature, Polygon, MultiPolygon, GeoJsonProperties } from 'geojson';\r\n\r\nexport function getCentroidCoordinates(\r\n multiPolygonFeature: Feature<Polygon | MultiPolygon, GeoJsonProperties>,\r\n centerLargestPolygon = true,\r\n) {\r\n if (multiPolygonFeature.geometry.type === 'Polygon' || centerLargestPolygon === false) {\r\n return centerOfMass(multiPolygonFeature).geometry.coordinates;\r\n }\r\n\r\n if (multiPolygonFeature.geometry.type === 'MultiPolygon') {\r\n let maxArea = 0;\r\n let largestPolygon: Feature<Polygon, GeoJsonProperties> | null = null;\r\n\r\n for (const coords of multiPolygonFeature.geometry.coordinates) {\r\n const poly: Feature<Polygon, GeoJsonProperties> = {\r\n type: 'Feature',\r\n geometry: {\r\n type: 'Polygon',\r\n coordinates: coords,\r\n },\r\n properties: {},\r\n };\r\n\r\n const polyArea = area(poly);\r\n if (polyArea > maxArea) {\r\n maxArea = polyArea;\r\n largestPolygon = poly;\r\n }\r\n }\r\n\r\n return centerOfMass(largestPolygon).geometry.coordinates;\r\n }\r\n\r\n throw new Error('Unsupported geometry type');\r\n}\r\n"],"names":["area","geojson","geomReduce","value","geom","calculateArea","total","i","polygonArea","coords","ringArea","FACTOR","earthRadius","PI_OVER_180","coordsLength","lower","middle","upper","lowerX","middleY","upperX","turf_area_default","getCentroidCoordinates","multiPolygonFeature","centerLargestPolygon","centerOfMass","maxArea","largestPolygon","poly","polyArea"],"mappings":";AAGA,SAASA,EAAKC,GAAS;AACrB,SAAOC;AAAA,IACLD;AAAA,IACA,CAACE,GAAOC,MACCD,IAAQE,EAAcD,CAAI;AAAA,IAEnC;AAAA,EACJ;AACA;AACA,SAASC,EAAcD,GAAM;AAC3B,MAAIE,IAAQ,GACRC;AACJ,UAAQH,EAAK,MAAI;AAA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S,SAAS,aAAaC,MAAyB;AAC9E,WAAOC,EAAaF,CAAmB,EAAE,SAAS;AAGpD,MAAIA,EAAoB,SAAS,SAAS,gBAAgB;AACxD,QAAIG,IAAU,GACVC,IAA6D;AAEjE,eAAWlB,KAAUc,EAAoB,SAAS,aAAa;AAC7D,YAAMK,IAA4C;AAAA,QAChD,MAAM;AAAA,QACN,UAAU;AAAA,UACR,MAAM;AAAA,UACN,aAAanB;AAAA,QAAA;AAAA,QAEf,YAAY,CAAA;AAAA,MAAC,GAGToB,IAAW7B,EAAK4B,CAAI;AAC1B,MAAIC,IAAWH,MACbA,IAAUG,GACVF,IAAiBC;AAAA,IAErB;AAEA,WAAOH,EAAaE,CAAc,EAAE,SAAS;AAAA,EAC/C;AAEA,QAAM,IAAI,MAAM,2BAA2B;AAC7C;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const o=require("./index-CoZbeNM9.cjs");function d(t){return o.geomReduce(t,(e,r)=>e+p(r),0)}function p(t){let e=0,r;switch(t.type){case"Polygon":return u(t.coordinates);case"MultiPolygon":for(r=0;r<t.coordinates.length;r++)e+=u(t.coordinates[r]);return e;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0}return 0}function u(t){let e=0;if(t&&t.length>0){e+=Math.abs(c(t[0]));for(let r=1;r<t.length;r++)e-=Math.abs(c(t[r]))}return e}var h=o.earthRadius*o.earthRadius/2,l=Math.PI/180;function c(t){const e=t.length-1;if(e<=2)return 0;let r=0,n=0;for(;n<e;){const s=t[n],a=t[n+1===e?0:n+1],i=t[n+2>=e?(n+2)%e:n+2],f=s[0]*l,g=a[1]*l,y=i[0]*l;r+=(y-f)*Math.sin(g),n++}return r*h}var _=d;function M(t,e=!0){if(t.geometry.type==="Polygon"||e===!1)return o.turf_center_of_mass_default(t).geometry.coordinates;if(t.geometry.type==="MultiPolygon"){let r=0,n=null;for(const s of t.geometry.coordinates){const a={type:"Feature",geometry:{type:"Polygon",coordinates:s},properties:{}},i=_(a);i>r&&(r=i,n=a)}return o.turf_center_of_mass_default(n).geometry.coordinates}throw new Error("Unsupported geometry type")}exports.getCentroidCoordinates=M;
|
|
2
|
+
//# sourceMappingURL=getCentroidCoordinates-DxTBqzp2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCentroidCoordinates-DxTBqzp2.cjs","sources":["../node_modules/@turf/area/dist/esm/index.js","../src/Utils/getCentroidCoordinates.ts"],"sourcesContent":["// index.ts\nimport { earthRadius } from \"@turf/helpers\";\nimport { geomReduce } from \"@turf/meta\";\nfunction area(geojson) {\n return geomReduce(\n geojson,\n (value, geom) => {\n return value + calculateArea(geom);\n },\n 0\n );\n}\nfunction calculateArea(geom) {\n let total = 0;\n let i;\n switch (geom.type) {\n case \"Polygon\":\n return polygonArea(geom.coordinates);\n case \"MultiPolygon\":\n for (i = 0; i < geom.coordinates.length; i++) {\n total += polygonArea(geom.coordinates[i]);\n }\n return total;\n case \"Point\":\n case \"MultiPoint\":\n case \"LineString\":\n case \"MultiLineString\":\n return 0;\n }\n return 0;\n}\nfunction polygonArea(coords) {\n let total = 0;\n if (coords && coords.length > 0) {\n total += Math.abs(ringArea(coords[0]));\n for (let i = 1; i < coords.length; i++) {\n total -= Math.abs(ringArea(coords[i]));\n }\n }\n return total;\n}\nvar FACTOR = earthRadius * earthRadius / 2;\nvar PI_OVER_180 = Math.PI / 180;\nfunction ringArea(coords) {\n const coordsLength = coords.length - 1;\n if (coordsLength <= 2) return 0;\n let total = 0;\n let i = 0;\n while (i < coordsLength) {\n const lower = coords[i];\n const middle = coords[i + 1 === coordsLength ? 0 : i + 1];\n const upper = coords[i + 2 >= coordsLength ? (i + 2) % coordsLength : i + 2];\n const lowerX = lower[0] * PI_OVER_180;\n const middleY = middle[1] * PI_OVER_180;\n const upperX = upper[0] * PI_OVER_180;\n total += (upperX - lowerX) * Math.sin(middleY);\n i++;\n }\n return total * FACTOR;\n}\nvar turf_area_default = area;\nexport {\n area,\n turf_area_default as default\n};\n//# sourceMappingURL=index.js.map","import area from '@turf/area';\r\nimport centerOfMass from '@turf/center-of-mass';\r\nimport { Feature, Polygon, MultiPolygon, GeoJsonProperties } from 'geojson';\r\n\r\nexport function getCentroidCoordinates(\r\n multiPolygonFeature: Feature<Polygon | MultiPolygon, GeoJsonProperties>,\r\n centerLargestPolygon = true,\r\n) {\r\n if (multiPolygonFeature.geometry.type === 'Polygon' || centerLargestPolygon === false) {\r\n return centerOfMass(multiPolygonFeature).geometry.coordinates;\r\n }\r\n\r\n if (multiPolygonFeature.geometry.type === 'MultiPolygon') {\r\n let maxArea = 0;\r\n let largestPolygon: Feature<Polygon, GeoJsonProperties> | null = null;\r\n\r\n for (const coords of multiPolygonFeature.geometry.coordinates) {\r\n const poly: Feature<Polygon, GeoJsonProperties> = {\r\n type: 'Feature',\r\n geometry: {\r\n type: 'Polygon',\r\n coordinates: coords,\r\n },\r\n properties: {},\r\n };\r\n\r\n const polyArea = area(poly);\r\n if (polyArea > maxArea) {\r\n maxArea = polyArea;\r\n largestPolygon = poly;\r\n }\r\n }\r\n\r\n return centerOfMass(largestPolygon).geometry.coordinates;\r\n }\r\n\r\n throw new Error('Unsupported geometry type');\r\n}\r\n"],"names":["area","geojson","geomReduce","value","geom","calculateArea","total","i","polygonArea","coords","ringArea","FACTOR","earthRadius","PI_OVER_180","coordsLength","lower","middle","upper","lowerX","middleY","upperX","turf_area_default","getCentroidCoordinates","multiPolygonFeature","centerLargestPolygon","centerOfMass","maxArea","largestPolygon","poly","polyArea"],"mappings":"qDAGA,SAASA,EAAKC,EAAS,CACrB,OAAOC,EAAAA,WACLD,EACA,CAACE,EAAOC,IACCD,EAAQE,EAAcD,CAAI,EAEnC,CACJ,CACA,CACA,SAASC,EAAcD,EAAM,CAC3B,IAAIE,EAAQ,EACRC,EACJ,OAAQH,EAAK,KAAI,CACf,IAAK,UACH,OAAOI,EAAYJ,EAAK,WAAW,EACrC,IAAK,eACH,IAAKG,E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VC,EAA6D,KAEjE,UAAWlB,KAAUc,EAAoB,SAAS,YAAa,CAC7D,MAAMK,EAA4C,CAChD,KAAM,UACN,SAAU,CACR,KAAM,UACN,YAAanB,CAAA,EAEf,WAAY,CAAA,CAAC,EAGToB,EAAW7B,EAAK4B,CAAI,EACtBC,EAAWH,IACbA,EAAUG,EACVF,EAAiBC,EAErB,CAEA,OAAOH,8BAAaE,CAAc,EAAE,SAAS,WAC/C,CAEA,MAAM,IAAI,MAAM,2BAA2B,CAC7C","x_google_ignoreList":[0]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./BarGraph.cjs"),i=require("./index-CVlCtJbC.cjs"),h=require("./DonutChart.cjs"),s=require("./DumbbellChart.cjs"),l=require("./BeeSwarmChart.cjs"),c=require("./DualAxisLineChart.cjs"),u=require("./LineChartWithConfidenceInterval.cjs"),d=require("./SimpleLineChart.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./BarGraph.cjs"),i=require("./index-CVlCtJbC.cjs"),h=require("./DonutChart.cjs"),s=require("./DumbbellChart.cjs"),l=require("./BeeSwarmChart.cjs"),c=require("./DualAxisLineChart.cjs"),u=require("./LineChartWithConfidenceInterval.cjs"),d=require("./SimpleLineChart.cjs"),g=require("./MultiLineChart.cjs"),p=require("./MultiLineAltChart.cjs"),C=require("./DifferenceLineChart.cjs"),m=require("./SparkLine.cjs"),S=require("./BiVariateChoroplethMap.cjs"),D=require("./ChoroplethMap.cjs"),G=require("./DotDensityMap.cjs"),q=require("./ThreeDGlobe.cjs"),f=require("./GeoHubMap.cjs"),b=require("./GeoHubCompareMaps.cjs"),F=require("./GeoHubMapWithLayerSelection.cjs"),M=require("./ScatterPlot.cjs"),L=require("./SlopeChart.cjs"),B=require("./BulletChart.cjs"),T=require("./AreaChart.cjs"),v=require("./BasicStatCard.cjs"),P=require("./StatCardFromData.cjs"),y=require("./TreeMapGraph.cjs"),A=require("./UnitChart.cjs"),H=require("./HeatMap.cjs"),O=require("./DataTable.cjs"),w=require("./DataCards.cjs"),I=require("./StripChart.cjs"),k=require("./ParetoChart.cjs"),W=require("./ButterflyChart.cjs"),x=require("./Histogram.cjs"),N=require("./SankeyChart.cjs"),V=require("./RadarChart.cjs"),J=require("./MultiGraphDashboard.cjs"),U=require("./PerformanceIntensiveMultiGraphDashboard.cjs"),E=require("./MultiGraphDashboardWideToLongFormat.cjs"),R=require("./SingleGraphDashboard.cjs"),Q=require("./SingleGraphDashboardGeoHubMaps.cjs"),j=require("./SingleGraphDashboardThreeDGraphs.cjs"),z=require("./GriddedGraphs.cjs"),K=require("./ScrollStory.cjs"),X=require("./PerformanceIntensiveScrollStory.cjs"),Y=require("./MultiGraphDashboardFromConfig.cjs"),Z=require("./PerformanceIntensiveMultiGraphDashboardFromConfig.cjs"),_=require("./MultiGraphDashboardWideToLongFormatFromConfig.cjs"),$=require("./SingleGraphDashboardFromConfig.cjs"),ee=require("./SingleGraphDashboardGeoHubMapsFromConfig.cjs"),re=require("./SingleGraphDashboardThreeDGraphsFromConfig.cjs"),ae=require("./GriddedGraphsFromConfig.cjs"),te=require("./ExcelDownloadButton.cjs"),oe=require("./ImageDownloadButton.cjs"),ne=require("./SVGDownloadButton.cjs"),ie=require("./CsvDownloadButton.cjs"),he=require("./CopyTextButton.cjs"),se=require("./Colors.cjs"),le=require("./ColorLegend.cjs"),ce=require("./ColorLegendWithMouseOver.cjs"),ue=require("./LinearColorLegend.cjs"),de=require("./ThresholdColorLegendWithMouseOver.cjs"),ge=require("./GraphFooter.cjs"),pe=require("./GraphHeader.cjs"),Ce=require("./FootNote.cjs"),me=require("./GraphDescription.cjs"),Se=require("./GraphTitle.cjs"),De=require("./Source.cjs"),Ge=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),a=require("./removeOutliers-WELHHqiI.cjs"),qe=require("./numberFormattingFunction-02t-wJta.cjs"),fe=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),be=require("./getJenks-GYmdwBqm.cjs"),Fe=require("./imageDownload-CgDcm1Sj.cjs"),Me=require("./svgDownload-D9zEGjTF.cjs"),Le=require("./excelDownload-BQpsCa62.cjs"),Be=require("./getUniqValue-RViz8tTw.cjs"),Te=require("./getCentroidCoordinates-DxTBqzp2.cjs"),r=require("./fetchAndParseData-Ba-_CgxS.cjs"),n=require("./transformDataForAggregation-KXGm6flX.cjs"),ve=require("./transformDataForGraphFromFile-DVZodTHd.cjs"),o=require("./validateSchema.cjs"),e=require("./getSchema.cjs"),Pe=require("./getGraphList-gf02xgT2.cjs");exports.GroupedBarGraph=t.GroupedBarGraph;exports.SimpleBarGraph=t.SimpleBarGraph;exports.StackedBarGraph=t.StackedBarGraph;exports.CirclePackingGraph=i.CirclePackingGraph;exports.DonutChart=h.DonutChart;exports.DumbbellChart=s.DumbbellChart;exports.BeeSwarmChart=l.BeeSwarmChart;exports.DualAxisLineChart=c.DualAxisLineChart;exports.LineChartWithConfidenceInterval=u.LineChartWithConfidenceInterval;exports.SimpleLineChart=d.SimpleLineChart;exports.MultiLineChart=g.MultiLineChart;exports.MultiLineAltChart=p.MultiLineAltChart;exports.DifferenceLineChart=C.DifferenceLineChart;exports.SparkLine=m.SparkLine;exports.BiVariateChoroplethMap=S.BiVariateChoroplethMap;exports.ChoroplethMap=D.ChoroplethMap;exports.DotDensityMap=G.DotDensityMap;exports.ThreeDGlobe=q.ThreeDGlobe;exports.GeoHubMap=f.GeoHubMap;exports.GeoHubCompareMaps=b.GeoHubCompareMaps;exports.GeoHubMapWithLayerSelection=F.GeoHubMapWithLayerSelection;exports.ScatterPlot=M.ScatterPlot;exports.SlopeChart=L.SlopeChart;exports.BulletChart=B.BulletChart;exports.AreaChart=T.AreaChart;exports.BasicStatCard=v.BasicStatCard;exports.StatCardFromData=P.StatCardFromData;exports.TreeMapGraph=y.TreeMapGraph;exports.UnitChart=A.UnitChart;exports.HeatMap=H.HeatMap;exports.DataTable=O.DataTable;exports.DataCards=w.DataCards;exports.StripChart=I.StripChart;exports.ParetoChart=k.ParetoChart;exports.ButterflyChart=W.ButterflyChart;exports.Histogram=x.Histogram;exports.SankeyChart=N.SankeyChart;exports.RadarChart=V.RadarChart;exports.MultiGraphDashboard=J.MultiGraphDashboard;exports.PerformanceIntensiveMultiGraphDashboard=U.PerformanceIntensiveMultiGraphDashboard;exports.MultiGraphDashboardWideToLongFormat=E.MultiGraphDashboardWideToLongFormat;exports.SingleGraphDashboard=R.SingleGraphDashboard;exports.SingleGraphDashboardGeoHubMaps=Q.SingleGraphDashboardGeoHubMaps;exports.SingleGraphDashboardThreeDGraphs=j.SingleGraphDashboardThreeDGraphs;exports.GriddedGraphs=z.GriddedGraphs;exports.ScrollStory=K.ScrollStory;exports.PerformanceIntensiveScrollStory=X.PerformanceIntensiveScrollStory;exports.MultiGraphDashboardFromConfig=Y.MultiGraphDashboardFromConfig;exports.PerformanceIntensiveMultiGraphDashboardFromConfig=Z.PerformanceIntensiveMultiGraphDashboardFromConfig;exports.MultiGraphDashboardWideToLongFormatFromConfig=_.MultiGraphDashboardWideToLongFormatFromConfig;exports.SingleGraphDashboardFromConfig=$.SingleGraphDashboardFromConfig;exports.SingleGraphDashboardGeoHubMapsFromConfig=ee.SingleGraphDashboardGeoHubMapsFromConfig;exports.SingleGraphDashboardThreeDGraphsFromConfig=re.SingleGraphDashboardThreeDGraphsFromConfig;exports.GriddedGraphsFromConfig=ae.GriddedGraphsFromConfig;exports.ExcelDownloadButton=te.ExcelDownloadButton;exports.ImageDownloadButton=oe.ImageDownloadButton;exports.SVGDownloadButton=ne.SVGDownloadButton;exports.CsvDownloadButton=ie.CsvDownloadButton;exports.CopyTextButton=he.CopyTextButton;exports.Colors=se.Colors;exports.ColorLegend=le.ColorLegend;exports.ColorLegendWithMouseOver=ce.ColorLegendWithMouseOver;exports.LinearColorLegend=ue.LinearColorLegend;exports.ThresholdColorLegendWithMouseOver=de.ThresholdColorLegendWithMouseOver;exports.GraphFooter=ge.GraphFooter;exports.GraphHeader=pe.GraphHeader;exports.FootNote=Ce.FootNote;exports.GraphDescription=me.GraphDescription;exports.GraphTitle=Se.GraphTitle;exports.Source=De.Source;exports.checkIfNullOrUndefined=Ge.checkIfNullOrUndefined;exports.generateEmbedLink=a.generateEmbedLink;exports.generateIframeCode=a.generateIframeCode;exports.getPercentileValue=a.getPercentileValue;exports.getQueryParamsFromLink=a.getQueryParamsFromLink;exports.removeOutliers=a.removeOutliers;exports.numberFormattingFunction=qe.numberFormattingFunction;exports.getTextColorBasedOnBgColor=fe.getTextColorBasedOnBgColor;exports.getJenks=be.getJenks;exports.imageDownload=Fe.imageDownload;exports.svgDownload=Me.svgDownload;exports.excelDownload=Le.excelDownload;exports.getUniqValue=Be.getUniqValue;exports.getCentroidCoordinates=Te.getCentroidCoordinates;exports.fetchAndParseCSV=r.fetchAndParseCSV;exports.fetchAndParseCSVFromTextBlob=r.fetchAndParseCSVFromTextBlob;exports.fetchAndParseJSON=r.fetchAndParseJSON;exports.fetchAndParseMultipleDataSources=r.fetchAndParseMultipleDataSources;exports.fetchAndTransformDataFromAPI=r.fetchAndTransformDataFromAPI;exports.transformColumnsToArray=r.transformColumnsToArray;exports.transformDataForAggregation=n.transformDataForAggregation;exports.transformDataForGraph=n.transformDataForGraph;exports.transformDataForGraphFromFile=ve.transformDataForGraphFromFile;exports.validateConfigSchema=o.validateConfigSchema;exports.validateDataSchema=o.validateDataSchema;exports.validateSettingsSchema=o.validateSettingsSchema;exports.getDashboardJSONSchema=e.getDashboardJSONSchema;exports.getDashboardWideToLongFormatJSONSchema=e.getDashboardWideToLongFormatJSONSchema;exports.getDataFiltersSchema=e.getDataFiltersSchema;exports.getDataSchema=e.getDataSchema;exports.getDataSelectionSchema=e.getDataSelectionSchema;exports.getDataSettingsSchema=e.getDataSettingsSchema;exports.getDataTransformSchema=e.getDataTransformSchema;exports.getFiltersSchema=e.getFiltersSchema;exports.getGraphDataConfigurationSchema=e.getGraphDataConfigurationSchema;exports.getGriddedGraphJSONSchema=e.getGriddedGraphJSONSchema;exports.getReadableHeaderSchema=e.getReadableHeaderSchema;exports.getSettingsSchema=e.getSettingsSchema;exports.getSingleGraphJSONSchema=e.getSingleGraphJSONSchema;exports.graphList=Pe.graphList;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
|
+
import { Feature } from 'geojson';
|
|
3
|
+
import { GeoJsonProperties } from 'geojson';
|
|
2
4
|
import { JSX } from 'react/jsx-runtime';
|
|
3
5
|
import { JSX as JSX_2 } from 'react';
|
|
6
|
+
import { MultiPolygon } from 'geojson';
|
|
7
|
+
import { Polygon } from 'geojson';
|
|
8
|
+
import { Position as Position_2 } from 'geojson';
|
|
4
9
|
import * as THREE from 'three';
|
|
5
10
|
|
|
6
11
|
declare interface AdvancedDataSelectionDataType {
|
|
@@ -867,6 +872,8 @@ export declare function GeoHubMap(props: Props_17): JSX.Element;
|
|
|
867
872
|
/** For using these maps you will have to install [`maplibre`](https://maplibre.org/maplibre-gl-js/docs/#npm) and [pmtiles](https://www.npmjs.com/package/pmtiles) package to your project */
|
|
868
873
|
export declare function GeoHubMapWithLayerSelection(props: Props_19): JSX.Element;
|
|
869
874
|
|
|
875
|
+
export declare function getCentroidCoordinates(multiPolygonFeature: Feature<Polygon | MultiPolygon, GeoJsonProperties>, centerLargestPolygon?: boolean): Position_2;
|
|
876
|
+
|
|
870
877
|
export declare const getDashboardJSONSchema: (columnList?: string[]) => Promise<{
|
|
871
878
|
properties: {
|
|
872
879
|
dashboardID: {
|
package/dist/index.js
CHANGED
|
@@ -75,12 +75,13 @@ import { i as zo } from "./imageDownload-Dcci2LEy.js";
|
|
|
75
75
|
import { s as Xo } from "./svgDownload-C2-E3yf2.js";
|
|
76
76
|
import { e as Zo } from "./excelDownload-BOA-lskf.js";
|
|
77
77
|
import { g as $o } from "./getUniqValue-DiCh_MOD.js";
|
|
78
|
-
import {
|
|
79
|
-
import {
|
|
80
|
-
import { t as ie } from "./
|
|
81
|
-
import {
|
|
82
|
-
import {
|
|
83
|
-
import {
|
|
78
|
+
import { g as oe } from "./getCentroidCoordinates-Dfk6IqEG.js";
|
|
79
|
+
import { b as ae, d as te, f as me, c as pe, a as fe, t as he } from "./fetchAndParseData-sapWbnYk.js";
|
|
80
|
+
import { t as xe, a as ie } from "./transformDataForAggregation-sBpdlX8n.js";
|
|
81
|
+
import { t as le } from "./transformDataForGraphFromFile-ComYvzuz.js";
|
|
82
|
+
import { validateConfigSchema as ge, validateDataSchema as Se, validateSettingsSchema as Ce } from "./validateSchema.js";
|
|
83
|
+
import { getDashboardJSONSchema as De, getDashboardWideToLongFormatJSONSchema as Ge, getDataFiltersSchema as ue, getDataSchema as be, getDataSelectionSchema as Fe, getDataSettingsSchema as Me, getDataTransformSchema as Le, getFiltersSchema as Be, getGraphDataConfigurationSchema as Te, getGriddedGraphJSONSchema as Pe, getReadableHeaderSchema as ve, getSettingsSchema as Ae, getSingleGraphJSONSchema as Oe } from "./getSchema.js";
|
|
84
|
+
import { g as He } from "./getGraphList-DuColTJM.js";
|
|
84
85
|
export {
|
|
85
86
|
K as AreaChart,
|
|
86
87
|
Y as BasicStatCard,
|
|
@@ -154,42 +155,43 @@ export {
|
|
|
154
155
|
er as UnitChart,
|
|
155
156
|
Ho as checkIfNullOrUndefined,
|
|
156
157
|
Zo as excelDownload,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
158
|
+
ae as fetchAndParseCSV,
|
|
159
|
+
te as fetchAndParseCSVFromTextBlob,
|
|
160
|
+
me as fetchAndParseJSON,
|
|
161
|
+
pe as fetchAndParseMultipleDataSources,
|
|
162
|
+
fe as fetchAndTransformDataFromAPI,
|
|
162
163
|
wo as generateEmbedLink,
|
|
163
164
|
Io as generateIframeCode,
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
165
|
+
oe as getCentroidCoordinates,
|
|
166
|
+
De as getDashboardJSONSchema,
|
|
167
|
+
Ge as getDashboardWideToLongFormatJSONSchema,
|
|
168
|
+
ue as getDataFiltersSchema,
|
|
169
|
+
be as getDataSchema,
|
|
170
|
+
Fe as getDataSelectionSchema,
|
|
171
|
+
Me as getDataSettingsSchema,
|
|
172
|
+
Le as getDataTransformSchema,
|
|
173
|
+
Be as getFiltersSchema,
|
|
174
|
+
Te as getGraphDataConfigurationSchema,
|
|
175
|
+
Pe as getGriddedGraphJSONSchema,
|
|
174
176
|
Qo as getJenks,
|
|
175
177
|
No as getPercentileValue,
|
|
176
178
|
Wo as getQueryParamsFromLink,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
ve as getReadableHeaderSchema,
|
|
180
|
+
Ae as getSettingsSchema,
|
|
181
|
+
Oe as getSingleGraphJSONSchema,
|
|
180
182
|
Ro as getTextColorBasedOnBgColor,
|
|
181
183
|
$o as getUniqValue,
|
|
182
|
-
|
|
184
|
+
He as graphList,
|
|
183
185
|
zo as imageDownload,
|
|
184
186
|
Uo as numberFormattingFunction,
|
|
185
187
|
Jo as removeOutliers,
|
|
186
188
|
Xo as svgDownload,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
189
|
+
he as transformColumnsToArray,
|
|
190
|
+
xe as transformDataForAggregation,
|
|
191
|
+
ie as transformDataForGraph,
|
|
192
|
+
le as transformDataForGraphFromFile,
|
|
193
|
+
ge as validateConfigSchema,
|
|
194
|
+
Se as validateDataSchema,
|
|
195
|
+
Ce as validateSettingsSchema
|
|
194
196
|
};
|
|
195
197
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/utils.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),e=require("./removeOutliers-WELHHqiI.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),e=require("./removeOutliers-WELHHqiI.cjs"),o=require("./numberFormattingFunction-02t-wJta.cjs"),n=require("./getTextColorBasedOnBgColor-nqY-bsM_.cjs"),t=require("./getJenks-GYmdwBqm.cjs"),i=require("./imageDownload-CgDcm1Sj.cjs"),a=require("./svgDownload-D9zEGjTF.cjs"),g=require("./excelDownload-BQpsCa62.cjs"),l=require("./getUniqValue-RViz8tTw.cjs"),s=require("./getGraphList-gf02xgT2.cjs"),u=require("./getCentroidCoordinates-DxTBqzp2.cjs");exports.checkIfNullOrUndefined=r.checkIfNullOrUndefined;exports.generateEmbedLink=e.generateEmbedLink;exports.generateIframeCode=e.generateIframeCode;exports.getPercentileValue=e.getPercentileValue;exports.getQueryParamsFromLink=e.getQueryParamsFromLink;exports.removeOutliers=e.removeOutliers;exports.numberFormattingFunction=o.numberFormattingFunction;exports.getTextColorBasedOnBgColor=n.getTextColorBasedOnBgColor;exports.getJenks=t.getJenks;exports.imageDownload=i.imageDownload;exports.svgDownload=a.svgDownload;exports.excelDownload=g.excelDownload;exports.getUniqValue=l.getUniqValue;exports.graphList=s.graphList;exports.getCentroidCoordinates=u.getCentroidCoordinates;
|
|
2
2
|
//# sourceMappingURL=utils.cjs.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { Feature } from 'geojson';
|
|
2
|
+
import { GeoJsonProperties } from 'geojson';
|
|
3
|
+
import { MultiPolygon } from 'geojson';
|
|
4
|
+
import { Polygon } from 'geojson';
|
|
5
|
+
import { Position } from 'geojson';
|
|
6
|
+
|
|
1
7
|
/**
|
|
2
8
|
* Checks whether a given value is `null` or `undefined`.
|
|
3
9
|
*
|
|
@@ -54,6 +60,8 @@ export declare function generateEmbedLink(link: string, params: ParamsProps[]):
|
|
|
54
60
|
*/
|
|
55
61
|
export declare function generateIframeCode(link: string, params: ParamsProps[]): string;
|
|
56
62
|
|
|
63
|
+
export declare function getCentroidCoordinates(multiPolygonFeature: Feature<Polygon | MultiPolygon, GeoJsonProperties>, centerLargestPolygon?: boolean): Position;
|
|
64
|
+
|
|
57
65
|
/**
|
|
58
66
|
* Returns a set of class break values based on Jenks natural breaks algorithm.
|
|
59
67
|
*
|
package/dist/utils.js
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import { g as t, a as s, b as
|
|
3
|
-
import { n as
|
|
4
|
-
import { g as
|
|
1
|
+
import { c as r } from "./checkIfNullOrUndefined-DmfiKkNw.js";
|
|
2
|
+
import { g as t, a as s, b as n, c as g, r as m } from "./removeOutliers-DR48e-18.js";
|
|
3
|
+
import { n as i } from "./numberFormattingFunction-14YCbkN2.js";
|
|
4
|
+
import { g as l } from "./getTextColorBasedOnBgColor-B6Nk2WBf.js";
|
|
5
5
|
import { g as d } from "./getJenks-BbngDoBQ.js";
|
|
6
6
|
import { i as u } from "./imageDownload-Dcci2LEy.js";
|
|
7
|
-
import { s as
|
|
8
|
-
import { e as
|
|
7
|
+
import { s as k } from "./svgDownload-C2-E3yf2.js";
|
|
8
|
+
import { e as w } from "./excelDownload-BOA-lskf.js";
|
|
9
9
|
import { g as F } from "./getUniqValue-DiCh_MOD.js";
|
|
10
10
|
import { g as O } from "./getGraphList-DuColTJM.js";
|
|
11
|
+
import { g as v } from "./getCentroidCoordinates-Dfk6IqEG.js";
|
|
11
12
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
r as checkIfNullOrUndefined,
|
|
14
|
+
w as excelDownload,
|
|
14
15
|
t as generateEmbedLink,
|
|
15
16
|
s as generateIframeCode,
|
|
17
|
+
v as getCentroidCoordinates,
|
|
16
18
|
d as getJenks,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
n as getPercentileValue,
|
|
20
|
+
g as getQueryParamsFromLink,
|
|
21
|
+
l as getTextColorBasedOnBgColor,
|
|
20
22
|
F as getUniqValue,
|
|
21
23
|
O as graphList,
|
|
22
24
|
u as imageDownload,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
i as numberFormattingFunction,
|
|
26
|
+
m as removeOutliers,
|
|
27
|
+
k as svgDownload
|
|
26
28
|
};
|
|
27
29
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RegressionLine-mH7UKOPi.js","sources":["../src/Components/Elements/RegressionLine.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { AnimatePresence, motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\n\r\ninterface Props {\r\n color?: string;\r\n y1: number;\r\n y2: number;\r\n x1: number;\r\n x2: number;\r\n graphWidth: number;\r\n graphHeight: number;\r\n className?: string;\r\n style?: React.CSSProperties;\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function RegressionLine(props: Props) {\r\n const { color, x1, x2, y1, y2, className, style, animate, isInView, graphWidth, graphHeight } =\r\n props;\r\n const id = generateRandomString(8);\r\n return (\r\n <g>\r\n <defs>\r\n <clipPath id={id}>\r\n <rect x='0' y='0' width={graphWidth} height={graphHeight} />\r\n </clipPath>\r\n </defs>\r\n <AnimatePresence>\r\n <motion.line\r\n clipPath={`url(#${id})`}\r\n className={cn(\r\n 'undp-ref-line',\r\n !color ? 'stroke-primary-gray-700 dark:stroke-primary-gray-300' : undefined,\r\n className,\r\n )}\r\n style={{\r\n ...(color && { stroke: color }),\r\n fill: 'none',\r\n ...(style || {}),\r\n }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n y1,\r\n y2: y1,\r\n x1,\r\n x2: x1,\r\n },\r\n whileInView: {\r\n y1,\r\n y2,\r\n x1,\r\n x2,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n </AnimatePresence>\r\n </g>\r\n );\r\n}\r\n"],"names":["RegressionLine","props","color","x1","x2","y1","y2","className","style","animate","isInView","graphWidth","graphHeight","id","generateRandomString","jsx","AnimatePresence","motion","cn"],"mappings":";;;;AAoBO,SAASA,EAAeC,GAAc;AAC3C,QAAM,EAAE,OAAAC,GAAO,IAAAC,GAAI,IAAAC,GAAI,IAAAC,GAAI,IAAAC,GAAI,WAAAC,GAAW,OAAAC,GAAO,SAAAC,GAAS,UAAAC,GAAU,YAAAC,GAAY,aAAAC,EAAA,IAC9EX,GACIY,IAAKC,EAAqB,CAAC;AACjC,gCACG,KAAA,EACC,UAAA;AAAA,IAAAC,gBAAAA,MAAC,QAAA,EACC,UAAAA,gBAAAA,EAAAA,IAAC,YAAA,EAAS,IAAAF,GACR,gCAAC,QAAA,EAAK,GAAE,KAAI,GAAE,KAAI,OAAOF,GAAY,QAAQC,EAAA,CAAa,GAC5D,GACF;AAAA,0BACCI,GAAA,EACC,UAAAD,gBAAAA,EAAAA;AAAAA,MAACE,EAAO;AAAA,MAAP;AAAA,QACC,UAAU,QAAQJ,CAAE;AAAA,QACpB,WAAWK;AAAAA,UACT;AAAA,UACChB,IAAiE,SAAzD;AAAA,UACTK;AAAA,QAAA;AAAA,QAEF,OAAO;AAAA,UACL,GAAIL,KAAS,EAAE,QAAQA,EAAA;AAAA,UACvB,MAAM;AAAA,UACN,GAAIM,KAAS,CAAA;AAAA,QAAC;AAAA,QAEhB,MAAM,EAAE,SAAS,GAAG,YAAY,EAAE,UAAUC,EAAQ,WAAS;AAAA,QAC7D,UAAU;AAAA,UACR,SAAS;AAAA,YACP,IAAAJ;AAAA,YACA,IAAIA;AAAA,YACJ,IAAAF;AAAA,YACA,IAAIA;AAAA,UAAA;AAAA,UAEN,aAAa;AAAA,YACX,IAAAE;AAAA,YACA,IAAAC;AAAA,YACA,IAAAH;AAAA,YACA,IAAAC;AAAA,YACA,YAAY,EAAE,UAAUK,EAAQ,SAAA;AAAA,UAAS;AAAA,QAC3C;AAAA,QAEF,SAAQ;AAAA,QACR,SAASC,IAAW,gBAAgB;AAAA,MAAA;AAAA,IAAA,EACtC,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),h=require("./generateRandomString-B5zBiJzS.cjs"),p=require("./index-BW8iNx7E.cjs"),g=require("./proxy-BHRoeZgd.cjs");function j(a){const{color:e,x1:n,x2:o,y1:t,y2:x,className:l,style:c,animate:r,isInView:d,graphWidth:u,graphHeight:m}=a,s=h.generateRandomString(8);return i.jsxRuntimeExports.jsxs("g",{children:[i.jsxRuntimeExports.jsx("defs",{children:i.jsxRuntimeExports.jsx("clipPath",{id:s,children:i.jsxRuntimeExports.jsx("rect",{x:"0",y:"0",width:u,height:m})})}),i.jsxRuntimeExports.jsx(p.AnimatePresence,{children:i.jsxRuntimeExports.jsx(g.motion.line,{clipPath:`url(#${s})`,className:i.mo("undp-ref-line",e?void 0:"stroke-primary-gray-700 dark:stroke-primary-gray-300",l),style:{...e&&{stroke:e},fill:"none",...c||{}},exit:{opacity:0,transition:{duration:r.duration}},variants:{initial:{y1:t,y2:t,x1:n,x2:n},whileInView:{y1:t,y2:x,x1:n,x2:o,transition:{duration:r.duration}}},initial:"initial",animate:d?"whileInView":"initial"})})]})}exports.RegressionLine=j;
|
|
2
|
-
//# sourceMappingURL=RegressionLine-xKdiJ8sw.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RegressionLine-xKdiJ8sw.cjs","sources":["../src/Components/Elements/RegressionLine.tsx"],"sourcesContent":["import { cn } from '@undp/design-system-react/cn';\r\nimport { AnimatePresence, motion } from 'motion/react';\r\n\r\nimport { AnimateDataType } from '@/Types';\r\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\n\r\ninterface Props {\r\n color?: string;\r\n y1: number;\r\n y2: number;\r\n x1: number;\r\n x2: number;\r\n graphWidth: number;\r\n graphHeight: number;\r\n className?: string;\r\n style?: React.CSSProperties;\r\n animate: AnimateDataType;\r\n isInView: boolean;\r\n}\r\n\r\nexport function RegressionLine(props: Props) {\r\n const { color, x1, x2, y1, y2, className, style, animate, isInView, graphWidth, graphHeight } =\r\n props;\r\n const id = generateRandomString(8);\r\n return (\r\n <g>\r\n <defs>\r\n <clipPath id={id}>\r\n <rect x='0' y='0' width={graphWidth} height={graphHeight} />\r\n </clipPath>\r\n </defs>\r\n <AnimatePresence>\r\n <motion.line\r\n clipPath={`url(#${id})`}\r\n className={cn(\r\n 'undp-ref-line',\r\n !color ? 'stroke-primary-gray-700 dark:stroke-primary-gray-300' : undefined,\r\n className,\r\n )}\r\n style={{\r\n ...(color && { stroke: color }),\r\n fill: 'none',\r\n ...(style || {}),\r\n }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n y1,\r\n y2: y1,\r\n x1,\r\n x2: x1,\r\n },\r\n whileInView: {\r\n y1,\r\n y2,\r\n x1,\r\n x2,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n />\r\n </AnimatePresence>\r\n </g>\r\n );\r\n}\r\n"],"names":["RegressionLine","props","color","x1","x2","y1","y2","className","style","animate","isInView","graphWidth","graphHeight","id","generateRandomString","jsx","AnimatePresence","motion","cn"],"mappings":"mLAoBO,SAASA,EAAeC,EAAc,CAC3C,KAAM,CAAE,MAAAC,EAAO,GAAAC,EAAI,GAAAC,EAAI,GAAAC,EAAI,GAAAC,EAAI,UAAAC,EAAW,MAAAC,EAAO,QAAAC,EAAS,SAAAC,EAAU,WAAAC,EAAY,YAAAC,CAAA,EAC9EX,EACIY,EAAKC,EAAAA,qBAAqB,CAAC,EACjC,gCACG,IAAA,CACC,SAAA,CAAAC,wBAAC,OAAA,CACC,SAAAA,EAAAA,kBAAAA,IAAC,WAAA,CAAS,GAAAF,EACR,iCAAC,OAAA,CAAK,EAAE,IAAI,EAAE,IAAI,MAAOF,EAAY,OAAQC,CAAA,CAAa,EAC5D,EACF,0BACCI,EAAAA,gBAAA,CACC,SAAAD,EAAAA,kBAAAA,IAACE,EAAAA,OAAO,KAAP,CACC,SAAU,QAAQJ,CAAE,IACpB,UAAWK,EAAAA,GACT,gBACChB,EAAiE,OAAzD,uDACTK,CAAA,EAEF,MAAO,CACL,GAAIL,GAAS,CAAE,OAAQA,CAAA,EACvB,KAAM,OACN,GAAIM,GAAS,CAAA,CAAC,EAEhB,KAAM,CAAE,QAAS,EAAG,WAAY,CAAE,SAAUC,EAAQ,SAAS,EAC7D,SAAU,CACR,QAAS,CACP,GAAAJ,EACA,GAAIA,EACJ,GAAAF,EACA,GAAIA,CAAA,EAEN,YAAa,CACX,GAAAE,EACA,GAAAC,EACA,GAAAH,EACA,GAAAC,EACA,WAAY,CAAE,SAAUK,EAAQ,QAAA,CAAS,CAC3C,EAEF,QAAQ,UACR,QAASC,EAAW,cAAgB,SAAA,CAAA,CACtC,CACF,CAAA,EACF,CAEJ"}
|