@fluentui/react-charts 9.1.9 → 9.1.10

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 (306) hide show
  1. package/CHANGELOG.md +21 -2
  2. package/dist/index.d.ts +309 -8
  3. package/lib/AreaChart.js.map +1 -1
  4. package/lib/CartesianChart.js.map +1 -1
  5. package/lib/DeclarativeChart.js.map +1 -1
  6. package/lib/DonutChart.js.map +1 -1
  7. package/lib/FunnelChart.js +1 -0
  8. package/lib/FunnelChart.js.map +1 -0
  9. package/lib/GanttChart.js +1 -0
  10. package/lib/GanttChart.js.map +1 -0
  11. package/lib/GaugeChart.js.map +1 -1
  12. package/lib/GroupedVerticalBarChart.js.map +1 -1
  13. package/lib/HeatMapChart.js.map +1 -1
  14. package/lib/HorizontalBarChart.js.map +1 -1
  15. package/lib/HorizontalBarChartWithAxis.js.map +1 -1
  16. package/lib/Legends.js.map +1 -1
  17. package/lib/LineChart.js.map +1 -1
  18. package/lib/Popover.js.map +1 -1
  19. package/lib/ResponsiveContainer.js.map +1 -1
  20. package/lib/SankeyChart.js.map +1 -1
  21. package/lib/ScatterChart.js.map +1 -1
  22. package/lib/Sparkline.js.map +1 -1
  23. package/lib/VerticalBarChart.js.map +1 -1
  24. package/lib/VerticalStackedBarChart.js.map +1 -1
  25. package/lib/components/AreaChart/AreaChart.js +13 -5
  26. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  27. package/lib/components/AreaChart/AreaChart.types.js.map +1 -1
  28. package/lib/components/AreaChart/index.js.map +1 -1
  29. package/lib/components/CommonComponents/CartesianChart.js +10 -7
  30. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  31. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  32. package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
  33. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -1
  34. package/lib/components/CommonComponents/index.js.map +1 -1
  35. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  36. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  37. package/lib/components/DeclarativeChart/imageExporter.js.map +1 -1
  38. package/lib/components/DeclarativeChart/index.js.map +1 -1
  39. package/lib/components/DonutChart/Arc/Arc.js +5 -5
  40. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  41. package/lib/components/DonutChart/Arc/Arc.types.js.map +1 -1
  42. package/lib/components/DonutChart/Arc/index.js.map +1 -1
  43. package/lib/components/DonutChart/DonutChart.js +7 -1
  44. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  45. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  46. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  47. package/lib/components/DonutChart/Pie/Pie.types.js.map +1 -1
  48. package/lib/components/DonutChart/Pie/index.js.map +1 -1
  49. package/lib/components/DonutChart/index.js.map +1 -1
  50. package/lib/components/FunnelChart/FunnelChart.js +391 -0
  51. package/lib/components/FunnelChart/FunnelChart.js.map +1 -0
  52. package/lib/components/FunnelChart/FunnelChart.types.js +1 -0
  53. package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -0
  54. package/lib/components/FunnelChart/funnelGeometry.js +220 -0
  55. package/lib/components/FunnelChart/funnelGeometry.js.map +1 -0
  56. package/lib/components/FunnelChart/index.js +2 -0
  57. package/lib/components/FunnelChart/index.js.map +1 -0
  58. package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +59 -0
  59. package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -0
  60. package/lib/components/GanttChart/GanttChart.js +530 -0
  61. package/lib/components/GanttChart/GanttChart.js.map +1 -0
  62. package/lib/components/GanttChart/GanttChart.types.js +4 -0
  63. package/lib/components/GanttChart/GanttChart.types.js.map +1 -0
  64. package/lib/components/GanttChart/index.js +2 -0
  65. package/lib/components/GanttChart/index.js.map +1 -0
  66. package/lib/components/GanttChart/useGanttChartStyles.styles.js +25 -0
  67. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -0
  68. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  69. package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
  70. package/lib/components/GaugeChart/index.js.map +1 -1
  71. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +10 -5
  72. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  73. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
  74. package/lib/components/GroupedVerticalBarChart/index.js.map +1 -1
  75. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  76. package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
  77. package/lib/components/HeatMapChart/index.js.map +1 -1
  78. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  79. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js +5 -3
  80. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  81. package/lib/components/HorizontalBarChart/index.js.map +1 -1
  82. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +9 -3
  83. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  84. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
  85. package/lib/components/HorizontalBarChartWithAxis/index.js.map +1 -1
  86. package/lib/components/Legends/Legends.js.map +1 -1
  87. package/lib/components/Legends/Legends.types.js.map +1 -1
  88. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  89. package/lib/components/Legends/index.js.map +1 -1
  90. package/lib/components/Legends/shape.js +3 -3
  91. package/lib/components/Legends/shape.js.map +1 -1
  92. package/lib/components/LineChart/LineChart.js +14 -7
  93. package/lib/components/LineChart/LineChart.js.map +1 -1
  94. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  95. package/lib/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -1
  96. package/lib/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
  97. package/lib/components/LineChart/eventAnnotation/Textbox.js +2 -1
  98. package/lib/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
  99. package/lib/components/LineChart/index.js.map +1 -1
  100. package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
  101. package/lib/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -1
  102. package/lib/components/ResponsiveContainer/index.js.map +1 -1
  103. package/lib/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
  104. package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
  105. package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
  106. package/lib/components/SankeyChart/index.js.map +1 -1
  107. package/lib/components/ScatterChart/ScatterChart.js +8 -2
  108. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  109. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  110. package/lib/components/ScatterChart/index.js.map +1 -1
  111. package/lib/components/Sparkline/Sparkline.js.map +1 -1
  112. package/lib/components/Sparkline/Sparkline.types.js.map +1 -1
  113. package/lib/components/Sparkline/index.js.map +1 -1
  114. package/lib/components/VerticalBarChart/VerticalBarChart.js +10 -4
  115. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  116. package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
  117. package/lib/components/VerticalBarChart/index.js.map +1 -1
  118. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +4 -4
  119. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  120. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  121. package/lib/components/VerticalStackedBarChart/index.js.map +1 -1
  122. package/lib/index.js +2 -0
  123. package/lib/index.js.map +1 -1
  124. package/lib/types/DataPoint.js +3 -1
  125. package/lib/types/DataPoint.js.map +1 -1
  126. package/lib/types/EventAnnotation.js.map +1 -1
  127. package/lib/types/LegendDataItem.js.map +1 -1
  128. package/lib/types/index.js.map +1 -1
  129. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  130. package/lib/utilities/KeyCodes.js.map +1 -1
  131. package/lib/utilities/SVGTooltipText.js.map +1 -1
  132. package/lib/utilities/async-utils.js.map +1 -1
  133. package/lib/utilities/colors.js +12 -0
  134. package/lib/utilities/colors.js.map +1 -1
  135. package/lib/utilities/getWindow.js.map +1 -1
  136. package/lib/utilities/index.js.map +1 -1
  137. package/lib/utilities/overflow-utils.js.map +1 -1
  138. package/lib/utilities/string.js.map +1 -1
  139. package/lib/utilities/test-data.js +236 -0
  140. package/lib/utilities/test-data.js.map +1 -1
  141. package/lib/utilities/utilities.js +90 -22
  142. package/lib/utilities/utilities.js.map +1 -1
  143. package/lib/utilities/vbc-utils.js +2 -2
  144. package/lib/utilities/vbc-utils.js.map +1 -1
  145. package/lib-commonjs/AreaChart.js.map +1 -1
  146. package/lib-commonjs/CartesianChart.js.map +1 -1
  147. package/lib-commonjs/DeclarativeChart.js.map +1 -1
  148. package/lib-commonjs/DonutChart.js.map +1 -1
  149. package/lib-commonjs/FunnelChart.js +6 -0
  150. package/lib-commonjs/FunnelChart.js.map +1 -0
  151. package/lib-commonjs/GanttChart.js +6 -0
  152. package/lib-commonjs/GanttChart.js.map +1 -0
  153. package/lib-commonjs/GaugeChart.js.map +1 -1
  154. package/lib-commonjs/GroupedVerticalBarChart.js.map +1 -1
  155. package/lib-commonjs/HeatMapChart.js.map +1 -1
  156. package/lib-commonjs/HorizontalBarChart.js.map +1 -1
  157. package/lib-commonjs/HorizontalBarChartWithAxis.js.map +1 -1
  158. package/lib-commonjs/Legends.js.map +1 -1
  159. package/lib-commonjs/LineChart.js.map +1 -1
  160. package/lib-commonjs/Popover.js.map +1 -1
  161. package/lib-commonjs/ResponsiveContainer.js.map +1 -1
  162. package/lib-commonjs/SankeyChart.js.map +1 -1
  163. package/lib-commonjs/ScatterChart.js.map +1 -1
  164. package/lib-commonjs/Sparkline.js.map +1 -1
  165. package/lib-commonjs/VerticalBarChart.js.map +1 -1
  166. package/lib-commonjs/VerticalStackedBarChart.js.map +1 -1
  167. package/lib-commonjs/components/AreaChart/AreaChart.js +13 -5
  168. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  169. package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -1
  170. package/lib-commonjs/components/AreaChart/index.js.map +1 -1
  171. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  172. package/lib-commonjs/components/CommonComponents/CartesianChart.js +9 -6
  173. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  174. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  175. package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
  176. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -1
  177. package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
  178. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  179. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  180. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  181. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  182. package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +1 -1
  183. package/lib-commonjs/components/DeclarativeChart/index.js.map +1 -1
  184. package/lib-commonjs/components/DonutChart/Arc/Arc.js +5 -5
  185. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  186. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js.map +1 -1
  187. package/lib-commonjs/components/DonutChart/Arc/index.js.map +1 -1
  188. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  189. package/lib-commonjs/components/DonutChart/DonutChart.js +7 -1
  190. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  191. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  192. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  193. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js.map +1 -1
  194. package/lib-commonjs/components/DonutChart/Pie/index.js.map +1 -1
  195. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
  196. package/lib-commonjs/components/DonutChart/index.js.map +1 -1
  197. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  198. package/lib-commonjs/components/FunnelChart/FunnelChart.js +402 -0
  199. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -0
  200. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js +6 -0
  201. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -0
  202. package/lib-commonjs/components/FunnelChart/funnelGeometry.js +248 -0
  203. package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -0
  204. package/lib-commonjs/components/FunnelChart/index.js +7 -0
  205. package/lib-commonjs/components/FunnelChart/index.js.map +1 -0
  206. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +79 -0
  207. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -0
  208. package/lib-commonjs/components/GanttChart/GanttChart.js +541 -0
  209. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -0
  210. package/lib-commonjs/components/GanttChart/GanttChart.types.js +7 -0
  211. package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -0
  212. package/lib-commonjs/components/GanttChart/index.js +7 -0
  213. package/lib-commonjs/components/GanttChart/index.js.map +1 -0
  214. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +39 -0
  215. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -0
  216. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  217. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
  218. package/lib-commonjs/components/GaugeChart/index.js.map +1 -1
  219. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
  220. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +10 -5
  221. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  222. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -1
  223. package/lib-commonjs/components/GroupedVerticalBarChart/index.js.map +1 -1
  224. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  225. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  226. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
  227. package/lib-commonjs/components/HeatMapChart/index.js.map +1 -1
  228. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  229. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  230. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js +3 -3
  231. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -1
  232. package/lib-commonjs/components/HorizontalBarChart/index.js.map +1 -1
  233. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  234. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +9 -3
  235. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  236. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
  237. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +1 -1
  238. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  239. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  240. package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
  241. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  242. package/lib-commonjs/components/Legends/index.js.map +1 -1
  243. package/lib-commonjs/components/Legends/shape.js +2 -2
  244. package/lib-commonjs/components/Legends/shape.js.map +1 -1
  245. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
  246. package/lib-commonjs/components/LineChart/LineChart.js +14 -7
  247. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  248. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  249. package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -1
  250. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
  251. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js +2 -1
  252. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
  253. package/lib-commonjs/components/LineChart/index.js.map +1 -1
  254. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  255. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
  256. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -1
  257. package/lib-commonjs/components/ResponsiveContainer/index.js.map +1 -1
  258. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.js.map +1 -1
  259. package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
  260. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
  261. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
  262. package/lib-commonjs/components/SankeyChart/index.js.map +1 -1
  263. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  264. package/lib-commonjs/components/ScatterChart/ScatterChart.js +8 -2
  265. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  266. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  267. package/lib-commonjs/components/ScatterChart/index.js.map +1 -1
  268. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  269. package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
  270. package/lib-commonjs/components/Sparkline/Sparkline.types.js.map +1 -1
  271. package/lib-commonjs/components/Sparkline/index.js.map +1 -1
  272. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js.map +1 -1
  273. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +10 -4
  274. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  275. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -1
  276. package/lib-commonjs/components/VerticalBarChart/index.js.map +1 -1
  277. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  278. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +4 -4
  279. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  280. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  281. package/lib-commonjs/components/VerticalStackedBarChart/index.js.map +1 -1
  282. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  283. package/lib-commonjs/index.js +2 -0
  284. package/lib-commonjs/index.js.map +1 -1
  285. package/lib-commonjs/types/DataPoint.js +3 -1
  286. package/lib-commonjs/types/DataPoint.js.map +1 -1
  287. package/lib-commonjs/types/EventAnnotation.js.map +1 -1
  288. package/lib-commonjs/types/LegendDataItem.js.map +1 -1
  289. package/lib-commonjs/types/index.js.map +1 -1
  290. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  291. package/lib-commonjs/utilities/KeyCodes.js.map +1 -1
  292. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  293. package/lib-commonjs/utilities/async-utils.js.map +1 -1
  294. package/lib-commonjs/utilities/colors.js +18 -0
  295. package/lib-commonjs/utilities/colors.js.map +1 -1
  296. package/lib-commonjs/utilities/getWindow.js.map +1 -1
  297. package/lib-commonjs/utilities/index.js.map +1 -1
  298. package/lib-commonjs/utilities/overflow-utils.js.map +1 -1
  299. package/lib-commonjs/utilities/string.js.map +1 -1
  300. package/lib-commonjs/utilities/test-data.js +245 -0
  301. package/lib-commonjs/utilities/test-data.js.map +1 -1
  302. package/lib-commonjs/utilities/utilities.js +86 -17
  303. package/lib-commonjs/utilities/utilities.js.map +1 -1
  304. package/lib-commonjs/utilities/vbc-utils.js +2 -2
  305. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  306. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"sources":["DonutChart.tsx"],"sourcesContent":["/* eslint-disable react/jsx-no-bind */\nimport * as React from 'react';\nimport { Pie } from './Pie/index';\nimport { DonutChartProps } from './DonutChart.types';\nimport { useDonutChartStyles } from './useDonutChartStyles.styles';\nimport { ChartDataPoint } from '../../DonutChart';\nimport { formatToLocaleString } from '@fluentui/chart-utilities';\nimport { getColorFromToken, getNextColor } from '../../utilities/index';\nimport { Legend, Legends } from '../../index';\nimport { useId } from '@fluentui/react-utilities';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { ChartPopover } from '../CommonComponents/ChartPopover';\n\nconst MIN_LEGEND_CONTAINER_HEIGHT = 40;\n\n// Create a DonutChart variant which uses these default styles and this styled subcomponent.\n/**\n * Donutchart component.\n * {@docCategory DonutChart}\n */\nexport const DonutChart: React.FunctionComponent<DonutChartProps> = React.forwardRef<HTMLDivElement, DonutChartProps>(\n (props, forwardedRef) => {\n const _rootElem = React.useRef<HTMLDivElement | null>(null);\n const _uniqText: string = useId('_Pie_');\n /* eslint-disable @typescript-eslint/no-explicit-any */\n let _calloutAnchorPoint: ChartDataPoint | null;\n let _emptyChartId: string | null;\n const legendContainer = React.useRef<HTMLDivElement | null>(null);\n const prevSize = React.useRef<{ width?: number; height?: number }>({});\n\n const [value, setValue] = React.useState<string | undefined>('');\n const [legend, setLegend] = React.useState<string | undefined>('');\n const [_width, setWidth] = React.useState<number | undefined>(props.width || 200);\n const [_height, setHeight] = React.useState<number | undefined>(props.height || 200);\n const [activeLegend, setActiveLegend] = React.useState<string>('');\n const [color, setColor] = React.useState<string | undefined>('');\n const [xCalloutValue, setXCalloutValue] = React.useState<string>('');\n const [yCalloutValue, setYCalloutValue] = React.useState<string>('');\n const [selectedLegend, setSelectedLegend] = React.useState<string>('');\n const [focusedArcId, setFocusedArcId] = React.useState<string>('');\n const [dataPointCalloutProps, setDataPointCalloutProps] = React.useState<ChartDataPoint | undefined>();\n const [clickPosition, setClickPosition] = React.useState({ x: 0, y: 0 });\n const [isPopoverOpen, setPopoverOpen] = React.useState(false);\n\n React.useEffect(() => {\n _fitParentContainer();\n }, []);\n\n React.useEffect(() => {\n if (prevSize.current.height !== props.height || prevSize.current.width !== props.width) {\n _fitParentContainer();\n }\n prevSize.current.height = props.height;\n prevSize.current.width = props.width;\n }, [props.width, props.height]);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n chartContainer: _rootElem.current,\n }),\n [],\n );\n\n function _elevateToMinimums(data: ChartDataPoint[]) {\n let sumOfData = 0;\n const minPercent = 0.01;\n const elevatedData: ChartDataPoint[] = [];\n data.forEach(item => {\n sumOfData += item.data!;\n });\n data.forEach(item => {\n elevatedData.push(\n minPercent * sumOfData > item.data! && item.data! > 0\n ? {\n ...item,\n data: minPercent * sumOfData,\n yAxisCalloutData:\n item.yAxisCalloutData === undefined ? item.data!.toLocaleString() : item.yAxisCalloutData,\n }\n : item,\n );\n });\n return elevatedData;\n }\n function _createLegends(chartData: ChartDataPoint[]): JSX.Element {\n const legendDataItems = chartData.map((point: ChartDataPoint, index: number) => {\n const color: string = point.color!;\n // mapping data to the format Legends component needs\n const legend: Legend = {\n title: point.legend!,\n color,\n action: () => {\n if (selectedLegend === point.legend) {\n setSelectedLegend('');\n } else {\n setSelectedLegend(point.legend!);\n }\n },\n hoverAction: () => {\n _handleChartMouseLeave();\n setActiveLegend(point.legend!);\n },\n onMouseOutAction: () => {\n setActiveLegend('');\n },\n };\n return legend;\n });\n const legends = (\n <Legends\n legends={legendDataItems}\n centerLegends\n overflowText={props.legendsOverflowText}\n {...props.legendProps}\n />\n );\n return legends;\n }\n\n function _focusCallback(data: ChartDataPoint, id: string, element: SVGPathElement): void {\n setPopoverOpen(selectedLegend === '' || selectedLegend === data.legend);\n setValue(data.data!.toString());\n setLegend(data.legend);\n setColor(data.color!);\n setXCalloutValue(data.xAxisCalloutData!);\n setYCalloutValue(data.yAxisCalloutData!);\n setFocusedArcId(id);\n setDataPointCalloutProps(data);\n }\n\n function _hoverCallback(data: ChartDataPoint, e: React.MouseEvent<SVGPathElement>): void {\n if (_calloutAnchorPoint !== data) {\n _calloutAnchorPoint = data;\n setPopoverOpen(selectedLegend === '' || selectedLegend === data.legend);\n setValue(data.data!.toString());\n setLegend(data.legend);\n setColor(data.color!);\n setXCalloutValue(data.xAxisCalloutData!);\n setYCalloutValue(data.yAxisCalloutData!);\n setDataPointCalloutProps(data);\n updatePosition(e.clientX, e.clientY);\n }\n }\n function _onBlur(): void {\n setFocusedArcId('');\n }\n\n function _hoverLeave(): void {\n /**/\n }\n\n function _handleChartMouseLeave() {\n _calloutAnchorPoint = null;\n setPopoverOpen(false);\n }\n\n function _valueInsideDonut(valueInsideDonut: string | number | undefined, data: ChartDataPoint[]) {\n const highlightedLegend = _getHighlightedLegend();\n if (valueInsideDonut !== undefined && (highlightedLegend !== '' || isPopoverOpen)) {\n let legendValue = valueInsideDonut;\n data!.map((point: ChartDataPoint, index: number) => {\n if (point.legend === highlightedLegend || (isPopoverOpen && point.legend === legend)) {\n legendValue = point.yAxisCalloutData ? point.yAxisCalloutData : point.data!;\n }\n return;\n });\n return legendValue;\n } else {\n return valueInsideDonut;\n }\n }\n\n function _toLocaleString(data: string | number | undefined) {\n const localeString = formatToLocaleString(data, props.culture);\n if (!localeString) {\n return data;\n }\n return localeString?.toString();\n }\n\n /**\n * This function returns\n * the selected legend if there is one\n * or the hovered legend if none of the legends is selected.\n * Note: This won't work in case of multiple legends selection.\n */\n function _getHighlightedLegend() {\n return selectedLegend || activeLegend;\n }\n\n function _isChartEmpty(): boolean {\n return !(\n props.data &&\n props.data.chartData &&\n props.data.chartData!.filter((d: ChartDataPoint) => d.data! > 0).length > 0\n );\n }\n\n function _addDefaultColors(donutChartDataPoint?: ChartDataPoint[]): ChartDataPoint[] {\n return donutChartDataPoint\n ? donutChartDataPoint.map((item, index) => {\n let defaultColor: string;\n if (typeof item.color === 'undefined') {\n defaultColor = getNextColor(index, 0);\n } else {\n defaultColor = getColorFromToken(item.color);\n }\n return { ...item, defaultColor };\n })\n : [];\n }\n\n function updatePosition(newX: number, newY: number) {\n const threshold = 1; // Set a threshold for movement\n const { x, y } = clickPosition;\n // Calculate the distance moved\n const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));\n // Update the position only if the distance moved is greater than the threshold\n if (distance > threshold) {\n setClickPosition({ x: newX, y: newY });\n setPopoverOpen(true);\n }\n }\n\n /**\n * When screen resizes, along with screen, chart also auto adjusted.\n * This method used to adjust height and width of the charts.\n */\n function _fitParentContainer(): void {\n //_reqID = requestAnimationFrame(() => {\n let legendContainerHeight;\n if (props.hideLegend) {\n // If there is no legend, need not to allocate some space from total chart space.\n legendContainerHeight = 0;\n } else {\n const legendContainerComputedStyles = legendContainer.current && getComputedStyle(legendContainer.current);\n legendContainerHeight =\n ((legendContainer.current && legendContainer.current.getBoundingClientRect().height) ||\n MIN_LEGEND_CONTAINER_HEIGHT) +\n parseFloat((legendContainerComputedStyles && legendContainerComputedStyles.marginTop) || '0') +\n parseFloat((legendContainerComputedStyles && legendContainerComputedStyles.marginBottom) || '0');\n }\n if (props.parentRef || _rootElem.current) {\n const container = props.parentRef ? props.parentRef : _rootElem.current!;\n const currentContainerWidth = container.getBoundingClientRect().width;\n const currentContainerHeight =\n container.getBoundingClientRect().height > legendContainerHeight\n ? container.getBoundingClientRect().height\n : 200;\n const shouldResize =\n _width !== currentContainerWidth || _height !== currentContainerHeight - legendContainerHeight;\n if (shouldResize) {\n setWidth(currentContainerWidth);\n setHeight(currentContainerHeight - legendContainerHeight);\n }\n }\n //});\n }\n\n const { data, hideLegend = false } = props;\n const points = _addDefaultColors(data?.chartData);\n\n const classes = useDonutChartStyles(props);\n\n const legendBars = _createLegends(points);\n const donutMarginHorizontal = props.hideLabels ? 0 : 80;\n const donutMarginVertical = props.hideLabels ? 0 : 40;\n const outerRadius = Math.min(_width! - donutMarginHorizontal, _height! - donutMarginVertical) / 2;\n const chartData = _elevateToMinimums(points.filter((d: ChartDataPoint) => d.data! >= 0));\n const valueInsideDonut = props.innerRadius !== 0 ? _valueInsideDonut(props.valueInsideDonut!, chartData!) : '';\n const focusAttributes = useFocusableGroup();\n return !_isChartEmpty() ? (\n <div\n className={classes.root}\n ref={(rootElem: HTMLDivElement | null) => (_rootElem.current = rootElem)}\n onMouseLeave={_handleChartMouseLeave}\n >\n <div className={classes.chartWrapper} {...focusAttributes}>\n <svg className={classes.chart} aria-label={data?.chartTitle} width={_width} height={_height}>\n <Pie\n width={_width!}\n height={_height!}\n outerRadius={outerRadius}\n innerRadius={props.innerRadius!}\n data={chartData!}\n onFocusCallback={_focusCallback}\n hoverOnCallback={_hoverCallback}\n hoverLeaveCallback={_hoverLeave}\n uniqText={_uniqText}\n onBlurCallback={_onBlur}\n activeArc={_getHighlightedLegend()}\n focusedArcId={focusedArcId || ''}\n href={props.href!}\n valueInsideDonut={_toLocaleString(valueInsideDonut)}\n showLabelsInPercent={props.showLabelsInPercent}\n hideLabels={props.hideLabels}\n />\n </svg>\n </div>\n <ChartPopover\n xCalloutValue={xCalloutValue}\n yCalloutValue={yCalloutValue}\n culture={props.culture ?? 'en-us'}\n clickPosition={clickPosition}\n isPopoverOpen={!props.hideTooltip && isPopoverOpen}\n legend={legend!}\n YValue={value!}\n color={color}\n isCalloutForStack={false}\n customCallout={{\n customizedCallout: props.onRenderCalloutPerDataPoint\n ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps!)\n : undefined,\n customCalloutProps: props.calloutPropsPerDataPoint\n ? props.calloutPropsPerDataPoint(dataPointCalloutProps!)\n : undefined,\n }}\n isCartesian={false}\n />\n {!hideLegend && (\n <div ref={(e: HTMLDivElement) => (legendContainer.current = e)} className={classes.legendContainer}>\n {legendBars}\n </div>\n )}\n </div>\n ) : (\n <div id={_emptyChartId!} role={'alert'} style={{ opacity: '0' }} aria-label={'Graph has no data to display'} />\n );\n },\n);\n\nDonutChart.displayName = 'DonutChart';\nDonutChart.defaultProps = {\n innerRadius: 0,\n hideLabels: true,\n};\n"],"names":["React","Pie","useDonutChartStyles","formatToLocaleString","getColorFromToken","getNextColor","Legends","useId","useFocusableGroup","ChartPopover","MIN_LEGEND_CONTAINER_HEIGHT","DonutChart","forwardRef","props","forwardedRef","_rootElem","useRef","_uniqText","_calloutAnchorPoint","_emptyChartId","legendContainer","prevSize","value","setValue","useState","legend","setLegend","_width","setWidth","width","_height","setHeight","height","activeLegend","setActiveLegend","color","setColor","xCalloutValue","setXCalloutValue","yCalloutValue","setYCalloutValue","selectedLegend","setSelectedLegend","focusedArcId","setFocusedArcId","dataPointCalloutProps","setDataPointCalloutProps","clickPosition","setClickPosition","x","y","isPopoverOpen","setPopoverOpen","useEffect","_fitParentContainer","current","useImperativeHandle","componentRef","chartContainer","_elevateToMinimums","data","sumOfData","minPercent","elevatedData","forEach","item","push","yAxisCalloutData","undefined","toLocaleString","_createLegends","chartData","legendDataItems","map","point","index","title","action","hoverAction","_handleChartMouseLeave","onMouseOutAction","legends","centerLegends","overflowText","legendsOverflowText","legendProps","_focusCallback","id","element","toString","xAxisCalloutData","_hoverCallback","e","updatePosition","clientX","clientY","_onBlur","_hoverLeave","_valueInsideDonut","valueInsideDonut","highlightedLegend","_getHighlightedLegend","legendValue","_toLocaleString","localeString","culture","_isChartEmpty","filter","d","length","_addDefaultColors","donutChartDataPoint","defaultColor","newX","newY","threshold","distance","Math","sqrt","pow","legendContainerHeight","hideLegend","legendContainerComputedStyles","getComputedStyle","getBoundingClientRect","parseFloat","marginTop","marginBottom","parentRef","container","currentContainerWidth","currentContainerHeight","shouldResize","points","classes","legendBars","donutMarginHorizontal","hideLabels","donutMarginVertical","outerRadius","min","innerRadius","focusAttributes","div","className","root","ref","rootElem","onMouseLeave","chartWrapper","svg","chart","aria-label","chartTitle","onFocusCallback","hoverOnCallback","hoverLeaveCallback","uniqText","onBlurCallback","activeArc","href","showLabelsInPercent","hideTooltip","YValue","isCalloutForStack","customCallout","customizedCallout","onRenderCalloutPerDataPoint","customCalloutProps","calloutPropsPerDataPoint","isCartesian","role","style","opacity","displayName","defaultProps"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GACpC,YAAYA,WAAW,QAAQ;AAC/B,SAASC,GAAG,QAAQ,cAAc;AAElC,SAASC,mBAAmB,QAAQ,+BAA+B;AAEnE,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,wBAAwB;AACxE,SAAiBC,OAAO,QAAQ,cAAc;AAC9C,SAASC,KAAK,QAAQ,4BAA4B;AAClD,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,YAAY,QAAQ,mCAAmC;AAEhE,MAAMC,8BAA8B;AAEpC,4FAA4F;AAC5F;;;CAGC,GACD,OAAO,MAAMC,2BAAuDX,MAAMY,UAAU,CAClF,CAACC,OAAOC;IACN,MAAM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;QACfI,eAAe,CAACtC,MAAMqJ,WAAW,IAAI/G;QACrC1B,QAAQA;QACR0I,QAAQ7I;QACRa,OAAOA;QACPiI,mBAAmB;QACnBC,eAAe;YACbC,mBAAmBzJ,MAAM0J,2BAA2B,GAChD1J,MAAM0J,2BAA2B,CAAC1H,yBAClCuB;YACJoG,oBAAoB3J,MAAM4J,wBAAwB,GAC9C5J,MAAM4J,wBAAwB,CAAC5H,yBAC/BuB;QACN;QACAsG,aAAa;QAEd,CAACjD,4BACA,oBAACsB;QAAIG,KAAK,CAACtD,IAAuBxE,gBAAgBmC,OAAO,GAAGqC;QAAIoD,WAAWV,QAAQlH,eAAe;OAC/FmH,6BAKP,oBAACQ;QAAIxD,IAAIpE;QAAgBwJ,MAAM;QAASC,OAAO;YAAEC,SAAS;QAAI;QAAGrB,cAAY;;AAEjF,GACA;AAEF7I,WAAWmK,WAAW,GAAG;AACzBnK,WAAWoK,YAAY,GAAG;IACxBlC,aAAa;IACbJ,YAAY;AACd"}
1
+ {"version":3,"sources":["DonutChart.tsx"],"sourcesContent":["/* eslint-disable react/jsx-no-bind */\nimport * as React from 'react';\nimport { Pie } from './Pie/index';\nimport { DonutChartProps } from './DonutChart.types';\nimport { useDonutChartStyles } from './useDonutChartStyles.styles';\nimport { ChartDataPoint } from '../../DonutChart';\nimport { formatToLocaleString } from '@fluentui/chart-utilities';\nimport { getColorFromToken, getNextColor } from '../../utilities/index';\nimport { Legend, Legends } from '../../index';\nimport { useId } from '@fluentui/react-utilities';\nimport { useFocusableGroup } from '@fluentui/react-tabster';\nimport { ChartPopover } from '../CommonComponents/ChartPopover';\n\nconst MIN_LEGEND_CONTAINER_HEIGHT = 40;\n\n// Create a DonutChart variant which uses these default styles and this styled subcomponent.\n/**\n * Donutchart component.\n * {@docCategory DonutChart}\n */\nexport const DonutChart: React.FunctionComponent<DonutChartProps> = React.forwardRef<HTMLDivElement, DonutChartProps>(\n (props, forwardedRef) => {\n const _rootElem = React.useRef<HTMLDivElement | null>(null);\n const _uniqText: string = useId('_Pie_');\n /* eslint-disable @typescript-eslint/no-explicit-any */\n let _calloutAnchorPoint: ChartDataPoint | null;\n let _emptyChartId: string | null;\n const legendContainer = React.useRef<HTMLDivElement | null>(null);\n const prevSize = React.useRef<{ width?: number; height?: number }>({});\n\n const [value, setValue] = React.useState<string | undefined>('');\n const [legend, setLegend] = React.useState<string | undefined>('');\n const [_width, setWidth] = React.useState<number | undefined>(props.width || 200);\n const [_height, setHeight] = React.useState<number | undefined>(props.height || 200);\n const [activeLegend, setActiveLegend] = React.useState<string>('');\n const [color, setColor] = React.useState<string | undefined>('');\n const [xCalloutValue, setXCalloutValue] = React.useState<string>('');\n const [yCalloutValue, setYCalloutValue] = React.useState<string>('');\n const [selectedLegend, setSelectedLegend] = React.useState<string>('');\n const [focusedArcId, setFocusedArcId] = React.useState<string>('');\n const [dataPointCalloutProps, setDataPointCalloutProps] = React.useState<ChartDataPoint | undefined>();\n const [clickPosition, setClickPosition] = React.useState({ x: 0, y: 0 });\n const [isPopoverOpen, setPopoverOpen] = React.useState(false);\n\n React.useEffect(() => {\n _fitParentContainer();\n }, []);\n\n React.useEffect(() => {\n if (prevSize.current.height !== props.height || prevSize.current.width !== props.width) {\n _fitParentContainer();\n }\n prevSize.current.height = props.height;\n prevSize.current.width = props.width;\n }, [props.width, props.height]);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n chartContainer: _rootElem.current,\n }),\n [],\n );\n\n function _elevateToMinimums(data: ChartDataPoint[]) {\n let sumOfData = 0;\n const minPercent = 0.01;\n const elevatedData: ChartDataPoint[] = [];\n data.forEach(item => {\n sumOfData += item.data!;\n });\n data.forEach(item => {\n elevatedData.push(\n minPercent * sumOfData > item.data! && item.data! > 0\n ? {\n ...item,\n data: minPercent * sumOfData,\n yAxisCalloutData:\n item.yAxisCalloutData === undefined ? item.data!.toLocaleString() : item.yAxisCalloutData,\n }\n : item,\n );\n });\n return elevatedData;\n }\n function _createLegends(chartData: ChartDataPoint[]): JSX.Element {\n const legendDataItems = chartData.map((point: ChartDataPoint, index: number) => {\n const color: string = point.color!;\n // mapping data to the format Legends component needs\n const legend: Legend = {\n title: point.legend!,\n color,\n action: () => {\n if (selectedLegend === point.legend) {\n setSelectedLegend('');\n } else {\n setSelectedLegend(point.legend!);\n }\n },\n hoverAction: () => {\n _handleChartMouseLeave();\n setActiveLegend(point.legend!);\n },\n onMouseOutAction: () => {\n setActiveLegend('');\n },\n };\n return legend;\n });\n const legends = (\n <Legends\n legends={legendDataItems}\n centerLegends\n overflowText={props.legendsOverflowText}\n {...props.legendProps}\n />\n );\n return legends;\n }\n\n function _focusCallback(data: ChartDataPoint, id: string, e: React.FocusEvent<SVGPathElement>): void {\n let cx = 0;\n let cy = 0;\n\n const targetRect = (e.target as SVGPathElement).getBoundingClientRect();\n cx = targetRect.left + targetRect.width / 2;\n cy = targetRect.top + targetRect.height / 2;\n updatePosition(cx, cy);\n setPopoverOpen(selectedLegend === '' || selectedLegend === data.legend);\n setValue(data.data!.toString());\n setLegend(data.legend);\n setColor(data.color!);\n setXCalloutValue(data.xAxisCalloutData!);\n setYCalloutValue(data.yAxisCalloutData!);\n setFocusedArcId(id);\n setDataPointCalloutProps(data);\n }\n\n function _hoverCallback(data: ChartDataPoint, e: React.MouseEvent<SVGPathElement>): void {\n if (_calloutAnchorPoint !== data) {\n _calloutAnchorPoint = data;\n setPopoverOpen(selectedLegend === '' || selectedLegend === data.legend);\n setValue(data.data!.toString());\n setLegend(data.legend);\n setColor(data.color!);\n setXCalloutValue(data.xAxisCalloutData!);\n setYCalloutValue(data.yAxisCalloutData!);\n setDataPointCalloutProps(data);\n updatePosition(e.clientX, e.clientY);\n }\n }\n function _onBlur(): void {\n setFocusedArcId('');\n }\n\n function _hoverLeave(): void {\n /**/\n }\n\n function _handleChartMouseLeave() {\n _calloutAnchorPoint = null;\n setPopoverOpen(false);\n }\n\n function _valueInsideDonut(valueInsideDonut: string | number | undefined, data: ChartDataPoint[]) {\n const highlightedLegend = _getHighlightedLegend();\n if (valueInsideDonut !== undefined && (highlightedLegend !== '' || isPopoverOpen)) {\n let legendValue = valueInsideDonut;\n data!.map((point: ChartDataPoint, index: number) => {\n if (point.legend === highlightedLegend || (isPopoverOpen && point.legend === legend)) {\n legendValue = point.yAxisCalloutData ? point.yAxisCalloutData : point.data!;\n }\n return;\n });\n return legendValue;\n } else {\n return valueInsideDonut;\n }\n }\n\n function _toLocaleString(data: string | number | undefined) {\n const localeString = formatToLocaleString(data, props.culture);\n if (!localeString) {\n return data;\n }\n return localeString?.toString();\n }\n\n /**\n * This function returns\n * the selected legend if there is one\n * or the hovered legend if none of the legends is selected.\n * Note: This won't work in case of multiple legends selection.\n */\n function _getHighlightedLegend() {\n return selectedLegend || activeLegend;\n }\n\n function _isChartEmpty(): boolean {\n return !(\n props.data &&\n props.data.chartData &&\n props.data.chartData!.filter((d: ChartDataPoint) => d.data! > 0).length > 0\n );\n }\n\n function _addDefaultColors(donutChartDataPoint?: ChartDataPoint[]): ChartDataPoint[] {\n return donutChartDataPoint\n ? donutChartDataPoint.map((item, index) => {\n let defaultColor: string;\n if (typeof item.color === 'undefined') {\n defaultColor = getNextColor(index, 0);\n } else {\n defaultColor = getColorFromToken(item.color);\n }\n return { ...item, defaultColor };\n })\n : [];\n }\n\n function updatePosition(newX: number, newY: number) {\n const threshold = 1; // Set a threshold for movement\n const { x, y } = clickPosition;\n // Calculate the distance moved\n const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));\n // Update the position only if the distance moved is greater than the threshold\n if (distance > threshold) {\n setClickPosition({ x: newX, y: newY });\n setPopoverOpen(true);\n }\n }\n\n /**\n * When screen resizes, along with screen, chart also auto adjusted.\n * This method used to adjust height and width of the charts.\n */\n function _fitParentContainer(): void {\n //_reqID = requestAnimationFrame(() => {\n let legendContainerHeight;\n if (props.hideLegend) {\n // If there is no legend, need not to allocate some space from total chart space.\n legendContainerHeight = 0;\n } else {\n const legendContainerComputedStyles = legendContainer.current && getComputedStyle(legendContainer.current);\n legendContainerHeight =\n ((legendContainer.current && legendContainer.current.getBoundingClientRect().height) ||\n MIN_LEGEND_CONTAINER_HEIGHT) +\n parseFloat((legendContainerComputedStyles && legendContainerComputedStyles.marginTop) || '0') +\n parseFloat((legendContainerComputedStyles && legendContainerComputedStyles.marginBottom) || '0');\n }\n if (props.parentRef || _rootElem.current) {\n const container = props.parentRef ? props.parentRef : _rootElem.current!;\n const currentContainerWidth = container.getBoundingClientRect().width;\n const currentContainerHeight =\n container.getBoundingClientRect().height > legendContainerHeight\n ? container.getBoundingClientRect().height\n : 200;\n const shouldResize =\n _width !== currentContainerWidth || _height !== currentContainerHeight - legendContainerHeight;\n if (shouldResize) {\n setWidth(currentContainerWidth);\n setHeight(currentContainerHeight - legendContainerHeight);\n }\n }\n //});\n }\n\n const { data, hideLegend = false } = props;\n const points = _addDefaultColors(data?.chartData);\n\n const classes = useDonutChartStyles(props);\n\n const legendBars = _createLegends(points);\n const donutMarginHorizontal = props.hideLabels ? 0 : 80;\n const donutMarginVertical = props.hideLabels ? 0 : 40;\n const outerRadius = Math.min(_width! - donutMarginHorizontal, _height! - donutMarginVertical) / 2;\n const chartData = _elevateToMinimums(points.filter((d: ChartDataPoint) => d.data! >= 0));\n const valueInsideDonut = props.innerRadius !== 0 ? _valueInsideDonut(props.valueInsideDonut!, chartData!) : '';\n const focusAttributes = useFocusableGroup();\n return !_isChartEmpty() ? (\n <div\n className={classes.root}\n ref={(rootElem: HTMLDivElement | null) => (_rootElem.current = rootElem)}\n onMouseLeave={_handleChartMouseLeave}\n >\n <div className={classes.chartWrapper} {...focusAttributes}>\n <svg className={classes.chart} aria-label={data?.chartTitle} width={_width} height={_height}>\n <Pie\n width={_width!}\n height={_height!}\n outerRadius={outerRadius}\n innerRadius={props.innerRadius!}\n data={chartData!}\n onFocusCallback={_focusCallback}\n hoverOnCallback={_hoverCallback}\n hoverLeaveCallback={_hoverLeave}\n uniqText={_uniqText}\n onBlurCallback={_onBlur}\n activeArc={_getHighlightedLegend()}\n focusedArcId={focusedArcId || ''}\n href={props.href!}\n valueInsideDonut={_toLocaleString(valueInsideDonut)}\n showLabelsInPercent={props.showLabelsInPercent}\n hideLabels={props.hideLabels}\n />\n </svg>\n </div>\n <ChartPopover\n xCalloutValue={xCalloutValue}\n yCalloutValue={yCalloutValue}\n culture={props.culture ?? 'en-us'}\n clickPosition={clickPosition}\n isPopoverOpen={!props.hideTooltip && isPopoverOpen}\n legend={legend!}\n YValue={value!}\n color={color}\n isCalloutForStack={false}\n customCallout={{\n customizedCallout: props.onRenderCalloutPerDataPoint\n ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps!)\n : undefined,\n customCalloutProps: props.calloutPropsPerDataPoint\n ? props.calloutPropsPerDataPoint(dataPointCalloutProps!)\n : undefined,\n }}\n isCartesian={false}\n />\n {!hideLegend && (\n <div ref={(e: HTMLDivElement) => (legendContainer.current = e)} className={classes.legendContainer}>\n {legendBars}\n </div>\n )}\n </div>\n ) : (\n <div id={_emptyChartId!} role={'alert'} style={{ opacity: '0' }} aria-label={'Graph has no data to display'} />\n );\n },\n);\n\nDonutChart.displayName = 'DonutChart';\nDonutChart.defaultProps = {\n innerRadius: 0,\n hideLabels: true,\n};\n"],"names":["React","Pie","useDonutChartStyles","formatToLocaleString","getColorFromToken","getNextColor","Legends","useId","useFocusableGroup","ChartPopover","MIN_LEGEND_CONTAINER_HEIGHT","DonutChart","forwardRef","props","forwardedRef","_rootElem","useRef","_uniqText","_calloutAnchorPoint","_emptyChartId","legendContainer","prevSize","value","setValue","useState","legend","setLegend","_width","setWidth","width","_height","setHeight","height","activeLegend","setActiveLegend","color","setColor","xCalloutValue","setXCalloutValue","yCalloutValue","setYCalloutValue","selectedLegend","setSelectedLegend","focusedArcId","setFocusedArcId","dataPointCalloutProps","setDataPointCalloutProps","clickPosition","setClickPosition","x","y","isPopoverOpen","setPopoverOpen","useEffect","_fitParentContainer","current","useImperativeHandle","componentRef","chartContainer","_elevateToMinimums","data","sumOfData","minPercent","elevatedData","forEach","item","push","yAxisCalloutData","undefined","toLocaleString","_createLegends","chartData","legendDataItems","map","point","index","title","action","hoverAction","_handleChartMouseLeave","onMouseOutAction","legends","centerLegends","overflowText","legendsOverflowText","legendProps","_focusCallback","id","e","cx","cy","targetRect","target","getBoundingClientRect","left","top","updatePosition","toString","xAxisCalloutData","_hoverCallback","clientX","clientY","_onBlur","_hoverLeave","_valueInsideDonut","valueInsideDonut","highlightedLegend","_getHighlightedLegend","legendValue","_toLocaleString","localeString","culture","_isChartEmpty","filter","d","length","_addDefaultColors","donutChartDataPoint","defaultColor","newX","newY","threshold","distance","Math","sqrt","pow","legendContainerHeight","hideLegend","legendContainerComputedStyles","getComputedStyle","parseFloat","marginTop","marginBottom","parentRef","container","currentContainerWidth","currentContainerHeight","shouldResize","points","classes","legendBars","donutMarginHorizontal","hideLabels","donutMarginVertical","outerRadius","min","innerRadius","focusAttributes","div","className","root","ref","rootElem","onMouseLeave","chartWrapper","svg","chart","aria-label","chartTitle","onFocusCallback","hoverOnCallback","hoverLeaveCallback","uniqText","onBlurCallback","activeArc","href","showLabelsInPercent","hideTooltip","YValue","isCalloutForStack","customCallout","customizedCallout","onRenderCalloutPerDataPoint","customCalloutProps","calloutPropsPerDataPoint","isCartesian","role","style","opacity","displayName","defaultProps"],"mappings":"AAAA,oCAAoC,GACpC,YAAYA,WAAW,QAAQ;AAC/B,SAASC,GAAG,QAAQ,cAAc;AAElC,SAASC,mBAAmB,QAAQ,+BAA+B;AAEnE,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,wBAAwB;AACxE,SAAiBC,OAAO,QAAQ,cAAc;AAC9C,SAASC,KAAK,QAAQ,4BAA4B;AAClD,SAASC,iBAAiB,QAAQ,0BAA0B;AAC5D,SAASC,YAAY,QAAQ,mCAAmC;AAEhE,MAAMC,8BAA8B;AAEpC,4FAA4F;AAC5F;;;CAGC,GACD,OAAO,MAAM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AWzD;QACXhE,cAAcA,gBAAgB;QAC9B0H,MAAMxJ,MAAMwJ,IAAI;QAChB5D,kBAAkBI,gBAAgBJ;QAClC6D,qBAAqBzJ,MAAMyJ,mBAAmB;QAC9CxB,YAAYjI,MAAMiI,UAAU;wBAIlC,oBAACrI;QACC4B,eAAeA;QACfE,eAAeA;QACfwE,SAASlG,CAAAA,iBAAAA,MAAMkG,OAAO,cAAblG,4BAAAA,iBAAiB;QAC1BkC,eAAeA;QACfI,eAAe,CAACtC,MAAM0J,WAAW,IAAIpH;QACrC1B,QAAQA;QACR+I,QAAQlJ;QACRa,OAAOA;QACPsI,mBAAmB;QACnBC,eAAe;YACbC,mBAAmB9J,MAAM+J,2BAA2B,GAChD/J,MAAM+J,2BAA2B,CAAC/H,yBAClCuB;YACJyG,oBAAoBhK,MAAMiK,wBAAwB,GAC9CjK,MAAMiK,wBAAwB,CAACjI,yBAC/BuB;QACN;QACA2G,aAAa;QAEd,CAAChD,4BACA,oBAACqB;QAAIG,KAAK,CAAC/D,IAAuBpE,gBAAgBmC,OAAO,GAAGiC;QAAI6D,WAAWV,QAAQvH,eAAe;OAC/FwH,6BAKP,oBAACQ;QAAI7D,IAAIpE;QAAgB6J,MAAM;QAASC,OAAO;YAAEC,SAAS;QAAI;QAAGrB,cAAY;;AAEjF,GACA;AAEFlJ,WAAWwK,WAAW,GAAG;AACzBxK,WAAWyK,YAAY,GAAG;IACxBlC,aAAa;IACbJ,YAAY;AACd"}
@@ -1 +1 @@
1
- {"version":3,"sources":["DonutChart.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { CartesianChartStyleProps } from '../CommonComponents/index';\nimport { ChartProps, ChartDataPoint, Chart } from './index';\nimport { ChartPopoverProps } from '../CommonComponents/ChartPopover.types';\nimport { LegendsProps } from '../Legends/index';\n\n/**\n * Donut Chart properties.\n * {@docCategory DonutChart}\n */\nexport interface DonutChartProps {\n /**\n * Data to render in the chart.\n */\n data?: ChartProps;\n\n /**\n * inner radius for donut size\n */\n innerRadius?: number;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: DonutChartStyles;\n\n /**\n * props for inside donut value\n */\n valueInsideDonut?: string | number;\n\n /**\n * Define a custom callout renderer for a data point\n */\n onRenderCalloutPerDataPoint?: (dataPointCalloutProps: ChartDataPoint) => JSX.Element | undefined;\n\n /**\n * Define a custom callout props override\n */\n calloutPropsPerDataPoint?: (dataPointCalloutProps: ChartDataPoint) => ChartPopoverProps;\n\n /**\n * props for the callout in the chart\n */\n calloutProps?: ChartPopoverProps;\n\n /**\n * The prop used to define the culture to localized the numbers\n */\n culture?: string;\n\n /**\n * Prop to show the arc labels in percentage format\n * @default false\n */\n showLabelsInPercent?: boolean;\n\n /**\n * Prop to hide the arc labels\n * @default true\n */\n hideLabels?: boolean;\n\n /**\n * Below height used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n height?: number;\n\n /**\n * Below width used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n width?: number;\n\n /**\n * this prop takes its parent as a HTML element to define the width and height of the chart\n */\n parentRef?: HTMLElement | null;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n legendsOverflowText?: any;\n\n /*\n * props for the legends in the chart\n */\n legendProps?: Partial<LegendsProps>;\n\n /** decides wether to show/hide legends\n * @defaultvalue false\n */\n hideLegend?: boolean;\n\n /**\n * Url that the data-viz needs to redirect to upon clicking on it\n */\n href?: string;\n\n /**\n * Do not show tooltips in chart\n * @default false\n */\n hideTooltip?: boolean;\n\n /**\n * Optional callback to access the Chart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<Chart>;\n}\n\n/**\n * Donut Chart style properties\n * {@docCategory DonutChart}\n */\nexport interface DonutChartStyleProps extends CartesianChartStyleProps {}\n\n/**\n * Donut Chart styles\n * {@docCategory DonutChart}\n */\nexport interface DonutChartStyles {\n /**\n * Style for the root element.\n */\n root?: string;\n\n /**\n * Style for the chart.\n */\n chart?: string;\n /**\n * Style for the legend container.\n */\n legendContainer: string;\n\n /**\n * Styles for the chart wrapper div\n */\n chartWrapper?: string;\n}\n"],"names":["React"],"rangeMappings":"","mappings":"AAAA,YAAYA,WAAW,QAAQ"}
1
+ {"version":3,"sources":["DonutChart.types.ts"],"sourcesContent":["import * as React from 'react';\nimport { CartesianChartStyleProps } from '../CommonComponents/index';\nimport { ChartProps, ChartDataPoint, Chart } from './index';\nimport { ChartPopoverProps } from '../CommonComponents/ChartPopover.types';\nimport { LegendsProps } from '../Legends/index';\n\n/**\n * Donut Chart properties.\n * {@docCategory DonutChart}\n */\nexport interface DonutChartProps {\n /**\n * Data to render in the chart.\n */\n data?: ChartProps;\n\n /**\n * inner radius for donut size\n */\n innerRadius?: number;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: DonutChartStyles;\n\n /**\n * props for inside donut value\n */\n valueInsideDonut?: string | number;\n\n /**\n * Define a custom callout renderer for a data point\n */\n onRenderCalloutPerDataPoint?: (dataPointCalloutProps: ChartDataPoint) => JSX.Element | undefined;\n\n /**\n * Define a custom callout props override\n */\n calloutPropsPerDataPoint?: (dataPointCalloutProps: ChartDataPoint) => ChartPopoverProps;\n\n /**\n * props for the callout in the chart\n */\n calloutProps?: ChartPopoverProps;\n\n /**\n * The prop used to define the culture to localized the numbers\n */\n culture?: string;\n\n /**\n * Prop to show the arc labels in percentage format\n * @default false\n */\n showLabelsInPercent?: boolean;\n\n /**\n * Prop to hide the arc labels\n * @default true\n */\n hideLabels?: boolean;\n\n /**\n * Below height used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n height?: number;\n\n /**\n * Below width used for resizing of the chart\n * Wrap chart in your container and send the updated height and width to these props.\n * These values decide wheather chart re render or not. Please check examples for reference\n */\n width?: number;\n\n /**\n * this prop takes its parent as a HTML element to define the width and height of the chart\n */\n parentRef?: HTMLElement | null;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n legendsOverflowText?: any;\n\n /*\n * props for the legends in the chart\n */\n legendProps?: Partial<LegendsProps>;\n\n /** decides wether to show/hide legends\n * @defaultvalue false\n */\n hideLegend?: boolean;\n\n /**\n * Url that the data-viz needs to redirect to upon clicking on it\n */\n href?: string;\n\n /**\n * Do not show tooltips in chart\n * @default false\n */\n hideTooltip?: boolean;\n\n /**\n * Optional callback to access the Chart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<Chart>;\n}\n\n/**\n * Donut Chart style properties\n * {@docCategory DonutChart}\n */\nexport interface DonutChartStyleProps extends CartesianChartStyleProps {}\n\n/**\n * Donut Chart styles\n * {@docCategory DonutChart}\n */\nexport interface DonutChartStyles {\n /**\n * Style for the root element.\n */\n root?: string;\n\n /**\n * Style for the chart.\n */\n chart?: string;\n /**\n * Style for the legend container.\n */\n legendContainer: string;\n\n /**\n * Styles for the chart wrapper div\n */\n chartWrapper?: string;\n}\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"sources":["Pie.tsx"],"sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\n/* eslint-disable react/jsx-no-bind */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport { pie as d3Pie } from 'd3-shape';\nimport { PieProps } from './index';\nimport { Arc } from '../Arc/index';\nimport { ChartDataPoint } from '../index';\nimport { usePieStyles } from './usePieStyles.styles';\nimport { wrapTextInsideDonut } from '../../../utilities/index';\nconst TEXT_PADDING: number = 5;\n\n// Create a Pie within Donut Chart variant which uses these default styles and this styled subcomponent.\n/**\n * Pie component within Donut Chart.\n * {@docCategory PieDonutChart}\n */\nexport const Pie: React.FunctionComponent<PieProps> = React.forwardRef<HTMLDivElement, PieProps>(\n (props, forwardedRef) => {\n React.useEffect(() => {\n wrapTextInsideDonut(classes.insideDonutString, props.innerRadius! * 2 - TEXT_PADDING);\n }, []);\n\n let _totalValue: number;\n const classes = usePieStyles(props);\n const pieForFocusRing = d3Pie()\n .sort(null)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .value((d: any) => d.data)\n .padAngle(0);\n\n function _focusCallback(data: ChartDataPoint, id: string, e: SVGPathElement): void {\n props.onFocusCallback!(data, id, e);\n }\n\n function _hoverCallback(data: ChartDataPoint, e: React.MouseEvent<SVGPathElement>): void {\n props.hoverOnCallback!(data, e);\n }\n\n function _computeTotalValue() {\n let totalValue = 0;\n props.data.forEach((arc: ChartDataPoint) => {\n totalValue += arc.data!;\n });\n return totalValue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function arcGenerator(d: any, i: number, focusData: any, href?: string): JSX.Element {\n const color = d && d.data && d.data.color;\n return (\n <Arc\n key={i}\n data={d}\n focusData={focusData}\n innerRadius={props.innerRadius}\n outerRadius={props.outerRadius}\n color={color!}\n onFocusCallback={_focusCallback}\n hoverOnCallback={_hoverCallback}\n onBlurCallback={props.onBlurCallback}\n hoverLeaveCallback={props.hoverLeaveCallback}\n uniqText={props.uniqText}\n activeArc={props.activeArc}\n href={href}\n calloutId={props.calloutId}\n valueInsideDonut={props.valueInsideDonut}\n focusedArcId={props.focusedArcId}\n showLabelsInPercent={props.showLabelsInPercent}\n totalValue={_totalValue}\n hideLabels={props.hideLabels}\n />\n );\n }\n\n const { data } = props;\n const focusData = pieForFocusRing(data.map(d => d.data!));\n\n const piechart = d3Pie<ChartDataPoint>()\n .sort(null)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .value((d: any) => d.data)\n .padAngle(0.02)(data);\n const translate = `translate(${props.width / 2}, ${props.height / 2})`;\n\n _totalValue = _computeTotalValue();\n\n return (\n <g transform={translate}>\n {piechart.map((d: any, i: number) => arcGenerator(d, i, focusData[i], props.href))}\n {props.valueInsideDonut && (\n <text y={5} textAnchor=\"middle\" dominantBaseline=\"middle\" className={classes.insideDonutString}>\n {props.valueInsideDonut}\n </text>\n )}\n </g>\n );\n },\n);\nPie.displayName = 'Pie';\n"],"names":["React","pie","d3Pie","Arc","usePieStyles","wrapTextInsideDonut","TEXT_PADDING","Pie","forwardRef","props","forwardedRef","useEffect","classes","insideDonutString","innerRadius","_totalValue","pieForFocusRing","sort","value","d","data","padAngle","_focusCallback","id","e","onFocusCallback","_hoverCallback","hoverOnCallback","_computeTotalValue","totalValue","forEach","arc","arcGenerator","i","focusData","href","color","key","outerRadius","onBlurCallback","hoverLeaveCallback","uniqText","activeArc","calloutId","valueInsideDonut","focusedArcId","showLabelsInPercent","hideLabels","map","piechart","translate","width","height","g","transform","text","y","textAnchor","dominantBaseline","className","displayName"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,8CAA8C,GAC9C,oCAAoC,GACpC,qDAAqD,GACrD,YAAYA,WAAW,QAAQ;AAC/B,SAASC,OAAOC,KAAK,QAAQ,WAAW;AAExC,SAASC,GAAG,QAAQ,eAAe;AAEnC,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,MAAMC,eAAuB;AAE7B,wGAAwG;AACxG;;;CAGC,GACD,OAAO,MAAMC,oBAAyCP,MAAMQ,UAAU,CACpE,CAACC,OAAOC;IACNV,MAAMW,SAAS,CAAC;QACdN,oBAAoBO,QAAQC,iBAAiB,EAAEJ,MAAMK,WAAW,GAAI,IAAIR;IAC1E,GAAG,EAAE;IAEL,IAAIS;IACJ,MAAMH,UAAUR,aAAaK;IAC7B,MAAMO,kBAAkBd,QACrBe,IAAI,CAAC,KACN,8DAA8D;KAC7DC,KAAK,CAAC,CAACC,IAAWA,EAAEC,IA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AQ,CAAC,MAAMD;IAClB,MAAM8B,YAAY,CAAC,UAAU,EAAEzC,MAAM0C,KAAK,GAAG,EAAE,EAAE,EAAE1C,MAAM2C,MAAM,GAAG,EAAE,CAAC,CAAC;IAEtErC,cAAca;IAEd,qBACE,oBAACyB;QAAEC,WAAWJ;OACXD,SAASD,GAAG,CAAC,CAAC7B,GAAQc,IAAcD,aAAab,GAAGc,GAAGC,SAAS,CAACD,EAAE,EAAExB,MAAM0B,IAAI,IAC/E1B,MAAMmC,gBAAgB,kBACrB,oBAACW;QAAKC,GAAG;QAAGC,YAAW;QAASC,kBAAiB;QAASC,WAAW/C,QAAQC,iBAAiB;OAC3FJ,MAAMmC,gBAAgB;AAKjC,GACA;AACFrC,IAAIqD,WAAW,GAAG"}
1
+ {"version":3,"sources":["Pie.tsx"],"sourcesContent":["/* eslint-disable react-hooks/exhaustive-deps */\n/* eslint-disable react/jsx-no-bind */\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as React from 'react';\nimport { pie as d3Pie } from 'd3-shape';\nimport { PieProps } from './index';\nimport { Arc } from '../Arc/index';\nimport { ChartDataPoint } from '../index';\nimport { usePieStyles } from './usePieStyles.styles';\nimport { wrapTextInsideDonut } from '../../../utilities/index';\nconst TEXT_PADDING: number = 5;\n\n// Create a Pie within Donut Chart variant which uses these default styles and this styled subcomponent.\n/**\n * Pie component within Donut Chart.\n * {@docCategory PieDonutChart}\n */\nexport const Pie: React.FunctionComponent<PieProps> = React.forwardRef<HTMLDivElement, PieProps>(\n (props, forwardedRef) => {\n React.useEffect(() => {\n wrapTextInsideDonut(classes.insideDonutString, props.innerRadius! * 2 - TEXT_PADDING);\n }, []);\n\n let _totalValue: number;\n const classes = usePieStyles(props);\n const pieForFocusRing = d3Pie()\n .sort(null)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .value((d: any) => d.data)\n .padAngle(0);\n\n function _focusCallback(data: ChartDataPoint, id: string, e: React.FocusEvent<SVGPathElement>): void {\n props.onFocusCallback!(data, id, e);\n }\n\n function _hoverCallback(data: ChartDataPoint, e: React.MouseEvent<SVGPathElement>): void {\n props.hoverOnCallback!(data, e);\n }\n\n function _computeTotalValue() {\n let totalValue = 0;\n props.data.forEach((arc: ChartDataPoint) => {\n totalValue += arc.data!;\n });\n return totalValue;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n function arcGenerator(d: any, i: number, focusData: any, href?: string): JSX.Element {\n const color = d && d.data && d.data.color;\n return (\n <Arc\n key={i}\n data={d}\n focusData={focusData}\n innerRadius={props.innerRadius}\n outerRadius={props.outerRadius}\n color={color!}\n onFocusCallback={_focusCallback}\n hoverOnCallback={_hoverCallback}\n onBlurCallback={props.onBlurCallback}\n hoverLeaveCallback={props.hoverLeaveCallback}\n uniqText={props.uniqText}\n activeArc={props.activeArc}\n href={href}\n calloutId={props.calloutId}\n valueInsideDonut={props.valueInsideDonut}\n focusedArcId={props.focusedArcId}\n showLabelsInPercent={props.showLabelsInPercent}\n totalValue={_totalValue}\n hideLabels={props.hideLabels}\n />\n );\n }\n\n const { data } = props;\n const focusData = pieForFocusRing(data.map(d => d.data!));\n\n const piechart = d3Pie<ChartDataPoint>()\n .sort(null)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n .value((d: any) => d.data)\n .padAngle(0.02)(data);\n const translate = `translate(${props.width / 2}, ${props.height / 2})`;\n\n _totalValue = _computeTotalValue();\n\n return (\n <g transform={translate}>\n {piechart.map((d: any, i: number) => arcGenerator(d, i, focusData[i], props.href))}\n {props.valueInsideDonut && (\n <text y={5} textAnchor=\"middle\" dominantBaseline=\"middle\" className={classes.insideDonutString}>\n {props.valueInsideDonut}\n </text>\n )}\n </g>\n );\n },\n);\nPie.displayName = 'Pie';\n"],"names":["React","pie","d3Pie","Arc","usePieStyles","wrapTextInsideDonut","TEXT_PADDING","Pie","forwardRef","props","forwardedRef","useEffect","classes","insideDonutString","innerRadius","_totalValue","pieForFocusRing","sort","value","d","data","padAngle","_focusCallback","id","e","onFocusCallback","_hoverCallback","hoverOnCallback","_computeTotalValue","totalValue","forEach","arc","arcGenerator","i","focusData","href","color","key","outerRadius","onBlurCallback","hoverLeaveCallback","uniqText","activeArc","calloutId","valueInsideDonut","focusedArcId","showLabelsInPercent","hideLabels","map","piechart","translate","width","height","g","transform","text","y","textAnchor","dominantBaseline","className","displayName"],"mappings":"AAAA,8CAA8C,GAC9C,oCAAoC,GACpC,qDAAqD,GACrD,YAAYA,WAAW,QAAQ;AAC/B,SAASC,OAAOC,KAAK,QAAQ,WAAW;AAExC,SAASC,GAAG,QAAQ,eAAe;AAEnC,SAASC,YAAY,QAAQ,wBAAwB;AACrD,SAASC,mBAAmB,QAAQ,2BAA2B;AAC/D,MAAMC,eAAuB;AAE7B,wGAAwG;AACxG;;;CAGC,GACD,OAAO,MAAMC,oBAAyCP,MAAMQ,UAAU,CACpE,CAACC,OAAOC;IACNV,MAAMW,SAAS,CAAC;QACdN,oBAAoBO,QAAQC,iBAAiB,EAAEJ,MAAMK,WAAW,GAAI,IAAIR;IAC1E,GAAG,EAAE;IAEL,IAAIS;IACJ,MAAMH,UAAUR,aAAaK;IAC7B,MAAMO,kBAAkBd,QACrBe,IAAI,CAAC,KACN,8DAA8D;KAC7DC,KAAK,CAAC,CAACC,IAAWA,EAAEC,IAAI,EACxBC,QAAQ,CAAC;IAEZ,SAASC,eAAeF,IAAoB,EAAEG,EAAU,EAAEC,CAAmC;QAC3Ff,MAAMgB,eAAe,CAAEL,MAAMG,IAAIC;IACnC;IAEA,SAASE,eAAeN,IAAoB,EAAEI,CAAmC;QAC/Ef,MAAMkB,eAAe,CAAEP,MAAMI;IAC/B;IAEA,SAASI;QACP,IAAIC,aAAa;QACjBpB,MAAMW,IAAI,CAACU,OAAO,CAAC,CAACC;YAClBF,cAAcE,IAAIX,IAAI;QACxB;QACA,OAAOS;IACT;IAEA,8DAA8D;IAC9D,SAASG,aAAab,CAAM,EAAEc,CAAS,EAAEC,SAAc,EAAEC,IAAa;QACpE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gBAAgB;AAKjC,GACA;AACFrC,IAAIqD,WAAW,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["Pie.types.ts"],"sourcesContent":["import { ChartDataPoint } from '../index';\n\nexport interface PieProps {\n /**\n * Width of the Pie.\n */\n width: number;\n /**\n * Height of the Pie.\n */\n height: number;\n /**\n * outerRadius of the Pie.\n */\n outerRadius: number;\n /**\n * innerRadius of the Pie.\n */\n innerRadius: number;\n /**\n * Data to render in the Pie.\n */\n data: ChartDataPoint[];\n /**\n * shape for pie.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n pie?: any;\n\n pieForFocusRing?: any;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n hoverOnCallback?: Function;\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n onFocusCallback?: Function;\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n onBlurCallback?: Function;\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n hoverLeaveCallback?: Function;\n /**\n * Uniq string for chart\n */\n uniqText?: string;\n /**\n * Active Arc for chart\n */\n activeArc?: string;\n\n /**\n * string for callout id\n */\n calloutId?: string;\n\n /**\n * internal prop for href\n */\n href?: string;\n\n /**\n * props for inside donut value\n */\n valueInsideDonut?: string | number;\n\n /**\n * id of the focused arc\n */\n focusedArcId?: string;\n\n /**\n * Prop to show the arc labels in percentage format\n */\n showLabelsInPercent?: boolean;\n\n /**\n * Prop to hide the arc labels\n */\n hideLabels?: boolean;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: PieStyles;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n}\n\nexport interface PieStyles {\n /**\n * Style set for the card header component root\n */\n root: string;\n\n /**\n * Style set for the inside donut string\n */\n insideDonutString: string;\n}\n"],"names":[],"rangeMappings":"","mappings":"AAiGA,WAUC"}
1
+ {"version":3,"sources":["Pie.types.ts"],"sourcesContent":["import { ChartDataPoint } from '../index';\n\nexport interface PieProps {\n /**\n * Width of the Pie.\n */\n width: number;\n /**\n * Height of the Pie.\n */\n height: number;\n /**\n * outerRadius of the Pie.\n */\n outerRadius: number;\n /**\n * innerRadius of the Pie.\n */\n innerRadius: number;\n /**\n * Data to render in the Pie.\n */\n data: ChartDataPoint[];\n /**\n * shape for pie.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n pie?: any;\n\n pieForFocusRing?: any;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n hoverOnCallback?: Function;\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n onFocusCallback?: Function;\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n onBlurCallback?: Function;\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n hoverLeaveCallback?: Function;\n /**\n * Uniq string for chart\n */\n uniqText?: string;\n /**\n * Active Arc for chart\n */\n activeArc?: string;\n\n /**\n * string for callout id\n */\n calloutId?: string;\n\n /**\n * internal prop for href\n */\n href?: string;\n\n /**\n * props for inside donut value\n */\n valueInsideDonut?: string | number;\n\n /**\n * id of the focused arc\n */\n focusedArcId?: string;\n\n /**\n * Prop to show the arc labels in percentage format\n */\n showLabelsInPercent?: boolean;\n\n /**\n * Prop to hide the arc labels\n */\n hideLabels?: boolean;\n\n /**\n * Call to provide customized styling that will layer on top of the variant rules.\n */\n styles?: PieStyles;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n}\n\nexport interface PieStyles {\n /**\n * Style set for the card header component root\n */\n root: string;\n\n /**\n * Style set for the inside donut string\n */\n insideDonutString: string;\n}\n"],"names":[],"mappings":"AAiGA,WAUC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './Pie';\nexport * from './Pie.types';\n"],"names":[],"rangeMappings":";","mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,cAAc"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './Pie';\nexport * from './Pie.types';\n"],"names":[],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './DonutChart';\nexport * from './DonutChart.types';\nexport * from '../../types/index';\n"],"names":[],"rangeMappings":";;","mappings":"AAAA,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,oBAAoB"}
1
+ {"version":3,"sources":["index.ts"],"sourcesContent":["export * from './DonutChart';\nexport * from './DonutChart.types';\nexport * from '../../types/index';\n"],"names":[],"mappings":"AAAA,cAAc,eAAe;AAC7B,cAAc,qBAAqB;AACnC,cAAc,oBAAoB"}
@@ -0,0 +1,391 @@
1
+ import * as React from 'react';
2
+ import { useId } from '@fluentui/react-utilities';
3
+ import { useRtl } from '../../utilities/index';
4
+ import { Legends } from '../Legends/index';
5
+ import { useFocusableGroup } from '@fluentui/react-tabster';
6
+ import { ChartPopover } from '../CommonComponents/ChartPopover';
7
+ import { formatToLocaleString } from '@fluentui/chart-utilities';
8
+ import { getContrastTextColor } from '../../utilities/colors';
9
+ import { useFunnelChartStyles } from './useFunnelChartStyles.styles';
10
+ import { getHorizontalFunnelSegmentGeometry, getVerticalFunnelSegmentGeometry, getSegmentTextProps, getStackedHorizontalFunnelSegmentGeometry, getStackedVerticalFunnelSegmentGeometry } from './funnelGeometry';
11
+ export const FunnelChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
12
+ var _props_legendProps;
13
+ const _emptyChartId = useId('_FunnelChart_empty');
14
+ const isRTL = useRtl();
15
+ const [hoveredStage, setHoveredStage] = React.useState(null);
16
+ const [calloutData, setCalloutData] = React.useState(null);
17
+ const [selectedLegends, setSelectedLegends] = React.useState([]);
18
+ const [clickPosition, setClickPosition] = React.useState({
19
+ x: 0,
20
+ y: 0
21
+ });
22
+ const [isPopoverOpen, setPopoverOpen] = React.useState(false);
23
+ const chartContainerRef = React.useRef(null);
24
+ const isStacked = isStackedFunnelData(props.data);
25
+ React.useEffect(()=>{
26
+ var _props_legendProps;
27
+ if ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) {
28
+ setSelectedLegends(props.legendProps.selectedLegends);
29
+ }
30
+ }, [
31
+ (_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends
32
+ ]);
33
+ function _handleHover(data, mouseEvent) {
34
+ mouseEvent === null || mouseEvent === void 0 ? void 0 : mouseEvent.persist();
35
+ updatePosition(mouseEvent.clientX, mouseEvent.clientY);
36
+ setCalloutData(data);
37
+ setPopoverOpen(true);
38
+ }
39
+ function _handleFocus(data, focusEvent) {
40
+ focusEvent === null || focusEvent === void 0 ? void 0 : focusEvent.persist();
41
+ let x = 0;
42
+ let y = 0;
43
+ const targetRect = focusEvent.target.getBoundingClientRect();
44
+ x = targetRect.left + targetRect.width / 2;
45
+ y = targetRect.top + targetRect.height / 2;
46
+ updatePosition(x, y);
47
+ setCalloutData(data);
48
+ setPopoverOpen(true);
49
+ }
50
+ function _handleStackedHover(stage, subValue, mouseEvent) {
51
+ mouseEvent === null || mouseEvent === void 0 ? void 0 : mouseEvent.persist();
52
+ updatePosition(mouseEvent.clientX, mouseEvent.clientY);
53
+ setCalloutData({
54
+ stage,
55
+ value: subValue.value,
56
+ color: subValue.color,
57
+ category: subValue.category
58
+ });
59
+ setPopoverOpen(true);
60
+ }
61
+ function _handleStackedFocus(stage, subValue, focusEvent) {
62
+ focusEvent === null || focusEvent === void 0 ? void 0 : focusEvent.persist();
63
+ let x = 0;
64
+ let y = 0;
65
+ const targetRect = focusEvent.target.getBoundingClientRect();
66
+ x = targetRect.left + targetRect.width / 2;
67
+ y = targetRect.top + targetRect.height / 2;
68
+ updatePosition(x, y);
69
+ setCalloutData({
70
+ stage,
71
+ value: subValue.value,
72
+ color: subValue.color,
73
+ category: subValue.category
74
+ });
75
+ setPopoverOpen(true);
76
+ }
77
+ function _handleMouseOut() {
78
+ setHoveredStage(null);
79
+ setPopoverOpen(false);
80
+ setCalloutData(null);
81
+ }
82
+ function _onLegendSelectionChange(legendsSelected, event, currentLegend) {
83
+ var _props_legendProps, _props_legendProps1;
84
+ if ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends) {
85
+ setSelectedLegends(legendsSelected);
86
+ } else {
87
+ setSelectedLegends(legendsSelected.slice(-1));
88
+ }
89
+ if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
90
+ props.legendProps.onChange(legendsSelected, event, currentLegend);
91
+ }
92
+ }
93
+ const _onLegendSelectionChangeCallback = React.useCallback(_onLegendSelectionChange, [
94
+ props.legendProps
95
+ ]);
96
+ function getHighlightedLegend() {
97
+ return selectedLegends.length > 0 ? selectedLegends : hoveredStage ? [
98
+ hoveredStage
99
+ ] : [];
100
+ }
101
+ function legendHighlighted(legend) {
102
+ return getHighlightedLegend().includes(legend);
103
+ }
104
+ function noLegendHighlighted() {
105
+ return getHighlightedLegend().length === 0;
106
+ }
107
+ function _getEventHandlerProps(data, opacity) {
108
+ if ('subValue' in data) {
109
+ return {
110
+ culture: props.culture,
111
+ onMouseOver: opacity == 1 ? (event)=>_handleStackedHover(data.stage, data.subValue, event) : undefined,
112
+ onMouseMove: opacity == 1 ? (event)=>_handleStackedHover(data.stage, data.subValue, event) : undefined,
113
+ onFocus: (event)=>_handleStackedFocus(data.stage, data.subValue, event),
114
+ onBlur: ()=>_handleMouseOut(),
115
+ onMouseOut: ()=>_handleMouseOut()
116
+ };
117
+ } else {
118
+ return {
119
+ culture: props.culture,
120
+ onMouseOver: opacity == 1 ? (event)=>_handleHover(data, event) : undefined,
121
+ onMouseMove: opacity == 1 ? (event)=>_handleHover(data, event) : undefined,
122
+ onFocus: (event)=>_handleFocus(data, event),
123
+ onBlur: ()=>_handleMouseOut(),
124
+ onMouseOut: ()=>_handleMouseOut()
125
+ };
126
+ }
127
+ }
128
+ function _renderSegmentText({ show, x, y, value, textColor }) {
129
+ if (!show) {
130
+ return null;
131
+ }
132
+ const textElement = /*#__PURE__*/ React.createElement("text", {
133
+ x: isRTL ? funnelWidth - x : x,
134
+ y: y,
135
+ textAnchor: "middle",
136
+ alignmentBaseline: "middle",
137
+ fill: textColor
138
+ }, formatToLocaleString(value.toString(), props.culture));
139
+ if (isRTL) {
140
+ return /*#__PURE__*/ React.createElement("g", {
141
+ transform: `scale(-1,1) translate(${-funnelWidth},0)`
142
+ }, textElement);
143
+ }
144
+ return textElement;
145
+ }
146
+ function _renderFunnelSegment({ key, pathD, fill, opacity, textProps, data, tabIndex }) {
147
+ const eventHandlers = _getEventHandlerProps(data, opacity);
148
+ const textColor = getContrastTextColor(fill);
149
+ return /*#__PURE__*/ React.createElement("g", {
150
+ key: key
151
+ }, /*#__PURE__*/ React.createElement("path", {
152
+ d: pathD,
153
+ fill: fill,
154
+ opacity: opacity,
155
+ ...eventHandlers,
156
+ tabIndex: tabIndex
157
+ }), textProps && /*#__PURE__*/ React.createElement("g", eventHandlers, _renderSegmentText({
158
+ ...textProps,
159
+ textColor
160
+ })));
161
+ }
162
+ function _createFunnel(containerHeight, containerWidth) {
163
+ const { data } = props;
164
+ const funnelWidth = containerWidth;
165
+ const funnelHeight = containerHeight * 0.8;
166
+ return data.map((d, i)=>{
167
+ const geometryProps = props.orientation === 'vertical' ? getVerticalFunnelSegmentGeometry({
168
+ d,
169
+ i,
170
+ data,
171
+ funnelWidth,
172
+ funnelHeight,
173
+ isRTL
174
+ }) : getHorizontalFunnelSegmentGeometry({
175
+ d,
176
+ i,
177
+ data,
178
+ funnelWidth,
179
+ funnelHeight,
180
+ isRTL
181
+ });
182
+ const { pathD, textX, textY, availableWidth } = geometryProps;
183
+ const minTextWidth = 16;
184
+ const eventHandlerProps = _getEventHandlerProps(d);
185
+ const textProps = getSegmentTextProps({
186
+ availableWidth,
187
+ minTextWidth,
188
+ textX,
189
+ textY,
190
+ value: d.value,
191
+ ...eventHandlerProps
192
+ });
193
+ return _renderFunnelSegment({
194
+ key: i,
195
+ pathD,
196
+ fill: d.color,
197
+ opacity: legendHighlighted(d.stage) || noLegendHighlighted() ? 1 : 0.1,
198
+ textProps,
199
+ data: d,
200
+ tabIndex: legendHighlighted(d.stage) || noLegendHighlighted() ? 0 : undefined
201
+ });
202
+ });
203
+ }
204
+ function isStackedFunnelData(data) {
205
+ return Array.isArray(data) && data.every((stage)=>Array.isArray(stage.subValues));
206
+ }
207
+ function _renderStackedSegment(stage, subValue, stageIndex, subValueIndex, geometryParams) {
208
+ // Ensure stages have subValues for geometry functions
209
+ const stagesWithSubValues = geometryParams.stages.map((s)=>({
210
+ ...s,
211
+ subValues: s.subValues || []
212
+ }));
213
+ const geom = props.orientation === 'vertical' ? getStackedVerticalFunnelSegmentGeometry({
214
+ ...geometryParams,
215
+ stages: stagesWithSubValues,
216
+ i: stageIndex,
217
+ k: subValueIndex
218
+ }) : getStackedHorizontalFunnelSegmentGeometry({
219
+ ...geometryParams,
220
+ stages: stagesWithSubValues,
221
+ i: stageIndex,
222
+ k: subValueIndex
223
+ });
224
+ const minTextWidth = 16;
225
+ const eventHandlerProps = _getEventHandlerProps({
226
+ stage: stage.stage,
227
+ subValue
228
+ });
229
+ const textProps = getSegmentTextProps({
230
+ availableWidth: geom.availableWidth,
231
+ minTextWidth,
232
+ textX: geom.textX,
233
+ textY: geom.textY,
234
+ value: subValue.value,
235
+ ...eventHandlerProps
236
+ });
237
+ return _renderFunnelSegment({
238
+ key: `${stageIndex}-${subValueIndex}`,
239
+ pathD: geom.pathD,
240
+ fill: subValue.color,
241
+ opacity: isStackedFunnelData(props.data) && legendHighlighted(subValue.category) || noLegendHighlighted() ? 1 : 0.1,
242
+ textProps,
243
+ data: {
244
+ stage: stage.stage,
245
+ subValue
246
+ },
247
+ tabIndex: legendHighlighted(subValue.category) || noLegendHighlighted() ? 0 : undefined
248
+ });
249
+ }
250
+ function _createStackedFunnel(containerHeight, containerWidth) {
251
+ const { data } = props;
252
+ const stages = data;
253
+ const totals = stages.map((s)=>{
254
+ var _s_subValues;
255
+ var _s_subValues_reduce;
256
+ return (_s_subValues_reduce = s === null || s === void 0 ? void 0 : (_s_subValues = s.subValues) === null || _s_subValues === void 0 ? void 0 : _s_subValues.reduce((sum, subValue)=>sum + subValue.value, 0)) !== null && _s_subValues_reduce !== void 0 ? _s_subValues_reduce : 0;
257
+ });
258
+ const maxTotal = Math.max(...totals);
259
+ const funnelWidth = containerWidth;
260
+ const funnelHeight = containerHeight * 0.8;
261
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
262
+ const paths = [];
263
+ const geometryParams = {
264
+ stages,
265
+ totals,
266
+ maxTotal,
267
+ funnelWidth,
268
+ funnelHeight,
269
+ isRTL
270
+ };
271
+ for(let i = 0; i < stages.length; i++){
272
+ const cur = stages[i];
273
+ var _cur_subValues;
274
+ for(let k = 0; k < ((_cur_subValues = cur.subValues) !== null && _cur_subValues !== void 0 ? _cur_subValues : []).length; k++){
275
+ var _cur_subValues1;
276
+ const v = (_cur_subValues1 = cur.subValues) === null || _cur_subValues1 === void 0 ? void 0 : _cur_subValues1[k];
277
+ if (!v) {
278
+ continue;
279
+ }
280
+ paths.push(_renderStackedSegment(cur, v, i, k, geometryParams));
281
+ }
282
+ }
283
+ return paths;
284
+ }
285
+ function _renderLegends() {
286
+ if (props.hideLegend) {
287
+ return /*#__PURE__*/ React.createElement(React.Fragment, null);
288
+ }
289
+ let legends;
290
+ if (isStacked) {
291
+ // Collect unique categories and their color
292
+ const categoryMap = {};
293
+ props.data.forEach((stage)=>{
294
+ (stage.subValues || []).forEach((sub)=>{
295
+ if (!(sub.category in categoryMap)) {
296
+ categoryMap[sub.category] = sub.color;
297
+ }
298
+ });
299
+ });
300
+ legends = Object.entries(categoryMap).map(([category, color])=>({
301
+ title: category,
302
+ color,
303
+ hoverAction: ()=>setHoveredStage(category),
304
+ onMouseOutAction: ()=>setHoveredStage(null)
305
+ }));
306
+ } else {
307
+ legends = props.data.map((d)=>({
308
+ title: d.stage,
309
+ color: d.color,
310
+ hoverAction: ()=>setHoveredStage(d.stage),
311
+ onMouseOutAction: ()=>setHoveredStage(null)
312
+ }));
313
+ }
314
+ return /*#__PURE__*/ React.createElement("div", {
315
+ style: {
316
+ display: 'flex',
317
+ justifyContent: 'center'
318
+ }
319
+ }, /*#__PURE__*/ React.createElement(Legends, {
320
+ legends: legends,
321
+ centerLegends: true,
322
+ onChange: _onLegendSelectionChangeCallback,
323
+ ...props.legendProps
324
+ }));
325
+ }
326
+ function _isChartEmpty() {
327
+ return !(props.data && props.data.length > 0);
328
+ }
329
+ function updatePosition(newX, newY) {
330
+ const threshold = 1; // Set a threshold for movement
331
+ const { x, y } = clickPosition;
332
+ // Calculate the distance moved
333
+ const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
334
+ // Update the position only if the distance moved is greater than the threshold
335
+ if (distance > threshold) {
336
+ setClickPosition({
337
+ x: newX,
338
+ y: newY
339
+ });
340
+ setPopoverOpen(true);
341
+ }
342
+ }
343
+ const classes = useFunnelChartStyles(props);
344
+ const calloutProps = {
345
+ ...props.calloutProps,
346
+ color: calloutData === null || calloutData === void 0 ? void 0 : calloutData.color,
347
+ hoverXValue: calloutData === null || calloutData === void 0 ? void 0 : calloutData.stage,
348
+ YValue: calloutData === null || calloutData === void 0 ? void 0 : calloutData.value
349
+ };
350
+ const width = props.width || 350;
351
+ const height = props.height || 500;
352
+ const funnelMarginTop = 40;
353
+ const funnelWidth = width * 0.8;
354
+ const funnelOffsetX = (width - funnelWidth) / 2;
355
+ const focusAttributes = useFocusableGroup();
356
+ var _props_culture;
357
+ return !_isChartEmpty() ? /*#__PURE__*/ React.createElement("div", {
358
+ ref: chartContainerRef,
359
+ className: classes.root,
360
+ ...focusAttributes
361
+ }, /*#__PURE__*/ React.createElement("svg", {
362
+ width: width,
363
+ height: height,
364
+ className: classes.chart,
365
+ role: 'img',
366
+ "aria-label": props.chartTitle
367
+ }, /*#__PURE__*/ React.createElement("g", {
368
+ transform: isRTL ? `translate(${funnelOffsetX + funnelWidth}, ${funnelMarginTop}) scale(-1,1)` : `translate(${funnelOffsetX}, ${funnelMarginTop})`
369
+ }, isStacked ? _createStackedFunnel(height - funnelMarginTop, funnelWidth) : _createFunnel(height - funnelMarginTop, funnelWidth))), isPopoverOpen && /*#__PURE__*/ React.createElement(ChartPopover, {
370
+ ...props.calloutProps,
371
+ XValue: calloutProps === null || calloutProps === void 0 ? void 0 : calloutProps.hoverXValue,
372
+ yCalloutValue: calloutProps === null || calloutProps === void 0 ? void 0 : calloutProps.YValue,
373
+ culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
374
+ clickPosition: clickPosition,
375
+ isPopoverOpen: isPopoverOpen,
376
+ color: calloutProps === null || calloutProps === void 0 ? void 0 : calloutProps.color,
377
+ isCartesian: false
378
+ }), _renderLegends()) : /*#__PURE__*/ React.createElement("div", {
379
+ id: _emptyChartId,
380
+ role: 'alert',
381
+ style: {
382
+ opacity: '0'
383
+ },
384
+ "aria-label": 'Graph has no data to display'
385
+ });
386
+ });
387
+ FunnelChart.displayName = 'FunnelChart';
388
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
389
+ FunnelChart.defaultProps = {
390
+ orientation: 'vertical'
391
+ };