@fluentui/react-charts 9.3.4 → 9.3.6

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 (309) hide show
  1. package/CHANGELOG.md +41 -2
  2. package/dist/index.d.ts +225 -46
  3. package/lib/AnnotationOnlyChart.js +1 -0
  4. package/lib/AnnotationOnlyChart.js.map +1 -0
  5. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +208 -0
  6. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
  7. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +1 -0
  8. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
  9. package/lib/components/AnnotationOnlyChart/index.js +2 -0
  10. package/lib/components/AnnotationOnlyChart/index.js.map +1 -0
  11. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +31 -0
  12. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
  13. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +23 -0
  14. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
  15. package/lib/components/AreaChart/useAreaChartStyles.styles.js +11 -6
  16. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  17. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
  18. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  19. package/lib/components/ChartTable/ChartTable.js +3 -1
  20. package/lib/components/ChartTable/ChartTable.js.map +1 -1
  21. package/lib/components/ChartTable/useChartTableStyles.styles.js +59 -39
  22. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
  23. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +5 -5
  24. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
  25. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +617 -0
  26. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  27. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +1 -0
  28. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  29. package/lib/components/CommonComponents/Annotations/index.js +2 -0
  30. package/lib/components/CommonComponents/Annotations/index.js.map +1 -0
  31. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +173 -0
  32. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
  33. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +126 -0
  34. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
  35. package/lib/components/CommonComponents/CartesianChart.js +182 -153
  36. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  37. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  38. package/lib/components/CommonComponents/index.js +2 -0
  39. package/lib/components/CommonComponents/index.js.map +1 -1
  40. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +29 -13
  41. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  42. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +14 -1
  43. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  44. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +2 -6
  45. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  46. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +3 -2
  47. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
  48. package/lib/components/DeclarativeChart/DeclarativeChart.js +42 -25
  49. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  50. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  51. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +635 -38
  52. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  53. package/lib/components/DonutChart/Arc/useArcStyles.styles.js +23 -8
  54. package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  55. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +2 -2
  56. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  57. package/lib/components/DonutChart/DonutChart.js +12 -7
  58. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  59. package/lib/components/DonutChart/useDonutChartStyles.styles.js +2 -2
  60. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  61. package/lib/components/FunnelChart/FunnelChart.js +5 -5
  62. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  63. package/lib/components/GanttChart/GanttChart.js +3 -3
  64. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  65. package/lib/components/GanttChart/GanttChart.types.js.map +1 -1
  66. package/lib/components/GanttChart/useGanttChartStyles.styles.js +3 -1
  67. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  68. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
  69. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  70. package/lib/components/GaugeChart/GaugeChart.js +3 -1
  71. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  72. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +1 -1
  73. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  74. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +11 -6
  75. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  76. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
  77. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  78. package/lib/components/HeatMapChart/HeatMapChart.js +6 -6
  79. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  80. package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
  81. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
  82. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  83. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
  84. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  85. package/lib/components/HorizontalBarChart/HorizontalBarChart.js +3 -1
  86. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  87. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +25 -12
  88. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  89. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +4 -4
  90. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  91. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
  92. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  93. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
  94. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
  95. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  96. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
  97. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  98. package/lib/components/Legends/Legends.js +3 -1
  99. package/lib/components/Legends/Legends.js.map +1 -1
  100. package/lib/components/Legends/Legends.types.js.map +1 -1
  101. package/lib/components/Legends/useLegendsStyles.styles.js +97 -37
  102. package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
  103. package/lib/components/Legends/useLegendsStyles.styles.raw.js +10 -11
  104. package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  105. package/lib/components/LineChart/LineChart.js +6 -5
  106. package/lib/components/LineChart/LineChart.js.map +1 -1
  107. package/lib/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
  108. package/lib/components/LineChart/useLineChartStyles.styles.js +15 -10
  109. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  110. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
  111. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  112. package/lib/components/ResponsiveContainer/ResponsiveContainer.js +1 -1
  113. package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
  114. package/lib/components/SankeyChart/SankeyChart.js +1 -1
  115. package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
  116. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +13 -10
  117. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  118. package/lib/components/ScatterChart/ScatterChart.js +1 -1
  119. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  120. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  121. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +13 -8
  122. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  123. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
  124. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  125. package/lib/components/VerticalBarChart/VerticalBarChart.js +4 -2
  126. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  127. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +13 -8
  128. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  129. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
  130. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  131. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +13 -5
  132. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  133. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  134. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +11 -6
  135. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  136. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
  137. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  138. package/lib/index.js +1 -0
  139. package/lib/index.js.map +1 -1
  140. package/lib/types/ChartAnnotation.js +1 -0
  141. package/lib/types/ChartAnnotation.js.map +1 -0
  142. package/lib/types/index.js +1 -0
  143. package/lib/types/index.js.map +1 -1
  144. package/lib/utilities/Common.styles.js +1 -2
  145. package/lib/utilities/Common.styles.js.map +1 -1
  146. package/lib/utilities/Common.styles.raw.js +1 -2
  147. package/lib/utilities/Common.styles.raw.js.map +1 -1
  148. package/lib/utilities/FocusableTooltipText.js +1 -1
  149. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  150. package/lib/utilities/SVGTooltipText.js +8 -8
  151. package/lib/utilities/SVGTooltipText.js.map +1 -1
  152. package/lib/utilities/image-export-utils.js +108 -0
  153. package/lib/utilities/image-export-utils.js.map +1 -1
  154. package/lib/utilities/utilities.js +16 -13
  155. package/lib/utilities/utilities.js.map +1 -1
  156. package/lib-commonjs/AnnotationOnlyChart.js +6 -0
  157. package/lib-commonjs/AnnotationOnlyChart.js.map +1 -0
  158. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +219 -0
  159. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
  160. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +6 -0
  161. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
  162. package/lib-commonjs/components/AnnotationOnlyChart/index.js +7 -0
  163. package/lib-commonjs/components/AnnotationOnlyChart/index.js.map +1 -0
  164. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +56 -0
  165. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
  166. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +33 -0
  167. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
  168. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +14 -15
  169. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  170. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
  171. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  172. package/lib-commonjs/components/ChartTable/ChartTable.js +3 -1
  173. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
  174. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +74 -102
  175. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
  176. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +4 -4
  177. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
  178. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +628 -0
  179. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  180. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +4 -0
  181. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  182. package/lib-commonjs/components/CommonComponents/Annotations/index.js +7 -0
  183. package/lib-commonjs/components/CommonComponents/Annotations/index.js.map +1 -0
  184. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +265 -0
  185. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
  186. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +161 -0
  187. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
  188. package/lib-commonjs/components/CommonComponents/CartesianChart.js +182 -152
  189. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  190. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  191. package/lib-commonjs/components/CommonComponents/index.js +2 -0
  192. package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
  193. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +32 -21
  194. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  195. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +14 -1
  196. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  197. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +0 -14
  198. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  199. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +2 -1
  200. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
  201. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +41 -24
  202. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  203. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  204. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +638 -38
  205. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  206. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +25 -16
  207. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  208. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +1 -1
  209. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  210. package/lib-commonjs/components/DonutChart/DonutChart.js +12 -7
  211. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  212. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +2 -2
  213. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  214. package/lib-commonjs/components/FunnelChart/FunnelChart.js +5 -5
  215. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  216. package/lib-commonjs/components/GanttChart/GanttChart.js +3 -3
  217. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  218. package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -1
  219. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +3 -1
  220. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  221. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
  222. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  223. package/lib-commonjs/components/GaugeChart/GaugeChart.js +3 -1
  224. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  225. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +1 -1
  226. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  227. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +14 -15
  228. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  229. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
  230. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  231. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +6 -6
  232. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  233. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
  234. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
  235. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  236. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
  237. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  238. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +3 -1
  239. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -1
  240. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +47 -34
  241. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  242. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +3 -3
  243. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  244. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +2 -2
  245. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  246. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
  247. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
  248. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  249. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
  250. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  251. package/lib-commonjs/components/Legends/Legends.js +3 -1
  252. package/lib-commonjs/components/Legends/Legends.js.map +1 -1
  253. package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
  254. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +144 -86
  255. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
  256. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js +9 -10
  257. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  258. package/lib-commonjs/components/LineChart/LineChart.js +6 -5
  259. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  260. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +1 -1
  261. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +18 -19
  262. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  263. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
  264. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  265. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js +1 -1
  266. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -1
  267. package/lib-commonjs/components/SankeyChart/SankeyChart.js +1 -1
  268. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
  269. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +16 -19
  270. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  271. package/lib-commonjs/components/ScatterChart/ScatterChart.js +1 -1
  272. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  273. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  274. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +16 -17
  275. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  276. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
  277. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  278. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +4 -2
  279. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  280. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +16 -17
  281. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  282. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
  283. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  284. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +13 -5
  285. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  286. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  287. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +14 -15
  288. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  289. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
  290. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  291. package/lib-commonjs/index.js +1 -0
  292. package/lib-commonjs/index.js.map +1 -1
  293. package/lib-commonjs/types/ChartAnnotation.js +6 -0
  294. package/lib-commonjs/types/ChartAnnotation.js.map +1 -0
  295. package/lib-commonjs/types/index.js +1 -0
  296. package/lib-commonjs/types/index.js.map +1 -1
  297. package/lib-commonjs/utilities/Common.styles.js +1 -2
  298. package/lib-commonjs/utilities/Common.styles.js.map +1 -1
  299. package/lib-commonjs/utilities/Common.styles.raw.js +1 -2
  300. package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -1
  301. package/lib-commonjs/utilities/FocusableTooltipText.js +1 -1
  302. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  303. package/lib-commonjs/utilities/SVGTooltipText.js +8 -8
  304. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -1
  305. package/lib-commonjs/utilities/image-export-utils.js +108 -0
  306. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  307. package/lib-commonjs/utilities/utilities.js +16 -13
  308. package/lib-commonjs/utilities/utilities.js.map +1 -1
  309. package/package.json +11 -11
@@ -5,25 +5,29 @@ import { select as d3Select } from 'd3-selection';
5
5
  import { createNumericXAxis, createStringXAxis, createDateXAxis, XAxisTypes, YAxisType, createWrapOfXLabels, rotateXAxisLabels, calculateLongestLabelWidth, createYAxisLabels, ChartTypes, wrapContent, useRtl, truncateString, tooltipOfAxislabels, getSecureProps, DEFAULT_WRAP_WIDTH } from '../../utilities/index';
6
6
  import { useId } from '@fluentui/react-utilities';
7
7
  import { SVGTooltipText } from '../../utilities/SVGTooltipText';
8
+ import { ChartAnnotationLayer } from './Annotations/ChartAnnotationLayer';
8
9
  import { ChartPopover } from './ChartPopover';
9
10
  import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabster';
11
+ const HORIZONTAL_MARGIN_FOR_YAXIS_TITLE = 24;
12
+ const VERTICAL_MARGIN_FOR_XAXIS_TITLE = 20;
13
+ const AXIS_TITLE_PADDING = 8;
14
+ const DEFAULT_MARGIN_WITH_TICKS = 40;
15
+ const DEFAULT_MARGIN_NO_TICKS = 20;
10
16
  /**
11
17
  * Cartesian Chart component
12
18
  * {@docCategory CartesianChart}
13
- */ export const CartesianChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
14
- var _props_margins, _props_margins1, _props_margins2, _props_margins3, _props_margins4, _props_margins5;
15
- const chartContainer = React.useRef();
19
+ */ export const CartesianChart = /*#__PURE__*/ React.forwardRef(({ hideTickOverlap = true, ...props }, forwardedRef)=>{
20
+ const chartContainer = React.useRef(null);
16
21
  let legendContainer;
17
22
  const minLegendContainerHeight = 40;
18
- const xAxisElement = React.useRef();
19
- const yAxisElement = React.useRef();
20
- const yAxisElementSecondary = React.useRef();
23
+ const xAxisElement = React.useRef(null);
24
+ const yAxisElement = React.useRef(null);
25
+ const yAxisElementSecondary = React.useRef(null);
21
26
  let margins;
22
27
  const idForGraph = 'chart_';
23
28
  let _reqID;
24
29
  const _useRtl = useRtl();
25
30
  let _tickValues;
26
- const titleMargin = 8;
27
31
  const _isFirstRender = React.useRef(true);
28
32
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
33
  let _xScale;
@@ -39,60 +43,12 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
39
43
  * These value need to be removed from actual svg height/graph height.
40
44
  * Defalut value is 0. And this values calculted when 'wrapXAxisLables' or 'showXAxisLablesTooltip' is true.
41
45
  */ let _removalValueForTextTuncate = 0;
46
+ const _yAxisTickText = React.useRef([]);
42
47
  const [containerWidth, setContainerWidth] = React.useState(0);
43
48
  const [containerHeight, setContainerHeight] = React.useState(0);
44
49
  const [startFromX, setStartFromX] = React.useState(0);
45
- const [prevProps, setPrevProps] = React.useState(null);
46
- const chartTypesWithStringYAxis = [
47
- ChartTypes.HorizontalBarChartWithAxis,
48
- ChartTypes.HeatMapChart,
49
- ChartTypes.VerticalStackedBarChart,
50
- ChartTypes.GanttChart,
51
- ChartTypes.ScatterChart
52
- ];
53
- var _props_margins_top, _props_margins_bottom, _props_margins_left, _props_margins_right, _props_margins_right1, _props_margins_left1;
54
- /**
55
- * In RTL mode, Only graph will be rendered left/right. We need to provide left and right margins manually.
56
- * So that, in RTL, left margins becomes right margins and viceversa.
57
- * As graph needs to be drawn perfecty, these values consider as default values.
58
- * Same margins using for all other cartesian charts. Can be accessible through 'getMargins' call back method.
59
- */ // eslint-disable-next-line prefer-const
60
- margins = {
61
- top: (_props_margins_top = (_props_margins = props.margins) === null || _props_margins === void 0 ? void 0 : _props_margins.top) !== null && _props_margins_top !== void 0 ? _props_margins_top : 20,
62
- bottom: (_props_margins_bottom = (_props_margins1 = props.margins) === null || _props_margins1 === void 0 ? void 0 : _props_margins1.bottom) !== null && _props_margins_bottom !== void 0 ? _props_margins_bottom : 35,
63
- right: _useRtl ? (_props_margins_left = (_props_margins2 = props.margins) === null || _props_margins2 === void 0 ? void 0 : _props_margins2.left) !== null && _props_margins_left !== void 0 ? _props_margins_left : 40 : ((_props_margins_right = (_props_margins3 = props.margins) === null || _props_margins3 === void 0 ? void 0 : _props_margins3.right) !== null && _props_margins_right !== void 0 ? _props_margins_right : props === null || props === void 0 ? void 0 : props.secondaryYScaleOptions) ? 40 : 20,
64
- left: _useRtl ? ((_props_margins_right1 = (_props_margins4 = props.margins) === null || _props_margins4 === void 0 ? void 0 : _props_margins4.right) !== null && _props_margins_right1 !== void 0 ? _props_margins_right1 : props === null || props === void 0 ? void 0 : props.secondaryYScaleOptions) ? 40 : 20 : (_props_margins_left1 = (_props_margins5 = props.margins) === null || _props_margins5 === void 0 ? void 0 : _props_margins5.left) !== null && _props_margins_left1 !== void 0 ? _props_margins_left1 : 40
65
- };
66
- const TITLE_MARGIN_HORIZONTAL = 24;
67
- const TITLE_MARGIN_VERTICAL = 20;
68
- if (props.xAxisTitle !== undefined && props.xAxisTitle !== '') {
69
- var _props_margins6;
70
- var _props_margins_bottom1;
71
- margins.bottom = (_props_margins_bottom1 = (_props_margins6 = props.margins) === null || _props_margins6 === void 0 ? void 0 : _props_margins6.bottom) !== null && _props_margins_bottom1 !== void 0 ? _props_margins_bottom1 : margins.bottom + TITLE_MARGIN_VERTICAL;
72
- }
73
- if (props.yAxisTitle !== undefined && props.yAxisTitle !== '') {
74
- var _props_margins7, _props_margins8, _props_margins9, _props_margins10;
75
- var _props_margins_right2, _props_margins_left2;
76
- margins.left = _useRtl ? ((_props_margins_right2 = (_props_margins7 = props.margins) === null || _props_margins7 === void 0 ? void 0 : _props_margins7.right) !== null && _props_margins_right2 !== void 0 ? _props_margins_right2 : props === null || props === void 0 ? void 0 : props.secondaryYAxistitle) ? margins.right + 2 * TITLE_MARGIN_HORIZONTAL : margins.right + TITLE_MARGIN_HORIZONTAL : (_props_margins_left2 = (_props_margins8 = props.margins) === null || _props_margins8 === void 0 ? void 0 : _props_margins8.left) !== null && _props_margins_left2 !== void 0 ? _props_margins_left2 : margins.left + TITLE_MARGIN_HORIZONTAL;
77
- var _props_margins_left3, _props_margins_right3;
78
- margins.right = _useRtl ? (_props_margins_left3 = (_props_margins9 = props.margins) === null || _props_margins9 === void 0 ? void 0 : _props_margins9.left) !== null && _props_margins_left3 !== void 0 ? _props_margins_left3 : margins.left + TITLE_MARGIN_HORIZONTAL : ((_props_margins_right3 = (_props_margins10 = props.margins) === null || _props_margins10 === void 0 ? void 0 : _props_margins10.right) !== null && _props_margins_right3 !== void 0 ? _props_margins_right3 : props === null || props === void 0 ? void 0 : props.secondaryYAxistitle) ? margins.right + 2 * TITLE_MARGIN_HORIZONTAL : margins.right + TITLE_MARGIN_HORIZONTAL;
79
- }
80
- if (props.xAxisAnnotation !== undefined && props.xAxisAnnotation !== '') {
81
- var _props_margins11;
82
- var _props_margins_top1;
83
- margins.top = (_props_margins_top1 = (_props_margins11 = props.margins) === null || _props_margins11 === void 0 ? void 0 : _props_margins11.top) !== null && _props_margins_top1 !== void 0 ? _props_margins_top1 : margins.top + TITLE_MARGIN_VERTICAL;
84
- }
85
- if (props.yAxisAnnotation !== undefined && props.yAxisAnnotation !== '' && (props.secondaryYAxistitle === undefined || props.secondaryYAxistitle === '')) {
86
- if (_useRtl) {
87
- var _props_margins12;
88
- var _props_margins_right4;
89
- margins.left = (_props_margins_right4 = (_props_margins12 = props.margins) === null || _props_margins12 === void 0 ? void 0 : _props_margins12.right) !== null && _props_margins_right4 !== void 0 ? _props_margins_right4 : margins.right + TITLE_MARGIN_HORIZONTAL;
90
- } else {
91
- var _props_margins13;
92
- var _props_margins_right5;
93
- margins.right = (_props_margins_right5 = (_props_margins13 = props.margins) === null || _props_margins13 === void 0 ? void 0 : _props_margins13.right) !== null && _props_margins_right5 !== void 0 ? _props_margins_right5 : margins.right + TITLE_MARGIN_HORIZONTAL;
94
- }
95
- }
50
+ const prevWidthRef = React.useRef(undefined);
51
+ const prevHeightRef = React.useRef(undefined);
96
52
  const classes = useCartesianChartStyles(props);
97
53
  const focusAttributes = useFocusableGroup();
98
54
  const arrowAttributes = useArrowNavigationGroup({
@@ -101,10 +57,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
101
57
  // ComponentdidMount and Componentwillunmount logic
102
58
  React.useEffect(()=>{
103
59
  _fitParentContainer();
104
- if (props !== null) {
105
- setPrevProps(props);
106
- }
107
- if (chartTypesWithStringYAxis.includes(props.chartType) && props.showYAxisLables && yAxisElement && props.yAxisType === YAxisType.StringAxis) {
60
+ if (props.showYAxisLables) {
108
61
  const maxYAxisLabelLength = calculateMaxYAxisLabelLength(classes.yAxis);
109
62
  if (startFromX !== maxYAxisLabelLength) {
110
63
  setStartFromX(maxYAxisLabelLength);
@@ -122,12 +75,14 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
122
75
  ]);
123
76
  // ComponentDidUpdate logic
124
77
  React.useEffect(()=>{
125
- if (prevProps) {
126
- if (prevProps.height !== props.height || prevProps.width !== props.width) {
127
- _fitParentContainer();
128
- }
78
+ // Check if height or width changed
79
+ if (prevWidthRef.current !== undefined && prevHeightRef.current !== undefined && (prevWidthRef.current !== props.width || prevHeightRef.current !== props.height)) {
80
+ _fitParentContainer();
129
81
  }
130
- if (chartTypesWithStringYAxis.includes(props.chartType) && props.showYAxisLables && yAxisElement && props.yAxisType === YAxisType.StringAxis) {
82
+ // Update refs with current values
83
+ prevWidthRef.current = props.width;
84
+ prevHeightRef.current = props.height;
85
+ if (props.showYAxisLables) {
131
86
  const maxYAxisLabelLength = calculateMaxYAxisLabelLength(classes.yAxis);
132
87
  if (startFromX !== maxYAxisLabelLength) {
133
88
  setStartFromX(maxYAxisLabelLength);
@@ -136,8 +91,11 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
136
91
  setStartFromX(0);
137
92
  }
138
93
  }, [
139
- props,
140
- prevProps
94
+ props.width,
95
+ props.height,
96
+ props.chartType,
97
+ props.showYAxisLables,
98
+ props.yAxisType
141
99
  ]);
142
100
  React.useImperativeHandle(props.componentRef, ()=>{
143
101
  var _chartContainer_current;
@@ -162,33 +120,26 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
162
120
  }
163
121
  return str;
164
122
  };
165
- return calculateLongestLabelWidth(props.stringDatasetForYAxisDomain.map((label)=>formatTickLabel(label)), `.${className} text`);
123
+ return calculateLongestLabelWidth(_yAxisTickText.current.map((label)=>formatTickLabel(label)), `.${className} text`);
166
124
  }
167
125
  const { calloutProps, points, chartType, svgProps, culture, dateLocalizeOptions, timeFormatLocale, customDateTimeFormatter } = props;
168
126
  if (props.parentRef) {
169
127
  _fitParentContainer();
170
128
  }
171
- const margin = {
172
- ...margins
173
- };
174
- // Note: This check is unnecessary since startFromX is only set for charts with string y-axis.
175
- if (chartTypesWithStringYAxis.includes(props.chartType)) {
176
- if (!_useRtl) {
177
- margin.left += startFromX;
178
- } else {
179
- margin.right += startFromX;
180
- }
181
- }
129
+ margins = _calcMargins();
182
130
  // Callback for margins to the chart
183
- props.getmargins && props.getmargins(margin);
131
+ props.getmargins && props.getmargins(margins);
184
132
  let callout = null;
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
+ let yScalePrimary;
135
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
136
+ let yScaleSecondary;
185
137
  let children = null;
186
138
  if (props.enableFirstRenderOptimization && chartContainer.current || !props.enableFirstRenderOptimization) {
187
139
  _isFirstRender.current = false;
188
140
  var _props_showRoundOffXTickValues;
189
141
  const XAxisParams = {
190
- domainNRangeValues: props.getDomainNRangeValues(points, props.getDomainMargins ? props.getDomainMargins(containerWidth) : margins, containerWidth, chartType, _useRtl, props.xAxisType, props.barwidth, props.tickValues, // This is only used for Horizontal Bar Chart with Axis for y as string axis
191
- startFromX),
142
+ domainNRangeValues: props.getDomainNRangeValues(points, props.getDomainMargins ? props.getDomainMargins(containerWidth) : margins, containerWidth, chartType, _useRtl, props.xAxisType, props.barwidth, props.tickValues),
192
143
  // FIXME: In XAxisParams, containerHeight is used by HBWA to generate vertical gridlines.
193
144
  // Since the x-axis in HBWA is numeric, it typically doesn't require transformation.
194
145
  // However, if transformation props are enabled, the updated _removalValueForTextTuncate
@@ -206,7 +157,7 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
206
157
  xAxisInnerPadding: props.xAxisInnerPadding,
207
158
  xAxisOuterPadding: props.xAxisOuterPadding,
208
159
  containerWidth: containerWidth,
209
- hideTickOverlap: props.rotateXAxisLables ? false : props.hideTickOverlap,
160
+ hideTickOverlap: props.rotateXAxisLables ? false : hideTickOverlap,
210
161
  calcMaxLabelWidth: _calcMaxLabelWidthWithTransform,
211
162
  ...props.xAxis
212
163
  };
@@ -258,15 +209,12 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
258
209
  * 1. To create x and y axis
259
210
  * 2. To draw the graph.
260
211
  * For area/line chart using same scales. For other charts, creating their own scales to draw the graph.
261
- */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
262
- let yScalePrimary;
263
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
264
- let yScaleSecondary;
265
- const axisData = {
266
- yAxisDomainValues: []
212
+ */ const axisData = {
213
+ yAxisDomainValues: [],
214
+ yAxisTickText: []
267
215
  };
268
216
  if (props.yAxisType && props.yAxisType === YAxisType.StringAxis) {
269
- yScalePrimary = props.createStringYAxis(YAxisParams, props.stringDatasetForYAxisDomain, _useRtl, props.barwidth, props.chartType);
217
+ yScalePrimary = props.createStringYAxis(YAxisParams, props.stringDatasetForYAxisDomain, _useRtl, axisData, props.barwidth, props.chartType);
270
218
  } else {
271
219
  // TODO: Since the scale domain values are now computed independently for both the primary and
272
220
  // secondary y-axes, the yMinValue and yMaxValue props are no longer necessary for accurately
@@ -293,42 +241,41 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
293
241
  }
294
242
  yScalePrimary = props.createYAxis(YAxisParams, _useRtl, axisData, isIntegralDataset, chartType, false, props.roundedTicks, props.yScaleType, _useRtl);
295
243
  }
296
- if (chartTypesWithStringYAxis.includes(props.chartType) && props.yAxisType === YAxisType.StringAxis) {
297
- // Removing un wanted tooltip div from DOM, when prop not provided, for proper cleanup
298
- // of unwanted DOM elements, to prevent flacky behaviour in tooltips , that might occur
299
- // in creating tooltips when tooltips are enabled( as we try to recreate a tspan with _tooltipId)
300
- if (!props.showYAxisLablesTooltip) {
301
- try {
302
- document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
303
- //eslint-disable-next-line no-empty
304
- } catch (e) {}
305
- }
306
- // Used to display tooltip at y axis labels.
307
- if (props.showYAxisLablesTooltip) {
308
- // To create y axis tick values by if specified truncating the rest of the text
309
- // and showing elipsis or showing the whole string,
310
- yScalePrimary && // Note: This function should be invoked within the showYAxisLablesTooltip check,
311
- // as its sole purpose is to truncate labels that exceed the noOfCharsToTruncate limit.
312
- createYAxisLabels(yAxisElement.current, yScalePrimary, props.noOfCharsToTruncate || 4, props.showYAxisLablesTooltip || false, _useRtl);
313
- const _yAxisElement = d3Select(yAxisElement.current).call(yScalePrimary);
314
- try {
315
- document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
316
- //eslint-disable-next-line no-empty
317
- } catch (e) {}
318
- const ytooltipProps = {
319
- tooltipCls: classes.tooltip,
320
- id: _tooltipId,
321
- axis: _yAxisElement
322
- };
323
- _yAxisElement && tooltipOfAxislabels(ytooltipProps);
324
- }
244
+ _yAxisTickText.current = axisData.yAxisTickText;
245
+ props.getAxisData && props.getAxisData(axisData);
246
+ // Removing un wanted tooltip div from DOM, when prop not provided, for proper cleanup
247
+ // of unwanted DOM elements, to prevent flacky behaviour in tooltips , that might occur
248
+ // in creating tooltips when tooltips are enabled( as we try to recreate a tspan with _tooltipId)
249
+ if (!props.showYAxisLablesTooltip) {
250
+ try {
251
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
252
+ //eslint-disable-next-line no-empty
253
+ } catch (e) {}
254
+ }
255
+ // Used to display tooltip at y axis labels.
256
+ if (props.showYAxisLablesTooltip) {
257
+ // To create y axis tick values by if specified truncating the rest of the text
258
+ // and showing elipsis or showing the whole string,
259
+ yScalePrimary && // Note: This function should be invoked within the showYAxisLablesTooltip check,
260
+ // as its sole purpose is to truncate labels that exceed the noOfCharsToTruncate limit.
261
+ createYAxisLabels(yAxisElement.current, yScalePrimary, props.noOfCharsToTruncate || 4, props.showYAxisLablesTooltip || false, _useRtl);
262
+ const _yAxisElement = d3Select(yAxisElement.current).call(yScalePrimary);
263
+ try {
264
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
265
+ //eslint-disable-next-line no-empty
266
+ } catch (e) {}
267
+ const ytooltipProps = {
268
+ tooltipCls: classes.tooltip,
269
+ id: _tooltipId,
270
+ axis: _yAxisElement
271
+ };
272
+ _yAxisElement && tooltipOfAxislabels(ytooltipProps);
325
273
  }
326
274
  // Call back to the chart.
327
275
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
328
276
  const _getData = (xScale, yScalePrimary, yScaleSecondary)=>{
329
277
  props.getGraphData && props.getGraphData(xScale, yScalePrimary, containerHeight - _removalValueForTextTuncate, containerWidth, xAxisElement.current, yAxisElement.current, yScaleSecondary);
330
278
  };
331
- props.getAxisData && props.getAxisData(axisData);
332
279
  // Callback function for chart, returns axis
333
280
  _getData(xScale, yScalePrimary, yScaleSecondary);
334
281
  children = props.children({
@@ -346,8 +293,30 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
346
293
  width: containerWidth,
347
294
  height: containerHeight
348
295
  };
349
- const xAxisTitleMaximumAllowedWidth = svgDimensions.width - margins.left - margins.right - startFromX;
350
- const yAxisTitleMaximumAllowedHeight = svgDimensions.height - margins.bottom - margins.top - _removalValueForTextTuncate - titleMargin;
296
+ const plotWidth = Math.max(0, svgDimensions.width - margins.left - margins.right);
297
+ const plotHeight = Math.max(0, svgDimensions.height - margins.top - margins.bottom - _removalValueForTextTuncate);
298
+ const plotRect = {
299
+ x: margins.left,
300
+ y: margins.top,
301
+ width: plotWidth,
302
+ height: plotHeight
303
+ };
304
+ var _props_annotations;
305
+ const annotations = (_props_annotations = props.annotations) !== null && _props_annotations !== void 0 ? _props_annotations : [];
306
+ const hasAnnotations = annotations.length > 0;
307
+ const annotationContext = hasAnnotations ? {
308
+ plotRect,
309
+ svgRect: svgDimensions,
310
+ isRtl: _useRtl,
311
+ xScale: _xScale,
312
+ yScalePrimary,
313
+ yScaleSecondary
314
+ } : undefined;
315
+ const xAxisTitleMaxWidth = svgDimensions.width - margins.left - margins.right - AXIS_TITLE_PADDING * 2;
316
+ const yAxisTitleMaxHeight = svgDimensions.height - margins.bottom - margins.top - _removalValueForTextTuncate - AXIS_TITLE_PADDING * 2;
317
+ const yAxisTitleCenterY = margins.top + AXIS_TITLE_PADDING + yAxisTitleMaxHeight / 2;
318
+ const yAxisTitleCenterX = _useRtl ? svgDimensions.width - AXIS_TITLE_PADDING : HORIZONTAL_MARGIN_FOR_YAXIS_TITLE - AXIS_TITLE_PADDING;
319
+ const secondaryYAxisTitleCenterX = _useRtl ? HORIZONTAL_MARGIN_FOR_YAXIS_TITLE - AXIS_TITLE_PADDING : svgDimensions.width - AXIS_TITLE_PADDING;
351
320
  const commonSvgToolTipProps = {
352
321
  wrapContent,
353
322
  showBackground: true,
@@ -467,6 +436,64 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
467
436
  _removalValueForTextTuncate = rotatedHeight + margins.bottom;
468
437
  }
469
438
  }
439
+ function _calcMargins() {
440
+ let _margins = _getDefaultMargins();
441
+ _margins = _applyTitleMargins(_margins);
442
+ _margins = _applyAnnotationMargins(_margins);
443
+ if (_useRtl) {
444
+ _margins = _swapRtlMargins(_margins);
445
+ }
446
+ return {
447
+ ..._margins,
448
+ ...props.margins
449
+ };
450
+ }
451
+ function _getDefaultMargins() {
452
+ return {
453
+ top: DEFAULT_MARGIN_NO_TICKS,
454
+ // Smaller than the default because it is based on the line height rather than
455
+ // the length of the tick labels.
456
+ bottom: DEFAULT_MARGIN_WITH_TICKS - 5,
457
+ // For the actual margin, add the tick size, tick padding, and some extra space to
458
+ // the width of the longest yaxis tick label (startFromX).
459
+ left: Math.max(DEFAULT_MARGIN_WITH_TICKS, startFromX + 20),
460
+ right: props.secondaryYScaleOptions ? DEFAULT_MARGIN_WITH_TICKS : DEFAULT_MARGIN_NO_TICKS
461
+ };
462
+ }
463
+ function _applyTitleMargins(_margins) {
464
+ const updated = {
465
+ ..._margins
466
+ };
467
+ if (props.xAxisTitle !== undefined && props.xAxisTitle !== '') {
468
+ updated.bottom += VERTICAL_MARGIN_FOR_XAXIS_TITLE;
469
+ }
470
+ if (props.yAxisTitle !== undefined && props.yAxisTitle !== '') {
471
+ updated.left += HORIZONTAL_MARGIN_FOR_YAXIS_TITLE;
472
+ }
473
+ if (props.secondaryYAxistitle !== undefined && props.secondaryYAxistitle !== '') {
474
+ updated.right += HORIZONTAL_MARGIN_FOR_YAXIS_TITLE;
475
+ }
476
+ return updated;
477
+ }
478
+ function _applyAnnotationMargins(_margins) {
479
+ const updated = {
480
+ ..._margins
481
+ };
482
+ if (props.xAxisAnnotation !== undefined && props.xAxisAnnotation !== '') {
483
+ updated.top += VERTICAL_MARGIN_FOR_XAXIS_TITLE;
484
+ }
485
+ if (props.yAxisAnnotation !== undefined && props.yAxisAnnotation !== '' && (props.secondaryYAxistitle === undefined || props.secondaryYAxistitle === '')) {
486
+ updated.right += HORIZONTAL_MARGIN_FOR_YAXIS_TITLE;
487
+ }
488
+ return updated;
489
+ }
490
+ function _swapRtlMargins(_margins) {
491
+ return {
492
+ ..._margins,
493
+ left: _margins.right,
494
+ right: _margins.left
495
+ };
496
+ }
470
497
  /**
471
498
  * We have use the {@link defaultTabbableElement } to fix
472
499
  * the Focus not landing on chart while tabbing, instead goes to legend.
@@ -489,7 +516,9 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
489
516
  id: idForGraph,
490
517
  className: classes.root,
491
518
  role: 'presentation',
492
- ref: (rootElem)=>chartContainer.current = rootElem,
519
+ ref: (rootElem)=>{
520
+ chartContainer.current = rootElem;
521
+ },
493
522
  onMouseLeave: _onChartLeave
494
523
  }, /*#__PURE__*/ React.createElement("div", {
495
524
  className: classes.chartWrapper,
@@ -516,82 +545,82 @@ import { useFocusableGroup, useArrowNavigationGroup } from '@fluentui/react-tabs
516
545
  ...commonSvgToolTipProps,
517
546
  content: props.xAxisTitle,
518
547
  textProps: {
519
- x: margins.left + startFromX + xAxisTitleMaximumAllowedWidth / 2,
520
- y: svgDimensions.height - titleMargin,
548
+ x: margins.left + AXIS_TITLE_PADDING + xAxisTitleMaxWidth / 2,
549
+ y: svgDimensions.height - AXIS_TITLE_PADDING,
521
550
  className: classes.axisTitle,
522
551
  textAnchor: 'middle'
523
552
  },
524
- maxWidth: xAxisTitleMaximumAllowedWidth
553
+ maxWidth: xAxisTitleMaxWidth
525
554
  }), props.xAxisAnnotation !== undefined && props.xAxisAnnotation !== '' && /*#__PURE__*/ React.createElement(SVGTooltipText, {
526
555
  ...commonSvgToolTipProps,
527
556
  content: props.xAxisAnnotation,
528
557
  textProps: {
529
- x: margins.left + startFromX + xAxisTitleMaximumAllowedWidth / 2,
530
- y: titleMargin + 3,
558
+ x: margins.left + AXIS_TITLE_PADDING + xAxisTitleMaxWidth / 2,
559
+ y: VERTICAL_MARGIN_FOR_XAXIS_TITLE - AXIS_TITLE_PADDING,
531
560
  className: classes.axisAnnotation,
532
561
  textAnchor: 'middle',
533
562
  'aria-hidden': true
534
563
  },
535
- maxWidth: xAxisTitleMaximumAllowedWidth
564
+ maxWidth: xAxisTitleMaxWidth
536
565
  }), /*#__PURE__*/ React.createElement("g", {
537
566
  ref: (e)=>{
538
567
  yAxisElement.current = e;
539
568
  },
540
569
  id: `yAxisGElement${idForGraph}`,
541
- transform: `translate(${_useRtl ? svgDimensions.width - margins.right - startFromX : margins.left + startFromX}, 0)`,
570
+ transform: `translate(${_useRtl ? svgDimensions.width - margins.right : margins.left}, 0)`,
542
571
  className: classes.yAxis
543
572
  }), props.secondaryYScaleOptions && /*#__PURE__*/ React.createElement("g", null, /*#__PURE__*/ React.createElement("g", {
544
573
  ref: (e)=>{
545
574
  yAxisElementSecondary.current = e;
546
575
  },
547
576
  id: `yAxisGElementSecondary${idForGraph}`,
548
- transform: `translate(${_useRtl ? margins.left + startFromX : svgDimensions.width - margins.right - startFromX}, 0)`,
577
+ transform: `translate(${_useRtl ? margins.left : svgDimensions.width - margins.right}, 0)`,
549
578
  className: classes.yAxis
550
579
  }), props.secondaryYAxistitle !== undefined && props.secondaryYAxistitle !== '' && /*#__PURE__*/ React.createElement(SVGTooltipText, {
551
580
  ...commonSvgToolTipProps,
552
581
  content: props.secondaryYAxistitle,
553
582
  textProps: {
554
- x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + _removalValueForTextTuncate,
555
- y: _useRtl ? startFromX - titleMargin : svgDimensions.width - margins.right,
583
+ x: secondaryYAxisTitleCenterX,
584
+ y: yAxisTitleCenterY,
556
585
  textAnchor: 'middle',
557
- transform: `translate(${_useRtl ? margins.right / 2 - titleMargin : margins.right / 2 + titleMargin},
558
- ${svgDimensions.height - margins.bottom - margins.top - titleMargin})rotate(-90)`,
586
+ transform: `rotate(-90, ${secondaryYAxisTitleCenterX}, ${yAxisTitleCenterY})`,
559
587
  className: classes.axisTitle
560
588
  },
561
- maxWidth: yAxisTitleMaximumAllowedHeight
589
+ maxWidth: yAxisTitleMaxHeight
562
590
  })), children, props.yAxisTitle !== undefined && props.yAxisTitle !== '' && /*#__PURE__*/ React.createElement(SVGTooltipText, {
563
591
  ...commonSvgToolTipProps,
564
592
  content: props.yAxisTitle,
565
593
  textProps: {
566
- x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + _removalValueForTextTuncate,
567
- y: _useRtl ? svgDimensions.width - margins.right / 2 + titleMargin : margins.left / 2 - titleMargin,
594
+ x: yAxisTitleCenterX,
595
+ y: yAxisTitleCenterY,
568
596
  textAnchor: 'middle',
569
- transform: `translate(0,
570
- ${svgDimensions.height - margins.bottom - margins.top - titleMargin})rotate(-90)`,
597
+ transform: `rotate(-90, ${yAxisTitleCenterX}, ${yAxisTitleCenterY})`,
571
598
  className: classes.axisTitle
572
599
  },
573
- maxWidth: yAxisTitleMaximumAllowedHeight
600
+ maxWidth: yAxisTitleMaxHeight
574
601
  }), props.yAxisAnnotation !== undefined && props.yAxisAnnotation !== '' && (props.secondaryYAxistitle === undefined || props.secondaryYAxistitle === '') && /*#__PURE__*/ React.createElement(SVGTooltipText, {
575
602
  ...commonSvgToolTipProps,
576
603
  content: props.yAxisAnnotation,
577
604
  textProps: {
578
- x: (yAxisTitleMaximumAllowedHeight - margins.bottom) / 2 + _removalValueForTextTuncate,
579
- y: _useRtl ? startFromX - titleMargin : svgDimensions.width - margins.right,
605
+ x: secondaryYAxisTitleCenterX,
606
+ y: yAxisTitleCenterY,
580
607
  textAnchor: 'middle',
581
- transform: `translate(${_useRtl ? margins.right / 2 - titleMargin : margins.right / 2 + titleMargin},
582
- ${svgDimensions.height - margins.bottom - margins.top - titleMargin})rotate(-90)`,
608
+ transform: `rotate(-90, ${secondaryYAxisTitleCenterX}, ${yAxisTitleCenterY})`,
583
609
  className: classes.axisAnnotation,
584
610
  'aria-hidden': true
585
611
  },
586
- maxWidth: yAxisTitleMaximumAllowedHeight
587
- }))), !props.hideLegend && /*#__PURE__*/ React.createElement("div", {
588
- ref: (e)=>legendContainer = e,
612
+ maxWidth: yAxisTitleMaxHeight
613
+ })), hasAnnotations && annotationContext && /*#__PURE__*/ React.createElement(ChartAnnotationLayer, {
614
+ annotations: annotations,
615
+ context: annotationContext,
616
+ className: classes.annotationLayer
617
+ })), !props.hideLegend && /*#__PURE__*/ React.createElement("div", {
618
+ ref: (e)=>{
619
+ legendContainer = e;
620
+ },
589
621
  className: classes.legendContainer
590
622
  }, props.legendBars), callout && /*#__PURE__*/ React.createElement(React.Suspense, {
591
623
  fallback: /*#__PURE__*/ React.createElement("div", null, "Loading...")
592
624
  }, callout));
593
625
  });
594
626
  CartesianChart.displayName = 'CartesianChart';
595
- CartesianChart.defaultProps = {
596
- hideTickOverlap: true
597
- };