@fluentui/react-charts 9.3.5 → 9.3.7

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 (337) hide show
  1. package/CHANGELOG.md +42 -2
  2. package/dist/index.d.ts +239 -55
  3. package/lib/AnnotationOnlyChart.js +1 -0
  4. package/lib/AnnotationOnlyChart.js.map +1 -0
  5. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js +194 -0
  6. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
  7. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +1 -0
  8. package/lib/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
  9. package/lib/components/AnnotationOnlyChart/index.js +2 -0
  10. package/lib/components/AnnotationOnlyChart/index.js.map +1 -0
  11. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +31 -0
  12. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
  13. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +23 -0
  14. package/lib/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
  15. package/lib/components/AreaChart/AreaChart.js +3 -16
  16. package/lib/components/AreaChart/AreaChart.js.map +1 -1
  17. package/lib/components/AreaChart/useAreaChartStyles.styles.js +11 -6
  18. package/lib/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  19. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
  20. package/lib/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  21. package/lib/components/ChartTable/ChartTable.js +2 -10
  22. package/lib/components/ChartTable/ChartTable.js.map +1 -1
  23. package/lib/components/ChartTable/ChartTable.types.js.map +1 -1
  24. package/lib/components/ChartTable/useChartTableStyles.styles.js +59 -39
  25. package/lib/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
  26. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js +5 -5
  27. package/lib/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
  28. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js +617 -0
  29. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  30. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +1 -0
  31. package/lib/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  32. package/lib/components/CommonComponents/Annotations/index.js +2 -0
  33. package/lib/components/CommonComponents/Annotations/index.js.map +1 -0
  34. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +173 -0
  35. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
  36. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +126 -0
  37. package/lib/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
  38. package/lib/components/CommonComponents/CartesianChart.js +159 -132
  39. package/lib/components/CommonComponents/CartesianChart.js.map +1 -1
  40. package/lib/components/CommonComponents/CartesianChart.types.js.map +1 -1
  41. package/lib/components/CommonComponents/ChartPopover.js +1 -2
  42. package/lib/components/CommonComponents/ChartPopover.js.map +1 -1
  43. package/lib/components/CommonComponents/index.js +2 -0
  44. package/lib/components/CommonComponents/index.js.map +1 -1
  45. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js +32 -14
  46. package/lib/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  47. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js +17 -2
  48. package/lib/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  49. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js +2 -6
  50. package/lib/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  51. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js +1 -2
  52. package/lib/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
  53. package/lib/components/DeclarativeChart/DeclarativeChart.js +83 -40
  54. package/lib/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  55. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js +4 -8
  56. package/lib/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  57. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js +692 -94
  58. package/lib/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  59. package/lib/components/DonutChart/Arc/useArcStyles.styles.js +23 -8
  60. package/lib/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  61. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js +2 -2
  62. package/lib/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  63. package/lib/components/DonutChart/DonutChart.js +3 -12
  64. package/lib/components/DonutChart/DonutChart.js.map +1 -1
  65. package/lib/components/DonutChart/DonutChart.types.js.map +1 -1
  66. package/lib/components/DonutChart/Pie/Pie.js +4 -2
  67. package/lib/components/DonutChart/Pie/Pie.js.map +1 -1
  68. package/lib/components/DonutChart/useDonutChartStyles.styles.js +2 -2
  69. package/lib/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  70. package/lib/components/FunnelChart/FunnelChart.js +2 -10
  71. package/lib/components/FunnelChart/FunnelChart.js.map +1 -1
  72. package/lib/components/FunnelChart/FunnelChart.types.js.map +1 -1
  73. package/lib/components/GanttChart/GanttChart.js +6 -19
  74. package/lib/components/GanttChart/GanttChart.js.map +1 -1
  75. package/lib/components/GanttChart/GanttChart.types.js.map +1 -1
  76. package/lib/components/GanttChart/useGanttChartStyles.styles.js +3 -1
  77. package/lib/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  78. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
  79. package/lib/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  80. package/lib/components/GaugeChart/GaugeChart.js +2 -10
  81. package/lib/components/GaugeChart/GaugeChart.js.map +1 -1
  82. package/lib/components/GaugeChart/GaugeChart.types.js.map +1 -1
  83. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +8 -20
  84. package/lib/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  85. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +11 -6
  86. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  87. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
  88. package/lib/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  89. package/lib/components/HeatMapChart/HeatMapChart.js +4 -17
  90. package/lib/components/HeatMapChart/HeatMapChart.js.map +1 -1
  91. package/lib/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
  92. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
  93. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  94. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
  95. package/lib/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  96. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +25 -12
  97. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  98. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +4 -4
  99. package/lib/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  100. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +5 -23
  101. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  102. package/lib/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
  103. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
  104. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  105. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
  106. package/lib/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  107. package/lib/components/Legends/Legends.types.js.map +1 -1
  108. package/lib/components/Legends/OverflowMenu.js.map +1 -1
  109. package/lib/components/Legends/useLegendsStyles.styles.js +97 -37
  110. package/lib/components/Legends/useLegendsStyles.styles.js.map +1 -1
  111. package/lib/components/Legends/useLegendsStyles.styles.raw.js +10 -11
  112. package/lib/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  113. package/lib/components/LineChart/LineChart.js +11 -20
  114. package/lib/components/LineChart/LineChart.js.map +1 -1
  115. package/lib/components/LineChart/LineChart.types.js +1 -1
  116. package/lib/components/LineChart/LineChart.types.js.map +1 -1
  117. package/lib/components/LineChart/eventAnnotation/EventAnnotation.js +3 -4
  118. package/lib/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -1
  119. package/lib/components/LineChart/useLineChartStyles.styles.js +15 -10
  120. package/lib/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  121. package/lib/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
  122. package/lib/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  123. package/lib/components/SankeyChart/SankeyChart.js +3 -9
  124. package/lib/components/SankeyChart/SankeyChart.js.map +1 -1
  125. package/lib/components/SankeyChart/SankeyChart.types.js.map +1 -1
  126. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js +13 -10
  127. package/lib/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  128. package/lib/components/ScatterChart/ScatterChart.js +24 -24
  129. package/lib/components/ScatterChart/ScatterChart.js.map +1 -1
  130. package/lib/components/ScatterChart/ScatterChart.types.js.map +1 -1
  131. package/lib/components/ScatterChart/useScatterChartStyles.styles.js +13 -8
  132. package/lib/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  133. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
  134. package/lib/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  135. package/lib/components/Sparkline/Sparkline.js +11 -7
  136. package/lib/components/Sparkline/Sparkline.js.map +1 -1
  137. package/lib/components/VerticalBarChart/VerticalBarChart.js +3 -15
  138. package/lib/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  139. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +13 -8
  140. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  141. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
  142. package/lib/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  143. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js +8 -18
  144. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  145. package/lib/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  146. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +11 -6
  147. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  148. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
  149. package/lib/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  150. package/lib/index.js +1 -0
  151. package/lib/index.js.map +1 -1
  152. package/lib/types/ChartAnnotation.js +1 -0
  153. package/lib/types/ChartAnnotation.js.map +1 -0
  154. package/lib/types/DataPoint.js.map +1 -1
  155. package/lib/types/index.js +1 -0
  156. package/lib/types/index.js.map +1 -1
  157. package/lib/utilities/Common.styles.js +1 -2
  158. package/lib/utilities/Common.styles.js.map +1 -1
  159. package/lib/utilities/Common.styles.raw.js +1 -2
  160. package/lib/utilities/Common.styles.raw.js.map +1 -1
  161. package/lib/utilities/FocusableTooltipText.js +1 -1
  162. package/lib/utilities/FocusableTooltipText.js.map +1 -1
  163. package/lib/utilities/getWindow.js +0 -1
  164. package/lib/utilities/getWindow.js.map +1 -1
  165. package/lib/utilities/hooks.js +34 -0
  166. package/lib/utilities/hooks.js.map +1 -0
  167. package/lib/utilities/image-export-utils.js +221 -73
  168. package/lib/utilities/image-export-utils.js.map +1 -1
  169. package/lib/utilities/utilities.js +39 -37
  170. package/lib/utilities/utilities.js.map +1 -1
  171. package/lib-commonjs/AnnotationOnlyChart.js +6 -0
  172. package/lib-commonjs/AnnotationOnlyChart.js.map +1 -0
  173. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js +205 -0
  174. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.js.map +1 -0
  175. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js +6 -0
  176. package/lib-commonjs/components/AnnotationOnlyChart/AnnotationOnlyChart.types.js.map +1 -0
  177. package/lib-commonjs/components/AnnotationOnlyChart/index.js +7 -0
  178. package/lib-commonjs/components/AnnotationOnlyChart/index.js.map +1 -0
  179. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js +56 -0
  180. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.js.map +1 -0
  181. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js +33 -0
  182. package/lib-commonjs/components/AnnotationOnlyChart/useAnnotationOnlyChartStyles.styles.raw.js.map +1 -0
  183. package/lib-commonjs/components/AreaChart/AreaChart.js +2 -15
  184. package/lib-commonjs/components/AreaChart/AreaChart.js.map +1 -1
  185. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js +14 -15
  186. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.js.map +1 -1
  187. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js +3 -1
  188. package/lib-commonjs/components/AreaChart/useAreaChartStyles.styles.raw.js.map +1 -1
  189. package/lib-commonjs/components/ChartTable/ChartTable.js +3 -10
  190. package/lib-commonjs/components/ChartTable/ChartTable.js.map +1 -1
  191. package/lib-commonjs/components/ChartTable/ChartTable.types.js.map +1 -1
  192. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js +74 -102
  193. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.js.map +1 -1
  194. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js +4 -4
  195. package/lib-commonjs/components/ChartTable/useChartTableStyles.styles.raw.js.map +1 -1
  196. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js +628 -0
  197. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.js.map +1 -0
  198. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js +4 -0
  199. package/lib-commonjs/components/CommonComponents/Annotations/ChartAnnotationLayer.types.js.map +1 -0
  200. package/lib-commonjs/components/CommonComponents/Annotations/index.js +7 -0
  201. package/lib-commonjs/components/CommonComponents/Annotations/index.js.map +1 -0
  202. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js +265 -0
  203. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.js.map +1 -0
  204. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js +161 -0
  205. package/lib-commonjs/components/CommonComponents/Annotations/useChartAnnotationLayer.styles.raw.js.map +1 -0
  206. package/lib-commonjs/components/CommonComponents/CartesianChart.js +159 -131
  207. package/lib-commonjs/components/CommonComponents/CartesianChart.js.map +1 -1
  208. package/lib-commonjs/components/CommonComponents/CartesianChart.types.js.map +1 -1
  209. package/lib-commonjs/components/CommonComponents/ChartPopover.js +1 -2
  210. package/lib-commonjs/components/CommonComponents/ChartPopover.js.map +1 -1
  211. package/lib-commonjs/components/CommonComponents/index.js +2 -0
  212. package/lib-commonjs/components/CommonComponents/index.js.map +1 -1
  213. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js +35 -22
  214. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.js.map +1 -1
  215. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js +17 -2
  216. package/lib-commonjs/components/CommonComponents/useCartesianChartStyles.styles.raw.js.map +1 -1
  217. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js +0 -14
  218. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.js.map +1 -1
  219. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js +0 -1
  220. package/lib-commonjs/components/CommonComponents/useChartPopoverStyles.styles.raw.js.map +1 -1
  221. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js +82 -39
  222. package/lib-commonjs/components/DeclarativeChart/DeclarativeChart.js.map +1 -1
  223. package/lib-commonjs/components/DeclarativeChart/PlotlyColorAdapter.js.map +1 -1
  224. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js +678 -60
  225. package/lib-commonjs/components/DeclarativeChart/PlotlySchemaAdapter.js.map +1 -1
  226. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js +25 -16
  227. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.js.map +1 -1
  228. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js +1 -1
  229. package/lib-commonjs/components/DonutChart/Arc/useArcStyles.styles.raw.js.map +1 -1
  230. package/lib-commonjs/components/DonutChart/DonutChart.js +2 -11
  231. package/lib-commonjs/components/DonutChart/DonutChart.js.map +1 -1
  232. package/lib-commonjs/components/DonutChart/DonutChart.types.js.map +1 -1
  233. package/lib-commonjs/components/DonutChart/Pie/Pie.js +4 -2
  234. package/lib-commonjs/components/DonutChart/Pie/Pie.js.map +1 -1
  235. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js +2 -2
  236. package/lib-commonjs/components/DonutChart/useDonutChartStyles.styles.js.map +1 -1
  237. package/lib-commonjs/components/FunnelChart/FunnelChart.js +2 -10
  238. package/lib-commonjs/components/FunnelChart/FunnelChart.js.map +1 -1
  239. package/lib-commonjs/components/FunnelChart/FunnelChart.types.js.map +1 -1
  240. package/lib-commonjs/components/GanttChart/GanttChart.js +5 -18
  241. package/lib-commonjs/components/GanttChart/GanttChart.js.map +1 -1
  242. package/lib-commonjs/components/GanttChart/GanttChart.types.js.map +1 -1
  243. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js +3 -1
  244. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.js.map +1 -1
  245. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js +3 -1
  246. package/lib-commonjs/components/GanttChart/useGanttChartStyles.styles.raw.js.map +1 -1
  247. package/lib-commonjs/components/GaugeChart/GaugeChart.js +2 -10
  248. package/lib-commonjs/components/GaugeChart/GaugeChart.js.map +1 -1
  249. package/lib-commonjs/components/GaugeChart/GaugeChart.types.js.map +1 -1
  250. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js +8 -20
  251. package/lib-commonjs/components/GroupedVerticalBarChart/GroupedVerticalBarChart.js.map +1 -1
  252. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js +14 -15
  253. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.js.map +1 -1
  254. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js +3 -1
  255. package/lib-commonjs/components/GroupedVerticalBarChart/useGroupedVerticalBarChartStyles.styles.raw.js.map +1 -1
  256. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js +3 -16
  257. package/lib-commonjs/components/HeatMapChart/HeatMapChart.js.map +1 -1
  258. package/lib-commonjs/components/HeatMapChart/HeatMapChart.types.js.map +1 -1
  259. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js +3 -1
  260. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.js.map +1 -1
  261. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js +3 -1
  262. package/lib-commonjs/components/HeatMapChart/useHeatMapChartStyles.styles.raw.js.map +1 -1
  263. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js +47 -34
  264. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.js.map +1 -1
  265. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js +3 -3
  266. package/lib-commonjs/components/HorizontalBarChart/useHorizontalBarChartStyles.styles.raw.js.map +1 -1
  267. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js +4 -21
  268. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.js.map +1 -1
  269. package/lib-commonjs/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.types.js.map +1 -1
  270. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js +3 -1
  271. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.js.map +1 -1
  272. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js +3 -1
  273. package/lib-commonjs/components/HorizontalBarChartWithAxis/useHorizontalBarChartWithAxisStyles.styles.raw.js.map +1 -1
  274. package/lib-commonjs/components/Legends/Legends.types.js.map +1 -1
  275. package/lib-commonjs/components/Legends/OverflowMenu.js.map +1 -1
  276. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js +144 -86
  277. package/lib-commonjs/components/Legends/useLegendsStyles.styles.js.map +1 -1
  278. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js +9 -10
  279. package/lib-commonjs/components/Legends/useLegendsStyles.styles.raw.js.map +1 -1
  280. package/lib-commonjs/components/LineChart/LineChart.js +11 -20
  281. package/lib-commonjs/components/LineChart/LineChart.js.map +1 -1
  282. package/lib-commonjs/components/LineChart/LineChart.types.js +1 -1
  283. package/lib-commonjs/components/LineChart/LineChart.types.js.map +1 -1
  284. package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js +2 -2
  285. package/lib-commonjs/components/LineChart/eventAnnotation/EventAnnotation.js.map +1 -1
  286. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js +18 -19
  287. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.js.map +1 -1
  288. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js +3 -1
  289. package/lib-commonjs/components/LineChart/useLineChartStyles.styles.raw.js.map +1 -1
  290. package/lib-commonjs/components/SankeyChart/SankeyChart.js +3 -9
  291. package/lib-commonjs/components/SankeyChart/SankeyChart.js.map +1 -1
  292. package/lib-commonjs/components/SankeyChart/SankeyChart.types.js.map +1 -1
  293. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js +16 -19
  294. package/lib-commonjs/components/SankeyChart/useSankeyChartStyles.styles.js.map +1 -1
  295. package/lib-commonjs/components/ScatterChart/ScatterChart.js +22 -22
  296. package/lib-commonjs/components/ScatterChart/ScatterChart.js.map +1 -1
  297. package/lib-commonjs/components/ScatterChart/ScatterChart.types.js.map +1 -1
  298. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js +16 -17
  299. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.js.map +1 -1
  300. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js +3 -1
  301. package/lib-commonjs/components/ScatterChart/useScatterChartStyles.styles.raw.js.map +1 -1
  302. package/lib-commonjs/components/Sparkline/Sparkline.js +11 -7
  303. package/lib-commonjs/components/Sparkline/Sparkline.js.map +1 -1
  304. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js +3 -15
  305. package/lib-commonjs/components/VerticalBarChart/VerticalBarChart.js.map +1 -1
  306. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js +16 -17
  307. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.js.map +1 -1
  308. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js +3 -1
  309. package/lib-commonjs/components/VerticalBarChart/useVerticalBarChartStyles.styles.raw.js.map +1 -1
  310. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js +7 -17
  311. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.js.map +1 -1
  312. package/lib-commonjs/components/VerticalStackedBarChart/VerticalStackedBarChart.types.js.map +1 -1
  313. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js +14 -15
  314. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.js.map +1 -1
  315. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js +3 -1
  316. package/lib-commonjs/components/VerticalStackedBarChart/useVerticalStackedBarChartStyles.styles.raw.js.map +1 -1
  317. package/lib-commonjs/index.js +1 -0
  318. package/lib-commonjs/index.js.map +1 -1
  319. package/lib-commonjs/types/ChartAnnotation.js +6 -0
  320. package/lib-commonjs/types/ChartAnnotation.js.map +1 -0
  321. package/lib-commonjs/types/DataPoint.js.map +1 -1
  322. package/lib-commonjs/types/index.js +1 -0
  323. package/lib-commonjs/types/index.js.map +1 -1
  324. package/lib-commonjs/utilities/Common.styles.js +1 -2
  325. package/lib-commonjs/utilities/Common.styles.js.map +1 -1
  326. package/lib-commonjs/utilities/Common.styles.raw.js +1 -2
  327. package/lib-commonjs/utilities/Common.styles.raw.js.map +1 -1
  328. package/lib-commonjs/utilities/FocusableTooltipText.js.map +1 -1
  329. package/lib-commonjs/utilities/getWindow.js +0 -1
  330. package/lib-commonjs/utilities/getWindow.js.map +1 -1
  331. package/lib-commonjs/utilities/hooks.js +45 -0
  332. package/lib-commonjs/utilities/hooks.js.map +1 -0
  333. package/lib-commonjs/utilities/image-export-utils.js +222 -74
  334. package/lib-commonjs/utilities/image-export-utils.js.map +1 -1
  335. package/lib-commonjs/utilities/utilities.js +37 -33
  336. package/lib-commonjs/utilities/utilities.js.map +1 -1
  337. package/package.json +11 -11
@@ -5,7 +5,8 @@ import { tokens } from '@fluentui/react-theme';
5
5
  import { ThemeContext_unstable as V9ThemeContext } from '@fluentui/react-shared-contexts';
6
6
  import { webLightTheme } from '@fluentui/tokens';
7
7
  import * as d3Color from 'd3-color';
8
- import { correctYearMonth, getGridProperties, isNonPlotType, transformPlotlyJsonToDonutProps, transformPlotlyJsonToVSBCProps, transformPlotlyJsonToAreaChartProps, transformPlotlyJsonToLineChartProps, transformPlotlyJsonToHorizontalBarWithAxisProps, transformPlotlyJsonToHeatmapProps, transformPlotlyJsonToSankeyProps, transformPlotlyJsonToGaugeProps, transformPlotlyJsonToGVBCProps, transformPlotlyJsonToVBCProps, transformPlotlyJsonToChartTableProps, transformPlotlyJsonToScatterChartProps, projectPolarToCartesian, getAllupLegendsProps, NON_PLOT_KEY_PREFIX, SINGLE_REPEAT, transformPlotlyJsonToFunnelChartProps, transformPlotlyJsonToGanttChartProps } from './PlotlySchemaAdapter';
8
+ import { correctYearMonth, getGridProperties, isNonPlotType, transformPlotlyJsonToDonutProps, transformPlotlyJsonToVSBCProps, transformPlotlyJsonToAreaChartProps, transformPlotlyJsonToLineChartProps, transformPlotlyJsonToHorizontalBarWithAxisProps, transformPlotlyJsonToHeatmapProps, transformPlotlyJsonToSankeyProps, transformPlotlyJsonToGaugeProps, transformPlotlyJsonToGVBCProps, transformPlotlyJsonToVBCProps, transformPlotlyJsonToChartTableProps, transformPlotlyJsonToScatterChartProps, projectPolarToCartesian, getAllupLegendsProps, NON_PLOT_KEY_PREFIX, SINGLE_REPEAT, transformPlotlyJsonToFunnelChartProps, transformPlotlyJsonToGanttChartProps, transformPlotlyJsonToAnnotationChartProps } from './PlotlySchemaAdapter';
9
+ import { AnnotationOnlyChart } from '../AnnotationOnlyChart/AnnotationOnlyChart';
9
10
  import { DonutChart } from '../DonutChart/index';
10
11
  import { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';
11
12
  import { LineChart } from '../LineChart/index';
@@ -22,6 +23,8 @@ import { GanttChart } from '../GanttChart/index';
22
23
  import { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';
23
24
  import { ChartTable } from '../ChartTable/index';
24
25
  import { Legends } from '../Legends/index';
26
+ import { resolveCSSVariables, useRtl } from '../../utilities/index';
27
+ import { exportChartsAsImage } from '../../utilities/image-export-utils';
25
28
  const ResponsiveDonutChart = withResponsiveContainer(DonutChart);
26
29
  const ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);
27
30
  const ResponsiveLineChart = withResponsiveContainer(LineChart);
@@ -76,6 +79,10 @@ const LineAreaPreTransformOp = (plotlyInput)=>{
76
79
  };
77
80
  };
78
81
  const chartMap = {
82
+ annotation: {
83
+ transformer: transformPlotlyJsonToAnnotationChartProps,
84
+ renderer: AnnotationOnlyChart
85
+ },
79
86
  // PieData category charts
80
87
  donut: {
81
88
  transformer: transformPlotlyJsonToDonutProps,
@@ -179,8 +186,11 @@ const useIsDarkTheme = ()=>{
179
186
  let { selectedLegends } = plotlySchema;
180
187
  const colorMap = useColorMapping();
181
188
  const isDarkTheme = useIsDarkTheme();
182
- const chartRef = React.useRef(null);
189
+ const chartRefs = React.useRef([]);
183
190
  const isMultiPlot = React.useRef(false);
191
+ const legendsRef = React.useRef(null);
192
+ const containerRef = React.useRef(null);
193
+ const isRTL = useRtl();
184
194
  if (!isArrayOrTypedArray(selectedLegends)) {
185
195
  selectedLegends = [];
186
196
  }
@@ -210,34 +220,46 @@ const useIsDarkTheme = ()=>{
210
220
  onChange: onActiveLegendsChange,
211
221
  selectedLegends: activeLegends
212
222
  };
213
- const commonProps = {
214
- legendProps: multiSelectLegendProps,
215
- componentRef: chartRef
223
+ const interactiveCommonProps = {
224
+ legendProps: multiSelectLegendProps
216
225
  };
217
226
  function createLegends(legendProps) {
218
227
  // eslint-disable-next-line react/jsx-no-bind
219
228
  return /*#__PURE__*/ React.createElement(Legends, {
220
229
  ...legendProps,
221
230
  selectedLegends: activeLegends,
222
- onChange: onActiveLegendsChange
231
+ onChange: onActiveLegendsChange,
232
+ legendRef: legendsRef
223
233
  });
224
234
  }
225
- // TODO
226
- const exportAsImage = React.useCallback((opts)=>{
227
- return new Promise((resolve, reject)=>{
228
- if (isMultiPlot.current) {
229
- return reject(Error('Exporting multi plot charts as image is not supported'));
230
- }
231
- if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {
232
- return reject(Error('Chart cannot be exported as image'));
235
+ const exportAsImage = React.useCallback(async (opts)=>{
236
+ var _legendsRef_current;
237
+ if (!containerRef.current) {
238
+ throw new Error('Container reference is null');
239
+ }
240
+ const imgExpOpts = {
241
+ background: resolveCSSVariables(containerRef.current, tokens.colorNeutralBackground1),
242
+ scale: 5,
243
+ ...opts
244
+ };
245
+ if (!isMultiPlot.current) {
246
+ var _chartRefs_current__compRef, _chartRefs_current_;
247
+ if (!((_chartRefs_current_ = chartRefs.current[0]) === null || _chartRefs_current_ === void 0 ? void 0 : (_chartRefs_current__compRef = _chartRefs_current_.compRef) === null || _chartRefs_current__compRef === void 0 ? void 0 : _chartRefs_current__compRef.toImage)) {
248
+ throw new Error('Chart cannot be exported as image');
233
249
  }
234
- chartRef.current.toImage({
235
- background: tokens.colorNeutralBackground1,
236
- scale: 5,
237
- ...opts
238
- }).then(resolve).catch(reject);
239
- });
240
- }, []);
250
+ return chartRefs.current[0].compRef.toImage(imgExpOpts);
251
+ }
252
+ return exportChartsAsImage(chartRefs.current.map((item)=>{
253
+ var _item_compRef;
254
+ return {
255
+ container: (_item_compRef = item.compRef) === null || _item_compRef === void 0 ? void 0 : _item_compRef.chartContainer,
256
+ row: item.row,
257
+ col: item.col
258
+ };
259
+ }), (_legendsRef_current = legendsRef.current) === null || _legendsRef_current === void 0 ? void 0 : _legendsRef_current.toSVG, isRTL, imgExpOpts);
260
+ }, [
261
+ isRTL
262
+ ]);
241
263
  React.useImperativeHandle(props.componentRef, ()=>({
242
264
  exportAsImage
243
265
  }), [
@@ -264,20 +286,25 @@ const useIsDarkTheme = ()=>{
264
286
  }
265
287
  const groupedTraces = {};
266
288
  let nonCartesianTraceCount = 0;
267
- plotlyInputWithValidData.data.forEach((trace, index)=>{
268
- let traceKey = '';
269
- if (isNonPlotType(chart.validTracesInfo[index].type)) {
270
- traceKey = `${NON_PLOT_KEY_PREFIX}${nonCartesianTraceCount + 1}`;
271
- nonCartesianTraceCount++;
272
- } else {
273
- var _trace_xaxis;
274
- traceKey = (_trace_xaxis = trace.xaxis) !== null && _trace_xaxis !== void 0 ? _trace_xaxis : DEFAULT_XAXIS;
275
- }
276
- if (!groupedTraces[traceKey]) {
277
- groupedTraces[traceKey] = [];
278
- }
279
- groupedTraces[traceKey].push(index);
280
- });
289
+ // For annotation-only charts, create a single group entry
290
+ if (chart.type === 'annotation') {
291
+ groupedTraces[DEFAULT_XAXIS] = [];
292
+ } else {
293
+ plotlyInputWithValidData.data.forEach((trace, index)=>{
294
+ let traceKey = '';
295
+ if (isNonPlotType(chart.validTracesInfo[index].type)) {
296
+ traceKey = `${NON_PLOT_KEY_PREFIX}${nonCartesianTraceCount + 1}`;
297
+ nonCartesianTraceCount++;
298
+ } else {
299
+ var _trace_xaxis;
300
+ traceKey = (_trace_xaxis = trace.xaxis) !== null && _trace_xaxis !== void 0 ? _trace_xaxis : DEFAULT_XAXIS;
301
+ }
302
+ if (!groupedTraces[traceKey]) {
303
+ groupedTraces[traceKey] = [];
304
+ }
305
+ groupedTraces[traceKey].push(index);
306
+ });
307
+ }
281
308
  isMultiPlot.current = Object.keys(groupedTraces).length > 1;
282
309
  const gridProperties = getGridProperties(plotlyInputWithValidData, isMultiPlot.current, chart.validTracesInfo);
283
310
  // Render only one plot if the grid properties cannot determine positioning of multiple plots.
@@ -306,14 +333,17 @@ const useIsDarkTheme = ()=>{
306
333
  display: 'grid',
307
334
  gridTemplateRows: gridProperties.templateRows,
308
335
  gridTemplateColumns: gridProperties.templateColumns
309
- }
310
- }, Object.entries(groupedTraces).map(([xAxisKey, index])=>{
336
+ },
337
+ ref: containerRef
338
+ }, Object.entries(groupedTraces).map(([xAxisKey, index], chartIdx)=>{
339
+ var _filteredTracesInfo_;
311
340
  const plotlyInputForGroup = {
312
341
  ...plotlyInputWithValidData,
313
342
  data: index.map((idx)=>plotlyInputWithValidData.data[idx])
314
343
  };
315
344
  const filteredTracesInfo = validTracesFilteredIndex.filter((trace)=>index.includes(trace.index));
316
- let chartType = chart.type === 'fallback' || chart.type === 'groupedverticalbar' ? chart.type : filteredTracesInfo[0].type;
345
+ var _filteredTracesInfo__type;
346
+ let chartType = chart.type === 'fallback' || chart.type === 'groupedverticalbar' ? chart.type : (_filteredTracesInfo__type = (_filteredTracesInfo_ = filteredTracesInfo[0]) === null || _filteredTracesInfo_ === void 0 ? void 0 : _filteredTracesInfo_.type) !== null && _filteredTracesInfo__type !== void 0 ? _filteredTracesInfo__type : chart.type;
317
347
  if (validTracesFilteredIndex.some((trace)=>trace.type === 'line') && validTracesFilteredIndex.some((trace)=>trace.type === 'scatter')) {
318
348
  chartType = 'line';
319
349
  }
@@ -323,6 +353,11 @@ const useIsDarkTheme = ()=>{
323
353
  if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {
324
354
  const transformedInput = preTransformOperation ? preTransformOperation(plotlyInputForGroup) : plotlyInputForGroup;
325
355
  const cellProperties = gridProperties.layout[xAxisKey];
356
+ const resolvedCommonProps = chartType === 'annotation' ? {} : {
357
+ ...interactiveCommonProps,
358
+ xAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.xAnnotation,
359
+ yAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.yAnnotation
360
+ };
326
361
  var _cellProperties_row, _cellProperties_column;
327
362
  return renderChart(renderer, transformer, [
328
363
  transformedInput,
@@ -331,9 +366,17 @@ const useIsDarkTheme = ()=>{
331
366
  colorwayType,
332
367
  isDarkTheme
333
368
  ], {
334
- ...commonProps,
369
+ ...resolvedCommonProps,
335
370
  xAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.xAnnotation,
336
- yAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.yAnnotation
371
+ yAxisAnnotation: cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.yAnnotation,
372
+ componentRef: (ref)=>{
373
+ var _cellProperties_row, _cellProperties_column;
374
+ chartRefs.current[chartIdx] = {
375
+ compRef: ref,
376
+ row: (_cellProperties_row = cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.row) !== null && _cellProperties_row !== void 0 ? _cellProperties_row : 1,
377
+ col: (_cellProperties_column = cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.column) !== null && _cellProperties_column !== void 0 ? _cellProperties_column : 1
378
+ };
379
+ }
337
380
  }, (_cellProperties_row = cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.row) !== null && _cellProperties_row !== void 0 ? _cellProperties_row : 1, (_cellProperties_column = cellProperties === null || cellProperties === void 0 ? void 0 : cellProperties.column) !== null && _cellProperties_column !== void 0 ? _cellProperties_column : 1);
338
381
  }
339
382
  return /*#__PURE__*/ React.createElement(React.Fragment, null);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DeclarativeChart/DeclarativeChart.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport * as React from 'react';\nimport type { Data, PlotData, PlotlySchema, OutputChartType, TraceInfo } from '@fluentui/chart-utilities';\nimport {\n decodeBase64Fields,\n isArrayOrTypedArray,\n isMonthArray,\n mapFluentChart,\n sanitizeJson,\n} from '@fluentui/chart-utilities';\nimport type { GridProperties } from './PlotlySchemaAdapter';\nimport { tokens } from '@fluentui/react-theme';\nimport { ThemeContext_unstable as V9ThemeContext } from '@fluentui/react-shared-contexts';\nimport { Theme, webLightTheme } from '@fluentui/tokens';\nimport * as d3Color from 'd3-color';\n\nimport {\n correctYearMonth,\n getGridProperties,\n isNonPlotType,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToAreaChartProps,\n transformPlotlyJsonToLineChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n transformPlotlyJsonToChartTableProps,\n transformPlotlyJsonToScatterChartProps,\n projectPolarToCartesian,\n getAllupLegendsProps,\n NON_PLOT_KEY_PREFIX,\n SINGLE_REPEAT,\n transformPlotlyJsonToFunnelChartProps,\n transformPlotlyJsonToGanttChartProps,\n} from './PlotlySchemaAdapter';\nimport type { ColorwayType } from './PlotlyColorAdapter';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport { LineChart } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { Chart, ImageExportOptions } from '../../types/index';\nimport { ScatterChart } from '../ScatterChart/index';\nimport { FunnelChart } from '../FunnelChart/FunnelChart';\nimport { GanttChart } from '../GanttChart/index';\n\nimport { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';\nimport { ChartTable } from '../ChartTable/index';\nimport { LegendsProps, Legends } from '../Legends/index';\nimport { JSXElement } from '@fluentui/react-utilities/src/index';\n\nconst ResponsiveDonutChart = withResponsiveContainer(DonutChart);\nconst ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);\nconst ResponsiveLineChart = withResponsiveContainer(LineChart);\nconst ResponsiveHorizontalBarChartWithAxis = withResponsiveContainer(HorizontalBarChartWithAxis);\nconst ResponsiveAreaChart = withResponsiveContainer(AreaChart);\nconst ResponsiveHeatMapChart = withResponsiveContainer(HeatMapChart);\nconst ResponsiveSankeyChart = withResponsiveContainer(SankeyChart);\nconst ResponsiveGaugeChart = withResponsiveContainer(GaugeChart);\nconst ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVerticalBarChart);\nconst ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);\nconst ResponsiveScatterChart = withResponsiveContainer(ScatterChart);\nconst ResponsiveChartTable = withResponsiveContainer(ChartTable);\nconst ResponsiveGanttChart = withResponsiveContainer(GanttChart);\n// Removing responsive wrapper for FunnelChart as responsive container is not working with FunnelChart\n//const ResponsiveFunnelChart = withResponsiveContainer(FunnelChart);\n\n// Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.\nconst DEFAULT_XAXIS = 'x';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.RefObject<IDeclarativeChart | null>;\n\n /**\n * Optional prop to specify the colorway type of the chart.\n * - 'default': Use Fluent UI color palette aligning with plotly colorway.\n * - 'builtin': Use Fluent UI colorway.\n * - 'others': Reserved for future colorways.\n * @default 'default'\n */\n colorwayType?: ColorwayType;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: ImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\nfunction renderChart<TProps>(\n Renderer: React.ComponentType<TProps>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformer: (...args: any[]) => TProps,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformerArgs: any[],\n commonProps: Partial<TProps>,\n cellRow: number,\n cellColumn: number,\n): JSXElement {\n const chartProps = transformer(...transformerArgs);\n return (\n <div\n key={`${cellRow}_${cellColumn}`}\n style={{\n gridRowStart: cellRow,\n gridRowEnd: cellRow + 1,\n gridColumnStart: cellColumn,\n gridColumnEnd: cellColumn + 1,\n }}\n >\n <Renderer {...chartProps} {...commonProps} />\n </div>\n );\n}\n\ntype PreTransformHooks = {\n preTransformCondition?: (plotlySchema: PlotlySchema) => boolean;\n preTransformOperation?: (plotlySchema: PlotlySchema) => PlotlySchema;\n};\n\nconst LineAreaPreTransformOp = (plotlyInput: PlotlySchema) => {\n const xValues = (plotlyInput.data[0] as PlotData).x;\n const isXMonth = isMonthArray(xValues);\n let renderData = plotlyInput.data;\n if (isXMonth) {\n renderData = plotlyInput.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n }\n return { data: renderData, layout: plotlyInput.layout };\n};\n\ntype ChartTypeMap = {\n donut: {\n transformer: typeof transformPlotlyJsonToDonutProps;\n renderer: typeof ResponsiveDonutChart;\n } & PreTransformHooks;\n sankey: {\n transformer: typeof transformPlotlyJsonToSankeyProps;\n renderer: typeof ResponsiveSankeyChart;\n } & PreTransformHooks;\n table: {\n transformer: typeof transformPlotlyJsonToChartTableProps;\n renderer: typeof ResponsiveChartTable;\n } & PreTransformHooks;\n horizontalbar: {\n transformer: typeof transformPlotlyJsonToHorizontalBarWithAxisProps;\n renderer: typeof ResponsiveHorizontalBarChartWithAxis;\n } & PreTransformHooks;\n groupedverticalbar: {\n transformer: typeof transformPlotlyJsonToGVBCProps;\n renderer: typeof ResponsiveGroupedVerticalBarChart;\n } & PreTransformHooks;\n verticalstackedbar: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n heatmap: {\n transformer: typeof transformPlotlyJsonToHeatmapProps;\n renderer: typeof ResponsiveHeatMapChart;\n } & PreTransformHooks;\n gauge: {\n transformer: typeof transformPlotlyJsonToGaugeProps;\n renderer: typeof ResponsiveGaugeChart;\n } & PreTransformHooks;\n verticalbar: {\n transformer: typeof transformPlotlyJsonToVBCProps;\n renderer: typeof ResponsiveVerticalBarChart;\n } & PreTransformHooks;\n area: {\n transformer: typeof transformPlotlyJsonToAreaChartProps;\n renderer: typeof ResponsiveAreaChart;\n } & PreTransformHooks;\n line: {\n transformer: typeof transformPlotlyJsonToLineChartProps;\n renderer: typeof ResponsiveLineChart;\n } & PreTransformHooks;\n scatter: {\n transformer: typeof transformPlotlyJsonToScatterChartProps;\n renderer: typeof ResponsiveScatterChart;\n } & PreTransformHooks;\n gantt: {\n transformer: typeof transformPlotlyJsonToGanttChartProps;\n renderer: typeof ResponsiveGanttChart;\n } & PreTransformHooks;\n funnel: {\n transformer: typeof transformPlotlyJsonToFunnelChartProps;\n renderer: typeof FunnelChart;\n } & PreTransformHooks;\n fallback: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n};\n\nconst chartMap: ChartTypeMap = {\n // PieData category charts\n donut: {\n transformer: transformPlotlyJsonToDonutProps,\n renderer: ResponsiveDonutChart,\n },\n // SankeyData category charts\n sankey: {\n transformer: transformPlotlyJsonToSankeyProps,\n renderer: ResponsiveSankeyChart,\n },\n // TableData category charts\n table: {\n transformer: transformPlotlyJsonToChartTableProps,\n renderer: ResponsiveChartTable,\n },\n // PlotData category charts\n horizontalbar: {\n transformer: transformPlotlyJsonToHorizontalBarWithAxisProps,\n renderer: ResponsiveHorizontalBarChartWithAxis,\n },\n groupedverticalbar: {\n transformer: transformPlotlyJsonToGVBCProps,\n renderer: ResponsiveGroupedVerticalBarChart,\n },\n verticalstackedbar: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n heatmap: {\n transformer: transformPlotlyJsonToHeatmapProps,\n renderer: ResponsiveHeatMapChart,\n },\n gauge: {\n transformer: transformPlotlyJsonToGaugeProps,\n renderer: ResponsiveGaugeChart,\n },\n verticalbar: {\n transformer: transformPlotlyJsonToVBCProps,\n renderer: ResponsiveVerticalBarChart,\n },\n area: {\n transformer: transformPlotlyJsonToAreaChartProps,\n renderer: ResponsiveAreaChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n line: {\n transformer: transformPlotlyJsonToLineChartProps,\n renderer: ResponsiveLineChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n scatter: {\n transformer: transformPlotlyJsonToScatterChartProps,\n renderer: ResponsiveScatterChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n gantt: {\n transformer: transformPlotlyJsonToGanttChartProps,\n renderer: ResponsiveGanttChart,\n },\n funnel: {\n transformer: transformPlotlyJsonToFunnelChartProps,\n renderer: FunnelChart,\n },\n fallback: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n};\n\nconst useIsDarkTheme = (): boolean => {\n const parentV9Theme = React.useContext(V9ThemeContext) as Theme;\n const v9Theme: Theme = parentV9Theme ? parentV9Theme : webLightTheme;\n\n // Get background and foreground colors\n const backgroundColor = d3Color.hsl(v9Theme.colorNeutralBackground1);\n const foregroundColor = d3Color.hsl(v9Theme.colorNeutralForeground1);\n\n const isDarkTheme = backgroundColor.l < foregroundColor.l;\n\n return isDarkTheme;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>(({ colorwayType = 'default', ...props }, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const chart: OutputChartType = mapFluentChart(plotlySchema);\n if (!chart.isValid) {\n throw new Error(`Invalid chart schema: ${chart.errorMessage}`);\n }\n let plotlyInput = plotlySchema as PlotlySchema;\n try {\n plotlyInput = decodeBase64Fields(plotlyInput);\n } catch (error) {\n throw new Error(`Failed to decode plotly schema: ${error}`);\n }\n const plotlyInputWithValidData: PlotlySchema = {\n ...plotlyInput,\n data: chart.validTracesInfo!.map(trace => plotlyInput.data[trace.index]),\n };\n\n const validTracesFilteredIndex: TraceInfo[] = chart.validTracesInfo!.map((trace, index) => ({\n index,\n type: trace.type,\n }));\n\n let { selectedLegends } = plotlySchema;\n const colorMap = useColorMapping();\n const isDarkTheme = useIsDarkTheme();\n const chartRef = React.useRef<Chart>(null);\n const isMultiPlot = React.useRef(false);\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { plotlyInput, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const multiSelectLegendProps = {\n canSelectMultipleLegends: true,\n onChange: onActiveLegendsChange,\n selectedLegends: activeLegends,\n };\n\n const commonProps = {\n legendProps: multiSelectLegendProps,\n componentRef: chartRef,\n };\n\n function createLegends(legendProps: LegendsProps): JSXElement {\n // eslint-disable-next-line react/jsx-no-bind\n return <Legends {...legendProps} selectedLegends={activeLegends} onChange={onActiveLegendsChange} />;\n }\n\n // TODO\n const exportAsImage = React.useCallback((opts?: ImageExportOptions): Promise<string> => {\n return new Promise((resolve, reject) => {\n if (isMultiPlot.current) {\n return reject(Error('Exporting multi plot charts as image is not supported'));\n }\n if (!chartRef.current || typeof chartRef.current.toImage !== 'function') {\n return reject(Error('Chart cannot be exported as image'));\n }\n\n chartRef.current\n .toImage({\n background: tokens.colorNeutralBackground1,\n scale: 5,\n ...opts,\n })\n .then(resolve)\n .catch(reject);\n });\n }, []);\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n plotlyInputWithValidData.layout = cartesianProjection.layout;\n validTracesFilteredIndex.forEach((trace, index) => {\n if (trace.type === 'scatterpolar') {\n const mode = (plotlyInputWithValidData.data[index] as PlotData)?.mode ?? '';\n if (mode.includes('line')) {\n validTracesFilteredIndex[index].type = 'line';\n } else if (mode.includes('markers') || mode === 'text') {\n validTracesFilteredIndex[index].type = 'scatter';\n } else {\n validTracesFilteredIndex[index].type = 'line';\n }\n }\n });\n }\n const groupedTraces: Record<string, number[]> = {};\n let nonCartesianTraceCount = 0;\n plotlyInputWithValidData.data.forEach((trace: Data, index: number) => {\n let traceKey = '';\n if (isNonPlotType(chart.validTracesInfo![index].type)) {\n traceKey = `${NON_PLOT_KEY_PREFIX}${nonCartesianTraceCount + 1}`;\n nonCartesianTraceCount++;\n } else {\n traceKey = (trace as PlotData).xaxis ?? DEFAULT_XAXIS;\n }\n if (!groupedTraces[traceKey]) {\n groupedTraces[traceKey] = [];\n }\n groupedTraces[traceKey].push(index);\n });\n\n isMultiPlot.current = Object.keys(groupedTraces).length > 1;\n const gridProperties: GridProperties = getGridProperties(\n plotlyInputWithValidData,\n isMultiPlot.current,\n chart.validTracesInfo!,\n );\n\n // Render only one plot if the grid properties cannot determine positioning of multiple plots.\n if (\n isMultiPlot.current &&\n gridProperties.templateRows === SINGLE_REPEAT &&\n gridProperties.templateColumns === SINGLE_REPEAT\n ) {\n if (chart.type === 'donut') {\n // If there are multiple data traces for donut/pie, picking the last one similar to plotly\n const keys = Object.keys(groupedTraces);\n keys.forEach((key, index) => {\n if (index < keys.length - 1) {\n delete groupedTraces[key];\n }\n });\n } else {\n Object.keys(groupedTraces).forEach((key, index) => {\n if (index > 0) {\n delete groupedTraces[key];\n }\n });\n }\n isMultiPlot.current = false;\n }\n\n const allupLegendsProps = getAllupLegendsProps(\n plotlyInputWithValidData,\n colorMap,\n colorwayType,\n chart.validTracesInfo!,\n isDarkTheme,\n );\n\n type ChartType = keyof ChartTypeMap;\n // map through the grouped traces and render the appropriate chart\n return (\n <>\n <div\n style={{\n display: 'grid',\n gridTemplateRows: gridProperties.templateRows,\n gridTemplateColumns: gridProperties.templateColumns,\n }}\n >\n {Object.entries(groupedTraces).map(([xAxisKey, index]) => {\n const plotlyInputForGroup: PlotlySchema = {\n ...plotlyInputWithValidData,\n data: index.map(idx => plotlyInputWithValidData.data[idx]),\n };\n\n const filteredTracesInfo = validTracesFilteredIndex.filter(trace => index.includes(trace.index));\n let chartType =\n chart.type === 'fallback' || chart.type === 'groupedverticalbar' ? chart.type : filteredTracesInfo[0].type;\n\n if (\n validTracesFilteredIndex.some(trace => trace.type === 'line') &&\n validTracesFilteredIndex.some(trace => trace.type === 'scatter')\n ) {\n chartType = 'line';\n }\n\n const chartEntry = chartMap[chartType as ChartType];\n if (chartEntry) {\n const { transformer, renderer, preTransformCondition, preTransformOperation } = chartEntry;\n if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {\n const transformedInput = preTransformOperation\n ? preTransformOperation(plotlyInputForGroup)\n : plotlyInputForGroup;\n const cellProperties = gridProperties.layout[xAxisKey];\n\n return renderChart<ReturnType<typeof transformer>>(\n renderer,\n transformer,\n [transformedInput, isMultiPlot.current, colorMap, colorwayType, isDarkTheme],\n {\n ...commonProps,\n xAxisAnnotation: cellProperties?.xAnnotation,\n yAxisAnnotation: cellProperties?.yAnnotation,\n },\n cellProperties?.row ?? 1,\n cellProperties?.column ?? 1,\n );\n }\n return <></>;\n } else {\n throw new Error(`Unsupported chart type :${plotlyInputForGroup.data[0]?.type}`);\n }\n })}\n </div>\n {isMultiPlot.current && createLegends(allupLegendsProps)}\n </>\n );\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\n"],"names":["React","decodeBase64Fields","isArrayOrTypedArray","isMonthArray","mapFluentChart","sanitizeJson","tokens","ThemeContext_unstable","V9ThemeContext","webLightTheme","d3Color","correctYearMonth","getGridProperties","isNonPlotType","transformPlotlyJsonToDonutProps","transformPlotlyJsonToVSBCProps","transformPlotlyJsonToAreaChartProps","transformPlotlyJsonToLineChartProps","transformPlotlyJsonToHorizontalBarWithAxisProps","transformPlotlyJsonToHeatmapProps","transformPlotlyJsonToSankeyProps","transformPlotlyJsonToGaugeProps","transformPlotlyJsonToGVBCProps","transformPlotlyJsonToVBCProps","transformPlotlyJsonToChartTableProps","transformPlotlyJsonToScatterChartProps","projectPolarToCartesian","getAllupLegendsProps","NON_PLOT_KEY_PREFIX","SINGLE_REPEAT","transformPlotlyJsonToFunnelChartProps","transformPlotlyJsonToGanttChartProps","DonutChart","VerticalStackedBarChart","LineChart","HorizontalBarChartWithAxis","AreaChart","HeatMapChart","SankeyChart","GaugeChart","GroupedVerticalBarChart","VerticalBarChart","ScatterChart","FunnelChart","GanttChart","withResponsiveContainer","ChartTable","Legends","ResponsiveDonutChart","ResponsiveVerticalStackedBarChart","ResponsiveLineChart","ResponsiveHorizontalBarChartWithAxis","ResponsiveAreaChart","ResponsiveHeatMapChart","ResponsiveSankeyChart","ResponsiveGaugeChart","ResponsiveGroupedVerticalBarChart","ResponsiveVerticalBarChart","ResponsiveScatterChart","ResponsiveChartTable","ResponsiveGanttChart","DEFAULT_XAXIS","useColorMapping","colorMap","useRef","Map","renderChart","Renderer","transformer","transformerArgs","commonProps","cellRow","cellColumn","chartProps","div","key","style","gridRowStart","gridRowEnd","gridColumnStart","gridColumnEnd","LineAreaPreTransformOp","plotlyInput","xValues","data","x","isXMonth","renderData","map","dataPoint","layout","chartMap","donut","renderer","sankey","table","horizontalbar","groupedverticalbar","verticalstackedbar","heatmap","gauge","verticalbar","area","preTransformOperation","line","scatter","gantt","funnel","fallback","useIsDarkTheme","parentV9Theme","useContext","v9Theme","backgroundColor","hsl","colorNeutralBackground1","foregroundColor","colorNeutralForeground1","isDarkTheme","l","DeclarativeChart","forwardRef","colorwayType","props","forwardedRef","plotlySchema","chartSchema","chart","isValid","Error","errorMessage","error","plotlyInputWithValidData","validTracesInfo","trace","index","validTracesFilteredIndex","type","selectedLegends","chartRef","isMultiPlot","activeLegends","setActiveLegends","useState","onActiveLegendsChange","keys","onSchemaChange","useEffect","multiSelectLegendProps","canSelectMultipleLegends","onChange","legendProps","componentRef","createLegends","exportAsImage","useCallback","opts","Promise","resolve","reject","current","toImage","background","scale","then","catch","useImperativeHandle","cartesianProjection","forEach","mode","includes","groupedTraces","nonCartesianTraceCount","traceKey","xaxis","push","Object","length","gridProperties","templateRows","templateColumns","allupLegendsProps","display","gridTemplateRows","gridTemplateColumns","entries","xAxisKey","plotlyInputForGroup","idx","filteredTracesInfo","filter","chartType","some","chartEntry","preTransformCondition","undefined","transformedInput","cellProperties","xAxisAnnotation","xAnnotation","yAxisAnnotation","yAnnotation","row","column","displayName"],"mappings":"AAAA;AAEA,uDAAuD,GACvD,YAAYA,WAAW,QAAQ;AAE/B,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,YAAY,EACZC,cAAc,EACdC,YAAY,QACP,4BAA4B;AAEnC,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,yBAAyBC,cAAc,QAAQ,kCAAkC;AAC1F,SAAgBC,aAAa,QAAQ,mBAAmB;AACxD,YAAYC,aAAa,WAAW;AAEpC,S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G0F;YAChF,IAAIC,0BAA0BC,aAAaD,sBAAsBP,sBAAsB;gBACrF,MAAMS,mBAAmB7F,wBACrBA,sBAAsBoF,uBACtBA;gBACJ,MAAMU,iBAAiBnB,eAAexF,MAAM,CAACgG,SAAS;oBAWpDW,qBACAA;gBAVF,OAAOnI,YACL2B,UACAzB,aACA;oBAACgI;oBAAkBxD,YAAYoB,OAAO;oBAAEjG;oBAAU2D;oBAAcJ;iBAAY,EAC5E;oBACE,GAAGhD,WAAW;oBACdgI,eAAe,EAAED,2BAAAA,qCAAAA,eAAgBE,WAAW;oBAC5CC,eAAe,EAAEH,2BAAAA,qCAAAA,eAAgBI,WAAW;gBAC9C,GACAJ,CAAAA,sBAAAA,2BAAAA,qCAAAA,eAAgBK,GAAG,cAAnBL,iCAAAA,sBAAuB,GACvBA,CAAAA,yBAAAA,2BAAAA,qCAAAA,eAAgBM,MAAM,cAAtBN,oCAAAA,yBAA0B;YAE9B;YACA,qBAAO;QACT,OAAO;gBACsCV;YAA3C,MAAM,IAAI1D,MAAM,CAAC,wBAAwB,GAAE0D,6BAAAA,oBAAoBvG,IAAI,CAAC,EAAE,cAA3BuG,iDAAAA,2BAA6BlD,IAAI,EAAE;QAChF;IACF,KAEDG,YAAYoB,OAAO,IAAIP,cAAc4B;AAG5C,GAAG;AACH7D,iBAAiBoF,WAAW,GAAG"}
1
+ {"version":3,"sources":["../src/components/DeclarativeChart/DeclarativeChart.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport * as React from 'react';\nimport type { Data, PlotData, PlotlySchema, OutputChartType, TraceInfo } from '@fluentui/chart-utilities';\nimport {\n decodeBase64Fields,\n isArrayOrTypedArray,\n isMonthArray,\n mapFluentChart,\n sanitizeJson,\n} from '@fluentui/chart-utilities';\nimport type { GridProperties } from './PlotlySchemaAdapter';\nimport { tokens } from '@fluentui/react-theme';\nimport { ThemeContext_unstable as V9ThemeContext } from '@fluentui/react-shared-contexts';\nimport { Theme, webLightTheme } from '@fluentui/tokens';\nimport * as d3Color from 'd3-color';\n\nimport {\n correctYearMonth,\n getGridProperties,\n isNonPlotType,\n transformPlotlyJsonToDonutProps,\n transformPlotlyJsonToVSBCProps,\n transformPlotlyJsonToAreaChartProps,\n transformPlotlyJsonToLineChartProps,\n transformPlotlyJsonToHorizontalBarWithAxisProps,\n transformPlotlyJsonToHeatmapProps,\n transformPlotlyJsonToSankeyProps,\n transformPlotlyJsonToGaugeProps,\n transformPlotlyJsonToGVBCProps,\n transformPlotlyJsonToVBCProps,\n transformPlotlyJsonToChartTableProps,\n transformPlotlyJsonToScatterChartProps,\n projectPolarToCartesian,\n getAllupLegendsProps,\n NON_PLOT_KEY_PREFIX,\n SINGLE_REPEAT,\n transformPlotlyJsonToFunnelChartProps,\n transformPlotlyJsonToGanttChartProps,\n transformPlotlyJsonToAnnotationChartProps,\n} from './PlotlySchemaAdapter';\nimport type { ColorwayType } from './PlotlyColorAdapter';\nimport { AnnotationOnlyChart } from '../AnnotationOnlyChart/AnnotationOnlyChart';\nimport { DonutChart } from '../DonutChart/index';\nimport { VerticalStackedBarChart } from '../VerticalStackedBarChart/index';\nimport { LineChart } from '../LineChart/index';\nimport { HorizontalBarChartWithAxis } from '../HorizontalBarChartWithAxis/index';\nimport { AreaChart } from '../AreaChart/index';\nimport { HeatMapChart } from '../HeatMapChart/index';\nimport { SankeyChart } from '../SankeyChart/SankeyChart';\nimport { GaugeChart } from '../GaugeChart/index';\nimport { GroupedVerticalBarChart } from '../GroupedVerticalBarChart/index';\nimport { VerticalBarChart } from '../VerticalBarChart/index';\nimport { Chart, ImageExportOptions } from '../../types/index';\nimport { ScatterChart } from '../ScatterChart/index';\nimport { FunnelChart } from '../FunnelChart/FunnelChart';\nimport { GanttChart } from '../GanttChart/index';\n\nimport { withResponsiveContainer } from '../ResponsiveContainer/withResponsiveContainer';\nimport { ChartTable } from '../ChartTable/index';\nimport { LegendsProps, Legends, LegendContainer } from '../Legends/index';\nimport { JSXElement } from '@fluentui/react-utilities/src/index';\nimport { resolveCSSVariables, useRtl } from '../../utilities/index';\nimport { exportChartsAsImage } from '../../utilities/image-export-utils';\n\nconst ResponsiveDonutChart = withResponsiveContainer(DonutChart);\nconst ResponsiveVerticalStackedBarChart = withResponsiveContainer(VerticalStackedBarChart);\nconst ResponsiveLineChart = withResponsiveContainer(LineChart);\nconst ResponsiveHorizontalBarChartWithAxis = withResponsiveContainer(HorizontalBarChartWithAxis);\nconst ResponsiveAreaChart = withResponsiveContainer(AreaChart);\nconst ResponsiveHeatMapChart = withResponsiveContainer(HeatMapChart);\nconst ResponsiveSankeyChart = withResponsiveContainer(SankeyChart);\nconst ResponsiveGaugeChart = withResponsiveContainer(GaugeChart);\nconst ResponsiveGroupedVerticalBarChart = withResponsiveContainer(GroupedVerticalBarChart);\nconst ResponsiveVerticalBarChart = withResponsiveContainer(VerticalBarChart);\nconst ResponsiveScatterChart = withResponsiveContainer(ScatterChart);\nconst ResponsiveChartTable = withResponsiveContainer(ChartTable);\nconst ResponsiveGanttChart = withResponsiveContainer(GanttChart);\n// Removing responsive wrapper for FunnelChart as responsive container is not working with FunnelChart\n//const ResponsiveFunnelChart = withResponsiveContainer(FunnelChart);\n\n// Default x-axis key for grouping traces. Also applicable for PieData and SankeyData where x-axis is not defined.\nconst DEFAULT_XAXIS = 'x';\n\n/**\n * DeclarativeChart schema.\n * {@docCategory DeclarativeChart}\n */\nexport interface Schema {\n /**\n * Plotly schema represented as JSON object\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n plotlySchema: any;\n}\n\n/**\n * DeclarativeChart props.\n * {@docCategory DeclarativeChart}\n */\nexport interface DeclarativeChartProps extends React.RefAttributes<HTMLDivElement> {\n /**\n * The schema representing the chart data, layout and configuration\n */\n chartSchema: Schema;\n\n /**\n * Callback when an event occurs\n */\n onSchemaChange?: (eventData: Schema) => void;\n\n /**\n * Optional callback to access the IDeclarativeChart interface. Use this instead of ref for accessing\n * the public methods and properties of the component.\n */\n componentRef?: React.Ref<IDeclarativeChart>;\n\n /**\n * Optional prop to specify the colorway type of the chart.\n * - 'default': Use Fluent UI color palette aligning with plotly colorway.\n * - 'builtin': Use Fluent UI colorway.\n * - 'others': Reserved for future colorways.\n * @default 'default'\n */\n colorwayType?: ColorwayType;\n}\n\n/**\n * {@docCategory DeclarativeChart}\n */\nexport interface IDeclarativeChart {\n exportAsImage: (opts?: ImageExportOptions) => Promise<string>;\n}\n\nconst useColorMapping = () => {\n const colorMap = React.useRef(new Map<string, string>());\n return colorMap;\n};\n\nfunction renderChart<TProps>(\n Renderer: React.ComponentType<TProps>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformer: (...args: any[]) => TProps,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n transformerArgs: any[],\n commonProps: Partial<TProps>,\n cellRow: number,\n cellColumn: number,\n): JSXElement {\n const chartProps = transformer(...transformerArgs);\n return (\n <div\n key={`${cellRow}_${cellColumn}`}\n style={{\n gridRowStart: cellRow,\n gridRowEnd: cellRow + 1,\n gridColumnStart: cellColumn,\n gridColumnEnd: cellColumn + 1,\n }}\n >\n <Renderer {...chartProps} {...commonProps} />\n </div>\n );\n}\n\ntype PreTransformHooks = {\n preTransformCondition?: (plotlySchema: PlotlySchema) => boolean;\n preTransformOperation?: (plotlySchema: PlotlySchema) => PlotlySchema;\n};\n\nconst LineAreaPreTransformOp = (plotlyInput: PlotlySchema) => {\n const xValues = (plotlyInput.data[0] as PlotData).x;\n const isXMonth = isMonthArray(xValues);\n let renderData = plotlyInput.data;\n if (isXMonth) {\n renderData = plotlyInput.data.map((dataPoint: PlotData) => ({\n ...dataPoint,\n x: correctYearMonth(dataPoint.x),\n }));\n }\n return { data: renderData, layout: plotlyInput.layout };\n};\n\ntype ChartTypeMap = {\n annotation: {\n transformer: typeof transformPlotlyJsonToAnnotationChartProps;\n renderer: typeof AnnotationOnlyChart;\n } & PreTransformHooks;\n donut: {\n transformer: typeof transformPlotlyJsonToDonutProps;\n renderer: typeof ResponsiveDonutChart;\n } & PreTransformHooks;\n sankey: {\n transformer: typeof transformPlotlyJsonToSankeyProps;\n renderer: typeof ResponsiveSankeyChart;\n } & PreTransformHooks;\n table: {\n transformer: typeof transformPlotlyJsonToChartTableProps;\n renderer: typeof ResponsiveChartTable;\n } & PreTransformHooks;\n horizontalbar: {\n transformer: typeof transformPlotlyJsonToHorizontalBarWithAxisProps;\n renderer: typeof ResponsiveHorizontalBarChartWithAxis;\n } & PreTransformHooks;\n groupedverticalbar: {\n transformer: typeof transformPlotlyJsonToGVBCProps;\n renderer: typeof ResponsiveGroupedVerticalBarChart;\n } & PreTransformHooks;\n verticalstackedbar: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n heatmap: {\n transformer: typeof transformPlotlyJsonToHeatmapProps;\n renderer: typeof ResponsiveHeatMapChart;\n } & PreTransformHooks;\n gauge: {\n transformer: typeof transformPlotlyJsonToGaugeProps;\n renderer: typeof ResponsiveGaugeChart;\n } & PreTransformHooks;\n verticalbar: {\n transformer: typeof transformPlotlyJsonToVBCProps;\n renderer: typeof ResponsiveVerticalBarChart;\n } & PreTransformHooks;\n area: {\n transformer: typeof transformPlotlyJsonToAreaChartProps;\n renderer: typeof ResponsiveAreaChart;\n } & PreTransformHooks;\n line: {\n transformer: typeof transformPlotlyJsonToLineChartProps;\n renderer: typeof ResponsiveLineChart;\n } & PreTransformHooks;\n scatter: {\n transformer: typeof transformPlotlyJsonToScatterChartProps;\n renderer: typeof ResponsiveScatterChart;\n } & PreTransformHooks;\n gantt: {\n transformer: typeof transformPlotlyJsonToGanttChartProps;\n renderer: typeof ResponsiveGanttChart;\n } & PreTransformHooks;\n funnel: {\n transformer: typeof transformPlotlyJsonToFunnelChartProps;\n renderer: typeof FunnelChart;\n } & PreTransformHooks;\n fallback: {\n transformer: typeof transformPlotlyJsonToVSBCProps;\n renderer: typeof ResponsiveVerticalStackedBarChart;\n } & PreTransformHooks;\n};\n\nconst chartMap: ChartTypeMap = {\n annotation: {\n transformer: transformPlotlyJsonToAnnotationChartProps,\n renderer: AnnotationOnlyChart,\n },\n // PieData category charts\n donut: {\n transformer: transformPlotlyJsonToDonutProps,\n renderer: ResponsiveDonutChart,\n },\n // SankeyData category charts\n sankey: {\n transformer: transformPlotlyJsonToSankeyProps,\n renderer: ResponsiveSankeyChart,\n },\n // TableData category charts\n table: {\n transformer: transformPlotlyJsonToChartTableProps,\n renderer: ResponsiveChartTable,\n },\n // PlotData category charts\n horizontalbar: {\n transformer: transformPlotlyJsonToHorizontalBarWithAxisProps,\n renderer: ResponsiveHorizontalBarChartWithAxis,\n },\n groupedverticalbar: {\n transformer: transformPlotlyJsonToGVBCProps,\n renderer: ResponsiveGroupedVerticalBarChart,\n },\n verticalstackedbar: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n heatmap: {\n transformer: transformPlotlyJsonToHeatmapProps,\n renderer: ResponsiveHeatMapChart,\n },\n gauge: {\n transformer: transformPlotlyJsonToGaugeProps,\n renderer: ResponsiveGaugeChart,\n },\n verticalbar: {\n transformer: transformPlotlyJsonToVBCProps,\n renderer: ResponsiveVerticalBarChart,\n },\n area: {\n transformer: transformPlotlyJsonToAreaChartProps,\n renderer: ResponsiveAreaChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n line: {\n transformer: transformPlotlyJsonToLineChartProps,\n renderer: ResponsiveLineChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n scatter: {\n transformer: transformPlotlyJsonToScatterChartProps,\n renderer: ResponsiveScatterChart,\n preTransformOperation: LineAreaPreTransformOp,\n },\n gantt: {\n transformer: transformPlotlyJsonToGanttChartProps,\n renderer: ResponsiveGanttChart,\n },\n funnel: {\n transformer: transformPlotlyJsonToFunnelChartProps,\n renderer: FunnelChart,\n },\n fallback: {\n transformer: transformPlotlyJsonToVSBCProps,\n renderer: ResponsiveVerticalStackedBarChart,\n },\n};\n\nconst useIsDarkTheme = (): boolean => {\n const parentV9Theme = React.useContext(V9ThemeContext) as Theme;\n const v9Theme: Theme = parentV9Theme ? parentV9Theme : webLightTheme;\n\n // Get background and foreground colors\n const backgroundColor = d3Color.hsl(v9Theme.colorNeutralBackground1);\n const foregroundColor = d3Color.hsl(v9Theme.colorNeutralForeground1);\n\n const isDarkTheme = backgroundColor.l < foregroundColor.l;\n\n return isDarkTheme;\n};\n\n/**\n * DeclarativeChart component.\n * {@docCategory DeclarativeChart}\n */\nexport const DeclarativeChart: React.FunctionComponent<DeclarativeChartProps> = React.forwardRef<\n HTMLDivElement,\n DeclarativeChartProps\n>(({ colorwayType = 'default', ...props }, forwardedRef) => {\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n const chart: OutputChartType = mapFluentChart(plotlySchema);\n if (!chart.isValid) {\n throw new Error(`Invalid chart schema: ${chart.errorMessage}`);\n }\n let plotlyInput = plotlySchema as PlotlySchema;\n try {\n plotlyInput = decodeBase64Fields(plotlyInput);\n } catch (error) {\n throw new Error(`Failed to decode plotly schema: ${error}`);\n }\n const plotlyInputWithValidData: PlotlySchema = {\n ...plotlyInput,\n data: chart.validTracesInfo!.map(trace => plotlyInput.data[trace.index]),\n };\n\n const validTracesFilteredIndex: TraceInfo[] = chart.validTracesInfo!.map((trace, index) => ({\n index,\n type: trace.type,\n }));\n\n let { selectedLegends } = plotlySchema;\n const colorMap = useColorMapping();\n const isDarkTheme = useIsDarkTheme();\n const chartRefs = React.useRef<{ compRef: Chart | null; row: number; col: number }[]>([]);\n const isMultiPlot = React.useRef(false);\n const legendsRef = React.useRef<LegendContainer>(null);\n const containerRef = React.useRef<HTMLDivElement>(null);\n const isRTL = useRtl();\n\n if (!isArrayOrTypedArray(selectedLegends)) {\n selectedLegends = [];\n }\n\n const [activeLegends, setActiveLegends] = React.useState<string[]>(selectedLegends);\n const onActiveLegendsChange = (keys: string[]) => {\n setActiveLegends(keys);\n if (props.onSchemaChange) {\n props.onSchemaChange({ plotlySchema: { plotlyInput, selectedLegends: keys } });\n }\n };\n\n React.useEffect(() => {\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { plotlySchema } = sanitizeJson(props.chartSchema);\n // eslint-disable-next-line @typescript-eslint/no-shadow\n const { selectedLegends } = plotlySchema;\n setActiveLegends(selectedLegends ?? []);\n }, [props.chartSchema]);\n\n const multiSelectLegendProps = {\n canSelectMultipleLegends: true,\n onChange: onActiveLegendsChange,\n selectedLegends: activeLegends,\n };\n\n const interactiveCommonProps = {\n legendProps: multiSelectLegendProps,\n };\n\n function createLegends(legendProps: LegendsProps): JSXElement {\n // eslint-disable-next-line react/jsx-no-bind\n return (\n <Legends\n {...legendProps}\n selectedLegends={activeLegends}\n onChange={onActiveLegendsChange}\n legendRef={legendsRef}\n />\n );\n }\n\n const exportAsImage = React.useCallback(\n async (opts?: ImageExportOptions) => {\n if (!containerRef.current) {\n throw new Error('Container reference is null');\n }\n\n const imgExpOpts = {\n background: resolveCSSVariables(containerRef.current, tokens.colorNeutralBackground1),\n scale: 5,\n ...opts,\n };\n\n if (!isMultiPlot.current) {\n if (!chartRefs.current[0]?.compRef?.toImage) {\n throw new Error('Chart cannot be exported as image');\n }\n\n return chartRefs.current[0].compRef.toImage(imgExpOpts);\n }\n\n return exportChartsAsImage(\n chartRefs.current.map(item => ({\n container: item.compRef?.chartContainer,\n row: item.row,\n col: item.col,\n })),\n legendsRef.current?.toSVG,\n isRTL,\n imgExpOpts,\n );\n },\n [isRTL],\n );\n\n React.useImperativeHandle(\n props.componentRef,\n () => ({\n exportAsImage,\n }),\n [exportAsImage],\n );\n\n if (chart.type === 'scatterpolar') {\n const cartesianProjection = projectPolarToCartesian(plotlyInputWithValidData);\n plotlyInputWithValidData.data = cartesianProjection.data;\n plotlyInputWithValidData.layout = cartesianProjection.layout;\n validTracesFilteredIndex.forEach((trace, index) => {\n if (trace.type === 'scatterpolar') {\n const mode = (plotlyInputWithValidData.data[index] as PlotData)?.mode ?? '';\n if (mode.includes('line')) {\n validTracesFilteredIndex[index].type = 'line';\n } else if (mode.includes('markers') || mode === 'text') {\n validTracesFilteredIndex[index].type = 'scatter';\n } else {\n validTracesFilteredIndex[index].type = 'line';\n }\n }\n });\n }\n const groupedTraces: Record<string, number[]> = {};\n let nonCartesianTraceCount = 0;\n\n // For annotation-only charts, create a single group entry\n if (chart.type === 'annotation') {\n groupedTraces[DEFAULT_XAXIS] = [];\n } else {\n plotlyInputWithValidData.data.forEach((trace: Data, index: number) => {\n let traceKey = '';\n if (isNonPlotType(chart.validTracesInfo![index].type)) {\n traceKey = `${NON_PLOT_KEY_PREFIX}${nonCartesianTraceCount + 1}`;\n nonCartesianTraceCount++;\n } else {\n traceKey = (trace as PlotData).xaxis ?? DEFAULT_XAXIS;\n }\n if (!groupedTraces[traceKey]) {\n groupedTraces[traceKey] = [];\n }\n groupedTraces[traceKey].push(index);\n });\n }\n\n isMultiPlot.current = Object.keys(groupedTraces).length > 1;\n const gridProperties: GridProperties = getGridProperties(\n plotlyInputWithValidData,\n isMultiPlot.current,\n chart.validTracesInfo!,\n );\n\n // Render only one plot if the grid properties cannot determine positioning of multiple plots.\n if (\n isMultiPlot.current &&\n gridProperties.templateRows === SINGLE_REPEAT &&\n gridProperties.templateColumns === SINGLE_REPEAT\n ) {\n if (chart.type === 'donut') {\n // If there are multiple data traces for donut/pie, picking the last one similar to plotly\n const keys = Object.keys(groupedTraces);\n keys.forEach((key, index) => {\n if (index < keys.length - 1) {\n delete groupedTraces[key];\n }\n });\n } else {\n Object.keys(groupedTraces).forEach((key, index) => {\n if (index > 0) {\n delete groupedTraces[key];\n }\n });\n }\n isMultiPlot.current = false;\n }\n\n const allupLegendsProps = getAllupLegendsProps(\n plotlyInputWithValidData,\n colorMap,\n colorwayType,\n chart.validTracesInfo!,\n isDarkTheme,\n );\n\n type ChartType = keyof ChartTypeMap;\n // map through the grouped traces and render the appropriate chart\n return (\n <>\n <div\n style={{\n display: 'grid',\n gridTemplateRows: gridProperties.templateRows,\n gridTemplateColumns: gridProperties.templateColumns,\n }}\n ref={containerRef}\n >\n {Object.entries(groupedTraces).map(([xAxisKey, index], chartIdx) => {\n const plotlyInputForGroup: PlotlySchema = {\n ...plotlyInputWithValidData,\n data: index.map(idx => plotlyInputWithValidData.data[idx]),\n };\n\n const filteredTracesInfo = validTracesFilteredIndex.filter(trace => index.includes(trace.index));\n let chartType =\n chart.type === 'fallback' || chart.type === 'groupedverticalbar'\n ? chart.type\n : filteredTracesInfo[0]?.type ?? chart.type;\n\n if (\n validTracesFilteredIndex.some(trace => trace.type === 'line') &&\n validTracesFilteredIndex.some(trace => trace.type === 'scatter')\n ) {\n chartType = 'line';\n }\n\n const chartEntry = chartMap[chartType as ChartType];\n if (chartEntry) {\n const { transformer, renderer, preTransformCondition, preTransformOperation } = chartEntry;\n if (preTransformCondition === undefined || preTransformCondition(plotlyInputForGroup)) {\n const transformedInput = preTransformOperation\n ? preTransformOperation(plotlyInputForGroup)\n : plotlyInputForGroup;\n const cellProperties = gridProperties.layout[xAxisKey];\n\n const resolvedCommonProps = (\n chartType === 'annotation'\n ? {}\n : {\n ...interactiveCommonProps,\n xAxisAnnotation: cellProperties?.xAnnotation,\n yAxisAnnotation: cellProperties?.yAnnotation,\n }\n ) as Partial<ReturnType<typeof transformer>>;\n\n return renderChart<ReturnType<typeof transformer>>(\n renderer,\n transformer,\n [transformedInput, isMultiPlot.current, colorMap, colorwayType, isDarkTheme],\n {\n ...resolvedCommonProps,\n xAxisAnnotation: cellProperties?.xAnnotation,\n yAxisAnnotation: cellProperties?.yAnnotation,\n componentRef: (ref: Chart | null) => {\n chartRefs.current[chartIdx] = {\n compRef: ref,\n row: cellProperties?.row ?? 1,\n col: cellProperties?.column ?? 1,\n };\n },\n },\n cellProperties?.row ?? 1,\n cellProperties?.column ?? 1,\n );\n }\n return <></>;\n } else {\n throw new Error(`Unsupported chart type :${plotlyInputForGroup.data[0]?.type}`);\n }\n })}\n </div>\n {isMultiPlot.current && createLegends(allupLegendsProps)}\n </>\n );\n});\nDeclarativeChart.displayName = 'DeclarativeChart';\n"],"names":["React","decodeBase64Fields","isArrayOrTypedArray","isMonthArray","mapFluentChart","sanitizeJson","tokens","ThemeContext_unstable","V9ThemeContext","webLightTheme","d3Color","correctYearMonth","getGridProperties","isNonPlotType","transformPlotlyJsonToDonutProps","transformPlotlyJsonToVSBCProps","transformPlotlyJsonToAreaChartProps","transformPlotlyJsonToLineChartProps","transformPlotlyJsonToHorizontalBarWithAxisProps","transformPlotlyJsonToHeatmapProps","transformPlotlyJsonToSankeyProps","transformPlotlyJsonToGaugeProps","transformPlotlyJsonToGVBCProps","transformPlotlyJsonToVBCProps","transformPlotlyJsonToChartTableProps","transformPlotlyJsonToScatterChartProps","projectPolarToCartesian","getAllupLegendsProps","NON_PLOT_KEY_PREFIX","SINGLE_REPEAT","transformPlotlyJsonToFunnelChartProps","transformPlotlyJsonToGanttChartProps","transformPlotlyJsonToAnnotationChartProps","AnnotationOnlyChart","DonutChart","VerticalStackedBarChart","LineChart","HorizontalBarChartWithAxis","AreaChart","HeatMapChart","SankeyChart","GaugeChart","GroupedVerticalBarChart","VerticalBarChart","ScatterChart","FunnelChart","GanttChart","withResponsiveContainer","ChartTable","Legends","resolveCSSVariables","useRtl","exportChartsAsImage","ResponsiveDonutChart","ResponsiveVerticalStackedBarChart","ResponsiveLineChart","ResponsiveHorizontalBarChartWithAxis","ResponsiveAreaChart","ResponsiveHeatMapChart","ResponsiveSankeyChart","ResponsiveGaugeChart","ResponsiveGroupedVerticalBarChart","ResponsiveVerticalBarChart","ResponsiveScatterChart","ResponsiveChartTable","ResponsiveGanttChart","DEFAULT_XAXIS","useColorMapping","colorMap","useRef","Map","renderChart","Renderer","transformer","transformerArgs","commonProps","cellRow","cellColumn","chartProps","div","key","style","gridRowStart","gridRowEnd","gridColumnStart","gridColumnEnd","LineAreaPreTransformOp","plotlyInput","xValues","data","x","isXMonth","renderData","map","dataPoint","layout","chartMap","annotation","renderer","donut","sankey","table","horizontalbar","groupedverticalbar","verticalstackedbar","heatmap","gauge","verticalbar","area","preTransformOperation","line","scatter","gantt","funnel","fallback","useIsDarkTheme","parentV9Theme","useContext","v9Theme","backgroundColor","hsl","colorNeutralBackground1","foregroundColor","colorNeutralForeground1","isDarkTheme","l","DeclarativeChart","forwardRef","colorwayType","props","forwardedRef","plotlySchema","chartSchema","chart","isValid","Error","errorMessage","error","plotlyInputWithValidData","validTracesInfo","trace","index","validTracesFilteredIndex","type","selectedLegends","chartRefs","isMultiPlot","legendsRef","containerRef","isRTL","activeLegends","setActiveLegends","useState","onActiveLegendsChange","keys","onSchemaChange","useEffect","multiSelectLegendProps","canSelectMultipleLegends","onChange","interactiveCommonProps","legendProps","createLegends","legendRef","exportAsImage","useCallback","opts","current","imgExpOpts","background","scale","compRef","toImage","item","container","chartContainer","row","col","toSVG","useImperativeHandle","componentRef","cartesianProjection","forEach","mode","includes","groupedTraces","nonCartesianTraceCount","traceKey","xaxis","push","Object","length","gridProperties","templateRows","templateColumns","allupLegendsProps","display","gridTemplateRows","gridTemplateColumns","ref","entries","xAxisKey","chartIdx","filteredTracesInfo","plotlyInputForGroup","idx","filter","chartType","some","chartEntry","preTransformCondition","undefined","transformedInput","cellProperties","resolvedCommonProps","xAxisAnnotation","xAnnotation","yAxisAnnotation","yAnnotation","column","displayName"],"mappings":"AAAA;AAEA,uDAAuD,GACvD,YAAYA,WAAW,QAAQ;AAE/B,SACEC,kBAAkB,EAClBC,mBAAmB,EACnBC,YAAY,EACZC,cAAc,EACdC,YAAY,QACP,4BAA4B;AAEnC,SAASC,MAAM,QAAQ,wBAAwB;AAC/C,SAASC,yBAAyBC,cAAc,QAAQ,kCAAkC;AAC1F,SAAgBC,aAAa,QAAQ,mBAAmB;AACxD,YAAYC,aAAa,WAAW;AAEpC,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,aAAa,EACbC,+BAA+B,EAC/BC,8BAA8B,EAC9BC,mCAAmC,EACnCC,mCAAmC,EACnCC,+CAA+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AAO9I,YACL2B,UACAzB,aACA;oBAAC2I;oBAAkBlE,YAAYqB,OAAO;oBAAEnG;oBAAU4D;oBAAcJ;iBAAY,EAC5E;oBACE,GAAG0F,mBAAmB;oBACtBC,eAAe,EAAEF,2BAAAA,qCAAAA,eAAgBG,WAAW;oBAC5CC,eAAe,EAAEJ,2BAAAA,qCAAAA,eAAgBK,WAAW;oBAC5CtC,cAAc,CAACmB;4BAGNc,qBACAA;wBAHPpE,UAAUsB,OAAO,CAACmC,SAAS,GAAG;4BAC5B/B,SAAS4B;4BACTvB,KAAKqC,CAAAA,sBAAAA,2BAAAA,qCAAAA,eAAgBrC,GAAG,cAAnBqC,iCAAAA,sBAAuB;4BAC5BpC,KAAKoC,CAAAA,yBAAAA,2BAAAA,qCAAAA,eAAgBM,MAAM,cAAtBN,oCAAAA,yBAA0B;wBACjC;oBACF;gBACF,GACAA,CAAAA,sBAAAA,2BAAAA,qCAAAA,eAAgBrC,GAAG,cAAnBqC,iCAAAA,sBAAuB,GACvBA,CAAAA,yBAAAA,2BAAAA,qCAAAA,eAAgBM,MAAM,cAAtBN,oCAAAA,yBAA0B;YAE9B;YACA,qBAAO;QACT,OAAO;gBACsCT;YAA3C,MAAM,IAAIrE,MAAM,CAAC,wBAAwB,GAAEqE,6BAAAA,oBAAoBnH,IAAI,CAAC,EAAE,cAA3BmH,iDAAAA,2BAA6B7D,IAAI,EAAE;QAChF;IACF,KAEDG,YAAYqB,OAAO,IAAIL,cAAciC;AAG5C,GAAG;AACHrE,iBAAiB8F,WAAW,GAAG"}
@@ -85,8 +85,7 @@ function tryMapFluentDataViz(hexColor, templateColorway, isDarkTheme, isDonut) {
85
85
  }
86
86
  return hexColor;
87
87
  }
88
- export const getColor = (legendLabel, // eslint-disable-next-line @typescript-eslint/no-deprecated
89
- colorMap, templateColorway, isDarkTheme, isDonut)=>{
88
+ export const getColor = (legendLabel, colorMap, templateColorway, isDarkTheme, isDonut)=>{
90
89
  if (!colorMap.current.has(legendLabel)) {
91
90
  let nextColor;
92
91
  const defaultColorMapping = isDonut ? templateColorway === 'plotly' ? PLOTLY_FLUENTVIZ_COLORWAY_MAPPING : D3_FLUENTVIZ_COLORWAY_MAPPING : PLOTLY_FLUENTVIZ_COLORWAY_MAPPING;
@@ -101,8 +100,7 @@ colorMap, templateColorway, isDarkTheme, isDonut)=>{
101
100
  }
102
101
  return colorMap.current.get(legendLabel);
103
102
  };
104
- export const getSchemaColors = (colorway, colors, // eslint-disable-next-line @typescript-eslint/no-deprecated
105
- colorMap, isDarkTheme, isDonut)=>{
103
+ export const getSchemaColors = (colorway, colors, colorMap, isDarkTheme, isDonut)=>{
106
104
  const hexColors = [];
107
105
  if (!colors) {
108
106
  return undefined;
@@ -126,12 +124,10 @@ colorMap, isDarkTheme, isDonut)=>{
126
124
  }
127
125
  return hexColors;
128
126
  };
129
- export const extractColor = (colorway, colorwayType, colors, // eslint-disable-next-line @typescript-eslint/no-deprecated
130
- colorMap, isDarkTheme, isDonut)=>{
127
+ export const extractColor = (colorway, colorwayType, colors, colorMap, isDarkTheme, isDonut)=>{
131
128
  return colorwayType === 'default' && colors ? getSchemaColors(colorway, colors, colorMap, isDarkTheme, isDonut) : undefined;
132
129
  };
133
- export const resolveColor = (extractedColors, index, legend, // eslint-disable-next-line @typescript-eslint/no-deprecated
134
- colorMap, colorway, isDarkTheme, isDonut)=>{
130
+ export const resolveColor = (extractedColors, index, legend, colorMap, colorway, isDarkTheme, isDonut)=>{
135
131
  let color = '';
136
132
  const templateColorway = getPlotlyColorway(colorway, isDonut);
137
133
  if (extractedColors && isArrayOrTypedArray(extractedColors) && extractedColors.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/DeclarativeChart/PlotlyColorAdapter.ts"],"sourcesContent":["import * as React from 'react';\nimport { color as d3Color } from 'd3-color';\nimport type { PieColors, Color, PlotData, Layout } from '@fluentui/chart-utilities';\nimport { isArrayOrTypedArray } from '@fluentui/chart-utilities';\nimport { areArraysEqual } from '../../utilities/utilities';\nimport { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';\nimport { scaleLinear as d3ScaleLinear } from 'd3-scale';\n\ntype PlotlyColorway = 'plotly' | 'd3' | 'others';\n\n// The color sequences in plotly express are defined here:\n// https://plotly.com/python/discrete-color/#:~:text=Join%20now.-,Color%20Sequences%20in%20Plotly%20Express,-By%20default%2C%20Plotly\nexport type ColorwayType = 'default' | 'builtin' | 'others' | undefined;\n\nconst DEFAULT_PLOTLY_COLORWAY = [\n '#636efa', //1\n '#ef553b', //2\n '#00cc96', //3\n '#ab63fa', //4\n '#ffa15a', //5\n '#19d3f3', //6\n '#ff6692', //7\n '#b6e880', //8\n '#ff97ff', //9\n '#fecb52', //10\n];\n\n// Default D3 qualitative colorway (Category10), matching Plotly Express px.colors.qualitative.D3\n// Source: https://plotly.com/python/discrete-color/#:~:text=Join%20now.-,Color%20Sequences%20in%20Plotly%20Express,-By%20default%2C%20Plotly\nexport const DEFAULT_D3_COLORWAY = [\n '#1f77b4', //1\n '#ff7f0e', //2\n '#2ca02c', //3\n '#d62728', //4\n '#9467bd', //5\n '#8c564b', //6\n '#e377c2', //7\n '#7f7f7f', //8\n '#bcbd22', //9\n '#17becf', //10\n];\n\nconst PLOTLY_FLUENTVIZ_COLORWAY_MAPPING = [\n DataVizPalette.color1, //1\n DataVizPalette.warning, //2\n DataVizPalette.color8, //3\n DataVizPalette.color4, //4\n DataVizPalette.color7, //5\n DataVizPalette.color6, //6\n DataVizPalette.color2, //7\n DataVizPalette.color5, //8\n DataVizPalette.color9, //9\n DataVizPalette.color10, //10\n];\n\n// Mapping from D3 Category10 order to Fluent DataViz tokens (light/dark handled via getColorFromToken)\n// D3: [blue, orange, green, red, purple, brown, pink, gray, olive, cyan]\nexport const D3_FLUENTVIZ_COLORWAY_MAPPING: string[] = [\n DataVizPalette.color26, // blue -> lightBlue.shade10\n DataVizPalette.warning, // orange -> semantic warning\n DataVizPalette.color5, // green -> lightGreen.primary\n DataVizPalette.error, // red -> semantic error\n DataVizPalette.color4, // purple -> orchid.tint10\n DataVizPalette.color17, // brown -> pumpkin.shade20\n DataVizPalette.color22, // pink -> hotPink.tint20\n DataVizPalette.disabled, // gray -> semantic disabled\n DataVizPalette.color10, // olive/yellow-green -> gold.shade10\n DataVizPalette.color3, // cyan/teal -> teal.tint20\n];\n\nfunction getPlotlyColorway(colorway: string[] | undefined, isDonut: boolean = false): PlotlyColorway {\n if (!colorway || !isArrayOrTypedArray(colorway)) {\n return 'others';\n }\n const lower = colorway.map(c => c.toLowerCase());\n if (isDonut && areArraysEqual(lower, D3_FLUENTVIZ_COLORWAY_MAPPING)) {\n return 'd3';\n }\n if (areArraysEqual(lower, DEFAULT_PLOTLY_COLORWAY)) {\n return 'plotly';\n }\n return 'others';\n}\n\nfunction tryMapFluentDataViz(\n hexColor: string,\n templateColorway: PlotlyColorway,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string {\n if (templateColorway !== 'plotly') {\n return hexColor;\n }\n let defaultColorway: string[] = DEFAULT_PLOTLY_COLORWAY;\n let defaultMapping: string[] = PLOTLY_FLUENTVIZ_COLORWAY_MAPPING;\n if (isDonut) {\n defaultColorway = templateColorway === 'plotly' ? DEFAULT_PLOTLY_COLORWAY : DEFAULT_D3_COLORWAY;\n defaultMapping = templateColorway === 'plotly' ? PLOTLY_FLUENTVIZ_COLORWAY_MAPPING : D3_FLUENTVIZ_COLORWAY_MAPPING;\n }\n const idx = defaultColorway.indexOf(hexColor.toLowerCase());\n if (idx !== -1) {\n return getColorFromToken(defaultMapping[idx], !!isDarkTheme);\n }\n return hexColor;\n}\n\nexport const getColor = (\n legendLabel: string,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n colorMap: React.MutableRefObject<Map<string, string>>,\n templateColorway: PlotlyColorway,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string => {\n if (!colorMap.current.has(legendLabel)) {\n let nextColor: string;\n const defaultColorMapping = isDonut\n ? templateColorway === 'plotly'\n ? PLOTLY_FLUENTVIZ_COLORWAY_MAPPING\n : D3_FLUENTVIZ_COLORWAY_MAPPING\n : PLOTLY_FLUENTVIZ_COLORWAY_MAPPING;\n if (colorMap.current.size < defaultColorMapping.length) {\n // Get first 10 colors from plotly-fluentviz colorway mapping\n nextColor = getColorFromToken(defaultColorMapping[colorMap.current.size], isDarkTheme);\n } else {\n nextColor = getNextColor(colorMap.current.size, 0, isDarkTheme);\n }\n colorMap.current.set(legendLabel, nextColor);\n return nextColor;\n }\n\n return colorMap.current.get(legendLabel) as string;\n};\n\nexport const getSchemaColors = (\n colorway: string[] | undefined,\n colors: PieColors | Color | Color[] | string | null | undefined,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string[] | string | undefined => {\n const hexColors: string[] = [];\n if (!colors) {\n return undefined;\n }\n const templateColorway = getPlotlyColorway(colorway, isDonut);\n if (isArrayOrTypedArray(colors)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (colors as any[]).forEach((element, index) => {\n const colorString = element?.toString().trim();\n const nextFluentColor = getColor(`Label_${index}`, colorMap, templateColorway, isDarkTheme, isDonut);\n if (colorString) {\n const parsedColor = d3Color(colorString);\n hexColors.push(\n parsedColor ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme) : nextFluentColor,\n );\n } else {\n hexColors.push(nextFluentColor);\n }\n });\n } else if (typeof colors === 'string') {\n const parsedColor = d3Color(colors);\n return parsedColor\n ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme)\n : getColor('Label_0', colorMap, templateColorway, isDarkTheme, isDonut);\n }\n return hexColors;\n};\n\nexport const extractColor = (\n colorway: string[] | undefined,\n colorwayType: ColorwayType,\n colors: PieColors | Color | Color[] | string | null | undefined,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n colorMap: React.MutableRefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string | string[] | undefined => {\n return colorwayType === 'default' && colors\n ? getSchemaColors(colorway, colors, colorMap, isDarkTheme, isDonut)\n : undefined;\n};\n\nexport const resolveColor = (\n extractedColors: string[] | string | null | undefined,\n index: number,\n legend: string,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n colorMap: React.MutableRefObject<Map<string, string>>,\n colorway: string[] | undefined,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string => {\n let color = '';\n const templateColorway = getPlotlyColorway(colorway, isDonut);\n if (extractedColors && isArrayOrTypedArray(extractedColors) && extractedColors.length > 0) {\n color = extractedColors[index % extractedColors.length];\n } else if (typeof extractedColors === 'string') {\n color = extractedColors;\n } else {\n color = getColor(legend, colorMap, templateColorway, isDarkTheme, isDonut);\n }\n return color;\n};\n\nexport const getOpacity = (series: Partial<PlotData>, index: number): number => {\n return series.marker?.opacity\n ? isArrayOrTypedArray(series.marker?.opacity)\n ? (series.marker?.opacity as number[])[index % (series.marker?.opacity as number[]).length]\n : (series.marker?.opacity as number)\n : series.opacity ?? 1;\n};\n\nexport const createColorScale = (\n layout: Partial<Layout> | undefined,\n series: Partial<PlotData>,\n currentColorScale: ((value: number) => string) | undefined,\n): ((value: number) => string) | undefined => {\n if (\n layout?.coloraxis?.colorscale?.length &&\n isArrayOrTypedArray(series.marker?.color) &&\n (series.marker?.color as Color[]).length > 0 &&\n typeof (series.marker?.color as Color[])?.[0] === 'number'\n ) {\n const scale = layout?.coloraxis?.colorscale as Array<[number, string]>;\n const colorValues = series.marker?.color as number[];\n const [dMin, dMax] = [\n layout?.coloraxis?.cmin ?? Math.min(...colorValues),\n layout?.coloraxis?.cmax ?? Math.max(...colorValues),\n ];\n\n // Normalize colorscale domain to actual data domain\n const scaleDomain = scale.map(([pos]) => dMin + pos * (dMax - dMin));\n const scaleColors = scale.map(item => item[1]);\n\n return d3ScaleLinear<string>().domain(scaleDomain).range(scaleColors);\n }\n return currentColorScale;\n};\n"],"names":["React","color","d3Color","isArrayOrTypedArray","areArraysEqual","DataVizPalette","getColorFromToken","getNextColor","scaleLinear","d3ScaleLinear","DEFAULT_PLOTLY_COLORWAY","DEFAULT_D3_COLORWAY","PLOTLY_FLUENTVIZ_COLORWAY_MAPPING","color1","warning","color8","color4","color7","color6","color2","color5","color9","color10","D3_FLUENTVIZ_COLORWAY_MAPPING","color26","error","color17","color22","disabled","color3","getPlotlyColorway","colorway","isDonut","lower","map","c","toLowerCase","tryMapFluentDataViz","hexColor","templateColorway","isDarkTheme","defaultColorway","defaultMapping","idx","indexOf","getColor","legendLabel","colorMap","current","has","nextColor","defaultColorMapping","size","length","set","get","getSchemaColors","colors","hexColors","undefined","forEach","element","index","colorString","toString","trim","nextFluentColor","parsedColor","push","formatHex","extractColor","colorwayType","resolveColor","extractedColors","legend","getOpacity","series","marker","opacity","createColorScale","layout","currentColorScale","coloraxis","colorscale","scale","colorValues","dMin","dMax","cmin","Math","min","cmax","max","scaleDomain","pos","scaleColors","item","domain","range"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,SAASC,OAAO,QAAQ,WAAW;AAE5C,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,cAAc,EAAEC,iBAAiB,EAAEC,YAAY,QAAQ,yBAAyB;AACzF,SAASC,eAAeC,aAAa,QAAQ,WAAW;AAQxD,MAAMC,0BAA0B;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,iGAAiG;AACjG,6IAA6I;AAC7I,OAAO,MAAMC,sBAAsB;IACjC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC;AAEF,MAAMC,oCAAoC;IACxCP,eAAeQ,MAAM;IACrBR,eAAeS,OAAO;IACtBT,eAAeU,MAAM;IACrBV,eAAeW,MAAM;IACrBX,eAAeY,MAAM;IACrBZ,eAAea,MAAM;IACrBb,eAAec,MAAM;IACrBd,eAAee,MAAM;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AACJ,aAAaK,KAAK,CAACH;IAC3D;IACA,OAAOd;AACT,EAAE"}
1
+ {"version":3,"sources":["../src/components/DeclarativeChart/PlotlyColorAdapter.ts"],"sourcesContent":["import * as React from 'react';\nimport { color as d3Color } from 'd3-color';\nimport type { PieColors, Color, PlotData, Layout } from '@fluentui/chart-utilities';\nimport { isArrayOrTypedArray } from '@fluentui/chart-utilities';\nimport { areArraysEqual } from '../../utilities/utilities';\nimport { DataVizPalette, getColorFromToken, getNextColor } from '../../utilities/colors';\nimport { scaleLinear as d3ScaleLinear } from 'd3-scale';\n\ntype PlotlyColorway = 'plotly' | 'd3' | 'others';\n\n// The color sequences in plotly express are defined here:\n// https://plotly.com/python/discrete-color/#:~:text=Join%20now.-,Color%20Sequences%20in%20Plotly%20Express,-By%20default%2C%20Plotly\nexport type ColorwayType = 'default' | 'builtin' | 'others' | undefined;\n\nconst DEFAULT_PLOTLY_COLORWAY = [\n '#636efa', //1\n '#ef553b', //2\n '#00cc96', //3\n '#ab63fa', //4\n '#ffa15a', //5\n '#19d3f3', //6\n '#ff6692', //7\n '#b6e880', //8\n '#ff97ff', //9\n '#fecb52', //10\n];\n\n// Default D3 qualitative colorway (Category10), matching Plotly Express px.colors.qualitative.D3\n// Source: https://plotly.com/python/discrete-color/#:~:text=Join%20now.-,Color%20Sequences%20in%20Plotly%20Express,-By%20default%2C%20Plotly\nexport const DEFAULT_D3_COLORWAY = [\n '#1f77b4', //1\n '#ff7f0e', //2\n '#2ca02c', //3\n '#d62728', //4\n '#9467bd', //5\n '#8c564b', //6\n '#e377c2', //7\n '#7f7f7f', //8\n '#bcbd22', //9\n '#17becf', //10\n];\n\nconst PLOTLY_FLUENTVIZ_COLORWAY_MAPPING = [\n DataVizPalette.color1, //1\n DataVizPalette.warning, //2\n DataVizPalette.color8, //3\n DataVizPalette.color4, //4\n DataVizPalette.color7, //5\n DataVizPalette.color6, //6\n DataVizPalette.color2, //7\n DataVizPalette.color5, //8\n DataVizPalette.color9, //9\n DataVizPalette.color10, //10\n];\n\n// Mapping from D3 Category10 order to Fluent DataViz tokens (light/dark handled via getColorFromToken)\n// D3: [blue, orange, green, red, purple, brown, pink, gray, olive, cyan]\nexport const D3_FLUENTVIZ_COLORWAY_MAPPING: string[] = [\n DataVizPalette.color26, // blue -> lightBlue.shade10\n DataVizPalette.warning, // orange -> semantic warning\n DataVizPalette.color5, // green -> lightGreen.primary\n DataVizPalette.error, // red -> semantic error\n DataVizPalette.color4, // purple -> orchid.tint10\n DataVizPalette.color17, // brown -> pumpkin.shade20\n DataVizPalette.color22, // pink -> hotPink.tint20\n DataVizPalette.disabled, // gray -> semantic disabled\n DataVizPalette.color10, // olive/yellow-green -> gold.shade10\n DataVizPalette.color3, // cyan/teal -> teal.tint20\n];\n\nfunction getPlotlyColorway(colorway: string[] | undefined, isDonut: boolean = false): PlotlyColorway {\n if (!colorway || !isArrayOrTypedArray(colorway)) {\n return 'others';\n }\n const lower = colorway.map(c => c.toLowerCase());\n if (isDonut && areArraysEqual(lower, D3_FLUENTVIZ_COLORWAY_MAPPING)) {\n return 'd3';\n }\n if (areArraysEqual(lower, DEFAULT_PLOTLY_COLORWAY)) {\n return 'plotly';\n }\n return 'others';\n}\n\nfunction tryMapFluentDataViz(\n hexColor: string,\n templateColorway: PlotlyColorway,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string {\n if (templateColorway !== 'plotly') {\n return hexColor;\n }\n let defaultColorway: string[] = DEFAULT_PLOTLY_COLORWAY;\n let defaultMapping: string[] = PLOTLY_FLUENTVIZ_COLORWAY_MAPPING;\n if (isDonut) {\n defaultColorway = templateColorway === 'plotly' ? DEFAULT_PLOTLY_COLORWAY : DEFAULT_D3_COLORWAY;\n defaultMapping = templateColorway === 'plotly' ? PLOTLY_FLUENTVIZ_COLORWAY_MAPPING : D3_FLUENTVIZ_COLORWAY_MAPPING;\n }\n const idx = defaultColorway.indexOf(hexColor.toLowerCase());\n if (idx !== -1) {\n return getColorFromToken(defaultMapping[idx], !!isDarkTheme);\n }\n return hexColor;\n}\n\nexport const getColor = (\n legendLabel: string,\n colorMap: React.RefObject<Map<string, string>>,\n templateColorway: PlotlyColorway,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string => {\n if (!colorMap.current!.has(legendLabel)) {\n let nextColor: string;\n const defaultColorMapping = isDonut\n ? templateColorway === 'plotly'\n ? PLOTLY_FLUENTVIZ_COLORWAY_MAPPING\n : D3_FLUENTVIZ_COLORWAY_MAPPING\n : PLOTLY_FLUENTVIZ_COLORWAY_MAPPING;\n if (colorMap.current!.size < defaultColorMapping.length) {\n // Get first 10 colors from plotly-fluentviz colorway mapping\n nextColor = getColorFromToken(defaultColorMapping[colorMap.current!.size], isDarkTheme);\n } else {\n nextColor = getNextColor(colorMap.current!.size, 0, isDarkTheme);\n }\n colorMap.current!.set(legendLabel, nextColor);\n return nextColor;\n }\n\n return colorMap.current!.get(legendLabel) as string;\n};\n\nexport const getSchemaColors = (\n colorway: string[] | undefined,\n colors: PieColors | Color | Color[] | string | null | undefined,\n colorMap: React.RefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string[] | string | undefined => {\n const hexColors: string[] = [];\n if (!colors) {\n return undefined;\n }\n const templateColorway = getPlotlyColorway(colorway, isDonut);\n if (isArrayOrTypedArray(colors)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (colors as any[]).forEach((element, index) => {\n const colorString = element?.toString().trim();\n const nextFluentColor = getColor(`Label_${index}`, colorMap, templateColorway, isDarkTheme, isDonut);\n if (colorString) {\n const parsedColor = d3Color(colorString);\n hexColors.push(\n parsedColor ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme) : nextFluentColor,\n );\n } else {\n hexColors.push(nextFluentColor);\n }\n });\n } else if (typeof colors === 'string') {\n const parsedColor = d3Color(colors);\n return parsedColor\n ? tryMapFluentDataViz(parsedColor.formatHex(), templateColorway, isDarkTheme)\n : getColor('Label_0', colorMap, templateColorway, isDarkTheme, isDonut);\n }\n return hexColors;\n};\n\nexport const extractColor = (\n colorway: string[] | undefined,\n colorwayType: ColorwayType,\n colors: PieColors | Color | Color[] | string | null | undefined,\n colorMap: React.RefObject<Map<string, string>>,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string | string[] | undefined => {\n return colorwayType === 'default' && colors\n ? getSchemaColors(colorway, colors, colorMap, isDarkTheme, isDonut)\n : undefined;\n};\n\nexport const resolveColor = (\n extractedColors: string[] | string | null | undefined,\n index: number,\n legend: string,\n colorMap: React.RefObject<Map<string, string>>,\n colorway: string[] | undefined,\n isDarkTheme?: boolean,\n isDonut?: boolean,\n): string => {\n let color = '';\n const templateColorway = getPlotlyColorway(colorway, isDonut);\n if (extractedColors && isArrayOrTypedArray(extractedColors) && extractedColors.length > 0) {\n color = extractedColors[index % extractedColors.length];\n } else if (typeof extractedColors === 'string') {\n color = extractedColors;\n } else {\n color = getColor(legend, colorMap, templateColorway, isDarkTheme, isDonut);\n }\n return color;\n};\n\nexport const getOpacity = (series: Partial<PlotData>, index: number): number => {\n return series.marker?.opacity\n ? isArrayOrTypedArray(series.marker?.opacity)\n ? (series.marker?.opacity as number[])[index % (series.marker?.opacity as number[]).length]\n : (series.marker?.opacity as number)\n : series.opacity ?? 1;\n};\n\nexport const createColorScale = (\n layout: Partial<Layout> | undefined,\n series: Partial<PlotData>,\n currentColorScale: ((value: number) => string) | undefined,\n): ((value: number) => string) | undefined => {\n if (\n layout?.coloraxis?.colorscale?.length &&\n isArrayOrTypedArray(series.marker?.color) &&\n (series.marker?.color as Color[]).length > 0 &&\n typeof (series.marker?.color as Color[])?.[0] === 'number'\n ) {\n const scale = layout?.coloraxis?.colorscale as Array<[number, string]>;\n const colorValues = series.marker?.color as number[];\n const [dMin, dMax] = [\n layout?.coloraxis?.cmin ?? Math.min(...colorValues),\n layout?.coloraxis?.cmax ?? Math.max(...colorValues),\n ];\n\n // Normalize colorscale domain to actual data domain\n const scaleDomain = scale.map(([pos]) => dMin + pos * (dMax - dMin));\n const scaleColors = scale.map(item => item[1]);\n\n return d3ScaleLinear<string>().domain(scaleDomain).range(scaleColors);\n }\n return currentColorScale;\n};\n"],"names":["React","color","d3Color","isArrayOrTypedArray","areArraysEqual","DataVizPalette","getColorFromToken","getNextColor","scaleLinear","d3ScaleLinear","DEFAULT_PLOTLY_COLORWAY","DEFAULT_D3_COLORWAY","PLOTLY_FLUENTVIZ_COLORWAY_MAPPING","color1","warning","color8","color4","color7","color6","color2","color5","color9","color10","D3_FLUENTVIZ_COLORWAY_MAPPING","color26","error","color17","color22","disabled","color3","getPlotlyColorway","colorway","isDonut","lower","map","c","toLowerCase","tryMapFluentDataViz","hexColor","templateColorway","isDarkTheme","defaultColorway","defaultMapping","idx","indexOf","getColor","legendLabel","colorMap","current","has","nextColor","defaultColorMapping","size","length","set","get","getSchemaColors","colors","hexColors","undefined","forEach","element","index","colorString","toString","trim","nextFluentColor","parsedColor","push","formatHex","extractColor","colorwayType","resolveColor","extractedColors","legend","getOpacity","series","marker","opacity","createColorScale","layout","currentColorScale","coloraxis","colorscale","scale","colorValues","dMin","dMax","cmin","Math","min","cmax","max","scaleDomain","pos","scaleColors","item","domain","range"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,SAASC,OAAO,QAAQ,WAAW;AAE5C,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAASC,cAAc,EAAEC,iBAAiB,EAAEC,YAAY,QAAQ,yBAAyB;AACzF,SAASC,eAAeC,aAAa,QAAQ,WAAW;AAQxD,MAAMC,0BAA0B;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,iGAAiG;AACjG,6IAA6I;AAC7I,OAAO,MAAMC,sBAAsB;IACjC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC;AAEF,MAAMC,oCAAoC;IACxCP,eAAeQ,MAAM;IACrBR,eAAeS,OA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