@undp/data-viz 1.4.12 → 1.4.14

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.
Files changed (180) hide show
  1. package/dist/AreaChart.cjs +1 -1
  2. package/dist/AreaChart.cjs.map +1 -1
  3. package/dist/AreaChart.js +25 -24
  4. package/dist/AreaChart.js.map +1 -1
  5. package/dist/BarGraph.cjs +1 -1
  6. package/dist/BarGraph.cjs.map +1 -1
  7. package/dist/BarGraph.js +638 -632
  8. package/dist/BarGraph.js.map +1 -1
  9. package/dist/BeeSwarmChart.cjs +1 -1
  10. package/dist/BeeSwarmChart.cjs.map +1 -1
  11. package/dist/BeeSwarmChart.js +134 -132
  12. package/dist/BeeSwarmChart.js.map +1 -1
  13. package/dist/BiVariateChoroplethMap.cjs +1 -1
  14. package/dist/BiVariateChoroplethMap.cjs.map +1 -1
  15. package/dist/BiVariateChoroplethMap.js +35 -34
  16. package/dist/BiVariateChoroplethMap.js.map +1 -1
  17. package/dist/BulletChart.cjs +1 -1
  18. package/dist/BulletChart.cjs.map +1 -1
  19. package/dist/BulletChart.js +226 -224
  20. package/dist/BulletChart.js.map +1 -1
  21. package/dist/ButterflyChart.cjs +1 -1
  22. package/dist/ButterflyChart.cjs.map +1 -1
  23. package/dist/ButterflyChart.js +48 -47
  24. package/dist/ButterflyChart.js.map +1 -1
  25. package/dist/ChoroplethMap.cjs +1 -1
  26. package/dist/ChoroplethMap.cjs.map +1 -1
  27. package/dist/ChoroplethMap.js +56 -55
  28. package/dist/ChoroplethMap.js.map +1 -1
  29. package/dist/CirclePackingGraph.cjs +1 -1
  30. package/dist/CirclePackingGraph.js +1 -1
  31. package/dist/DataCards.cjs +3 -3
  32. package/dist/DataCards.cjs.map +1 -1
  33. package/dist/DataCards.js +2 -1
  34. package/dist/DataCards.js.map +1 -1
  35. package/dist/DataTable.cjs +1 -1
  36. package/dist/DataTable.cjs.map +1 -1
  37. package/dist/DataTable.js +9 -8
  38. package/dist/DataTable.js.map +1 -1
  39. package/dist/DifferenceLineChart.cjs +1 -1
  40. package/dist/DifferenceLineChart.cjs.map +1 -1
  41. package/dist/DifferenceLineChart.js +1 -0
  42. package/dist/DifferenceLineChart.js.map +1 -1
  43. package/dist/DonutChart.cjs +1 -1
  44. package/dist/DonutChart.cjs.map +1 -1
  45. package/dist/DonutChart.js +77 -76
  46. package/dist/DonutChart.js.map +1 -1
  47. package/dist/DotDensityMap.cjs +1 -1
  48. package/dist/DotDensityMap.cjs.map +1 -1
  49. package/dist/DotDensityMap.js +1 -0
  50. package/dist/DotDensityMap.js.map +1 -1
  51. package/dist/{DropdownSelect-CeHog_ih.js → DropdownSelect-CtOKZHD0.js} +22 -20
  52. package/dist/{DropdownSelect-CeHog_ih.js.map → DropdownSelect-CtOKZHD0.js.map} +1 -1
  53. package/dist/{DropdownSelect-BmE5JaeE.cjs → DropdownSelect-DBDM64B5.cjs} +2 -2
  54. package/dist/{DropdownSelect-BmE5JaeE.cjs.map → DropdownSelect-DBDM64B5.cjs.map} +1 -1
  55. package/dist/DualAxisLineChart.cjs +1 -1
  56. package/dist/DualAxisLineChart.cjs.map +1 -1
  57. package/dist/DualAxisLineChart.d.ts +3 -1
  58. package/dist/DualAxisLineChart.js +265 -261
  59. package/dist/DualAxisLineChart.js.map +1 -1
  60. package/dist/DumbbellChart.cjs +1 -1
  61. package/dist/DumbbellChart.cjs.map +1 -1
  62. package/dist/DumbbellChart.js +216 -214
  63. package/dist/DumbbellChart.js.map +1 -1
  64. package/dist/GeoHubCompareMaps.cjs +1 -1
  65. package/dist/GeoHubCompareMaps.cjs.map +1 -1
  66. package/dist/GeoHubCompareMaps.js +1 -0
  67. package/dist/GeoHubCompareMaps.js.map +1 -1
  68. package/dist/GeoHubMap.cjs +1 -1
  69. package/dist/GeoHubMap.cjs.map +1 -1
  70. package/dist/GeoHubMap.js +29 -28
  71. package/dist/GeoHubMap.js.map +1 -1
  72. package/dist/GeoHubMapWithLayerSelection.cjs +1 -1
  73. package/dist/GeoHubMapWithLayerSelection.cjs.map +1 -1
  74. package/dist/GeoHubMapWithLayerSelection.js +34 -33
  75. package/dist/GeoHubMapWithLayerSelection.js.map +1 -1
  76. package/dist/{GraphEl-s3ctz7oA.js → GraphEl-N6vuMRw_.js} +6 -2
  77. package/dist/GraphEl-N6vuMRw_.js.map +1 -0
  78. package/dist/GraphEl-Zl0W-LK9.cjs +2 -0
  79. package/dist/GraphEl-Zl0W-LK9.cjs.map +1 -0
  80. package/dist/GriddedGraphs.cjs +1 -1
  81. package/dist/GriddedGraphs.d.ts +1 -0
  82. package/dist/GriddedGraphs.js +2 -2
  83. package/dist/GriddedGraphsFromConfig.d.ts +1 -0
  84. package/dist/HeatMap.cjs +1 -1
  85. package/dist/HeatMap.cjs.map +1 -1
  86. package/dist/HeatMap.js +55 -54
  87. package/dist/HeatMap.js.map +1 -1
  88. package/dist/Histogram.cjs +1 -1
  89. package/dist/Histogram.js +1 -1
  90. package/dist/LineChartWithConfidenceInterval.cjs +1 -1
  91. package/dist/LineChartWithConfidenceInterval.cjs.map +1 -1
  92. package/dist/LineChartWithConfidenceInterval.js +22 -21
  93. package/dist/LineChartWithConfidenceInterval.js.map +1 -1
  94. package/dist/MultiGraphDashboard.cjs +1 -1
  95. package/dist/MultiGraphDashboard.d.ts +1 -0
  96. package/dist/MultiGraphDashboard.js +1 -1
  97. package/dist/MultiGraphDashboardFromConfig.d.ts +1 -0
  98. package/dist/MultiGraphDashboardWideToLongFormat.cjs +1 -1
  99. package/dist/MultiGraphDashboardWideToLongFormat.js +1 -1
  100. package/dist/MultiLineAltChart.cjs +1 -1
  101. package/dist/MultiLineAltChart.cjs.map +1 -1
  102. package/dist/MultiLineAltChart.js +34 -33
  103. package/dist/MultiLineAltChart.js.map +1 -1
  104. package/dist/MultiLineChart.cjs +1 -1
  105. package/dist/MultiLineChart.cjs.map +1 -1
  106. package/dist/MultiLineChart.js +72 -71
  107. package/dist/MultiLineChart.js.map +1 -1
  108. package/dist/ParetoChart.cjs +1 -1
  109. package/dist/ParetoChart.cjs.map +1 -1
  110. package/dist/ParetoChart.d.ts +4 -0
  111. package/dist/ParetoChart.js +317 -312
  112. package/dist/ParetoChart.js.map +1 -1
  113. package/dist/PerformanceIntensiveMultiGraphDashboard.cjs +1 -1
  114. package/dist/PerformanceIntensiveMultiGraphDashboard.d.ts +1 -0
  115. package/dist/PerformanceIntensiveMultiGraphDashboard.js +1 -1
  116. package/dist/PerformanceIntensiveMultiGraphDashboardFromConfig.d.ts +1 -0
  117. package/dist/PerformanceIntensiveScrollStory.d.ts +1 -0
  118. package/dist/RadarChart.cjs +1 -1
  119. package/dist/RadarChart.cjs.map +1 -1
  120. package/dist/RadarChart.js +27 -26
  121. package/dist/RadarChart.js.map +1 -1
  122. package/dist/SankeyChart.cjs +1 -1
  123. package/dist/SankeyChart.cjs.map +1 -1
  124. package/dist/SankeyChart.js +30 -29
  125. package/dist/SankeyChart.js.map +1 -1
  126. package/dist/ScatterPlot.cjs +1 -1
  127. package/dist/ScatterPlot.cjs.map +1 -1
  128. package/dist/ScatterPlot.js +119 -118
  129. package/dist/ScatterPlot.js.map +1 -1
  130. package/dist/ScrollStory.d.ts +1 -0
  131. package/dist/SimpleLineChart.cjs +1 -1
  132. package/dist/SimpleLineChart.cjs.map +1 -1
  133. package/dist/SimpleLineChart.js +16 -15
  134. package/dist/SimpleLineChart.js.map +1 -1
  135. package/dist/SingleGraphDashboard.cjs +1 -1
  136. package/dist/SingleGraphDashboard.d.ts +1 -0
  137. package/dist/SingleGraphDashboard.js +2 -2
  138. package/dist/SingleGraphDashboardFromConfig.d.ts +1 -0
  139. package/dist/SingleGraphDashboardGeoHubMaps.d.ts +1 -0
  140. package/dist/SingleGraphDashboardGeoHubMapsFromConfig.d.ts +1 -0
  141. package/dist/SingleGraphDashboardThreeDGraphs.cjs +1 -1
  142. package/dist/SingleGraphDashboardThreeDGraphs.d.ts +1 -0
  143. package/dist/SingleGraphDashboardThreeDGraphs.js +1 -1
  144. package/dist/SingleGraphDashboardThreeDGraphsFromConfig.d.ts +1 -0
  145. package/dist/SlopeChart.cjs +1 -1
  146. package/dist/SlopeChart.cjs.map +1 -1
  147. package/dist/SlopeChart.js +46 -45
  148. package/dist/SlopeChart.js.map +1 -1
  149. package/dist/SparkLine.cjs +1 -1
  150. package/dist/SparkLine.cjs.map +1 -1
  151. package/dist/SparkLine.js +12 -11
  152. package/dist/SparkLine.js.map +1 -1
  153. package/dist/StripChart.cjs +1 -1
  154. package/dist/StripChart.cjs.map +1 -1
  155. package/dist/StripChart.js +81 -79
  156. package/dist/StripChart.js.map +1 -1
  157. package/dist/ThreeDGlobe.cjs +1 -1
  158. package/dist/ThreeDGlobe.cjs.map +1 -1
  159. package/dist/ThreeDGlobe.js +1 -0
  160. package/dist/ThreeDGlobe.js.map +1 -1
  161. package/dist/TreeMapGraph.cjs +1 -1
  162. package/dist/TreeMapGraph.cjs.map +1 -1
  163. package/dist/TreeMapGraph.js +114 -113
  164. package/dist/TreeMapGraph.js.map +1 -1
  165. package/dist/Types.d.ts +1 -0
  166. package/dist/UnitChart.cjs +1 -1
  167. package/dist/UnitChart.cjs.map +1 -1
  168. package/dist/UnitChart.js +10 -9
  169. package/dist/UnitChart.js.map +1 -1
  170. package/dist/{index-CZLvTu6p.cjs → index-BbNoLJ_w.cjs} +2 -2
  171. package/dist/{index-CZLvTu6p.cjs.map → index-BbNoLJ_w.cjs.map} +1 -1
  172. package/dist/{index-DGAaLNu9.js → index-Bc5VF70V.js} +46 -45
  173. package/dist/{index-DGAaLNu9.js.map → index-Bc5VF70V.js.map} +1 -1
  174. package/dist/index.cjs +1 -1
  175. package/dist/index.d.ts +8 -1
  176. package/dist/index.js +1 -1
  177. package/package.json +2 -2
  178. package/dist/GraphEl-OzC-icbr.cjs +0 -2
  179. package/dist/GraphEl-OzC-icbr.cjs.map +0 -1
  180. package/dist/GraphEl-s3ctz7oA.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SankeyChart.js","sources":["../node_modules/d3-sankey/node_modules/d3-array/src/max.js","../node_modules/d3-sankey/node_modules/d3-array/src/min.js","../node_modules/d3-sankey/node_modules/d3-array/src/sum.js","../node_modules/d3-sankey/src/align.js","../node_modules/d3-sankey/src/constant.js","../node_modules/d3-sankey/src/sankey.js","../node_modules/d3-sankey/node_modules/d3-path/src/path.js","../node_modules/d3-sankey/node_modules/d3-shape/src/constant.js","../node_modules/d3-sankey/node_modules/d3-shape/src/point.js","../node_modules/d3-sankey/node_modules/d3-shape/src/array.js","../node_modules/d3-sankey/node_modules/d3-shape/src/link/index.js","../node_modules/d3-sankey/src/sankeyLinkHorizontal.js","../src/Components/Graphs/SankeyChart/Graph.tsx","../src/Components/Graphs/SankeyChart/index.tsx"],"sourcesContent":["export default function max(values, valueof) {\n let max;\n if (valueof === undefined) {\n for (const value of values) {\n if (value != null\n && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n } else {\n let index = -1;\n for (let value of values) {\n if ((value = valueof(value, ++index, values)) != null\n && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n }\n return max;\n}\n","export default function min(values, valueof) {\n let min;\n if (valueof === undefined) {\n for (const value of values) {\n if (value != null\n && (min > value || (min === undefined && value >= value))) {\n min = value;\n }\n }\n } else {\n let index = -1;\n for (let value of values) {\n if ((value = valueof(value, ++index, values)) != null\n && (min > value || (min === undefined && value >= value))) {\n min = value;\n }\n }\n }\n return min;\n}\n","export default function sum(values, valueof) {\n let sum = 0;\n if (valueof === undefined) {\n for (let value of values) {\n if (value = +value) {\n sum += value;\n }\n }\n } else {\n let index = -1;\n for (let value of values) {\n if (value = +valueof(value, ++index, values)) {\n sum += value;\n }\n }\n }\n return sum;\n}\n","import {min} from \"d3-array\";\n\nfunction targetDepth(d) {\n return d.target.depth;\n}\n\nexport function left(node) {\n return node.depth;\n}\n\nexport function right(node, n) {\n return n - 1 - node.height;\n}\n\nexport function justify(node, n) {\n return node.sourceLinks.length ? node.depth : n - 1;\n}\n\nexport function center(node) {\n return node.targetLinks.length ? node.depth\n : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1\n : 0;\n}\n","export default function constant(x) {\n return function() {\n return x;\n };\n}\n","import {max, min, sum} from \"d3-array\";\nimport {justify} from \"./align.js\";\nimport constant from \"./constant.js\";\n\nfunction ascendingSourceBreadth(a, b) {\n return ascendingBreadth(a.source, b.source) || a.index - b.index;\n}\n\nfunction ascendingTargetBreadth(a, b) {\n return ascendingBreadth(a.target, b.target) || a.index - b.index;\n}\n\nfunction ascendingBreadth(a, b) {\n return a.y0 - b.y0;\n}\n\nfunction value(d) {\n return d.value;\n}\n\nfunction defaultId(d) {\n return d.index;\n}\n\nfunction defaultNodes(graph) {\n return graph.nodes;\n}\n\nfunction defaultLinks(graph) {\n return graph.links;\n}\n\nfunction find(nodeById, id) {\n const node = nodeById.get(id);\n if (!node) throw new Error(\"missing: \" + id);\n return node;\n}\n\nfunction computeLinkBreadths({nodes}) {\n for (const node of nodes) {\n let y0 = node.y0;\n let y1 = y0;\n for (const link of node.sourceLinks) {\n link.y0 = y0 + link.width / 2;\n y0 += link.width;\n }\n for (const link of node.targetLinks) {\n link.y1 = y1 + link.width / 2;\n y1 += link.width;\n }\n }\n}\n\nexport default function Sankey() {\n let x0 = 0, y0 = 0, x1 = 1, y1 = 1; // extent\n let dx = 24; // nodeWidth\n let dy = 8, py; // nodePadding\n let id = defaultId;\n let align = justify;\n let sort;\n let linkSort;\n let nodes = defaultNodes;\n let links = defaultLinks;\n let iterations = 6;\n\n function sankey() {\n const graph = {nodes: nodes.apply(null, arguments), links: links.apply(null, arguments)};\n computeNodeLinks(graph);\n computeNodeValues(graph);\n computeNodeDepths(graph);\n computeNodeHeights(graph);\n computeNodeBreadths(graph);\n computeLinkBreadths(graph);\n return graph;\n }\n\n sankey.update = function(graph) {\n computeLinkBreadths(graph);\n return graph;\n };\n\n sankey.nodeId = function(_) {\n return arguments.length ? (id = typeof _ === \"function\" ? _ : constant(_), sankey) : id;\n };\n\n sankey.nodeAlign = function(_) {\n return arguments.length ? (align = typeof _ === \"function\" ? _ : constant(_), sankey) : align;\n };\n\n sankey.nodeSort = function(_) {\n return arguments.length ? (sort = _, sankey) : sort;\n };\n\n sankey.nodeWidth = function(_) {\n return arguments.length ? (dx = +_, sankey) : dx;\n };\n\n sankey.nodePadding = function(_) {\n return arguments.length ? (dy = py = +_, sankey) : dy;\n };\n\n sankey.nodes = function(_) {\n return arguments.length ? (nodes = typeof _ === \"function\" ? _ : constant(_), sankey) : nodes;\n };\n\n sankey.links = function(_) {\n return arguments.length ? (links = typeof _ === \"function\" ? _ : constant(_), sankey) : links;\n };\n\n sankey.linkSort = function(_) {\n return arguments.length ? (linkSort = _, sankey) : linkSort;\n };\n\n sankey.size = function(_) {\n return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];\n };\n\n sankey.extent = function(_) {\n return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]];\n };\n\n sankey.iterations = function(_) {\n return arguments.length ? (iterations = +_, sankey) : iterations;\n };\n\n function computeNodeLinks({nodes, links}) {\n for (const [i, node] of nodes.entries()) {\n node.index = i;\n node.sourceLinks = [];\n node.targetLinks = [];\n }\n const nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d]));\n for (const [i, link] of links.entries()) {\n link.index = i;\n let {source, target} = link;\n if (typeof source !== \"object\") source = link.source = find(nodeById, source);\n if (typeof target !== \"object\") target = link.target = find(nodeById, target);\n source.sourceLinks.push(link);\n target.targetLinks.push(link);\n }\n if (linkSort != null) {\n for (const {sourceLinks, targetLinks} of nodes) {\n sourceLinks.sort(linkSort);\n targetLinks.sort(linkSort);\n }\n }\n }\n\n function computeNodeValues({nodes}) {\n for (const node of nodes) {\n node.value = node.fixedValue === undefined\n ? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value))\n : node.fixedValue;\n }\n }\n\n function computeNodeDepths({nodes}) {\n const n = nodes.length;\n let current = new Set(nodes);\n let next = new Set;\n let x = 0;\n while (current.size) {\n for (const node of current) {\n node.depth = x;\n for (const {target} of node.sourceLinks) {\n next.add(target);\n }\n }\n if (++x > n) throw new Error(\"circular link\");\n current = next;\n next = new Set;\n }\n }\n\n function computeNodeHeights({nodes}) {\n const n = nodes.length;\n let current = new Set(nodes);\n let next = new Set;\n let x = 0;\n while (current.size) {\n for (const node of current) {\n node.height = x;\n for (const {source} of node.targetLinks) {\n next.add(source);\n }\n }\n if (++x > n) throw new Error(\"circular link\");\n current = next;\n next = new Set;\n }\n }\n\n function computeNodeLayers({nodes}) {\n const x = max(nodes, d => d.depth) + 1;\n const kx = (x1 - x0 - dx) / (x - 1);\n const columns = new Array(x);\n for (const node of nodes) {\n const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x))));\n node.layer = i;\n node.x0 = x0 + i * kx;\n node.x1 = node.x0 + dx;\n if (columns[i]) columns[i].push(node);\n else columns[i] = [node];\n }\n if (sort) for (const column of columns) {\n column.sort(sort);\n }\n return columns;\n }\n\n function initializeNodeBreadths(columns) {\n const ky = min(columns, c => (y1 - y0 - (c.length - 1) * py) / sum(c, value));\n for (const nodes of columns) {\n let y = y0;\n for (const node of nodes) {\n node.y0 = y;\n node.y1 = y + node.value * ky;\n y = node.y1 + py;\n for (const link of node.sourceLinks) {\n link.width = link.value * ky;\n }\n }\n y = (y1 - y + py) / (nodes.length + 1);\n for (let i = 0; i < nodes.length; ++i) {\n const node = nodes[i];\n node.y0 += y * (i + 1);\n node.y1 += y * (i + 1);\n }\n reorderLinks(nodes);\n }\n }\n\n function computeNodeBreadths(graph) {\n const columns = computeNodeLayers(graph);\n py = Math.min(dy, (y1 - y0) / (max(columns, c => c.length) - 1));\n initializeNodeBreadths(columns);\n for (let i = 0; i < iterations; ++i) {\n const alpha = Math.pow(0.99, i);\n const beta = Math.max(1 - alpha, (i + 1) / iterations);\n relaxRightToLeft(columns, alpha, beta);\n relaxLeftToRight(columns, alpha, beta);\n }\n }\n\n // Reposition each node based on its incoming (target) links.\n function relaxLeftToRight(columns, alpha, beta) {\n for (let i = 1, n = columns.length; i < n; ++i) {\n const column = columns[i];\n for (const target of column) {\n let y = 0;\n let w = 0;\n for (const {source, value} of target.targetLinks) {\n let v = value * (target.layer - source.layer);\n y += targetTop(source, target) * v;\n w += v;\n }\n if (!(w > 0)) continue;\n let dy = (y / w - target.y0) * alpha;\n target.y0 += dy;\n target.y1 += dy;\n reorderNodeLinks(target);\n }\n if (sort === undefined) column.sort(ascendingBreadth);\n resolveCollisions(column, beta);\n }\n }\n\n // Reposition each node based on its outgoing (source) links.\n function relaxRightToLeft(columns, alpha, beta) {\n for (let n = columns.length, i = n - 2; i >= 0; --i) {\n const column = columns[i];\n for (const source of column) {\n let y = 0;\n let w = 0;\n for (const {target, value} of source.sourceLinks) {\n let v = value * (target.layer - source.layer);\n y += sourceTop(source, target) * v;\n w += v;\n }\n if (!(w > 0)) continue;\n let dy = (y / w - source.y0) * alpha;\n source.y0 += dy;\n source.y1 += dy;\n reorderNodeLinks(source);\n }\n if (sort === undefined) column.sort(ascendingBreadth);\n resolveCollisions(column, beta);\n }\n }\n\n function resolveCollisions(nodes, alpha) {\n const i = nodes.length >> 1;\n const subject = nodes[i];\n resolveCollisionsBottomToTop(nodes, subject.y0 - py, i - 1, alpha);\n resolveCollisionsTopToBottom(nodes, subject.y1 + py, i + 1, alpha);\n resolveCollisionsBottomToTop(nodes, y1, nodes.length - 1, alpha);\n resolveCollisionsTopToBottom(nodes, y0, 0, alpha);\n }\n\n // Push any overlapping nodes down.\n function resolveCollisionsTopToBottom(nodes, y, i, alpha) {\n for (; i < nodes.length; ++i) {\n const node = nodes[i];\n const dy = (y - node.y0) * alpha;\n if (dy > 1e-6) node.y0 += dy, node.y1 += dy;\n y = node.y1 + py;\n }\n }\n\n // Push any overlapping nodes up.\n function resolveCollisionsBottomToTop(nodes, y, i, alpha) {\n for (; i >= 0; --i) {\n const node = nodes[i];\n const dy = (node.y1 - y) * alpha;\n if (dy > 1e-6) node.y0 -= dy, node.y1 -= dy;\n y = node.y0 - py;\n }\n }\n\n function reorderNodeLinks({sourceLinks, targetLinks}) {\n if (linkSort === undefined) {\n for (const {source: {sourceLinks}} of targetLinks) {\n sourceLinks.sort(ascendingTargetBreadth);\n }\n for (const {target: {targetLinks}} of sourceLinks) {\n targetLinks.sort(ascendingSourceBreadth);\n }\n }\n }\n\n function reorderLinks(nodes) {\n if (linkSort === undefined) {\n for (const {sourceLinks, targetLinks} of nodes) {\n sourceLinks.sort(ascendingTargetBreadth);\n targetLinks.sort(ascendingSourceBreadth);\n }\n }\n }\n\n // Returns the target.y0 that would produce an ideal link from source to target.\n function targetTop(source, target) {\n let y = source.y0 - (source.sourceLinks.length - 1) * py / 2;\n for (const {target: node, width} of source.sourceLinks) {\n if (node === target) break;\n y += width + py;\n }\n for (const {source: node, width} of target.targetLinks) {\n if (node === source) break;\n y -= width;\n }\n return y;\n }\n\n // Returns the source.y0 that would produce an ideal link from source to target.\n function sourceTop(source, target) {\n let y = target.y0 - (target.targetLinks.length - 1) * py / 2;\n for (const {source: node, width} of target.targetLinks) {\n if (node === source) break;\n y += width + py;\n }\n for (const {target: node, width} of source.sourceLinks) {\n if (node === target) break;\n y -= width;\n }\n return y;\n }\n\n return sankey;\n}\n","var pi = Math.PI,\n tau = 2 * pi,\n epsilon = 1e-6,\n tauEpsilon = tau - epsilon;\n\nfunction Path() {\n this._x0 = this._y0 = // start of current subpath\n this._x1 = this._y1 = null; // end of current subpath\n this._ = \"\";\n}\n\nfunction path() {\n return new Path;\n}\n\nPath.prototype = path.prototype = {\n constructor: Path,\n moveTo: function(x, y) {\n this._ += \"M\" + (this._x0 = this._x1 = +x) + \",\" + (this._y0 = this._y1 = +y);\n },\n closePath: function() {\n if (this._x1 !== null) {\n this._x1 = this._x0, this._y1 = this._y0;\n this._ += \"Z\";\n }\n },\n lineTo: function(x, y) {\n this._ += \"L\" + (this._x1 = +x) + \",\" + (this._y1 = +y);\n },\n quadraticCurveTo: function(x1, y1, x, y) {\n this._ += \"Q\" + (+x1) + \",\" + (+y1) + \",\" + (this._x1 = +x) + \",\" + (this._y1 = +y);\n },\n bezierCurveTo: function(x1, y1, x2, y2, x, y) {\n this._ += \"C\" + (+x1) + \",\" + (+y1) + \",\" + (+x2) + \",\" + (+y2) + \",\" + (this._x1 = +x) + \",\" + (this._y1 = +y);\n },\n arcTo: function(x1, y1, x2, y2, r) {\n x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;\n var x0 = this._x1,\n y0 = this._y1,\n x21 = x2 - x1,\n y21 = y2 - y1,\n x01 = x0 - x1,\n y01 = y0 - y1,\n l01_2 = x01 * x01 + y01 * y01;\n\n // Is the radius negative? Error.\n if (r < 0) throw new Error(\"negative radius: \" + r);\n\n // Is this path empty? Move to (x1,y1).\n if (this._x1 === null) {\n this._ += \"M\" + (this._x1 = x1) + \",\" + (this._y1 = y1);\n }\n\n // Or, is (x1,y1) coincident with (x0,y0)? Do nothing.\n else if (!(l01_2 > epsilon));\n\n // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear?\n // Equivalently, is (x1,y1) coincident with (x2,y2)?\n // Or, is the radius zero? Line to (x1,y1).\n else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {\n this._ += \"L\" + (this._x1 = x1) + \",\" + (this._y1 = y1);\n }\n\n // Otherwise, draw an arc!\n else {\n var x20 = x2 - x0,\n y20 = y2 - y0,\n l21_2 = x21 * x21 + y21 * y21,\n l20_2 = x20 * x20 + y20 * y20,\n l21 = Math.sqrt(l21_2),\n l01 = Math.sqrt(l01_2),\n l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),\n t01 = l / l01,\n t21 = l / l21;\n\n // If the start tangent is not coincident with (x0,y0), line to.\n if (Math.abs(t01 - 1) > epsilon) {\n this._ += \"L\" + (x1 + t01 * x01) + \",\" + (y1 + t01 * y01);\n }\n\n this._ += \"A\" + r + \",\" + r + \",0,0,\" + (+(y01 * x20 > x01 * y20)) + \",\" + (this._x1 = x1 + t21 * x21) + \",\" + (this._y1 = y1 + t21 * y21);\n }\n },\n arc: function(x, y, r, a0, a1, ccw) {\n x = +x, y = +y, r = +r, ccw = !!ccw;\n var dx = r * Math.cos(a0),\n dy = r * Math.sin(a0),\n x0 = x + dx,\n y0 = y + dy,\n cw = 1 ^ ccw,\n da = ccw ? a0 - a1 : a1 - a0;\n\n // Is the radius negative? Error.\n if (r < 0) throw new Error(\"negative radius: \" + r);\n\n // Is this path empty? Move to (x0,y0).\n if (this._x1 === null) {\n this._ += \"M\" + x0 + \",\" + y0;\n }\n\n // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0).\n else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {\n this._ += \"L\" + x0 + \",\" + y0;\n }\n\n // Is this arc empty? We’re done.\n if (!r) return;\n\n // Does the angle go the wrong way? Flip the direction.\n if (da < 0) da = da % tau + tau;\n\n // Is this a complete circle? Draw two arcs to complete the circle.\n if (da > tauEpsilon) {\n this._ += \"A\" + r + \",\" + r + \",0,1,\" + cw + \",\" + (x - dx) + \",\" + (y - dy) + \"A\" + r + \",\" + r + \",0,1,\" + cw + \",\" + (this._x1 = x0) + \",\" + (this._y1 = y0);\n }\n\n // Is this arc non-empty? Draw an arc!\n else if (da > epsilon) {\n this._ += \"A\" + r + \",\" + r + \",0,\" + (+(da >= pi)) + \",\" + cw + \",\" + (this._x1 = x + r * Math.cos(a1)) + \",\" + (this._y1 = y + r * Math.sin(a1));\n }\n },\n rect: function(x, y, w, h) {\n this._ += \"M\" + (this._x0 = this._x1 = +x) + \",\" + (this._y0 = this._y1 = +y) + \"h\" + (+w) + \"v\" + (+h) + \"h\" + (-w) + \"Z\";\n },\n toString: function() {\n return this._;\n }\n};\n\nexport default path;\n","export default function(x) {\n return function constant() {\n return x;\n };\n}\n","export function x(p) {\n return p[0];\n}\n\nexport function y(p) {\n return p[1];\n}\n","export var slice = Array.prototype.slice;\n","import {path} from \"d3-path\";\nimport {slice} from \"../array.js\";\nimport constant from \"../constant.js\";\nimport {x as pointX, y as pointY} from \"../point.js\";\nimport pointRadial from \"../pointRadial.js\";\n\nfunction linkSource(d) {\n return d.source;\n}\n\nfunction linkTarget(d) {\n return d.target;\n}\n\nfunction link(curve) {\n var source = linkSource,\n target = linkTarget,\n x = pointX,\n y = pointY,\n context = null;\n\n function link() {\n var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);\n if (!context) context = buffer = path();\n curve(context, +x.apply(this, (argv[0] = s, argv)), +y.apply(this, argv), +x.apply(this, (argv[0] = t, argv)), +y.apply(this, argv));\n if (buffer) return context = null, buffer + \"\" || null;\n }\n\n link.source = function(_) {\n return arguments.length ? (source = _, link) : source;\n };\n\n link.target = function(_) {\n return arguments.length ? (target = _, link) : target;\n };\n\n link.x = function(_) {\n return arguments.length ? (x = typeof _ === \"function\" ? _ : constant(+_), link) : x;\n };\n\n link.y = function(_) {\n return arguments.length ? (y = typeof _ === \"function\" ? _ : constant(+_), link) : y;\n };\n\n link.context = function(_) {\n return arguments.length ? ((context = _ == null ? null : _), link) : context;\n };\n\n return link;\n}\n\nfunction curveHorizontal(context, x0, y0, x1, y1) {\n context.moveTo(x0, y0);\n context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);\n}\n\nfunction curveVertical(context, x0, y0, x1, y1) {\n context.moveTo(x0, y0);\n context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1);\n}\n\nfunction curveRadial(context, x0, y0, x1, y1) {\n var p0 = pointRadial(x0, y0),\n p1 = pointRadial(x0, y0 = (y0 + y1) / 2),\n p2 = pointRadial(x1, y0),\n p3 = pointRadial(x1, y1);\n context.moveTo(p0[0], p0[1]);\n context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);\n}\n\nexport function linkHorizontal() {\n return link(curveHorizontal);\n}\n\nexport function linkVertical() {\n return link(curveVertical);\n}\n\nexport function linkRadial() {\n var l = link(curveRadial);\n l.angle = l.x, delete l.x;\n l.radius = l.y, delete l.y;\n return l;\n}\n","import {linkHorizontal} from \"d3-shape\";\n\nfunction horizontalSource(d) {\n return [d.source.x1, d.y0];\n}\n\nfunction horizontalTarget(d) {\n return [d.target.x0, d.y1];\n}\n\nexport default function() {\n return linkHorizontal()\n .source(horizontalSource)\n .target(horizontalTarget);\n}\n","import isEqual from 'fast-deep-equal';\r\nimport { useRef, useState } from 'react';\r\nimport { sankey, sankeyCenter, sankeyLinkHorizontal } from 'd3-sankey';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport { Modal } from '@undp/design-system-react/Modal';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { P } from '@undp/design-system-react/Typography';\r\n\r\nimport {\r\n AnimateDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n NodeDataType,\r\n NodesLinkDataType,\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\n\r\ninterface Props {\r\n data: NodesLinkDataType;\r\n showLabels: boolean;\r\n leftMargin: number;\r\n truncateBy: number;\r\n defaultLinkOpacity: number;\r\n width: number;\r\n height: number;\r\n nodePadding: number;\r\n nodeWidth: number;\r\n rightMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n suffix: string;\r\n prefix: string;\r\n showValues?: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n id: string;\r\n highlightedSourceDataPoints: string[];\r\n highlightedTargetDataPoints: string[];\r\n sourceTitle?: string;\r\n targetTitle?: string;\r\n animate: AnimateDataType;\r\n sortNodes: 'asc' | 'desc' | 'mostReadable' | 'none';\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 precision: number;\r\n customLayers: CustomLayerDataType[];\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n showLabels,\r\n leftMargin,\r\n rightMargin,\r\n truncateBy,\r\n width,\r\n height,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n suffix,\r\n prefix,\r\n showValues,\r\n onSeriesMouseClick,\r\n nodePadding,\r\n nodeWidth,\r\n id,\r\n highlightedSourceDataPoints,\r\n highlightedTargetDataPoints,\r\n defaultLinkOpacity,\r\n sourceTitle,\r\n targetTitle,\r\n animate,\r\n sortNodes,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n // 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [selectedNode, setSelectedNode] = 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 const sankeyGenerator =\r\n sortNodes === 'mostReadable'\r\n ? sankey()\r\n .nodeWidth(nodeWidth)\r\n .nodePadding(nodePadding)\r\n .size([graphWidth, graphHeight])\r\n .nodeAlign(sankeyCenter)\r\n : sortNodes === 'none'\r\n ? sankey()\r\n .nodeWidth(nodeWidth)\r\n .nodePadding(nodePadding)\r\n .size([graphWidth, graphHeight])\r\n .nodeAlign(sankeyCenter)\r\n .nodeSort(() => null)\r\n .linkSort(() => null)\r\n : sankey()\r\n .nodeWidth(nodeWidth)\r\n .nodePadding(nodePadding)\r\n .size([graphWidth, graphHeight])\r\n .nodeAlign(sankeyCenter)\r\n .nodeSort(\r\n sortNodes === 'desc'\r\n ? (a, b) => (b.value || 0) - (a.value || 0)\r\n : (a, b) => (a.value || 0) - (b.value || 0),\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const { nodes, links } = sankeyGenerator(data as any);\r\n const linkPathGenerator = sankeyLinkHorizontal();\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 style={{ marginLeft: 'auto', marginRight: 'auto' }}\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n {sourceTitle ? (\r\n <text\r\n x={margin.left}\r\n y={margin.top - 10}\r\n className='text-base font-bold fill-primary-gray-700 dark:fill-primary-gray-100'\r\n style={{ textAnchor: 'start' }}\r\n >\r\n {sourceTitle}\r\n </text>\r\n ) : null}\r\n {targetTitle ? (\r\n <text\r\n x={width - margin.right}\r\n y={margin.top - 10}\r\n className='text-base font-bold fill-primary-gray-700 dark:fill-primary-gray-100'\r\n style={{ textAnchor: 'end' }}\r\n >\r\n {targetTitle}\r\n </text>\r\n ) : null}\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n {nodes\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .filter((d: any) => d.type === 'source')\r\n .map((d, i) => (\r\n <g\r\n key={i}\r\n onMouseEnter={() => {\r\n setSelectedNode(d);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedNode(undefined);\r\n }}\r\n >\r\n <g transform={`translate(${d.x0},${d.y0})`}>\r\n <rect\r\n x={0}\r\n y={0}\r\n width={(d.x1 || 0) - (d.x0 || 0)}\r\n height={(d.y1 || 0) - (d.y0 || 0)}\r\n style={{ fill: (d as NodeDataType).color }}\r\n />\r\n {showLabels || showValues ? (\r\n <foreignObject\r\n y={0 - nodePadding / 2}\r\n x={0 - leftMargin}\r\n width={leftMargin}\r\n height={(d.y1 || 0) - (d.y0 || 0) + nodePadding}\r\n >\r\n <div\r\n className='flex flex-col gap-0.5 justify-center py-0 px-1.5'\r\n style={{\r\n height: `${(d.y1 || 0) - (d.y0 || 0) + nodePadding}px`,\r\n overflow: 'visible',\r\n }}\r\n >\r\n {showLabels ? (\r\n <P\r\n marginBottom={showValues ? '3xs' : 'none'}\r\n size='sm'\r\n leading='none'\r\n className={cn(\r\n 'sankey-right-label text-right',\r\n classNames?.graphObjectValues,\r\n )}\r\n style={{\r\n hyphens: 'auto',\r\n color: (d as NodeDataType).color,\r\n ...styles?.graphObjectValues,\r\n }}\r\n >\r\n {`${(d as NodeDataType).label}`.length < truncateBy\r\n ? `${(d as NodeDataType).label}`\r\n : `${`${(d as NodeDataType).label}`.substring(0, truncateBy)}...`}\r\n </P>\r\n ) : null}\r\n {showValues ? (\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n leading='none'\r\n className={cn(\r\n 'sankey-right-value text-right font-bold',\r\n classNames?.graphObjectValues,\r\n )}\r\n style={{\r\n hyphens: 'auto',\r\n color: (d as NodeDataType).color,\r\n ...styles?.graphObjectValues,\r\n }}\r\n >\r\n {numberFormattingFunction(d.value, 'NA', precision, prefix, suffix)}\r\n </P>\r\n ) : null}\r\n </div>\r\n </foreignObject>\r\n ) : null}\r\n </g>\r\n </g>\r\n ))}\r\n {nodes\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .filter((d: any) => d.type === 'target')\r\n .map((d, i) => (\r\n <g\r\n key={i}\r\n onMouseEnter={() => {\r\n setSelectedNode(d);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedNode(undefined);\r\n }}\r\n >\r\n <g transform={`translate(${d.x0},${d.y0})`}>\r\n <rect\r\n x={0}\r\n y={0}\r\n width={(d.x1 || 0) - (d.x0 || 0)}\r\n height={(d.y1 || 0) - (d.y0 || 0)}\r\n style={{ fill: (d as NodeDataType).color }}\r\n />\r\n {showLabels || showValues ? (\r\n <foreignObject\r\n y={0 - nodePadding / 2}\r\n x={nodeWidth}\r\n width={rightMargin - nodeWidth}\r\n height={(d.y1 || 0) - (d.y0 || 0) + nodePadding}\r\n >\r\n <div\r\n className='flex flex-col gap-0.5 justify-center py-0 px-1.5'\r\n style={{\r\n height: `${(d.y1 || 0) - (d.y0 || 0) + nodePadding}px`,\r\n }}\r\n >\r\n {showLabels ? (\r\n <P\r\n marginBottom={showValues ? '3xs' : 'none'}\r\n size='sm'\r\n leading='none'\r\n className={cn(\r\n 'sankey-left-label text-left',\r\n classNames?.graphObjectValues,\r\n )}\r\n style={{\r\n hyphens: 'auto',\r\n color: (d as NodeDataType).color,\r\n ...styles?.graphObjectValues,\r\n }}\r\n >\r\n {`${(d as NodeDataType).label}`.length < truncateBy\r\n ? `${(d as NodeDataType).label}`\r\n : `${`${(d as NodeDataType).label}`.substring(0, truncateBy)}...`}\r\n </P>\r\n ) : null}\r\n {showValues ? (\r\n <P\r\n size='sm'\r\n leading='none'\r\n marginBottom='none'\r\n className={cn(\r\n 'sankey-left-value text-left font-bold',\r\n classNames?.graphObjectValues,\r\n )}\r\n style={{\r\n hyphens: 'auto',\r\n color: (d as NodeDataType).color,\r\n ...styles?.graphObjectValues,\r\n }}\r\n >\r\n {numberFormattingFunction(d.value, 'NA', precision, prefix, suffix)}\r\n </P>\r\n ) : null}\r\n </div>\r\n </foreignObject>\r\n ) : null}\r\n </g>\r\n </g>\r\n ))}\r\n <defs>\r\n {links.map((d, i) => (\r\n <linearGradient\r\n id={`${id}-gradient-${i}`}\r\n x1='0%'\r\n y1='0%'\r\n x2='100%'\r\n y2='0%'\r\n key={i}\r\n gradientUnits='userSpaceOnUse'\r\n >\r\n <stop\r\n offset='0%'\r\n style={{\r\n stopColor: (d.source as NodeDataType).color,\r\n stopOpacity: 1,\r\n }}\r\n />\r\n <stop\r\n offset='100%'\r\n style={{\r\n stopColor: (d.target as NodeDataType).color,\r\n stopOpacity: 1,\r\n }}\r\n />\r\n </linearGradient>\r\n ))}\r\n </defs>\r\n <g>\r\n <AnimatePresence>\r\n {links.map((d, i) => (\r\n <motion.g\r\n className='undp-viz-g-with-hover'\r\n key={`${d.source}-${d.target}`}\r\n onMouseEnter={event => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n setMouseOverData((d as any).data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onMouseMove={event => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n setMouseOverData((d as any).data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n isEqual(mouseClickData, (d as any).data) &&\r\n resetSelectionOnDoubleClick\r\n ) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n setMouseClickData((d as any).data);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?.((d as any).data);\r\n }\r\n }\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 variants={{\r\n initial: {\r\n opacity: selectedNode\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.source as any).name === selectedNode.name ||\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.target as any).name === selectedNode.name\r\n ? 0.85\r\n : defaultLinkOpacity\r\n : highlightedSourceDataPoints.length !== 0 ||\r\n highlightedTargetDataPoints.length !== 0\r\n ? highlightedSourceDataPoints.indexOf(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.source as any).label,\r\n ) !== -1 ||\r\n highlightedTargetDataPoints.indexOf(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.target as any).label,\r\n ) !== -1\r\n ? 0.85\r\n : defaultLinkOpacity\r\n : defaultLinkOpacity,\r\n },\r\n whileInView: {\r\n opacity: selectedNode\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.source as any).name === selectedNode.name ||\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.target as any).name === selectedNode.name\r\n ? 0.85\r\n : defaultLinkOpacity\r\n : highlightedSourceDataPoints.length !== 0 ||\r\n highlightedTargetDataPoints.length !== 0\r\n ? highlightedSourceDataPoints.indexOf(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.source as any).label,\r\n ) !== -1 ||\r\n highlightedTargetDataPoints.indexOf(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.target as any).label,\r\n ) !== -1\r\n ? 0.85\r\n : defaultLinkOpacity\r\n : defaultLinkOpacity,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <motion.path\r\n key={`${d.source}-${d.target}`}\r\n d={linkPathGenerator(d) || ''}\r\n style={{\r\n stroke: `url(#${id}-gradient-${i})`,\r\n strokeWidth: d.width,\r\n fill: 'none',\r\n }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n opacity: 1,\r\n },\r\n whileInView: {\r\n pathLength: 1,\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 </motion.g>\r\n ))}\r\n </AnimatePresence>\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 uniqBy from 'lodash.uniqby';\r\nimport sortBy from 'lodash.sortby';\r\nimport sum from 'lodash.sum';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport {\r\n AnimateDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n Languages,\r\n NodesLinkDataType,\r\n SankeyDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: SankeyDataType[];\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 or array of colors for source */\r\n sourceColors?: string[] | string;\r\n /** Color or array of colors for targets */\r\n targetColors?: string[] | string;\r\n /** Domain of colors for the source */\r\n sourceColorDomain?: (string | number)[];\r\n /** Domain of colors for the target */\r\n targetColorDomain?: (string | number)[];\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 /** Toggles the background to fill the container. This only works if the width of the graph is defined. */\r\n fillContainer?: boolean;\r\n /** Padding between nodes */\r\n nodePadding?: number;\r\n /** Thickness of each node */\r\n nodeWidth?: 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 /** Truncate labels by specified length */\r\n truncateBy?: number;\r\n\r\n // Graph Parameters\r\n /** Title of the source */\r\n sourceTitle?: string;\r\n /** Title of the targets */\r\n targetTitle?: string;\r\n /** Toggle visibility of labels */\r\n showLabels?: boolean;\r\n /** Toggle visibility of values */\r\n showValues?: boolean;\r\n /** Source to highlight. Use the label value from data to highlight the data point */\r\n highlightedSourceDataPoints?: (string | number)[];\r\n /** Targets to highlight. Use the label value from data to highlight the data point */\r\n highlightedTargetDataPoints?: (string | number)[];\r\n /** Opacity of the links */\r\n defaultLinkOpacity?: number;\r\n /** Sorting order of the nodes */\r\n sortNodes?: 'asc' | 'desc' | 'mostReadable' | 'none';\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 /** 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 when user mouseover on the links. 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 SankeyChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n sources,\r\n graphDescription,\r\n showLabels = true,\r\n leftMargin = 75,\r\n rightMargin = 75,\r\n topMargin = 30,\r\n bottomMargin = 10,\r\n truncateBy = 999,\r\n height,\r\n width,\r\n footNote,\r\n padding,\r\n backgroundColor,\r\n tooltip,\r\n onSeriesMouseOver,\r\n suffix = '',\r\n prefix = '',\r\n relativeHeight,\r\n showValues = true,\r\n graphID,\r\n onSeriesMouseClick,\r\n graphDownload = false,\r\n dataDownload = false,\r\n fillContainer = true,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n sourceColors,\r\n targetColors,\r\n sourceColorDomain,\r\n targetColorDomain,\r\n nodePadding = 5,\r\n nodeWidth = 5,\r\n highlightedSourceDataPoints = [],\r\n highlightedTargetDataPoints = [],\r\n defaultLinkOpacity = 0.3,\r\n sourceTitle,\r\n targetTitle,\r\n sortNodes = 'mostReadable',\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n animate = false,\r\n precision = 2,\r\n customLayers = [],\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [sankeyData, setSankeyData] = useState<NodesLinkDataType | undefined>(undefined);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n const sourceNodes = uniqBy(data, 'source').map(d => ({\r\n name: `source_${d.source}`,\r\n type: 'source' as const,\r\n label: `${d.source}`,\r\n color:\r\n typeof sourceColors === 'string' || !sourceColors\r\n ? sourceColors || Colors.graphMainColor\r\n : sourceColors[\r\n (sourceColorDomain || uniqBy(data, 'source').map(el => `${el.source}`)).findIndex(\r\n el => `${el}` === `${d.source}`,\r\n ) > sourceColors.length\r\n ? sourceColors.length - 1\r\n : (sourceColorDomain || uniqBy(data, 'source').map(el => `${el.source}`)).findIndex(\r\n el => `${el}` === `${d.source}`,\r\n )\r\n ],\r\n totalValue: sum(data.filter(el => `${el.source}` === `${d.source}`).map(el => el.value)),\r\n }));\r\n const sourceNodesSorted =\r\n sortNodes === 'asc'\r\n ? sortBy(sourceNodes, d => d.totalValue)\r\n : sortNodes === 'desc'\r\n ? sortBy(sourceNodes, d => d.totalValue).reverse()\r\n : sourceNodes;\r\n const targetNodes = uniqBy(data, 'target').map(d => ({\r\n name: `target_${d.target}`,\r\n type: 'target' as const,\r\n label: `${d.target}`,\r\n color:\r\n typeof targetColors === 'string' || !targetColors\r\n ? targetColors || Colors.graphMainColor\r\n : targetColors[\r\n (targetColorDomain || uniqBy(data, 'target').map(el => `${el.target}`)).findIndex(\r\n el => `${el}` === `${d.target}`,\r\n ) > targetColors.length\r\n ? targetColors.length - 1\r\n : (targetColorDomain || uniqBy(data, 'target').map(el => `${el.target}`)).findIndex(\r\n el => `${el}` === `${d.target}`,\r\n )\r\n ],\r\n totalValue: sum(data.filter(el => `${el.target}` === `${d.target}`).map(el => el.value)),\r\n }));\r\n const targetNodesSorted =\r\n sortNodes === 'asc'\r\n ? sortBy(targetNodes, d => d.totalValue)\r\n : sortNodes === 'desc'\r\n ? sortBy(targetNodes, d => d.totalValue).reverse()\r\n : targetNodes;\r\n\r\n const nodes = [...sourceNodesSorted, ...targetNodesSorted];\r\n setSankeyData({\r\n nodes,\r\n links: data.map(d => ({\r\n source: nodes.findIndex(el => el.name === `source_${d.source}`),\r\n target: nodes.findIndex(el => el.name === `target_${d.target}`),\r\n value: d.value,\r\n data: { ...d },\r\n })),\r\n });\r\n }, [data, sortNodes, sourceColorDomain, sourceColors, targetColorDomain, targetColors]);\r\n\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'grow-0' : 'grow'} ${\r\n !fillContainer ? 'w-fit' : 'w-full'\r\n } `}\r\n dir={language === 'he' || language === 'ar' ? 'rtl' : undefined}\r\n >\r\n <div\r\n className={cn(\r\n `${\r\n !backgroundColor\r\n ? 'bg-transparent '\r\n : backgroundColor === true\r\n ? 'bg-primary-gray-200 dark:bg-primary-gray-650 '\r\n : ''\r\n }ml-auto mr-auto flex flex-col grow h-inherit ${language || 'en'}`,\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a sankey chart showing flow. ${graphDescription ? ` ${graphDescription}` : ''}`\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-4 w-full grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n {data.length === 0 ? (\r\n <EmptyState />\r\n ) : (\r\n <div\r\n className='flex flex-col grow justify-center gap-3 w-full leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) && sankeyData ? (\r\n <Graph\r\n data={sankeyData}\r\n width={width || svgWidth}\r\n nodePadding={nodePadding}\r\n nodeWidth={nodeWidth}\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 showLabels={showLabels}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n truncateBy={truncateBy}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n showValues={showValues}\r\n suffix={suffix}\r\n prefix={prefix}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n id={generateRandomString(8)}\r\n highlightedSourceDataPoints={highlightedSourceDataPoints.map(d => `${d}`)}\r\n highlightedTargetDataPoints={highlightedTargetDataPoints.map(d => `${d}`)}\r\n defaultLinkOpacity={defaultLinkOpacity}\r\n sourceTitle={sourceTitle}\r\n targetTitle={targetTitle}\r\n sortNodes={sortNodes}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n styles={styles}\r\n classNames={classNames}\r\n detailsOnClick={detailsOnClick}\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 />\r\n ) : null}\r\n </div>\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":["max","values","valueof","value","index","min","sum","targetDepth","d","justify","node","center","constant","x","ascendingSourceBreadth","a","b","ascendingBreadth","ascendingTargetBreadth","defaultId","defaultNodes","graph","defaultLinks","find","nodeById","id","computeLinkBreadths","nodes","y0","y1","link","Sankey","x0","x1","dx","dy","py","align","sort","linkSort","links","iterations","sankey","computeNodeLinks","computeNodeValues","computeNodeDepths","computeNodeHeights","computeNodeBreadths","_","i","source","target","sourceLinks","targetLinks","n","current","next","computeNodeLayers","kx","columns","column","initializeNodeBreadths","ky","c","y","reorderLinks","alpha","beta","relaxRightToLeft","relaxLeftToRight","w","v","targetTop","reorderNodeLinks","resolveCollisions","sourceTop","subject","resolveCollisionsBottomToTop","resolveCollisionsTopToBottom","width","pi","tau","epsilon","tauEpsilon","Path","path","x2","y2","r","x21","y21","x01","y01","l01_2","x20","y20","l21_2","l20_2","l21","l01","l","t01","t21","a0","a1","ccw","cw","da","h","p","slice","linkSource","linkTarget","curve","pointX","pointY","context","buffer","argv","s","t","curveHorizontal","linkHorizontal","horizontalSource","horizontalTarget","sankeyLinkHorizontal","Graph","props","data","showLabels","leftMargin","rightMargin","truncateBy","height","topMargin","bottomMargin","tooltip","onSeriesMouseOver","suffix","prefix","showValues","onSeriesMouseClick","nodePadding","nodeWidth","highlightedSourceDataPoints","highlightedTargetDataPoints","defaultLinkOpacity","sourceTitle","targetTitle","animate","sortNodes","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","precision","customLayers","svgRef","useRef","isInView","useInView","mouseOverData","setMouseOverData","useState","mouseClickData","setMouseClickData","selectedNode","setSelectedNode","eventX","setEventX","eventY","setEventY","margin","graphWidth","graphHeight","sankeyGenerator","sankeyCenter","linkPathGenerator","jsxs","Fragment","motion","jsx","P","cn","AnimatePresence","event","isEqual","Tooltip","Modal","string2HTML","SankeyChart","graphTitle","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","fillContainer","language","minHeight","theme","ariaLabel","sourceColors","targetColors","sourceColorDomain","targetColorDomain","svgWidth","setSvgWidth","svgHeight","setSvgHeight","sankeyData","setSankeyData","graphDiv","graphParentDiv","useEffect","sourceNodes","uniqBy","Colors","el","sourceNodesSorted","sortBy","targetNodes","targetNodesSorted","resizeObserver","entries","GraphHeader","EmptyState","generateRandomString","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;AAAe,SAASA,GAAIC,GAAQC,GAAS;AAC3C,MAAIF;AACJ,MAAIE,MAAY;AACd,eAAWC,KAASF;AAClB,MAAIE,KAAS,SACLH,IAAMG,KAAUH,MAAQ,UAAaG,KAASA,OACpDH,IAAMG;AAAA,OAGL;AACL,QAAIC,IAAQ;AACZ,aAASD,KAASF;AAChB,OAAKE,IAAQD,EAAQC,GAAO,EAAEC,GAAOH,CAAM,MAAM,SACzCD,IAAMG,KAAUH,MAAQ,UAAaG,KAASA,OACpDH,IAAMG;AAAA,EAGZ;AACA,SAAOH;AACT;ACnBe,SAASK,GAAIJ,GAAQC,GAAS;AAC3C,MAAIG;AACJ,MAAIH,MAAY;AACd,eAAWC,KAASF;AAClB,MAAIE,KAAS,SACLE,IAAMF,KAAUE,MAAQ,UAAaF,KAASA,OACpDE,IAAMF;AAAA,OAGL;AACL,QAAIC,IAAQ;AACZ,aAASD,KAASF;AAChB,OAAKE,IAAQD,EAAQC,GAAO,EAAEC,GAAOH,CAAM,MAAM,SACzCI,IAAMF,KAAUE,MAAQ,UAAaF,KAASA,OACpDE,IAAMF;AAAA,EAGZ;AACA,SAAOE;AACT;ACnBe,SAASC,GAAIL,GAAQC,GAAS;AAC3C,MAAII,IAAM;AACV,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;AAAA,wBACA,oBAAAE;AAAA,wBACA,IAAI0F,GAAqB,CAAC;AAAA,wBAC1B,6BAA6BvF,EAA4B,IAAI,CAAAxI,MAAK,GAAGA,CAAC,EAAE;AAAA,wBACxE,6BAA6ByI,EAA4B,IAAI,CAAAzI,MAAK,GAAGA,CAAC,EAAE;AAAA,wBACxE,oBAAA0I;AAAA,wBACA,aAAAC;AAAA,wBACA,aAAAC;AAAA,wBACA,WAAAE;AAAA,wBACA,6BAAAC;AAAA,wBACA,QAAAE;AAAA,wBACA,YAAAC;AAAA,wBACA,gBAAAF;AAAA,wBACA,SACEH,OAAY,KACR,EAAE,UAAU,KAAK,MAAM,IAAM,QAAQ,IAAA,IACrCA,MAAW,EAAE,UAAU,GAAG,MAAM,IAAM,QAAQ,EAAA;AAAA,wBAEpD,WAAAM;AAAA,wBACA,cAAAC;AAAA,sBAAA;AAAA,oBAAA,IAEA;AAAA,kBAAA;AAAA,gBAAA,GAGV;AAAA,gBACCoC,KAAWE,IACVb,gBAAAA,EAAAA;AAAAA,kBAACmD;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAU/E,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAAsC;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAAnH;AAAA,kBAAA;AAAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11]}
1
+ {"version":3,"file":"SankeyChart.js","sources":["../node_modules/d3-sankey/node_modules/d3-array/src/max.js","../node_modules/d3-sankey/node_modules/d3-array/src/min.js","../node_modules/d3-sankey/node_modules/d3-array/src/sum.js","../node_modules/d3-sankey/src/align.js","../node_modules/d3-sankey/src/constant.js","../node_modules/d3-sankey/src/sankey.js","../node_modules/d3-sankey/node_modules/d3-path/src/path.js","../node_modules/d3-sankey/node_modules/d3-shape/src/constant.js","../node_modules/d3-sankey/node_modules/d3-shape/src/point.js","../node_modules/d3-sankey/node_modules/d3-shape/src/array.js","../node_modules/d3-sankey/node_modules/d3-shape/src/link/index.js","../node_modules/d3-sankey/src/sankeyLinkHorizontal.js","../src/Components/Graphs/SankeyChart/Graph.tsx","../src/Components/Graphs/SankeyChart/index.tsx"],"sourcesContent":["export default function max(values, valueof) {\n let max;\n if (valueof === undefined) {\n for (const value of values) {\n if (value != null\n && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n } else {\n let index = -1;\n for (let value of values) {\n if ((value = valueof(value, ++index, values)) != null\n && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n }\n return max;\n}\n","export default function min(values, valueof) {\n let min;\n if (valueof === undefined) {\n for (const value of values) {\n if (value != null\n && (min > value || (min === undefined && value >= value))) {\n min = value;\n }\n }\n } else {\n let index = -1;\n for (let value of values) {\n if ((value = valueof(value, ++index, values)) != null\n && (min > value || (min === undefined && value >= value))) {\n min = value;\n }\n }\n }\n return min;\n}\n","export default function sum(values, valueof) {\n let sum = 0;\n if (valueof === undefined) {\n for (let value of values) {\n if (value = +value) {\n sum += value;\n }\n }\n } else {\n let index = -1;\n for (let value of values) {\n if (value = +valueof(value, ++index, values)) {\n sum += value;\n }\n }\n }\n return sum;\n}\n","import {min} from \"d3-array\";\n\nfunction targetDepth(d) {\n return d.target.depth;\n}\n\nexport function left(node) {\n return node.depth;\n}\n\nexport function right(node, n) {\n return n - 1 - node.height;\n}\n\nexport function justify(node, n) {\n return node.sourceLinks.length ? node.depth : n - 1;\n}\n\nexport function center(node) {\n return node.targetLinks.length ? node.depth\n : node.sourceLinks.length ? min(node.sourceLinks, targetDepth) - 1\n : 0;\n}\n","export default function constant(x) {\n return function() {\n return x;\n };\n}\n","import {max, min, sum} from \"d3-array\";\nimport {justify} from \"./align.js\";\nimport constant from \"./constant.js\";\n\nfunction ascendingSourceBreadth(a, b) {\n return ascendingBreadth(a.source, b.source) || a.index - b.index;\n}\n\nfunction ascendingTargetBreadth(a, b) {\n return ascendingBreadth(a.target, b.target) || a.index - b.index;\n}\n\nfunction ascendingBreadth(a, b) {\n return a.y0 - b.y0;\n}\n\nfunction value(d) {\n return d.value;\n}\n\nfunction defaultId(d) {\n return d.index;\n}\n\nfunction defaultNodes(graph) {\n return graph.nodes;\n}\n\nfunction defaultLinks(graph) {\n return graph.links;\n}\n\nfunction find(nodeById, id) {\n const node = nodeById.get(id);\n if (!node) throw new Error(\"missing: \" + id);\n return node;\n}\n\nfunction computeLinkBreadths({nodes}) {\n for (const node of nodes) {\n let y0 = node.y0;\n let y1 = y0;\n for (const link of node.sourceLinks) {\n link.y0 = y0 + link.width / 2;\n y0 += link.width;\n }\n for (const link of node.targetLinks) {\n link.y1 = y1 + link.width / 2;\n y1 += link.width;\n }\n }\n}\n\nexport default function Sankey() {\n let x0 = 0, y0 = 0, x1 = 1, y1 = 1; // extent\n let dx = 24; // nodeWidth\n let dy = 8, py; // nodePadding\n let id = defaultId;\n let align = justify;\n let sort;\n let linkSort;\n let nodes = defaultNodes;\n let links = defaultLinks;\n let iterations = 6;\n\n function sankey() {\n const graph = {nodes: nodes.apply(null, arguments), links: links.apply(null, arguments)};\n computeNodeLinks(graph);\n computeNodeValues(graph);\n computeNodeDepths(graph);\n computeNodeHeights(graph);\n computeNodeBreadths(graph);\n computeLinkBreadths(graph);\n return graph;\n }\n\n sankey.update = function(graph) {\n computeLinkBreadths(graph);\n return graph;\n };\n\n sankey.nodeId = function(_) {\n return arguments.length ? (id = typeof _ === \"function\" ? _ : constant(_), sankey) : id;\n };\n\n sankey.nodeAlign = function(_) {\n return arguments.length ? (align = typeof _ === \"function\" ? _ : constant(_), sankey) : align;\n };\n\n sankey.nodeSort = function(_) {\n return arguments.length ? (sort = _, sankey) : sort;\n };\n\n sankey.nodeWidth = function(_) {\n return arguments.length ? (dx = +_, sankey) : dx;\n };\n\n sankey.nodePadding = function(_) {\n return arguments.length ? (dy = py = +_, sankey) : dy;\n };\n\n sankey.nodes = function(_) {\n return arguments.length ? (nodes = typeof _ === \"function\" ? _ : constant(_), sankey) : nodes;\n };\n\n sankey.links = function(_) {\n return arguments.length ? (links = typeof _ === \"function\" ? _ : constant(_), sankey) : links;\n };\n\n sankey.linkSort = function(_) {\n return arguments.length ? (linkSort = _, sankey) : linkSort;\n };\n\n sankey.size = function(_) {\n return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];\n };\n\n sankey.extent = function(_) {\n return arguments.length ? (x0 = +_[0][0], x1 = +_[1][0], y0 = +_[0][1], y1 = +_[1][1], sankey) : [[x0, y0], [x1, y1]];\n };\n\n sankey.iterations = function(_) {\n return arguments.length ? (iterations = +_, sankey) : iterations;\n };\n\n function computeNodeLinks({nodes, links}) {\n for (const [i, node] of nodes.entries()) {\n node.index = i;\n node.sourceLinks = [];\n node.targetLinks = [];\n }\n const nodeById = new Map(nodes.map((d, i) => [id(d, i, nodes), d]));\n for (const [i, link] of links.entries()) {\n link.index = i;\n let {source, target} = link;\n if (typeof source !== \"object\") source = link.source = find(nodeById, source);\n if (typeof target !== \"object\") target = link.target = find(nodeById, target);\n source.sourceLinks.push(link);\n target.targetLinks.push(link);\n }\n if (linkSort != null) {\n for (const {sourceLinks, targetLinks} of nodes) {\n sourceLinks.sort(linkSort);\n targetLinks.sort(linkSort);\n }\n }\n }\n\n function computeNodeValues({nodes}) {\n for (const node of nodes) {\n node.value = node.fixedValue === undefined\n ? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value))\n : node.fixedValue;\n }\n }\n\n function computeNodeDepths({nodes}) {\n const n = nodes.length;\n let current = new Set(nodes);\n let next = new Set;\n let x = 0;\n while (current.size) {\n for (const node of current) {\n node.depth = x;\n for (const {target} of node.sourceLinks) {\n next.add(target);\n }\n }\n if (++x > n) throw new Error(\"circular link\");\n current = next;\n next = new Set;\n }\n }\n\n function computeNodeHeights({nodes}) {\n const n = nodes.length;\n let current = new Set(nodes);\n let next = new Set;\n let x = 0;\n while (current.size) {\n for (const node of current) {\n node.height = x;\n for (const {source} of node.targetLinks) {\n next.add(source);\n }\n }\n if (++x > n) throw new Error(\"circular link\");\n current = next;\n next = new Set;\n }\n }\n\n function computeNodeLayers({nodes}) {\n const x = max(nodes, d => d.depth) + 1;\n const kx = (x1 - x0 - dx) / (x - 1);\n const columns = new Array(x);\n for (const node of nodes) {\n const i = Math.max(0, Math.min(x - 1, Math.floor(align.call(null, node, x))));\n node.layer = i;\n node.x0 = x0 + i * kx;\n node.x1 = node.x0 + dx;\n if (columns[i]) columns[i].push(node);\n else columns[i] = [node];\n }\n if (sort) for (const column of columns) {\n column.sort(sort);\n }\n return columns;\n }\n\n function initializeNodeBreadths(columns) {\n const ky = min(columns, c => (y1 - y0 - (c.length - 1) * py) / sum(c, value));\n for (const nodes of columns) {\n let y = y0;\n for (const node of nodes) {\n node.y0 = y;\n node.y1 = y + node.value * ky;\n y = node.y1 + py;\n for (const link of node.sourceLinks) {\n link.width = link.value * ky;\n }\n }\n y = (y1 - y + py) / (nodes.length + 1);\n for (let i = 0; i < nodes.length; ++i) {\n const node = nodes[i];\n node.y0 += y * (i + 1);\n node.y1 += y * (i + 1);\n }\n reorderLinks(nodes);\n }\n }\n\n function computeNodeBreadths(graph) {\n const columns = computeNodeLayers(graph);\n py = Math.min(dy, (y1 - y0) / (max(columns, c => c.length) - 1));\n initializeNodeBreadths(columns);\n for (let i = 0; i < iterations; ++i) {\n const alpha = Math.pow(0.99, i);\n const beta = Math.max(1 - alpha, (i + 1) / iterations);\n relaxRightToLeft(columns, alpha, beta);\n relaxLeftToRight(columns, alpha, beta);\n }\n }\n\n // Reposition each node based on its incoming (target) links.\n function relaxLeftToRight(columns, alpha, beta) {\n for (let i = 1, n = columns.length; i < n; ++i) {\n const column = columns[i];\n for (const target of column) {\n let y = 0;\n let w = 0;\n for (const {source, value} of target.targetLinks) {\n let v = value * (target.layer - source.layer);\n y += targetTop(source, target) * v;\n w += v;\n }\n if (!(w > 0)) continue;\n let dy = (y / w - target.y0) * alpha;\n target.y0 += dy;\n target.y1 += dy;\n reorderNodeLinks(target);\n }\n if (sort === undefined) column.sort(ascendingBreadth);\n resolveCollisions(column, beta);\n }\n }\n\n // Reposition each node based on its outgoing (source) links.\n function relaxRightToLeft(columns, alpha, beta) {\n for (let n = columns.length, i = n - 2; i >= 0; --i) {\n const column = columns[i];\n for (const source of column) {\n let y = 0;\n let w = 0;\n for (const {target, value} of source.sourceLinks) {\n let v = value * (target.layer - source.layer);\n y += sourceTop(source, target) * v;\n w += v;\n }\n if (!(w > 0)) continue;\n let dy = (y / w - source.y0) * alpha;\n source.y0 += dy;\n source.y1 += dy;\n reorderNodeLinks(source);\n }\n if (sort === undefined) column.sort(ascendingBreadth);\n resolveCollisions(column, beta);\n }\n }\n\n function resolveCollisions(nodes, alpha) {\n const i = nodes.length >> 1;\n const subject = nodes[i];\n resolveCollisionsBottomToTop(nodes, subject.y0 - py, i - 1, alpha);\n resolveCollisionsTopToBottom(nodes, subject.y1 + py, i + 1, alpha);\n resolveCollisionsBottomToTop(nodes, y1, nodes.length - 1, alpha);\n resolveCollisionsTopToBottom(nodes, y0, 0, alpha);\n }\n\n // Push any overlapping nodes down.\n function resolveCollisionsTopToBottom(nodes, y, i, alpha) {\n for (; i < nodes.length; ++i) {\n const node = nodes[i];\n const dy = (y - node.y0) * alpha;\n if (dy > 1e-6) node.y0 += dy, node.y1 += dy;\n y = node.y1 + py;\n }\n }\n\n // Push any overlapping nodes up.\n function resolveCollisionsBottomToTop(nodes, y, i, alpha) {\n for (; i >= 0; --i) {\n const node = nodes[i];\n const dy = (node.y1 - y) * alpha;\n if (dy > 1e-6) node.y0 -= dy, node.y1 -= dy;\n y = node.y0 - py;\n }\n }\n\n function reorderNodeLinks({sourceLinks, targetLinks}) {\n if (linkSort === undefined) {\n for (const {source: {sourceLinks}} of targetLinks) {\n sourceLinks.sort(ascendingTargetBreadth);\n }\n for (const {target: {targetLinks}} of sourceLinks) {\n targetLinks.sort(ascendingSourceBreadth);\n }\n }\n }\n\n function reorderLinks(nodes) {\n if (linkSort === undefined) {\n for (const {sourceLinks, targetLinks} of nodes) {\n sourceLinks.sort(ascendingTargetBreadth);\n targetLinks.sort(ascendingSourceBreadth);\n }\n }\n }\n\n // Returns the target.y0 that would produce an ideal link from source to target.\n function targetTop(source, target) {\n let y = source.y0 - (source.sourceLinks.length - 1) * py / 2;\n for (const {target: node, width} of source.sourceLinks) {\n if (node === target) break;\n y += width + py;\n }\n for (const {source: node, width} of target.targetLinks) {\n if (node === source) break;\n y -= width;\n }\n return y;\n }\n\n // Returns the source.y0 that would produce an ideal link from source to target.\n function sourceTop(source, target) {\n let y = target.y0 - (target.targetLinks.length - 1) * py / 2;\n for (const {source: node, width} of target.targetLinks) {\n if (node === source) break;\n y += width + py;\n }\n for (const {target: node, width} of source.sourceLinks) {\n if (node === target) break;\n y -= width;\n }\n return y;\n }\n\n return sankey;\n}\n","var pi = Math.PI,\n tau = 2 * pi,\n epsilon = 1e-6,\n tauEpsilon = tau - epsilon;\n\nfunction Path() {\n this._x0 = this._y0 = // start of current subpath\n this._x1 = this._y1 = null; // end of current subpath\n this._ = \"\";\n}\n\nfunction path() {\n return new Path;\n}\n\nPath.prototype = path.prototype = {\n constructor: Path,\n moveTo: function(x, y) {\n this._ += \"M\" + (this._x0 = this._x1 = +x) + \",\" + (this._y0 = this._y1 = +y);\n },\n closePath: function() {\n if (this._x1 !== null) {\n this._x1 = this._x0, this._y1 = this._y0;\n this._ += \"Z\";\n }\n },\n lineTo: function(x, y) {\n this._ += \"L\" + (this._x1 = +x) + \",\" + (this._y1 = +y);\n },\n quadraticCurveTo: function(x1, y1, x, y) {\n this._ += \"Q\" + (+x1) + \",\" + (+y1) + \",\" + (this._x1 = +x) + \",\" + (this._y1 = +y);\n },\n bezierCurveTo: function(x1, y1, x2, y2, x, y) {\n this._ += \"C\" + (+x1) + \",\" + (+y1) + \",\" + (+x2) + \",\" + (+y2) + \",\" + (this._x1 = +x) + \",\" + (this._y1 = +y);\n },\n arcTo: function(x1, y1, x2, y2, r) {\n x1 = +x1, y1 = +y1, x2 = +x2, y2 = +y2, r = +r;\n var x0 = this._x1,\n y0 = this._y1,\n x21 = x2 - x1,\n y21 = y2 - y1,\n x01 = x0 - x1,\n y01 = y0 - y1,\n l01_2 = x01 * x01 + y01 * y01;\n\n // Is the radius negative? Error.\n if (r < 0) throw new Error(\"negative radius: \" + r);\n\n // Is this path empty? Move to (x1,y1).\n if (this._x1 === null) {\n this._ += \"M\" + (this._x1 = x1) + \",\" + (this._y1 = y1);\n }\n\n // Or, is (x1,y1) coincident with (x0,y0)? Do nothing.\n else if (!(l01_2 > epsilon));\n\n // Or, are (x0,y0), (x1,y1) and (x2,y2) collinear?\n // Equivalently, is (x1,y1) coincident with (x2,y2)?\n // Or, is the radius zero? Line to (x1,y1).\n else if (!(Math.abs(y01 * x21 - y21 * x01) > epsilon) || !r) {\n this._ += \"L\" + (this._x1 = x1) + \",\" + (this._y1 = y1);\n }\n\n // Otherwise, draw an arc!\n else {\n var x20 = x2 - x0,\n y20 = y2 - y0,\n l21_2 = x21 * x21 + y21 * y21,\n l20_2 = x20 * x20 + y20 * y20,\n l21 = Math.sqrt(l21_2),\n l01 = Math.sqrt(l01_2),\n l = r * Math.tan((pi - Math.acos((l21_2 + l01_2 - l20_2) / (2 * l21 * l01))) / 2),\n t01 = l / l01,\n t21 = l / l21;\n\n // If the start tangent is not coincident with (x0,y0), line to.\n if (Math.abs(t01 - 1) > epsilon) {\n this._ += \"L\" + (x1 + t01 * x01) + \",\" + (y1 + t01 * y01);\n }\n\n this._ += \"A\" + r + \",\" + r + \",0,0,\" + (+(y01 * x20 > x01 * y20)) + \",\" + (this._x1 = x1 + t21 * x21) + \",\" + (this._y1 = y1 + t21 * y21);\n }\n },\n arc: function(x, y, r, a0, a1, ccw) {\n x = +x, y = +y, r = +r, ccw = !!ccw;\n var dx = r * Math.cos(a0),\n dy = r * Math.sin(a0),\n x0 = x + dx,\n y0 = y + dy,\n cw = 1 ^ ccw,\n da = ccw ? a0 - a1 : a1 - a0;\n\n // Is the radius negative? Error.\n if (r < 0) throw new Error(\"negative radius: \" + r);\n\n // Is this path empty? Move to (x0,y0).\n if (this._x1 === null) {\n this._ += \"M\" + x0 + \",\" + y0;\n }\n\n // Or, is (x0,y0) not coincident with the previous point? Line to (x0,y0).\n else if (Math.abs(this._x1 - x0) > epsilon || Math.abs(this._y1 - y0) > epsilon) {\n this._ += \"L\" + x0 + \",\" + y0;\n }\n\n // Is this arc empty? We’re done.\n if (!r) return;\n\n // Does the angle go the wrong way? Flip the direction.\n if (da < 0) da = da % tau + tau;\n\n // Is this a complete circle? Draw two arcs to complete the circle.\n if (da > tauEpsilon) {\n this._ += \"A\" + r + \",\" + r + \",0,1,\" + cw + \",\" + (x - dx) + \",\" + (y - dy) + \"A\" + r + \",\" + r + \",0,1,\" + cw + \",\" + (this._x1 = x0) + \",\" + (this._y1 = y0);\n }\n\n // Is this arc non-empty? Draw an arc!\n else if (da > epsilon) {\n this._ += \"A\" + r + \",\" + r + \",0,\" + (+(da >= pi)) + \",\" + cw + \",\" + (this._x1 = x + r * Math.cos(a1)) + \",\" + (this._y1 = y + r * Math.sin(a1));\n }\n },\n rect: function(x, y, w, h) {\n this._ += \"M\" + (this._x0 = this._x1 = +x) + \",\" + (this._y0 = this._y1 = +y) + \"h\" + (+w) + \"v\" + (+h) + \"h\" + (-w) + \"Z\";\n },\n toString: function() {\n return this._;\n }\n};\n\nexport default path;\n","export default function(x) {\n return function constant() {\n return x;\n };\n}\n","export function x(p) {\n return p[0];\n}\n\nexport function y(p) {\n return p[1];\n}\n","export var slice = Array.prototype.slice;\n","import {path} from \"d3-path\";\nimport {slice} from \"../array.js\";\nimport constant from \"../constant.js\";\nimport {x as pointX, y as pointY} from \"../point.js\";\nimport pointRadial from \"../pointRadial.js\";\n\nfunction linkSource(d) {\n return d.source;\n}\n\nfunction linkTarget(d) {\n return d.target;\n}\n\nfunction link(curve) {\n var source = linkSource,\n target = linkTarget,\n x = pointX,\n y = pointY,\n context = null;\n\n function link() {\n var buffer, argv = slice.call(arguments), s = source.apply(this, argv), t = target.apply(this, argv);\n if (!context) context = buffer = path();\n curve(context, +x.apply(this, (argv[0] = s, argv)), +y.apply(this, argv), +x.apply(this, (argv[0] = t, argv)), +y.apply(this, argv));\n if (buffer) return context = null, buffer + \"\" || null;\n }\n\n link.source = function(_) {\n return arguments.length ? (source = _, link) : source;\n };\n\n link.target = function(_) {\n return arguments.length ? (target = _, link) : target;\n };\n\n link.x = function(_) {\n return arguments.length ? (x = typeof _ === \"function\" ? _ : constant(+_), link) : x;\n };\n\n link.y = function(_) {\n return arguments.length ? (y = typeof _ === \"function\" ? _ : constant(+_), link) : y;\n };\n\n link.context = function(_) {\n return arguments.length ? ((context = _ == null ? null : _), link) : context;\n };\n\n return link;\n}\n\nfunction curveHorizontal(context, x0, y0, x1, y1) {\n context.moveTo(x0, y0);\n context.bezierCurveTo(x0 = (x0 + x1) / 2, y0, x0, y1, x1, y1);\n}\n\nfunction curveVertical(context, x0, y0, x1, y1) {\n context.moveTo(x0, y0);\n context.bezierCurveTo(x0, y0 = (y0 + y1) / 2, x1, y0, x1, y1);\n}\n\nfunction curveRadial(context, x0, y0, x1, y1) {\n var p0 = pointRadial(x0, y0),\n p1 = pointRadial(x0, y0 = (y0 + y1) / 2),\n p2 = pointRadial(x1, y0),\n p3 = pointRadial(x1, y1);\n context.moveTo(p0[0], p0[1]);\n context.bezierCurveTo(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1]);\n}\n\nexport function linkHorizontal() {\n return link(curveHorizontal);\n}\n\nexport function linkVertical() {\n return link(curveVertical);\n}\n\nexport function linkRadial() {\n var l = link(curveRadial);\n l.angle = l.x, delete l.x;\n l.radius = l.y, delete l.y;\n return l;\n}\n","import {linkHorizontal} from \"d3-shape\";\n\nfunction horizontalSource(d) {\n return [d.source.x1, d.y0];\n}\n\nfunction horizontalTarget(d) {\n return [d.target.x0, d.y1];\n}\n\nexport default function() {\n return linkHorizontal()\n .source(horizontalSource)\n .target(horizontalTarget);\n}\n","import isEqual from 'fast-deep-equal';\r\nimport { useRef, useState } from 'react';\r\nimport { sankey, sankeyCenter, sankeyLinkHorizontal } from 'd3-sankey';\r\nimport { AnimatePresence, motion, useInView } from 'motion/react';\r\nimport { Modal } from '@undp/design-system-react/Modal';\r\nimport { cn } from '@undp/design-system-react/cn';\r\nimport { P } from '@undp/design-system-react/Typography';\r\n\r\nimport {\r\n AnimateDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n NodeDataType,\r\n NodesLinkDataType,\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\n\r\ninterface Props {\r\n data: NodesLinkDataType;\r\n showLabels: boolean;\r\n leftMargin: number;\r\n truncateBy: number;\r\n defaultLinkOpacity: number;\r\n width: number;\r\n height: number;\r\n nodePadding: number;\r\n nodeWidth: number;\r\n rightMargin: number;\r\n topMargin: number;\r\n bottomMargin: number;\r\n suffix: string;\r\n prefix: string;\r\n showValues?: boolean;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n tooltip?: string | ((_d: any) => React.ReactNode);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseOver?: (_d: any) => void;\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?: (_d: any) => void;\r\n id: string;\r\n highlightedSourceDataPoints: string[];\r\n highlightedTargetDataPoints: string[];\r\n sourceTitle?: string;\r\n targetTitle?: string;\r\n animate: AnimateDataType;\r\n sortNodes: 'asc' | 'desc' | 'mostReadable' | 'none';\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 precision: number;\r\n customLayers: CustomLayerDataType[];\r\n}\r\n\r\nexport function Graph(props: Props) {\r\n const {\r\n data,\r\n showLabels,\r\n leftMargin,\r\n rightMargin,\r\n truncateBy,\r\n width,\r\n height,\r\n topMargin,\r\n bottomMargin,\r\n tooltip,\r\n onSeriesMouseOver,\r\n suffix,\r\n prefix,\r\n showValues,\r\n onSeriesMouseClick,\r\n nodePadding,\r\n nodeWidth,\r\n id,\r\n highlightedSourceDataPoints,\r\n highlightedTargetDataPoints,\r\n defaultLinkOpacity,\r\n sourceTitle,\r\n targetTitle,\r\n animate,\r\n sortNodes,\r\n resetSelectionOnDoubleClick,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n precision,\r\n customLayers,\r\n } = props;\r\n const svgRef = useRef(null);\r\n const isInView = useInView(svgRef, {\r\n once: animate.once,\r\n amount: animate.amount,\r\n });\r\n // 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const [selectedNode, setSelectedNode] = 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 const sankeyGenerator =\r\n sortNodes === 'mostReadable'\r\n ? sankey()\r\n .nodeWidth(nodeWidth)\r\n .nodePadding(nodePadding)\r\n .size([graphWidth, graphHeight])\r\n .nodeAlign(sankeyCenter)\r\n : sortNodes === 'none'\r\n ? sankey()\r\n .nodeWidth(nodeWidth)\r\n .nodePadding(nodePadding)\r\n .size([graphWidth, graphHeight])\r\n .nodeAlign(sankeyCenter)\r\n .nodeSort(() => null)\r\n .linkSort(() => null)\r\n : sankey()\r\n .nodeWidth(nodeWidth)\r\n .nodePadding(nodePadding)\r\n .size([graphWidth, graphHeight])\r\n .nodeAlign(sankeyCenter)\r\n .nodeSort(\r\n sortNodes === 'desc'\r\n ? (a, b) => (b.value || 0) - (a.value || 0)\r\n : (a, b) => (a.value || 0) - (b.value || 0),\r\n );\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n const { nodes, links } = sankeyGenerator(data as any);\r\n const linkPathGenerator = sankeyLinkHorizontal();\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 style={{ marginLeft: 'auto', marginRight: 'auto' }}\r\n direction='ltr'\r\n ref={svgRef}\r\n >\r\n {sourceTitle ? (\r\n <text\r\n x={margin.left}\r\n y={margin.top - 10}\r\n className='text-base font-bold fill-primary-gray-700 dark:fill-primary-gray-100'\r\n style={{ textAnchor: 'start' }}\r\n >\r\n {sourceTitle}\r\n </text>\r\n ) : null}\r\n {targetTitle ? (\r\n <text\r\n x={width - margin.right}\r\n y={margin.top - 10}\r\n className='text-base font-bold fill-primary-gray-700 dark:fill-primary-gray-100'\r\n style={{ textAnchor: 'end' }}\r\n >\r\n {targetTitle}\r\n </text>\r\n ) : null}\r\n <g transform={`translate(${margin.left},${margin.top})`}>\r\n {customLayers.filter(d => d.position === 'before').map(d => d.layer)}\r\n {nodes\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .filter((d: any) => d.type === 'source')\r\n .map((d, i) => (\r\n <g\r\n key={i}\r\n onMouseEnter={() => {\r\n setSelectedNode(d);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedNode(undefined);\r\n }}\r\n >\r\n <g transform={`translate(${d.x0},${d.y0})`}>\r\n <rect\r\n x={0}\r\n y={0}\r\n width={(d.x1 || 0) - (d.x0 || 0)}\r\n height={(d.y1 || 0) - (d.y0 || 0)}\r\n style={{ fill: (d as NodeDataType).color }}\r\n />\r\n {showLabels || showValues ? (\r\n <foreignObject\r\n y={0 - nodePadding / 2}\r\n x={0 - leftMargin}\r\n width={leftMargin}\r\n height={(d.y1 || 0) - (d.y0 || 0) + nodePadding}\r\n >\r\n <div\r\n className='flex flex-col gap-0.5 justify-center py-0 px-1.5'\r\n style={{\r\n height: `${(d.y1 || 0) - (d.y0 || 0) + nodePadding}px`,\r\n overflow: 'visible',\r\n }}\r\n >\r\n {showLabels ? (\r\n <P\r\n marginBottom={showValues ? '3xs' : 'none'}\r\n size='sm'\r\n leading='none'\r\n className={cn(\r\n 'sankey-right-label text-right',\r\n classNames?.graphObjectValues,\r\n )}\r\n style={{\r\n hyphens: 'auto',\r\n color: (d as NodeDataType).color,\r\n ...styles?.graphObjectValues,\r\n }}\r\n >\r\n {`${(d as NodeDataType).label}`.length < truncateBy\r\n ? `${(d as NodeDataType).label}`\r\n : `${`${(d as NodeDataType).label}`.substring(0, truncateBy)}...`}\r\n </P>\r\n ) : null}\r\n {showValues ? (\r\n <P\r\n marginBottom='none'\r\n size='sm'\r\n leading='none'\r\n className={cn(\r\n 'sankey-right-value text-right font-bold',\r\n classNames?.graphObjectValues,\r\n )}\r\n style={{\r\n hyphens: 'auto',\r\n color: (d as NodeDataType).color,\r\n ...styles?.graphObjectValues,\r\n }}\r\n >\r\n {numberFormattingFunction(d.value, 'NA', precision, prefix, suffix)}\r\n </P>\r\n ) : null}\r\n </div>\r\n </foreignObject>\r\n ) : null}\r\n </g>\r\n </g>\r\n ))}\r\n {nodes\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n .filter((d: any) => d.type === 'target')\r\n .map((d, i) => (\r\n <g\r\n key={i}\r\n onMouseEnter={() => {\r\n setSelectedNode(d);\r\n }}\r\n onMouseLeave={() => {\r\n setSelectedNode(undefined);\r\n }}\r\n >\r\n <g transform={`translate(${d.x0},${d.y0})`}>\r\n <rect\r\n x={0}\r\n y={0}\r\n width={(d.x1 || 0) - (d.x0 || 0)}\r\n height={(d.y1 || 0) - (d.y0 || 0)}\r\n style={{ fill: (d as NodeDataType).color }}\r\n />\r\n {showLabels || showValues ? (\r\n <foreignObject\r\n y={0 - nodePadding / 2}\r\n x={nodeWidth}\r\n width={rightMargin - nodeWidth}\r\n height={(d.y1 || 0) - (d.y0 || 0) + nodePadding}\r\n >\r\n <div\r\n className='flex flex-col gap-0.5 justify-center py-0 px-1.5'\r\n style={{\r\n height: `${(d.y1 || 0) - (d.y0 || 0) + nodePadding}px`,\r\n }}\r\n >\r\n {showLabels ? (\r\n <P\r\n marginBottom={showValues ? '3xs' : 'none'}\r\n size='sm'\r\n leading='none'\r\n className={cn(\r\n 'sankey-left-label text-left',\r\n classNames?.graphObjectValues,\r\n )}\r\n style={{\r\n hyphens: 'auto',\r\n color: (d as NodeDataType).color,\r\n ...styles?.graphObjectValues,\r\n }}\r\n >\r\n {`${(d as NodeDataType).label}`.length < truncateBy\r\n ? `${(d as NodeDataType).label}`\r\n : `${`${(d as NodeDataType).label}`.substring(0, truncateBy)}...`}\r\n </P>\r\n ) : null}\r\n {showValues ? (\r\n <P\r\n size='sm'\r\n leading='none'\r\n marginBottom='none'\r\n className={cn(\r\n 'sankey-left-value text-left font-bold',\r\n classNames?.graphObjectValues,\r\n )}\r\n style={{\r\n hyphens: 'auto',\r\n color: (d as NodeDataType).color,\r\n ...styles?.graphObjectValues,\r\n }}\r\n >\r\n {numberFormattingFunction(d.value, 'NA', precision, prefix, suffix)}\r\n </P>\r\n ) : null}\r\n </div>\r\n </foreignObject>\r\n ) : null}\r\n </g>\r\n </g>\r\n ))}\r\n <defs>\r\n {links.map((d, i) => (\r\n <linearGradient\r\n id={`${id}-gradient-${i}`}\r\n x1='0%'\r\n y1='0%'\r\n x2='100%'\r\n y2='0%'\r\n key={i}\r\n gradientUnits='userSpaceOnUse'\r\n >\r\n <stop\r\n offset='0%'\r\n style={{\r\n stopColor: (d.source as NodeDataType).color,\r\n stopOpacity: 1,\r\n }}\r\n />\r\n <stop\r\n offset='100%'\r\n style={{\r\n stopColor: (d.target as NodeDataType).color,\r\n stopOpacity: 1,\r\n }}\r\n />\r\n </linearGradient>\r\n ))}\r\n </defs>\r\n <g>\r\n <AnimatePresence>\r\n {links.map((d, i) => (\r\n <motion.g\r\n className='undp-viz-g-with-hover'\r\n key={`${d.source}-${d.target}`}\r\n onMouseEnter={event => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n setMouseOverData((d as any).data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n\r\n onSeriesMouseOver?.(d);\r\n }}\r\n onMouseMove={event => {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n setMouseOverData((d as any).data);\r\n setEventY(event.clientY);\r\n setEventX(event.clientX);\r\n }}\r\n onClick={() => {\r\n if (onSeriesMouseClick || detailsOnClick) {\r\n if (\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n isEqual(mouseClickData, (d as any).data) &&\r\n resetSelectionOnDoubleClick\r\n ) {\r\n setMouseClickData(undefined);\r\n onSeriesMouseClick?.(undefined);\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n setMouseClickData((d as any).data);\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n onSeriesMouseClick?.((d as any).data);\r\n }\r\n }\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 variants={{\r\n initial: {\r\n opacity: selectedNode\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.source as any).name === selectedNode.name ||\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.target as any).name === selectedNode.name\r\n ? 0.85\r\n : defaultLinkOpacity\r\n : highlightedSourceDataPoints.length !== 0 ||\r\n highlightedTargetDataPoints.length !== 0\r\n ? highlightedSourceDataPoints.indexOf(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.source as any).label,\r\n ) !== -1 ||\r\n highlightedTargetDataPoints.indexOf(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.target as any).label,\r\n ) !== -1\r\n ? 0.85\r\n : defaultLinkOpacity\r\n : defaultLinkOpacity,\r\n },\r\n whileInView: {\r\n opacity: selectedNode\r\n ? // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.source as any).name === selectedNode.name ||\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.target as any).name === selectedNode.name\r\n ? 0.85\r\n : defaultLinkOpacity\r\n : highlightedSourceDataPoints.length !== 0 ||\r\n highlightedTargetDataPoints.length !== 0\r\n ? highlightedSourceDataPoints.indexOf(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.source as any).label,\r\n ) !== -1 ||\r\n highlightedTargetDataPoints.indexOf(\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n (d.target as any).label,\r\n ) !== -1\r\n ? 0.85\r\n : defaultLinkOpacity\r\n : defaultLinkOpacity,\r\n transition: { duration: animate.duration },\r\n },\r\n }}\r\n initial='initial'\r\n animate={isInView ? 'whileInView' : 'initial'}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n >\r\n <motion.path\r\n key={`${d.source}-${d.target}`}\r\n d={linkPathGenerator(d) || ''}\r\n style={{\r\n stroke: `url(#${id}-gradient-${i})`,\r\n strokeWidth: d.width,\r\n fill: 'none',\r\n }}\r\n exit={{ opacity: 0, transition: { duration: animate.duration } }}\r\n variants={{\r\n initial: {\r\n pathLength: 0,\r\n opacity: 1,\r\n },\r\n whileInView: {\r\n pathLength: 1,\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 </motion.g>\r\n ))}\r\n </AnimatePresence>\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 uniqBy from 'lodash.uniqby';\r\nimport sortBy from 'lodash.sortby';\r\nimport sum from 'lodash.sum';\r\nimport { cn } from '@undp/design-system-react/cn';\r\n\r\nimport { Graph } from './Graph';\r\n\r\nimport { GraphHeader } from '@/Components/Elements/GraphHeader';\r\nimport {\r\n AnimateDataType,\r\n ClassNameObject,\r\n CustomLayerDataType,\r\n Languages,\r\n NodesLinkDataType,\r\n SankeyDataType,\r\n SourcesDataType,\r\n StyleObject,\r\n} from '@/Types';\r\nimport { GraphFooter } from '@/Components/Elements/GraphFooter';\r\nimport { Colors } from '@/Components/ColorPalette';\r\nimport { generateRandomString } from '@/Utils/generateRandomString';\r\nimport { EmptyState } from '@/Components/Elements/EmptyState';\r\n\r\ninterface Props {\r\n // Data\r\n /** Array of data objects */\r\n data: SankeyDataType[];\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 or array of colors for source */\r\n sourceColors?: string[] | string;\r\n /** Color or array of colors for targets */\r\n targetColors?: string[] | string;\r\n /** Domain of colors for the source */\r\n sourceColorDomain?: (string | number)[];\r\n /** Domain of colors for the target */\r\n targetColorDomain?: (string | number)[];\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 /** Toggles the background to fill the container. This only works if the width of the graph is defined. */\r\n fillContainer?: boolean;\r\n /** Padding between nodes */\r\n nodePadding?: number;\r\n /** Thickness of each node */\r\n nodeWidth?: 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 /** Truncate labels by specified length */\r\n truncateBy?: number;\r\n\r\n // Graph Parameters\r\n /** Title of the source */\r\n sourceTitle?: string;\r\n /** Title of the targets */\r\n targetTitle?: string;\r\n /** Toggle visibility of labels */\r\n showLabels?: boolean;\r\n /** Toggle visibility of values */\r\n showValues?: boolean;\r\n /** Source to highlight. Use the label value from data to highlight the data point */\r\n highlightedSourceDataPoints?: (string | number)[];\r\n /** Targets to highlight. Use the label value from data to highlight the data point */\r\n highlightedTargetDataPoints?: (string | number)[];\r\n /** Opacity of the links */\r\n defaultLinkOpacity?: number;\r\n /** Sorting order of the nodes */\r\n sortNodes?: 'asc' | 'desc' | 'mostReadable' | 'none';\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 /** 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 when user mouseover on the links. 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 SankeyChart(props: Props) {\r\n const {\r\n data,\r\n graphTitle,\r\n sources,\r\n graphDescription,\r\n showLabels = true,\r\n leftMargin = 75,\r\n rightMargin = 75,\r\n topMargin = 30,\r\n bottomMargin = 10,\r\n truncateBy = 999,\r\n height,\r\n width,\r\n footNote,\r\n padding,\r\n backgroundColor,\r\n tooltip,\r\n onSeriesMouseOver,\r\n suffix = '',\r\n prefix = '',\r\n relativeHeight,\r\n showValues = true,\r\n graphID,\r\n onSeriesMouseClick,\r\n graphDownload = false,\r\n dataDownload = false,\r\n fillContainer = true,\r\n language = 'en',\r\n minHeight = 0,\r\n theme = 'light',\r\n ariaLabel,\r\n sourceColors,\r\n targetColors,\r\n sourceColorDomain,\r\n targetColorDomain,\r\n nodePadding = 5,\r\n nodeWidth = 5,\r\n highlightedSourceDataPoints = [],\r\n highlightedTargetDataPoints = [],\r\n defaultLinkOpacity = 0.3,\r\n sourceTitle,\r\n targetTitle,\r\n sortNodes = 'mostReadable',\r\n resetSelectionOnDoubleClick = true,\r\n detailsOnClick,\r\n styles,\r\n classNames,\r\n animate = false,\r\n precision = 2,\r\n customLayers = [],\r\n } = props;\r\n\r\n const [svgWidth, setSvgWidth] = useState(0);\r\n const [svgHeight, setSvgHeight] = useState(0);\r\n const [sankeyData, setSankeyData] = useState<NodesLinkDataType | undefined>(undefined);\r\n\r\n const graphDiv = useRef<HTMLDivElement>(null);\r\n const graphParentDiv = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n const sourceNodes = uniqBy(data, 'source').map(d => ({\r\n name: `source_${d.source}`,\r\n type: 'source' as const,\r\n label: `${d.source}`,\r\n color:\r\n typeof sourceColors === 'string' || !sourceColors\r\n ? sourceColors || Colors.graphMainColor\r\n : sourceColors[\r\n (sourceColorDomain || uniqBy(data, 'source').map(el => `${el.source}`)).findIndex(\r\n el => `${el}` === `${d.source}`,\r\n ) > sourceColors.length\r\n ? sourceColors.length - 1\r\n : (sourceColorDomain || uniqBy(data, 'source').map(el => `${el.source}`)).findIndex(\r\n el => `${el}` === `${d.source}`,\r\n )\r\n ],\r\n totalValue: sum(data.filter(el => `${el.source}` === `${d.source}`).map(el => el.value)),\r\n }));\r\n const sourceNodesSorted =\r\n sortNodes === 'asc'\r\n ? sortBy(sourceNodes, d => d.totalValue)\r\n : sortNodes === 'desc'\r\n ? sortBy(sourceNodes, d => d.totalValue).reverse()\r\n : sourceNodes;\r\n const targetNodes = uniqBy(data, 'target').map(d => ({\r\n name: `target_${d.target}`,\r\n type: 'target' as const,\r\n label: `${d.target}`,\r\n color:\r\n typeof targetColors === 'string' || !targetColors\r\n ? targetColors || Colors.graphMainColor\r\n : targetColors[\r\n (targetColorDomain || uniqBy(data, 'target').map(el => `${el.target}`)).findIndex(\r\n el => `${el}` === `${d.target}`,\r\n ) > targetColors.length\r\n ? targetColors.length - 1\r\n : (targetColorDomain || uniqBy(data, 'target').map(el => `${el.target}`)).findIndex(\r\n el => `${el}` === `${d.target}`,\r\n )\r\n ],\r\n totalValue: sum(data.filter(el => `${el.target}` === `${d.target}`).map(el => el.value)),\r\n }));\r\n const targetNodesSorted =\r\n sortNodes === 'asc'\r\n ? sortBy(targetNodes, d => d.totalValue)\r\n : sortNodes === 'desc'\r\n ? sortBy(targetNodes, d => d.totalValue).reverse()\r\n : targetNodes;\r\n\r\n const nodes = [...sourceNodesSorted, ...targetNodesSorted];\r\n setSankeyData({\r\n nodes,\r\n links: data.map(d => ({\r\n source: nodes.findIndex(el => el.name === `source_${d.source}`),\r\n target: nodes.findIndex(el => el.name === `target_${d.target}`),\r\n value: d.value,\r\n data: { ...d },\r\n })),\r\n });\r\n }, [data, sortNodes, sourceColorDomain, sourceColors, targetColorDomain, targetColors]);\r\n\r\n useEffect(() => {\r\n const resizeObserver = new ResizeObserver(entries => {\r\n setSvgWidth(width || entries[0].target.clientWidth || 620);\r\n setSvgHeight(height || entries[0].target.clientHeight || 480);\r\n });\r\n if (graphDiv.current) {\r\n setSvgHeight(graphDiv.current.clientHeight || 480);\r\n setSvgWidth(graphDiv.current.clientWidth || 620);\r\n if (!width) resizeObserver.observe(graphDiv.current);\r\n }\r\n return () => resizeObserver.disconnect();\r\n }, [width, height]);\r\n\r\n return (\r\n <div\r\n className={`${theme || 'light'} flex ${width ? 'grow-0' : 'grow'} ${\r\n !fillContainer ? 'w-fit' : 'w-full'\r\n } `}\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 !fillContainer ? 'w-fit' : 'w-full',\r\n classNames?.graphContainer,\r\n )}\r\n style={{\r\n ...(styles?.graphContainer || {}),\r\n ...(backgroundColor && backgroundColor !== true ? { backgroundColor } : {}),\r\n }}\r\n id={graphID}\r\n ref={graphParentDiv}\r\n aria-label={\r\n ariaLabel ||\r\n `${\r\n graphTitle ? `The graph shows ${graphTitle}. ` : ''\r\n }This is a sankey chart showing flow. ${graphDescription ? ` ${graphDescription}` : ''}`\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-4 w-full grow justify-between'>\r\n {graphTitle || graphDescription || graphDownload || dataDownload ? (\r\n <GraphHeader\r\n styles={{\r\n title: styles?.title,\r\n description: styles?.description,\r\n }}\r\n classNames={{\r\n title: classNames?.title,\r\n description: classNames?.description,\r\n }}\r\n graphTitle={graphTitle}\r\n graphDescription={graphDescription}\r\n width={width}\r\n graphDownload={graphDownload ? graphParentDiv.current : undefined}\r\n dataDownload={\r\n dataDownload\r\n ? data.map(d => d.data).filter(d => d !== undefined).length > 0\r\n ? data.map(d => d.data).filter(d => d !== undefined)\r\n : data.filter(d => d !== undefined)\r\n : null\r\n }\r\n />\r\n ) : null}\r\n <div className='grow flex flex-col justify-center gap-3 w-full'>\r\n {data.length === 0 ? (\r\n <EmptyState />\r\n ) : (\r\n <div\r\n className='flex flex-col grow justify-center gap-3 w-full leading-0'\r\n ref={graphDiv}\r\n aria-label='Graph area'\r\n >\r\n {(width || svgWidth) && (height || svgHeight) && sankeyData ? (\r\n <Graph\r\n data={sankeyData}\r\n width={width || svgWidth}\r\n nodePadding={nodePadding}\r\n nodeWidth={nodeWidth}\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 showLabels={showLabels}\r\n leftMargin={leftMargin}\r\n rightMargin={rightMargin}\r\n topMargin={topMargin}\r\n bottomMargin={bottomMargin}\r\n truncateBy={truncateBy}\r\n tooltip={tooltip}\r\n onSeriesMouseOver={onSeriesMouseOver}\r\n showValues={showValues}\r\n suffix={suffix}\r\n prefix={prefix}\r\n onSeriesMouseClick={onSeriesMouseClick}\r\n id={generateRandomString(8)}\r\n highlightedSourceDataPoints={highlightedSourceDataPoints.map(d => `${d}`)}\r\n highlightedTargetDataPoints={highlightedTargetDataPoints.map(d => `${d}`)}\r\n defaultLinkOpacity={defaultLinkOpacity}\r\n sourceTitle={sourceTitle}\r\n targetTitle={targetTitle}\r\n sortNodes={sortNodes}\r\n resetSelectionOnDoubleClick={resetSelectionOnDoubleClick}\r\n styles={styles}\r\n classNames={classNames}\r\n detailsOnClick={detailsOnClick}\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 />\r\n ) : null}\r\n </div>\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":["max","values","valueof","value","index","min","sum","targetDepth","d","justify","node","center","constant","x","ascendingSourceBreadth","a","b","ascendingBreadth","ascendingTargetBreadth","defaultId","defaultNodes","graph","defaultLinks","find","nodeById","id","computeLinkBreadths","nodes","y0","y1","link","Sankey","x0","x1","dx","dy","py","align","sort","linkSort","links","iterations","sankey","computeNodeLinks","computeNodeValues","computeNodeDepths","computeNodeHeights","computeNodeBreadths","_","i","source","target","sourceLinks","targetLinks","n","current","next","computeNodeLayers","kx","columns","column","initializeNodeBreadths","ky","c","y","reorderLinks","alpha","beta","relaxRightToLeft","relaxLeftToRight","w","v","targetTop","reorderNodeLinks","resolveCollisions","sourceTop","subject","resolveCollisionsBottomToTop","resolveCollisionsTopToBottom","width","pi","tau","epsilon","tauEpsilon","Path","path","x2","y2","r","x21","y21","x01","y01","l01_2","x20","y20","l21_2","l20_2","l21","l01","l","t01","t21","a0","a1","ccw","cw","da","h","p","slice","linkSource","linkTarget","curve","pointX","pointY","context","buffer","argv","s","t","curveHorizontal","linkHorizontal","horizontalSource","horizontalTarget","sankeyLinkHorizontal","Graph","props","data","showLabels","leftMargin","rightMargin","truncateBy","height","topMargin","bottomMargin","tooltip","onSeriesMouseOver","suffix","prefix","showValues","onSeriesMouseClick","nodePadding","nodeWidth","highlightedSourceDataPoints","highlightedTargetDataPoints","defaultLinkOpacity","sourceTitle","targetTitle","animate","sortNodes","resetSelectionOnDoubleClick","detailsOnClick","styles","classNames","precision","customLayers","svgRef","useRef","isInView","useInView","mouseOverData","setMouseOverData","useState","mouseClickData","setMouseClickData","selectedNode","setSelectedNode","eventX","setEventX","eventY","setEventY","margin","graphWidth","graphHeight","sankeyGenerator","sankeyCenter","linkPathGenerator","jsxs","Fragment","motion","jsx","P","cn","AnimatePresence","event","isEqual","Tooltip","Modal","string2HTML","SankeyChart","graphTitle","sources","graphDescription","footNote","padding","backgroundColor","relativeHeight","graphID","graphDownload","dataDownload","fillContainer","language","minHeight","theme","ariaLabel","sourceColors","targetColors","sourceColorDomain","targetColorDomain","svgWidth","setSvgWidth","svgHeight","setSvgHeight","sankeyData","setSankeyData","graphDiv","graphParentDiv","useEffect","sourceNodes","uniqBy","Colors","el","sourceNodesSorted","sortBy","targetNodes","targetNodesSorted","resizeObserver","entries","GraphHeader","EmptyState","generateRandomString","GraphFooter"],"mappings":";;;;;;;;;;;;;;;;;;;AAAe,SAASA,GAAIC,GAAQC,GAAS;AAC3C,MAAIF;AACJ,MAAIE,MAAY;AACd,eAAWC,KAASF;AAClB,MAAIE,KAAS,SACLH,IAAMG,KAAUH,MAAQ,UAAaG,KAASA,OACpDH,IAAMG;AAAA,OAGL;AACL,QAAIC,IAAQ;AACZ,aAASD,KAASF;AAChB,OAAKE,IAAQD,EAAQC,GAAO,EAAEC,GAAOH,CAAM,MAAM,SACzCD,IAAMG,KAAUH,MAAQ,UAAaG,KAASA,OACpDH,IAAMG;AAAA,EAGZ;AACA,SAAOH;AACT;ACnBe,SAASK,GAAIJ,GAAQC,GAAS;AAC3C,MAAIG;AACJ,MAAIH,MAAY;AACd,eAAWC,KAASF;AAClB,MAAIE,KAAS,SACLE,IAAMF,KAAUE,MAAQ,UAAaF,KAASA,OACpDE,IAAMF;AAAA,OAGL;AACL,QAAIC,IAAQ;AACZ,aAASD,KAASF;AAChB,OAAKE,IAAQD,EAAQC,GAAO,EAAEC,GAAOH,CAAM,MAAM,SACzCI,IAAMF,KAAUE,MAAQ,UAAaF,KAASA,OACpDE,IAAMF;AAAA,EAGZ;AACA,SAAOE;AACT;ACnBe,SAASC,GAAIL,GAAQC,GAAS;AAC3C,MAAII,IAAM;AACV,MAAIJ,MAAY;AACd,aAASC,KAASF;AAChB,OAAIE,IAAQ,CAACA,OACXG,KAAOH;AAAA,OAGN;AACL,QAAIC,IAAQ;AACZ,aAASD,K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IAAI,CAAAxI,MAAK,GAAGA,CAAC,EAAE;AAAA,wBACxE,6BAA6ByI,EAA4B,IAAI,CAAAzI,MAAK,GAAGA,CAAC,EAAE;AAAA,wBACxE,oBAAA0I;AAAA,wBACA,aAAAC;AAAA,wBACA,aAAAC;AAAA,wBACA,WAAAE;AAAA,wBACA,6BAAAC;AAAA,wBACA,QAAAE;AAAA,wBACA,YAAAC;AAAA,wBACA,gBAAAF;AAAA,wBACA,SACEH,OAAY,KACR,EAAE,UAAU,KAAK,MAAM,IAAM,QAAQ,IAAA,IACrCA,MAAW,EAAE,UAAU,GAAG,MAAM,IAAM,QAAQ,EAAA;AAAA,wBAEpD,WAAAM;AAAA,wBACA,cAAAC;AAAA,sBAAA;AAAA,oBAAA,IAEA;AAAA,kBAAA;AAAA,gBAAA,GAGV;AAAA,gBACCoC,KAAWE,IACVb,gBAAAA,EAAAA;AAAAA,kBAACmD;AAAA,kBAAA;AAAA,oBACC,QAAQ,EAAE,UAAU/E,GAAQ,UAAU,QAAQA,GAAQ,OAAA;AAAA,oBACtD,YAAY;AAAA,sBACV,UAAUC,GAAY;AAAA,sBACtB,QAAQA,GAAY;AAAA,oBAAA;AAAA,oBAEtB,SAAAsC;AAAA,oBACA,UAAAE;AAAA,oBACA,OAAAnH;AAAA,kBAAA;AAAA,gBAAA,IAEA;AAAA,cAAA,EAAA,CACN;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11]}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),ke=require("./index-CZbIGs8q.cjs"),Me=require("./parse-hMnG_lRV.cjs"),j=require("react"),Ae=require("./getSliderMarks-CtsEXiLV.cjs"),Ie=require("./index-BXns0-ng.cjs"),Ue=require("./index-BczVvEBZ.cjs"),Le=require("./simple-statistics-xm8c0LQQ.cjs"),Fe=require("./Modal-tXZlLE5s.cjs"),He=require("./Tooltip-n8z5bfav.cjs"),c=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),N=require("./Colors.cjs"),Ve=require("./numberFormattingFunction-02t-wJta.cjs"),Ne=require("./customArea-CK768gCn.cjs"),Ge=require("./string2HTML-D2Avudmb.cjs"),$e=require("./Axis-DE7dSn1_.cjs"),Te=require("./AxisTitle-CK9YeovX.cjs"),We=require("./XTicksAndGridLines-CCzXIV8d.cjs"),De=require("./ReferenceLine-CFVBBN__.cjs"),Be=require("./RegressionLine-xKdiJ8sw.cjs"),ze=require("./YTicksAndGridLines-DBDuz6vb.cjs"),_e=require("./index-DNj994Pv.cjs"),Je=require("./pow-B5-jkdHU.cjs"),Pe=require("./linear-BVckp9RD.cjs"),Ke=require("./delaunay-rcy0HhZi.cjs"),Qe=require("./use-in-view-sQJZ_xDO.cjs"),ie=require("./proxy-BHRoeZgd.cjs"),Xe=require("./index-BW8iNx7E.cjs"),Ze=require("./GraphFooter.cjs"),et=require("./GraphHeader.cjs"),tt=require("./ColorLegendWithMouseOver.cjs"),it=require("./EmptyState-d8_8SxeW.cjs"),Ye=require("./index-BW_-wD2k.cjs"),st=require("./ensureCompleteData-DqWQ2Zbi.cjs"),ot=require("./init-DU0ybBc_.cjs");function rt(ge){const{data:s,width:q,height:M,showLabels:se,colors:l,colorDomain:C,radius:R,xAxisTitle:h,yAxisTitle:J,leftMargin:G,rightMargin:ye,topMargin:pe,bottomMargin:oe,tooltip:re,onSeriesMouseOver:X,refXValues:I,refYValues:je,highlightAreaSettings:ve,selectedColor:W,highlightedDataPoints:L,maxRadiusValue:be,maxXValue:B,minXValue:w,maxYValue:Oe,minYValue:E,onSeriesMouseClick:V,rtl:K,annotations:Ce,customHighlightAreaSettings:Re,regressionLine:z,resetSelectionOnDoubleClick:Q,detailsOnClick:k,noOfXTicks:ne,noOfYTicks:le,labelColor:Z,xSuffix:ae,ySuffix:ce,xPrefix:xe,yPrefix:ue,styles:x,classNames:u,animate:n,dimmedOpacity:A,precision:S,customLayers:fe}=ge,me=j.useRef(null),p=Qe.useInView(me,{once:n.once,amount:n.amount}),[$,T]=j.useState(void 0),[D,Y]=j.useState(void 0),[de,P]=j.useState(void 0),[he,v]=j.useState(void 0),m={top:pe,bottom:h?oe+50:oe,left:J?G+30:G,right:ye},_=s.map((e,y)=>({...e,id:`${y}`})),g=q-m.left-m.right,b=M-m.top-m.bottom,O=s.filter(e=>e.radius===void 0||e.radius===null).length!==s.length?Je.sqrt().domain([0,be]).range([.25,R]).nice():void 0,d=_.filter(e=>!c.checkIfNullOrUndefined(e.radius)).length===0?_:Ue.orderBy(_.filter(e=>!c.checkIfNullOrUndefined(e.radius)),"radius","desc"),r=Pe.linear().domain([w,B]).range([0,g]).nice(),a=Pe.linear().domain([E,Oe]).range([b,0]).nice(),ee=r.ticks(ne),te=a.ticks(le),U=Ke.Delaunay.from(d.filter(e=>!c.checkIfNullOrUndefined(e.x)&&!c.checkIfNullOrUndefined(e.y)),e=>r(e.x),e=>a(e.y)).voronoi([0,0,g<0?0:g,b<0?0:b]),we=Le.linearRegression(s.filter(e=>!c.checkIfNullOrUndefined(e.x)&&!c.checkIfNullOrUndefined(e.y)).map(e=>[r(e.x),a(e.y)])),f=Le.linearRegressionLine(we);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(ie.motion.svg,{width:`${q}px`,height:`${M}px`,viewBox:`0 0 ${q} ${M}`,direction:"ltr",ref:me,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${m.left},${m.top})`,children:[i.jsxRuntimeExports.jsxs(Xe.AnimatePresence,{children:[i.jsxRuntimeExports.jsx(_e.HighlightAreaForScatterPlot,{areaSettings:ve,width:g,height:b,scaleX:r,scaleY:a,animate:n,isInView:p}),i.jsxRuntimeExports.jsx(Ne.CustomArea,{areaSettings:Re,scaleX:r,scaleY:a,animate:n,isInView:p})]}),i.jsxRuntimeExports.jsxs("g",{children:[i.jsxRuntimeExports.jsx(ze.YTicksAndGridLines,{values:te.filter(e=>e!==0),y:te.filter(e=>e!==0).map(e=>a(e)),x1:0,x2:g+m.right,styles:{gridLines:x?.yAxis?.gridLines,labels:x?.yAxis?.labels},classNames:{gridLines:u?.yAxis?.gridLines,labels:u?.yAxis?.labels},suffix:ce,prefix:ue,labelType:"secondary",showGridLines:!0,labelPos:"side",precision:S}),i.jsxRuntimeExports.jsx($e.Axis,{y1:a(E<0?0:E),y2:a(E<0?0:E),x1:0,x2:g+m.right,label:Ve.numberFormattingFunction(E<0?0:E,"NA",S,ue,ce),labelPos:{x:0,y:a(E<0?0:E),dy:"0.33em",dx:-4},classNames:{axis:u?.xAxis?.axis,label:u?.yAxis?.labels},styles:{axis:x?.xAxis?.axis,label:{textAnchor:"end",...x?.yAxis?.labels||{}}}}),i.jsxRuntimeExports.jsx(Te.AxisTitle,{x:0-G-15,y:b/2,style:x?.yAxis?.title,className:u?.yAxis?.title,text:J,rotate90:!0})]}),i.jsxRuntimeExports.jsxs("g",{children:[i.jsxRuntimeExports.jsx(We.XTicksAndGridLines,{values:ee.filter(e=>e!==0),x:ee.filter(e=>e!==0).map(e=>r(e)),y1:0,y2:b,styles:{gridLines:x?.xAxis?.gridLines,labels:x?.xAxis?.labels},classNames:{gridLines:u?.xAxis?.gridLines,labels:u?.xAxis?.labels},suffix:ae,prefix:xe,labelType:"primary",showGridLines:!0,precision:S}),i.jsxRuntimeExports.jsx($e.Axis,{x1:r(w<0?0:w),x2:r(w<0?0:w),y1:0,y2:b,label:Ve.numberFormattingFunction(w<0?0:w,"NA",S,xe,ae),labelPos:{x:r(w<0?0:w),y:b,dy:"1em",dx:0},classNames:{axis:u?.xAxis?.axis,label:u?.yAxis?.labels},styles:{axis:x?.xAxis?.axis,label:{textAnchor:"middle",...x?.yAxis?.labels||{}}}}),i.jsxRuntimeExports.jsx(Te.AxisTitle,{x:g/2,y:b+30,style:x?.xAxis?.title,className:u?.xAxis?.title,text:h})]}),fe.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(Xe.AnimatePresence,{children:[d.filter(e=>!c.checkIfNullOrUndefined(e.x)&&!c.checkIfNullOrUndefined(e.y)).map((e,y)=>i.jsxRuntimeExports.jsx("path",{d:U.renderCell(d.findIndex(o=>o.id===e.id)),opacity:0,onMouseEnter:o=>{T(e),v(o.clientY),P(o.clientX),X?.(e)},onMouseMove:o=>{T(e),v(o.clientY),P(o.clientX)},onMouseLeave:()=>{T(void 0),P(void 0),v(void 0),X?.(void 0)},onClick:()=>{(V||k)&&(Ie.isEqual(D,e)&&Q?(Y(void 0),V?.(void 0)):(Y(e),V?.(e)))}},`${e.label||y}`)),d.filter(e=>!c.checkIfNullOrUndefined(e.x)&&!c.checkIfNullOrUndefined(e.y)).map((e,y)=>i.jsxRuntimeExports.jsxs(ie.motion.g,{variants:{initial:{x:r(e.x),y:a(e.y),opacity:W?e.color&&l[C.indexOf(`${e.color}`)]===W?1:A:$?$.id===e.id?1:A:L.length!==0?L.indexOf(e.label||"")!==-1?1:A:1},whileInView:{x:r(e.x),y:a(e.y),opacity:W?e.color&&l[C.indexOf(`${e.color}`)]===W?1:A:$?$.id===e.id?1:A:L.length!==0?L.indexOf(e.label||"")!==-1?1:A:1,transition:{duration:n.duration}}},initial:"initial",animate:p?"whileInView":"initial",exit:{opacity:0,transition:{duration:n.duration}},onMouseEnter:o=>{T(e),v(o.clientY),P(o.clientX),X?.(e)},onMouseMove:o=>{T(e),v(o.clientY),P(o.clientX)},onMouseLeave:()=>{T(void 0),P(void 0),v(void 0),X?.(void 0)},onClick:()=>{(V||k)&&(Ie.isEqual(D,e)&&Q?(Y(void 0),V?.(void 0)):(Y(e),V?.(e)))},children:[i.jsxRuntimeExports.jsx(ie.motion.circle,{cx:0,cy:0,exit:{r:0,transition:{duration:n.duration}},variants:{initial:{r:0,fill:s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray,stroke:s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray},whileInView:{r:O?O(e.radius||0):R,fill:s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray,stroke:s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray,transition:{duration:n.duration}}},initial:"initial",animate:p?"whileInView":"initial",style:{fillOpacity:.6}}),se&&!c.checkIfNullOrUndefined(e.label)?i.jsxRuntimeExports.jsx(ie.motion.text,{style:{...x?.graphObjectValues||{}},className:i.mo("graph-value text-sm",u?.graphObjectValues),y:0,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{x:O?O(e.radius||0):R,opacity:0,fill:Z||(s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray)},whileInView:{x:O?O(e.radius||0):R,opacity:1,fill:Z||(s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray),transition:{duration:n.duration}}},initial:"initial",animate:p?"whileInView":"initial",dy:"0.33em",dx:3,children:e.label}):L.length!==0&&!c.checkIfNullOrUndefined(e.label)&&L.indexOf(e.label)!==-1?i.jsxRuntimeExports.jsx(ie.motion.text,{style:{fill:Z||(s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray),...x?.graphObjectValues||{}},className:i.mo("graph-value text-sm",u?.graphObjectValues),y:0,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{x:O?O(e.radius||0):R,opacity:0},whileInView:{x:O?O(e.radius||0):R,opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:p?"whileInView":"initial",dy:"0.33em",dx:3,children:e.label}):null]},`${e.label||y}`)),I.map((e,y)=>i.jsxRuntimeExports.jsx(De.RefLineX,{text:e.text,color:e.color,x:r(e.value),y1:0,y2:b,textSide:r(e.value)>g*.75||K?"left":"right",classNames:e.classNames,styles:e.styles,animate:n,isInView:p},y)),je.map((e,y)=>i.jsxRuntimeExports.jsx(De.RefLineY,{text:e.text,color:e.color,y:a(e.value),x1:0,x2:g,classNames:e.classNames,styles:e.styles,animate:n,isInView:p},y)),i.jsxRuntimeExports.jsx("g",{children:Ce.map((e,y)=>{const o=Ne.getLineEndPoint({x:e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?a(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?r(e.xCoordinate):0,y:e.yCoordinate?a(e.yCoordinate):0},c.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),Ee=e.showConnector?{y1:o.y,x1:o.x,y2:e.yCoordinate?a(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0),cy:e.yCoordinate?a(e.yCoordinate):0,cx:e.xCoordinate?r(e.xCoordinate):0,circleRadius:c.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,F={y:e.yCoordinate?a(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:K?0:e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0),width:K?e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0):g+m.right-(e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return i.jsxRuntimeExports.jsx(Ne.Annotation,{color:e.color,connectorsSettings:Ee,labelSettings:F,text:e.text,classNames:e.classNames,styles:e.styles,animate:n,isInView:p},y)})}),z?i.jsxRuntimeExports.jsx(Be.RegressionLine,{x1:0,x2:g,y1:f(0),y2:f(g),graphHeight:b,graphWidth:g,className:u?.regLine,style:x?.regLine,color:typeof z=="string"?z:void 0,animate:n,isInView:p}):null]}),fe.filter(e=>e.position==="after").map(e=>e.layer)]})}),$&&re&&de&&he?i.jsxRuntimeExports.jsx(He.Tooltip,{data:$,body:re,xPos:de,yPos:he,backgroundStyle:x?.tooltip,className:u?.tooltip}):null,k&&D!==void 0?i.jsxRuntimeExports.jsx(Fe.X,{open:D!==void 0,onClose:()=>{Y(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof k=="string"?{__html:Ge.string2HTML(k,D)}:void 0,children:typeof k=="function"?k(D):null})}):null]})}function nt(ge){const{data:s,graphTitle:q,colors:M,sources:se,graphDescription:l,showLabels:C=!1,height:R,width:h,footNote:J,colorDomain:G,colorLegendTitle:ye,radius:pe=5,xAxisTitle:oe="X Axis",yAxisTitle:re="Y Axis",padding:X,backgroundColor:I=!1,leftMargin:je=0,rightMargin:ve=10,topMargin:W=20,bottomMargin:L=50,tooltip:be,relativeHeight:B,onSeriesMouseOver:w,refXValues:Oe=[],refYValues:E=[],highlightAreaSettings:V=[],showColorScale:K=!0,highlightedDataPoints:Ce=[],graphID:Re,maxRadiusValue:z,maxXValue:Q,minXValue:k,maxYValue:ne,minYValue:le,xSuffix:Z="",ySuffix:ae="",xPrefix:ce="",yPrefix:xe="",onSeriesMouseClick:ue,graphDownload:x=!1,dataDownload:u=!1,language:n="en",showNAColor:A=!0,minHeight:S=0,annotations:fe=[],customHighlightAreaSettings:me=[],theme:p="light",regressionLine:$=!1,ariaLabel:T,resetSelectionOnDoubleClick:D=!0,detailsOnClick:Y,noOfXTicks:de=5,noOfYTicks:P=5,labelColor:he,styles:v,classNames:m,animate:_=!1,dimmedOpacity:g=.3,precision:b=2,customLayers:O=[],timeline:d={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=ge,[r,a]=j.useState(0),[ee,te]=j.useState(0),[U,we]=j.useState(d.autoplay),f=Ae.sort(ke.uniqBy(s.filter(t=>t.date!==void 0&&t.date!==null),t=>t.date).map(t=>Me.parse(`${t.date}`,d.dateFormat||"yyyy",new Date).getTime()),(t,H)=>ot.ascending(t,H)),[e,y]=j.useState(d.autoplay?0:f.length-1),[o,Ee]=j.useState(void 0),F=j.useRef(null),Se=j.useRef(null);j.useEffect(()=>{const t=new ResizeObserver(H=>{a(h||H[0].target.clientWidth||620),te(R||H[0].target.clientHeight||480)});return F.current&&(te(F.current.clientHeight||480),a(F.current.clientWidth||620),h||t.observe(F.current)),()=>t.disconnect()},[h,R]),j.useEffect(()=>{const t=setInterval(()=>{y(H=>H<f.length-1?H+1:0)},(d.speed||2)*1e3);return U||clearInterval(t),()=>clearInterval(t)},[f,U,d.speed]);const qe=Ae.getSliderMarks(f,e,d.showOnlyActiveDate,d.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${p||"light"} flex ${h?"w-fit grow-0":"w-full grow"}`,dir:n==="he"||n==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${I?I===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${n||"en"}`,m?.graphContainer),style:{...v?.graphContainer||{},...I&&I!==!0?{backgroundColor:I}:{}},id:Re,ref:Se,"aria-label":T||`${q?`The graph shows ${q}. `:""}This is a scatter plot that shows correlation between two variables.${l?` ${l}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:I?X||"1rem":X||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[q||l||x||u?i.jsxRuntimeExports.jsx(et.GraphHeader,{styles:{title:v?.title,description:v?.description},classNames:{title:m?.title,description:m?.description},graphTitle:q,graphDescription:l,width:h,graphDownload:x?Se.current:void 0,dataDownload:u?s.map(t=>t.data).filter(t=>t!==void 0).length>0?s.map(t=>t.data).filter(t=>t!==void 0):s.filter(t=>t!==void 0):null}):null,d.enabled&&f.length>0&&qe?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!U)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":U?"Click to pause animation":"Click to play animation",children:U?i.jsxRuntimeExports.jsx(Ye.Pause,{}):i.jsxRuntimeExports.jsx(Ye.Play,{})}),i.jsxRuntimeExports.jsx(Ae.xr,{min:f[0],max:f[f.length-1],marks:qe,step:null,defaultValue:f[f.length-1],value:f[e],onChangeComplete:t=>{y(f.indexOf(t))},onChange:t=>{y(f.indexOf(t))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(it.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[K&&s.filter(t=>t.color).length!==0?i.jsxRuntimeExports.jsx(tt.ColorLegendWithMouseOver,{width:h,colorLegendTitle:ye,colors:M||N.Colors[p].categoricalColors.colors,colorDomain:G||ke.uniqBy(s.filter(t=>t.color),"color").map(t=>t.color),setSelectedColor:Ee,showNAColor:A}):null,i.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:F,"aria-label":"Graph area",children:(h||r)&&(R||ee)?i.jsxRuntimeExports.jsx(rt,{data:st.ensureCompleteDataForScatterPlot(s,d.dateFormat||"yyyy").filter(t=>d.enabled?t.date===Me.format(new Date(f[e]),d.dateFormat||"yyyy"):t),width:h||r,height:Math.max(S,R||(B?S?(h||r)*B>S?(h||r)*B:S:(h||r)*B:ee)),colorDomain:s.filter(t=>t.color).length===0?[]:G||ke.uniqBy(s.filter(t=>t.color),"color").map(t=>t.color),colors:s.filter(t=>t.color).length===0?M?[M]:[N.Colors.primaryColors["blue-600"]]:M||N.Colors[p].categoricalColors.colors,xAxisTitle:oe,yAxisTitle:re,refXValues:Oe,refYValues:E,showLabels:C,radius:pe,leftMargin:je,rightMargin:ve,topMargin:W,bottomMargin:L,tooltip:be,onSeriesMouseOver:w,highlightAreaSettings:V,highlightedDataPoints:s.filter(t=>t.label).length===0?[]:Ce,selectedColor:o,maxRadiusValue:c.checkIfNullOrUndefined(z)?Math.max(...s.map(t=>t.radius).filter(t=>t!=null)):z,maxXValue:c.checkIfNullOrUndefined(Q)?Math.max(...s.map(t=>t.x).filter(t=>t!=null))>0?Math.max(...s.map(t=>t.x).filter(t=>t!=null)):0:Q,minXValue:c.checkIfNullOrUndefined(k)?Math.min(...s.map(t=>t.x).filter(t=>t!=null))>0?0:Math.min(...s.map(t=>t.x).filter(t=>t!=null)):k,maxYValue:c.checkIfNullOrUndefined(ne)?Math.max(...s.map(t=>t.y).filter(t=>t!=null))>0?Math.max(...s.map(t=>t.y).filter(t=>t!=null)):0:ne,minYValue:c.checkIfNullOrUndefined(le)?Math.min(...s.map(t=>t.y).filter(t=>t!=null))>0?0:Math.min(...s.map(t=>t.y).filter(t=>t!=null)):le,onSeriesMouseClick:ue,rtl:n==="he"||n==="ar",annotations:fe,customHighlightAreaSettings:me,regressionLine:$,resetSelectionOnDoubleClick:D,detailsOnClick:Y,noOfXTicks:de,noOfYTicks:P,labelColor:he,xSuffix:Z,ySuffix:ae,xPrefix:ce,yPrefix:xe,styles:v,classNames:m,animate:_===!0?{duration:.5,once:!0,amount:.5}:_||{duration:0,once:!0,amount:0},dimmedOpacity:g,precision:b,customLayers:O}):null})]})}),se||J?i.jsxRuntimeExports.jsx(Ze.GraphFooter,{styles:{footnote:v?.footnote,source:v?.source},classNames:{footnote:m?.footnote,source:m?.source},sources:se,footNote:J,width:h}):null]})})})})}exports.ScatterPlot=nt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./index-CHPV5EwG-DDoeWRVt.cjs"),ke=require("./index-CZbIGs8q.cjs"),Me=require("./parse-hMnG_lRV.cjs"),j=require("react"),Ae=require("./getSliderMarks-CtsEXiLV.cjs"),Ie=require("./index-BXns0-ng.cjs"),Ue=require("./index-BczVvEBZ.cjs"),Le=require("./simple-statistics-xm8c0LQQ.cjs"),Fe=require("./Modal-tXZlLE5s.cjs"),He=require("./Tooltip-n8z5bfav.cjs"),c=require("./checkIfNullOrUndefined-BCW3Y1ML.cjs"),N=require("./Colors.cjs"),Ve=require("./numberFormattingFunction-02t-wJta.cjs"),Ne=require("./customArea-CK768gCn.cjs"),Ge=require("./string2HTML-D2Avudmb.cjs"),$e=require("./Axis-DE7dSn1_.cjs"),Te=require("./AxisTitle-CK9YeovX.cjs"),We=require("./XTicksAndGridLines-CCzXIV8d.cjs"),De=require("./ReferenceLine-CFVBBN__.cjs"),Be=require("./RegressionLine-xKdiJ8sw.cjs"),ze=require("./YTicksAndGridLines-DBDuz6vb.cjs"),_e=require("./index-DNj994Pv.cjs"),Je=require("./pow-B5-jkdHU.cjs"),Pe=require("./linear-BVckp9RD.cjs"),Ke=require("./delaunay-rcy0HhZi.cjs"),Qe=require("./use-in-view-sQJZ_xDO.cjs"),ie=require("./proxy-BHRoeZgd.cjs"),Xe=require("./index-BW8iNx7E.cjs"),Ze=require("./GraphFooter.cjs"),et=require("./GraphHeader.cjs"),tt=require("./ColorLegendWithMouseOver.cjs"),it=require("./EmptyState-d8_8SxeW.cjs"),Ye=require("./index-BW_-wD2k.cjs"),st=require("./ensureCompleteData-DqWQ2Zbi.cjs"),ot=require("./init-DU0ybBc_.cjs");function rt(ge){const{data:s,width:q,height:M,showLabels:se,colors:l,colorDomain:C,radius:R,xAxisTitle:m,yAxisTitle:J,leftMargin:G,rightMargin:ye,topMargin:pe,bottomMargin:oe,tooltip:re,onSeriesMouseOver:X,refXValues:I,refYValues:je,highlightAreaSettings:ve,selectedColor:W,highlightedDataPoints:L,maxRadiusValue:be,maxXValue:B,minXValue:w,maxYValue:Oe,minYValue:E,onSeriesMouseClick:V,rtl:K,annotations:Ce,customHighlightAreaSettings:Re,regressionLine:z,resetSelectionOnDoubleClick:Q,detailsOnClick:k,noOfXTicks:ne,noOfYTicks:le,labelColor:Z,xSuffix:ae,ySuffix:ce,xPrefix:xe,yPrefix:ue,styles:x,classNames:u,animate:n,dimmedOpacity:A,precision:S,customLayers:fe}=ge,me=j.useRef(null),p=Qe.useInView(me,{once:n.once,amount:n.amount}),[$,T]=j.useState(void 0),[D,Y]=j.useState(void 0),[de,P]=j.useState(void 0),[he,v]=j.useState(void 0),d={top:pe,bottom:m?oe+50:oe,left:J?G+30:G,right:ye},_=s.map((e,y)=>({...e,id:`${y}`})),g=q-d.left-d.right,b=M-d.top-d.bottom,O=s.filter(e=>e.radius===void 0||e.radius===null).length!==s.length?Je.sqrt().domain([0,be]).range([.25,R]).nice():void 0,h=_.filter(e=>!c.checkIfNullOrUndefined(e.radius)).length===0?_:Ue.orderBy(_.filter(e=>!c.checkIfNullOrUndefined(e.radius)),"radius","desc"),r=Pe.linear().domain([w,B]).range([0,g]).nice(),a=Pe.linear().domain([E,Oe]).range([b,0]).nice(),ee=r.ticks(ne),te=a.ticks(le),U=Ke.Delaunay.from(h.filter(e=>!c.checkIfNullOrUndefined(e.x)&&!c.checkIfNullOrUndefined(e.y)),e=>r(e.x),e=>a(e.y)).voronoi([0,0,g<0?0:g,b<0?0:b]),we=Le.linearRegression(s.filter(e=>!c.checkIfNullOrUndefined(e.x)&&!c.checkIfNullOrUndefined(e.y)).map(e=>[r(e.x),a(e.y)])),f=Le.linearRegressionLine(we);return i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[i.jsxRuntimeExports.jsx(ie.motion.svg,{width:`${q}px`,height:`${M}px`,viewBox:`0 0 ${q} ${M}`,direction:"ltr",ref:me,children:i.jsxRuntimeExports.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[i.jsxRuntimeExports.jsxs(Xe.AnimatePresence,{children:[i.jsxRuntimeExports.jsx(_e.HighlightAreaForScatterPlot,{areaSettings:ve,width:g,height:b,scaleX:r,scaleY:a,animate:n,isInView:p}),i.jsxRuntimeExports.jsx(Ne.CustomArea,{areaSettings:Re,scaleX:r,scaleY:a,animate:n,isInView:p})]}),i.jsxRuntimeExports.jsxs("g",{children:[i.jsxRuntimeExports.jsx(ze.YTicksAndGridLines,{values:te.filter(e=>e!==0),y:te.filter(e=>e!==0).map(e=>a(e)),x1:0,x2:g+d.right,styles:{gridLines:x?.yAxis?.gridLines,labels:x?.yAxis?.labels},classNames:{gridLines:u?.yAxis?.gridLines,labels:u?.yAxis?.labels},suffix:ce,prefix:ue,labelType:"secondary",showGridLines:!0,labelPos:"side",precision:S}),i.jsxRuntimeExports.jsx($e.Axis,{y1:a(E<0?0:E),y2:a(E<0?0:E),x1:0,x2:g+d.right,label:Ve.numberFormattingFunction(E<0?0:E,"NA",S,ue,ce),labelPos:{x:0,y:a(E<0?0:E),dy:"0.33em",dx:-4},classNames:{axis:u?.xAxis?.axis,label:u?.yAxis?.labels},styles:{axis:x?.xAxis?.axis,label:{textAnchor:"end",...x?.yAxis?.labels||{}}}}),i.jsxRuntimeExports.jsx(Te.AxisTitle,{x:0-G-15,y:b/2,style:x?.yAxis?.title,className:u?.yAxis?.title,text:J,rotate90:!0})]}),i.jsxRuntimeExports.jsxs("g",{children:[i.jsxRuntimeExports.jsx(We.XTicksAndGridLines,{values:ee.filter(e=>e!==0),x:ee.filter(e=>e!==0).map(e=>r(e)),y1:0,y2:b,styles:{gridLines:x?.xAxis?.gridLines,labels:x?.xAxis?.labels},classNames:{gridLines:u?.xAxis?.gridLines,labels:u?.xAxis?.labels},suffix:ae,prefix:xe,labelType:"primary",showGridLines:!0,precision:S}),i.jsxRuntimeExports.jsx($e.Axis,{x1:r(w<0?0:w),x2:r(w<0?0:w),y1:0,y2:b,label:Ve.numberFormattingFunction(w<0?0:w,"NA",S,xe,ae),labelPos:{x:r(w<0?0:w),y:b,dy:"1em",dx:0},classNames:{axis:u?.xAxis?.axis,label:u?.yAxis?.labels},styles:{axis:x?.xAxis?.axis,label:{textAnchor:"middle",...x?.yAxis?.labels||{}}}}),i.jsxRuntimeExports.jsx(Te.AxisTitle,{x:g/2,y:b+30,style:x?.xAxis?.title,className:u?.xAxis?.title,text:m})]}),fe.filter(e=>e.position==="before").map(e=>e.layer),i.jsxRuntimeExports.jsxs(Xe.AnimatePresence,{children:[h.filter(e=>!c.checkIfNullOrUndefined(e.x)&&!c.checkIfNullOrUndefined(e.y)).map((e,y)=>i.jsxRuntimeExports.jsx("path",{d:U.renderCell(h.findIndex(o=>o.id===e.id)),opacity:0,onMouseEnter:o=>{T(e),v(o.clientY),P(o.clientX),X?.(e)},onMouseMove:o=>{T(e),v(o.clientY),P(o.clientX)},onMouseLeave:()=>{T(void 0),P(void 0),v(void 0),X?.(void 0)},onClick:()=>{(V||k)&&(Ie.isEqual(D,e)&&Q?(Y(void 0),V?.(void 0)):(Y(e),V?.(e)))}},`${e.label||y}`)),h.filter(e=>!c.checkIfNullOrUndefined(e.x)&&!c.checkIfNullOrUndefined(e.y)).map((e,y)=>i.jsxRuntimeExports.jsxs(ie.motion.g,{variants:{initial:{x:r(e.x),y:a(e.y),opacity:W?e.color&&l[C.indexOf(`${e.color}`)]===W?1:A:$?$.id===e.id?1:A:L.length!==0?L.indexOf(e.label||"")!==-1?1:A:1},whileInView:{x:r(e.x),y:a(e.y),opacity:W?e.color&&l[C.indexOf(`${e.color}`)]===W?1:A:$?$.id===e.id?1:A:L.length!==0?L.indexOf(e.label||"")!==-1?1:A:1,transition:{duration:n.duration}}},initial:"initial",animate:p?"whileInView":"initial",exit:{opacity:0,transition:{duration:n.duration}},onMouseEnter:o=>{T(e),v(o.clientY),P(o.clientX),X?.(e)},onMouseMove:o=>{T(e),v(o.clientY),P(o.clientX)},onMouseLeave:()=>{T(void 0),P(void 0),v(void 0),X?.(void 0)},onClick:()=>{(V||k)&&(Ie.isEqual(D,e)&&Q?(Y(void 0),V?.(void 0)):(Y(e),V?.(e)))},children:[i.jsxRuntimeExports.jsx(ie.motion.circle,{cx:0,cy:0,exit:{r:0,transition:{duration:n.duration}},variants:{initial:{r:0,fill:s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray,stroke:s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray},whileInView:{r:O?O(e.radius||0):R,fill:s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray,stroke:s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray,transition:{duration:n.duration}}},initial:"initial",animate:p?"whileInView":"initial",style:{fillOpacity:.6}}),se&&!c.checkIfNullOrUndefined(e.label)?i.jsxRuntimeExports.jsx(ie.motion.text,{style:{...x?.graphObjectValues||{}},className:i.mo("graph-value text-sm",u?.graphObjectValues),y:0,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{x:O?O(e.radius||0):R,opacity:0,fill:Z||(s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray)},whileInView:{x:O?O(e.radius||0):R,opacity:1,fill:Z||(s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray),transition:{duration:n.duration}}},initial:"initial",animate:p?"whileInView":"initial",dy:"0.33em",dx:3,children:e.label}):L.length!==0&&!c.checkIfNullOrUndefined(e.label)&&L.indexOf(e.label)!==-1?i.jsxRuntimeExports.jsx(ie.motion.text,{style:{fill:Z||(s.filter(o=>o.color).length===0?l[0]:e.color?l[C.indexOf(`${e.color}`)]:N.Colors.gray),...x?.graphObjectValues||{}},className:i.mo("graph-value text-sm",u?.graphObjectValues),y:0,exit:{opacity:0,transition:{duration:n.duration}},variants:{initial:{x:O?O(e.radius||0):R,opacity:0},whileInView:{x:O?O(e.radius||0):R,opacity:1,transition:{duration:n.duration}}},initial:"initial",animate:p?"whileInView":"initial",dy:"0.33em",dx:3,children:e.label}):null]},`${e.label||y}`)),I.map((e,y)=>i.jsxRuntimeExports.jsx(De.RefLineX,{text:e.text,color:e.color,x:r(e.value),y1:0,y2:b,textSide:r(e.value)>g*.75||K?"left":"right",classNames:e.classNames,styles:e.styles,animate:n,isInView:p},y)),je.map((e,y)=>i.jsxRuntimeExports.jsx(De.RefLineY,{text:e.text,color:e.color,y:a(e.value),x1:0,x2:g,classNames:e.classNames,styles:e.styles,animate:n,isInView:p},y)),i.jsxRuntimeExports.jsx("g",{children:Ce.map((e,y)=>{const o=Ne.getLineEndPoint({x:e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0),y:e.yCoordinate?a(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8},{x:e.xCoordinate?r(e.xCoordinate):0,y:e.yCoordinate?a(e.yCoordinate):0},c.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius),Ee=e.showConnector?{y1:o.y,x1:o.x,y2:e.yCoordinate?a(e.yCoordinate)+(e.yOffset||0):0+(e.yOffset||0),x2:e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0),cy:e.yCoordinate?a(e.yCoordinate):0,cx:e.xCoordinate?r(e.xCoordinate):0,circleRadius:c.checkIfNullOrUndefined(e.connectorRadius)?3.5:e.connectorRadius,strokeWidth:e.showConnector===!0?2:Math.min(e.showConnector||0,1)}:void 0,F={y:e.yCoordinate?a(e.yCoordinate)+(e.yOffset||0)-8:0+(e.yOffset||0)-8,x:K?0:e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0),width:K?e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0):g+d.right-(e.xCoordinate?r(e.xCoordinate)+(e.xOffset||0):0+(e.xOffset||0)),maxWidth:e.maxWidth,fontWeight:e.fontWeight,align:e.align};return i.jsxRuntimeExports.jsx(Ne.Annotation,{color:e.color,connectorsSettings:Ee,labelSettings:F,text:e.text,classNames:e.classNames,styles:e.styles,animate:n,isInView:p},y)})}),z?i.jsxRuntimeExports.jsx(Be.RegressionLine,{x1:0,x2:g,y1:f(0),y2:f(g),graphHeight:b,graphWidth:g,className:u?.regLine,style:x?.regLine,color:typeof z=="string"?z:void 0,animate:n,isInView:p}):null]}),fe.filter(e=>e.position==="after").map(e=>e.layer)]})}),$&&re&&de&&he?i.jsxRuntimeExports.jsx(He.Tooltip,{data:$,body:re,xPos:de,yPos:he,backgroundStyle:x?.tooltip,className:u?.tooltip}):null,k&&D!==void 0?i.jsxRuntimeExports.jsx(Fe.X,{open:D!==void 0,onClose:()=>{Y(void 0)},children:i.jsxRuntimeExports.jsx("div",{className:"graph-modal-content m-0",dangerouslySetInnerHTML:typeof k=="string"?{__html:Ge.string2HTML(k,D)}:void 0,children:typeof k=="function"?k(D):null})}):null]})}function nt(ge){const{data:s,graphTitle:q,colors:M,sources:se,graphDescription:l,showLabels:C=!1,height:R,width:m,footNote:J,colorDomain:G,colorLegendTitle:ye,radius:pe=5,xAxisTitle:oe="X Axis",yAxisTitle:re="Y Axis",padding:X,backgroundColor:I=!1,leftMargin:je=0,rightMargin:ve=10,topMargin:W=20,bottomMargin:L=50,tooltip:be,relativeHeight:B,onSeriesMouseOver:w,refXValues:Oe=[],refYValues:E=[],highlightAreaSettings:V=[],showColorScale:K=!0,highlightedDataPoints:Ce=[],graphID:Re,maxRadiusValue:z,maxXValue:Q,minXValue:k,maxYValue:ne,minYValue:le,xSuffix:Z="",ySuffix:ae="",xPrefix:ce="",yPrefix:xe="",onSeriesMouseClick:ue,graphDownload:x=!1,dataDownload:u=!1,language:n="en",showNAColor:A=!0,minHeight:S=0,annotations:fe=[],customHighlightAreaSettings:me=[],theme:p="light",regressionLine:$=!1,ariaLabel:T,resetSelectionOnDoubleClick:D=!0,detailsOnClick:Y,noOfXTicks:de=5,noOfYTicks:P=5,labelColor:he,styles:v,classNames:d,animate:_=!1,dimmedOpacity:g=.3,precision:b=2,customLayers:O=[],timeline:h={enabled:!1,autoplay:!1,showOnlyActiveDate:!0}}=ge,[r,a]=j.useState(0),[ee,te]=j.useState(0),[U,we]=j.useState(h.autoplay),f=Ae.sort(ke.uniqBy(s.filter(t=>t.date!==void 0&&t.date!==null),t=>t.date).map(t=>Me.parse(`${t.date}`,h.dateFormat||"yyyy",new Date).getTime()),(t,H)=>ot.ascending(t,H)),[e,y]=j.useState(h.autoplay?0:f.length-1),[o,Ee]=j.useState(void 0),F=j.useRef(null),Se=j.useRef(null);j.useEffect(()=>{const t=new ResizeObserver(H=>{a(m||H[0].target.clientWidth||620),te(R||H[0].target.clientHeight||480)});return F.current&&(te(F.current.clientHeight||480),a(F.current.clientWidth||620),m||t.observe(F.current)),()=>t.disconnect()},[m,R]),j.useEffect(()=>{const t=setInterval(()=>{y(H=>H<f.length-1?H+1:0)},(h.speed||2)*1e3);return U||clearInterval(t),()=>clearInterval(t)},[f,U,h.speed]);const qe=Ae.getSliderMarks(f,e,h.showOnlyActiveDate,h.dateFormat||"yyyy");return i.jsxRuntimeExports.jsx("div",{className:`${p||"light"} flex ${m?"w-fit grow-0":"w-full grow"}`,dir:n==="he"||n==="ar"?"rtl":void 0,children:i.jsxRuntimeExports.jsx("div",{className:i.mo(`${I?I===!0?"bg-primary-gray-200 dark:bg-primary-gray-650 ":"":"bg-transparent "}ml-auto mr-auto flex flex-col grow h-inherit ${n||"en"}`,m?"w-fit":"w-full",d?.graphContainer),style:{...v?.graphContainer||{},...I&&I!==!0?{backgroundColor:I}:{}},id:Re,ref:Se,"aria-label":T||`${q?`The graph shows ${q}. `:""}This is a scatter plot that shows correlation between two variables.${l?` ${l}`:""}`,children:i.jsxRuntimeExports.jsx("div",{className:"flex grow",style:{padding:I?X||"1rem":X||0},children:i.jsxRuntimeExports.jsxs("div",{className:"flex flex-col w-full gap-4 grow justify-between",children:[q||l||x||u?i.jsxRuntimeExports.jsx(et.GraphHeader,{styles:{title:v?.title,description:v?.description},classNames:{title:d?.title,description:d?.description},graphTitle:q,graphDescription:l,width:m,graphDownload:x?Se.current:void 0,dataDownload:u?s.map(t=>t.data).filter(t=>t!==void 0).length>0?s.map(t=>t.data).filter(t=>t!==void 0):s.filter(t=>t!==void 0):null}):null,h.enabled&&f.length>0&&qe?i.jsxRuntimeExports.jsxs("div",{className:"flex gap-6 items-center",dir:"ltr",children:[i.jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{we(!U)},className:"p-0 border-0 cursor-pointer bg-transparent","aria-label":U?"Click to pause animation":"Click to play animation",children:U?i.jsxRuntimeExports.jsx(Ye.Pause,{}):i.jsxRuntimeExports.jsx(Ye.Play,{})}),i.jsxRuntimeExports.jsx(Ae.xr,{min:f[0],max:f[f.length-1],marks:qe,step:null,defaultValue:f[f.length-1],value:f[e],onChangeComplete:t=>{y(f.indexOf(t))},onChange:t=>{y(f.indexOf(t))},"aria-label":"Time slider. Use arrow keys to adjust selected time period."})]}):null,i.jsxRuntimeExports.jsx("div",{className:"grow flex flex-col justify-center gap-3 w-full",children:s.length===0?i.jsxRuntimeExports.jsx(it.EmptyState,{}):i.jsxRuntimeExports.jsxs(i.jsxRuntimeExports.Fragment,{children:[K&&s.filter(t=>t.color).length!==0?i.jsxRuntimeExports.jsx(tt.ColorLegendWithMouseOver,{width:m,colorLegendTitle:ye,colors:M||N.Colors[p].categoricalColors.colors,colorDomain:G||ke.uniqBy(s.filter(t=>t.color),"color").map(t=>t.color),setSelectedColor:Ee,showNAColor:A}):null,i.jsxRuntimeExports.jsx("div",{className:"flex flex-col grow justify-center w-full leading-0",ref:F,"aria-label":"Graph area",children:(m||r)&&(R||ee)?i.jsxRuntimeExports.jsx(rt,{data:st.ensureCompleteDataForScatterPlot(s,h.dateFormat||"yyyy").filter(t=>h.enabled?t.date===Me.format(new Date(f[e]),h.dateFormat||"yyyy"):t),width:m||r,height:Math.max(S,R||(B?S?(m||r)*B>S?(m||r)*B:S:(m||r)*B:ee)),colorDomain:s.filter(t=>t.color).length===0?[]:G||ke.uniqBy(s.filter(t=>t.color),"color").map(t=>t.color),colors:s.filter(t=>t.color).length===0?M?[M]:[N.Colors.primaryColors["blue-600"]]:M||N.Colors[p].categoricalColors.colors,xAxisTitle:oe,yAxisTitle:re,refXValues:Oe,refYValues:E,showLabels:C,radius:pe,leftMargin:je,rightMargin:ve,topMargin:W,bottomMargin:L,tooltip:be,onSeriesMouseOver:w,highlightAreaSettings:V,highlightedDataPoints:s.filter(t=>t.label).length===0?[]:Ce,selectedColor:o,maxRadiusValue:c.checkIfNullOrUndefined(z)?Math.max(...s.map(t=>t.radius).filter(t=>t!=null)):z,maxXValue:c.checkIfNullOrUndefined(Q)?Math.max(...s.map(t=>t.x).filter(t=>t!=null))>0?Math.max(...s.map(t=>t.x).filter(t=>t!=null)):0:Q,minXValue:c.checkIfNullOrUndefined(k)?Math.min(...s.map(t=>t.x).filter(t=>t!=null))>0?0:Math.min(...s.map(t=>t.x).filter(t=>t!=null)):k,maxYValue:c.checkIfNullOrUndefined(ne)?Math.max(...s.map(t=>t.y).filter(t=>t!=null))>0?Math.max(...s.map(t=>t.y).filter(t=>t!=null)):0:ne,minYValue:c.checkIfNullOrUndefined(le)?Math.min(...s.map(t=>t.y).filter(t=>t!=null))>0?0:Math.min(...s.map(t=>t.y).filter(t=>t!=null)):le,onSeriesMouseClick:ue,rtl:n==="he"||n==="ar",annotations:fe,customHighlightAreaSettings:me,regressionLine:$,resetSelectionOnDoubleClick:D,detailsOnClick:Y,noOfXTicks:de,noOfYTicks:P,labelColor:he,xSuffix:Z,ySuffix:ae,xPrefix:ce,yPrefix:xe,styles:v,classNames:d,animate:_===!0?{duration:.5,once:!0,amount:.5}:_||{duration:0,once:!0,amount:0},dimmedOpacity:g,precision:b,customLayers:O}):null})]})}),se||J?i.jsxRuntimeExports.jsx(Ze.GraphFooter,{styles:{footnote:v?.footnote,source:v?.source},classNames:{footnote:d?.footnote,source:d?.source},sources:se,footNote:J,width:m}):null]})})})})}exports.ScatterPlot=nt;
2
2
  //# sourceMappingURL=ScatterPlot.cjs.map