@fluentui/react-charts 9.2.4 → 9.3.1

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 (313) hide show
  1. package/CHANGELOG.md +41 -2
  2. package/dist/index.d.ts +1 -1
  3. package/lib/components/AreaChart/AreaChart.js +6 -4
  4. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  5. package/lib/components/AreaChart/useAreaChartStyles.styles.js +2 -0
  6. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  7. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +1 -0
  8. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  9. package/lib/components/ChartTable/ChartTable.js +11 -7
  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 +11 -12
  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 +2 -0
  21. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  22. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +1 -0
  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 +1 -0
  29. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  30. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +62 -67
  31. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  32. package/lib/components/DeclarativeChart/imageExporter.js +1 -0
  33. package/lib/components/DeclarativeChart/imageExporter.js.map +1 -1
  34. package/lib/components/DonutChart/Arc/Arc.js +8 -8
  35. package/lib/components/DonutChart/Arc/Arc.js.map +1 -1
  36. package/lib/components/DonutChart/Arc/Arc.types.js.map +1 -1
  37. package/lib/components/DonutChart/Arc/useArcStyles.styles.js +4 -2
  38. package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  39. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +2 -1
  40. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  41. package/lib/components/DonutChart/DonutChart.js +55 -24
  42. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  43. package/lib/components/DonutChart/Pie/Pie.js +1 -0
  44. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  45. package/lib/components/DonutChart/Pie/Pie.types.js.map +1 -1
  46. package/lib/components/DonutChart/Pie/usePieStyles.styles.js +2 -0
  47. package/lib/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
  48. package/lib/components/DonutChart/Pie/usePieStyles.styles.raw.js +1 -0
  49. package/lib/components/DonutChart/Pie/usePieStyles.styles.raw.js.map +1 -1
  50. package/lib/components/DonutChart/useDonutChartStyles.styles.js +2 -0
  51. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  52. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js +1 -0
  53. package/lib/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  54. package/lib/components/FunnelChart/FunnelChart.js +7 -3
  55. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  56. package/lib/components/FunnelChart/useFunnelChartStyles.styles.js +2 -0
  57. package/lib/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
  58. package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js +1 -0
  59. package/lib/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
  60. package/lib/components/GanttChart/GanttChart.js +1 -0
  61. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  62. package/lib/components/GaugeChart/GaugeChart.js +1 -0
  63. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  64. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +2 -0
  65. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
  66. package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js +1 -0
  67. package/lib/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
  68. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +13 -7
  69. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  70. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +2 -0
  71. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  72. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +1 -0
  73. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  74. package/lib/components/HeatMapChart/HeatMapChart.js +2 -1
  75. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  76. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +2 -0
  77. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  78. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +1 -0
  79. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  80. package/lib/components/HorizontalBarChart/HorizontalBarChart.js +2 -2
  81. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  82. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +3 -1
  83. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  84. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
  85. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  86. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
  87. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  88. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +2 -0
  89. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  90. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +1 -0
  91. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  92. package/lib/components/Legends/Legends.js +1 -0
  93. package/lib/components/Legends/Legends.js.map +1 -1
  94. package/lib/components/Legends/OverflowMenu.js +1 -0
  95. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  96. package/lib/components/Legends/shape.js +1 -0
  97. package/lib/components/Legends/shape.js.map +1 -1
  98. package/lib/components/Legends/useLegendsStyles.styles.js +2 -0
  99. package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
  100. package/lib/components/Legends/useLegendsStyles.styles.raw.js +1 -0
  101. package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  102. package/lib/components/LineChart/LineChart.js +42 -39
  103. package/lib/components/LineChart/LineChart.js.map +1 -1
  104. package/lib/components/LineChart/eventAnnotation/LabelLink.js +1 -0
  105. package/lib/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
  106. package/lib/components/LineChart/eventAnnotation/Textbox.js +1 -0
  107. package/lib/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
  108. package/lib/components/LineChart/useLineChartStyles.styles.js +2 -0
  109. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  110. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +1 -0
  111. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  112. package/lib/components/ResponsiveContainer/ResponsiveContainer.js +1 -0
  113. package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
  114. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.js +2 -0
  115. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.js.map +1 -1
  116. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js +1 -0
  117. package/lib/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js.map +1 -1
  118. package/lib/components/ResponsiveContainer/withResponsiveContainer.js +1 -0
  119. package/lib/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
  120. package/lib/components/SankeyChart/SankeyChart.js +1 -0
  121. package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
  122. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +2 -0
  123. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  124. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js +1 -0
  125. package/lib/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  126. package/lib/components/ScatterChart/ScatterChart.js +7 -6
  127. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  128. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +2 -0
  129. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  130. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +1 -0
  131. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  132. package/lib/components/Sparkline/Sparkline.js +1 -0
  133. package/lib/components/Sparkline/Sparkline.js.map +1 -1
  134. package/lib/components/Sparkline/useSparklineStyles.styles.js +2 -0
  135. package/lib/components/Sparkline/useSparklineStyles.styles.js.map +1 -1
  136. package/lib/components/Sparkline/useSparklineStyles.styles.raw.js +1 -0
  137. package/lib/components/Sparkline/useSparklineStyles.styles.raw.js.map +1 -1
  138. package/lib/components/VerticalBarChart/VerticalBarChart.js +15 -10
  139. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  140. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +2 -0
  141. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  142. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +1 -0
  143. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  144. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +29 -24
  145. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  146. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +2 -0
  147. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  148. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +1 -0
  149. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  150. package/lib/utilities/FocusableTooltipText.js +1 -0
  151. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  152. package/lib/utilities/SVGTooltipText.js +1 -0
  153. package/lib/utilities/SVGTooltipText.js.map +1 -1
  154. package/lib/utilities/image-export-utils.js +1 -0
  155. package/lib/utilities/image-export-utils.js.map +1 -1
  156. package/lib/utilities/utilities.js +12 -11
  157. package/lib/utilities/utilities.js.map +1 -1
  158. package/lib-commonjs/components/AreaChart/AreaChart.js +5 -3
  159. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  160. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +1 -0
  161. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  162. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +1 -0
  163. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  164. package/lib-commonjs/components/ChartTable/ChartTable.js +11 -7
  165. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
  166. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +4 -3
  167. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
  168. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +3 -2
  169. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
  170. package/lib-commonjs/components/CommonComponents/CartesianChart.js +11 -12
  171. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  172. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  173. package/lib-commonjs/components/CommonComponents/ChartPopover.js +14 -5
  174. package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
  175. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +1 -0
  176. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  177. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +1 -0
  178. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  179. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +4 -3
  180. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  181. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +3 -2
  182. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
  183. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +2 -1
  184. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  185. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +63 -68
  186. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  187. package/lib-commonjs/components/DeclarativeChart/imageExporter.js +1 -0
  188. package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +1 -1
  189. package/lib-commonjs/components/DonutChart/Arc/Arc.js +8 -8
  190. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -1
  191. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js.map +1 -1
  192. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +3 -2
  193. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  194. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +2 -1
  195. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  196. package/lib-commonjs/components/DonutChart/DonutChart.js +55 -24
  197. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  198. package/lib-commonjs/components/DonutChart/Pie/Pie.js +2 -1
  199. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  200. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js.map +1 -1
  201. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js +1 -0
  202. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -1
  203. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.raw.js +1 -0
  204. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.raw.js.map +1 -1
  205. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +1 -0
  206. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  207. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js +1 -0
  208. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.raw.js.map +1 -1
  209. package/lib-commonjs/components/FunnelChart/FunnelChart.js +7 -3
  210. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  211. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js +1 -0
  212. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.js.map +1 -1
  213. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js +1 -0
  214. package/lib-commonjs/components/FunnelChart/useFunnelChartStyles.styles.raw.js.map +1 -1
  215. package/lib-commonjs/components/GanttChart/GanttChart.js +1 -0
  216. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  217. package/lib-commonjs/components/GaugeChart/GaugeChart.js +1 -0
  218. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  219. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +1 -0
  220. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -1
  221. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js +1 -0
  222. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.raw.js.map +1 -1
  223. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +13 -7
  224. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  225. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +1 -0
  226. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  227. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +1 -0
  228. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  229. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +2 -1
  230. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  231. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +1 -0
  232. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  233. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +1 -0
  234. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  235. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +2 -2
  236. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  237. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +2 -1
  238. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  239. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +2 -1
  240. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  241. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
  242. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  243. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +1 -0
  244. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  245. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +1 -0
  246. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  247. package/lib-commonjs/components/Legends/Legends.js +1 -0
  248. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  249. package/lib-commonjs/components/Legends/OverflowMenu.js +1 -0
  250. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  251. package/lib-commonjs/components/Legends/shape.js +1 -0
  252. package/lib-commonjs/components/Legends/shape.js.map +1 -1
  253. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +1 -0
  254. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
  255. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js +1 -0
  256. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  257. package/lib-commonjs/components/LineChart/LineChart.js +41 -38
  258. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  259. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js +1 -0
  260. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js.map +1 -1
  261. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js +1 -0
  262. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
  263. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +1 -0
  264. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  265. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +1 -0
  266. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  267. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js +1 -0
  268. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
  269. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.js +1 -0
  270. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.js.map +1 -1
  271. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js +1 -0
  272. package/lib-commonjs/components/ResponsiveContainer/useResponsiveChildStyles.styles.raw.js.map +1 -1
  273. package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js +2 -1
  274. package/lib-commonjs/components/ResponsiveContainer/withResponsiveContainer.js.map +1 -1
  275. package/lib-commonjs/components/SankeyChart/SankeyChart.js +1 -0
  276. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
  277. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +1 -0
  278. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  279. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js +1 -0
  280. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.raw.js.map +1 -1
  281. package/lib-commonjs/components/ScatterChart/ScatterChart.js +6 -5
  282. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  283. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +1 -0
  284. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  285. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +1 -0
  286. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  287. package/lib-commonjs/components/Sparkline/Sparkline.js +1 -0
  288. package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
  289. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js +1 -0
  290. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js.map +1 -1
  291. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.raw.js +1 -0
  292. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.raw.js.map +1 -1
  293. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +15 -10
  294. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  295. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +1 -0
  296. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  297. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +1 -0
  298. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  299. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +28 -23
  300. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  301. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +1 -0
  302. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  303. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +1 -0
  304. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  305. package/lib-commonjs/utilities/FocusableTooltipText.js +2 -1
  306. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  307. package/lib-commonjs/utilities/SVGTooltipText.js +1 -0
  308. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  309. package/lib-commonjs/utilities/image-export-utils.js +1 -0
  310. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  311. package/lib-commonjs/utilities/utilities.js +12 -11
  312. package/lib-commonjs/utilities/utilities.js.map +1 -1
  313. package/package.json +10 -10
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { create as d3Create, select as d3Select } from 'd3-selection';
2
3
  import { resolveCSSVariables } from '../../utilities/index';
3
4
  export function toImage(chartContainer, opts = {}) {
@@ -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":"AAAA,SAASA,UAAUC,QAAQ,EAAEC,UAAUC,QAAQ,QAAmB,eAAe;AACjF,SAASC,mBAAmB,QAAQ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OAAO,CAACN,aAAa;QAC7BA,WAAWlC,OAAO,CAACyC,CAAAA;YACjBvH,SAASkH,MAAMM,KAAK,CAACD,MAAMJ,OAAOM,gBAAgB,CAACF;QACrD;IACF,OAAO;QACLG,OAAOC,OAAO,CAACX,YAAYlC,OAAO,CAAC,CAAC,CAAC8C,UAAUC,OAAO;YACpD7H,SAASkH,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;AAEA,SAASA,UAAUC,QAAQ,EAAEC,UAAUC,QAAQ,QAAmB,eAAe;AACjF,SAASC,mBAAmB,QAAQ,wBAAwB;AAY5D,OAAO,SAASC,QAAQC,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,WAAWR,oBAAoBE,gBAAgBC,KAAKK,UAAU,IAAI;YAC/F,MAAMC,MAAMC,MAAMR,gBAAgBM;YAElC,MAAMG,UAAU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'react';
2
3
  import { arc as d3Arc } from 'd3-shape';
3
4
  import { useArcStyles } from './useArcStyles.styles';
@@ -8,7 +9,7 @@ import { formatScientificLimitWidth, useRtl } from '../../../utilities/index';
8
9
  * Arc component within Donut Chart.
9
10
  * {@docCategory ArcDonutChart}
10
11
  */ export const Arc = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
11
- var _props_data;
12
+ var _props_data, _props_activeArc, _props_data1;
12
13
  const arc = d3Arc();
13
14
  const currentRef = /*#__PURE__*/ React.createRef();
14
15
  const _isRTL = useRtl();
@@ -44,8 +45,8 @@ import { formatScientificLimitWidth, useRtl } from '../../../utilities/index';
44
45
  return !activeArc || activeArc.length === 0 || legend === undefined || activeArc.includes(legend);
45
46
  }
46
47
  function _renderArcLabel(className) {
47
- const { data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels, activeArc } = props;
48
- if (hideLabels || Math.abs(data.endAngle - data.startAngle) < Math.PI / 12 || activeArc !== data.data.legend && activeArc !== '') {
48
+ const { data, innerRadius, outerRadius, showLabelsInPercent, totalValue, hideLabels } = props;
49
+ if (hideLabels || Math.abs(data.endAngle - data.startAngle) < Math.PI / 12 || !_shouldHighlightArc(data.data.legend)) {
49
50
  return null;
50
51
  }
51
52
  const [base, perp] = arc.centroid({
@@ -72,10 +73,10 @@ import { formatScientificLimitWidth, useRtl } from '../../../utilities/index';
72
73
  newProps.arc.outerRadius(newProps.outerRadius);
73
74
  }
74
75
  }
75
- const { href, focusedArcId } = props;
76
+ const { href, focusedArcId, activeArc } = props;
76
77
  //TO DO 'replace' is throwing error
77
78
  const id = props.uniqText + (typeof props.data.data.legend === 'string' ? props.data.data.legend.replace(/\s+/g, '') : '') + props.data.data.data;
78
- const opacity = props.activeArc === props.data.data.legend || props.activeArc === '' ? 1 : 0.1;
79
+ 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;
79
80
  const cornerRadius = props.roundCorners ? 3 : 0;
80
81
  return /*#__PURE__*/ React.createElement("g", {
81
82
  ref: currentRef
@@ -102,14 +103,13 @@ import { formatScientificLimitWidth, useRtl } from '../../../utilities/index';
102
103
  cursor: href ? 'pointer' : 'default'
103
104
  },
104
105
  onFocus: (event)=>_onFocus(props.data.data, id, event),
105
- "data-is-focusable": props.activeArc === props.data.data.legend || props.activeArc === '',
106
106
  onMouseOver: (event)=>_hoverOn(props.data.data, event),
107
107
  onMouseMove: (event)=>_hoverOn(props.data.data, event),
108
108
  onMouseLeave: _hoverOff,
109
- tabIndex: _shouldHighlightArc(props.data.data.legend) ? 0 : undefined,
109
+ tabIndex: _shouldHighlightArc(props.data.data.legend) || ((_props_activeArc = props.activeArc) === null || _props_activeArc === void 0 ? void 0 : _props_activeArc.length) === 0 ? 0 : undefined,
110
110
  onBlur: _onBlur,
111
111
  opacity: opacity,
112
- onClick: (_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.data.onClick,
112
+ onClick: (_props_data1 = props.data) === null || _props_data1 === void 0 ? void 0 : _props_data1.data.onClick,
113
113
  "aria-label": _getAriaLabel(),
114
114
  role: "img"
115
115
  }), _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":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,OAAOC,KAAK,QAAQ,WAAW;AACxC,SAASC,YAAY,QAAQ,wBAAwB;AAGrD,SAASC,UAAUC,QAAQ,QAAQ,YAAY;AAC/C,SAASC,0BAA0B,EAAEC,MAAM,QAAQ,2BAA2B;AAE9E,wGAAwG;AACxG;;;CAGC,GACD,OAAO,MAAMC,oBAAyCR,MAAMS,UAAU,CACpE,CAACC,OAAOC;QA4HSD;IA3Hf,MAAMT,MAAMC;IACZ,MAAMU,2BAAaZ,MAAMa,SAAS;IAClC,MAAMC,SAAkBP;IACxB,MAAMQ,UAAUZ,aAAaO;IAE7BV,MAAMgB,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,MAAM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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;AAEA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,OAAOC,KAAK,QAAQ,WAAW;AACxC,SAASC,YAAY,QAAQ,wBAAwB;AAGrD,SAASC,UAAUC,QAAQ,QAAQ,YAAY;AAC/C,SAASC,0BAA0B,EAAEC,MAAM,QAAQ,2BAA2B;AAE9E,wGAAwG;AACxG;;;CAGC,GACD,OAAO,MAAMC,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,QAASG,SAASd,MAAMS,IAAI,CAAEA,IAAI,EAAEE;QACjDyE,cAAclE;QACdmE,UAAUvD,oBAAoB9B,MAAMS,IAAI,CAAEA,IAAI,CAACe,MAAM,KAAMxB,EAAAA,mBAAAA,MAAM+B,SAAS,cAAf/B,uCAAAA,iBAAiBgC,MAAM,MAAK,IAAI,IAAIC;QAC/FqD,QAAQlE;QACRgD,SAASA;QACTmB,OAAO,GAAEvF,eAAAA,MAAMS,IAAI,cAAVT,mCAAAA,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":"AA6IA,WAeC"}
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":"AA6IA,WAeC"}
@@ -1,3 +1,5 @@
1
+ 'use client';
2
+
1
3
  import { __styles, mergeClasses, shorthands } from '@griffel/react';
2
4
  import { tokens, typographyStyles } from '@fluentui/react-theme';
3
5
  import { HighContrastSelector } from '../../../utilities/utilities';
@@ -33,7 +35,7 @@ const useStyles = /*#__PURE__*/__styles({
33
35
  arcLabel: {
34
36
  Bahqtrf: "fk6fouc",
35
37
  Be2twd7: "fy9rknc",
36
- Bhrd7zp: "figsok6",
38
+ Bhrd7zp: "fl43uef",
37
39
  Bg96gwp: "fwrc4pm",
38
40
  Bkfmm31: "fhuob2q",
39
41
  Bpvj6i6: "f1l20po4"
@@ -41,7 +43,7 @@ const useStyles = /*#__PURE__*/__styles({
41
43
  }, {
42
44
  d: [".f158kwzp{cursor:default;}", [".f1391ufr{outline:transparent;}", {
43
45
  p: -1
44
- }], ".f1yuyku4{stroke:var(--colorNeutralBackground1);}", ".f138xzbb selectors::-moz-focus-inner{border-top-width:0;}", ".fny96iz selectors::-moz-focus-inner{border-right-width:0;}", ".fi0bkha selectors::-moz-focus-inner{border-left-width:0;}", ".f1jv8gm3 selectors::-moz-focus-inner{border-bottom-width:0;}", ".frcfrt5{stroke:var(--colorStrokeFocus2);}", ".f9nnx8l{stroke-width:var(--strokeWidthThickest);}", ".f1au8mb3{fill:transparent;}", ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fy9rknc{font-size:var(--fontSizeBase200);}", ".figsok6{font-weight:var(--fontWeightRegular);}", ".fwrc4pm{line-height:var(--lineHeightBase200);}", ".fhuob2q{fill:var(--colorNeutralForeground1);}"],
46
+ }], ".f1yuyku4{stroke:var(--colorNeutralBackground1);}", ".f138xzbb selectors::-moz-focus-inner{border-top-width:0;}", ".fny96iz selectors::-moz-focus-inner{border-right-width:0;}", ".fi0bkha selectors::-moz-focus-inner{border-left-width:0;}", ".f1jv8gm3 selectors::-moz-focus-inner{border-bottom-width:0;}", ".frcfrt5{stroke:var(--colorStrokeFocus2);}", ".f9nnx8l{stroke-width:var(--strokeWidthThickest);}", ".f1au8mb3{fill:transparent;}", ".fk6fouc{font-family:var(--fontFamilyBase);}", ".fy9rknc{font-size:var(--fontSizeBase200);}", ".fl43uef{font-weight:var(--fontWeightSemibold);}", ".fwrc4pm{line-height:var(--lineHeightBase200);}", ".fhuob2q{fill:var(--colorNeutralForeground1);}"],
45
47
  m: [["@media screen and (-ms-high-contrast: active),screen and (forced-colors: active){.f1l20po4{stroke:CanvasText;}}", {
46
48
  m: "screen and (-ms-high-contrast: active), screen and (forced-colors: active)"
47
49
  }]]
@@ -1 +1 @@
1
- {"version":3,"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","m","useArcStyles","props","_props_styles","_props_styles1","_props_styles2","className","baseStyles","styles"],"sources":["useArcStyles.styles.js"],"sourcesContent":["import { 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.caption1,\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,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,aAAa,CAAC1B,IAAI,CAAC;IAC1KC,SAAS,EAAEP,YAAY,CAACK,kBAAkB,CAACE,SAAS,EAAE6B,UAAU,CAAC7B,SAAS,EAAE,CAAC0B,cAAc,GAAGF,KAAK,CAACM,MAAM,MAAM,IAAI,IAAIJ,cAAc,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,cAAc,CAAC1B,SAAS,CAAC;IACtLC,QAAQ,EAAER,YAAY,CAACK,kBAAkB,CAACG,QAAQ,EAAE4B,UAAU,CAAC5B,QAAQ,EAAE,CAAC0B,cAAc,GAAGH,KAAK,CAACM,MAAM,MAAM,IAAI,IAAIH,cAAc,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,cAAc,CAAC1B,QAAQ;EACrL,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"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","m","useArcStyles","props","_props_styles","_props_styles1","_props_styles2","className","baseStyles","styles"],"sources":["useArcStyles.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"],"mappings":"AAAA,YAAY;;AACZ,SAAAA,QAAA,EAAqBC,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AACrE,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,uBAAuB;AAChE,SAASC,oBAAoB,QAAQ,8BAA8B;AACnE;AACA;AACA;AAAI,OAAO,MAAMC,kBAAkB,GAAG;EAClCC,IAAI,EAAE,qBAAqB;EAC3BC,SAAS,EAAE,0BAA0B;EACrCC,QAAQ,EAAE;AACd,CAAC;AACD;AACA;AACA;AAAI,MAAMC,SAAS,gBAAGV,QAAA;EAAAO,IAAA;IAAAI,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;EAAAZ,SAAA;IAAAQ,MAAA;IAAAK,OAAA;IAAAC,OAAA;EAAA;EAAAb,QAAA;IAAAc,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAJ,OAAA;IAAAK,OAAA;EAAA;AAAA;EAAAC,CAAA;IAAAC,CAAA;EAAA;EAAAC,CAAA;IAAAA,CAAA;EAAA;AAAA,CAuBrB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMC,YAAY,GAAIC,KAAK,IAAG;EACrC,IAAIC,aAAa,EAAEC,cAAc,EAAEC,cAAc;EACjD,MAAM;IAAEC;EAAU,CAAC,GAAGJ,KAAK;EAC3B,MAAMK,UAAU,GAAG3B,SAAS,CAAC,CAAC;EAC9B,OAAO;IACHH,IAAI,EAAEN,YAAY,CAACK,kBAAkB,CAACC,IAAI,EAAE8B,UAAU,CAAC9B,IAAI,EAAE6B,SAAS,EAAE,CAACH,aAAa,GAAGD,KAAK,CAACM,MAAM,MAAM,IAAI,IAAIL,aAAa,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,aAAa,CAAC1B,IAAI,CAAC;IAC1KC,SAAS,EAAEP,YAAY,CAACK,kBAAkB,CAACE,SAAS,EAAE6B,UAAU,CAAC7B,SAAS,EAAE,CAAC0B,cAAc,GAAGF,KAAK,CAACM,MAAM,MAAM,IAAI,IAAIJ,cAAc,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,cAAc,CAAC1B,SAAS,CAAC;IACtLC,QAAQ,EAAER,YAAY,CAACK,kBAAkB,CAACG,QAAQ,EAAE4B,UAAU,CAAC5B,QAAQ,EAAE,CAAC0B,cAAc,GAAGH,KAAK,CAACM,MAAM,MAAM,IAAI,IAAIH,cAAc,KAAK,KAAK,CAAC,GAAG,KAAK,CAAC,GAAGA,cAAc,CAAC1B,QAAQ;EACrL,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { makeStyles, mergeClasses, shorthands } from '@griffel/react';
2
3
  import { tokens, typographyStyles } from '@fluentui/react-theme';
3
4
  import { HighContrastSelector } from '../../../utilities/utilities';
@@ -27,7 +28,7 @@ import { HighContrastSelector } from '../../../utilities/utilities';
27
28
  fill: 'transparent'
28
29
  },
29
30
  arcLabel: {
30
- ...typographyStyles.caption1,
31
+ ...typographyStyles.caption1Strong,
31
32
  fill: tokens.colorNeutralForeground1,
32
33
  [HighContrastSelector]: {
33
34
  stroke: 'CanvasText'
@@ -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';\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.caption1,\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","caption1","colorNeutralForeground1","useArcStyles","props","className","baseStyles","styles"],"mappings":"AACA,SAASA,UAAU,EAAEC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AACtE,SAASC,MAAM,EAAEC,gBAAgB,QAAQ,wBAAwB;AAEjE,SAASC,oBAAoB,QAAQ,+BAA+B;AAEpE;;CAEC,GACD,OAAO,MAAMC,qBAAgD;IAC3DC,MAAM;IACNC,WAAW;IACXC,UAAU;AACZ,EAAE;AAEF;;CAEC,GACD,MAAMC,YAAYV,WAAW;IAC3BO,MAAM;QACJI,QAAQ;QACRC,SAAS;QACTC,QAAQV,OAAOW,uBAAuB;QACtC,eAAe;YACb,sBAAsB;gBACpB,GAAGZ,WAAWa,MAAM,CAAC,IAAI;YAC3B;QACF;IACF;IACAP,WAAW;QACTK,QAAQV,OAAOa,iBAAiB;QAChCC,aAAad,OAAOe,mBAAmB;QACvCC,MAAM;IACR;IACAV,UAAU;QACR,GAAGL,iBAAiBgB,QAAQ;QAC5BD,MAAMhB,OAAOkB,uBAAuB;QACpC,CAAChB,qBAAqB,EAAE;YACtBQ,QAAQ;QACV;IACF;AACF;AAEA;;CAEC,GACD,OAAO,MAAMS,eAAe,CAACC;QAK+CA,eACIA,gBACHA;IAN3E,MAAM,EAAEC,SAAS,EAAE,GAAGD;IACtB,MAAME,aAAaf;IAEnB,OAAO;QACLH,MAAMN,aAAaK,mBAAmBC,IAAI,EAAEkB,WAAWlB,IAAI,EAAEiB,YAAWD,gBAAAA,MAAMG,MAAM,cAAZH,oCAAAA,cAAchB,IAAI;QAC1FC,WAAWP,aAAaK,mBAAmBE,SAAS,EAAEiB,WAAWjB,SAAS,GAAEe,iBAAAA,MAAMG,MAAM,cAAZH,qCAAAA,eAAcf,SAAS;QACnGC,UAAUR,aAAaK,mBAAmBG,QAAQ,EAAEgB,WAAWhB,QAAQ,GAAEc,iBAAAA,MAAMG,MAAM,cAAZH,qCAAAA,eAAcd,QAAQ;IACjG;AACF,EAAE"}
1
+ {"version":3,"sources":["../src/components/DonutChart/Arc/useArcStyles.styles.ts"],"sourcesContent":["'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","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
  /* eslint-disable react/jsx-no-bind */ import * as React from 'react';
2
3
  import { Pie } from './Pie/index';
3
4
  import { useDonutChartStyles } from './useDonutChartStyles.styles';
4
5
  import { formatToLocaleString } from '@fluentui/chart-utilities';
5
- import { getColorFromToken, getNextColor, MIN_DONUT_RADIUS, useRtl } from '../../utilities/index';
6
+ import { areArraysEqual, getColorFromToken, getNextColor, MIN_DONUT_RADIUS, useRtl } from '../../utilities/index';
6
7
  import { Legends } from '../../index';
7
8
  import { useId } from '@fluentui/react-utilities';
8
9
  import { useFocusableGroup } from '@fluentui/react-tabster';
@@ -14,6 +15,7 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
14
15
  * Donutchart component.
15
16
  * {@docCategory DonutChart}
16
17
  */ export const DonutChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
18
+ var _props_legendProps;
17
19
  const _rootElem = React.useRef(null);
18
20
  const _uniqText = useId('_Pie_');
19
21
  /* eslint-disable @typescript-eslint/no-explicit-any */ let _calloutAnchorPoint;
@@ -24,11 +26,11 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
24
26
  const [legend, setLegend] = React.useState('');
25
27
  const [_width, setWidth] = React.useState(props.width || 200);
26
28
  const [_height, setHeight] = React.useState(props.height || 200);
27
- const [activeLegend, setActiveLegend] = React.useState('');
29
+ const [activeLegend, setActiveLegend] = React.useState(undefined);
28
30
  const [color, setColor] = React.useState('');
29
31
  const [xCalloutValue, setXCalloutValue] = React.useState('');
30
32
  const [yCalloutValue, setYCalloutValue] = React.useState('');
31
- const [selectedLegend, setSelectedLegend] = React.useState('');
33
+ const [selectedLegends, setSelectedLegends] = React.useState(((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.selectedLegends) || []);
32
34
  const [focusedArcId, setFocusedArcId] = React.useState('');
33
35
  const [dataPointCalloutProps, setDataPointCalloutProps] = React.useState();
34
36
  const [clickPosition, setClickPosition] = React.useState({
@@ -36,11 +38,25 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
36
38
  y: 0
37
39
  });
38
40
  const [isPopoverOpen, setPopoverOpen] = React.useState(false);
41
+ const prevPropsRef = React.useRef(null);
39
42
  const _legendsRef = React.useRef(null);
40
43
  const _isRTL = useRtl();
41
44
  React.useEffect(()=>{
42
45
  _fitParentContainer();
43
46
  }, []);
47
+ React.useEffect(()=>{
48
+ if (prevPropsRef.current) {
49
+ var _prevProps_legendProps, _props_legendProps;
50
+ const prevProps = prevPropsRef.current;
51
+ if (!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)) {
52
+ var _props_legendProps1;
53
+ setSelectedLegends(((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.selectedLegends) || []);
54
+ }
55
+ }
56
+ prevPropsRef.current = props;
57
+ }, [
58
+ props
59
+ ]);
44
60
  React.useEffect(()=>{
45
61
  if (prevSize.current.height !== props.height || prevSize.current.width !== props.width) {
46
62
  _fitParentContainer();
@@ -81,19 +97,12 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
81
97
  const legend = {
82
98
  title: point.legend,
83
99
  color,
84
- action: ()=>{
85
- if (selectedLegend === point.legend) {
86
- setSelectedLegend('');
87
- } else {
88
- setSelectedLegend(point.legend);
89
- }
90
- },
91
100
  hoverAction: ()=>{
92
101
  _handleChartMouseLeave();
93
102
  setActiveLegend(point.legend);
94
103
  },
95
104
  onMouseOutAction: ()=>{
96
- setActiveLegend('');
105
+ setActiveLegend(undefined);
97
106
  }
98
107
  };
99
108
  return legend;
@@ -103,10 +112,23 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
103
112
  centerLegends: true,
104
113
  overflowText: props.legendsOverflowText,
105
114
  ...props.legendProps,
115
+ // eslint-disable-next-line react/jsx-no-bind
116
+ onChange: _onLegendSelectionChange,
106
117
  legendRef: _legendsRef
107
118
  });
108
119
  return legends;
109
120
  }
121
+ function _onLegendSelectionChange(selectedLegends, event, currentLegend) {
122
+ var _props_legendProps, _props_legendProps1;
123
+ if (props.legendProps && ((_props_legendProps = props.legendProps) === null || _props_legendProps === void 0 ? void 0 : _props_legendProps.canSelectMultipleLegends)) {
124
+ setSelectedLegends(selectedLegends);
125
+ } else {
126
+ setSelectedLegends(selectedLegends.slice(-1));
127
+ }
128
+ if ((_props_legendProps1 = props.legendProps) === null || _props_legendProps1 === void 0 ? void 0 : _props_legendProps1.onChange) {
129
+ props.legendProps.onChange(selectedLegends, event, currentLegend);
130
+ }
131
+ }
110
132
  function _focusCallback(data, id, e) {
111
133
  let cx = 0;
112
134
  let cy = 0;
@@ -114,7 +136,7 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
114
136
  cx = targetRect.left + targetRect.width / 2;
115
137
  cy = targetRect.top + targetRect.height / 2;
116
138
  updatePosition(cx, cy);
117
- setPopoverOpen(selectedLegend === '' || selectedLegend === data.legend);
139
+ setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));
118
140
  setValue(data.data.toString());
119
141
  setLegend(data.legend);
120
142
  setColor(data.color);
@@ -126,7 +148,7 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
126
148
  function _hoverCallback(data, e) {
127
149
  if (_calloutAnchorPoint !== data) {
128
150
  _calloutAnchorPoint = data;
129
- setPopoverOpen(selectedLegend === '' || selectedLegend === data.legend);
151
+ setPopoverOpen(_noLegendsHighlighted() || _isLegendHighlighted(data.legend));
130
152
  setValue(data.data.toString());
131
153
  setLegend(data.legend);
132
154
  setColor(data.color);
@@ -146,16 +168,18 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
146
168
  setPopoverOpen(false);
147
169
  }
148
170
  function _valueInsideDonut(valueInsideDonut, data) {
149
- const highlightedLegend = _getHighlightedLegend();
150
- if (valueInsideDonut !== undefined && (highlightedLegend !== '' || isPopoverOpen)) {
151
- let legendValue = valueInsideDonut;
152
- data.map((point, index)=>{
153
- if (point.legend === highlightedLegend || isPopoverOpen && point.legend === legend) {
154
- legendValue = point.yAxisCalloutData ? point.yAxisCalloutData : point.data;
171
+ const highlightedLegends = _getHighlightedLegend();
172
+ if (valueInsideDonut !== undefined && (highlightedLegends.length === 1 || isPopoverOpen)) {
173
+ const pointValue = data.find((point)=>_isLegendHighlighted(point.legend));
174
+ return pointValue ? pointValue.yAxisCalloutData ? pointValue.yAxisCalloutData : pointValue.data : valueInsideDonut;
175
+ } else if (highlightedLegends.length > 0) {
176
+ let totalValue = 0;
177
+ data.forEach((point)=>{
178
+ if (highlightedLegends.includes(point.legend)) {
179
+ totalValue += point.data;
155
180
  }
156
- return;
157
181
  });
158
- return legendValue;
182
+ return totalValue;
159
183
  } else {
160
184
  return valueInsideDonut;
161
185
  }
@@ -171,9 +195,16 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
171
195
  * This function returns
172
196
  * the selected legend if there is one
173
197
  * or the hovered legend if none of the legends is selected.
174
- * Note: This won't work in case of multiple legends selection.
175
198
  */ function _getHighlightedLegend() {
176
- return selectedLegend || activeLegend;
199
+ return selectedLegends.length > 0 ? selectedLegends : activeLegend ? [
200
+ activeLegend
201
+ ] : [];
202
+ }
203
+ function _isLegendHighlighted(legend) {
204
+ return _getHighlightedLegend().includes(legend);
205
+ }
206
+ function _noLegendsHighlighted() {
207
+ return _getHighlightedLegend().length === 0;
177
208
  }
178
209
  function _isChartEmpty() {
179
210
  return !(props.data && props.data.chartData && props.data.chartData.filter((d)=>d.data > 0).length > 0);
@@ -281,7 +312,7 @@ const MIN_LEGEND_CONTAINER_HEIGHT = 40;
281
312
  yCalloutValue: yCalloutValue,
282
313
  culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
283
314
  clickPosition: clickPosition,
284
- isPopoverOpen: !props.hideTooltip && isPopoverOpen,
315
+ isPopoverOpen: !props.hideTooltip && isPopoverOpen && (_noLegendsHighlighted() || _isLegendHighlighted(legend)),
285
316
  legend: legend,
286
317
  YValue: value,
287
318
  color: color,