@fluentui/react-charts 9.2.3 → 9.3.0

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 (347) hide show
  1. package/CHANGELOG.md +79 -10
  2. package/dist/index.d.ts +98 -5
  3. package/lib/components/AreaChart/AreaChart.js +8 -6
  4. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  5. package/lib/components/AreaChart/useAreaChartStyles.styles.js +4 -2
  6. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +4 -15
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  9. package/lib/components/ChartTable/ChartTable.js +95 -8
  10. package/lib/components/ChartTable/ChartTable.js.map +1 -1
  11. package/lib/components/ChartTable/useChartTableStyles.styles.js +5 -3
  12. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
  13. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +3 -2
  14. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
  15. package/lib/components/CommonComponents/CartesianChart.js +45 -42
  16. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  17. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  18. package/lib/components/CommonComponents/ChartPopover.js +14 -5
  19. package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
  20. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +19 -14
  21. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  22. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +7 -33
  23. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  24. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +5 -3
  25. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  26. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +3 -2
  27. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
  28. package/lib/components/DeclarativeChart/DeclarativeChart.js +56 -16
  29. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  30. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +19 -0
  31. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  32. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +1096 -337
  33. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  34. package/lib/components/DeclarativeChart/imageExporter.js +1 -0
  35. package/lib/components/DeclarativeChart/imageExporter.js.map +1 -1
  36. package/lib/components/DonutChart/Arc/Arc.js +8 -8
  37. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  38. package/lib/components/DonutChart/Arc/Arc.types.js.map +1 -1
  39. package/lib/components/DonutChart/Arc/useArcStyles.styles.js +9 -2
  40. package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  41. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -1
  42. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  43. package/lib/components/DonutChart/DonutChart.js +61 -25
  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 +1 -0
  47. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  48. package/lib/components/DonutChart/Pie/Pie.types.js.map +1 -1
  49. package/lib/components/DonutChart/Pie/usePieStyles.styles.js +2 -0
  50. package/lib/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
  51. package/lib/components/DonutChart/Pie/usePieStyles.styles.raw.js +1 -0
  52. package/lib/components/DonutChart/Pie/usePieStyles.styles.raw.js.map +1 -1
  53. package/lib/components/DonutChart/useDonutChartStyles.styles.js +23 -4
  54. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  55. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +9 -4
  56. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  57. package/lib/components/FunnelChart/FunnelChart.js +11 -5
  58. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  59. package/lib/components/FunnelChart/funnelGeometry.js.map +1 -1
  60. package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +2 -0
  61. package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
  62. package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +1 -0
  63. package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
  64. package/lib/components/GanttChart/GanttChart.js +1 -0
  65. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  66. package/lib/components/GaugeChart/GaugeChart.js +2 -2
  67. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  68. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +2 -0
  69. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
  70. package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +1 -0
  71. package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
  72. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +15 -9
  73. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  74. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +6 -17
  75. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  76. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +5 -21
  77. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  78. package/lib/components/HeatMapChart/HeatMapChart.js +2 -1
  79. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  80. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -0
  81. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  82. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +1 -0
  83. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  84. package/lib/components/HorizontalBarChart/HorizontalBarChart.js +3 -3
  85. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  86. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +8 -2
  87. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  88. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -1
  89. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  90. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
  91. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  92. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -0
  93. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  94. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +1 -0
  95. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  96. package/lib/components/Legends/Legends.js +1 -0
  97. package/lib/components/Legends/Legends.js.map +1 -1
  98. package/lib/components/Legends/OverflowMenu.js +1 -0
  99. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  100. package/lib/components/Legends/shape.js +1 -0
  101. package/lib/components/Legends/shape.js.map +1 -1
  102. package/lib/components/Legends/useLegendsStyles.styles.js +2 -0
  103. package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
  104. package/lib/components/Legends/useLegendsStyles.styles.raw.js +1 -0
  105. package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  106. package/lib/components/LineChart/LineChart.js +284 -281
  107. package/lib/components/LineChart/LineChart.js.map +1 -1
  108. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  109. package/lib/components/LineChart/eventAnnotation/LabelLink.js +1 -0
  110. package/lib/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
  111. package/lib/components/LineChart/eventAnnotation/Textbox.js +1 -0
  112. package/lib/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
  113. package/lib/components/LineChart/useLineChartStyles.styles.js +25 -10
  114. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  115. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +5 -21
  116. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  117. package/lib/components/ResponsiveContainer/ResponsiveContainer.js +1 -0
  118. package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
  119. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.js +2 -0
  120. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.js.map +1 -1
  121. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js +1 -0
  122. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js.map +1 -1
  123. package/lib/components/ResponsiveContainer/withResponsiveContainer.js +1 -0
  124. package/lib/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
  125. package/lib/components/SankeyChart/SankeyChart.js +1 -0
  126. package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
  127. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +14 -25
  128. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  129. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +3 -12
  130. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  131. package/lib/components/ScatterChart/ScatterChart.js +121 -81
  132. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  133. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  134. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +13 -7
  135. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  136. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +5 -22
  137. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  138. package/lib/components/Sparkline/Sparkline.js +1 -0
  139. package/lib/components/Sparkline/Sparkline.js.map +1 -1
  140. package/lib/components/Sparkline/useSparklineStyles.styles.js +2 -0
  141. package/lib/components/Sparkline/useSparklineStyles.styles.js.map +1 -1
  142. package/lib/components/Sparkline/useSparklineStyles.styles.raw.js +1 -0
  143. package/lib/components/Sparkline/useSparklineStyles.styles.raw.js.map +1 -1
  144. package/lib/components/VerticalBarChart/VerticalBarChart.js +17 -12
  145. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  146. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +10 -6
  147. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  148. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +6 -19
  149. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  150. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +30 -25
  151. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  152. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +9 -6
  153. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  154. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +5 -19
  155. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  156. package/lib/types/DataPoint.js +3 -1
  157. package/lib/types/DataPoint.js.map +1 -1
  158. package/lib/utilities/Common.styles.js +47 -0
  159. package/lib/utilities/Common.styles.js.map +1 -0
  160. package/lib/utilities/Common.styles.raw.js +47 -0
  161. package/lib/utilities/Common.styles.raw.js.map +1 -0
  162. package/lib/utilities/FocusableTooltipText.js +1 -0
  163. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  164. package/lib/utilities/SVGTooltipText.js +1 -0
  165. package/lib/utilities/SVGTooltipText.js.map +1 -1
  166. package/lib/utilities/image-export-utils.js +1 -0
  167. package/lib/utilities/image-export-utils.js.map +1 -1
  168. package/lib/utilities/index.js +1 -0
  169. package/lib/utilities/index.js.map +1 -1
  170. package/lib/utilities/scatterpolar-utils.js +52 -0
  171. package/lib/utilities/scatterpolar-utils.js.map +1 -0
  172. package/lib/utilities/utilities.js +314 -146
  173. package/lib/utilities/utilities.js.map +1 -1
  174. package/lib/utilities/vbc-utils.js.map +1 -1
  175. package/lib-commonjs/components/AreaChart/AreaChart.js +7 -5
  176. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  177. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +1 -0
  178. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  179. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -14
  180. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  181. package/lib-commonjs/components/ChartTable/ChartTable.js +95 -8
  182. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
  183. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +4 -3
  184. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
  185. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +3 -2
  186. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
  187. package/lib-commonjs/components/CommonComponents/CartesianChart.js +45 -42
  188. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  189. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  190. package/lib-commonjs/components/CommonComponents/ChartPopover.js +14 -5
  191. package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
  192. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +16 -13
  193. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  194. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +5 -32
  195. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  196. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +4 -3
  197. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  198. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +3 -2
  199. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
  200. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +60 -20
  201. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  202. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js +22 -0
  203. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  204. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +1109 -338
  205. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  206. package/lib-commonjs/components/DeclarativeChart/imageExporter.js +1 -0
  207. package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +1 -1
  208. package/lib-commonjs/components/DonutChart/Arc/Arc.js +8 -8
  209. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  210. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js.map +1 -1
  211. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +11 -1
  212. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  213. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +6 -1
  214. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  215. package/lib-commonjs/components/DonutChart/DonutChart.js +61 -25
  216. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  217. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  218. package/lib-commonjs/components/DonutChart/Pie/Pie.js +2 -1
  219. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  220. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js.map +1 -1
  221. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js +1 -0
  222. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
  223. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.raw.js +1 -0
  224. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.raw.js.map +1 -1
  225. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +33 -4
  226. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  227. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +9 -4
  228. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  229. package/lib-commonjs/components/FunnelChart/FunnelChart.js +11 -5
  230. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  231. package/lib-commonjs/components/FunnelChart/funnelGeometry.js.map +1 -1
  232. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +1 -0
  233. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
  234. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +1 -0
  235. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
  236. package/lib-commonjs/components/GanttChart/GanttChart.js +1 -0
  237. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  238. package/lib-commonjs/components/GaugeChart/GaugeChart.js +2 -2
  239. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  240. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +1 -0
  241. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
  242. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +1 -0
  243. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
  244. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +15 -9
  245. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  246. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +3 -19
  247. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  248. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +4 -20
  249. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  250. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +2 -1
  251. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  252. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +1 -0
  253. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  254. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +1 -0
  255. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  256. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +3 -3
  257. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  258. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +10 -2
  259. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  260. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +5 -1
  261. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  262. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
  263. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  264. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +1 -0
  265. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  266. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +1 -0
  267. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  268. package/lib-commonjs/components/Legends/Legends.js +1 -0
  269. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  270. package/lib-commonjs/components/Legends/OverflowMenu.js +1 -0
  271. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  272. package/lib-commonjs/components/Legends/shape.js +1 -0
  273. package/lib-commonjs/components/Legends/shape.js.map +1 -1
  274. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +1 -0
  275. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
  276. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js +1 -0
  277. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  278. package/lib-commonjs/components/LineChart/LineChart.js +282 -279
  279. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  280. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  281. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js +1 -0
  282. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
  283. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js +1 -0
  284. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
  285. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +31 -9
  286. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  287. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +3 -20
  288. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  289. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js +1 -0
  290. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
  291. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.js +1 -0
  292. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.js.map +1 -1
  293. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js +1 -0
  294. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js.map +1 -1
  295. package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js +2 -1
  296. package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
  297. package/lib-commonjs/components/SankeyChart/SankeyChart.js +1 -0
  298. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
  299. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +24 -33
  300. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  301. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +2 -12
  302. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  303. package/lib-commonjs/components/ScatterChart/ScatterChart.js +118 -78
  304. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  305. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  306. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +14 -7
  307. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  308. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -20
  309. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  310. package/lib-commonjs/components/Sparkline/Sparkline.js +1 -0
  311. package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
  312. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js +1 -0
  313. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js.map +1 -1
  314. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.raw.js +1 -0
  315. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.raw.js.map +1 -1
  316. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +16 -11
  317. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  318. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +6 -3
  319. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  320. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +4 -17
  321. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  322. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +29 -24
  323. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  324. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +6 -3
  325. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  326. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +4 -18
  327. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  328. package/lib-commonjs/types/DataPoint.js +3 -1
  329. package/lib-commonjs/types/DataPoint.js.map +1 -1
  330. package/lib-commonjs/utilities/Common.styles.js +71 -0
  331. package/lib-commonjs/utilities/Common.styles.js.map +1 -0
  332. package/lib-commonjs/utilities/Common.styles.raw.js +71 -0
  333. package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -0
  334. package/lib-commonjs/utilities/FocusableTooltipText.js +2 -1
  335. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  336. package/lib-commonjs/utilities/SVGTooltipText.js +1 -0
  337. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  338. package/lib-commonjs/utilities/image-export-utils.js +1 -0
  339. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  340. package/lib-commonjs/utilities/index.js +1 -0
  341. package/lib-commonjs/utilities/index.js.map +1 -1
  342. package/lib-commonjs/utilities/scatterpolar-utils.js +67 -0
  343. package/lib-commonjs/utilities/scatterpolar-utils.js.map +1 -0
  344. package/lib-commonjs/utilities/utilities.js +327 -137
  345. package/lib-commonjs/utilities/utilities.js.map +1 -1
  346. package/lib-commonjs/utilities/vbc-utils.js.map +1 -1
  347. package/package.json +10 -10
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DeclarativeChart/imageExporter.ts"],"sourcesContent":["import { create as d3Create, select as d3Select, Selection } from 'd3-selection';\nimport { resolveCSSVariables } from '../../utilities/index';\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface ImageExportOptions {\n width?: number;\n height?: number;\n scale?: number;\n background?: string;\n}\n\nexport function toImage(chartContainer?: HTMLElement | null, opts: ImageExportOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n if (!chartContainer) {\n return reject(new Error('Chart container is not defined'));\n }\n\n try {\n const background =\n typeof opts.background === 'string' ? resolveCSSVariables(chartContainer, opts.background) : 'transparent';\n const svg = toSVG(chartContainer, background);\n\n const svgData = new XMLSerializer().serializeToString(svg.node);\n const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescapePonyfill(encodeURIComponent(svgData)));\n\n svgToPng(svgDataUrl, {\n width: opts.width || svg.width,\n height: opts.height || svg.height,\n scale: opts.scale,\n })\n .then(resolve)\n .catch(reject);\n } catch (err) {\n return reject(err);\n }\n });\n}\n\nconst SVG_STYLE_PROPERTIES = ['display', 'fill', 'fill-opacity', 'opacity', 'stroke', 'stroke-width', 'transform'];\nconst SVG_TEXT_STYLE_PROPERTIES = ['font-family', 'font-size', 'font-weight', 'text-anchor'];\n\nfunction toSVG(chartContainer: HTMLElement, background: string) {\n const svg = chartContainer.querySelector<SVGSVGElement>('svg');\n if (!svg) {\n throw new Error('SVG not found');\n }\n\n const clonedSvg = d3Select(svg.cloneNode(true) as SVGSVGElement)\n .attr('width', null)\n .attr('height', null)\n .attr('viewBox', null);\n const svgElements = svg.getElementsByTagName('*');\n const clonedSvgElements = clonedSvg.node()!.getElementsByTagName('*');\n\n for (let i = 0; i < svgElements.length; i++) {\n if (svgElements[i].tagName.toLowerCase() === 'text') {\n copyStyle([...SVG_STYLE_PROPERTIES, ...SVG_TEXT_STYLE_PROPERTIES], svgElements[i], clonedSvgElements[i]);\n } else {\n copyStyle(SVG_STYLE_PROPERTIES, svgElements[i], clonedSvgElements[i]);\n }\n }\n\n const { width: svgWidth, height: svgHeight } = svg.getBoundingClientRect();\n const legendGroup = cloneLegendsToSVG(chartContainer, svgWidth, svgHeight);\n const w1 = Math.max(svgWidth, legendGroup.width);\n const h1 = svgHeight + legendGroup.height;\n\n if (legendGroup.node) {\n clonedSvg.append(() => legendGroup.node);\n }\n clonedSvg\n .insert('rect', ':first-child')\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', w1)\n .attr('height', h1)\n .attr('fill', background);\n clonedSvg.attr('width', w1).attr('height', h1).attr('viewBox', `0 0 ${w1} ${h1}`);\n\n return {\n node: clonedSvg.node()!,\n width: w1,\n height: h1,\n };\n}\n\nconst LEGEND_RECT_STYLE_PROPERTIES_MAP = {\n 'background-color': 'fill',\n 'border-color': 'stroke',\n};\nconst LEGEND_TEXT_STYLE_PROPERTIES_MAP = {\n color: 'fill',\n 'font-family': 'font-family',\n 'font-size': 'font-size',\n 'font-weight': 'font-weight',\n opacity: 'opacity',\n};\n\nfunction cloneLegendsToSVG(chartContainer: HTMLElement, svgWidth: number, svgHeight: number) {\n const legendButtons = chartContainer.querySelectorAll<HTMLElement>(`\n button.fui-legend__legend:not([data-overflowing]),\n .fui-donut__legendContainer button.fui-MenuButton,\n .fui-cart__legendContainer button.fui-MenuButton\n `);\n if (legendButtons.length === 0) {\n return {\n node: null,\n width: 0,\n height: 0,\n };\n }\n\n const legendGroup = d3Create<SVGGElement>('svg:g');\n let legendX = 0;\n let legendY = 8;\n let legendLine: Selection<SVGGElement, unknown, null, undefined>[] = [];\n const legendLines: (typeof legendLine)[] = [];\n const legendLineWidths: number[] = [];\n\n for (let i = 0; i < legendButtons.length; i++) {\n const { width: legendWidth } = legendButtons[i].getBoundingClientRect();\n const legendItem = legendGroup.append('g');\n\n legendLine.push(legendItem);\n if (legendX + legendWidth > svgWidth && legendLine.length > 1) {\n legendLine.pop();\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n\n legendLine = [legendItem];\n legendX = 0;\n legendY += 32;\n }\n\n let legendText: HTMLDivElement | HTMLButtonElement | null;\n let textOffset = 0;\n\n if (!legendButtons[i].hasAttribute('data-overflow-menu')) {\n const legendRect = legendButtons[i].querySelector<HTMLDivElement>('.fui-legend__rect');\n\n legendText = legendButtons[i].querySelector<HTMLDivElement>('.fui-legend__text');\n legendItem\n .append('rect')\n .attr('x', legendX + 8)\n .attr('y', svgHeight + legendY + 8)\n .attr('width', 12)\n .attr('height', 12)\n .attr('stroke-width', 1)\n .call(selection => copyStyle(LEGEND_RECT_STYLE_PROPERTIES_MAP, legendRect!, selection.node()!));\n textOffset = 28;\n } else {\n legendText = legendButtons[i] as HTMLButtonElement;\n // eslint-disable-next-line no-console\n console.log(legendText!.textContent);\n textOffset = 8;\n }\n\n legendItem\n .append('text')\n .attr('x', legendX + textOffset)\n .attr('y', svgHeight + legendY + 8)\n .attr('dominant-baseline', 'hanging')\n .text(legendText!.textContent)\n .call(selection => copyStyle(LEGEND_TEXT_STYLE_PROPERTIES_MAP, legendText!, selection.node()!));\n legendX += legendWidth;\n }\n\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n legendY += 32;\n\n const centerLegends = true;\n if (centerLegends) {\n legendLines.forEach((ln, idx) => {\n const offsetX = Math.max((svgWidth - legendLineWidths[idx]) / 2, 0);\n ln.forEach(item => {\n item.attr('transform', `translate(${offsetX}, 0)`);\n });\n });\n }\n\n return {\n node: legendGroup.node(),\n width: Math.max(...legendLineWidths),\n height: legendY,\n };\n}\n\nfunction svgToPng(svgDataUrl: string, opts: ImageExportOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n const scale = opts.scale || 1;\n const w0 = opts.width || 300;\n const h0 = opts.height || 150;\n const w1 = scale * w0;\n const h1 = scale * h0;\n\n const canvas = document.createElement('canvas');\n const img = new Image();\n\n canvas.width = w1;\n canvas.height = h1;\n\n img.onload = function () {\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return reject(new Error('Canvas context is null'));\n }\n\n ctx.clearRect(0, 0, w1, h1);\n ctx.drawImage(img, 0, 0, w1, h1);\n\n const imgData = canvas.toDataURL('image/png');\n resolve(imgData);\n };\n\n img.onerror = function (err) {\n reject(err);\n };\n\n img.src = svgDataUrl;\n });\n}\n\nconst hex2 = /^[\\da-f]{2}$/i;\nconst hex4 = /^[\\da-f]{4}$/i;\n\n/**\n * A ponyfill for the deprecated `unescape` method, taken from the `core-js` library.\n *\n * Source: {@link https://github.com/zloirock/core-js/blob/167136f479d3b8519953f2e4c534ecdd1031d3cf/packages/core-js/modules/es.unescape.js core-js/packages/core-js/modules/es.unescape.js}\n */\nfunction unescapePonyfill(str: string) {\n let result = '';\n const length = str.length;\n let index = 0;\n let chr;\n let part;\n while (index < length) {\n chr = str.charAt(index++);\n if (chr === '%') {\n if (str.charAt(index) === 'u') {\n part = str.slice(index + 1, index + 5);\n if (hex4.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 5;\n continue;\n }\n } else {\n part = str.slice(index, index + 2);\n if (hex2.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 2;\n continue;\n }\n }\n }\n result += chr;\n }\n return result;\n}\n\nfunction copyStyle(properties: string[] | Record<string, string>, fromEl: Element, toEl: Element) {\n const styles = getComputedStyle(fromEl);\n if (Array.isArray(properties)) {\n properties.forEach(prop => {\n d3Select(toEl).style(prop, styles.getPropertyValue(prop));\n });\n } else {\n Object.entries(properties).forEach(([fromProp, toProp]) => {\n d3Select(toEl).style(toProp, styles.getPropertyValue(fromProp));\n });\n }\n}\n"],"names":["create","d3Create","select","d3Select","resolveCSSVariables","toImage","chartContainer","opts","Promise","resolve","reject","Error","background","svg","toSVG","svgData","XMLSerializer","serializeToString","node","svgDataUrl","btoa","unescapePonyfill","encodeURIComponent","svgToPng","width","height","scale","then","catch","err","SVG_STYLE_PROPERTIES","SVG_TEXT_STYLE_PROPERTIES","querySelector","clonedSvg","cloneNode","attr","svgElements","getElementsByTagName","clonedSvgElements","i","length","tagName","toLowerCase","copyStyle","svgWidth","svgHeight","getBoundingClientRect","legendGroup","cloneLegendsToSVG","w1","Math","max","h1","append","insert","LEGEND_RECT_STYLE_PROPERTIES_MAP","LEGEND_TEXT_STYLE_PROPERTIES_MAP","color","opacity","legendButtons","querySelectorAll","legendX","legendY","legendLine","legendLines","legendLineWidths","legendWidth","legendItem","push","pop","legendText","textOffset","hasAttribute","legendRect","call","selection","console","log","textContent","text","centerLegends","forEach","ln","idx","offsetX","item","w0","h0","canvas","document","createElement","img","Image","onload","ctx","getContext","clearRect","drawImage","imgData","toDataURL","onerror","src","hex2","hex4","str","result","index","chr","part","charAt","slice","exec","String","fromCharCode","parseInt","properties","fromEl","toEl","styles","getComputedStyle","Array","isArray","prop","style","getPropertyValue","Object","entries","fromProp","toProp"],"mappings":";;;;+BAagBK;;;;;;6BAbkD,eAAe;uBAC7C,wBAAwB;AAYrD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O,CAACN,aAAa;QAC7BA,WAAWlC,OAAO,CAACyC,CAAAA;gBACjBvH,mBAAAA,EAASkH,MAAMM,KAAK,CAACD,MAAMJ,OAAOM,gBAAgB,CAACF;QACrD;IACF,OAAO;QACLG,OAAOC,OAAO,CAACX,YAAYlC,OAAO,CAAC,CAAC,CAAC8C,UAAUC,OAAO;gBACpD7H,mBAAAA,EAASkH,MAAMM,KAAK,CAACK,QAAQV,OAAOM,gBAAgB,CAACG;QACvD;IACF;AACF"}
1
+ {"version":3,"sources":["../src/components/DeclarativeChart/imageExporter.ts"],"sourcesContent":["'use client';\n\nimport { create as d3Create, select as d3Select, Selection } from 'd3-selection';\nimport { resolveCSSVariables } from '../../utilities/index';\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface ImageExportOptions {\n width?: number;\n height?: number;\n scale?: number;\n background?: string;\n}\n\nexport function toImage(chartContainer?: HTMLElement | null, opts: ImageExportOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n if (!chartContainer) {\n return reject(new Error('Chart container is not defined'));\n }\n\n try {\n const background =\n typeof opts.background === 'string' ? resolveCSSVariables(chartContainer, opts.background) : 'transparent';\n const svg = toSVG(chartContainer, background);\n\n const svgData = new XMLSerializer().serializeToString(svg.node);\n const svgDataUrl = 'data:image/svg+xml;base64,' + btoa(unescapePonyfill(encodeURIComponent(svgData)));\n\n svgToPng(svgDataUrl, {\n width: opts.width || svg.width,\n height: opts.height || svg.height,\n scale: opts.scale,\n })\n .then(resolve)\n .catch(reject);\n } catch (err) {\n return reject(err);\n }\n });\n}\n\nconst SVG_STYLE_PROPERTIES = ['display', 'fill', 'fill-opacity', 'opacity', 'stroke', 'stroke-width', 'transform'];\nconst SVG_TEXT_STYLE_PROPERTIES = ['font-family', 'font-size', 'font-weight', 'text-anchor'];\n\nfunction toSVG(chartContainer: HTMLElement, background: string) {\n const svg = chartContainer.querySelector<SVGSVGElement>('svg');\n if (!svg) {\n throw new Error('SVG not found');\n }\n\n const clonedSvg = d3Select(svg.cloneNode(true) as SVGSVGElement)\n .attr('width', null)\n .attr('height', null)\n .attr('viewBox', null);\n const svgElements = svg.getElementsByTagName('*');\n const clonedSvgElements = clonedSvg.node()!.getElementsByTagName('*');\n\n for (let i = 0; i < svgElements.length; i++) {\n if (svgElements[i].tagName.toLowerCase() === 'text') {\n copyStyle([...SVG_STYLE_PROPERTIES, ...SVG_TEXT_STYLE_PROPERTIES], svgElements[i], clonedSvgElements[i]);\n } else {\n copyStyle(SVG_STYLE_PROPERTIES, svgElements[i], clonedSvgElements[i]);\n }\n }\n\n const { width: svgWidth, height: svgHeight } = svg.getBoundingClientRect();\n const legendGroup = cloneLegendsToSVG(chartContainer, svgWidth, svgHeight);\n const w1 = Math.max(svgWidth, legendGroup.width);\n const h1 = svgHeight + legendGroup.height;\n\n if (legendGroup.node) {\n clonedSvg.append(() => legendGroup.node);\n }\n clonedSvg\n .insert('rect', ':first-child')\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', w1)\n .attr('height', h1)\n .attr('fill', background);\n clonedSvg.attr('width', w1).attr('height', h1).attr('viewBox', `0 0 ${w1} ${h1}`);\n\n return {\n node: clonedSvg.node()!,\n width: w1,\n height: h1,\n };\n}\n\nconst LEGEND_RECT_STYLE_PROPERTIES_MAP = {\n 'background-color': 'fill',\n 'border-color': 'stroke',\n};\nconst LEGEND_TEXT_STYLE_PROPERTIES_MAP = {\n color: 'fill',\n 'font-family': 'font-family',\n 'font-size': 'font-size',\n 'font-weight': 'font-weight',\n opacity: 'opacity',\n};\n\nfunction cloneLegendsToSVG(chartContainer: HTMLElement, svgWidth: number, svgHeight: number) {\n const legendButtons = chartContainer.querySelectorAll<HTMLElement>(`\n button.fui-legend__legend:not([data-overflowing]),\n .fui-donut__legendContainer button.fui-MenuButton,\n .fui-cart__legendContainer button.fui-MenuButton\n `);\n if (legendButtons.length === 0) {\n return {\n node: null,\n width: 0,\n height: 0,\n };\n }\n\n const legendGroup = d3Create<SVGGElement>('svg:g');\n let legendX = 0;\n let legendY = 8;\n let legendLine: Selection<SVGGElement, unknown, null, undefined>[] = [];\n const legendLines: (typeof legendLine)[] = [];\n const legendLineWidths: number[] = [];\n\n for (let i = 0; i < legendButtons.length; i++) {\n const { width: legendWidth } = legendButtons[i].getBoundingClientRect();\n const legendItem = legendGroup.append('g');\n\n legendLine.push(legendItem);\n if (legendX + legendWidth > svgWidth && legendLine.length > 1) {\n legendLine.pop();\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n\n legendLine = [legendItem];\n legendX = 0;\n legendY += 32;\n }\n\n let legendText: HTMLDivElement | HTMLButtonElement | null;\n let textOffset = 0;\n\n if (!legendButtons[i].hasAttribute('data-overflow-menu')) {\n const legendRect = legendButtons[i].querySelector<HTMLDivElement>('.fui-legend__rect');\n\n legendText = legendButtons[i].querySelector<HTMLDivElement>('.fui-legend__text');\n legendItem\n .append('rect')\n .attr('x', legendX + 8)\n .attr('y', svgHeight + legendY + 8)\n .attr('width', 12)\n .attr('height', 12)\n .attr('stroke-width', 1)\n .call(selection => copyStyle(LEGEND_RECT_STYLE_PROPERTIES_MAP, legendRect!, selection.node()!));\n textOffset = 28;\n } else {\n legendText = legendButtons[i] as HTMLButtonElement;\n // eslint-disable-next-line no-console\n console.log(legendText!.textContent);\n textOffset = 8;\n }\n\n legendItem\n .append('text')\n .attr('x', legendX + textOffset)\n .attr('y', svgHeight + legendY + 8)\n .attr('dominant-baseline', 'hanging')\n .text(legendText!.textContent)\n .call(selection => copyStyle(LEGEND_TEXT_STYLE_PROPERTIES_MAP, legendText!, selection.node()!));\n legendX += legendWidth;\n }\n\n legendLines.push(legendLine);\n legendLineWidths.push(legendX);\n legendY += 32;\n\n const centerLegends = true;\n if (centerLegends) {\n legendLines.forEach((ln, idx) => {\n const offsetX = Math.max((svgWidth - legendLineWidths[idx]) / 2, 0);\n ln.forEach(item => {\n item.attr('transform', `translate(${offsetX}, 0)`);\n });\n });\n }\n\n return {\n node: legendGroup.node(),\n width: Math.max(...legendLineWidths),\n height: legendY,\n };\n}\n\nfunction svgToPng(svgDataUrl: string, opts: ImageExportOptions = {}): Promise<string> {\n return new Promise((resolve, reject) => {\n const scale = opts.scale || 1;\n const w0 = opts.width || 300;\n const h0 = opts.height || 150;\n const w1 = scale * w0;\n const h1 = scale * h0;\n\n const canvas = document.createElement('canvas');\n const img = new Image();\n\n canvas.width = w1;\n canvas.height = h1;\n\n img.onload = function () {\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n return reject(new Error('Canvas context is null'));\n }\n\n ctx.clearRect(0, 0, w1, h1);\n ctx.drawImage(img, 0, 0, w1, h1);\n\n const imgData = canvas.toDataURL('image/png');\n resolve(imgData);\n };\n\n img.onerror = function (err) {\n reject(err);\n };\n\n img.src = svgDataUrl;\n });\n}\n\nconst hex2 = /^[\\da-f]{2}$/i;\nconst hex4 = /^[\\da-f]{4}$/i;\n\n/**\n * A ponyfill for the deprecated `unescape` method, taken from the `core-js` library.\n *\n * Source: {@link https://github.com/zloirock/core-js/blob/167136f479d3b8519953f2e4c534ecdd1031d3cf/packages/core-js/modules/es.unescape.js core-js/packages/core-js/modules/es.unescape.js}\n */\nfunction unescapePonyfill(str: string) {\n let result = '';\n const length = str.length;\n let index = 0;\n let chr;\n let part;\n while (index < length) {\n chr = str.charAt(index++);\n if (chr === '%') {\n if (str.charAt(index) === 'u') {\n part = str.slice(index + 1, index + 5);\n if (hex4.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 5;\n continue;\n }\n } else {\n part = str.slice(index, index + 2);\n if (hex2.exec(part)) {\n result += String.fromCharCode(parseInt(part, 16));\n index += 2;\n continue;\n }\n }\n }\n result += chr;\n }\n return result;\n}\n\nfunction copyStyle(properties: string[] | Record<string, string>, fromEl: Element, toEl: Element) {\n const styles = getComputedStyle(fromEl);\n if (Array.isArray(properties)) {\n properties.forEach(prop => {\n d3Select(toEl).style(prop, styles.getPropertyValue(prop));\n });\n } else {\n Object.entries(properties).forEach(([fromProp, toProp]) => {\n d3Select(toEl).style(toProp, styles.getPropertyValue(fromProp));\n });\n }\n}\n"],"names":["create","d3Create","select","d3Select","resolveCSSVariables","toImage","chartContainer","opts","Promise","resolve","reject","Error","background","svg","toSVG","svgData","XMLSerializer","serializeToString","node","svgDataUrl","btoa","unescapePonyfill","encodeURIComponent","svgToPng","width","height","scale","then","catch","err","SVG_STYLE_PROPERTIES","SVG_TEXT_STYLE_PROPERTIES","querySelector","clonedSvg","cloneNode","attr","svgElements","getElementsByTagName","clonedSvgElements","i","length","tagName","toLowerCase","copyStyle","svgWidth","svgHeight","getBoundingClientRect","legendGroup","cloneLegendsToSVG","w1","Math","max","h1","append","insert","LEGEND_RECT_STYLE_PROPERTIES_MAP","LEGEND_TEXT_STYLE_PROPERTIES_MAP","color","opacity","legendButtons","querySelectorAll","legendX","legendY","legendLine","legendLines","legendLineWidths","legendWidth","legendItem","push","pop","legendText","textOffset","hasAttribute","legendRect","call","selection","console","log","textContent","text","centerLegends","forEach","ln","idx","offsetX","item","w0","h0","canvas","document","createElement","img","Image","onload","ctx","getContext","clearRect","drawImage","imgData","toDataURL","onerror","src","hex2","hex4","str","result","index","chr","part","charAt","slice","exec","String","fromCharCode","parseInt","properties","fromEl","toEl","styles","getComputedStyle","Array","isArray","prop","style","getPropertyValue","Object","entries","fromProp","toProp"],"mappings":"AAAA;;;;;+BAegBK;;;;;;6BAbkD,eAAe;uBAC7C,wBAAwB;AAYrD,iBAAiBC,cAAmC,EAAEC,OAA2B,CAAC,CAAC;IACxF,OAAO,IAAIC,QAAQ,CAACC,SAASC;QAC3B,IAAI,CAACJ,gBAAgB;YACnB,OAAOI,OAAO,IAAIC,MAAM;QAC1B;QAEA,IAAI;YACF,MAAMC,aACJ,OAAOL,KAAKK,UAAU,KAAK,eAAWR,0BAAAA,EAAoBE,gBAAgBC,KAAKK,UAAU,IAAI;YAC/F,MAAMC,MAAMC,MAAMR,gBAAgBM;YAElC,MAAMG,UAAU,IAAIC,gBAAgBC,iBAAiB,CAACJ,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
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
@@ -15,7 +16,7 @@ const _useArcStylesstyles = require("./useArcStyles.styles");
15
16
  const _d3format = require("d3-format");
16
17
  const _index = require("../../../utilities/index");
17
18
  const Arc = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
18
- var _props_data;
19
+ var _props_data, _props_activeArc, _props_data1;
19
20
  const arc = (0, _d3shape.arc)();
20
21
  const currentRef = /*#__PURE__*/ _react.createRef();
21
22
  const _isRTL = (0, _index.useRtl)();
@@ -51,8 +52,8 @@ const Arc = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
51
52
  return !activeArc || activeArc.length === 0 || legend === undefined || activeArc.includes(legend);
52
53
  }
53
54
  function _renderArcLabel(className) {
54
- const { data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels, activeArc } = props;
55
- if (hideLabels || Math.abs(data.endAngle - data.startAngle) < Math.PI / 12 || activeArc !== data.data.legend && activeArc !== '') {
55
+ const { data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels } = props;
56
+ if (hideLabels || Math.abs(data.endAngle - data.startAngle) < Math.PI / 12 || !_shouldHighlightArc(data.data.legend)) {
56
57
  return null;
57
58
  }
58
59
  const [base, perp] = arc.centroid({
@@ -79,10 +80,10 @@ const Arc = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
79
80
  newProps.arc.outerRadius(newProps.outerRadius);
80
81
  }
81
82
  }
82
- const { href, focusedArcId } = props;
83
+ const { href, focusedArcId, activeArc } = props;
83
84
  //TO DO 'replace' is throwing error
84
85
  const id = props.uniqText + (typeof props.data.data.legend === 'string' ? props.data.data.legend.replace(/\s+/g, '') : '') + props.data.data.data;
85
- const opacity = props.activeArc === props.data.data.legend || props.activeArc === '' ? 1 : 0.1;
86
+ const opacity = activeArc && activeArc.length > 0 ? activeArc.includes((_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.data.legend) ? 1 : 0.1 : 1;
86
87
  const cornerRadius = props.roundCorners ? 3 : 0;
87
88
  return /*#__PURE__*/ _react.createElement("g", {
88
89
  ref: currentRef
@@ -109,14 +110,13 @@ const Arc = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
109
110
  cursor: href ? 'pointer' : 'default'
110
111
  },
111
112
  onFocus: (event)=>_onFocus(props.data.data, id, event),
112
- "data-is-focusable": props.activeArc === props.data.data.legend || props.activeArc === '',
113
113
  onMouseOver: (event)=>_hoverOn(props.data.data, event),
114
114
  onMouseMove: (event)=>_hoverOn(props.data.data, event),
115
115
  onMouseLeave: _hoverOff,
116
- tabIndex: _shouldHighlightArc(props.data.data.legend) ? 0 : undefined,
116
+ tabIndex: _shouldHighlightArc(props.data.data.legend) || ((_props_activeArc = props.activeArc) === null || _props_activeArc === void 0 ? void 0 : _props_activeArc.length) === 0 ? 0 : undefined,
117
117
  onBlur: _onBlur,
118
118
  opacity: opacity,
119
- onClick: (_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.data.onClick,
119
+ onClick: (_props_data1 = props.data) === null || _props_data1 === void 0 ? void 0 : _props_data1.data.onClick,
120
120
  "aria-label": _getAriaLabel(),
121
121
  role: "img"
122
122
  }), _renderArcLabel(classes.arcLabel));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DonutChart/Arc/Arc.tsx"],"sourcesContent":["import * as React from 'react';\nimport { arc as d3Arc } from 'd3-shape';\nimport { useArcStyles } from './useArcStyles.styles';\nimport { ChartDataPoint } from '../index';\nimport { ArcProps } from './index';\nimport { format as d3Format } from 'd3-format';\nimport { formatScientificLimitWidth, useRtl } from '../../../utilities/index';\n\n// Create a Arc within Donut Chart variant which uses these default styles and this styled subcomponent.\n/**\n * Arc component within Donut Chart.\n * {@docCategory ArcDonutChart}\n */\nexport const Arc: React.FunctionComponent<ArcProps> = React.forwardRef<HTMLDivElement, ArcProps>(\n (props, forwardedRef) => {\n const arc = d3Arc();\n const currentRef = React.createRef<SVGPathElement>();\n const _isRTL: boolean = useRtl();\n const classes = useArcStyles(props);\n\n React.useEffect(() => {\n _updateChart(props);\n }, [props]);\n\n function _onFocus(data: ChartDataPoint, id: string, event: React.FocusEvent<SVGPathElement, Element>): void {\n props.onFocusCallback!(data, id, event, currentRef.current);\n }\n\n function _hoverOn(data: ChartDataPoint, mouseEvent: React.MouseEvent<SVGPathElement>): void {\n mouseEvent.persist();\n props.hoverOnCallback!(data, mouseEvent);\n }\n\n function _hoverOff(): void {\n props.hoverLeaveCallback!();\n }\n\n function _onBlur(): void {\n props.onBlurCallback!();\n }\n\n function _getAriaLabel(): string {\n const point = props.data!.data;\n const legend = point.xAxisCalloutData || point.legend;\n const yValue = point.yAxisCalloutData || point.data || 0;\n return point.callOutAccessibilityData?.ariaLabel || (legend ? `${legend}, ` : '') + `${yValue}.`;\n }\n\n function _shouldHighlightArc(legend?: string): boolean {\n const { activeArc } = props;\n // If no activeArc is provided, highlight all arcs. Otherwise, only highlight the arcs that are active.\n return !activeArc || activeArc.length === 0 || legend === undefined || activeArc.includes(legend);\n }\n\n function _renderArcLabel(className: string) {\n const { data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels, activeArc } = props;\n\n if (\n hideLabels ||\n Math.abs(data!.endAngle - data!.startAngle) < Math.PI / 12 ||\n (activeArc !== data!.data.legend && activeArc !== '')\n ) {\n return null;\n }\n\n const [base, perp] = arc.centroid({ ...data!, innerRadius, outerRadius });\n const hyp = Math.sqrt(base * base + perp * perp);\n const labelRadius = Math.max(innerRadius!, outerRadius!) + 2;\n const angle = (data!.startAngle + data!.endAngle) / 2;\n const arcValue = data!.value;\n\n return (\n <text\n x={(hyp === 0 ? 0 : base / hyp) * labelRadius}\n y={(hyp === 0 ? 0 : perp / hyp) * labelRadius}\n textAnchor={angle > Math.PI !== _isRTL ? 'end' : 'start'}\n dominantBaseline={angle > Math.PI / 2 && angle < (3 * Math.PI) / 2 ? 'hanging' : 'auto'}\n className={className}\n aria-hidden={true}\n >\n {showLabelsInPercent\n ? d3Format('.0%')(totalValue! === 0 ? 0 : arcValue / totalValue!)\n : formatScientificLimitWidth(arcValue)}\n </text>\n );\n }\n\n function _updateChart(newProps: ArcProps): void {\n if (newProps.arc && newProps.innerRadius && newProps.outerRadius) {\n newProps.arc.innerRadius(newProps.innerRadius);\n newProps.arc.outerRadius(newProps.outerRadius);\n }\n }\n\n const { href, focusedArcId } = props;\n //TO DO 'replace' is throwing error\n const id =\n props.uniqText! +\n (typeof props.data!.data.legend === 'string' ? props.data!.data.legend.replace(/\\s+/g, '') : '') +\n props.data!.data.data;\n const opacity: number = props.activeArc === props.data!.data.legend || props.activeArc === '' ? 1 : 0.1;\n const cornerRadius = props.roundCorners ? 3 : 0;\n return (\n <g ref={currentRef}>\n {!!focusedArcId && focusedArcId === id && (\n // TODO innerradius and outerradius were absent\n <path\n id={id + 'focusRing'}\n d={\n arc.cornerRadius(cornerRadius)({\n ...props.data!,\n innerRadius: props.innerRadius,\n outerRadius: props.outerRadius,\n })!\n }\n className={classes.focusRing}\n />\n )}\n <path\n // TODO innerradius and outerradius were absent\n id={id}\n d={\n arc.cornerRadius(cornerRadius)({\n ...props.data!,\n innerRadius: props.innerRadius,\n outerRadius: props.outerRadius,\n })!\n }\n className={classes.root}\n style={{ fill: props.color, cursor: href ? 'pointer' : 'default' }}\n onFocus={event => _onFocus(props.data!.data, id, event)}\n data-is-focusable={props.activeArc === props.data!.data.legend || props.activeArc === ''}\n onMouseOver={event => _hoverOn(props.data!.data, event)}\n onMouseMove={event => _hoverOn(props.data!.data, event)}\n onMouseLeave={_hoverOff}\n tabIndex={_shouldHighlightArc(props.data!.data.legend!) ? 0 : undefined}\n onBlur={_onBlur}\n opacity={opacity}\n onClick={props.data?.data.onClick}\n aria-label={_getAriaLabel()}\n role=\"img\"\n />\n {_renderArcLabel(classes.arcLabel)}\n </g>\n );\n },\n);\nArc.displayName = 'Arc';\n"],"names":["React","arc","d3Arc","useArcStyles","format","d3Format","formatScientificLimitWidth","useRtl","Arc","forwardRef","props","forwardedRef","currentRef","createRef","_isRTL","classes","useEffect","_updateChart","_onFocus","data","id","event","onFocusCallback","current","_hoverOn","mouseEvent","persist","hoverOnCallback","_hoverOff","hoverLeaveCallback","_onBlur","onBlurCallback","_getAriaLabel","point","legend","xAxisCalloutData","yValue","yAxisCalloutData","callOutAccessibilityData","ariaLabel","_shouldHighlightArc","activeArc","length","undefined","includes","_renderArcLabel","className","innerRadius","outerRadius","showLabelsInPercent","totalValue","hideLabels","Math","abs","endAngle","startAngle","PI","base","perp","centroid","hyp","sqrt","labelRadius","max","angle","arcValue","value","text","x","y","textAnchor","dominantBaseline","aria-hidden","newProps","href","focusedArcId","uniqText","replace","opacity","cornerRadius","roundCorners","g","ref","path","d","focusRing","root","style","fill","color","cursor","onFocus","data-is-focusable","onMouseOver","onMouseMove","onMouseLeave","tabIndex","onBlur","onClick","aria-label","role","arcLabel","displayName"],"mappings":";;;;+BAaaQ;;;;;;;iEAbU,QAAQ;yBACF,WAAW;oCACX,wBAAwB;0BAGlB,YAAY;uBACI,2BAA2B;AAOvE,YAAMA,WAAAA,GAAyCR,OAAMS,UAAU,CACpE,CAACC,OAAOC;QA4HSD;IA3Hf,MAAMT,UAAMC,YAAAA;IACZ,MAAMU,aAAAA,WAAAA,GAAaZ,OAAMa,SAAS;IAClC,MAAMC,aAAkBP,aAAAA;IACxB,MAAMQ,cAAUZ,gCAAAA,EAAaO;IAE7BV,OAAMgB,SAAS,CAAC;QACdC,aAAaP;IACf,GAAG;QAACA;KAAM;IAEV,SAASQ,SAASC,IAAoB,EAAEC,EAAU,EAAEC,KAAgD;QAClGX,MAAMY,eAAe,CAAEH,MAAMC,IAAIC,OAAOT,WAAWW,OAAO;IAC5D;IAEA,SAASC,SAASL,IAAoB,EAAEM,UAA4C;QAClFA,WAAWC,OAAO;QAClBhB,MAAMiB,eAAe,CAAER,MAAMM;IAC/B;IAEA,SAASG;QACPlB,MAAMmB,kBAAkB;IAC1B;IAEA,SAASC;QACPpB,MAAMqB,cAA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AAO;QACjCC,cAAYnE;QACZoE,MAAK;QAENvD,gBAAgB9B,QAAQsF,QAAQ;AAGvC,GACA;AACF7F,IAAI8F,WAAW,GAAG"}
1
+ {"version":3,"sources":["../src/components/DonutChart/Arc/Arc.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { arc as d3Arc } from 'd3-shape';\nimport { useArcStyles } from './useArcStyles.styles';\nimport { ChartDataPoint } from '../index';\nimport { ArcProps } from './index';\nimport { format as d3Format } from 'd3-format';\nimport { formatScientificLimitWidth, useRtl } from '../../../utilities/index';\n\n// Create a Arc within Donut Chart variant which uses these default styles and this styled subcomponent.\n/**\n * Arc component within Donut Chart.\n * {@docCategory ArcDonutChart}\n */\nexport const Arc: React.FunctionComponent<ArcProps> = React.forwardRef<HTMLDivElement, ArcProps>(\n (props, forwardedRef) => {\n const arc = d3Arc();\n const currentRef = React.createRef<SVGPathElement>();\n const _isRTL: boolean = useRtl();\n const classes = useArcStyles(props);\n\n React.useEffect(() => {\n _updateChart(props);\n }, [props]);\n\n function _onFocus(data: ChartDataPoint, id: string, event: React.FocusEvent<SVGPathElement, Element>): void {\n props.onFocusCallback!(data, id, event, currentRef.current);\n }\n\n function _hoverOn(data: ChartDataPoint, mouseEvent: React.MouseEvent<SVGPathElement>): void {\n mouseEvent.persist();\n props.hoverOnCallback!(data, mouseEvent);\n }\n\n function _hoverOff(): void {\n props.hoverLeaveCallback!();\n }\n\n function _onBlur(): void {\n props.onBlurCallback!();\n }\n\n function _getAriaLabel(): string {\n const point = props.data!.data;\n const legend = point.xAxisCalloutData || point.legend;\n const yValue = point.yAxisCalloutData || point.data || 0;\n return point.callOutAccessibilityData?.ariaLabel || (legend ? `${legend}, ` : '') + `${yValue}.`;\n }\n\n function _shouldHighlightArc(legend?: string): boolean {\n const { activeArc } = props;\n // If no activeArc is provided, highlight all arcs. Otherwise, only highlight the arcs that are active.\n return !activeArc || activeArc.length === 0 || legend === undefined || activeArc.includes(legend);\n }\n\n function _renderArcLabel(className: string) {\n const { data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels } = props;\n\n if (\n hideLabels ||\n Math.abs(data!.endAngle - data!.startAngle) < Math.PI / 12 ||\n !_shouldHighlightArc(data!.data.legend!)\n ) {\n return null;\n }\n\n const [base, perp] = arc.centroid({ ...data!, innerRadius, outerRadius });\n const hyp = Math.sqrt(base * base + perp * perp);\n const labelRadius = Math.max(innerRadius!, outerRadius!) + 2;\n const angle = (data!.startAngle + data!.endAngle) / 2;\n const arcValue = data!.value;\n\n return (\n <text\n x={(hyp === 0 ? 0 : base / hyp) * labelRadius}\n y={(hyp === 0 ? 0 : perp / hyp) * labelRadius}\n textAnchor={angle > Math.PI !== _isRTL ? 'end' : 'start'}\n dominantBaseline={angle > Math.PI / 2 && angle < (3 * Math.PI) / 2 ? 'hanging' : 'auto'}\n className={className}\n aria-hidden={true}\n >\n {showLabelsInPercent\n ? d3Format('.0%')(totalValue! === 0 ? 0 : arcValue / totalValue!)\n : formatScientificLimitWidth(arcValue)}\n </text>\n );\n }\n\n function _updateChart(newProps: ArcProps): void {\n if (newProps.arc && newProps.innerRadius && newProps.outerRadius) {\n newProps.arc.innerRadius(newProps.innerRadius);\n newProps.arc.outerRadius(newProps.outerRadius);\n }\n }\n\n const { href, focusedArcId, activeArc } = props;\n //TO DO 'replace' is throwing error\n const id =\n props.uniqText! +\n (typeof props.data!.data.legend === 'string' ? props.data!.data.legend.replace(/\\s+/g, '') : '') +\n props.data!.data.data;\n const opacity: number =\n activeArc && activeArc.length > 0 ? (activeArc.includes(props.data?.data.legend!) ? 1 : 0.1) : 1;\n const cornerRadius = props.roundCorners ? 3 : 0;\n return (\n <g ref={currentRef}>\n {!!focusedArcId && focusedArcId === id && (\n // TODO innerradius and outerradius were absent\n <path\n id={id + 'focusRing'}\n d={\n arc.cornerRadius(cornerRadius)({\n ...props.data!,\n innerRadius: props.innerRadius,\n outerRadius: props.outerRadius,\n })!\n }\n className={classes.focusRing}\n />\n )}\n <path\n // TODO innerradius and outerradius were absent\n id={id}\n d={\n arc.cornerRadius(cornerRadius)({\n ...props.data!,\n innerRadius: props.innerRadius,\n outerRadius: props.outerRadius,\n })!\n }\n className={classes.root}\n style={{ fill: props.color, cursor: href ? 'pointer' : 'default' }}\n onFocus={event => _onFocus(props.data!.data, id, event)}\n onMouseOver={event => _hoverOn(props.data!.data, event)}\n onMouseMove={event => _hoverOn(props.data!.data, event)}\n onMouseLeave={_hoverOff}\n tabIndex={_shouldHighlightArc(props.data!.data.legend!) || props.activeArc?.length === 0 ? 0 : undefined}\n onBlur={_onBlur}\n opacity={opacity}\n onClick={props.data?.data.onClick}\n aria-label={_getAriaLabel()}\n role=\"img\"\n />\n {_renderArcLabel(classes.arcLabel)}\n </g>\n );\n },\n);\nArc.displayName = 'Arc';\n"],"names":["React","arc","d3Arc","useArcStyles","format","d3Format","formatScientificLimitWidth","useRtl","Arc","forwardRef","props","forwardedRef","currentRef","createRef","_isRTL","classes","useEffect","_updateChart","_onFocus","data","id","event","onFocusCallback","current","_hoverOn","mouseEvent","persist","hoverOnCallback","_hoverOff","hoverLeaveCallback","_onBlur","onBlurCallback","_getAriaLabel","point","legend","xAxisCalloutData","yValue","yAxisCalloutData","callOutAccessibilityData","ariaLabel","_shouldHighlightArc","activeArc","length","undefined","includes","_renderArcLabel","className","innerRadius","outerRadius","showLabelsInPercent","totalValue","hideLabels","Math","abs","endAngle","startAngle","PI","base","perp","centroid","hyp","sqrt","labelRadius","max","angle","arcValue","value","text","x","y","textAnchor","dominantBaseline","aria-hidden","newProps","href","focusedArcId","uniqText","replace","opacity","cornerRadius","roundCorners","g","ref","path","d","focusRing","root","style","fill","color","cursor","onFocus","onMouseOver","onMouseMove","onMouseLeave","tabIndex","onBlur","onClick","aria-label","role","arcLabel","displayName"],"mappings":"AAAA;;;;;+BAeaQ;;;;;;;iEAbU,QAAQ;yBACF,WAAW;oCACX,wBAAwB;0BAGlB,YAAY;uBACI,2BAA2B;AAOvE,YAAMA,WAAA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,IAAI;QACvBC,OAAO;YAAEC,MAAM9E,MAAM+E,KAAK;YAAEC,QAAQhB,OAAO,YAAY;QAAU;QACjEiB,SAAStE,CAAAA,QAASH,SAASR,MAAMS,IAAI,CAAEA,IAAI,EAAEC,IAAIC;QACjDuE,aAAavE,CAAAA,QAASG,SAASd,MAAMS,IAAI,CAAEA,IAAI,EAAEE;QACjDwE,aAAaxE,CAAAA,QAASG,SAASd,MAAMS,IAAI,CAAEA,IAAI,EAAEE;QACjDyE,cAAclE;QACdmE,UAAUvD,oBAAoB9B,MAAMS,IAAI,CAAEA,IAAI,CAACe,MAAM,KAAMxB,CAAAA,CAAAA,mBAAAA,MAAM+B,SAAAA,AAAS,MAAA,QAAf/B,qBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,iBAAiBgC,MAAAA,AAAM,MAAK,IAAI,IAAIC;QAC/FqD,QAAQlE;QACRgD,SAASA;QACTmB,OAAO,EAAA,CAAEvF,eAAAA,MAAMS,IAAAA,AAAI,MAAA,QAAVT,iBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,aAAYS,IAAI,CAAC8E,OAAO;QACjCC,cAAYlE;QACZmE,MAAK;QAENtD,gBAAgB9B,QAAQqF,QAAQ;AAGvC,GACA;AACF5F,IAAI6F,WAAW,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DonutChart/Arc/Arc.types.ts"],"sourcesContent":["import { ChartDataPoint } from '../index';\nexport interface ArcProps {\n /**\n * Data to render in the Arc.\n */\n data?: ArcData;\n\n /**\n * Data to render focused Arc\n */\n focusData?: ArcData;\n\n /**\n * id of the focused arc\n */\n focusedArcId?: string;\n /**\n * shape for Arc.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n arc?: any;\n\n /**\n * innerRadius of the Arc.\n */\n innerRadius: number;\n\n /**\n * outerRadius of the Arc.\n */\n outerRadius: number;\n\n /**\n * Color for the Arc.\n */\n color: string;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n hoverOnCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n onFocusCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n onBlurCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n hoverLeaveCallback?: Function;\n\n /**\n * Uniq string for chart\n */\n uniqText?: string;\n\n /**\n * string for callout id\n */\n calloutId?: string;\n\n /**\n * Active Arc for chart\n */\n activeArc?: 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 * Prop to show the arc labels in percentage format\n */\n showLabelsInPercent?: boolean;\n\n /**\n * Prop used to define the sum of all arc values\n */\n totalValue?: number;\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?: ArcStyles;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Prop to enable the round corners in the chart\n * @default false\n */\n roundCorners?: boolean;\n}\n\nexport interface ArcData {\n /**\n * Data to render in the chart for individual arc.\n */\n data: ChartDataPoint;\n /**\n * endAngle of the Arc\n */\n endAngle: number;\n /**\n * index of the Arc\n */\n index: number;\n /**\n * padAngle of the Arc\n */\n padAngle: number;\n /**\n * startAngle of the Arc\n */\n startAngle: number;\n /**\n * value of the Arc\n */\n value: number;\n}\n\nexport interface ArcStyles {\n /**\n * Style set for the card header component root\n */\n root: string;\n\n /**\n * styles for the focus\n */\n focusRing: string;\n\n /**\n * Style for the arc labels\n */\n arcLabel: string;\n}\n"],"names":[],"mappings":""}
1
+ {"version":3,"sources":["../src/components/DonutChart/Arc/Arc.types.ts"],"sourcesContent":["import { ChartDataPoint } from '../index';\nexport interface ArcProps {\n /**\n * Data to render in the Arc.\n */\n data?: ArcData;\n\n /**\n * Data to render focused Arc\n */\n focusData?: ArcData;\n\n /**\n * id of the focused arc\n */\n focusedArcId?: string;\n /**\n * shape for Arc.\n */\n /* eslint-disable @typescript-eslint/no-explicit-any */\n arc?: any;\n\n /**\n * innerRadius of the Arc.\n */\n innerRadius: number;\n\n /**\n * outerRadius of the Arc.\n */\n outerRadius: number;\n\n /**\n * Color for the Arc.\n */\n color: string;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n hoverOnCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering over the legend\n */\n onFocusCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n onBlurCallback?: Function;\n\n /**\n * Defines the function that is executed upon hovering Leave the legend\n */\n hoverLeaveCallback?: Function;\n\n /**\n * Uniq string for chart\n */\n uniqText?: string;\n\n /**\n * string for callout id\n */\n calloutId?: string;\n\n /**\n * Active Arc for chart\n */\n activeArc?: 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 * Prop to show the arc labels in percentage format\n */\n showLabelsInPercent?: boolean;\n\n /**\n * Prop used to define the sum of all arc values\n */\n totalValue?: number;\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?: ArcStyles;\n\n /**\n * Additional CSS class(es) to apply to the Chart.\n */\n className?: string;\n\n /**\n * Prop to enable the round corners in the chart\n * @default false\n */\n roundCorners?: boolean;\n}\n\nexport interface ArcData {\n /**\n * Data to render in the chart for individual arc.\n */\n data: ChartDataPoint;\n /**\n * endAngle of the Arc\n */\n endAngle: number;\n /**\n * index of the Arc\n */\n index: number;\n /**\n * padAngle of the Arc\n */\n padAngle: number;\n /**\n * startAngle of the Arc\n */\n startAngle: number;\n /**\n * value of the Arc\n */\n value: number;\n}\n\nexport interface ArcStyles {\n /**\n * Style set for the card header component root\n */\n root: string;\n\n /**\n * styles for the focus\n */\n focusRing: string;\n\n /**\n * Style for the arc labels\n */\n arcLabel: string;\n}\n"],"names":[],"mappings":""}
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
@@ -53,7 +54,8 @@ const donutArcClassNames = {
53
54
  Be2twd7: "fy9rknc",
54
55
  Bhrd7zp: "fl43uef",
55
56
  Bg96gwp: "fwrc4pm",
56
- Bkfmm31: "fhuob2q"
57
+ Bkfmm31: "fhuob2q",
58
+ Bpvj6i6: "f1l20po4"
57
59
  }
58
60
  }, {
59
61
  d: [
@@ -77,6 +79,14 @@ const donutArcClassNames = {
77
79
  ".fl43uef{font-weight:var(--fontWeightSemibold);}",
78
80
  ".fwrc4pm{line-height:var(--lineHeightBase200);}",
79
81
  ".fhuob2q{fill:var(--colorNeutralForeground1);}"
82
+ ],
83
+ m: [
84
+ [
85
+ "@media screen and (-ms-high-contrast: active),screen and (forced-colors: active){.f1l20po4{stroke:CanvasText;}}",
86
+ {
87
+ m: "screen and (-ms-high-contrast: active), screen and (forced-colors: active)"
88
+ }
89
+ ]
80
90
  ]
81
91
  });
82
92
  const useArcStyles = (props)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["useArcStyles.styles.js"],"sourcesContent":["import { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\n/**\n * @internal\n */ export const donutArcClassNames = {\n root: 'fui-donut-arc__root',\n focusRing: 'fui-donut-arc__focusRing',\n arcLabel: 'fui-donut-arc__arcLabel'\n};\n/**\n * Base Styles\n */ const useStyles = makeStyles({\n root: {\n cursor: 'default',\n outline: 'transparent',\n stroke: tokens.colorNeutralBackground1,\n '& selectors': {\n '::-moz-focus-inner': {\n ...shorthands.border('0')\n }\n }\n },\n focusRing: {\n stroke: tokens.colorStrokeFocus2,\n strokeWidth: tokens.strokeWidthThickest,\n fill: 'transparent'\n },\n arcLabel: {\n ...typographyStyles.caption1Strong,\n fill: tokens.colorNeutralForeground1\n }\n});\n/**\n * Apply styling to the Arc components\n */ export const useArcStyles = (props)=>{\n var _props_styles, _props_styles1, _props_styles2;\n const { className } = props;\n const baseStyles = useStyles();\n return {\n root: mergeClasses(donutArcClassNames.root, baseStyles.root, className, (_props_styles = props.styles) === null || _props_styles === void 0 ? void 0 : _props_styles.root),\n focusRing: mergeClasses(donutArcClassNames.focusRing, baseStyles.focusRing, (_props_styles1 = props.styles) === null || _props_styles1 === void 0 ? void 0 : _props_styles1.focusRing),\n arcLabel: mergeClasses(donutArcClassNames.arcLabel, baseStyles.arcLabel, (_props_styles2 = props.styles) === null || _props_styles2 === void 0 ? void 0 : _props_styles2.arcLabel)\n };\n};\n"],"names":["__styles","mergeClasses","shorthands","tokens","typographyStyles","donutArcClassNames","root","focusRing","arcLabel","useStyles","Bceei9c","Bw0xxkn","oeaueh","Bpd4iqm","Befb4lg","ojy3ng","B4ncu3z","zxy5zd","bkw2yb","Bjksbd0","Be5yapy","Bkfmm31","Bahqtrf","Be2twd7","Bhrd7zp","Bg96gwp","d","p","useArcStyles","props","_props_styles","_props_styles1","_props_styles2","className","baseStyles","styles"],"mappings":";;;;;;;;;;;IAIiBK,kBAAkB;;;gBA8BN;eAAZuB;;;uBAlCoC,gBAAgB;AAI1D,2BAA2B;IAClCtB,IAAI,EAAE,qBAAqB;IAC3BC,SAAS,EAAE,0BAA0B;IACrCC,QAAQ,EAAE;AACd,CAAC;AACD;;CAEA,GAAI,MAAMC,SAAS,GAAA,WAAA,OAAGT,eAAA,EAAA;IAAAM,IAAA,EAAA;QAAAI,OAAA,EAAA;QAAAC,OAAA,EAAA;QAAAC,MAAA,EAAA;QAAAC,OAAA,EAAA;QAAAC,OAAA,EAAA;QAAAC,MAAA,EAAA;QAAAC,OAAA,EAAA;QAAAC,MAAA,EAAA;YAAA;YAAA;SAAA;QAAAC,MAAA,EAAA;QAAAC,OAAA,EAAA;YAAA;YAAA;SAAA;IAAA;IAAAZ,SAAA,EAAA;QAAAQ,MAAA,EAAA;QAAAK,OAAA,EAAA;QAAAC,OAAA,EAAA;IAAA;IAAAb,QAAA,EA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Styles.styles.js"],"sourcesContent":["'use client';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport { HighContrastSelector } from '../../../utilities/utilities';\n/**\n * @internal\n */ export const donutArcClassNames = {\n root: 'fui-donut-arc__root',\n focusRing: 'fui-donut-arc__focusRing',\n arcLabel: 'fui-donut-arc__arcLabel'\n};\n/**\n * Base Styles\n */ const useStyles = makeStyles({\n root: {\n cursor: 'default',\n outline: 'transparent',\n stroke: tokens.colorNeutralBackground1,\n '& selectors': {\n '::-moz-focus-inner': {\n ...shorthands.border('0')\n }\n }\n },\n focusRing: {\n stroke: tokens.colorStrokeFocus2,\n strokeWidth: tokens.strokeWidthThickest,\n fill: 'transparent'\n },\n arcLabel: {\n ...typographyStyles.caption1Strong,\n fill: tokens.colorNeutralForeground1,\n [HighContrastSelector]: {\n stroke: 'CanvasText'\n }\n }\n});\n/**\n * Apply styling to the Arc components\n */ export const useArcStyles = (props)=>{\n var _props_styles, _props_styles1, _props_styles2;\n const { className } = props;\n const baseStyles = useStyles();\n return {\n root: mergeClasses(donutArcClassNames.root, baseStyles.root, className, (_props_styles = props.styles) === null || _props_styles === void 0 ? void 0 : _props_styles.root),\n focusRing: mergeClasses(donutArcClassNames.focusRing, baseStyles.focusRing, (_props_styles1 = props.styles) === null || _props_styles1 === void 0 ? void 0 : _props_styles1.focusRing),\n arcLabel: mergeClasses(donutArcClassNames.arcLabel, baseStyles.arcLabel, (_props_styles2 = props.styles) === null || _props_styles2 === void 0 ? void 0 : _props_styles2.arcLabel)\n };\n};\n"],"names":["__styles","mergeClasses","shorthands","tokens","typographyStyles","HighContrastSelector","donutArcClassNames","root","focusRing","arcLabel","useStyles","Bceei9c","Bw0xxkn","oeaueh","Bpd4iqm","Befb4lg","ojy3ng","B4ncu3z","zxy5zd","bkw2yb","Bjksbd0","Be5yapy","Bkfmm31","Bahqtrf","Be2twd7","Bhrd7zp","Bg96gwp","Bpvj6i6","d","p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C9B,OAAO;QACHH,IAAI,MAAEN,mBAAY,EAACK,kBAAkB,CAACC,IAAI,EAAE8B,UAAU,CAAC9B,IAAI,EAAE6B,SAAS,EAAE,CAACH,aAAa,GAAGD,KAAK,CAACM,MAAAA,AAAM,MAAM,IAAI,IAAIL,aAAa,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,aAAa,CAAC1B,IAAI,CAAC;QAC1KC,SAAS,MAAEP,mBAAY,EAACK,kBAAkB,CAACE,SAAS,EAAE6B,UAAU,CAAC7B,SAAS,EAAE,CAAC0B,cAAc,GAAGF,KAAK,CAACM,MAAM,AAANA,MAAY,IAAI,IAAIJ,cAAc,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,cAAc,CAAC1B,SAAS,CAAC;QACtLC,QAAQ,MAAER,mBAAY,EAACK,kBAAkB,CAACG,QAAQ,EAAE4B,UAAU,CAAC5B,QAAQ,EAAE,CAAC0B,cAAc,GAAGH,KAAK,CAACM,MAAAA,AAAM,MAAM,IAAI,IAAIH,cAAc,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,cAAc,CAAC1B,QAAQ;IACrL,CAAC;AACL,CAAC"}
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
@@ -18,6 +19,7 @@ _export(exports, {
18
19
  });
19
20
  const _react = require("@griffel/react");
20
21
  const _reacttheme = require("@fluentui/react-theme");
22
+ const _utilities = require("../../../utilities/utilities");
21
23
  const donutArcClassNames = {
22
24
  root: 'fui-donut-arc__root',
23
25
  focusRing: 'fui-donut-arc__focusRing',
@@ -43,7 +45,10 @@ const donutArcClassNames = {
43
45
  },
44
46
  arcLabel: {
45
47
  ..._reacttheme.typographyStyles.caption1Strong,
46
- fill: _reacttheme.tokens.colorNeutralForeground1
48
+ fill: _reacttheme.tokens.colorNeutralForeground1,
49
+ [_utilities.HighContrastSelector]: {
50
+ stroke: 'CanvasText'
51
+ }
47
52
  }
48
53
  });
49
54
  const useArcStyles = (props)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DonutChart/Arc/useArcStyles.styles.ts"],"sourcesContent":["import { ArcProps, ArcStyles } from './Arc.types';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\n\n/**\n * @internal\n */\nexport const donutArcClassNames: SlotClassNames<ArcStyles> = {\n root: 'fui-donut-arc__root',\n focusRing: 'fui-donut-arc__focusRing',\n arcLabel: 'fui-donut-arc__arcLabel',\n};\n\n/**\n * Base Styles\n */\nconst useStyles = makeStyles({\n root: {\n cursor: 'default',\n outline: 'transparent',\n stroke: tokens.colorNeutralBackground1,\n '& selectors': {\n '::-moz-focus-inner': {\n ...shorthands.border('0'),\n },\n },\n },\n focusRing: {\n stroke: tokens.colorStrokeFocus2,\n strokeWidth: tokens.strokeWidthThickest,\n fill: 'transparent',\n },\n arcLabel: {\n ...typographyStyles.caption1Strong,\n fill: tokens.colorNeutralForeground1,\n },\n});\n\n/**\n * Apply styling to the Arc components\n */\nexport const useArcStyles = (props: ArcProps): ArcStyles => {\n const { className } = props;\n const baseStyles = useStyles();\n\n return {\n root: mergeClasses(donutArcClassNames.root, baseStyles.root, className, props.styles?.root),\n focusRing: mergeClasses(donutArcClassNames.focusRing, baseStyles.focusRing, props.styles?.focusRing),\n arcLabel: mergeClasses(donutArcClassNames.arcLabel, baseStyles.arcLabel, props.styles?.arcLabel),\n };\n};\n"],"names":["makeStyles","mergeClasses","shorthands","tokens","typographyStyles","donutArcClassNames","root","focusRing","arcLabel","useStyles","cursor","outline","stroke","colorNeutralBackground1","border","colorStrokeFocus2","strokeWidth","strokeWidthThickest","fill","caption1Strong","colorNeutralForeground1","useArcStyles","props","className","baseStyles","styles"],"mappings":";;;;;;;;;;;IAQaK,kBAAAA;;;IAkCAgB,YAAAA;;;;uBAzCwC,iBA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esContent":["'use client';\n\nimport { ArcProps, ArcStyles } from './Arc.types';\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { tokens, typographyStyles } from '@fluentui/react-theme';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { HighContrastSelector } from '../../../utilities/utilities';\n\n/**\n * @internal\n */\nexport const donutArcClassNames: SlotClassNames<ArcStyles> = {\n root: 'fui-donut-arc__root',\n focusRing: 'fui-donut-arc__focusRing',\n arcLabel: 'fui-donut-arc__arcLabel',\n};\n\n/**\n * Base Styles\n */\nconst useStyles = makeStyles({\n root: {\n cursor: 'default',\n outline: 'transparent',\n stroke: tokens.colorNeutralBackground1,\n '& selectors': {\n '::-moz-focus-inner': {\n ...shorthands.border('0'),\n },\n },\n },\n focusRing: {\n stroke: tokens.colorStrokeFocus2,\n strokeWidth: tokens.strokeWidthThickest,\n fill: 'transparent',\n },\n arcLabel: {\n ...typographyStyles.caption1Strong,\n fill: tokens.colorNeutralForeground1,\n [HighContrastSelector]: {\n stroke: 'CanvasText',\n },\n },\n});\n\n/**\n * Apply styling to the Arc components\n */\nexport const useArcStyles = (props: ArcProps): ArcStyles => {\n const { className } = props;\n const baseStyles = useStyles();\n\n return {\n root: mergeClasses(donutArcClassNames.root, baseStyles.root, className, props.styles?.root),\n focusRing: mergeClasses(donutArcClassNames.focusRing, baseStyles.focusRing, props.styles?.focusRing),\n arcLabel: mergeClasses(donutArcClassNames.arcLabel, baseStyles.arcLabel, props.styles?.arcLabel),\n };\n};\n"],"names":["makeStyles","mergeClasses","shorthands","tokens","typographyStyles","HighContrastSelector","donutArcClassNames","root","focusRing","arcLabel","useStyles","cursor","outline","stroke","colorNeutralBackground1","border","colorStrokeFocus2","strokeWidth","strokeWidthThickest","fill","caption1Strong","colorNeutralForeground1","useArcStyles","props","className","baseStyles","styles"],"mappings":"AAAA;;;;;;;;;;;;IAWaM,kBAAAA;;;gBAqCAgB;eAAAA;;;uBA7CwC,iBAAiB;4BAC7B,wBAAwB;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-1,4 +1,5 @@
1
- /* eslint-disable react/jsx-no-bind */ "use strict";
1
+ 'use client';
2
+ "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
4
5
  });
@@ -21,6 +22,7 @@ const _ChartPopover = require("../CommonComponents/ChartPopover");
21
22
  const _imageexportutils = require("../../utilities/image-export-utils");
22
23
  const MIN_LEGEND_CONTAINER_HEIGHT = 40;
23
24
  const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
25
+ var _props_legendProps;
24
26
  const _rootElem = _react.useRef(null);
25
27
  const _uniqText = (0, _reactutilities.useId)('_Pie_');
26
28
  /* eslint-disable @typescript-eslint/no-explicit-any */ let _calloutAnchorPoint;
@@ -31,11 +33,11 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
31
33
  const [legend, setLegend] = _react.useState('');
32
34
  const [_width, setWidth] = _react.useState(props.width || 200);
33
35
  const [_height, setHeight] = _react.useState(props.height || 200);
34
- const [activeLegend, setActiveLegend] = _react.useState('');
36
+ const [activeLegend, setActiveLegend] = _react.useState(undefined);
35
37
  const [color, setColor] = _react.useState('');
36
38
  const [xCalloutValue, setXCalloutValue] = _react.useState('');
37
39
  const [yCalloutValue, setYCalloutValue] = _react.useState('');
38
- const [selectedLegend, setSelectedLegend] = _react.useState('');
40
+ const [selectedLegends, setSelectedLegends] = _react.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
39
41
  const [focusedArcId, setFocusedArcId] = _react.useState('');
40
42
  const [dataPointCalloutProps, setDataPointCalloutProps] = _react.useState();
41
43
  const [clickPosition, setClickPosition] = _react.useState({
@@ -43,11 +45,25 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
43
45
  y: 0
44
46
  });
45
47
  const [isPopoverOpen, setPopoverOpen] = _react.useState(false);
48
+ const prevPropsRef = _react.useRef(null);
46
49
  const _legendsRef = _react.useRef(null);
47
50
  const _isRTL = (0, _index1.useRtl)();
48
51
  _react.useEffect(()=>{
49
52
  _fitParentContainer();
50
53
  }, []);
54
+ _react.useEffect(()=>{
55
+ if (prevPropsRef.current) {
56
+ var _prevProps_legendProps, _props_legendProps;
57
+ const prevProps = prevPropsRef.current;
58
+ if (!(0, _index1.areArraysEqual)((_prevProps_legendProps = prevProps.legendProps) === null || _prevProps_legendProps === void 0 ? void 0 : _prevProps_legendProps.selectedLegends, (_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends)) {
59
+ var _props_legendProps1;
60
+ setSelectedLegends(((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegends) || []);
61
+ }
62
+ }
63
+ prevPropsRef.current = props;
64
+ }, [
65
+ props
66
+ ]);
51
67
  _react.useEffect(()=>{
52
68
  if (prevSize.current.height !== props.height || prevSize.current.width !== props.width) {
53
69
  _fitParentContainer();
@@ -88,19 +104,12 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
88
104
  const legend = {
89
105
  title: point.legend,
90
106
  color,
91
- action: ()=>{
92
- if (selectedLegend === point.legend) {
93
- setSelectedLegend('');
94
- } else {
95
- setSelectedLegend(point.legend);
96
- }
97
- },
98
107
  hoverAction: ()=>{
99
108
  _handleChartMouseLeave();
100
109
  setActiveLegend(point.legend);
101
110
  },
102
111
  onMouseOutAction: ()=>{
103
- setActiveLegend('');
112
+ setActiveLegend(undefined);
104
113
  }
105
114
  };
106
115
  return legend;
@@ -110,10 +119,23 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
110
119
  centerLegends: true,
111
120
  overflowText: props.legendsOverflowText,
112
121
  ...props.legendProps,
122
+ // eslint-disable-next-line react/jsx-no-bind
123
+ onChange: _onLegendSelectionChange,
113
124
  legendRef: _legendsRef
114
125
  });
115
126
  return legends;
116
127
  }
128
+ function _onLegendSelectionChange(selectedLegends, event, currentLegend) {
129
+ var _props_legendProps, _props_legendProps1;
130
+ if (props.legendProps && ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends)) {
131
+ setSelectedLegends(selectedLegends);
132
+ } else {
133
+ setSelectedLegends(selectedLegends.slice(-1));
134
+ }
135
+ if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
136
+ props.legendProps.onChange(selectedLegends, event, currentLegend);
137
+ }
138
+ }
117
139
  function _focusCallback(data, id, e) {
118
140
  let cx = 0;
119
141
  let cy = 0;
@@ -121,7 +143,7 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
121
143
  cx = targetRect.left + targetRect.width / 2;
122
144
  cy = targetRect.top + targetRect.height / 2;
123
145
  updatePosition(cx, cy);
124
- setPopoverOpen(selectedLegend === '' || selectedLegend === data.legend);
146
+ setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));
125
147
  setValue(data.data.toString());
126
148
  setLegend(data.legend);
127
149
  setColor(data.color);
@@ -133,7 +155,7 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
133
155
  function _hoverCallback(data, e) {
134
156
  if (_calloutAnchorPoint !== data) {
135
157
  _calloutAnchorPoint = data;
136
- setPopoverOpen(selectedLegend === '' || selectedLegend === data.legend);
158
+ setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));
137
159
  setValue(data.data.toString());
138
160
  setLegend(data.legend);
139
161
  setColor(data.color);
@@ -153,16 +175,18 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
153
175
  setPopoverOpen(false);
154
176
  }
155
177
  function _valueInsideDonut(valueInsideDonut, data) {
156
- const highlightedLegend = _getHighlightedLegend();
157
- if (valueInsideDonut !== undefined && (highlightedLegend !== '' || isPopoverOpen)) {
158
- let legendValue = valueInsideDonut;
159
- data.map((point, index)=>{
160
- if (point.legend === highlightedLegend || isPopoverOpen && point.legend === legend) {
161
- legendValue = point.yAxisCalloutData ? point.yAxisCalloutData : point.data;
178
+ const highlightedLegends = _getHighlightedLegend();
179
+ if (valueInsideDonut !== undefined && (highlightedLegends.length === 1 || isPopoverOpen)) {
180
+ const pointValue = data.find((point)=>_isLegendHighlighted(point.legend));
181
+ return pointValue ? pointValue.yAxisCalloutData ? pointValue.yAxisCalloutData : pointValue.data : valueInsideDonut;
182
+ } else if (highlightedLegends.length > 0) {
183
+ let totalValue = 0;
184
+ data.forEach((point)=>{
185
+ if (highlightedLegends.includes(point.legend)) {
186
+ totalValue += point.data;
162
187
  }
163
- return;
164
188
  });
165
- return legendValue;
189
+ return totalValue;
166
190
  } else {
167
191
  return valueInsideDonut;
168
192
  }
@@ -178,9 +202,16 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
178
202
  * This function returns
179
203
  * the selected legend if there is one
180
204
  * or the hovered legend if none of the legends is selected.
181
- * Note: This won't work in case of multiple legends selection.
182
205
  */ function _getHighlightedLegend() {
183
- return selectedLegend || activeLegend;
206
+ return selectedLegends.length > 0 ? selectedLegends : activeLegend ? [
207
+ activeLegend
208
+ ] : [];
209
+ }
210
+ function _isLegendHighlighted(legend) {
211
+ return _getHighlightedLegend().includes(legend);
212
+ }
213
+ function _noLegendsHighlighted() {
214
+ return _getHighlightedLegend().length === 0;
184
215
  }
185
216
  function _isChartEmpty() {
186
217
  return !(props.data && props.data.chartData && props.data.chartData.filter((d)=>d.data > 0).length > 0);
@@ -253,7 +284,12 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
253
284
  className: classes.root,
254
285
  ref: (rootElem)=>_rootElem.current = rootElem,
255
286
  onMouseLeave: _handleChartMouseLeave
256
- }, /*#__PURE__*/ _react.createElement("div", {
287
+ }, props.xAxisAnnotation && /*#__PURE__*/ _react.createElement("text", {
288
+ className: classes.axisAnnotation,
289
+ x: _width / 2,
290
+ y: _height - 10,
291
+ textAnchor: "middle"
292
+ }, props.xAxisAnnotation), /*#__PURE__*/ _react.createElement("div", {
257
293
  className: classes.chartWrapper,
258
294
  ...focusAttributes
259
295
  }, /*#__PURE__*/ _react.createElement("svg", {
@@ -283,7 +319,7 @@ const DonutChart = /*#__PURE__*/ _react.forwardRef((props, forwardedRef)=>{
283
319
  yCalloutValue: yCalloutValue,
284
320
  culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
285
321
  clickPosition: clickPosition,
286
- isPopoverOpen: !props.hideTooltip && isPopoverOpen,
322
+ isPopoverOpen: !props.hideTooltip && isPopoverOpen && (_noLegendsHighlighted() || _isLegendHighlighted(legend)),
287
323
  legend: legend,
288
324
  YValue: value,
289
325
  color: color,