@fluentui/react-charts 0.0.0-nightly-20250423-0405.1 → 0.0.0-nightly-20250423-1415.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (483) hide show
  1. package/CHANGELOG.md +16 -16
  2. package/dist/index.d.ts +3337 -0
  3. package/lib/AreaChart.js +1 -0
  4. package/lib/AreaChart.js.map +1 -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/GaugeChart.js +1 -0
  12. package/lib/GaugeChart.js.map +1 -0
  13. package/lib/GroupedVerticalBarChart.js +1 -0
  14. package/lib/GroupedVerticalBarChart.js.map +1 -0
  15. package/lib/HeatMapChart.js +1 -0
  16. package/lib/HeatMapChart.js.map +1 -0
  17. package/lib/HorizontalBarChart.js +1 -0
  18. package/lib/HorizontalBarChart.js.map +1 -0
  19. package/lib/HorizontalBarChartWithAxis.js +1 -0
  20. package/lib/HorizontalBarChartWithAxis.js.map +1 -0
  21. package/lib/Legends.js +1 -0
  22. package/lib/Legends.js.map +1 -0
  23. package/lib/LineChart.js +1 -0
  24. package/lib/LineChart.js.map +1 -0
  25. package/lib/Popover.js +1 -0
  26. package/lib/Popover.js.map +1 -0
  27. package/lib/ResponsiveContainer.js +1 -0
  28. package/lib/ResponsiveContainer.js.map +1 -0
  29. package/lib/SankeyChart.js +1 -0
  30. package/lib/SankeyChart.js.map +1 -0
  31. package/lib/ScatterChart.js +1 -0
  32. package/lib/ScatterChart.js.map +1 -0
  33. package/lib/Sparkline.js +1 -0
  34. package/lib/Sparkline.js.map +1 -0
  35. package/lib/VerticalBarChart.js +1 -0
  36. package/lib/VerticalBarChart.js.map +1 -0
  37. package/lib/VerticalStackedBarChart.js +1 -0
  38. package/lib/VerticalStackedBarChart.js.map +1 -0
  39. package/lib/components/AreaChart/AreaChart.js +775 -0
  40. package/lib/components/AreaChart/AreaChart.js.map +1 -0
  41. package/lib/components/AreaChart/AreaChart.types.js +4 -0
  42. package/lib/components/AreaChart/AreaChart.types.js.map +1 -0
  43. package/lib/components/AreaChart/index.js +3 -0
  44. package/lib/components/AreaChart/index.js.map +1 -0
  45. package/lib/components/AreaChart/useAreaChartStyles.styles.js +64 -0
  46. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
  47. package/lib/components/CommonComponents/CartesianChart.js +478 -0
  48. package/lib/components/CommonComponents/CartesianChart.js.map +1 -0
  49. package/lib/components/CommonComponents/CartesianChart.types.js +1 -0
  50. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -0
  51. package/lib/components/CommonComponents/ChartPopover.js +187 -0
  52. package/lib/components/CommonComponents/ChartPopover.js.map +1 -0
  53. package/lib/components/CommonComponents/ChartPopover.types.js +1 -0
  54. package/lib/components/CommonComponents/ChartPopover.types.js.map +1 -0
  55. package/lib/components/CommonComponents/index.js +4 -0
  56. package/lib/components/CommonComponents/index.js.map +1 -0
  57. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +229 -0
  58. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -0
  59. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +178 -0
  60. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -0
  61. package/lib/components/DeclarativeChart/DeclarativeChart.js +197 -0
  62. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -0
  63. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +811 -0
  64. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -0
  65. package/lib/components/DeclarativeChart/imageExporter.js +221 -0
  66. package/lib/components/DeclarativeChart/imageExporter.js.map +1 -0
  67. package/lib/components/DeclarativeChart/index.js +1 -0
  68. package/lib/components/DeclarativeChart/index.js.map +1 -0
  69. package/lib/components/DonutChart/Arc/Arc.js +110 -0
  70. package/lib/components/DonutChart/Arc/Arc.js.map +1 -0
  71. package/lib/components/DonutChart/Arc/Arc.types.js +1 -0
  72. package/lib/components/DonutChart/Arc/Arc.types.js.map +1 -0
  73. package/lib/components/DonutChart/Arc/index.js +2 -0
  74. package/lib/components/DonutChart/Arc/index.js.map +1 -0
  75. package/lib/components/DonutChart/Arc/useArcStyles.styles.js +54 -0
  76. package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -0
  77. package/lib/components/DonutChart/DonutChart.js +291 -0
  78. package/lib/components/DonutChart/DonutChart.js.map +1 -0
  79. package/lib/components/DonutChart/DonutChart.types.js +1 -0
  80. package/lib/components/DonutChart/DonutChart.types.js.map +1 -0
  81. package/lib/components/DonutChart/Pie/Pie.js +72 -0
  82. package/lib/components/DonutChart/Pie/Pie.js.map +1 -0
  83. package/lib/components/DonutChart/Pie/Pie.types.js +1 -0
  84. package/lib/components/DonutChart/Pie/Pie.types.js.map +1 -0
  85. package/lib/components/DonutChart/Pie/index.js +2 -0
  86. package/lib/components/DonutChart/Pie/index.js.map +1 -0
  87. package/lib/components/DonutChart/Pie/usePieStyles.styles.js +44 -0
  88. package/lib/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -0
  89. package/lib/components/DonutChart/index.js +3 -0
  90. package/lib/components/DonutChart/index.js.map +1 -0
  91. package/lib/components/DonutChart/useDonutChartStyles.styles.js +58 -0
  92. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -0
  93. package/lib/components/GaugeChart/GaugeChart.js +592 -0
  94. package/lib/components/GaugeChart/GaugeChart.js.map +1 -0
  95. package/lib/components/GaugeChart/GaugeChart.types.js +4 -0
  96. package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -0
  97. package/lib/components/GaugeChart/index.js +3 -0
  98. package/lib/components/GaugeChart/index.js.map +1 -0
  99. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js +174 -0
  100. package/lib/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -0
  101. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +501 -0
  102. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -0
  103. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js +4 -0
  104. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -0
  105. package/lib/components/GroupedVerticalBarChart/index.js +3 -0
  106. package/lib/components/GroupedVerticalBarChart/index.js.map +1 -0
  107. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +90 -0
  108. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -0
  109. package/lib/components/HeatMapChart/HeatMapChart.js +588 -0
  110. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -0
  111. package/lib/components/HeatMapChart/HeatMapChart.types.js +4 -0
  112. package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
  113. package/lib/components/HeatMapChart/index.js +3 -0
  114. package/lib/components/HeatMapChart/index.js.map +1 -0
  115. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +46 -0
  116. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
  117. package/lib/components/HorizontalBarChart/HorizontalBarChart.js +402 -0
  118. package/lib/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -0
  119. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js +6 -0
  120. package/lib/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -0
  121. package/lib/components/HorizontalBarChart/index.js +3 -0
  122. package/lib/components/HorizontalBarChart/index.js.map +1 -0
  123. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +163 -0
  124. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -0
  125. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +571 -0
  126. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
  127. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +4 -0
  128. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
  129. package/lib/components/HorizontalBarChartWithAxis/index.js +3 -0
  130. package/lib/components/HorizontalBarChartWithAxis/index.js.map +1 -0
  131. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +76 -0
  132. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
  133. package/lib/components/Legends/Legends.js +303 -0
  134. package/lib/components/Legends/Legends.js.map +1 -0
  135. package/lib/components/Legends/Legends.types.js +1 -0
  136. package/lib/components/Legends/Legends.types.js.map +1 -0
  137. package/lib/components/Legends/OverflowMenu.js +25 -0
  138. package/lib/components/Legends/OverflowMenu.js.map +1 -0
  139. package/lib/components/Legends/index.js +3 -0
  140. package/lib/components/Legends/index.js.map +1 -0
  141. package/lib/components/Legends/shape.js +35 -0
  142. package/lib/components/Legends/shape.js.map +1 -0
  143. package/lib/components/Legends/useLegendsStyles.styles.js +147 -0
  144. package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -0
  145. package/lib/components/LineChart/LineChart.js +1034 -0
  146. package/lib/components/LineChart/LineChart.js.map +1 -0
  147. package/lib/components/LineChart/LineChart.types.js +3 -0
  148. package/lib/components/LineChart/LineChart.types.js.map +1 -0
  149. package/lib/components/LineChart/eventAnnotation/EventAnnotation.js +119 -0
  150. package/lib/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -0
  151. package/lib/components/LineChart/eventAnnotation/LabelLink.js +57 -0
  152. package/lib/components/LineChart/eventAnnotation/LabelLink.js.map +1 -0
  153. package/lib/components/LineChart/eventAnnotation/Textbox.js +40 -0
  154. package/lib/components/LineChart/eventAnnotation/Textbox.js.map +1 -0
  155. package/lib/components/LineChart/index.js +4 -0
  156. package/lib/components/LineChart/index.js.map +1 -0
  157. package/lib/components/LineChart/useLineChartStyles.styles.js +65 -0
  158. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -0
  159. package/lib/components/ResponsiveContainer/ResponsiveContainer.js +65 -0
  160. package/lib/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -0
  161. package/lib/components/ResponsiveContainer/ResponsiveContainer.types.js +1 -0
  162. package/lib/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -0
  163. package/lib/components/ResponsiveContainer/index.js +1 -0
  164. package/lib/components/ResponsiveContainer/index.js.map +1 -0
  165. package/lib/components/ResponsiveContainer/useResponsiveContainerStyles.styles.js +23 -0
  166. package/lib/components/ResponsiveContainer/useResponsiveContainerStyles.styles.js.map +1 -0
  167. package/lib/components/SankeyChart/SankeyChart.js +1022 -0
  168. package/lib/components/SankeyChart/SankeyChart.js.map +1 -0
  169. package/lib/components/SankeyChart/SankeyChart.types.js +3 -0
  170. package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -0
  171. package/lib/components/SankeyChart/index.js +3 -0
  172. package/lib/components/SankeyChart/index.js.map +1 -0
  173. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +109 -0
  174. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
  175. package/lib/components/ScatterChart/ScatterChart.js +465 -0
  176. package/lib/components/ScatterChart/ScatterChart.js.map +1 -0
  177. package/lib/components/ScatterChart/ScatterChart.types.js +4 -0
  178. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -0
  179. package/lib/components/ScatterChart/index.js +3 -0
  180. package/lib/components/ScatterChart/index.js.map +1 -0
  181. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +65 -0
  182. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -0
  183. package/lib/components/Sparkline/Sparkline.js +119 -0
  184. package/lib/components/Sparkline/Sparkline.js.map +1 -0
  185. package/lib/components/Sparkline/Sparkline.types.js +4 -0
  186. package/lib/components/Sparkline/Sparkline.types.js.map +1 -0
  187. package/lib/components/Sparkline/index.js +3 -0
  188. package/lib/components/Sparkline/index.js.map +1 -0
  189. package/lib/components/Sparkline/useSparklineStyles.styles.js +49 -0
  190. package/lib/components/Sparkline/useSparklineStyles.styles.js.map +1 -0
  191. package/lib/components/VerticalBarChart/VerticalBarChart.js +926 -0
  192. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -0
  193. package/lib/components/VerticalBarChart/VerticalBarChart.types.js +4 -0
  194. package/lib/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -0
  195. package/lib/components/VerticalBarChart/index.js +3 -0
  196. package/lib/components/VerticalBarChart/index.js.map +1 -0
  197. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +74 -0
  198. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -0
  199. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +904 -0
  200. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
  201. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +1 -0
  202. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
  203. package/lib/components/VerticalStackedBarChart/index.js +3 -0
  204. package/lib/components/VerticalStackedBarChart/index.js.map +1 -0
  205. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +73 -0
  206. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
  207. package/lib/index.js +20 -0
  208. package/lib/index.js.map +1 -0
  209. package/lib/types/DataPoint.js +1 -0
  210. package/lib/types/DataPoint.js.map +1 -0
  211. package/lib/types/EventAnnotation.js +1 -0
  212. package/lib/types/EventAnnotation.js.map +1 -0
  213. package/lib/types/LegendDataItem.js +1 -0
  214. package/lib/types/LegendDataItem.js.map +1 -0
  215. package/lib/types/index.js +2 -0
  216. package/lib/types/index.js.map +1 -0
  217. package/lib/utilities/FocusableTooltipText.js +65 -0
  218. package/lib/utilities/FocusableTooltipText.js.map +1 -0
  219. package/lib/utilities/KeyCodes.js +8 -0
  220. package/lib/utilities/KeyCodes.js.map +1 -0
  221. package/lib/utilities/SVGTooltipText.js +183 -0
  222. package/lib/utilities/SVGTooltipText.js.map +1 -0
  223. package/lib/utilities/async-utils.js +380 -0
  224. package/lib/utilities/async-utils.js.map +1 -0
  225. package/lib/utilities/colors.js +269 -0
  226. package/lib/utilities/colors.js.map +1 -0
  227. package/lib/utilities/getWindow.js +25 -0
  228. package/lib/utilities/getWindow.js.map +1 -0
  229. package/lib/utilities/index.js +3 -0
  230. package/lib/utilities/index.js.map +1 -0
  231. package/lib/utilities/locale-util.js +15 -0
  232. package/lib/utilities/locale-util.js.map +1 -0
  233. package/lib/utilities/overflow-utils.js +27 -0
  234. package/lib/utilities/overflow-utils.js.map +1 -0
  235. package/lib/utilities/string.js +32 -0
  236. package/lib/utilities/string.js.map +1 -0
  237. package/lib/utilities/test-data.js +329 -0
  238. package/lib/utilities/test-data.js.map +1 -0
  239. package/lib/utilities/utilities.js +1405 -0
  240. package/lib/utilities/utilities.js.map +1 -0
  241. package/lib/utilities/vbc-utils.js +27 -0
  242. package/lib/utilities/vbc-utils.js.map +1 -0
  243. package/lib-commonjs/AreaChart.js +6 -0
  244. package/lib-commonjs/AreaChart.js.map +1 -0
  245. package/lib-commonjs/CartesianChart.js +6 -0
  246. package/lib-commonjs/CartesianChart.js.map +1 -0
  247. package/lib-commonjs/DeclarativeChart.js +6 -0
  248. package/lib-commonjs/DeclarativeChart.js.map +1 -0
  249. package/lib-commonjs/DonutChart.js +6 -0
  250. package/lib-commonjs/DonutChart.js.map +1 -0
  251. package/lib-commonjs/GaugeChart.js +6 -0
  252. package/lib-commonjs/GaugeChart.js.map +1 -0
  253. package/lib-commonjs/GroupedVerticalBarChart.js +6 -0
  254. package/lib-commonjs/GroupedVerticalBarChart.js.map +1 -0
  255. package/lib-commonjs/HeatMapChart.js +6 -0
  256. package/lib-commonjs/HeatMapChart.js.map +1 -0
  257. package/lib-commonjs/HorizontalBarChart.js +6 -0
  258. package/lib-commonjs/HorizontalBarChart.js.map +1 -0
  259. package/lib-commonjs/HorizontalBarChartWithAxis.js +6 -0
  260. package/lib-commonjs/HorizontalBarChartWithAxis.js.map +1 -0
  261. package/lib-commonjs/Legends.js +6 -0
  262. package/lib-commonjs/Legends.js.map +1 -0
  263. package/lib-commonjs/LineChart.js +6 -0
  264. package/lib-commonjs/LineChart.js.map +1 -0
  265. package/lib-commonjs/Popover.js +6 -0
  266. package/lib-commonjs/Popover.js.map +1 -0
  267. package/lib-commonjs/ResponsiveContainer.js +6 -0
  268. package/lib-commonjs/ResponsiveContainer.js.map +1 -0
  269. package/lib-commonjs/SankeyChart.js +6 -0
  270. package/lib-commonjs/SankeyChart.js.map +1 -0
  271. package/lib-commonjs/ScatterChart.js +6 -0
  272. package/lib-commonjs/ScatterChart.js.map +1 -0
  273. package/lib-commonjs/Sparkline.js +6 -0
  274. package/lib-commonjs/Sparkline.js.map +1 -0
  275. package/lib-commonjs/VerticalBarChart.js +6 -0
  276. package/lib-commonjs/VerticalBarChart.js.map +1 -0
  277. package/lib-commonjs/VerticalStackedBarChart.js +6 -0
  278. package/lib-commonjs/VerticalStackedBarChart.js.map +1 -0
  279. package/lib-commonjs/components/AreaChart/AreaChart.js +781 -0
  280. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -0
  281. package/lib-commonjs/components/AreaChart/AreaChart.types.js +7 -0
  282. package/lib-commonjs/components/AreaChart/AreaChart.types.js.map +1 -0
  283. package/lib-commonjs/components/AreaChart/index.js +8 -0
  284. package/lib-commonjs/components/AreaChart/index.js.map +1 -0
  285. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +104 -0
  286. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -0
  287. package/lib-commonjs/components/CommonComponents/CartesianChart.js +484 -0
  288. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -0
  289. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js +6 -0
  290. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -0
  291. package/lib-commonjs/components/CommonComponents/ChartPopover.js +197 -0
  292. package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -0
  293. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js +4 -0
  294. package/lib-commonjs/components/CommonComponents/ChartPopover.types.js.map +1 -0
  295. package/lib-commonjs/components/CommonComponents/index.js +9 -0
  296. package/lib-commonjs/components/CommonComponents/index.js.map +1 -0
  297. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +356 -0
  298. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -0
  299. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +261 -0
  300. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -0
  301. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +205 -0
  302. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -0
  303. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +859 -0
  304. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -0
  305. package/lib-commonjs/components/DeclarativeChart/imageExporter.js +231 -0
  306. package/lib-commonjs/components/DeclarativeChart/imageExporter.js.map +1 -0
  307. package/lib-commonjs/components/DeclarativeChart/index.js +6 -0
  308. package/lib-commonjs/components/DeclarativeChart/index.js.map +1 -0
  309. package/lib-commonjs/components/DonutChart/Arc/Arc.js +117 -0
  310. package/lib-commonjs/components/DonutChart/Arc/Arc.js.map +1 -0
  311. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js +4 -0
  312. package/lib-commonjs/components/DonutChart/Arc/Arc.types.js.map +1 -0
  313. package/lib-commonjs/components/DonutChart/Arc/index.js +7 -0
  314. package/lib-commonjs/components/DonutChart/Arc/index.js.map +1 -0
  315. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +83 -0
  316. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -0
  317. package/lib-commonjs/components/DonutChart/DonutChart.js +298 -0
  318. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -0
  319. package/lib-commonjs/components/DonutChart/DonutChart.types.js +6 -0
  320. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -0
  321. package/lib-commonjs/components/DonutChart/Pie/Pie.js +79 -0
  322. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -0
  323. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js +4 -0
  324. package/lib-commonjs/components/DonutChart/Pie/Pie.types.js.map +1 -0
  325. package/lib-commonjs/components/DonutChart/Pie/index.js +7 -0
  326. package/lib-commonjs/components/DonutChart/Pie/index.js.map +1 -0
  327. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js +61 -0
  328. package/lib-commonjs/components/DonutChart/Pie/usePieStyles.styles.js.map +1 -0
  329. package/lib-commonjs/components/DonutChart/index.js +8 -0
  330. package/lib-commonjs/components/DonutChart/index.js.map +1 -0
  331. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +82 -0
  332. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -0
  333. package/lib-commonjs/components/GaugeChart/GaugeChart.js +621 -0
  334. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -0
  335. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js +7 -0
  336. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -0
  337. package/lib-commonjs/components/GaugeChart/index.js +8 -0
  338. package/lib-commonjs/components/GaugeChart/index.js.map +1 -0
  339. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js +252 -0
  340. package/lib-commonjs/components/GaugeChart/useGaugeChartStyles.styles.js.map +1 -0
  341. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +507 -0
  342. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -0
  343. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js +7 -0
  344. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.types.js.map +1 -0
  345. package/lib-commonjs/components/GroupedVerticalBarChart/index.js +8 -0
  346. package/lib-commonjs/components/GroupedVerticalBarChart/index.js.map +1 -0
  347. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +139 -0
  348. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -0
  349. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +599 -0
  350. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -0
  351. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js +7 -0
  352. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -0
  353. package/lib-commonjs/components/HeatMapChart/index.js +8 -0
  354. package/lib-commonjs/components/HeatMapChart/index.js.map +1 -0
  355. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +68 -0
  356. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -0
  357. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js +408 -0
  358. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.js.map +1 -0
  359. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js +17 -0
  360. package/lib-commonjs/components/HorizontalBarChart/HorizontalBarChart.types.js.map +1 -0
  361. package/lib-commonjs/components/HorizontalBarChart/index.js +8 -0
  362. package/lib-commonjs/components/HorizontalBarChart/index.js.map +1 -0
  363. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +251 -0
  364. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -0
  365. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +580 -0
  366. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -0
  367. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js +7 -0
  368. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -0
  369. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js +8 -0
  370. package/lib-commonjs/components/HorizontalBarChartWithAxis/index.js.map +1 -0
  371. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +116 -0
  372. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -0
  373. package/lib-commonjs/components/Legends/Legends.js +313 -0
  374. package/lib-commonjs/components/Legends/Legends.js.map +1 -0
  375. package/lib-commonjs/components/Legends/Legends.types.js +6 -0
  376. package/lib-commonjs/components/Legends/Legends.types.js.map +1 -0
  377. package/lib-commonjs/components/Legends/OverflowMenu.js +36 -0
  378. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -0
  379. package/lib-commonjs/components/Legends/index.js +8 -0
  380. package/lib-commonjs/components/Legends/index.js.map +1 -0
  381. package/lib-commonjs/components/Legends/shape.js +46 -0
  382. package/lib-commonjs/components/Legends/shape.js.map +1 -0
  383. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +304 -0
  384. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -0
  385. package/lib-commonjs/components/LineChart/LineChart.js +1040 -0
  386. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -0
  387. package/lib-commonjs/components/LineChart/LineChart.types.js +6 -0
  388. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -0
  389. package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js +129 -0
  390. package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -0
  391. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js +68 -0
  392. package/lib-commonjs/components/LineChart/eventAnnotation/LabelLink.js.map +1 -0
  393. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js +51 -0
  394. package/lib-commonjs/components/LineChart/eventAnnotation/Textbox.js.map +1 -0
  395. package/lib-commonjs/components/LineChart/index.js +9 -0
  396. package/lib-commonjs/components/LineChart/index.js.map +1 -0
  397. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +96 -0
  398. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -0
  399. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js +76 -0
  400. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.js.map +1 -0
  401. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.js +6 -0
  402. package/lib-commonjs/components/ResponsiveContainer/ResponsiveContainer.types.js.map +1 -0
  403. package/lib-commonjs/components/ResponsiveContainer/index.js +6 -0
  404. package/lib-commonjs/components/ResponsiveContainer/index.js.map +1 -0
  405. package/lib-commonjs/components/ResponsiveContainer/useResponsiveContainerStyles.styles.js +47 -0
  406. package/lib-commonjs/components/ResponsiveContainer/useResponsiveContainerStyles.styles.js.map +1 -0
  407. package/lib-commonjs/components/SankeyChart/SankeyChart.js +1038 -0
  408. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -0
  409. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js +6 -0
  410. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -0
  411. package/lib-commonjs/components/SankeyChart/index.js +8 -0
  412. package/lib-commonjs/components/SankeyChart/index.js.map +1 -0
  413. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +179 -0
  414. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -0
  415. package/lib-commonjs/components/ScatterChart/ScatterChart.js +471 -0
  416. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -0
  417. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js +7 -0
  418. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -0
  419. package/lib-commonjs/components/ScatterChart/index.js +8 -0
  420. package/lib-commonjs/components/ScatterChart/index.js.map +1 -0
  421. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +96 -0
  422. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -0
  423. package/lib-commonjs/components/Sparkline/Sparkline.js +125 -0
  424. package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -0
  425. package/lib-commonjs/components/Sparkline/Sparkline.types.js +7 -0
  426. package/lib-commonjs/components/Sparkline/Sparkline.types.js.map +1 -0
  427. package/lib-commonjs/components/Sparkline/index.js +8 -0
  428. package/lib-commonjs/components/Sparkline/index.js.map +1 -0
  429. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js +77 -0
  430. package/lib-commonjs/components/Sparkline/useSparklineStyles.styles.js.map +1 -0
  431. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +928 -0
  432. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -0
  433. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js +7 -0
  434. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.types.js.map +1 -0
  435. package/lib-commonjs/components/VerticalBarChart/index.js +8 -0
  436. package/lib-commonjs/components/VerticalBarChart/index.js.map +1 -0
  437. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +117 -0
  438. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -0
  439. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +915 -0
  440. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -0
  441. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js +6 -0
  442. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -0
  443. package/lib-commonjs/components/VerticalStackedBarChart/index.js +8 -0
  444. package/lib-commonjs/components/VerticalStackedBarChart/index.js.map +1 -0
  445. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +120 -0
  446. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -0
  447. package/lib-commonjs/index.js +25 -0
  448. package/lib-commonjs/index.js.map +1 -0
  449. package/lib-commonjs/types/DataPoint.js +4 -0
  450. package/lib-commonjs/types/DataPoint.js.map +1 -0
  451. package/lib-commonjs/types/EventAnnotation.js +6 -0
  452. package/lib-commonjs/types/EventAnnotation.js.map +1 -0
  453. package/lib-commonjs/types/LegendDataItem.js +4 -0
  454. package/lib-commonjs/types/LegendDataItem.js.map +1 -0
  455. package/lib-commonjs/types/index.js +7 -0
  456. package/lib-commonjs/types/index.js.map +1 -0
  457. package/lib-commonjs/utilities/FocusableTooltipText.js +75 -0
  458. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -0
  459. package/lib-commonjs/utilities/KeyCodes.js +18 -0
  460. package/lib-commonjs/utilities/KeyCodes.js.map +1 -0
  461. package/lib-commonjs/utilities/SVGTooltipText.js +193 -0
  462. package/lib-commonjs/utilities/SVGTooltipText.js.map +1 -0
  463. package/lib-commonjs/utilities/async-utils.js +382 -0
  464. package/lib-commonjs/utilities/async-utils.js.map +1 -0
  465. package/lib-commonjs/utilities/colors.js +293 -0
  466. package/lib-commonjs/utilities/colors.js.map +1 -0
  467. package/lib-commonjs/utilities/getWindow.js +28 -0
  468. package/lib-commonjs/utilities/getWindow.js.map +1 -0
  469. package/lib-commonjs/utilities/index.js +8 -0
  470. package/lib-commonjs/utilities/index.js.map +1 -0
  471. package/lib-commonjs/utilities/locale-util.js +25 -0
  472. package/lib-commonjs/utilities/locale-util.js.map +1 -0
  473. package/lib-commonjs/utilities/overflow-utils.js +36 -0
  474. package/lib-commonjs/utilities/overflow-utils.js.map +1 -0
  475. package/lib-commonjs/utilities/string.js +29 -0
  476. package/lib-commonjs/utilities/string.js.map +1 -0
  477. package/lib-commonjs/utilities/test-data.js +383 -0
  478. package/lib-commonjs/utilities/test-data.js.map +1 -0
  479. package/lib-commonjs/utilities/utilities.js +1371 -0
  480. package/lib-commonjs/utilities/utilities.js.map +1 -0
  481. package/lib-commonjs/utilities/vbc-utils.js +45 -0
  482. package/lib-commonjs/utilities/vbc-utils.js.map +1 -0
  483. package/package.json +13 -13
@@ -0,0 +1,1405 @@
1
+ import { axisRight as d3AxisRight, axisBottom as d3AxisBottom, axisLeft as d3AxisLeft } from 'd3-axis';
2
+ import { max as d3Max, min as d3Min, ticks as d3Ticks, nice as d3nice } from 'd3-array';
3
+ import { scaleLinear as d3ScaleLinear, scaleBand as d3ScaleBand, scaleUtc as d3ScaleUtc, scaleTime as d3ScaleTime } from 'd3-scale';
4
+ import { select as d3Select, selectAll as d3SelectAll } from 'd3-selection';
5
+ import { format as d3Format } from 'd3-format';
6
+ import { timeFormat as d3TimeFormat, timeFormatLocale as d3TimeFormatLocale, utcFormat as d3UtcFormat } from 'd3-time-format';
7
+ import { timeSecond as d3TimeSecond, timeMinute as d3TimeMinute, timeHour as d3TimeHour, timeDay as d3TimeDay, timeMonth as d3TimeMonth, timeWeek as d3TimeWeek, timeYear as d3TimeYear, utcSecond as d3UtcSecond, utcMinute as d3UtcMinute, utcHour as d3UtcHour, utcDay as d3UtcDay, utcMonth as d3UtcMonth, utcWeek as d3UtcWeek, utcYear as d3UtcYear } from 'd3-time';
8
+ import { curveLinear as d3CurveLinear, curveNatural as d3CurveNatural, curveStep as d3CurveStep, curveStepAfter as d3CurveStepAfter, curveStepBefore as d3CurveStepBefore } from 'd3-shape';
9
+ import { formatPrefix as d3FormatPrefix } from 'd3-format';
10
+ import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
11
+ export var ChartTypes;
12
+ (function(ChartTypes) {
13
+ ChartTypes[ChartTypes["AreaChart"] = 0] = "AreaChart";
14
+ ChartTypes[ChartTypes["LineChart"] = 1] = "LineChart";
15
+ ChartTypes[ChartTypes["VerticalBarChart"] = 2] = "VerticalBarChart";
16
+ ChartTypes[ChartTypes["VerticalStackedBarChart"] = 3] = "VerticalStackedBarChart";
17
+ ChartTypes[ChartTypes["GroupedVerticalBarChart"] = 4] = "GroupedVerticalBarChart";
18
+ ChartTypes[ChartTypes["HeatMapChart"] = 5] = "HeatMapChart";
19
+ ChartTypes[ChartTypes["HorizontalBarChartWithAxis"] = 6] = "HorizontalBarChartWithAxis";
20
+ ChartTypes[ChartTypes["ScatterChart"] = 7] = "ScatterChart";
21
+ })(ChartTypes || (ChartTypes = {}));
22
+ export var XAxisTypes;
23
+ (function(XAxisTypes) {
24
+ XAxisTypes[XAxisTypes["NumericAxis"] = 0] = "NumericAxis";
25
+ XAxisTypes[XAxisTypes["DateAxis"] = 1] = "DateAxis";
26
+ XAxisTypes[XAxisTypes["StringAxis"] = 2] = "StringAxis";
27
+ })(XAxisTypes || (XAxisTypes = {}));
28
+ export var YAxisType;
29
+ (function(YAxisType) {
30
+ YAxisType[YAxisType["NumericAxis"] = 0] = "NumericAxis";
31
+ YAxisType[YAxisType["DateAxis"] = 1] = "DateAxis";
32
+ YAxisType[YAxisType["StringAxis"] = 2] = "StringAxis";
33
+ })(YAxisType || (YAxisType = {}));
34
+ /**
35
+ * Create Numeric X axis
36
+ * @export
37
+ * @param {IXAxisParams} xAxisParams
38
+ */ export function createNumericXAxis(xAxisParams, tickParams, chartType, culture) {
39
+ const { domainNRangeValues, showRoundOffXTickValues = false, xAxistickSize = 6, tickPadding = 10, xAxisCount, xAxisElement, hideTickOverlap } = xAxisParams;
40
+ const xAxisScale = d3ScaleLinear().domain([
41
+ domainNRangeValues.dStartValue,
42
+ domainNRangeValues.dEndValue
43
+ ]).range([
44
+ domainNRangeValues.rStartValue,
45
+ domainNRangeValues.rEndValue
46
+ ]);
47
+ showRoundOffXTickValues && xAxisScale.nice();
48
+ let tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
49
+ const tickFormat = (domainValue, _index)=>{
50
+ if (tickParams.tickFormat) {
51
+ return d3Format(tickParams.tickFormat)(domainValue);
52
+ }
53
+ const xAxisValue = typeof domainValue === 'number' ? domainValue : domainValue.valueOf();
54
+ return convertToLocaleString(xAxisValue, culture);
55
+ };
56
+ if (hideTickOverlap && typeof xAxisCount === 'undefined') {
57
+ const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 20;
58
+ const [start, end] = xAxisScale.range();
59
+ tickCount = Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth));
60
+ }
61
+ const xAxis = d3AxisBottom(xAxisScale).tickSize(xAxistickSize).tickPadding(tickPadding).ticks(tickCount).tickFormat(tickFormat);
62
+ if (chartType === 6) {
63
+ xAxis.tickSizeInner(-(xAxisParams.containerHeight - xAxisParams.margins.top));
64
+ }
65
+ if (tickParams.tickValues) {
66
+ xAxis.tickValues(tickParams.tickValues);
67
+ }
68
+ if (xAxisElement) {
69
+ d3Select(xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
70
+ }
71
+ var _tickParams_tickValues;
72
+ const tickValues = ((_tickParams_tickValues = tickParams.tickValues) !== null && _tickParams_tickValues !== void 0 ? _tickParams_tickValues : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
73
+ return {
74
+ xScale: xAxisScale,
75
+ tickValues
76
+ };
77
+ }
78
+ function multiFormat(date, locale, useUTC) {
79
+ const timeFormat = locale ? useUTC ? locale.utcFormat : locale.format : useUTC ? d3UtcFormat : d3TimeFormat;
80
+ const formatMillisecond = timeFormat('.%L');
81
+ const formatSecond = timeFormat(':%S');
82
+ const formatMinute = timeFormat('%I:%M');
83
+ const formatHour = timeFormat('%I %p');
84
+ const formatDay = timeFormat('%a %d');
85
+ const formatWeek = timeFormat('%b %d');
86
+ const formatMonth = timeFormat('%B');
87
+ const formatYear = timeFormat('%Y');
88
+ const timeSecond = useUTC ? d3UtcSecond : d3TimeSecond;
89
+ const timeMinute = useUTC ? d3UtcMinute : d3TimeMinute;
90
+ const timeHour = useUTC ? d3UtcHour : d3TimeHour;
91
+ const timeDay = useUTC ? d3UtcDay : d3TimeDay;
92
+ const timeMonth = useUTC ? d3UtcMonth : d3TimeMonth;
93
+ const timeWeek = useUTC ? d3UtcWeek : d3TimeWeek;
94
+ const timeYear = useUTC ? d3UtcYear : d3TimeYear;
95
+ return (timeSecond(date) < date ? formatMillisecond : timeMinute(date) < date ? formatSecond : timeHour(date) < date ? formatMinute : timeDay(date) < date ? formatHour : timeMonth(date) < date ? timeWeek(date) < date ? formatDay : formatWeek : timeYear(date) < date ? formatMonth : formatYear)(date);
96
+ }
97
+ /**
98
+ * Creating Date x axis of the Chart
99
+ * @export
100
+ * @param {IXAxisParams} xAxisParams
101
+ * @param {ITickParams} tickParams
102
+ */ export function createDateXAxis(xAxisParams, tickParams, culture, options, timeFormatLocale, customDateTimeFormatter, useUTC) {
103
+ const { domainNRangeValues, xAxisElement, tickPadding = 6, xAxistickSize = 6, xAxisCount, hideTickOverlap } = xAxisParams;
104
+ const xAxisScale = useUTC ? d3ScaleUtc() : d3ScaleTime();
105
+ xAxisScale.domain([
106
+ domainNRangeValues.dStartValue,
107
+ domainNRangeValues.dEndValue
108
+ ]).range([
109
+ domainNRangeValues.rStartValue,
110
+ domainNRangeValues.rEndValue
111
+ ]);
112
+ let tickCount = xAxisCount !== null && xAxisCount !== void 0 ? xAxisCount : 6;
113
+ const tickFormat = (domainValue, _index)=>{
114
+ if (customDateTimeFormatter) {
115
+ return customDateTimeFormatter(domainValue);
116
+ }
117
+ if (culture && options) {
118
+ return domainValue.toLocaleString(culture, options);
119
+ }
120
+ if (timeFormatLocale) {
121
+ const locale = d3TimeFormatLocale(timeFormatLocale);
122
+ return multiFormat(domainValue, locale, useUTC);
123
+ }
124
+ if (culture === undefined && tickParams.tickFormat) {
125
+ if (useUTC) {
126
+ return d3UtcFormat(tickParams.tickFormat)(domainValue);
127
+ } else {
128
+ return d3TimeFormat(tickParams.tickFormat)(domainValue);
129
+ }
130
+ }
131
+ return multiFormat(domainValue, undefined, useUTC);
132
+ };
133
+ if (hideTickOverlap && typeof xAxisCount === 'undefined') {
134
+ const longestLabelWidth = calculateLongestLabelWidth(xAxisScale.ticks().map(tickFormat), '.fui-cart__xAxis text') + 40;
135
+ const [start, end] = xAxisScale.range();
136
+ tickCount = Math.max(1, Math.floor(Math.abs(end - start) / longestLabelWidth));
137
+ }
138
+ const xAxis = d3AxisBottom(xAxisScale).tickSize(xAxistickSize).tickPadding(tickPadding).ticks(tickCount).tickFormat(tickFormat);
139
+ tickParams.tickValues ? xAxis.tickValues(tickParams.tickValues) : '';
140
+ if (xAxisElement) {
141
+ d3Select(xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
142
+ }
143
+ var _tickParams_tickValues;
144
+ const tickValues = ((_tickParams_tickValues = tickParams.tickValues) !== null && _tickParams_tickValues !== void 0 ? _tickParams_tickValues : xAxisScale.ticks(tickCount)).map(xAxis.tickFormat());
145
+ return {
146
+ xScale: xAxisScale,
147
+ tickValues
148
+ };
149
+ }
150
+ /**
151
+ * Create String X axis
152
+ * Currently using for only Vetical stacked bar chart and grouped vertical bar chart
153
+ * @export
154
+ * @param {IXAxisParams} xAxisParams
155
+ * @param {ITickParams} tickParams
156
+ * @param {string[]} dataset
157
+ * @returns
158
+ */ export function createStringXAxis(xAxisParams, tickParams, dataset, culture) {
159
+ const { domainNRangeValues, xAxistickSize = 6, tickPadding = 10, xAxisPadding = 0.1, xAxisInnerPadding, xAxisOuterPadding, containerWidth, hideTickOverlap } = xAxisParams;
160
+ const xAxisScale = d3ScaleBand().domain(dataset).range([
161
+ domainNRangeValues.rStartValue,
162
+ domainNRangeValues.rEndValue
163
+ ]).paddingInner(typeof xAxisInnerPadding !== 'undefined' ? xAxisInnerPadding : xAxisPadding).paddingOuter(typeof xAxisOuterPadding !== 'undefined' ? xAxisOuterPadding : xAxisPadding);
164
+ var _tickParams_tickValues;
165
+ let tickValues = (_tickParams_tickValues = tickParams.tickValues) !== null && _tickParams_tickValues !== void 0 ? _tickParams_tickValues : dataset;
166
+ const tickFormat = (domainValue, _index)=>{
167
+ return convertToLocaleString(domainValue, culture);
168
+ };
169
+ if (hideTickOverlap) {
170
+ let nonOverlappingTickValues = [];
171
+ const tickSizes = tickValues.map((value, index)=>calculateLongestLabelWidth([
172
+ tickFormat(value, index)
173
+ ], '.fui-cart__xAxis text'));
174
+ // for LTR
175
+ let start = 0;
176
+ let end = containerWidth;
177
+ let sign = 1;
178
+ const range = xAxisScale.range();
179
+ if (range[1] - range[0] < 0) {
180
+ // for RTL
181
+ start = containerWidth;
182
+ end = 0;
183
+ sign = -1;
184
+ }
185
+ for(let i = tickValues.length - 1; i >= 0; i--){
186
+ const tickPosition = xAxisScale(tickValues[i]);
187
+ if (sign * (tickPosition - sign * tickSizes[i] / 2 - start) >= 0 && sign * (tickPosition + sign * tickSizes[i] / 2 - end) <= 0) {
188
+ nonOverlappingTickValues.push(tickValues[i]);
189
+ end = tickPosition - sign * (tickSizes[i] / 2 + 10);
190
+ }
191
+ }
192
+ nonOverlappingTickValues = nonOverlappingTickValues.reverse();
193
+ tickValues = nonOverlappingTickValues;
194
+ }
195
+ const xAxis = d3AxisBottom(xAxisScale).tickSize(xAxistickSize).tickPadding(tickPadding).tickValues(tickValues).tickFormat(tickFormat);
196
+ if (xAxisParams.xAxisElement) {
197
+ d3Select(xAxisParams.xAxisElement).call(xAxis).selectAll('text').attr('aria-hidden', 'true');
198
+ }
199
+ return {
200
+ xScale: xAxisScale,
201
+ tickValues: tickValues.map(xAxis.tickFormat())
202
+ };
203
+ }
204
+ export function useRtl() {
205
+ const { dir } = useFluent(); // "dir" returns "ltr" or "rtl"
206
+ return dir === 'rtl';
207
+ }
208
+ function isPowerOf10(num) {
209
+ const roundedfinalYMax = handleFloatingPointPrecisionError(num);
210
+ return Math.log10(roundedfinalYMax) % 1 === 0;
211
+ }
212
+ //for reference, go through this 'https://docs.python.org/release/2.5.1/tut/node16.html'
213
+ function handleFloatingPointPrecisionError(num) {
214
+ const rounded = Math.round(num);
215
+ return Math.abs(num - rounded) < 1e-6 ? rounded : num;
216
+ }
217
+ /**
218
+ * This method is used to calculate the rounded tick values for the y-axis
219
+ * @param {number} minVal
220
+ * @param {number} maxVal
221
+ * @param {number} splitInto
222
+ * @returns {number[]}
223
+ */ function calculateRoundedTicks(minVal, maxVal, splitInto) {
224
+ const finalYmin = minVal >= 0 && minVal === maxVal ? 0 : minVal;
225
+ const finalYmax = minVal < 0 && minVal === maxVal ? 0 : maxVal;
226
+ const ticksInterval = d3nice(finalYmin, finalYmax, splitInto);
227
+ const ticks = d3Ticks(ticksInterval[0], ticksInterval[ticksInterval.length - 1], splitInto);
228
+ if (ticks[ticks.length - 1] > finalYmax && isPowerOf10(finalYmax)) {
229
+ ticks.pop();
230
+ }
231
+ return ticks;
232
+ }
233
+ /**
234
+ * This method used for creating data points for the y axis.
235
+ * @export
236
+ * @param {number} maxVal
237
+ * @param {number} minVal
238
+ * @param {number} splitInto
239
+ * @param {boolean} isIntegralDataset
240
+ * @returns {number[]}
241
+ */ export function prepareDatapoints(maxVal, minVal, splitInto, isIntegralDataset, roundedTicks) {
242
+ if (roundedTicks) {
243
+ return calculateRoundedTicks(minVal, maxVal, splitInto);
244
+ }
245
+ const val = isIntegralDataset ? Math.ceil((maxVal - minVal) / splitInto) : (maxVal - minVal) / splitInto >= 1 ? Math.ceil((maxVal - minVal) / splitInto) : (maxVal - minVal) / splitInto;
246
+ /*
247
+ For cases where we have negative and positive values
248
+ The dataPointsArray is filled from 0 to minVal by val difference
249
+ Then the array is reversed and values from 0(excluding 0) to maxVal are appended
250
+ This ensures presence of 0 to act as an anchor reference.
251
+ For simple cases where the scale may not encounter such a need for 0,
252
+ We simply fill from minVal to maxVal
253
+ */ const dataPointsArray = [
254
+ minVal < 0 && maxVal >= 0 ? 0 : minVal
255
+ ];
256
+ /*For the case of all positive or all negative, we need to add another value
257
+ in array for atleast one interval, but in case of mix of positive and negative,
258
+ there will always be one more entry that will be added by the logic we have*/ if (dataPointsArray[0] === minVal) {
259
+ dataPointsArray.push(minVal + val);
260
+ }
261
+ if (minVal < 0 && maxVal >= 0) {
262
+ while(dataPointsArray[dataPointsArray.length - 1] > minVal){
263
+ dataPointsArray.push(dataPointsArray[dataPointsArray.length - 1] - val);
264
+ }
265
+ dataPointsArray.reverse();
266
+ }
267
+ while(dataPointsArray[dataPointsArray.length - 1] < maxVal){
268
+ dataPointsArray.push(dataPointsArray[dataPointsArray.length - 1] + val);
269
+ }
270
+ return dataPointsArray;
271
+ }
272
+ /**
273
+ * Creating Numeric Y axis of the chart
274
+ * @export
275
+ * @param {IYAxisParams} yAxisParams
276
+ * @param {boolean} isRtl
277
+ */ export function createYAxis(yAxisParams, isRtl, axisData, chartType, barWidth, isIntegralDataset, useSecondaryYScale = false, roundedTicks = false) {
278
+ switch(chartType){
279
+ case 6:
280
+ return createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData, barWidth);
281
+ default:
282
+ return createYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale, roundedTicks);
283
+ }
284
+ }
285
+ export function createYAxisForHorizontalBarChartWithAxis(yAxisParams, isRtl, axisData, barWidth) {
286
+ const { yMinMaxValues = {
287
+ startValue: 0,
288
+ endValue: 0
289
+ }, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4 } = yAxisParams;
290
+ // maxOfYVal coming from only area chart and Grouped vertical bar chart(Calculation done at base file)
291
+ const tempVal = maxOfYVal || yMinMaxValues.endValue;
292
+ const finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
293
+ const finalYmin = yMinMaxValues.startValue < yMinValue ? 0 : yMinValue;
294
+ const yAxisScale = d3ScaleLinear().domain([
295
+ finalYmin,
296
+ finalYmax
297
+ ]).range([
298
+ containerHeight - margins.bottom,
299
+ margins.top
300
+ ]);
301
+ const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
302
+ const yAxis = axis.tickPadding(tickPadding).ticks(yAxisTickCount);
303
+ yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(d3Format('.2~s'));
304
+ yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
305
+ return yAxisScale;
306
+ }
307
+ export function createYAxisForOtherCharts(yAxisParams, isRtl, axisData, isIntegralDataset, chartType, useSecondaryYScale = false, roundedTicks = false) {
308
+ const { yMinMaxValues = {
309
+ startValue: 0,
310
+ endValue: 0
311
+ }, yAxisElement = null, yMaxValue = 0, yMinValue = 0, containerHeight, containerWidth, margins, tickPadding = 12, maxOfYVal = 0, yAxisTickFormat, yAxisTickCount = 4, eventAnnotationProps, eventLabelHeight } = yAxisParams;
312
+ // maxOfYVal coming from only area chart and Grouped vertical bar chart(Calculation done at base file)
313
+ const tempVal = maxOfYVal || yMinMaxValues.endValue;
314
+ const finalYmax = tempVal > yMaxValue ? tempVal : yMaxValue;
315
+ const finalYmin = Math.min(yMinMaxValues.startValue, yMinValue || 0);
316
+ const domainValues = prepareDatapoints(finalYmax, finalYmin, yAxisTickCount, isIntegralDataset, roundedTicks);
317
+ let yMin = finalYmin;
318
+ let yMax = domainValues[domainValues.length - 1];
319
+ if (chartType === 7) {
320
+ const yPadding = (yMax - yMin) * 0.1;
321
+ yMin = yMin - yPadding;
322
+ yMax = yMax + yPadding;
323
+ }
324
+ const yAxisScale = d3ScaleLinear().domain([
325
+ domainValues[0],
326
+ yMax
327
+ ]).range([
328
+ containerHeight - margins.bottom,
329
+ margins.top + (eventAnnotationProps ? eventLabelHeight : 0)
330
+ ]);
331
+ const axis = !isRtl && useSecondaryYScale || isRtl && !useSecondaryYScale ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
332
+ const yAxis = axis.tickPadding(tickPadding).tickValues(domainValues).tickSizeInner(-(containerWidth - margins.left - margins.right));
333
+ yAxisTickFormat ? yAxis.tickFormat(yAxisTickFormat) : yAxis.tickFormat(d3Format('.2~s'));
334
+ yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text').attr('aria-hidden', 'true') : '';
335
+ axisData.yAxisDomainValues = domainValues;
336
+ return yAxisScale;
337
+ }
338
+ export const createStringYAxis = (yAxisParams, dataPoints, isRtl, chartType, barWidth, culture)=>{
339
+ switch(chartType){
340
+ case 6:
341
+ return createStringYAxisForHorizontalBarChartWithAxis(yAxisParams, dataPoints, isRtl, barWidth, culture);
342
+ default:
343
+ return createStringYAxisForOtherCharts(yAxisParams, dataPoints, isRtl);
344
+ }
345
+ };
346
+ /**
347
+ * Creating String Y axis of the chart for Horizontal Bar Chart With Axis
348
+ * @param yAxisParams
349
+ * @param dataPoints
350
+ * @param isRtl
351
+ */ export const createStringYAxisForHorizontalBarChartWithAxis = (yAxisParams, dataPoints, isRtl, barWidth, culture)=>{
352
+ const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement } = yAxisParams;
353
+ const yAxisScale = d3ScaleBand().domain(dataPoints).range([
354
+ containerHeight - margins.bottom - barWidth / 2,
355
+ margins.top + barWidth / 2
356
+ ]);
357
+ const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
358
+ const yAxis = axis.tickPadding(tickPadding).ticks(dataPoints);
359
+ if (yAxisTickFormat) {
360
+ yAxis.tickFormat(yAxisTickFormat);
361
+ }
362
+ yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
363
+ return yAxisScale;
364
+ };
365
+ /**
366
+ * Creating String Y axis of the chart for other chart except Horizontal Bar Chart With Axis
367
+ * @param yAxisParams
368
+ * @param dataPoints
369
+ * @param isRtl
370
+ */ export const createStringYAxisForOtherCharts = (yAxisParams, dataPoints, isRtl)=>{
371
+ const { containerHeight, tickPadding = 12, margins, yAxisTickFormat, yAxisElement, yAxisPadding = 0 } = yAxisParams;
372
+ const yAxisScale = d3ScaleBand().domain(dataPoints).range([
373
+ containerHeight - margins.bottom,
374
+ margins.top
375
+ ]).padding(yAxisPadding);
376
+ const axis = isRtl ? d3AxisRight(yAxisScale) : d3AxisLeft(yAxisScale);
377
+ const yAxis = axis.tickPadding(tickPadding).tickValues(dataPoints).tickSize(0);
378
+ if (yAxisTickFormat) {
379
+ yAxis.tickFormat(yAxisTickFormat);
380
+ }
381
+ yAxisElement ? d3Select(yAxisElement).call(yAxis).selectAll('text') : '';
382
+ return yAxisScale;
383
+ };
384
+ /**
385
+ * For area chart and line chart, while displaying stackCallout, Need to form a callout data object.
386
+ * This methos creates an object for those 2 charts.
387
+ * @param values
388
+ */ export function calloutData(values) {
389
+ let combinedResult = [];
390
+ values.forEach((line)=>{
391
+ const elements = line.data.filter((point)=>!point.hideCallout).map((point)=>{
392
+ return {
393
+ ...point,
394
+ legend: line.legend,
395
+ color: line.color,
396
+ index: line.index
397
+ };
398
+ });
399
+ combinedResult = combinedResult.concat(elements);
400
+ });
401
+ const xValToDataPoints = {};
402
+ combinedResult.forEach((ele)=>{
403
+ const xValue = ele.x instanceof Date ? ele.x.getTime() : ele.x;
404
+ if (xValue in xValToDataPoints) {
405
+ xValToDataPoints[xValue].push({
406
+ legend: ele.legend,
407
+ y: ele.y,
408
+ color: ele.color,
409
+ xAxisCalloutData: ele.xAxisCalloutData,
410
+ yAxisCalloutData: ele.yAxisCalloutData,
411
+ callOutAccessibilityData: ele.callOutAccessibilityData,
412
+ index: ele.index
413
+ });
414
+ } else {
415
+ xValToDataPoints[xValue] = [
416
+ {
417
+ legend: ele.legend,
418
+ y: ele.y,
419
+ color: ele.color,
420
+ xAxisCalloutData: ele.xAxisCalloutData,
421
+ yAxisCalloutData: ele.yAxisCalloutData,
422
+ callOutAccessibilityData: ele.callOutAccessibilityData,
423
+ index: ele.index
424
+ }
425
+ ];
426
+ }
427
+ });
428
+ const result = Object.keys(xValToDataPoints).map((xValue)=>{
429
+ const originalXValue = isNaN(Number(xValue)) ? xValue : Number(xValue);
430
+ return {
431
+ x: originalXValue,
432
+ values: xValToDataPoints[xValue]
433
+ };
434
+ });
435
+ return result;
436
+ }
437
+ export function getUnique(arr, comp) {
438
+ const unique = arr// eslint-disable-next-line @typescript-eslint/no-explicit-any
439
+ .map((e)=>e[comp])// store the keys of the unique objects
440
+ .map((e, i, final)=>final.indexOf(e) === i && i)// eliminate the dead keys & store unique objects
441
+ .filter((e)=>arr[e]).map((e)=>arr[e]);
442
+ return unique;
443
+ }
444
+ /**
445
+ * This function takes two paramerter
446
+ * 1. an array of strings
447
+ * 2. a string value
448
+ * if the value is not present in the given array then it will return the new
449
+ * array by appending the value to the present arrray.
450
+ *
451
+ * if the value is already present in the given array then it will return the new
452
+ * array by deleteing the value from the the array
453
+ * @param array
454
+ * @param value
455
+ */ export function silceOrAppendToArray(array, value) {
456
+ const pos = array.indexOf(value);
457
+ if (pos === -1) {
458
+ return [
459
+ ...array,
460
+ value
461
+ ];
462
+ } else {
463
+ return array.slice(0, pos).concat(array.slice(pos + 1));
464
+ }
465
+ }
466
+ /**
467
+ * This method used for wrapping of x axis labels (tick values).
468
+ * It breaks down given text value by space separated and calculates the total height needed to display all the words.
469
+ * That value = removal value. This value needs to be remove from total svg height, svg will shrink and
470
+ * total text will be displayed.
471
+ * @export
472
+ * @param {IWrapLabelProps} wrapLabelProps
473
+ * @returns
474
+ */ export function createWrapOfXLabels(wrapLabelProps) {
475
+ const { node, xAxis, noOfCharsToTruncate, showXAxisLablesTooltip } = wrapLabelProps;
476
+ if (node === null) {
477
+ return;
478
+ }
479
+ const axisNode = d3Select(node).call(xAxis);
480
+ let removeVal = 0;
481
+ const width = 10;
482
+ const arr = [];
483
+ axisNode.selectAll('.tick text').each(function() {
484
+ const text = d3Select(this);
485
+ const totalWord = text.text();
486
+ const truncatedWord = `${text.text().slice(0, noOfCharsToTruncate)}...`;
487
+ const totalWordLength = text.text().length;
488
+ const words = text.text().split(/\s+/).reverse();
489
+ arr.push(words.length);
490
+ let word = '';
491
+ let line = [];
492
+ let lineNumber = 0;
493
+ const lineHeight = 1.1; // ems
494
+ const y = text.attr('y');
495
+ const dy = parseFloat(text.attr('dy'));
496
+ let tspan = text.text(null).append('tspan').attr('x', 0).attr('y', y).attr('id', 'BaseSpan').attr('dy', dy + 'em').attr('data-', totalWord);
497
+ if (showXAxisLablesTooltip && totalWordLength > noOfCharsToTruncate) {
498
+ tspan = text.append('tspan').attr('id', 'showDots').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(truncatedWord);
499
+ } else if (showXAxisLablesTooltip && totalWordLength <= noOfCharsToTruncate) {
500
+ tspan = text.append('tspan').attr('id', 'LessLength').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(totalWord);
501
+ } else {
502
+ while(word = words.pop()){
503
+ line.push(word);
504
+ tspan.text(line.join(' '));
505
+ if (tspan.node().getComputedTextLength() > width && line.length > 1) {
506
+ line.pop();
507
+ tspan.text(line.join(' '));
508
+ line = [
509
+ word
510
+ ];
511
+ tspan = text.append('tspan').attr('id', 'WordBreakId').attr('x', 0).attr('y', y).attr('dy', ++lineNumber * lineHeight + dy + 'em').text(word);
512
+ }
513
+ }
514
+ const maxDigit = Math.max(...arr);
515
+ let maxHeight = 12; // intial value to render corretly first time
516
+ axisNode.selectAll('text').each(()=>{
517
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
518
+ const outerHTMLElement = document.getElementById('WordBreakId');
519
+ const BoxCordinates = outerHTMLElement && outerHTMLElement.getBoundingClientRect();
520
+ const boxHeight = BoxCordinates && BoxCordinates.height;
521
+ if (boxHeight > maxHeight) {
522
+ maxHeight = boxHeight;
523
+ }
524
+ });
525
+ // If we take directly maxDigit * maxheight, then it will show more height between x axis tick values and bottom.
526
+ // To avoid this, reducing maxDigit value by removing some digit based on legth of word.
527
+ let removeDigit = 4;
528
+ if (maxDigit <= 2) {
529
+ removeDigit = 1;
530
+ } else if (maxDigit > 2 && maxDigit <= 6) {
531
+ removeDigit = 2;
532
+ } else if (maxDigit > 6 && maxDigit <= 9) {
533
+ removeDigit = 3;
534
+ }
535
+ removeVal = (maxDigit - removeDigit) * maxHeight;
536
+ }
537
+ });
538
+ return removeVal > 0 ? removeVal : 0;
539
+ }
540
+ /**
541
+ * This method used for wrapping of y axis labels (tick values).
542
+ */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
543
+ export function createYAxisLabels(node, // eslint-disable-next-line @typescript-eslint/no-explicit-any
544
+ yAxis, noOfCharsToTruncate, truncateLabel, xValue, isRtl) {
545
+ if (node === null) {
546
+ return;
547
+ }
548
+ let tickIndex = 0;
549
+ const axisNode = d3Select(node).call(yAxis);
550
+ axisNode.selectAll('.tick text').each(function() {
551
+ const text = d3Select(this);
552
+ const totalWord = text.text();
553
+ const truncatedWord = isRtl ? `...${text.text().slice(0, noOfCharsToTruncate)}` : `${text.text().slice(0, noOfCharsToTruncate)}...`;
554
+ const totalWordLength = text.text().length;
555
+ const padding = truncateLabel ? 1.5 : 1; // ems
556
+ const y = text.attr('y');
557
+ const x = text.attr('x');
558
+ const dy = parseFloat(text.attr('dy'));
559
+ const dx = 0;
560
+ const uid = tickIndex++;
561
+ text.text(null).append('tspan').attr('x', x).attr('y', y).attr('id', `BaseSpan-${uid}`).attr('dy', dy + 'em').attr('data-', totalWord);
562
+ if (truncateLabel && totalWordLength > noOfCharsToTruncate) {
563
+ text.append('tspan').attr('id', `showDots-${uid}`).attr('x', isRtl ? 0 : x).attr('y', y).attr('dy', dy).attr('dx', padding + dx + 'em').text(truncatedWord);
564
+ } else {
565
+ text.attr('text-align', 'start').append('tspan').attr('id', `LessLength-${uid}`).attr('x', isRtl ? 0 : x).attr('y', y).attr('dx', padding + dx + 'em').text(totalWord);
566
+ }
567
+ });
568
+ }
569
+ export const wrapContent = (content, id, maxWidth)=>{
570
+ const textElement = d3Select(`#${id}`);
571
+ textElement.text(content);
572
+ if (!textElement.node()) {
573
+ return false;
574
+ }
575
+ let isOverflowing = false;
576
+ let textLength = textElement.node().getComputedTextLength();
577
+ while(textLength > maxWidth && content.length > 0){
578
+ content = content.slice(0, -1);
579
+ textElement.text(content + '...');
580
+ isOverflowing = true;
581
+ textLength = textElement.node().getComputedTextLength();
582
+ }
583
+ return isOverflowing;
584
+ };
585
+ /**
586
+ * Calculates the width of the longest axis label in pixels
587
+ */ export const calculateLongestLabelWidth = (labels, query = 'none')=>{
588
+ let maxLabelWidth = 0;
589
+ const canvas = document.createElement('canvas');
590
+ const ctx = canvas.getContext('2d');
591
+ if (ctx) {
592
+ const axisText = document.querySelector(query);
593
+ if (axisText) {
594
+ const styles = window.getComputedStyle(axisText, null);
595
+ const fontWeight = styles.getPropertyValue('font-weight');
596
+ const fontSize = styles.getPropertyValue('font-size');
597
+ const fontFamily = styles.getPropertyValue('font-family');
598
+ ctx.font = `${fontWeight} ${fontSize} ${fontFamily}`;
599
+ } else {
600
+ ctx.font = '600 10px "Segoe UI"';
601
+ }
602
+ labels.forEach((label)=>{
603
+ maxLabelWidth = Math.max(ctx.measureText(label.toString()).width, maxLabelWidth);
604
+ });
605
+ }
606
+ return maxLabelWidth;
607
+ };
608
+ /**
609
+ * This method displays a tooltip to the x axis lables(tick values)
610
+ * when prop 'showXAxisLablesTooltip' enables to the respected chart.
611
+ * On hover of the truncated word(at x axis labels tick), a tooltip will be appeared.
612
+ */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
613
+ export function tooltipOfXAxislabels(xAxistooltipProps) {
614
+ const { tooltipCls, xAxis, id } = xAxistooltipProps;
615
+ if (xAxis === null) {
616
+ return null;
617
+ }
618
+ const div = d3Select('body').append('div').attr('id', id).attr('class', tooltipCls).style('opacity', 0);
619
+ const aa = xAxis.selectAll('#BaseSpan')._groups[0];
620
+ const baseSpanLength = aa && Object.keys(aa).length;
621
+ const originalDataArray = [];
622
+ for(let i = 0; i < baseSpanLength; i++){
623
+ const originalData = aa[i].dataset && Object.values(aa[i].dataset)[0];
624
+ originalDataArray.push(originalData);
625
+ }
626
+ const tickObject = xAxis.selectAll('.tick')._groups[0];
627
+ const tickObjectLength = tickObject && Object.keys(tickObject).length;
628
+ for(let i = 0; i < tickObjectLength; i++){
629
+ const d1 = tickObject[i];
630
+ d3Select(d1)// eslint-disable-next-line @typescript-eslint/no-explicit-any
631
+ .on('mouseover', (event, d)=>{
632
+ div.style('opacity', 0.9);
633
+ div.html(originalDataArray[i]).style('left', event.pageX + 'px').style('top', event.pageY - 28 + 'px');
634
+ }).on('mouseout', (d)=>{
635
+ div.style('opacity', 0);
636
+ });
637
+ }
638
+ }
639
+ /**
640
+ * Find the axis type of line chart and area chart from given data
641
+ * @param points
642
+ */ export function getXAxisType(points) {
643
+ let isXAxisDateType = false;
644
+ if (points && points.length > 0) {
645
+ points.forEach((chartData)=>{
646
+ if (chartData.data.length > 0) {
647
+ isXAxisDateType = chartData.data[0].x instanceof Date;
648
+ return;
649
+ }
650
+ });
651
+ }
652
+ return isXAxisDateType;
653
+ }
654
+ /**
655
+ * Calculates Domain and range values for Numeric X axis.
656
+ * This method calculates Area cart and line chart.
657
+ * @export
658
+ * @param {LineChartPoints[]} points
659
+ * @param {IMargins} margins
660
+ * @param {number} width
661
+ * @param {boolean} isRTL
662
+ * @returns {IDomainNRange}
663
+ */ export function domainRangeOfNumericForAreaChart(points, margins, width, isRTL) {
664
+ const xMin = d3Min(points, (point)=>{
665
+ return d3Min(point.data, (item)=>item.x);
666
+ });
667
+ const xMax = d3Max(points, (point)=>{
668
+ return d3Max(point.data, (item)=>{
669
+ return item.x;
670
+ });
671
+ });
672
+ const rStartValue = margins.left;
673
+ const rEndValue = width - margins.right;
674
+ return isRTL ? {
675
+ dStartValue: xMax,
676
+ dEndValue: xMin,
677
+ rStartValue,
678
+ rEndValue
679
+ } : {
680
+ dStartValue: xMin,
681
+ dEndValue: xMax,
682
+ rStartValue,
683
+ rEndValue
684
+ };
685
+ }
686
+ /**
687
+ * Calculates Domain and range values for Numeric X axis for scatter chart.
688
+ * @export
689
+ * @param {LineChartPoints[]} points
690
+ * @param {IMargins} margins
691
+ * @param {number} width
692
+ * @param {boolean} isRTL
693
+ * @returns {IDomainNRange}
694
+ */ export function domainRangeOfNumericForScatterChart(points, margins, width, isRTL) {
695
+ let xMin = d3Min(points, (point)=>{
696
+ return d3Min(point.data, (item)=>item.x);
697
+ });
698
+ let xMax = d3Max(points, (point)=>{
699
+ return d3Max(point.data, (item)=>{
700
+ return item.x;
701
+ });
702
+ });
703
+ const xPadding = (xMax - xMin) * 0.1;
704
+ xMin = xMin - xPadding;
705
+ xMax = xMax + xPadding;
706
+ const rStartValue = margins.left;
707
+ const rEndValue = width - margins.right;
708
+ return isRTL ? {
709
+ dStartValue: xMax,
710
+ dEndValue: xMin,
711
+ rStartValue,
712
+ rEndValue
713
+ } : {
714
+ dStartValue: xMin,
715
+ dEndValue: xMax,
716
+ rStartValue,
717
+ rEndValue
718
+ };
719
+ }
720
+ /**
721
+ * Calculates Domain and range values for Numeric X axis.
722
+ * This method calculates Horizontal Chart with Axis
723
+ * @export
724
+ * @param {LineChartPoints[]} points
725
+ * @param {IMargins} margins
726
+ * @param {number} width
727
+ * @param {boolean} isRTL
728
+ * @returns {IDomainNRange}
729
+ */ export function domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, containerWidth, isRTL, shiftX) {
730
+ const xMax = d3Max(points, (point)=>point.x);
731
+ const rMin = isRTL ? margins.left : margins.left + shiftX;
732
+ const rMax = isRTL ? containerWidth - margins.right - shiftX : containerWidth - margins.right;
733
+ return isRTL ? {
734
+ dStartValue: xMax,
735
+ dEndValue: 0,
736
+ rStartValue: rMin,
737
+ rEndValue: rMax
738
+ } : {
739
+ dStartValue: 0,
740
+ dEndValue: xMax,
741
+ rStartValue: rMin,
742
+ rEndValue: rMax
743
+ };
744
+ }
745
+ /**
746
+ * Calculates Range values of x Axis string axis
747
+ * For String axis, we need to give domain values (Not start and end array values)
748
+ * So sending 0 as domain values. Domain will be handled at creation of string axis
749
+ * For charts stacked bar chart, grouped vertical bar chart, HeatMapChart and Vertical bar chart
750
+ * @export
751
+ * @param {IMargins} margins
752
+ * @param {number} width
753
+ * @param {boolean} isRTL
754
+ * @returns {IDomainNRange}
755
+ */ export function domainRangeOfXStringAxis(margins, width, isRTL) {
756
+ const rMin = margins.left;
757
+ const rMax = width - margins.right;
758
+ return isRTL ? {
759
+ dStartValue: 0,
760
+ dEndValue: 0,
761
+ rStartValue: rMax,
762
+ rEndValue: rMin
763
+ } : {
764
+ dStartValue: 0,
765
+ dEndValue: 0,
766
+ rStartValue: rMin,
767
+ rEndValue: rMax
768
+ };
769
+ }
770
+ /**
771
+ * Calculate domain and range values to the Vertical stacked bar chart - For Numeric axis
772
+ * @export
773
+ * @param {DataPoint[]} points
774
+ * @param {IMargins} margins
775
+ * @param {number} width
776
+ * @param {boolean} isRTL
777
+ * @param {number} barWidth
778
+ * @returns {IDomainNRange}
779
+ */ export function domainRangeOfVSBCNumeric(points, margins, width, isRTL, barWidth) {
780
+ const xMin = d3Min(points, (point)=>point.x);
781
+ const xMax = d3Max(points, (point)=>point.x);
782
+ const rMax = margins.left;
783
+ const rMin = width - margins.right;
784
+ return isRTL ? {
785
+ dStartValue: xMax,
786
+ dEndValue: xMin,
787
+ rStartValue: rMax,
788
+ rEndValue: rMin
789
+ } : {
790
+ dStartValue: xMin,
791
+ dEndValue: xMax,
792
+ rStartValue: rMax,
793
+ rEndValue: rMin
794
+ };
795
+ }
796
+ /**
797
+ * Calculates Domain and range values for Date X axis.
798
+ * This method calculates Bar chart.
799
+ * @export
800
+ * @param {VerticalBarChartDataPoint[]} points
801
+ * @param {IMargins} margins
802
+ * @param {number} width
803
+ * @param {boolean} isRTL
804
+ * @param {Date[] | number[]} tickValues
805
+ * @returns {IDomainNRange}
806
+ */ export function domainRangeOfDateForAreaLineVerticalBarChart(points, margins, width, isRTL, tickValues = [], chartType, barWidth) {
807
+ let sDate;
808
+ let lDate;
809
+ if (chartType === 0 || chartType === 1) {
810
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
811
+ sDate = d3Min(points, (point)=>{
812
+ return d3Min(point.data, (item)=>{
813
+ return item.x;
814
+ });
815
+ });
816
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
817
+ lDate = d3Max(points, (point)=>{
818
+ return d3Max(point.data, (item)=>{
819
+ return item.x;
820
+ });
821
+ });
822
+ // Need to draw graph with given small and large date
823
+ // (Which Involves customization of date axis tick values)
824
+ // That may be Either from given graph data or from prop 'tickValues' date values.
825
+ // So, Finding smallest and largest dates
826
+ sDate = d3Min([
827
+ ...tickValues,
828
+ sDate
829
+ ]);
830
+ lDate = d3Max([
831
+ ...tickValues,
832
+ lDate
833
+ ]);
834
+ } else {
835
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
836
+ sDate = d3Min(points, (point)=>point.x);
837
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
838
+ lDate = d3Max(points, (point)=>point.x);
839
+ }
840
+ const rStartValue = margins.left;
841
+ const rEndValue = width - margins.right;
842
+ return isRTL ? {
843
+ dStartValue: lDate,
844
+ dEndValue: sDate,
845
+ rStartValue,
846
+ rEndValue
847
+ } : {
848
+ dStartValue: sDate,
849
+ dEndValue: lDate,
850
+ rStartValue,
851
+ rEndValue
852
+ };
853
+ }
854
+ /**
855
+ * Calculates Domain and range values for Date X axis for scatter chart.
856
+ * @export
857
+ * @param {LineChartPoints[]} points
858
+ * @param {IMargins} margins
859
+ * @param {number} width
860
+ * @param {boolean} isRTL
861
+ * @param {Date[] | number[]} tickValues
862
+ * @returns {IDomainNRange}
863
+ */ export function domainRangeOfDateForScatterChart(points, margins, width, isRTL, tickValues = []) {
864
+ let sDate;
865
+ let lDate;
866
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
867
+ sDate = d3Min(points, (point)=>{
868
+ return d3Min(point.data, (item)=>{
869
+ return item.x;
870
+ });
871
+ });
872
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
873
+ lDate = d3Max(points, (point)=>{
874
+ return d3Max(point.data, (item)=>{
875
+ return item.x;
876
+ });
877
+ });
878
+ const xPadding = (lDate.getTime() - sDate.getTime()) * 0.1;
879
+ sDate = new Date(sDate.getTime() - xPadding);
880
+ lDate = new Date(lDate.getTime() + xPadding);
881
+ // Need to draw graph with given small and large date
882
+ // (Which Involves customization of date axis tick values)
883
+ // That may be Either from given graph data or from prop 'tickValues' date values.
884
+ // So, Finding smallest and largest dates
885
+ sDate = d3Min([
886
+ ...tickValues,
887
+ sDate
888
+ ]);
889
+ lDate = d3Max([
890
+ ...tickValues,
891
+ lDate
892
+ ]);
893
+ const rStartValue = margins.left;
894
+ const rEndValue = width - margins.right;
895
+ return isRTL ? {
896
+ dStartValue: lDate,
897
+ dEndValue: sDate,
898
+ rStartValue,
899
+ rEndValue
900
+ } : {
901
+ dStartValue: sDate,
902
+ dEndValue: lDate,
903
+ rStartValue,
904
+ rEndValue
905
+ };
906
+ }
907
+ /**
908
+ * Calculate domain and range values to the Vertical bar chart - For Numeric axis
909
+ * @export
910
+ * @param {DataPoint[]} points
911
+ * @param {IMargins} margins
912
+ * @param {number} containerWidth
913
+ * @param {boolean} isRTL
914
+ * @param {number} barWidth
915
+ * @returns {IDomainNRange}
916
+ */ export function domainRageOfVerticalNumeric(points, margins, containerWidth, isRTL, barWidth) {
917
+ const xMax = d3Max(points, (point)=>point.x);
918
+ const xMin = d3Min(points, (point)=>point.x);
919
+ const rMin = margins.left;
920
+ const rMax = containerWidth - margins.right;
921
+ return isRTL ? {
922
+ dStartValue: xMax,
923
+ dEndValue: xMin,
924
+ rStartValue: rMin,
925
+ rEndValue: rMax
926
+ } : {
927
+ dStartValue: xMin,
928
+ dEndValue: xMax,
929
+ rStartValue: rMin,
930
+ rEndValue: rMax
931
+ };
932
+ }
933
+ /**
934
+ * For creating X axis, need to calculate x axis domain and range values from given points.
935
+ * This may vary based on chart type and type of x axis
936
+ * So, this method will define which method need to call based on chart type and axis type.
937
+ * @export
938
+ * @param {*} points
939
+ * @param {IMargins} margins
940
+ * @param {number} width
941
+ * @param {ChartTypes} chartType
942
+ * @param {boolean} isRTL
943
+ * @param {XAxisTypes} xAxisType
944
+ * @param {number} [barWidth]
945
+ * @returns {IDomainNRange}
946
+ */ export function getDomainNRangeValues(// eslint-disable-next-line @typescript-eslint/no-explicit-any
947
+ points, margins, width, chartType, isRTL, xAxisType, barWidth, tickValues, shiftX) {
948
+ let domainNRangeValue;
949
+ if (xAxisType === 0) {
950
+ switch(chartType){
951
+ case 0:
952
+ case 1:
953
+ domainNRangeValue = domainRangeOfNumericForAreaChart(points, margins, width, isRTL);
954
+ break;
955
+ case 3:
956
+ domainNRangeValue = domainRangeOfVSBCNumeric(points, margins, width, isRTL, barWidth);
957
+ break;
958
+ case 2:
959
+ domainNRangeValue = domainRageOfVerticalNumeric(points, margins, width, isRTL, barWidth);
960
+ break;
961
+ case 6:
962
+ domainNRangeValue = domainRangeOfNumericForHorizontalBarChartWithAxis(points, margins, width, isRTL, shiftX);
963
+ break;
964
+ case 7:
965
+ domainNRangeValue = domainRangeOfNumericForScatterChart(points, margins, width, isRTL);
966
+ break;
967
+ default:
968
+ domainNRangeValue = {
969
+ dStartValue: 0,
970
+ dEndValue: 0,
971
+ rStartValue: 0,
972
+ rEndValue: 0
973
+ };
974
+ }
975
+ } else if (xAxisType === 1) {
976
+ switch(chartType){
977
+ case 0:
978
+ case 1:
979
+ case 2:
980
+ case 3:
981
+ domainNRangeValue = domainRangeOfDateForAreaLineVerticalBarChart(points, margins, width, isRTL, tickValues, chartType, barWidth);
982
+ break;
983
+ case 7:
984
+ domainNRangeValue = domainRangeOfDateForScatterChart(points, margins, width, isRTL, tickValues);
985
+ break;
986
+ default:
987
+ domainNRangeValue = {
988
+ dStartValue: 0,
989
+ dEndValue: 0,
990
+ rStartValue: 0,
991
+ rEndValue: 0
992
+ };
993
+ }
994
+ } else {
995
+ // String Axis type
996
+ switch(chartType){
997
+ case 3:
998
+ case 4:
999
+ case 2:
1000
+ case 5:
1001
+ case 7:
1002
+ domainNRangeValue = domainRangeOfXStringAxis(margins, width, isRTL);
1003
+ break;
1004
+ default:
1005
+ domainNRangeValue = {
1006
+ dStartValue: 0,
1007
+ dEndValue: 0,
1008
+ rStartValue: 0,
1009
+ rEndValue: 0
1010
+ };
1011
+ }
1012
+ }
1013
+ return domainNRangeValue;
1014
+ }
1015
+ /**
1016
+ * Calculating start and ending values of the Area chart and LineChart
1017
+ * @export
1018
+ * @param {LineChartPoints[]} points
1019
+ * @returns {{ startValue: number; endValue: number }}
1020
+ */ export function findNumericMinMaxOfY(points) {
1021
+ const yMax = d3Max(points, (point)=>{
1022
+ return d3Max(point.data, (item)=>item.y);
1023
+ });
1024
+ const yMin = d3Min(points, (point)=>{
1025
+ return d3Min(point.data, (item)=>item.y);
1026
+ });
1027
+ return {
1028
+ startValue: yMin,
1029
+ endValue: yMax
1030
+ };
1031
+ }
1032
+ /**
1033
+ * Find the minimum and maximum values of the vertical stacked bar chart y axis data point. Used for create y axis.
1034
+ * @export
1035
+ * @param {DataPoint[]} dataset
1036
+ * @returns {{ startValue: number; endValue: number }}
1037
+ */ export function findVSBCNumericMinMaxOfY(dataset) {
1038
+ const yMax = d3Max(dataset, (point)=>point.y);
1039
+ const yMin = d3Min(dataset, (point)=>point.y);
1040
+ return {
1041
+ startValue: yMin,
1042
+ endValue: yMax
1043
+ };
1044
+ }
1045
+ /**
1046
+ * Fins the min and max values of the vertical bar chart y axis data point.
1047
+ * @export
1048
+ * @param {VerticalBarChartDataPoint[]} points
1049
+ * @returns {{ startValue: number; endValue: number }}
1050
+ */ export function findVerticalNumericMinMaxOfY(points) {
1051
+ const yMax = d3Max(points, (point)=>{
1052
+ if (point.lineData !== undefined) {
1053
+ if (point.y > point.lineData.y) {
1054
+ return point.y;
1055
+ } else {
1056
+ return point.lineData.y;
1057
+ }
1058
+ } else {
1059
+ return point.y;
1060
+ }
1061
+ });
1062
+ const yMin = d3Min(points, (point)=>{
1063
+ if (point.lineData !== undefined) {
1064
+ if (point.y < point.lineData.y) {
1065
+ return point.y;
1066
+ } else {
1067
+ return point.lineData.y;
1068
+ }
1069
+ } else {
1070
+ return point.y;
1071
+ }
1072
+ });
1073
+ return {
1074
+ startValue: yMin,
1075
+ endValue: yMax
1076
+ };
1077
+ }
1078
+ /**
1079
+ * Fins the min and max values of the vertical bar chart y axis data point.
1080
+ * @export
1081
+ * @param {VerticalBarChartDataPoint[]} points
1082
+ * @returns {{ startValue: number; endValue: number }}
1083
+ */ export function findHBCWANumericMinMaxOfY(points, yAxisType) {
1084
+ if (yAxisType !== undefined && yAxisType === 0) {
1085
+ const yMax = d3Max(points, (point)=>point.y);
1086
+ const yMin = d3Min(points, (point)=>point.y);
1087
+ return {
1088
+ startValue: yMin,
1089
+ endValue: yMax
1090
+ };
1091
+ }
1092
+ return {
1093
+ startValue: 0,
1094
+ endValue: 0
1095
+ };
1096
+ }
1097
+ /**
1098
+ * For creating Y axis, need to calculate y axis domain values from given points. This may vary based on chart type.
1099
+ * So, this method will define which method need to call based on chart type to find out min and max values(For Domain).
1100
+ * For grouped vertical bar chart, Calculating yMax value in the base file and sending as MaxOfYVal to cartesian.
1101
+ * @export
1102
+ * @param {*} points
1103
+ * @param {ChartTypes} chartType
1104
+ * @returns {{ startValue: number; endValue: number }}
1105
+ */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1106
+ export function getMinMaxOfYAxis(// eslint-disable-next-line @typescript-eslint/no-explicit-any
1107
+ points, chartType, yAxisType = 0) {
1108
+ let minMaxValues;
1109
+ switch(chartType){
1110
+ case 0:
1111
+ case 1:
1112
+ case 7:
1113
+ minMaxValues = findNumericMinMaxOfY(points);
1114
+ break;
1115
+ case 3:
1116
+ minMaxValues = findVSBCNumericMinMaxOfY(points);
1117
+ break;
1118
+ case 2:
1119
+ minMaxValues = findVerticalNumericMinMaxOfY(points);
1120
+ break;
1121
+ case 6:
1122
+ minMaxValues = findHBCWANumericMinMaxOfY(points, yAxisType);
1123
+ break;
1124
+ default:
1125
+ minMaxValues = {
1126
+ startValue: 0,
1127
+ endValue: 0
1128
+ };
1129
+ }
1130
+ return minMaxValues;
1131
+ }
1132
+ /**
1133
+ * @param p string or number or Date
1134
+ *
1135
+ * This function takes the single data point of the x-aixs
1136
+ * and decides what is the x-axis
1137
+ */ export const getTypeOfAxis = (p, isXAxis)=>{
1138
+ if (isXAxis) {
1139
+ switch(typeof p){
1140
+ case 'string':
1141
+ return 2;
1142
+ case 'number':
1143
+ return 0;
1144
+ default:
1145
+ return 1;
1146
+ }
1147
+ } else {
1148
+ switch(typeof p){
1149
+ case 'string':
1150
+ return 2;
1151
+ case 'number':
1152
+ return 0;
1153
+ default:
1154
+ return 1;
1155
+ }
1156
+ }
1157
+ };
1158
+ export var Points;
1159
+ (function(Points) {
1160
+ Points[Points["circle"] = 0] = "circle";
1161
+ Points[Points["square"] = 1] = "square";
1162
+ Points[Points["triangle"] = 2] = "triangle";
1163
+ Points[Points["diamond"] = 3] = "diamond";
1164
+ Points[Points["pyramid"] = 4] = "pyramid";
1165
+ Points[Points["hexagon"] = 5] = "hexagon";
1166
+ Points[Points["pentagon"] = 6] = "pentagon";
1167
+ Points[Points["octagon"] = 7] = "octagon";
1168
+ })(Points || (Points = {}));
1169
+ export var CustomPoints;
1170
+ (function(CustomPoints) {
1171
+ CustomPoints[CustomPoints["dottedLine"] = 0] = "dottedLine";
1172
+ })(CustomPoints || (CustomPoints = {}));
1173
+ /**
1174
+ * we need to make sure that if we add any property to this, then
1175
+ * we need to also add that in enum Point and vise-versa
1176
+ */ export const pointTypes = {
1177
+ [0]: {
1178
+ widthRatio: 1
1179
+ },
1180
+ [1]: {
1181
+ widthRatio: 1
1182
+ },
1183
+ [2]: {
1184
+ widthRatio: 1
1185
+ },
1186
+ [3]: {
1187
+ widthRatio: 1
1188
+ },
1189
+ [4]: {
1190
+ widthRatio: 1
1191
+ },
1192
+ [5]: {
1193
+ widthRatio: 2
1194
+ },
1195
+ [6]: {
1196
+ widthRatio: 1.168
1197
+ },
1198
+ [7]: {
1199
+ widthRatio: 2.414
1200
+ }
1201
+ };
1202
+ /**
1203
+ * @param accessibleData accessible data
1204
+ * @param role string to define role of tag
1205
+ * @param isDataFocusable boolean
1206
+ * function returns the accessibility data object
1207
+ */ export const getAccessibleDataObject = (accessibleData, role = 'text', isDataFocusable = true)=>{
1208
+ accessibleData = accessibleData !== null && accessibleData !== void 0 ? accessibleData : {};
1209
+ return {
1210
+ role,
1211
+ 'data-is-focusable': isDataFocusable,
1212
+ 'aria-label': accessibleData.ariaLabel,
1213
+ 'aria-labelledby': accessibleData.ariaLabelledBy,
1214
+ 'aria-describedby': accessibleData.ariaDescribedBy
1215
+ };
1216
+ };
1217
+ export const convertToLocaleString = (data, culture)=>{
1218
+ if (data === undefined || data === null || Number.isNaN(data)) {
1219
+ return data;
1220
+ }
1221
+ culture = culture || undefined;
1222
+ if (typeof data === 'number') {
1223
+ return data.toLocaleString(culture);
1224
+ } else if (typeof data === 'string' && !isNaN(Number(data))) {
1225
+ const num = Number(data);
1226
+ return num.toLocaleString(culture);
1227
+ } else if (data instanceof Date) {
1228
+ return data.toLocaleDateString(culture);
1229
+ }
1230
+ return data;
1231
+ };
1232
+ export function rotateXAxisLabels(rotateLabelProps) {
1233
+ const { node, xAxis } = rotateLabelProps;
1234
+ if (node === null || xAxis === null) {
1235
+ return;
1236
+ }
1237
+ let maxHeight = 0;
1238
+ const xAxisTranslations = [];
1239
+ d3Select(node).call(xAxis).selectAll('.tick').each(function() {
1240
+ const translateValue = this.getAttribute('transform');
1241
+ if ((translateValue === null || translateValue === void 0 ? void 0 : translateValue.indexOf('rotate')) === -1) {
1242
+ const translatePair = translateValue.substring(translateValue.indexOf('(') + 1, translateValue.indexOf(')')).split(',');
1243
+ if (translatePair.length === 2) {
1244
+ xAxisTranslations.push(translatePair[0]);
1245
+ this.setAttribute('transform', `translate(${translatePair[0]},0)rotate(-45)`);
1246
+ }
1247
+ }
1248
+ const BoxCordinates = this.getBoundingClientRect();
1249
+ const boxHeight = BoxCordinates && BoxCordinates.height;
1250
+ if (boxHeight > maxHeight) {
1251
+ maxHeight = boxHeight;
1252
+ }
1253
+ });
1254
+ let idx = 0;
1255
+ d3Select(node).call(xAxis).selectAll('.tick').each(function() {
1256
+ if (xAxisTranslations.length > idx) {
1257
+ this.setAttribute('transform', `translate(${xAxisTranslations[idx]},${maxHeight / 2})rotate(-45)`); // Translate y by max height/2
1258
+ idx += 1;
1259
+ }
1260
+ });
1261
+ return Math.floor(maxHeight / 1.414); // Compute maxHeight/tanInverse(45) to get the vertical height of labels.
1262
+ }
1263
+ export function wrapTextInsideDonut(selectorClass, maxWidth) {
1264
+ let idx = 0;
1265
+ d3SelectAll(`.${selectorClass}`).each(function() {
1266
+ const text = d3Select(this);
1267
+ const words = text.text().split(/\s+/).reverse();
1268
+ let word = '';
1269
+ let line = [];
1270
+ let lineNumber = 0;
1271
+ const lineHeight = 1.1; // ems
1272
+ const y = text.attr('y');
1273
+ let tspan = text.text(null).append('tspan').attr('id', `WordBreakId-${idx}-${lineNumber}`).attr('x', 0).attr('y', y).attr('dy', lineNumber++ * lineHeight + 'em');
1274
+ while(word = words.pop()){
1275
+ line.push(word);
1276
+ tspan.text(line.join(' ') + ' ');
1277
+ if (tspan.node().getComputedTextLength() > maxWidth && line.length > 1) {
1278
+ line.pop();
1279
+ tspan.text(line.join(' ') + ' ');
1280
+ line = [
1281
+ word
1282
+ ];
1283
+ tspan = text.append('tspan').attr('id', `WordBreakId-${idx}-${lineNumber}`).attr('x', 0).attr('y', y).attr('dy', lineNumber++ * lineHeight + 'em').text(word);
1284
+ }
1285
+ }
1286
+ idx += 1;
1287
+ });
1288
+ }
1289
+ export function formatValueWithSIPrefix(value) {
1290
+ let specifier;
1291
+ if (value < 1000) {
1292
+ specifier = '.2~'; // upto 2 decimal places without insignificant trailing zeros
1293
+ } else {
1294
+ specifier = '.1'; // upto 1 decimal place
1295
+ }
1296
+ return d3FormatPrefix(specifier, value)(value);
1297
+ }
1298
+ const DEFAULT_BAR_WIDTH = 16;
1299
+ const MIN_BAR_WIDTH = 1;
1300
+ export const getBarWidth = (barWidthProp, maxBarWidthProp, adjustedValue = DEFAULT_BAR_WIDTH)=>{
1301
+ let barWidth;
1302
+ if (typeof barWidthProp === 'number') {
1303
+ barWidth = barWidthProp;
1304
+ } else if (barWidthProp === 'default' || typeof barWidthProp === 'undefined') {
1305
+ barWidth = Math.min(adjustedValue, DEFAULT_BAR_WIDTH);
1306
+ } else {
1307
+ barWidth = adjustedValue;
1308
+ }
1309
+ if (typeof maxBarWidthProp === 'number') {
1310
+ barWidth = Math.min(barWidth, maxBarWidthProp);
1311
+ }
1312
+ barWidth = Math.max(barWidth, MIN_BAR_WIDTH);
1313
+ return barWidth;
1314
+ };
1315
+ export const getScalePadding = (prop, shorthandProp, defaultValue = 0)=>{
1316
+ let padding = typeof prop === 'number' ? prop : typeof shorthandProp === 'number' ? shorthandProp : defaultValue;
1317
+ padding = Math.max(0, Math.min(padding, 1));
1318
+ return padding;
1319
+ };
1320
+ export const isScalePaddingDefined = (prop, shorthandProp)=>{
1321
+ return typeof prop === 'number' || typeof shorthandProp === 'number';
1322
+ };
1323
+ /**
1324
+ * Helper to find the index of an item within an array, using a callback to
1325
+ * determine the match.
1326
+ *
1327
+ * @public
1328
+ * @param array - Array to search.
1329
+ * @param cb - Callback which returns true on matches.
1330
+ * @param fromIndex - Optional index to start from (defaults to 0)
1331
+ */ export function findIndex(array, cb, fromIndex = 0) {
1332
+ let index = -1;
1333
+ for(let i = fromIndex; array && i < array.length; i++){
1334
+ if (cb(array[i], i)) {
1335
+ index = i;
1336
+ break;
1337
+ }
1338
+ }
1339
+ return index;
1340
+ }
1341
+ /**
1342
+ * Helper to find the first item within an array that satisfies the callback.
1343
+ * @param array - Array to search
1344
+ * @param cb - Callback which returns true on matches
1345
+ */ export function find(array, cb) {
1346
+ let index = findIndex(array, cb);
1347
+ if (index < 0) {
1348
+ return undefined;
1349
+ }
1350
+ return array[index];
1351
+ }
1352
+ export const HighContrastSelector = '@media screen and (-ms-high-contrast: active), screen and (forced-colors: active)';
1353
+ export const HighContrastSelectorWhite = // eslint-disable-next-line @fluentui/max-len
1354
+ '@media screen and (-ms-high-contrast: black-on-white), screen and (forced-colors: active) and (prefers-color-scheme: light)';
1355
+ export const HighContrastSelectorBlack = // eslint-disable-next-line @fluentui/max-len
1356
+ '@media screen and (-ms-high-contrast: white-on-black), screen and (forced-colors: active) and (prefers-color-scheme: dark)';
1357
+ export const formatDate = (date, useUTC)=>{
1358
+ const timeFormat = useUTC ? d3UtcFormat : d3TimeFormat;
1359
+ return timeFormat('%-e %b %Y, %H:%M')(date) + (useUTC ? ' GMT' : '');
1360
+ };
1361
+ export function areArraysEqual(arr1, arr2) {
1362
+ if (arr1 === arr2 || !arr1 && !arr2) {
1363
+ return true;
1364
+ }
1365
+ if (!arr1 || !arr2 || arr1.length !== arr2.length) {
1366
+ return false;
1367
+ }
1368
+ for(let i = 0; i < arr1.length; i++){
1369
+ if (arr1[i] !== arr2[i]) {
1370
+ return false;
1371
+ }
1372
+ }
1373
+ return true;
1374
+ }
1375
+ const cssVarRegExp = /var\((--[a-zA-Z0-9\-]+)\)/g;
1376
+ export function resolveCSSVariables(chartContainer, styleRules) {
1377
+ const containerStyles = getComputedStyle(chartContainer);
1378
+ return styleRules.replace(cssVarRegExp, (match, group1)=>{
1379
+ return containerStyles.getPropertyValue(group1);
1380
+ });
1381
+ }
1382
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1383
+ export function getSecureProps(props = {}) {
1384
+ const { dangerouslySetInnerHTML, ...result } = props;
1385
+ return result;
1386
+ }
1387
+ export function getCurveFactory(curve, defaultFactory = d3CurveLinear) {
1388
+ if (typeof curve === 'function') {
1389
+ return curve;
1390
+ }
1391
+ switch(curve){
1392
+ case 'linear':
1393
+ return d3CurveLinear;
1394
+ case 'natural':
1395
+ return d3CurveNatural;
1396
+ case 'step':
1397
+ return d3CurveStep;
1398
+ case 'stepAfter':
1399
+ return d3CurveStepAfter;
1400
+ case 'stepBefore':
1401
+ return d3CurveStepBefore;
1402
+ default:
1403
+ return defaultFactory;
1404
+ }
1405
+ }