@fluentui/react-charts 1.1.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/CHANGELOG.md +181 -11
  2. package/LICENSE +11 -17
  3. package/README.md +174 -23
  4. package/dist/index.d.ts +2143 -0
  5. package/lib/CartesianChart.js +1 -0
  6. package/lib/CartesianChart.js.map +1 -0
  7. package/lib/DeclarativeChart.js +1 -0
  8. package/lib/DeclarativeChart.js.map +1 -0
  9. package/lib/DonutChart.js +1 -0
  10. package/lib/DonutChart.js.map +1 -0
  11. package/lib/HorizontalBarChart.js +1 -0
  12. package/lib/HorizontalBarChart.js.map +1 -0
  13. package/lib/Legends.js +1 -0
  14. package/lib/Legends.js.map +1 -0
  15. package/lib/LineChart.js +1 -0
  16. package/lib/LineChart.js.map +1 -0
  17. package/lib/Popover.js +1 -0
  18. package/lib/Popover.js.map +1 -0
  19. package/lib/ResponsiveContainer.js +1 -0
  20. package/lib/ResponsiveContainer.js.map +1 -0
  21. package/lib/Sparkline.js +1 -0
  22. package/lib/Sparkline.js.map +1 -0
  23. package/lib/VerticalBarChart.js +1 -0
  24. package/lib/VerticalBarChart.js.map +1 -0
  25. package/lib/components/CommonComponents/CartesianChart.js +462 -0
  26. package/lib/components/CommonComponents/CartesianChart.js.map +1 -0
  27. package/lib/components/CommonComponents/CartesianChart.types.js +1 -0
  28. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -0
  29. package/lib/components/CommonComponents/ChartPopover.js +187 -0
  30. package/lib/components/CommonComponents/ChartPopover.js.map +1 -0
  31. package/lib/components/CommonComponents/ChartPopover.types.js +1 -0
  32. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -0
  33. package/lib/components/CommonComponents/index.js +4 -0
  34. package/lib/components/CommonComponents/index.js.map +1 -0
  35. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +229 -0
  36. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -0
  37. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +178 -0
  38. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -0
  39. package/lib/components/DeclarativeChart/DeclarativeChart.js +150 -0
  40. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -0
  41. package/lib/components/DeclarativeChart/PlotlySchema.js +7 -0
  42. package/lib/components/DeclarativeChart/PlotlySchema.js.map +1 -0
  43. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +400 -0
  44. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -0
  45. package/lib/components/DeclarativeChart/imageExporter.js +221 -0
  46. package/lib/components/DeclarativeChart/imageExporter.js.map +1 -0
  47. package/lib/components/DeclarativeChart/index.js +1 -0
  48. package/lib/components/DeclarativeChart/index.js.map +1 -0
  49. package/lib/components/DonutChart/Arc/Arc.js +110 -0
  50. package/lib/components/DonutChart/Arc/Arc.js.map +1 -0
  51. package/lib/components/DonutChart/Arc/Arc.types.js +1 -0
  52. package/lib/components/DonutChart/Arc/Arc.types.js.map +1 -0
  53. package/lib/components/DonutChart/Arc/index.js +2 -0
  54. package/lib/components/DonutChart/Arc/index.js.map +1 -0
  55. package/lib/components/DonutChart/Arc/useArcStyles.styles.js +54 -0
  56. package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -0
  57. package/lib/components/DonutChart/DonutChart.js +291 -0
  58. package/lib/components/DonutChart/DonutChart.js.map +1 -0
  59. package/lib/components/DonutChart/DonutChart.types.js +1 -0
  60. package/lib/components/DonutChart/DonutChart.types.js.map +1 -0
  61. package/lib/components/DonutChart/Pie/Pie.js +72 -0
  62. package/lib/components/DonutChart/Pie/Pie.js.map +1 -0
  63. package/lib/components/DonutChart/Pie/Pie.types.js +1 -0
  64. package/lib/components/DonutChart/Pie/Pie.types.js.map +1 -0
  65. package/lib/components/DonutChart/Pie/index.js +2 -0
  66. package/lib/components/DonutChart/Pie/index.js.map +1 -0
  67. package/lib/components/DonutChart/Pie/usePieStyles.styles.js +44 -0
  68. package/lib/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -0
  69. package/lib/components/DonutChart/index.js +3 -0
  70. package/lib/components/DonutChart/index.js.map +1 -0
  71. package/lib/components/DonutChart/useDonutChartStyles.styles.js +58 -0
  72. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -0
  73. package/lib/components/HorizontalBarChart/HorizontalBarChart.js +402 -0
  74. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -0
  75. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js +6 -0
  76. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -0
  77. package/lib/components/HorizontalBarChart/index.js +3 -0
  78. package/lib/components/HorizontalBarChart/index.js.map +1 -0
  79. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +163 -0
  80. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -0
  81. package/lib/components/Legends/Legends.js +302 -0
  82. package/lib/components/Legends/Legends.js.map +1 -0
  83. package/lib/components/Legends/Legends.types.js +1 -0
  84. package/lib/components/Legends/Legends.types.js.map +1 -0
  85. package/lib/components/Legends/OverflowMenu.js +25 -0
  86. package/lib/components/Legends/OverflowMenu.js.map +1 -0
  87. package/lib/components/Legends/index.js +3 -0
  88. package/lib/components/Legends/index.js.map +1 -0
  89. package/lib/components/Legends/shape.js +35 -0
  90. package/lib/components/Legends/shape.js.map +1 -0
  91. package/lib/components/Legends/useLegendsStyles.styles.js +147 -0
  92. package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -0
  93. package/lib/components/LineChart/LineChart.js +1026 -0
  94. package/lib/components/LineChart/LineChart.js.map +1 -0
  95. package/lib/components/LineChart/LineChart.types.js +3 -0
  96. package/lib/components/LineChart/LineChart.types.js.map +1 -0
  97. package/lib/components/LineChart/eventAnnotation/EventAnnotation.js +119 -0
  98. package/lib/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -0
  99. package/lib/components/LineChart/eventAnnotation/LabelLink.js +57 -0
  100. package/lib/components/LineChart/eventAnnotation/LabelLink.js.map +1 -0
  101. package/lib/components/LineChart/eventAnnotation/Textbox.js +40 -0
  102. package/lib/components/LineChart/eventAnnotation/Textbox.js.map +1 -0
  103. package/lib/components/LineChart/index.js +4 -0
  104. package/lib/components/LineChart/index.js.map +1 -0
  105. package/lib/components/LineChart/useLineChartStyles.styles.js +65 -0
  106. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -0
  107. package/lib/components/ResponsiveContainer/ResponsiveContainer.js +65 -0
  108. package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -0
  109. package/lib/components/ResponsiveContainer/ResponsiveContainer.types.js +1 -0
  110. package/lib/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -0
  111. package/lib/components/ResponsiveContainer/index.js +1 -0
  112. package/lib/components/ResponsiveContainer/index.js.map +1 -0
  113. package/lib/components/ResponsiveContainer/useResponsiveContainerStyles.styles.js +23 -0
  114. package/lib/components/ResponsiveContainer/useResponsiveContainerStyles.styles.js.map +1 -0
  115. package/lib/components/Sparkline/Sparkline.js +119 -0
  116. package/lib/components/Sparkline/Sparkline.js.map +1 -0
  117. package/lib/components/Sparkline/Sparkline.types.js +4 -0
  118. package/lib/components/Sparkline/Sparkline.types.js.map +1 -0
  119. package/lib/components/Sparkline/index.js +3 -0
  120. package/lib/components/Sparkline/index.js.map +1 -0
  121. package/lib/components/Sparkline/useSparklineStyles.styles.js +49 -0
  122. package/lib/components/Sparkline/useSparklineStyles.styles.js.map +1 -0
  123. package/lib/components/VerticalBarChart/VerticalBarChart.js +849 -0
  124. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -0
  125. package/lib/components/VerticalBarChart/VerticalBarChart.types.js +4 -0
  126. package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -0
  127. package/lib/components/VerticalBarChart/index.js +3 -0
  128. package/lib/components/VerticalBarChart/index.js.map +1 -0
  129. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +74 -0
  130. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -0
  131. package/lib/index.js +12 -8
  132. package/lib/index.js.map +1 -1
  133. package/lib/types/DataPoint.js +3 -0
  134. package/lib/types/DataPoint.js.map +1 -0
  135. package/lib/types/EventAnnotation.js +1 -0
  136. package/lib/types/EventAnnotation.js.map +1 -0
  137. package/lib/types/LegendDataItem.js +1 -0
  138. package/lib/types/LegendDataItem.js.map +1 -0
  139. package/lib/types/index.js +2 -2
  140. package/lib/types/index.js.map +1 -1
  141. package/lib/utilities/FocusableTooltipText.js +65 -0
  142. package/lib/utilities/FocusableTooltipText.js.map +1 -0
  143. package/lib/utilities/KeyCodes.js +8 -0
  144. package/lib/utilities/KeyCodes.js.map +1 -0
  145. package/lib/utilities/SVGTooltipText.js +138 -0
  146. package/lib/utilities/SVGTooltipText.js.map +1 -0
  147. package/lib/utilities/async-utils.js +380 -0
  148. package/lib/utilities/async-utils.js.map +1 -0
  149. package/lib/utilities/colors.js +249 -0
  150. package/lib/utilities/colors.js.map +1 -0
  151. package/lib/utilities/getWindow.js +25 -0
  152. package/lib/utilities/getWindow.js.map +1 -0
  153. package/lib/utilities/index.js +3 -0
  154. package/lib/utilities/index.js.map +1 -0
  155. package/lib/utilities/locale-util.js +15 -0
  156. package/lib/utilities/locale-util.js.map +1 -0
  157. package/lib/utilities/overflow-utils.js +27 -0
  158. package/lib/utilities/overflow-utils.js.map +1 -0
  159. package/lib/utilities/test-data.js +276 -0
  160. package/lib/utilities/test-data.js.map +1 -0
  161. package/lib/utilities/utilities.js +1215 -0
  162. package/lib/utilities/utilities.js.map +1 -0
  163. package/lib/utilities/vbc-utils.js +27 -0
  164. package/lib/utilities/vbc-utils.js.map +1 -0
  165. package/lib-commonjs/CartesianChart.js +6 -0
  166. package/lib-commonjs/CartesianChart.js.map +1 -0
  167. package/lib-commonjs/DeclarativeChart.js +6 -0
  168. package/lib-commonjs/DeclarativeChart.js.map +1 -0
  169. package/lib-commonjs/DonutChart.js +6 -0
  170. package/lib-commonjs/DonutChart.js.map +1 -0
  171. package/lib-commonjs/HorizontalBarChart.js +6 -0
  172. package/lib-commonjs/HorizontalBarChart.js.map +1 -0
  173. package/lib-commonjs/Legends.js +6 -0
  174. package/lib-commonjs/Legends.js.map +1 -0
  175. package/lib-commonjs/LineChart.js +6 -0
  176. package/lib-commonjs/LineChart.js.map +1 -0
  177. package/lib-commonjs/Popover.js +6 -0
  178. package/lib-commonjs/Popover.js.map +1 -0
  179. package/lib-commonjs/ResponsiveContainer.js +6 -0
  180. package/lib-commonjs/ResponsiveContainer.js.map +1 -0
  181. package/lib-commonjs/Sparkline.js +6 -0
  182. package/lib-commonjs/Sparkline.js.map +1 -0
  183. package/lib-commonjs/VerticalBarChart.js +6 -0
  184. package/lib-commonjs/VerticalBarChart.js.map +1 -0
  185. package/lib-commonjs/components/CommonComponents/CartesianChart.js +469 -0
  186. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -0
  187. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js +6 -0
  188. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -0
  189. package/lib-commonjs/components/CommonComponents/ChartPopover.js +197 -0
  190. package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -0
  191. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js +4 -0
  192. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -0
  193. package/lib-commonjs/components/CommonComponents/index.js +9 -0
  194. package/lib-commonjs/components/CommonComponents/index.js.map +1 -0
  195. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +356 -0
  196. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -0
  197. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +261 -0
  198. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -0
  199. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +158 -0
  200. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -0
  201. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js +10 -0
  202. package/lib-commonjs/components/DeclarativeChart/PlotlySchema.js.map +1 -0
  203. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +445 -0
  204. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -0
  205. package/lib-commonjs/components/DeclarativeChart/imageExporter.js +231 -0
  206. package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +1 -0
  207. package/lib-commonjs/components/DeclarativeChart/index.js +6 -0
  208. package/lib-commonjs/components/DeclarativeChart/index.js.map +1 -0
  209. package/lib-commonjs/components/DonutChart/Arc/Arc.js +117 -0
  210. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -0
  211. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js +4 -0
  212. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js.map +1 -0
  213. package/lib-commonjs/components/DonutChart/Arc/index.js +7 -0
  214. package/lib-commonjs/components/DonutChart/Arc/index.js.map +1 -0
  215. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +83 -0
  216. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -0
  217. package/lib-commonjs/components/DonutChart/DonutChart.js +298 -0
  218. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -0
  219. package/lib-commonjs/components/DonutChart/DonutChart.types.js +6 -0
  220. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -0
  221. package/lib-commonjs/components/DonutChart/Pie/Pie.js +79 -0
  222. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -0
  223. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js +4 -0
  224. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js.map +1 -0
  225. package/lib-commonjs/components/DonutChart/Pie/index.js +7 -0
  226. package/lib-commonjs/components/DonutChart/Pie/index.js.map +1 -0
  227. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js +61 -0
  228. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -0
  229. package/lib-commonjs/components/DonutChart/index.js +8 -0
  230. package/lib-commonjs/components/DonutChart/index.js.map +1 -0
  231. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +82 -0
  232. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -0
  233. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +408 -0
  234. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -0
  235. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js +17 -0
  236. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -0
  237. package/lib-commonjs/components/HorizontalBarChart/index.js +8 -0
  238. package/lib-commonjs/components/HorizontalBarChart/index.js.map +1 -0
  239. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +251 -0
  240. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -0
  241. package/lib-commonjs/components/Legends/Legends.js +313 -0
  242. package/lib-commonjs/components/Legends/Legends.js.map +1 -0
  243. package/lib-commonjs/components/Legends/Legends.types.js +6 -0
  244. package/lib-commonjs/components/Legends/Legends.types.js.map +1 -0
  245. package/lib-commonjs/components/Legends/OverflowMenu.js +36 -0
  246. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -0
  247. package/lib-commonjs/components/Legends/index.js +8 -0
  248. package/lib-commonjs/components/Legends/index.js.map +1 -0
  249. package/lib-commonjs/components/Legends/shape.js +46 -0
  250. package/lib-commonjs/components/Legends/shape.js.map +1 -0
  251. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +304 -0
  252. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -0
  253. package/lib-commonjs/components/LineChart/LineChart.js +1032 -0
  254. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -0
  255. package/lib-commonjs/components/LineChart/LineChart.types.js +6 -0
  256. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -0
  257. package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js +129 -0
  258. package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -0
  259. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js +68 -0
  260. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js.map +1 -0
  261. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js +51 -0
  262. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +1 -0
  263. package/lib-commonjs/components/LineChart/index.js +9 -0
  264. package/lib-commonjs/components/LineChart/index.js.map +1 -0
  265. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +96 -0
  266. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -0
  267. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js +76 -0
  268. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -0
  269. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.js +6 -0
  270. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -0
  271. package/lib-commonjs/components/ResponsiveContainer/index.js +6 -0
  272. package/lib-commonjs/components/ResponsiveContainer/index.js.map +1 -0
  273. package/lib-commonjs/components/ResponsiveContainer/useResponsiveContainerStyles.styles.js +47 -0
  274. package/lib-commonjs/components/ResponsiveContainer/useResponsiveContainerStyles.styles.js.map +1 -0
  275. package/lib-commonjs/components/Sparkline/Sparkline.js +125 -0
  276. package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -0
  277. package/lib-commonjs/components/Sparkline/Sparkline.types.js +7 -0
  278. package/lib-commonjs/components/Sparkline/Sparkline.types.js.map +1 -0
  279. package/lib-commonjs/components/Sparkline/index.js +8 -0
  280. package/lib-commonjs/components/Sparkline/index.js.map +1 -0
  281. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js +77 -0
  282. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js.map +1 -0
  283. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +851 -0
  284. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -0
  285. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js +7 -0
  286. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -0
  287. package/lib-commonjs/components/VerticalBarChart/index.js +8 -0
  288. package/lib-commonjs/components/VerticalBarChart/index.js.map +1 -0
  289. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +117 -0
  290. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -0
  291. package/lib-commonjs/index.js +17 -0
  292. package/lib-commonjs/index.js.map +1 -0
  293. package/lib-commonjs/types/DataPoint.js +6 -0
  294. package/lib-commonjs/types/DataPoint.js.map +1 -0
  295. package/lib-commonjs/types/EventAnnotation.js +6 -0
  296. package/lib-commonjs/types/EventAnnotation.js.map +1 -0
  297. package/lib-commonjs/types/LegendDataItem.js +4 -0
  298. package/lib-commonjs/types/LegendDataItem.js.map +1 -0
  299. package/lib-commonjs/types/index.js +7 -0
  300. package/lib-commonjs/types/index.js.map +1 -0
  301. package/lib-commonjs/utilities/FocusableTooltipText.js +75 -0
  302. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -0
  303. package/lib-commonjs/utilities/KeyCodes.js +18 -0
  304. package/lib-commonjs/utilities/KeyCodes.js.map +1 -0
  305. package/lib-commonjs/utilities/SVGTooltipText.js +148 -0
  306. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -0
  307. package/lib-commonjs/utilities/async-utils.js +382 -0
  308. package/lib-commonjs/utilities/async-utils.js.map +1 -0
  309. package/lib-commonjs/utilities/colors.js +270 -0
  310. package/lib-commonjs/utilities/colors.js.map +1 -0
  311. package/lib-commonjs/utilities/getWindow.js +28 -0
  312. package/lib-commonjs/utilities/getWindow.js.map +1 -0
  313. package/lib-commonjs/utilities/index.js +8 -0
  314. package/lib-commonjs/utilities/index.js.map +1 -0
  315. package/lib-commonjs/utilities/locale-util.js +25 -0
  316. package/lib-commonjs/utilities/locale-util.js.map +1 -0
  317. package/lib-commonjs/utilities/overflow-utils.js +36 -0
  318. package/lib-commonjs/utilities/overflow-utils.js.map +1 -0
  319. package/lib-commonjs/utilities/test-data.js +324 -0
  320. package/lib-commonjs/utilities/test-data.js.map +1 -0
  321. package/lib-commonjs/utilities/utilities.js +1184 -0
  322. package/lib-commonjs/utilities/utilities.js.map +1 -0
  323. package/lib-commonjs/utilities/vbc-utils.js +45 -0
  324. package/lib-commonjs/utilities/vbc-utils.js.map +1 -0
  325. package/package.json +80 -71
  326. package/CHANGELOG.json +0 -50
  327. package/lib/chart/chart-legend.d.ts +0 -6
  328. package/lib/chart/chart-legend.js +0 -446
  329. package/lib/chart/chart-legend.js.map +0 -1
  330. package/lib/chart/chart-render.d.ts +0 -3
  331. package/lib/chart/chart-render.js +0 -50
  332. package/lib/chart/chart-render.js.map +0 -1
  333. package/lib/chart/chart.d.ts +0 -3
  334. package/lib/chart/chart.js +0 -11
  335. package/lib/chart/chart.js.map +0 -1
  336. package/lib/chart/index.d.ts +0 -1
  337. package/lib/chart/index.js +0 -2
  338. package/lib/chart/index.js.map +0 -1
  339. package/lib/index.d.ts +0 -7
  340. package/lib/lib/builder.d.ts +0 -82
  341. package/lib/lib/builder.js +0 -341
  342. package/lib/lib/builder.js.map +0 -1
  343. package/lib/lib/datasets.d.ts +0 -99
  344. package/lib/lib/datasets.js +0 -240
  345. package/lib/lib/datasets.js.map +0 -1
  346. package/lib/lib/patterns.d.ts +0 -43
  347. package/lib/lib/patterns.js +0 -433
  348. package/lib/lib/patterns.js.map +0 -1
  349. package/lib/lib/plugins.d.ts +0 -11
  350. package/lib/lib/plugins.js +0 -403
  351. package/lib/lib/plugins.js.map +0 -1
  352. package/lib/lib/settings.d.ts +0 -11
  353. package/lib/lib/settings.js +0 -342
  354. package/lib/lib/settings.js.map +0 -1
  355. package/lib/lib/storybook.d.ts +0 -11
  356. package/lib/lib/storybook.js +0 -13
  357. package/lib/lib/storybook.js.map +0 -1
  358. package/lib/lib/utils.d.ts +0 -34
  359. package/lib/lib/utils.js +0 -253
  360. package/lib/lib/utils.js.map +0 -1
  361. package/lib/types/index.d.ts +0 -1
  362. package/lib/types/types.d.ts +0 -94
  363. package/lib/types/types.js +0 -41
  364. package/lib/types/types.js.map +0 -1
@@ -0,0 +1,849 @@
1
+ import * as React from 'react';
2
+ import { useVerticalBarChartStyles } from './useVerticalBarChartStyles.styles';
3
+ import { max as d3Max, min as d3Min } from 'd3-array';
4
+ import { line as d3Line } from 'd3-shape';
5
+ import { select as d3Select } from 'd3-selection';
6
+ import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand, scaleUtc as d3ScaleUtc } from 'd3-scale';
7
+ import { useId } from '@fluentui/react-utilities';
8
+ import { tokens } from '@fluentui/react-theme';
9
+ import { CartesianChart, Legends, ChartPopover } from '../../index';
10
+ import { ChartTypes, getAccessibleDataObject, XAxisTypes, getTypeOfAxis, tooltipOfXAxislabels, formatValueWithSIPrefix, getBarWidth, getScalePadding, isScalePaddingDefined, calculateAppropriateBarWidth, useRtl } from '../../utilities/index';
11
+ var CircleVisbility;
12
+ (function(CircleVisbility) {
13
+ CircleVisbility["show"] = "visibility";
14
+ CircleVisbility["hide"] = "hidden";
15
+ })(CircleVisbility || (CircleVisbility = {}));
16
+ const MIN_DOMAIN_MARGIN = 8;
17
+ // Create a VerticalBarChart variant which uses these default styles and this styled subcomponent.
18
+ /**
19
+ * VerticalBarchart component
20
+ * {@docCategory VerticalBarChart}
21
+ */ export const VerticalBarChart = /*#__PURE__*/ React.forwardRef((props, forwardedRef)=>{
22
+ let _points = [];
23
+ let _barWidth = 0;
24
+ let _colors;
25
+ const _refArray = [];
26
+ let margins;
27
+ const _useRtl = useRtl();
28
+ let _bars;
29
+ let _xAxisLabels;
30
+ let _yMax;
31
+ let _isHavingLine = _checkForLine();
32
+ const _tooltipId = useId('VCTooltipID_');
33
+ const _xAxisType = props.data && props.data.length > 0 ? getTypeOfAxis(props.data[0].x, true) : XAxisTypes.StringAxis;
34
+ let _calloutAnchorPoint;
35
+ let _domainMargin;
36
+ const _emptyChartId = useId('_VBC_empty');
37
+ const _vbcLineId = useId('_VBC_line_');
38
+ const _vbcPointId = useId('_VBC_point_');
39
+ const _vbcBarId = useId('_VBC_bar_');
40
+ let _xAxisInnerPadding = 0;
41
+ let _xAxisOuterPadding = 0;
42
+ const cartesianChartRef = React.useRef(null);
43
+ const [color, setColor] = React.useState('');
44
+ const [dataForHoverCard, setDataForHoverCard] = React.useState(0);
45
+ const [selectedLegend, setSelectedLegend] = React.useState('');
46
+ const [activeLegend, setActiveLegend] = React.useState('');
47
+ const [xCalloutValue, setXCalloutValue] = React.useState('');
48
+ const [yCalloutValue, setYCalloutValue] = React.useState('');
49
+ const [activeXdataPoint, setActiveXDatapoint] = React.useState(null);
50
+ const [YValueHover, setYValueHover] = React.useState();
51
+ const [hoverXValue, setHoverXValue] = React.useState('');
52
+ const [calloutLegend, setCalloutLegend] = React.useState('');
53
+ const [callOutAccessibilityData, setCalloutAccessibilityData] = React.useState();
54
+ const [dataPointCalloutProps, setDataPointCalloutProps] = React.useState();
55
+ const [clickPosition, setClickPosition] = React.useState({
56
+ x: 0,
57
+ y: 0
58
+ });
59
+ const [isPopoverOpen, setPopoverOpen] = React.useState(false);
60
+ React.useImperativeHandle(props.componentRef, ()=>{
61
+ var _cartesianChartRef_current;
62
+ var _cartesianChartRef_current_chartContainer;
63
+ return {
64
+ chartContainer: (_cartesianChartRef_current_chartContainer = (_cartesianChartRef_current = cartesianChartRef.current) === null || _cartesianChartRef_current === void 0 ? void 0 : _cartesianChartRef_current.chartContainer) !== null && _cartesianChartRef_current_chartContainer !== void 0 ? _cartesianChartRef_current_chartContainer : null
65
+ };
66
+ }, []);
67
+ function _createLine(// eslint-disable-next-line @typescript-eslint/no-explicit-any
68
+ xScale, // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ yScale, containerHeight = 0, containerWidth = 0, // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
+ yScaleSecondary) {
71
+ var _props_lineOptions;
72
+ const isStringAxis = _xAxisType === XAxisTypes.StringAxis;
73
+ const colorScale = _createColors();
74
+ const { data, lineLegendColor = tokens.colorPaletteYellowBackground1, lineLegendText } = props;
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+ const lineData = [];
77
+ const line = [];
78
+ data && data.forEach((item, index)=>{
79
+ if (item.lineData && item.lineData.y) {
80
+ var _item_lineData_useSecondaryYScale;
81
+ lineData.push({
82
+ x: item.x,
83
+ y: item.lineData.y,
84
+ useSecondaryYScale: (_item_lineData_useSecondaryYScale = item.lineData.useSecondaryYScale) !== null && _item_lineData_useSecondaryYScale !== void 0 ? _item_lineData_useSecondaryYScale : false,
85
+ point: item,
86
+ index
87
+ });
88
+ }
89
+ });
90
+ const linePath = d3Line()// eslint-disable-next-line @typescript-eslint/no-explicit-any
91
+ .x((d)=>isStringAxis ? xScale(d.x) + 0.5 * xScale.bandwidth() : xScale(d.x))// eslint-disable-next-line @typescript-eslint/no-explicit-any
92
+ .y((d)=>d.useSecondaryYScale && yScaleSecondary ? yScaleSecondary(d.y) : yScale(d.y));
93
+ const shouldHighlight = _legendHighlighted(lineLegendText) || _noLegendHighlighted() ? true : false;
94
+ const lineBorderWidth = ((_props_lineOptions = props.lineOptions) === null || _props_lineOptions === void 0 ? void 0 : _props_lineOptions.lineBorderWidth) ? Number.parseFloat(props.lineOptions.lineBorderWidth.toString()) : 0;
95
+ if (lineBorderWidth > 0) {
96
+ line.push(/*#__PURE__*/ React.createElement("path", {
97
+ key: _vbcLineId,
98
+ id: _vbcLineId,
99
+ opacity: shouldHighlight ? 1 : 0.1,
100
+ d: linePath(lineData),
101
+ fill: "transparent",
102
+ strokeLinecap: "square",
103
+ strokeWidth: 3 + lineBorderWidth * 2,
104
+ stroke: tokens.colorNeutralBackground1
105
+ }));
106
+ }
107
+ line.push(/*#__PURE__*/ React.createElement("path", {
108
+ key: _vbcLineId,
109
+ id: _vbcLineId,
110
+ opacity: shouldHighlight ? 1 : 0.1,
111
+ d: linePath(lineData),
112
+ fill: "transparent",
113
+ strokeLinecap: "square",
114
+ strokeWidth: 3,
115
+ stroke: lineLegendColor
116
+ }));
117
+ const dots = lineData.map((item, index)=>{
118
+ var _item_point_lineData;
119
+ // Create an object to store line point ref so that the object can be passed by reference to the focus handler
120
+ const circleRef = {
121
+ refElement: null
122
+ };
123
+ return /*#__PURE__*/ React.createElement("circle", {
124
+ key: index,
125
+ id: `${_vbcPointId}-${index}`,
126
+ cx: isStringAxis ? xScale(item.x) + 0.5 * xScale.bandwidth() : xScale(item.x),
127
+ cy: item.useSecondaryYScale && yScaleSecondary ? yScaleSecondary(item.y) : yScale(item.y),
128
+ onMouseOver: _legendHighlighted(lineLegendText) ? _lineHover.bind(item.point) : (event)=>_onBarHover(item.point, colorScale(item.y), event),
129
+ onMouseOut: _onBarLeave,
130
+ r: _getCircleVisibilityAndRadius(item.x, lineLegendText).radius,
131
+ stroke: lineLegendColor,
132
+ fill: tokens.colorNeutralBackground1,
133
+ strokeWidth: 3,
134
+ visibility: _getCircleVisibilityAndRadius(item.x, lineLegendText).visibility,
135
+ onClick: (_item_point_lineData = item.point.lineData) === null || _item_point_lineData === void 0 ? void 0 : _item_point_lineData.onClick,
136
+ // When no legend is highlighted: Line points are automatically displayed along with the bars
137
+ // at the same x-axis point in the stack callout. So to prevent an increase in focusable elements
138
+ // and avoid conveying duplicate info, make these line points non-focusable.
139
+ "data-is-focusable": _legendHighlighted(lineLegendText),
140
+ ref: (e)=>circleRef.refElement = e,
141
+ onFocus: _lineFocus.bind(item.point, circleRef),
142
+ onBlur: _handleChartMouseLeave
143
+ });
144
+ });
145
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, line, dots);
146
+ }
147
+ function _getCircleVisibilityAndRadius(xAxisPoint, legend) {
148
+ if (selectedLegend !== '') {
149
+ if (xAxisPoint === activeXdataPoint && selectedLegend === legend) {
150
+ return {
151
+ visibility: "visibility",
152
+ radius: 8
153
+ };
154
+ } else if (selectedLegend === legend) {
155
+ // Don't hide the circle to keep it focusable. For more information,
156
+ // see https://fuzzbomb.github.io/accessibility-demos/visually-hidden-focus-test.html
157
+ return {
158
+ visibility: "visibility",
159
+ radius: 0.3
160
+ };
161
+ } else {
162
+ return {
163
+ visibility: "hidden",
164
+ radius: 0
165
+ };
166
+ }
167
+ } else {
168
+ return {
169
+ visibility: activeXdataPoint === xAxisPoint ? "visibility" : "hidden",
170
+ radius: 8
171
+ };
172
+ }
173
+ }
174
+ function _checkForLine() {
175
+ const { data } = props;
176
+ return data.some((item)=>{
177
+ var _item_lineData;
178
+ return (item === null || item === void 0 ? void 0 : (_item_lineData = item.lineData) === null || _item_lineData === void 0 ? void 0 : _item_lineData.y) !== undefined;
179
+ });
180
+ }
181
+ function _adjustProps() {
182
+ _points = props.data || [];
183
+ _barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
184
+ const defaultColors = [
185
+ tokens.colorPaletteBlueForeground2,
186
+ tokens.colorPaletteCornflowerForeground2,
187
+ tokens.colorPaletteDarkGreenForeground2,
188
+ tokens.colorPaletteNavyForeground2,
189
+ tokens.colorPaletteDarkOrangeForeground2
190
+ ];
191
+ _colors = props.colors || defaultColors;
192
+ _isHavingLine = _checkForLine();
193
+ _xAxisInnerPadding = getScalePadding(props.xAxisInnerPadding, props.xAxisPadding, 2 / 3);
194
+ _xAxisOuterPadding = getScalePadding(props.xAxisOuterPadding, props.xAxisPadding, 0);
195
+ }
196
+ function _getMargins(_margins) {
197
+ margins = _margins;
198
+ }
199
+ function _renderContentForBothLineAndBars(point) {
200
+ // eslint-disable-next-line @typescript-eslint/no-shadow
201
+ const { YValueHover, hoverXValue } = _getCalloutContentForLineAndBar(point);
202
+ const content = YValueHover.map((item, index)=>{
203
+ var _props_culture;
204
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(ChartPopover, {
205
+ culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
206
+ clickPosition: clickPosition,
207
+ isPopoverOpen: isPopoverOpen,
208
+ legend: item.legend,
209
+ ...index === 0 && {
210
+ XValue: `${hoverXValue || item.data}`
211
+ },
212
+ YValue: item.data || item.y,
213
+ color: item.color,
214
+ isCalloutForStack: false
215
+ }));
216
+ });
217
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, content);
218
+ }
219
+ function _renderContentForOnlyBars(_props) {
220
+ var _props_culture;
221
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(ChartPopover, {
222
+ XValue: _props.xAxisCalloutData || _props.x,
223
+ xCalloutValue: xCalloutValue,
224
+ yCalloutValue: yCalloutValue,
225
+ culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
226
+ clickPosition: clickPosition,
227
+ isPopoverOpen: isPopoverOpen,
228
+ legend: _props.legend,
229
+ YValue: _props.yAxisCalloutData || _props.y,
230
+ color: !props.useSingleColor && _props.color ? _props.color : _createColors()(_props.y),
231
+ isCalloutForStack: false
232
+ }));
233
+ }
234
+ // eslint-disable-next-line @typescript-eslint/no-shadow
235
+ function _renderCallout(props) {
236
+ return props ? _isHavingLine ? _renderContentForBothLineAndBars(props) : _renderContentForOnlyBars(props) : null;
237
+ }
238
+ function _getCustomizedCallout() {
239
+ return props.onRenderCalloutPerDataPoint ? props.onRenderCalloutPerDataPoint(dataPointCalloutProps, _renderCallout) : null;
240
+ }
241
+ function _getGraphData(// eslint-disable-next-line @typescript-eslint/no-explicit-any
242
+ xScale, yScale, containerHeight, containerWidth, xElement) {
243
+ return _bars = _xAxisType === XAxisTypes.NumericAxis ? _createNumericBars(containerHeight, containerWidth, xElement) : _xAxisType === XAxisTypes.DateAxis ? _createDateBars(containerHeight, containerWidth, xElement) : _createStringBars(containerHeight, containerWidth, xElement);
244
+ }
245
+ function _createColors() {
246
+ const increment = _colors.length <= 1 ? 1 : 1 / (_colors.length - 1);
247
+ const { useSingleColor = false } = props;
248
+ if (useSingleColor) {
249
+ return (_p)=>{
250
+ const { colors } = props;
251
+ return colors && colors.length > 0 ? colors[0] : tokens.colorPaletteBlueBackground2;
252
+ };
253
+ }
254
+ const domainValues = [];
255
+ for(let i = 0; i < _colors.length; i++){
256
+ domainValues.push(increment * i * _yMax);
257
+ }
258
+ const colorScale = d3ScaleLinear().domain(domainValues).range(_colors);
259
+ return colorScale;
260
+ }
261
+ function _refCallback(element, legendTitle) {
262
+ _refArray.push({
263
+ index: legendTitle,
264
+ refElement: element
265
+ });
266
+ }
267
+ function _getCalloutContentForLineAndBar(point) {
268
+ var _selectedPoint__lineData;
269
+ // eslint-disable-next-line @typescript-eslint/no-shadow
270
+ const YValueHover = [];
271
+ const { useSingleColor = false } = props;
272
+ const { data, lineLegendText, lineLegendColor = tokens.colorPaletteYellowBackground1 } = props;
273
+ const selectedPoint = data.filter((xDataPoint)=>xDataPoint.x === point.x);
274
+ // there might be no y value of the line for the hovered bar. so we need to check this condition
275
+ if (_isHavingLine && ((_selectedPoint__lineData = selectedPoint[0].lineData) === null || _selectedPoint__lineData === void 0 ? void 0 : _selectedPoint__lineData.y) !== undefined) {
276
+ var _selectedPoint__lineData1, _selectedPoint__lineData2, _selectedPoint__lineData3;
277
+ // callout data for the line
278
+ YValueHover.push({
279
+ legend: lineLegendText,
280
+ color: lineLegendColor,
281
+ y: (_selectedPoint__lineData1 = selectedPoint[0].lineData) === null || _selectedPoint__lineData1 === void 0 ? void 0 : _selectedPoint__lineData1.y,
282
+ data: (_selectedPoint__lineData2 = selectedPoint[0].lineData) === null || _selectedPoint__lineData2 === void 0 ? void 0 : _selectedPoint__lineData2.yAxisCalloutData,
283
+ yAxisCalloutData: (_selectedPoint__lineData3 = selectedPoint[0].lineData) === null || _selectedPoint__lineData3 === void 0 ? void 0 : _selectedPoint__lineData3.yAxisCalloutData
284
+ });
285
+ }
286
+ // callout data for the bar
287
+ YValueHover.push({
288
+ legend: selectedPoint[0].legend,
289
+ y: selectedPoint[0].y,
290
+ color: !useSingleColor ? selectedPoint[0].color ? selectedPoint[0].color : _createColors()(selectedPoint[0].y) : _createColors()(1),
291
+ data: selectedPoint[0].yAxisCalloutData,
292
+ yAxisCalloutData: selectedPoint[0].yAxisCalloutData
293
+ });
294
+ // eslint-disable-next-line @typescript-eslint/no-shadow
295
+ const hoverXValue = point.x instanceof Date ? point.x.toLocaleString() : point.x.toString();
296
+ return {
297
+ YValueHover,
298
+ hoverXValue: point.xAxisCalloutData || hoverXValue
299
+ };
300
+ }
301
+ function _onBarHover(point, // eslint-disable-next-line @typescript-eslint/no-shadow
302
+ color, mouseEvent) {
303
+ mouseEvent.persist();
304
+ // eslint-disable-next-line @typescript-eslint/no-shadow
305
+ const { YValueHover, hoverXValue } = _getCalloutContentForLineAndBar(point);
306
+ if (_calloutAnchorPoint !== point) {
307
+ _calloutAnchorPoint = point;
308
+ /** Show the callout if highlighted bar is hovered and Hide it if unhighlighted bar is hovered */ updatePosition(mouseEvent.clientX, mouseEvent.clientY);
309
+ setPopoverOpen(selectedLegend === '' || selectedLegend === point.legend);
310
+ setDataForHoverCard(point.y);
311
+ setCalloutLegend(point.legend);
312
+ setColor(point.color || color);
313
+ // To display callout value, if no callout value given, taking given point.x value as a string.
314
+ setXCalloutValue(point.xAxisCalloutData || (point.x instanceof Date ? point.x.toLocaleDateString() : point.x.toString()));
315
+ setDataPointCalloutProps(point);
316
+ // Hovering over a bar should highlight corresponding line points only when no legend is selected
317
+ setActiveXDatapoint(_noLegendHighlighted() ? point.x : null);
318
+ setYValueHover(YValueHover);
319
+ setHoverXValue(hoverXValue);
320
+ setCalloutAccessibilityData(point.callOutAccessibilityData);
321
+ }
322
+ }
323
+ function _onBarLeave() {
324
+ /**/ }
325
+ function _handleChartMouseLeave() {
326
+ _calloutAnchorPoint = null;
327
+ setPopoverOpen(false);
328
+ setActiveXDatapoint(null);
329
+ setYValueHover([]);
330
+ setHoverXValue('');
331
+ }
332
+ // eslint-disable-next-line @typescript-eslint/no-shadow
333
+ function _onBarFocus(point, refArrayIndexNumber, color) {
334
+ // eslint-disable-next-line @typescript-eslint/no-shadow
335
+ const { YValueHover, hoverXValue } = _getCalloutContentForLineAndBar(point);
336
+ _refArray.forEach((obj, index)=>{
337
+ if (obj.index === point.legend && refArrayIndexNumber === index) {
338
+ /** Show the callout if highlighted bar is hovered and Hide it if unhighlighted bar is hovered */ setPopoverOpen(selectedLegend === '' || selectedLegend === point.legend);
339
+ setDataForHoverCard(point.y);
340
+ setCalloutLegend(point.legend);
341
+ setColor(point.color || color);
342
+ // To display callout value, if no callout value given, taking given point.x value as a string.
343
+ setXCalloutValue(point.xAxisCalloutData || (point.x instanceof Date ? point.x.toLocaleDateString() : point.x.toString()));
344
+ setYCalloutValue(point.yAxisCalloutData);
345
+ setDataPointCalloutProps(point);
346
+ // Hovering over a bar should highlight corresponding line points only when no legend is selected
347
+ setActiveXDatapoint(point.x);
348
+ setYValueHover(YValueHover);
349
+ setHoverXValue(hoverXValue);
350
+ setCalloutAccessibilityData(point.callOutAccessibilityData);
351
+ }
352
+ });
353
+ }
354
+ function _lineHover(point, mouseEvent) {
355
+ mouseEvent.persist();
356
+ _lineHoverFocus(point, mouseEvent);
357
+ }
358
+ function _lineFocus(point, ref) {
359
+ if (ref.refElement) {
360
+ _lineHoverFocus(point, ref.refElement);
361
+ }
362
+ }
363
+ function _lineHoverFocus(point, _refSelected) {
364
+ const { lineLegendText = '', lineLegendColor = tokens.colorPaletteYellowBackground1 } = props;
365
+ setPopoverOpen(false);
366
+ setCalloutLegend(lineLegendText);
367
+ setDataForHoverCard(point.lineData.y);
368
+ setColor(lineLegendColor);
369
+ setXCalloutValue(point.xAxisCalloutData || (point.x instanceof Date ? point.x.toLocaleDateString() : point.x.toString()));
370
+ setYCalloutValue(point.lineData.yAxisCalloutData);
371
+ setDataPointCalloutProps(point);
372
+ setActiveXDatapoint(point.x);
373
+ }
374
+ function _getScales(containerHeight, containerWidth) {
375
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
376
+ let xBarScale;
377
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
378
+ const yBarScale = d3ScaleLinear().domain([
379
+ 0,
380
+ _yMax
381
+ ]).range([
382
+ 0,
383
+ containerHeight - margins.bottom - margins.top
384
+ ]);
385
+ if (_xAxisType === XAxisTypes.NumericAxis) {
386
+ const xMax = d3Max(_points, (point)=>point.x);
387
+ const xMin = d3Min(_points, (point)=>point.x);
388
+ xBarScale = d3ScaleLinear().domain(_useRtl ? [
389
+ xMax,
390
+ xMin
391
+ ] : [
392
+ xMin,
393
+ xMax
394
+ ]).nice().range([
395
+ margins.left + _domainMargin,
396
+ containerWidth - margins.right - _domainMargin
397
+ ]);
398
+ } else if (_xAxisType === XAxisTypes.DateAxis) {
399
+ const sDate = d3Min(_points, (point)=>point.x);
400
+ const lDate = d3Max(_points, (point)=>point.x);
401
+ xBarScale = d3ScaleUtc().domain([
402
+ sDate,
403
+ lDate
404
+ ]).range(_useRtl ? [
405
+ containerWidth - margins.right - _domainMargin,
406
+ margins.left + _domainMargin
407
+ ] : [
408
+ margins.left + _domainMargin,
409
+ containerWidth - margins.right - _domainMargin
410
+ ]);
411
+ } else {
412
+ xBarScale = d3ScaleBand().domain(_xAxisLabels).range(_useRtl ? [
413
+ containerWidth - margins.right - _domainMargin,
414
+ margins.left + _domainMargin
415
+ ] : [
416
+ margins.left + _domainMargin,
417
+ containerWidth - margins.right - _domainMargin
418
+ ]).paddingInner(_xAxisInnerPadding).paddingOuter(_xAxisOuterPadding);
419
+ }
420
+ return {
421
+ xBarScale,
422
+ yBarScale
423
+ };
424
+ }
425
+ const classes = useVerticalBarChartStyles(props);
426
+ function _createNumericBars(containerHeight, containerWidth, xElement) {
427
+ const { useSingleColor = false } = props;
428
+ const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
429
+ const colorScale = _createColors();
430
+ const bars = _points.map((point, index)=>{
431
+ const shouldHighlight = _legendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
432
+ const barHeight = Math.max(yBarScale(point.y), 0);
433
+ let adjustedBarHeight = 0;
434
+ if (barHeight <= 0) {
435
+ return /*#__PURE__*/ React.createElement(React.Fragment, {
436
+ key: point.x
437
+ }, " ");
438
+ } else if (barHeight <= Math.ceil(yBarScale(_yMax) / 100.0)) {
439
+ adjustedBarHeight = Math.ceil(yBarScale(_yMax) / 100.0);
440
+ } else {
441
+ adjustedBarHeight = barHeight;
442
+ }
443
+ const xPoint = xBarScale(point.x) - _barWidth / 2;
444
+ const yPoint = containerHeight - margins.bottom - adjustedBarHeight;
445
+ return /*#__PURE__*/ React.createElement("g", {
446
+ key: point.x
447
+ }, /*#__PURE__*/ React.createElement("rect", {
448
+ id: `${_vbcBarId}-${index}`,
449
+ x: xPoint,
450
+ y: yPoint,
451
+ width: _barWidth,
452
+ "data-is-focusable": !props.hideTooltip && shouldHighlight,
453
+ height: adjustedBarHeight,
454
+ ref: (e)=>{
455
+ _refCallback(e, point.legend);
456
+ },
457
+ onClick: point.onClick,
458
+ onMouseOver: (event)=>_onBarHover(point, colorScale(point.y), event),
459
+ "aria-label": _getAriaLabel(point),
460
+ role: "img",
461
+ onMouseLeave: _onBarLeave,
462
+ onFocus: _onBarFocus.bind(point, index, colorScale(point.y)),
463
+ onBlur: _onBarLeave,
464
+ fill: point.color && !useSingleColor ? point.color : colorScale(point.y),
465
+ tabIndex: point.legend !== '' ? 0 : undefined,
466
+ opacity: shouldHighlight ? '1' : '0.1'
467
+ }), _renderBarLabel(xPoint, yPoint, point.y, point.legend));
468
+ });
469
+ // Removing un wanted tooltip div from DOM, when prop not provided.
470
+ if (!props.showXAxisLablesTooltip) {
471
+ try {
472
+ // eslint-disable-next-line no-restricted-globals
473
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
474
+ // eslint-disable-next-line no-empty
475
+ } catch (e) {}
476
+ }
477
+ // Used to display tooltip at x axis labels.
478
+ if (!props.wrapXAxisLables && props.showXAxisLablesTooltip) {
479
+ const xAxisElement = d3Select(xElement).call(xBarScale);
480
+ try {
481
+ // eslint-disable-next-line no-restricted-globals
482
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
483
+ // eslint-disable-next-line no-empty
484
+ } catch (e) {}
485
+ const tooltipProps = {
486
+ tooltipCls: classes.tooltip,
487
+ id: _tooltipId,
488
+ xAxis: xAxisElement
489
+ };
490
+ xAxisElement && tooltipOfXAxislabels(tooltipProps);
491
+ }
492
+ return bars;
493
+ }
494
+ function _createStringBars(containerHeight, containerWidth, xElement) {
495
+ const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
496
+ const colorScale = _createColors();
497
+ const bars = _points.map((point, index)=>{
498
+ const barHeight = Math.max(yBarScale(point.y), 0);
499
+ let adjustedBarHeight = 0;
500
+ if (barHeight <= 0) {
501
+ return /*#__PURE__*/ React.createElement(React.Fragment, {
502
+ key: point.x instanceof Date ? point.x.getTime() : point.x
503
+ }, " ");
504
+ } else if (barHeight <= Math.ceil(yBarScale(_yMax) / 100.0)) {
505
+ adjustedBarHeight = Math.ceil(yBarScale(_yMax) / 100.0);
506
+ } else {
507
+ adjustedBarHeight = barHeight;
508
+ }
509
+ const xPoint = xBarScale(point.x);
510
+ const yPoint = containerHeight - margins.bottom - adjustedBarHeight;
511
+ // Setting the bar width here is safe because there are no dependencies earlier in the code
512
+ // that rely on the width of bars in vertical bar charts with string x-axis.
513
+ _barWidth = getBarWidth(props.barWidth, props.maxBarWidth, xBarScale.bandwidth());
514
+ return /*#__PURE__*/ React.createElement("g", {
515
+ key: point.x instanceof Date ? point.x.getTime() : point.x,
516
+ transform: `translate(${0.5 * (xBarScale.bandwidth() - _barWidth)}, 0)`
517
+ }, /*#__PURE__*/ React.createElement("rect", {
518
+ id: `${_vbcBarId}-${index}`,
519
+ x: xPoint,
520
+ y: yPoint,
521
+ width: _barWidth,
522
+ height: adjustedBarHeight,
523
+ "aria-label": _getAriaLabel(point),
524
+ role: "img",
525
+ ref: (e)=>{
526
+ _refCallback(e, point.legend);
527
+ },
528
+ onClick: point.onClick,
529
+ onMouseOver: (event)=>_onBarHover(point, colorScale(point.y), event),
530
+ onMouseLeave: _onBarLeave,
531
+ onBlur: _onBarLeave,
532
+ "data-is-focusable": !props.hideTooltip,
533
+ onFocus: _onBarFocus.bind(point, index, colorScale(point.y)),
534
+ fill: point.color ? point.color : colorScale(point.y),
535
+ tabIndex: point.legend !== '' ? 0 : undefined
536
+ }), _renderBarLabel(xPoint, yPoint, point.y, point.legend));
537
+ });
538
+ // Removing un wanted tooltip div from DOM, when prop not provided.
539
+ if (!props.showXAxisLablesTooltip) {
540
+ try {
541
+ // eslint-disable-next-line no-restricted-globals
542
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
543
+ // eslint-disable-next-line no-empty
544
+ } catch (e) {}
545
+ }
546
+ // Used to display tooltip at x axis labels.
547
+ if (!props.wrapXAxisLables && props.showXAxisLablesTooltip) {
548
+ const xAxisElement = d3Select(xElement).call(xBarScale);
549
+ try {
550
+ // eslint-disable-next-line no-restricted-globals
551
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
552
+ // eslint-disable-next-line no-empty
553
+ } catch (e) {}
554
+ const tooltipProps = {
555
+ tooltipCls: classes.tooltip,
556
+ id: _tooltipId,
557
+ xAxis: xAxisElement,
558
+ showTooltip: props.showXAxisLablesTooltip
559
+ };
560
+ xAxisElement && tooltipOfXAxislabels(tooltipProps);
561
+ }
562
+ return bars;
563
+ }
564
+ function _createDateBars(containerHeight, containerWidth, xElement) {
565
+ const { useSingleColor = false } = props;
566
+ const { xBarScale, yBarScale } = _getScales(containerHeight, containerWidth);
567
+ const colorScale = _createColors();
568
+ const bars = _points.map((point, index)=>{
569
+ const shouldHighlight = _legendHighlighted(point.legend) || _noLegendHighlighted() ? true : false;
570
+ const barHeight = Math.max(yBarScale(point.y), 0);
571
+ let adjustedBarHeight = 0;
572
+ if (barHeight <= 0) {
573
+ return /*#__PURE__*/ React.createElement(React.Fragment, {
574
+ key: point.x instanceof Date ? point.x.getTime() : point.x
575
+ }, " ");
576
+ } else if (barHeight <= Math.ceil(yBarScale(_yMax) / 100.0)) {
577
+ adjustedBarHeight = Math.ceil(yBarScale(_yMax) / 100.0);
578
+ } else {
579
+ adjustedBarHeight = barHeight;
580
+ }
581
+ const xPoint = xBarScale(point.x) - _barWidth / 2;
582
+ const yPoint = containerHeight - margins.bottom - adjustedBarHeight;
583
+ return /*#__PURE__*/ React.createElement("g", {
584
+ key: point.x instanceof Date ? point.x.getTime() : point.x
585
+ }, /*#__PURE__*/ React.createElement("rect", {
586
+ id: `${_vbcBarId}-${index}`,
587
+ x: xPoint,
588
+ className: classes.opacityChangeOnHover,
589
+ y: yPoint,
590
+ width: _barWidth,
591
+ "data-is-focusable": !props.hideTooltip && shouldHighlight,
592
+ height: adjustedBarHeight,
593
+ ref: (e)=>{
594
+ _refCallback(e, point.legend);
595
+ },
596
+ onClick: point.onClick,
597
+ onMouseOver: (event)=>_onBarHover(point, colorScale(point.y), event),
598
+ "aria-label": _getAriaLabel(point),
599
+ role: "img",
600
+ onMouseLeave: _onBarLeave,
601
+ onFocus: _onBarFocus.bind(point, index, colorScale(point.y)),
602
+ onBlur: _onBarLeave,
603
+ fill: point.color && !useSingleColor ? point.color : colorScale(point.y),
604
+ tabIndex: point.legend !== '' ? 0 : undefined
605
+ }), _renderBarLabel(xPoint, yPoint, point.y, point.legend));
606
+ });
607
+ // Removing un wanted tooltip div from DOM, when prop not provided.
608
+ if (!props.showXAxisLablesTooltip) {
609
+ try {
610
+ // eslint-disable-next-line no-restricted-globals
611
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
612
+ // eslint-disable-next-line no-empty
613
+ } catch (e) {}
614
+ }
615
+ // Used to display tooltip at x axis labels.
616
+ if (!props.wrapXAxisLables && props.showXAxisLablesTooltip) {
617
+ const xAxisElement = d3Select(xElement).call(xBarScale);
618
+ try {
619
+ // eslint-disable-next-line no-restricted-globals
620
+ document.getElementById(_tooltipId) && document.getElementById(_tooltipId).remove();
621
+ // eslint-disable-next-line no-empty
622
+ } catch (e) {}
623
+ const tooltipProps = {
624
+ tooltipCls: classes.tooltip,
625
+ id: _tooltipId,
626
+ xAxis: xAxisElement
627
+ };
628
+ xAxisElement && tooltipOfXAxislabels(tooltipProps);
629
+ }
630
+ return bars;
631
+ }
632
+ function _onLegendClick(legendTitle) {
633
+ if (selectedLegend === legendTitle) {
634
+ setSelectedLegend('');
635
+ } else {
636
+ setSelectedLegend(legendTitle);
637
+ }
638
+ }
639
+ function _onLegendHover(legendTitle) {
640
+ setActiveLegend(legendTitle);
641
+ }
642
+ function _onLegendLeave() {
643
+ setActiveLegend('');
644
+ }
645
+ function _getLegendData(data) {
646
+ const { useSingleColor } = props;
647
+ const { lineLegendText, lineLegendColor = tokens.colorPaletteYellowForeground1 } = props;
648
+ const actions = [];
649
+ data.forEach((point, _index)=>{
650
+ // eslint-disable-next-line @typescript-eslint/no-shadow
651
+ const color = !useSingleColor ? point.color : _createColors()(1);
652
+ // mapping data to the format Legends component needs
653
+ const legend = {
654
+ title: point.legend,
655
+ color,
656
+ action: ()=>{
657
+ _onLegendClick(point.legend);
658
+ },
659
+ hoverAction: ()=>{
660
+ _handleChartMouseLeave();
661
+ _onLegendHover(point.legend);
662
+ },
663
+ onMouseOutAction: ()=>{
664
+ _onLegendLeave();
665
+ }
666
+ };
667
+ actions.push(legend);
668
+ });
669
+ if (_isHavingLine && lineLegendText && lineLegendColor) {
670
+ const lineLegend = {
671
+ title: lineLegendText,
672
+ color: lineLegendColor,
673
+ action: ()=>{
674
+ _onLegendClick(lineLegendText);
675
+ },
676
+ hoverAction: ()=>{
677
+ _handleChartMouseLeave();
678
+ _onLegendHover(lineLegendText);
679
+ },
680
+ onMouseOutAction: ()=>{
681
+ _onLegendLeave();
682
+ },
683
+ isLineLegendInBarChart: true
684
+ };
685
+ actions.unshift(lineLegend);
686
+ }
687
+ const legends = /*#__PURE__*/ React.createElement(Legends, {
688
+ legends: actions,
689
+ enabledWrapLines: props.enabledLegendsWrapLines,
690
+ overflowText: props.legendsOverflowText,
691
+ ...props.legendProps
692
+ });
693
+ return legends;
694
+ }
695
+ function _getAxisData(yAxisData) {
696
+ if (yAxisData && yAxisData.yAxisDomainValues.length) {
697
+ const { yAxisDomainValues: domainValue } = yAxisData;
698
+ _yMax = Math.max(domainValue[domainValue.length - 1], props.yMaxValue || 0);
699
+ }
700
+ }
701
+ /**
702
+ * This function checks if the given legend is highlighted or not.
703
+ * A legend can be highlighted in 2 ways:
704
+ * 1. selection: if the user clicks on it
705
+ * 2. hovering: if there is no selected legend and the user hovers over it
706
+ */ function _legendHighlighted(legendTitle) {
707
+ return selectedLegend === legendTitle || selectedLegend === '' && activeLegend === legendTitle;
708
+ }
709
+ /**
710
+ * This function checks if none of the legends is selected or hovered.
711
+ */ function _noLegendHighlighted() {
712
+ return selectedLegend === '' && activeLegend === '';
713
+ }
714
+ function _getAriaLabel(point) {
715
+ var _point_lineData, _point_lineData1, _point_callOutAccessibilityData;
716
+ const xValue = point.xAxisCalloutData ? point.xAxisCalloutData : point.x instanceof Date ? point.x.toLocaleString() : point.x;
717
+ const legend = point.legend;
718
+ const yValue = point.yAxisCalloutData || point.y;
719
+ const lineLegend = props.lineLegendText || 'Line';
720
+ const lineYValue = ((_point_lineData = point.lineData) === null || _point_lineData === void 0 ? void 0 : _point_lineData.yAxisCalloutData) || ((_point_lineData1 = point.lineData) === null || _point_lineData1 === void 0 ? void 0 : _point_lineData1.y);
721
+ return ((_point_callOutAccessibilityData = point.callOutAccessibilityData) === null || _point_callOutAccessibilityData === void 0 ? void 0 : _point_callOutAccessibilityData.ariaLabel) || `${xValue}. ` + (legend ? `${legend}, ` : '') + `${yValue}.` + (typeof lineYValue !== 'undefined' ? ` ${lineLegend}, ${lineYValue}.` : '');
722
+ }
723
+ function _renderBarLabel(xPoint, yPoint, barValue, legend) {
724
+ if (props.hideLabels || _barWidth < 16 || !(_legendHighlighted(legend) || _noLegendHighlighted())) {
725
+ return null;
726
+ }
727
+ return /*#__PURE__*/ React.createElement("text", {
728
+ x: xPoint + _barWidth / 2,
729
+ y: yPoint - 6,
730
+ textAnchor: "middle",
731
+ className: classes.barLabel,
732
+ "aria-hidden": true
733
+ }, formatValueWithSIPrefix(barValue));
734
+ }
735
+ function _getDomainMargins(containerWidth) {
736
+ _domainMargin = MIN_DOMAIN_MARGIN;
737
+ /** Total width available to render the bars */ const totalWidth = containerWidth - (margins.left + MIN_DOMAIN_MARGIN) - (margins.right + MIN_DOMAIN_MARGIN);
738
+ if (_xAxisType === XAxisTypes.StringAxis) {
739
+ if (isScalePaddingDefined(props.xAxisOuterPadding, props.xAxisPadding)) {
740
+ // Setting the domain margin for string x-axis to 0 because the xAxisOuterPadding prop is now available
741
+ // to adjust the space before the first bar and after the last bar.
742
+ _domainMargin = 0;
743
+ } else if (props.barWidth !== 'auto') {
744
+ /** Rate at which the space between the bars changes wrt the bar width */ const barGapRate = _xAxisInnerPadding / (1 - _xAxisInnerPadding);
745
+ // Update the bar width so that when CartesianChart rerenders,
746
+ // the following calculations don't use the previous bar width.
747
+ _barWidth = getBarWidth(props.barWidth, props.maxBarWidth);
748
+ /** Total width required to render the bars. Directly proportional to bar width */ const reqWidth = (_xAxisLabels.length + (_xAxisLabels.length - 1) * barGapRate) * _barWidth;
749
+ if (totalWidth >= reqWidth) {
750
+ // Center align the chart by setting equal left and right margins for domain
751
+ _domainMargin = MIN_DOMAIN_MARGIN + (totalWidth - reqWidth) / 2;
752
+ }
753
+ }
754
+ } else {
755
+ var _props_data;
756
+ const data = ((_props_data = props.data) === null || _props_data === void 0 ? void 0 : _props_data.map((point)=>point.x)) || [];
757
+ _barWidth = getBarWidth(props.barWidth, props.maxBarWidth, calculateAppropriateBarWidth(data, totalWidth));
758
+ _domainMargin = MIN_DOMAIN_MARGIN + _barWidth / 2;
759
+ }
760
+ return {
761
+ ...margins,
762
+ left: margins.left + _domainMargin,
763
+ right: margins.right + _domainMargin
764
+ };
765
+ }
766
+ function _isChartEmpty() {
767
+ return _points.length === 0 || d3Max(_points, (point)=>point.y) <= 0 && !_isHavingLine;
768
+ }
769
+ function updatePosition(newX, newY) {
770
+ const threshold = 1; // Set a threshold for movement
771
+ const { x, y } = clickPosition;
772
+ // Calculate the distance moved
773
+ const distance = Math.sqrt(Math.pow(newX - x, 2) + Math.pow(newY - y, 2));
774
+ // Update the position only if the distance moved is greater than the threshold
775
+ if (distance > threshold) {
776
+ setClickPosition({
777
+ x: newX,
778
+ y: newY
779
+ });
780
+ setPopoverOpen(true);
781
+ }
782
+ }
783
+ _adjustProps();
784
+ _xAxisLabels = _points.map((point)=>point.x);
785
+ _yMax = Math.max(d3Max(_points, (point)=>point.y), props.yMaxValue || 0);
786
+ const legendBars = _getLegendData(_points);
787
+ var _props_culture;
788
+ const calloutProps = {
789
+ ..._isHavingLine && {
790
+ YValueHover: YValueHover,
791
+ hoverXValue: hoverXValue
792
+ },
793
+ color: color,
794
+ legend: calloutLegend,
795
+ XValue: xCalloutValue,
796
+ YValue: yCalloutValue ? yCalloutValue : dataForHoverCard,
797
+ ...props.calloutProps,
798
+ ...getAccessibleDataObject(callOutAccessibilityData),
799
+ clickPosition: clickPosition,
800
+ isPopoverOpen: isPopoverOpen,
801
+ isCalloutForStack: _isHavingLine && _noLegendHighlighted(),
802
+ culture: (_props_culture = props.culture) !== null && _props_culture !== void 0 ? _props_culture : 'en-us',
803
+ isCartesian: true,
804
+ customCallout: {
805
+ customizedCallout: _getCustomizedCallout() != null ? _getCustomizedCallout() : undefined,
806
+ customCalloutProps: props.calloutPropsPerDataPoint ? props.calloutPropsPerDataPoint(dataPointCalloutProps) : undefined
807
+ }
808
+ };
809
+ const tickParams = {
810
+ tickValues: props.tickValues,
811
+ tickFormat: props.tickFormat
812
+ };
813
+ return !_isChartEmpty() ? /*#__PURE__*/ React.createElement(CartesianChart, {
814
+ ...props,
815
+ points: _points,
816
+ chartType: ChartTypes.VerticalBarChart,
817
+ xAxisType: _xAxisType,
818
+ calloutProps: calloutProps,
819
+ tickParams: tickParams,
820
+ ..._isHavingLine && _noLegendHighlighted() && {
821
+ isCalloutForStack: true
822
+ },
823
+ legendBars: legendBars,
824
+ datasetForXAxisDomain: _xAxisLabels,
825
+ barwidth: _barWidth,
826
+ getmargins: _getMargins,
827
+ getGraphData: _getGraphData,
828
+ getAxisData: _getAxisData,
829
+ onChartMouseLeave: _handleChartMouseLeave,
830
+ getDomainMargins: _getDomainMargins,
831
+ ..._xAxisType === XAxisTypes.StringAxis && {
832
+ xAxisInnerPadding: _xAxisInnerPadding,
833
+ xAxisOuterPadding: _xAxisOuterPadding
834
+ },
835
+ componentRef: cartesianChartRef,
836
+ /* eslint-disable react/jsx-no-bind */ // eslint-disable-next-line react/no-children-prop
837
+ children: (props)=>{
838
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("g", null, _bars), _isHavingLine && /*#__PURE__*/ React.createElement("g", null, _createLine(props.xScale, props.yScale, props.containerHeight, props.containerWidth, props.yScaleSecondary)));
839
+ }
840
+ }) : /*#__PURE__*/ React.createElement("div", {
841
+ id: _emptyChartId,
842
+ role: 'alert',
843
+ style: {
844
+ opacity: '0'
845
+ },
846
+ "aria-label": 'Graph has no data to display'
847
+ });
848
+ });
849
+ VerticalBarChart.displayName = 'VerticalBarChart';